summaryrefslogtreecommitdiff
path: root/engine/sine.asm
blob: e22d785af791d8d5074d4ef970dfb647f1238b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
_Sine:: ; 8ac9 (2:4ac9)
	ld a, e
	and $3f
	cp $20
	jr nc, .negative
	call .GetSine
	ld a, h
	ret
.negative
	and $1f
	call .GetSine
	ld a, h
	xor $ff
	inc a
	ret

.GetSine: ; 8adf (2:4adf)
	ld e, a
	ld a, d
	ld d, $0
	ld hl, .SineWave
	add hl, de
	add hl, de
	ld e, [hl]
	inc hl
	ld d, [hl]
	ld hl, $0
.loop
	srl a
	jr nc, .no_add
	add hl, de
.no_add
	sla e
	rl d
	and a
	jr nz, .loop
	ret

.SineWave:
	sine_table $100