-
Notifications
You must be signed in to change notification settings - Fork 0
/
soundplayer.inc
468 lines (412 loc) · 7 KB
/
soundplayer.inc
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
; **** SOUNDTRACKER PLAY ROUTINE WITH EQU REGISTERS ****
; Check registers gflag1, gflag2, gflag3, and gflag4
; if they are not 0 a note has been player. Reset the
; flag to 0 once handled in your own code.
mt_init:lea mt_data,a0
add.l #$03b8,a0
moveq #$7f,d0
moveq #0,d1
mt_init1:
move.l d1,d2
subq.w #1,d0
mt_init2:
move.b (a0)+,d1
cmp.b d2,d1
bgt.s mt_init1
dbf d0,mt_init2
addq.b #1,d2
mt_init3:
lea mt_data,a0
lea mt_sample1(pc),a1
asl.l #8,d2
asl.l #2,d2
add.l #$438,d2
add.l a0,d2
moveq #$1e,d0
mt_init4:
move.l d2,(a1)+
moveq #0,d1
move.w 42(a0),d1
asl.l #1,d1
add.l d1,d2
add.l #$1e,a0
dbf d0,mt_init4
lea mt_sample1(PC),a0
moveq #0,d0
mt_clear:
move.l (a0,d0.w),a1
clr.l (a1)
addq.w #4,d0
cmp.w #$7c,d0
bne.s mt_clear
clr.w $dff0a8
clr.w $dff0b8
clr.w $dff0c8
clr.w $dff0d8
clr.l mt_partnrplay
clr.l mt_partnote
clr.l mt_partpoint
move.b mt_data+$3b6,mt_maxpart+1
rts
; call 'mt_end' to switch the sound off
mt_end: clr.w $dff0a8
clr.w $dff0b8
clr.w $dff0c8
clr.w $dff0d8
move.w #$f,$dff096
rts
; the playroutine - call this every frame
mt_music:
addq.w #1,mt_counter
mt_cool:cmp.w #6,mt_counter
bne.s mt_notsix
clr.w mt_counter
bra mt_rout2
mt_notsix:
lea mt_aud1temp(PC),a6
tst.b 3(a6)
beq.s mt_arp1
lea $dff0a0,a5
bsr.s mt_arprout
mt_arp1:lea mt_aud2temp(PC),a6
tst.b 3(a6)
beq.s mt_arp2
lea $dff0b0,a5
bsr.s mt_arprout
mt_arp2:lea mt_aud3temp(PC),a6
tst.b 3(a6)
beq.s mt_arp3
lea $dff0c0,a5
bsr.s mt_arprout
mt_arp3:lea mt_aud4temp(PC),a6
tst.b 3(a6)
beq.s mt_arp4
lea $dff0d0,a5
bra.s mt_arprout
mt_arp4:rts
mt_arprout:
move.b 2(a6),d0
and.b #$0f,d0
tst.b d0
beq mt_arpegrt
cmp.b #$01,d0
beq.s mt_portup
cmp.b #$02,d0
beq.s mt_portdwn
cmp.b #$0a,d0
beq.s mt_volslide
rts
mt_portup:
moveq #0,d0
move.b 3(a6),d0
sub.w d0,22(a6)
cmp.w #$71,22(a6)
bpl.s mt_ok1
move.w #$71,22(a6)
mt_ok1: move.w 22(a6),6(a5)
rts
mt_portdwn:
moveq #0,d0
move.b 3(a6),d0
add.w d0,22(a6)
cmp.w #$538,22(a6)
bmi.s mt_ok2
move.w #$538,22(a6)
mt_ok2: move.w 22(a6),6(a5)
rts
mt_volslide:
moveq #0,d0
move.b 3(a6),d0
lsr.b #4,d0
tst.b d0
beq.s mt_voldwn
add.w d0,18(a6)
cmp.w #64,18(a6)
bmi.s mt_ok3
move.w #64,18(a6)
mt_ok3: move.w 18(a6),8(a5)
rts
mt_voldwn:
moveq #0,d0
move.b 3(a6),d0
and.b #$0f,d0
sub.w d0,18(a6)
bpl.s mt_ok4
clr.w 18(a6)
mt_ok4: move.w 18(a6),8(a5)
rts
mt_arpegrt:
move.w mt_counter(PC),d0
cmp.w #1,d0
beq.s mt_loop2
cmp.w #2,d0
beq.s mt_loop3
cmp.w #3,d0
beq.s mt_loop4
cmp.w #4,d0
beq.s mt_loop2
cmp.w #5,d0
beq.s mt_loop3
rts
mt_loop2:
moveq #0,d0
move.b 3(a6),d0
lsr.b #4,d0
bra.s mt_cont
mt_loop3:
moveq #$00,d0
move.b 3(a6),d0
and.b #$0f,d0
bra.s mt_cont
mt_loop4:
move.w 16(a6),d2
bra.s mt_endpart
mt_cont:
add.w d0,d0
moveq #0,d1
move.w 16(a6),d1
and.w #$fff,d1
lea mt_arpeggio(PC),a0
mt_loop5:
move.w (a0,d0),d2
cmp.w (a0),d1
beq.s mt_endpart
addq.l #2,a0
bra.s mt_loop5
mt_endpart:
move.w d2,6(a5)
rts
mt_rout2:
lea mt_data,a0
move.l a0,a3
add.l #$0c,a3
move.l a0,a2
add.l #$3b8,a2
add.l #$43c,a0
move.l mt_partnrplay(PC),d0
moveq #0,d1
move.b (a2,d0),d1
asl.l #8,d1
asl.l #2,d1
add.l mt_partnote(PC),d1
move.l d1,mt_partpoint
clr.w mt_dmacon
lea $dff0a0,a5
lea mt_aud1temp(PC),a6
bsr mt_playit
lea $dff0b0,a5
lea mt_aud2temp(PC),a6
bsr mt_playit
lea $dff0c0,a5
lea mt_aud3temp(PC),a6
bsr mt_playit
lea $dff0d0,a5
lea mt_aud4temp(PC),a6
bsr mt_playit
move.w #$01f4,d0
mt_rls: dbf d0,mt_rls
move.w #$8000,d0
or.w mt_dmacon,d0
move.w d0,$dff096
lea mt_aud4temp(PC),a6
cmp.w #1,14(a6)
bne.s mt_voice3
move.l 10(a6),$dff0d0
cmp.w #0,(a6)
beq.s noplus4
; equaliser 4
move.l #1,gflag4
noplus4
move.w #1,$dff0d4
mt_voice3:
lea mt_aud3temp(PC),a6
cmp.w #1,14(a6)
bne.s mt_voice2
move.l 10(a6),$dff0c0
cmp.w #0,(a6)
beq.s noplus3
; equaliser 3
move.l #1,gflag3
noplus3
move.w #1,$dff0c4
mt_voice2:
lea mt_aud2temp(PC),a6
cmp.w #1,14(a6)
bne.s mt_voice1
move.l 10(a6),$dff0b0
cmp.w #0,(a6)
beq.s noplus2
; equaliser 2
move.l #1,gflag2 ; and reset gflag also
noplus2
move.w #1,$dff0b4
mt_voice1:
lea mt_aud1temp(PC),a6
cmp.w #1,14(a6)
bne.s mt_voice0
move.l 10(a6),$dff0a0
cmp.w #0,(a6)
beq.s noplus1
; equaliser 1
move.l #1,gflag1
noplus1
move.w #1,$dff0a4
mt_voice0:
move.l mt_partnote(PC),d0
add.l #$10,d0
move.l d0,mt_partnote
cmp.l #$400,d0
bne.s mt_stop
mt_higher:
clr.l mt_partnote
addq.l #1,mt_partnrplay
moveq #0,d0
move.w mt_maxpart(PC),d0
move.l mt_partnrplay(PC),d1
cmp.l d0,d1
bne.s mt_stop
clr.l mt_partnrplay
; st Pflag
mt_stop:tst.w mt_status
beq.s mt_stop2
clr.w mt_status
bra.s mt_higher
mt_stop2:
rts
mt_playit:
move.l (a0,d1.l),(a6)
addq.l #4,d1
moveq #0,d2
move.b 2(a6),d2
and.b #$f0,d2
lsr.b #4,d2
move.b (a6),d0
and.b #$f0,d0
or.b d0,d2
tst.b d2
beq.s mt_nosamplechange
moveq #0,d3
lea mt_samples(PC),a1
move.l d2,d4
asl.l #2,d2
mulu #$1e,d4
move.l (a1,d2),4(a6)
move.w (a3,d4.l),8(a6)
move.w 2(a3,d4.l),18(a6)
move.w 4(a3,d4.l),d3
tst.w d3
beq.s mt_displace
move.l 4(a6),d2
add.l d3,d2
move.l d2,4(a6)
move.l d2,10(a6)
move.w 6(a3,d4.l),8(a6)
move.w 6(a3,d4.l),14(a6)
move.w 18(a6),8(a5)
bra.s mt_nosamplechange
mt_displace:
move.l 4(a6),d2
add.l d3,d2
move.l d2,10(a6)
move.w 6(a3,d4.l),14(a6)
move.w 18(a6),8(a5)
mt_nosamplechange:
move.w (a6),d0
and.w #$fff,d0
tst.w d0
beq.s mt_retrout
move.w (a6),16(a6)
move.w 20(a6),$dff096
move.l 4(a6),(a5)
move.w 8(a6),4(a5)
move.w (a6),d0
and.w #$fff,d0
move.w d0,6(a5)
move.w 20(a6),d0
or.w d0,mt_dmacon
mt_retrout:
tst.w (a6)
beq.s mt_nonewper
move.w (a6),22(a6)
mt_nonewper:
move.b 2(a6),d0
and.b #$0f,d0
cmp.b #$0b,d0
beq.s mt_posjmp
cmp.b #$0c,d0
beq.s mt_setvol
cmp.b #$0d,d0
beq.s mt_break
cmp.b #$0e,d0
beq.s mt_setfil
cmp.b #$0f,d0
beq.s mt_setspeed
rts
mt_posjmp:
not.w mt_status
moveq #0,d0
move.b 3(a6),d0
subq.b #1,d0
move.l d0,mt_partnrplay
rts
mt_setvol:
move.b 3(a6),8(a5)
rts
mt_break:
not.w mt_status
rts
mt_setfil:
moveq #0,d0
move.b 3(a6),d0
and.b #1,d0
rol.b #1,d0
and.b #$fd,$bfe001
or.b d0,$bfe001
rts
mt_setspeed:
move.b 3(a6),d0
and.b #$0f,d0
beq.s mt_back
clr.w mt_counter
move.b d0,mt_cool+3
mt_back:rts
mt_aud1temp:
dcb.w 10,0
dc.w 1
dcb.w 2,0
mt_aud2temp:
dcb.w 10,0
dc.w 2
dcb.w 2,0
mt_aud3temp:
dcb.w 10,0
dc.w 4
dcb.w 2,0
mt_aud4temp:
dcb.w 10,0
dc.w 8
dcb.w 2,0
mt_partnote: dc.l 0
mt_partnrplay: dc.l 0
mt_counter: dc.w 0
mt_partpoint: dc.l 0
mt_samples: dc.l 0
mt_sample1: dcb.l 31,0
mt_maxpart: dc.w 0
mt_dmacon: dc.w 0
mt_status: dc.w 0
gflag1: dc.l 0
gflag2: dc.l 0
gflag3: dc.l 0
gflag4: dc.l 0
mt_arpeggio:
dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
notetable: dc.w 856,808,762,720,678,640,604,570
dc.w 538,508,480,453,428,404,381,360
dc.w 339,320,302,285,269,254,240,226
dc.w 214,202,190,180,170,160,151,143
dc.w 135,127,120,113,000