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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
;****************************************************************************
; Channel ID constants
;****************************************************************************
ESF_FM1 equ $00 ; FM channel #1
ESF_FM2 equ $01 ; FM channel #2
ESF_FM3 equ $02 ; FM channel #3
ESF_FM4 equ $04 ; FM channel #4
ESF_FM5 equ $05 ; FM channel #5
ESF_FM6 equ $06 ; FM channel #6
ESF_PSG1 equ $08 ; PSG square channel #1
ESF_PSG2 equ $09 ; PSG square channel #2
ESF_PSG3 equ $0A ; PSG square channel #3
ESF_PSG4 equ $0B ; PSG noise channel
ESF_PCM equ $0C ; PCM channel
;****************************************************************************
; ESF_NoteOn
; Start playing a note.
;----------------------------------------------------------------------------
; For FM channels:
; ESF_NoteOn channel, octave, semitone
; For square PSG channels:
; ESF_NoteOn channel, octave, semitone
; For noise PSG channel:
; ESF_NoteOn channel, type
; For PCM channel:
; ESF_NoteOn channel, instrument
;----------------------------------------------------------------------------
; param channel ...... channel to play on
; param octave ....... octave (0 to 7 for FM, 0 to 5 for PSG)
; param semitone ..... semitone (0 to 11)
; param type ......... noise type ($00 to $07)
; param instrument ... drum instrument ID ($00 to $FF)
;****************************************************************************
ESF_NoteOn macro
dc.b $00+(\1)
if (\1)<ESF_PSG1
dc.b (\2)*32+(\3)*2+1
elseif (\1)<ESF_PSG4
dc.b (\2)*24+(\3)*2
else
dc.b \2
endc
endm
;****************************************************************************
; ESF_NoteOff
; Stop playing a note.
;----------------------------------------------------------------------------
; Format:
; ESF_NoteOff channel
;----------------------------------------------------------------------------
; param channel ...... channel to stop
;****************************************************************************
ESF_NoteOff macro
dc.b $10+(\1)
endm
;****************************************************************************
; ESF_SetVol
; Set the volume of a channel.
;----------------------------------------------------------------------------
; Format:
; ESF_SetVol channel, volume
;----------------------------------------------------------------------------
; param channel ... channel to modify
; param volume .... new volume ($00 to $7F for FM, $00 to $0F for PSG)
;****************************************************************************
ESF_SetVol macro
dc.b $20+(\1)
dc.b (\2)
endm
;****************************************************************************
; ESF_SetFreq
; Sets the frequency of a channel (allows note slides).
;----------------------------------------------------------------------------
; For FM channels:
; ESF_SetFreq channel, octave, frequency
; For square PSG channels:
; ESF_SetFreq channel, frequency
; For noise PSG channel:
; ESF_SetFreq channel, type
;----------------------------------------------------------------------------
; param channel ..... affected channel
; param octave ...... octave
; param frequency ... frequency (0 to $7FF for FM, 0 to $3FF for PSG)
; param type ........ noise type ($00 to $07)
;****************************************************************************
ESF_SetFreq macro
dc.b $30+(\1)
if (\1)<ESF_PSG1
dc.b ((\2)<<3)|((\3)>>8)
dc.b (\3)&$FF
elseif (\1)<ESF_PSG4
dc.b (\2)&$0F
dc.b (\2)>>6
else
dc.b (\2)
endc
endm
;****************************************************************************
; ESF_SetInstr
; Set the instrument of a channel.
;----------------------------------------------------------------------------
; Format:
; ESF_SetInstr channel, instrument
;----------------------------------------------------------------------------
; param channel ...... Channel to lock
; param instrument ... Instrument ID ($00 to $FF)
;****************************************************************************
ESF_SetInstr macro
dc.b $40+(\1)
dc.b (\2)
endm
;****************************************************************************
; ESF_Lock
; Lock SFX channel.
;----------------------------------------------------------------------------
; Format:
; ESF_Lock channel
;----------------------------------------------------------------------------
; param channel ... Channel to lock
;****************************************************************************
ESF_Lock macro
dc.b $E0
dc.b (\1)
endm
;****************************************************************************
; ESF_Delay
; Stop event.
;----------------------------------------------------------------------------
; Format:
; ESF_Delay ticks
;----------------------------------------------------------------------------
; param ticks ... Ticks to wait (60 = 1 second)
;****************************************************************************
ESF_Delay macro
dc.b $FE
dc.b (\1)
endm
;****************************************************************************
; ESF_Stop
; Stop event.
;****************************************************************************
ESF_Stop macro
dc.b $FF
endm
|