-
Notifications
You must be signed in to change notification settings - Fork 5
/
smps-z80-ristar-simple-pcm.asm
278 lines (205 loc) · 5.77 KB
/
smps-z80-ristar-simple-pcm.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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
; ---------------------------------------------------------------------------
sample_entry struc ; (sizeof=0xA)
playing: db ?
id: db ?
bank: db ? ; string(C)
offset: dw ?
length: dw ?
length_high_byte:db ?
length_low_word:dw ?
sample_entry ends
;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2011 Hex-Rays, <support@hex-rays.com> |
; +-------------------------------------------------------------------------+
;
; Input MD5 : 593656C38B49B369F54438C2BB08B459
; Input CRC32 : 5676C0BE
; File Name : Z:\home\marzojr\Documents\Source\sonicretro\smps\smps-ristar-2.bin
; Format : Binary file
; Base Address: 0000h Range: 0000h - 00E9h Loaded length: 00E9h
; Processor : z80 []
; Target assembler: Zilog Macro Assembler
; ===========================================================================
; Segment type: Regular
segment ROM
; =============== S U B R O U T I N E =======================================
; Attributes: noreturn
EntryPoint:
di
di
di
ld a, 2Ah
ex af, af'
PCMwaitloop: ; CODE XREF: EntryPoint+Aj
; EntryPoint+89j
ld a, (driver_input)
or a
jr z, PCMwaitloop
ld (fm_in_progress_flag), a
busywait: ; CODE XREF: EntryPoint+13j
ld a, (zYM2612_A0)
or a
jp m, busywait
ld a, 2Bh
ld (zYM2612_A0), a
ld a, 80h
ld (zYM2612_D0), a
xor a
ld (fm_in_progress_flag), a
PCMplayloop: ; CODE XREF: EntryPoint+5Cj
xor a
ld (driver_input), a
ld ix, sample0
call LoadSampleData
ld hl, driver_input
exx
ld bc, fm_in_progress_flag
ld de, zYM2612_D0
ld hl, zYM2612_A0
exx
PCMplaysampleloop: ; CODE XREF: EntryPoint+59j
; EntryPoint+6Ej
ld a, e
or d
jr z, samplebankdone
ld a, (bc)
dec de
inc bc
ex af, af'
exx
ld (bc), a
busywait_1: ; CODE XREF: EntryPoint+49j
bit 7, (hl)
jr nz, busywait_1
ld (hl), a
ret nz
ex af, af'
ld (de), a
xor a
ld (bc), a
exx
ld a, 1
pitchloop: ; CODE XREF: EntryPoint+55j
dec a
jr nz, pitchloop
ld a, (hl)
or a
jp p, PCMplaysampleloop
jp PCMplayloop
; ---------------------------------------------------------------------------
samplebankdone: ; CODE XREF: EntryPoint+3Fj
ld ix, sample0
ld a, (ix+sample_entry.length_low_word)
or (ix+ sample_entry.length_low_word+1 )
jr z, disableDAC
call DoNextSampleBank
jp PCMplaysampleloop
; ---------------------------------------------------------------------------
disableDAC: ; CODE XREF: EntryPoint+69j
ld a, 80h
ld (fm_in_progress_flag), a
busywait_2: ; CODE XREF: EntryPoint+7Aj
ld a, (zYM2612_A0)
or a
jp m, busywait_2
ld a, 2Bh
ld (zYM2612_A0), a
xor a
ld (zYM2612_D0), a
ld (fm_in_progress_flag), a
jp PCMwaitloop
; End of function EntryPoint
; =============== S U B R O U T I N E =======================================
LoadSampleData: ; CODE XREF: EntryPoint+2Cp
call zBankSwitch
ld (ix+sample_entry.id), a
ld d, (ix+sample_entry.length)
ld e, (ix+ sample_entry.length+1 )
ld b, (ix+sample_entry.offset)
ld c, (ix+ sample_entry.offset+1 )
ret
; End of function LoadSampleData
; =============== S U B R O U T I N E =======================================
DoNextSampleBank: ; CODE XREF: EntryPoint+6Bp
inc (ix+sample_entry.bank)
call zBankSwitch
ld bc, zROMWindow
ld a, (ix+sample_entry.length_low_word)
rla
ld a, (ix+sample_entry.length_high_byte)
rl a
jr z, dolastbank
ld a, (ix+sample_entry.length_low_word)
sub 80h
ld (ix+sample_entry.length_low_word), a
ld a, (ix+sample_entry.length_high_byte)
sbc a, 0
ld (ix+sample_entry.length_high_byte), a
ld de, zROMWindow
ret
; ---------------------------------------------------------------------------
dolastbank: ; CODE XREF: DoNextSampleBank+12j
ld d, (ix+sample_entry.length_low_word)
ld e, (ix+ sample_entry.length_low_word+1 )
ld (ix+sample_entry.length_low_word), 0
ld (ix+ sample_entry.length_low_word+1 ), 0
ret
; End of function DoNextSampleBank
; =============== S U B R O U T I N E =======================================
zBankSwitch: ; CODE XREF: LoadSampleDatap
; DoNextSampleBank+3p
ld b, 7
ld a, (ix+sample_entry.bank)
bankswitchloop: ; CODE XREF: zBankSwitch+9j
ld (zBankRegister), a
rrca
djnz bankswitchloop
xor a
ld (zBankRegister), a
ld (zBankRegister), a
ret
; End of function zBankSwitch
; ---------------------------------------------------------------------------
ds 1F0Bh
sample0: sample_entry <?> ; DATA XREF: EntryPoint+28o
; EntryPoint:samplebankdoneo
driver_input: ds 1 ; DATA XREF: EntryPoint:PCMwaitloopr
; EntryPoint+25w ...
fm_in_progress_flag:ds 1 ; DATA XREF: EntryPoint+Cw
; EntryPoint+21w ...
ds 1
; end of 'ROM'
; ===========================================================================
; Segment type: Regular
segment YM2612
org 4000h
zYM2612_A0: ds 1 ; DATA XREF: EntryPoint:busywaitr
; EntryPoint+18w ...
zYM2612_D0: ds 1 ; DATA XREF: EntryPoint+1Dw
; EntryPoint+36o ...
zYM2612_A1: ds 1
zYM2612_D1: ds 1
; end of 'YM2612'
; ===========================================================================
; Segment type: Regular
segment BankRegister
org 6000h
zBankRegister: ds 1 ; DATA XREF: zBankSwitch:bankswitchloopw
; zBankSwitch+Cw ...
; end of 'BankRegister'
; ===========================================================================
; Segment type: Regular
segment SN76489
org 7F11h
zPSG: ds 1
; end of 'SN76489'
; ===========================================================================
; Segment type: Regular
segment ROMWindow
org 8000h
zROMWindow: ds 8000h ; DATA XREF: DoNextSampleBank+6o
; DoNextSampleBank+24o
; end of 'ROMWindow'
end