gb_test2

changeset 1:d63782badb6b

nicer distortion
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 10 Jan 2019 04:47:42 +0200
parents cacfa0888410
children a8b7297e7e2c
files Makefile test.asm
diffstat 2 files changed, 44 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Thu Jan 10 04:16:47 2019 +0200
     1.2 +++ b/Makefile	Thu Jan 10 04:47:42 2019 +0200
     1.3 @@ -19,8 +19,12 @@
     1.4  clean:
     1.5  	rm -f $(obj) $(bin) $(img)
     1.6  
     1.7 +.PHONY: run
     1.8 +run: $(img)
     1.9 +	sameboy $<
    1.10 +
    1.11  logo.tiles: logo.png
    1.12  	rgbgfx -T -u -o $@ $<
    1.13  
    1.14 -sin.inc:
    1.15 +sin.inc: gensine
    1.16  	./gensine >$@
     2.1 --- a/test.asm	Thu Jan 10 04:16:47 2019 +0200
     2.2 +++ b/test.asm	Thu Jan 10 04:47:42 2019 +0200
     2.3 @@ -46,17 +46,52 @@
     2.4  
     2.5  	xor a, a
     2.6  	ld b, a
     2.7 +
     2.8  	ldh a, [REG_LY]
     2.9 -	add a, d
    2.10 +	add a, d	; add frame number
    2.11  	ld c, a
    2.12  
    2.13  	ld hl, sintab
    2.14 -	add hl, bc	; hl points to sin value (0-64)
    2.15 +	add hl, bc	; hl now points to the sine value
    2.16  
    2.17 -	ld a, yoffs_center
    2.18 -	add a, [hl]
    2.19 +	ld a, [hl]
    2.20 +
    2.21 +	; add a half-octave sine
    2.22 +	ld e, a		; save first sine to e
    2.23 +	sla d
    2.24 +	ld a, [REG_LY]
    2.25 +	sla a
    2.26 +	add a, d
    2.27 +	ld c, a
    2.28 +	srl d
    2.29 +
    2.30 +	ld hl, sintab
    2.31 +	add hl, bc
    2.32 +	ld a, [hl]
    2.33 +	sra a
    2.34 +	add a, e	; add previously saved sine
    2.35 +
    2.36 +	add a, yoffs_center
    2.37  	ldh [REG_SCY], a
    2.38  
    2.39 +	; do something for SCX too
    2.40 +	ld a, d
    2.41 +	sla a
    2.42 +	ld d, a
    2.43 +
    2.44 +	ldh a, [REG_LY]
    2.45 +	add a, 32
    2.46 +	add a, d	; add frame number
    2.47 +	ld c, a
    2.48 +
    2.49 +	ld hl, sintab
    2.50 +	add hl, bc
    2.51 +
    2.52 +	ld a, [hl]
    2.53 +	sra a
    2.54 +	add a, xoffs_center
    2.55 +	ldh [REG_SCX], a
    2.56 +
    2.57  	; done, wait until we're out of hsync
    2.58  .wait_endhsync:
    2.59  	ldh a, [REG_STAT]