-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmusic.asm
61 lines (55 loc) · 827 Bytes
/
music.asm
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.ifndef MUSIC_INC
MUSIC_INC = 1
OPM_DELAY_REG = 2
OPM_DONE_REG = 4
__music_delay: .byte 0
.macro INC_MUSIC_PTR
clc
lda MUSIC_PTR
adc #2
sta MUSIC_PTR
lda MUSIC_PTR+1
adc #0
sta MUSIC_PTR+1
.endmacro
init_music:
stz __music_delay
lda #<RAM_WIN
sta MUSIC_PTR
lda #>RAM_WIN
sta MUSIC_PTR+1
rts
music_tick:
lda __music_delay
beq @load
dec __music_delay
bra @return
@load:
lda #MUSIC_BANK
sta RAM_BANK
@loop:
ldy #0
lda (MUSIC_PTR),y
iny
cmp #OPM_DELAY_REG
beq @delay
cmp #OPM_DONE_REG
beq @done
bra @write
@delay:
lda (MUSIC_PTR),y
sta __music_delay
INC_MUSIC_PTR
bra @return
@done:
jsr init_music
bra @return
@write:
sta YM_reg
lda (MUSIC_PTR),y
sta YM_data
INC_MUSIC_PTR
bra @loop
@return:
rts
.endif