-
Notifications
You must be signed in to change notification settings - Fork 1
/
vgm_effect.asm
130 lines (101 loc) · 4.24 KB
/
vgm_effect.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
; *****************************************************************************
; * Play a special effect using the SN76489
; *****************************************************************************
play_effect .macro
.as
LDX \1
CPX #0
BEQ PE_READ_COMMAND
DEX
STX \1
RTS
PE_READ_COMMAND
LDA [\2]
increment_long_addr \2
CMP #$50
BNE PE_CHK_WAIT_50th
LDA [\2]
STA PSG_BASE_ADDRESS
increment_long_addr \2
BRA PE_DONE ; for some reason, this chip needs more time between writes
PE_CHK_WAIT_50th
CMP #$62
BNE PE_CHK_WAIT_60th
LDX #$2df
STX \1
BRA PE_DONE
PE_CHK_WAIT_60th
CMP #$63
BNE PE_CHK_END_SONG
LDX #$372
STX \1
BRA PE_DONE
PE_CHK_END_SONG
CMP #$66 ; end of song
BNE PE_DONE
LDA EFFECT_PLAY
AND #~(\3)
STA EFFECT_PLAY ; effect is done
PE_DONE
RTS
.endm
PLAY_T_EFFECT
.play_effect EFFECT_T_WAIT_CNTR, EFFECT_T_POSITION, TILE_EFFECT
PLAY_L_EFFECT
.play_effect EFFECT_L_WAIT_CNTR, EFFECT_L_POSITION, LINE_EFFECT
PLAY_R_EFFECT
.play_effect EFFECT_R_WAIT_CNTR, EFFECT_R_POSITION, ROTATE_EFFECT
; *****************************************************************************
; * Setup the Tile Down Effect
; *****************************************************************************
PLAY_EFFECT_TILE_DOWN
.as
LDX #<>VGM_EFFECT_DROP + $40 ; we know the offset already
STX EFFECT_T_POSITION
LDA #`VGM_EFFECT_DROP + $40
STA EFFECT_T_POSITION + 2
LDX #0
STX EFFECT_T_WAIT_CNTR
LDA EFFECT_PLAY
ORA #TILE_EFFECT
STA EFFECT_PLAY
; enable the TIMER1 interrupt
;LDA #~( FNX0_INT00_SOF | FNX0_INT02_TMR0 | FNX0_INT03_TMR1 )
;STA @lINT_MASK_REG0
RTS
; *****************************************************************************
; * Setup the Line Effect
; *****************************************************************************
PLAY_EFFECT_LINE
.as
LDX #<>VGM_EFFECT_LINE + $40 ; we know the offset already
STX EFFECT_L_POSITION
LDA #`VGM_EFFECT_LINE + $40
STA EFFECT_L_POSITION + 2
LDX #0
STX EFFECT_L_WAIT_CNTR
LDA EFFECT_PLAY
ORA #LINE_EFFECT
STA EFFECT_PLAY
; enable the TIMER1 interrupt
;LDA #~( FNX0_INT00_SOF | FNX0_INT02_TMR0 | FNX0_INT03_TMR1 )
;STA @lINT_MASK_REG0
RTS
; *****************************************************************************
; * Setup the Rotate Effect
; *****************************************************************************
PLAY_EFFECT_ROTATE
.as
LDX #<>VGM_EFFECT_ROTATE + $40 ; we know the offset already
STX EFFECT_R_POSITION
LDA #`VGM_EFFECT_ROTATE + $40
STA EFFECT_R_POSITION + 2
LDX #0
STX EFFECT_R_WAIT_CNTR
LDA EFFECT_PLAY
ORA #ROTATE_EFFECT
STA EFFECT_PLAY
; enable the TIMER1 interrupt
;LDA #~( FNX0_INT00_SOF | FNX0_INT02_TMR0 | FNX0_INT03_TMR1 )
;STA @lINT_MASK_REG0
RTS