revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Examples / Low-level / PT-AHIPlay / PT-AHIPlay.s
blob70b2add1e9cab9cee95c16de23ba2dccf1ef0970
1 ;Run me to assemble with PhxAss (sets TEST, too)
2 IF 0
3 PhxAss SYMDEBUG LINEDEBUG OPT NRQBPSMD SET "TEST=1" PT-AHIPlay.s
4 Quit
5 ENDC
7 ;TEST =1 ; Set to 1 to enable small test code
8 ; The test code in not reentrant!
9 ; Change MixFreq AudioID module name around line 140.
12 **************************************************
13 * ----- Protracker V2.3A Playroutine ----- *
14 **************************************************
16 * Adapted for 'ahi.device' by Martin Blom.
17 * FilterOnOff and Funk commands are not supported.
18 * FilterOnOff cannot be be supported.
19 * Funk can be supported by using AHI_DYNAMICSAMPLE, but shouldn't.
20 * The player part is fully reentrant.
22 * The audio mode you allocate MUST have these tags:
23 * AHIA_Channels AT LEAST 4 (No. 0-3 are used by the replayer)
24 * AHIA_Sounds,1 AT LEAST 1 (No. 0 is used by the replayer)
25 * AHIA_MinPlayerFreq Should be (32*2/5)<<16
26 * AHIA_MaxPlayerFreq Should be (255*2/5)<<16
29 * Available functions:
31 *********************************************************************
32 * success = mt_init( ptdata );
33 * d0 a2
35 * Call to initialize module. d0= FALSE if error.
36 *********************************************************************
37 * success = mt_start( ptdata );
38 * d0 a2
40 * Call to start module. d0= FALSE if error.
41 *********************************************************************
42 * mt_stop( ptdata );
43 * a2
45 * Call to stop module.
46 *********************************************************************
47 * mt_end( ptdata );
48 * a2
50 * Call to deallocate resources taken by mt_init.
51 *********************************************************************
52 * mt_music( ptdata );
53 * a2
54 * Your PlayerFunc() should call this function.
55 *********************************************************************
59 IFND TRUE
60 TRUE EQU 1
61 ENDC
62 IFND FALSE
63 FALSE EQU 0
64 ENDC
65 IFND NULL
66 NULL EQU 0
67 ENDC
69 incdir include:
70 include devices/ahi.i
71 include lvo/ahi_lib.i
73 include PT-AHIPlay.i
75 IFEQ TEST
77 XDEF mt_init
78 XDEF mt_start
79 XDEF mt_stop
80 XDEF mt_end
81 XDEF mt_music
83 XDEF _mt_init
84 XDEF _mt_start
85 XDEF _mt_stop
86 XDEF _mt_end
87 XDEF _mt_music
89 ELSE ; TEST
91 include lvo/exec_lib.i
92 include lvo/dos_lib.i
93 include utility/hooks.i
95 main
96 lea ptdata(pc),a2
97 move.l #mt_data,ptd_ModuleAddress(a2) ;Initialize
99 OPENAHI 4
100 move.l d0,ptd_AHIBase(a2) ;Initialize
101 beq.b close_ahi
102 move.l d0,a6
103 lea ahi_tags(pc),a1
104 jsr _LVOAHI_AllocAudioA(a6)
105 move.l d0,ptd_AudioCtrl(a2) ;Initialize
106 beq.w close_ahi
108 lea ptdata(pc),a2
109 jsr mt_init
110 tst.l d0
111 beq close_ahi
112 lea ptdata(pc),a2
113 jsr mt_start
114 tst.l d0
115 beq exit
117 MOVE.L 4.W,A6
118 LEA DOSname(PC),A1
119 MOVEQ #0,D0
120 JSR _LVOOpenLibrary(A6)
121 TST.L D0
122 BEQ.S exit
123 MOVE.L D0,A6
125 MOVEQ #10,D1
126 JSR _LVODelay(A6)
127 BTST #6,$BFE001
128 BNE.S .1
129 BTST #2,$DFF016
130 BNE.S .1
131 MOVE.L A6,A1
132 MOVE.L 4.W,A6
133 JSR _LVOCloseLibrary(A6)
135 exit
136 lea ptdata(pc),a2
137 jsr mt_end
138 close_ahi
139 lea ptdata(pc),a2
140 move.l ptd_AHIBase(a2),d0
141 beq.b .1
142 move.l d0,a6
143 move.l ptd_AudioCtrl(a2),a2
144 jsr _LVOAHI_FreeAudio(a6)
146 CLOSEAHI
149 DOSname dc.b "dos.library",0
151 ptdata blk.b PTData_SIZEOF,0
153 ahi_tags
154 dc.l AHIA_MixFreq,22050
155 dc.l AHIA_Channels,4
156 dc.l AHIA_Sounds,1
157 dc.l AHIA_AudioID,$00020002 ; Just an example! No hardcoded values permitted!
158 dc.l AHIA_PlayerFunc,PlayerFunc
159 dc.l AHIA_PlayerFreq,50<<16
160 dc.l AHIA_MinPlayerFreq,(32*2/5)<<16
161 dc.l AHIA_MaxPlayerFreq,(255*2/5)<<16
162 dc.l TAG_DONE
164 PlayerFunc:
165 blk.b MLN_SIZE
166 dc.l .code
167 dc.l 0
168 dc.l ptdata
169 .code
170 move.l a2,-(sp)
171 move.l h_Data(a0),a2
172 jsr mt_music
173 move.l (sp)+,a2
176 mt_data:
177 incbin "st-00:Modules/mod/mod.avoidtune"
179 ENDC ; TEST
186 ;---- Playroutine ----
188 section ptplayer,code
190 ;in:
191 * a2 Filled PTData structure
192 ;out:
193 * d0 TRUE on success
194 _mt_init
195 mt_init
196 movem.l d1-d7/a0-a6,-(sp)
197 move.l ptd_ModuleAddress(a2),a0
198 move.l a0,a1
199 lea 952(a1),a1
200 moveq #127,d0
201 moveq #0,d1
202 mtloop
203 move.l d1,d2
204 subq.w #1,d0
205 mtloop2
206 move.b (a1)+,d1
207 cmp.b d2,d1
208 bgt.s mtloop
209 dbra d0,mtloop2
210 addq.b #1,d2
211 asl.l #8,d2
212 asl.l #2,d2
213 add.l #1084,d2
214 move.l d2,d3
215 add.l ptd_ModuleAddress(a2),d3 ;d3 is now start of samples
217 lea ptd_SampleStarts(a2),a1
218 moveq #30,d0
219 moveq #0,d2
220 mtloop3
221 move.l d2,(a1)+
222 moveq #0,d1
223 move.w 42(a0),d1
224 asl.l #1,d1
225 add.l d1,d2
226 add.l #30,a0
227 dbra d0,mtloop3
229 ;d2 is now total sample length
230 ;Build AHISampleInfo strcuture on stack and declare it:
231 move.l d2,-(sp)
232 move.l d3,-(sp)
233 move.l #AHIST_M8S,-(sp)
235 move.l ptd_AHIBase(a2),a6
236 move.l a2,a3
237 move.l ptd_AudioCtrl(a2),a2
238 moveq #0,d0
239 moveq #AHIST_SAMPLE,d1
240 move.l sp,a0
241 jsr _LVOAHI_LoadSound(a6)
242 move.l a3,a2
243 lea 3*4(sp),sp
244 tst.l d0
245 bne .error
247 move.w #$0001,n_dmabit+ptd_chan1temp(a2)
248 move.w #$0002,n_dmabit+ptd_chan2temp(a2)
249 move.w #$0004,n_dmabit+ptd_chan3temp(a2)
250 move.w #$0008,n_dmabit+ptd_chan4temp(a2)
252 moveq #TRUE,d0
253 .exit
254 movem.l (sp)+,d1-d7/a0-a6
256 .error
257 moveq #FALSE,d0
258 bra .exit
261 ;in:
262 * a2 Filled PTData structure
263 ;out:
264 * d0 TRUE on success
265 _mt_start
266 mt_start
267 movem.l d1-d7/a0-a6,-(sp)
269 move.b #6,ptd_speed(a2)
270 clr.b ptd_counter(a2)
271 clr.b ptd_SongPos(a2)
272 clr.b ptd_PBreakPos(a2)
273 clr.b ptd_PosJumpFlag(a2)
274 clr.b ptd_PBreakFlag(a2)
275 clr.b ptd_LowMask(a2)
276 clr.b ptd_PattDelTime(a2)
277 clr.b ptd_PattDelTime2(a2)
278 st ptd_Enable(a2)
279 clr.w ptd_PatternPos(a2)
280 clr.w ptd_DMACONtemp(a2)
282 move.l #TAG_DONE,-(sp)
283 move.l #50<<16,-(sp)
284 move.l #AHIA_PlayerFreq,-(sp)
285 move.l #TRUE,-(sp)
286 move.l #AHIC_Play,-(sp)
288 move.l ptd_AHIBase(a2),a6
289 move.l ptd_AudioCtrl(a2),a2
290 move.l sp,a1
291 jsr _LVOAHI_ControlAudioA(a6)
292 lea 5*4(sp),sp
293 tst.l d0
294 bne .error
295 moveq #TRUE,d0
296 .exit
297 movem.l (sp)+,d1-d7/a0-a6
299 .error
300 moveq #FALSE,d0
301 bra .exit
303 ;in:
304 * a2 Filled PTData structure
305 _mt_stop
306 mt_stop
307 movem.l d0-d7/a0-a6,-(sp)
309 sf ptd_Enable(a2)
310 move.l #TAG_DONE,-(sp)
311 move.l #FALSE,-(sp)
312 move.l #AHIC_Play,-(sp)
314 move.l ptd_AHIBase(a2),a6
315 move.l ptd_AudioCtrl(a2),a2
316 move.l sp,a1
317 jsr _LVOAHI_ControlAudioA(a6)
318 lea 3*4(sp),sp
319 movem.l (sp)+,d0-d7/a0-a6
322 ;in:
323 * a2 Filled PTData structure
324 _mt_end
325 mt_end
326 movem.l d0-d7/a0-a6,-(sp)
327 bsr mt_stop
328 move.l ptd_AHIBase(a2),a6
329 move.l ptd_AudioCtrl(a2),a2
330 moveq #0,d2
331 moveq #0,d3
332 moveq #AHISF_IMM,d4
333 moveq #0,d0
334 moveq #AHI_NOSOUND,d1
335 jsr _LVOAHI_SetSound(a6)
336 moveq #1,d0
337 moveq #AHI_NOSOUND,d1
338 jsr _LVOAHI_SetSound(a6)
339 moveq #2,d0
340 moveq #AHI_NOSOUND,d1
341 jsr _LVOAHI_SetSound(a6)
342 moveq #3,d0
343 moveq #AHI_NOSOUND,d1
344 jsr _LVOAHI_SetSound(a6)
345 moveq #0,d0
346 jsr _LVOAHI_UnloadSound(a6)
347 moveq #0,d0
348 movem.l (sp)+,d0-d7/a0-a6
351 ;---- Tempo ----
353 SetTempo
354 CMP.W #32,D0
355 BHS.S setemsk
356 MOVEQ #32,D0
357 setemsk
358 addq.w #1,ptd_NewTempo(a2)
359 move.w d0,ptd_Tempo(a2)
362 ;in:
363 * a2 Filled PTData structure
364 _mt_music
365 mt_music
366 movem.l d0-d7/a0-a6,-(sp)
368 bsr .org
370 move.l a2,a3
371 move.l ptd_AHIBase(a3),a6
372 move.l ptd_AudioCtrl(a3),a2
373 lea ptd_Chs(a3),a4
374 moveq #0,d7 ;channel
375 .loop
376 tst.w pe_NewSample(a4)
377 beq.b .nosample
378 clr.w pe_NewSample(a4)
379 move.l d7,d0
380 moveq #0,d1
381 move.l pe_Offset(a4),d2
382 moveq #0,d3
383 move.w pe_Length(a4),d3
384 lsl.l #1,d3
385 cmp.l #2,d3
386 bne .1
387 moveq #AHI_NOSOUND,d1
389 moveq #AHISF_IMM,d4
390 jsr _LVOAHI_SetSound(a6)
391 .nosample
392 tst.w pe_NewLoopSample(a4)
393 beq.b .noloopsample
394 clr.w pe_NewLoopSample(a4)
395 move.l d7,d0
396 moveq #0,d1
397 move.l pe_LoopOffset(a4),d2
398 moveq #0,d3
399 move.w pe_LoopLength(a4),d3
400 lsl.l #1,d3
401 cmp.l #2,d3
402 bne .2
403 moveq #AHI_NOSOUND,d1
405 moveq #NULL,d4
406 jsr _LVOAHI_SetSound(a6)
407 .noloopsample
408 tst.w pe_NewPeriod(a4)
409 beq.b .noperiod
410 clr.w pe_NewPeriod(a4)
411 move.l d7,d0
412 move.w pe_Period(a4),d2
413 beq .noperiod
414 move.l #3546895,d1
415 divu.w d2,d1
416 ext.l d1
417 moveq #AHISF_IMM,d2
418 jsr _LVOAHI_SetFreq(a6)
419 .noperiod
420 tst.w pe_NewVolume(a4)
421 beq.b .novolume
422 clr.w pe_NewVolume(a4)
423 move.l d7,d0
424 move.w pe_Volume(a4),d1
425 ext.l d1
426 lsl.l #8,d1
427 lsl.l #2,d1
428 move.l d0,d2
429 lsl.l #2,d2
430 move.l .pantable(pc,d2.l),d2
431 moveq #AHISF_IMM,d3
432 jsr _LVOAHI_SetVol(a6)
433 .novolume
434 add.w #PaulaEmul_SIZEOF,a4
435 addq.w #1,d7
436 cmp.w #4,d7
437 bne .loop
439 tst.w ptd_NewTempo(a3)
440 beq .notempo
441 clr.w ptd_NewTempo(a3)
442 move.w ptd_Tempo(a3),d0
443 ext.l d0
444 lsl.l #1,d0
445 divu #5,d0
446 swap.w d0
447 clr.w d0
448 move.l #TAG_DONE,-(sp)
449 move.l d0,-(sp)
450 move.l #AHIA_PlayerFreq,-(sp)
451 move.l sp,a1
452 jsr _LVOAHI_ControlAudioA(a6)
453 lea 3*4(sp),sp
454 .notempo
456 movem.l (sp)+,d0-d7/a0-a6
458 .pantable
459 dc.l $00000,$10000,$00000,$10000
461 .org
462 MOVEM.L D0-D4/A0-A6,-(SP)
463 TST.B ptd_Enable(a2)
464 BEQ mt_exit
465 ADDQ.B #1,ptd_counter(a2)
466 MOVE.B ptd_counter(a2),D0
467 CMP.B ptd_speed(a2),D0
468 BLO.S mt_NoNewNote
469 CLR.B ptd_counter(a2)
470 TST.B ptd_PattDelTime2(a2)
471 BEQ.S mt_GetNewNote
472 BSR.S mt_NoNewAllChannels
473 BRA mt_dskip
475 mt_NoNewNote
476 BSR.S mt_NoNewAllChannels
477 BRA mt_NoNewPosYet
479 mt_NoNewAllChannels
480 LEA ptd_Ch1(a2),A5
481 LEA ptd_chan1temp(a2),A6
482 BSR mt_CheckEfx
483 LEA ptd_Ch2(a2),A5
484 LEA ptd_chan2temp(a2),A6
485 BSR mt_CheckEfx
486 LEA ptd_Ch3(a2),A5
487 LEA ptd_chan3temp(a2),A6
488 BSR mt_CheckEfx
489 LEA ptd_Ch4(a2),A5
490 LEA ptd_chan4temp(a2),A6
491 BRA mt_CheckEfx
493 mt_GetNewNote
494 MOVE.L ptd_ModuleAddress(a2),A0
495 LEA 12(A0),A3
496 LEA 952(A0),A1 ;pattpo
497 LEA 1084(A0),A0 ;patterndata
498 MOVEQ #0,D0
499 MOVEQ #0,D1
500 MOVE.B ptd_SongPos(a2),D0
501 MOVE.B (A1,D0.W),D1
502 ASL.L #8,D1
503 ASL.L #2,D1
504 ADD.W ptd_PatternPos(a2),D1
505 CLR.W ptd_DMACONtemp(a2)
507 LEA ptd_Ch1(a2),A5
508 LEA ptd_chan1temp(a2),A6
509 BSR.S mt_PlayVoice
510 LEA ptd_Ch2(a2),A5
511 LEA ptd_chan2temp(a2),A6
512 BSR.S mt_PlayVoice
513 LEA ptd_Ch3(a2),A5
514 LEA ptd_chan3temp(a2),A6
515 BSR.S mt_PlayVoice
516 LEA ptd_Ch4(a2),A5
517 LEA ptd_chan4temp(a2),A6
518 BSR.S mt_PlayVoice
519 BRA mt_SetDMA
521 mt_PlayVoice
522 TST.L (A6)
523 BNE.S mt_plvskip
524 BSR mt_PerNop
525 mt_plvskip
526 MOVE.L (A0,D1.L),(A6)
527 ADDQ.L #4,D1
528 MOVEQ #0,D2
529 MOVE.B n_cmd(A6),D2
530 AND.B #$F0,D2
531 LSR.B #4,D2
532 MOVE.B (A6),D0
533 AND.B #$F0,D0
534 OR.B D0,D2
535 TST.B D2
536 BEQ mt_SetRegs
538 MOVEQ #0,D3
539 LEA ptd_SampleStarts(a2),A1
540 MOVE D2,D4
541 SUBQ.L #1,D2
542 ASL.L #2,D2
543 MULU #30,D4
544 MOVE.L (A1,D2.L),n_start(A6)
545 MOVE.W (A3,D4.L),n_length(A6)
546 MOVE.W (A3,D4.L),n_reallength(A6)
547 MOVE.B 2(A3,D4.L),n_finetune(A6)
548 MOVE.B 3(A3,D4.L),n_volume(A6)
549 MOVE.W 4(A3,D4.L),D3 ; Get repeat
550 TST.W D3
551 BEQ.S mt_NoLoop
552 MOVE.L n_start(A6),D2 ; Get start
553 ASL.W #1,D3
554 ADD.L D3,D2 ; Add repeat
555 MOVE.L D2,n_loopstart(A6)
556 MOVE.L D2,n_wavestart(A6)
557 MOVE.W 4(A3,D4.L),D0 ; Get repeat
558 ADD.W 6(A3,D4.L),D0 ; Add replen
559 MOVE.W D0,n_length(A6)
560 MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
561 MOVEQ #0,D0
562 MOVE.B n_volume(A6),D0
563 move.w d0,pe_Volume(a5)
564 addq.w #1,pe_NewVolume(a5)
565 ; MOVE.W D0,8(A5) ; Set volume
566 BRA.S mt_SetRegs
568 mt_NoLoop
569 MOVE.L n_start(A6),D2
570 ADD.L D3,D2
571 MOVE.L D2,n_loopstart(A6)
572 MOVE.L D2,n_wavestart(A6)
573 MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
574 MOVEQ #0,D0
575 MOVE.B n_volume(A6),D0
576 move.w d0,pe_Volume(a5)
577 addq.w #1,pe_NewVolume(a5)
578 ; MOVE.W D0,8(A5) ; Set volume
579 mt_SetRegs
580 MOVE.W (A6),D0
581 AND.W #$0FFF,D0
582 BEQ mt_CheckMoreEfx ; If no note
583 MOVE.W 2(A6),D0
584 AND.W #$0FF0,D0
585 CMP.W #$0E50,D0
586 BEQ.S mt_DoSetFineTune
587 MOVE.B 2(A6),D0
588 AND.B #$0F,D0
589 CMP.B #3,D0 ; TonePortamento
590 BEQ.S mt_ChkTonePorta
591 CMP.B #5,D0
592 BEQ.S mt_ChkTonePorta
593 CMP.B #9,D0 ; Sample Offset
594 BNE.S mt_SetPeriod
595 BSR mt_CheckMoreEfx
596 BRA.S mt_SetPeriod
598 mt_DoSetFineTune
599 BSR mt_SetFineTune
600 BRA.S mt_SetPeriod
602 mt_ChkTonePorta
603 BSR mt_SetTonePorta
604 BRA mt_CheckMoreEfx
606 mt_SetPeriod
607 MOVEM.L D0-D1/A0-A1,-(SP)
608 MOVE.W (A6),D1
609 AND.W #$0FFF,D1
610 LEA mt_PeriodTable(PC),A1
611 MOVEQ #0,D0
612 MOVEQ #36,D2
613 mt_ftuloop
614 CMP.W (A1,D0.W),D1
615 BHS.S mt_ftufound
616 ADDQ.L #2,D0
617 DBRA D2,mt_ftuloop
618 mt_ftufound
619 MOVEQ #0,D1
620 MOVE.B n_finetune(A6),D1
621 MULU #36*2,D1
622 ADD.L D1,A1
623 MOVE.W (A1,D0.W),n_period(A6)
624 MOVEM.L (SP)+,D0-D1/A0-A1
626 MOVE.W 2(A6),D0
627 AND.W #$0FF0,D0
628 CMP.W #$0ED0,D0 ; Notedelay
629 BEQ mt_CheckMoreEfx
631 ; MOVE.W n_dmabit(A6),$DFF096
632 BTST #2,n_wavecontrol(A6)
633 BNE.S mt_vibnoc
634 CLR.B n_vibratopos(A6)
635 mt_vibnoc
636 BTST #6,n_wavecontrol(A6)
637 BNE.S mt_trenoc
638 CLR.B n_tremolopos(A6)
639 mt_trenoc
640 move.l n_start(A6),pe_Offset(a5)
641 move.w n_length(A6),pe_Length(a5)
642 addq.w #1,pe_NewSample(a5)
643 move.w n_period(A6),pe_Period(a5)
644 addq.w #1,pe_NewPeriod(a5)
646 ; MOVE.L n_start(A6),(A5) ; Set start
647 ; MOVE.W n_length(A6),4(A5) ; Set length
649 ; MOVE.W n_period(A6),D0
650 ; MOVE.W D0,6(A5) ; Set period
651 ; MOVE.W n_dmabit(A6),D0
652 ; OR.W D0,ptd_DMACONtemp(a2)
653 BRA mt_CheckMoreEfx
655 mt_SetDMA
656 ; MOVE.W #DMAWait,D0
657 ;mt_WaitDMA
658 ; DBRA D0,mt_WaitDMA
659 ; MOVE.W mt_DMACONtemp(PC),D0
660 ; OR.W #$8000,D0
661 ; MOVE.W D0,$DFF096
662 ; MOVE.W #DMAWait,D0
663 ;mt_WaitDMA2
664 ; DBRA D0,mt_WaitDMA2
666 ; LEA $DFF000,A5
667 ; LEA mt_chan4temp(PC),A6
668 ; MOVE.L n_loopstart(A6),$D0(A5)
669 ; MOVE.W n_replen(A6),$D4(A5)
670 ; LEA mt_chan3temp(PC),A6
671 ; MOVE.L n_loopstart(A6),$C0(A5)
672 ; MOVE.W n_replen(A6),$C4(A5)
673 ; LEA mt_chan2temp(PC),A6
674 ; MOVE.L n_loopstart(A6),$B0(A5)
675 ; MOVE.W n_replen(A6),$B4(A5)
676 ; LEA mt_chan1temp(PC),A6
677 ; MOVE.L n_loopstart(A6),$A0(A5)
678 ; MOVE.W n_replen(A6),$A4(A5)
680 move.l n_loopstart+ptd_chan1temp(A2),pe_LoopOffset+ptd_Ch1(a2)
681 move.w n_replen+ptd_chan1temp(A2),pe_LoopLength+ptd_Ch1(a2)
682 addq.w #1,pe_NewLoopSample+ptd_Ch1(a2)
684 move.l n_loopstart+ptd_chan2temp(A2),pe_LoopOffset+ptd_Ch2(a2)
685 move.w n_replen+ptd_chan2temp(A2),pe_LoopLength+ptd_Ch2(a2)
686 addq.w #1,pe_NewLoopSample+ptd_Ch2(a2)
688 move.l n_loopstart+ptd_chan3temp(A2),pe_LoopOffset+ptd_Ch3(a2)
689 move.w n_replen+ptd_chan3temp(A2),pe_LoopLength+ptd_Ch3(a2)
690 addq.w #1,pe_NewLoopSample+ptd_Ch3(a2)
692 move.l n_loopstart+ptd_chan4temp(A2),pe_LoopOffset+ptd_Ch4(a2)
693 move.w n_replen+ptd_chan4temp(A2),pe_LoopLength+ptd_Ch4(a2)
694 addq.w #1,pe_NewLoopSample+ptd_Ch4(a2)
697 mt_dskip
698 ADD.W #16,ptd_PatternPos(a2)
699 MOVE.B ptd_PattDelTime(a2),D0
700 BEQ.S mt_dskc
701 MOVE.B D0,ptd_PattDelTime2(a2)
702 CLR.B ptd_PattDelTime(a2)
703 mt_dskc TST.B ptd_PattDelTime2(a2)
704 BEQ.S mt_dska
705 SUBQ.B #1,ptd_PattDelTime2(a2)
706 BEQ.S mt_dska
707 SUB.W #16,ptd_PatternPos(a2)
708 mt_dska TST.B ptd_PBreakFlag(a2)
709 BEQ.S mt_nnpysk
710 SF ptd_PBreakFlag(a2)
711 MOVEQ #0,D0
712 MOVE.B ptd_PBreakPos(a2),D0
713 CLR.B ptd_PBreakPos(a2)
714 LSL.W #4,D0
715 MOVE.W D0,ptd_PatternPos(a2)
716 mt_nnpysk
717 CMP.W #1024,ptd_PatternPos(a2)
718 BLO.S mt_NoNewPosYet
719 mt_NextPosition
720 MOVEQ #0,D0
721 MOVE.B ptd_PBreakPos(a2),D0
722 LSL.W #4,D0
723 MOVE.W D0,ptd_PatternPos(a2)
724 CLR.B ptd_PBreakPos(a2)
725 CLR.B ptd_PosJumpFlag(a2)
726 ADDQ.B #1,ptd_SongPos(a2)
727 AND.B #$7F,ptd_SongPos(a2)
728 MOVE.B ptd_SongPos(a2),D1
729 MOVE.L ptd_ModuleAddress(a2),A0
730 CMP.B 950(A0),D1
731 BLO.S mt_NoNewPosYet
732 CLR.B ptd_SongPos(a2)
733 mt_NoNewPosYet
734 TST.B ptd_PosJumpFlag(a2)
735 BNE.S mt_NextPosition
736 mt_exit MOVEM.L (SP)+,D0-D4/A0-A6
739 mt_CheckEfx
740 BSR mt_UpdateFunk
741 MOVE.W n_cmd(A6),D0
742 AND.W #$0FFF,D0
743 BEQ.S mt_PerNop
744 MOVE.B n_cmd(A6),D0
745 AND.B #$0F,D0
746 BEQ.S mt_Arpeggio
747 CMP.B #1,D0
748 BEQ mt_PortaUp
749 CMP.B #2,D0
750 BEQ mt_PortaDown
751 CMP.B #3,D0
752 BEQ mt_TonePortamento
753 CMP.B #4,D0
754 BEQ mt_Vibrato
755 CMP.B #5,D0
756 BEQ mt_TonePlusVolSlide
757 CMP.B #6,D0
758 BEQ mt_VibratoPlusVolSlide
759 CMP.B #$E,D0
760 BEQ mt_E_Commands
761 SetBack
762 ; MOVE.W n_period(A6),6(A5)
763 move.w n_period(a6),pe_Period(a5)
764 addq.w #1,pe_NewPeriod(a5)
765 CMP.B #7,D0
766 BEQ mt_Tremolo
767 CMP.B #$A,D0
768 BEQ mt_VolumeSlide
769 mt_Return
772 mt_PerNop
773 ; MOVE.W n_period(A6),6(A5)
774 move.w n_period(a6),pe_Period(a5)
775 addq.w #1,pe_NewPeriod(a5)
778 mt_Arpeggio
779 MOVEQ #0,D0
780 MOVE.B ptd_counter(a2),D0
781 DIVS #3,D0
782 SWAP D0
783 CMP.W #0,D0
784 BEQ.S mt_Arpeggio2
785 CMP.W #2,D0
786 BEQ.S mt_Arpeggio1
787 MOVEQ #0,D0
788 MOVE.B n_cmdlo(A6),D0
789 LSR.B #4,D0
790 BRA.S mt_Arpeggio3
792 mt_Arpeggio1
793 MOVEQ #0,D0
794 MOVE.B n_cmdlo(A6),D0
795 AND.B #15,D0
796 BRA.S mt_Arpeggio3
798 mt_Arpeggio2
799 MOVE.W n_period(A6),D2
800 BRA.S mt_Arpeggio4
802 mt_Arpeggio3
803 ASL.W #1,D0
804 MOVEQ #0,D1
805 MOVE.B n_finetune(A6),D1
806 MULU #36*2,D1
807 LEA mt_PeriodTable(PC),A0
808 ADD.L D1,A0
809 MOVEQ #0,D1
810 MOVE.W n_period(A6),D1
811 MOVEQ #36,D3
812 mt_arploop
813 MOVE.W (A0,D0.W),D2
814 CMP.W (A0),D1
815 BHS.S mt_Arpeggio4
816 ADDQ.L #2,A0
817 DBRA D3,mt_arploop
820 mt_Arpeggio4
821 ; MOVE.W D2,6(A5)
822 move.w d2,pe_Period(a5)
823 addq.w #1,pe_NewPeriod(a5)
826 mt_FinePortaUp
827 TST.B ptd_counter(a2)
828 BNE mt_Return
829 MOVE.B #$0F,ptd_LowMask(a2)
830 mt_PortaUp
831 MOVEQ #0,D0
832 MOVE.B n_cmdlo(A6),D0
833 AND.B ptd_LowMask(a2),D0
834 MOVE.B #$FF,ptd_LowMask(a2)
835 SUB.W D0,n_period(A6)
836 MOVE.W n_period(A6),D0
837 AND.W #$0FFF,D0
838 CMP.W #113,D0
839 BPL.S mt_PortaUskip
840 AND.W #$F000,n_period(A6)
841 OR.W #113,n_period(A6)
842 mt_PortaUskip
843 MOVE.W n_period(A6),D0
844 AND.W #$0FFF,D0
845 ; MOVE.W D0,6(A5)
846 move.w d0,pe_Period(a5)
847 addq.w #1,pe_NewPeriod(a5)
848 RTS
850 mt_FinePortaDown
851 TST.B ptd_counter(a2)
852 BNE mt_Return
853 MOVE.B #$0F,ptd_LowMask(a2)
854 mt_PortaDown
855 CLR.W D0
856 MOVE.B n_cmdlo(A6),D0
857 AND.B ptd_LowMask(a2),D0
858 MOVE.B #$FF,ptd_LowMask(a2)
859 ADD.W D0,n_period(A6)
860 MOVE.W n_period(A6),D0
861 AND.W #$0FFF,D0
862 CMP.W #856,D0
863 BMI.S mt_PortaDskip
864 AND.W #$F000,n_period(A6)
865 OR.W #856,n_period(A6)
866 mt_PortaDskip
867 MOVE.W n_period(A6),D0
868 AND.W #$0FFF,D0
869 move.w d0,pe_Period(a5)
870 addq.w #1,pe_NewPeriod(a5)
871 ; MOVE.W D0,6(A5)
874 mt_SetTonePorta
875 MOVE.L A0,-(SP)
876 MOVE.W (A6),D2
877 AND.W #$0FFF,D2
878 MOVEQ #0,D0
879 MOVE.B n_finetune(A6),D0
880 MULU #36*2,D0 ;37?
881 LEA mt_PeriodTable(PC),A0
882 ADD.L D0,A0
883 MOVEQ #0,D0
884 mt_StpLoop
885 CMP.W (A0,D0.W),D2
886 BHS.S mt_StpFound
887 ADDQ.W #2,D0
888 CMP.W #36*2,D0 ;37?
889 BLO.S mt_StpLoop
890 MOVEQ #35*2,D0
891 mt_StpFound
892 MOVE.B n_finetune(A6),D2
893 AND.B #8,D2
894 BEQ.S mt_StpGoss
895 TST.W D0
896 BEQ.S mt_StpGoss
897 SUBQ.W #2,D0
898 mt_StpGoss
899 MOVE.W (A0,D0.W),D2
900 MOVE.L (SP)+,A0
901 MOVE.W D2,n_wantedperiod(A6)
902 MOVE.W n_period(A6),D0
903 CLR.B n_toneportdirec(A6)
904 CMP.W D0,D2
905 BEQ.S mt_ClearTonePorta
906 BGE mt_Return
907 MOVE.B #1,n_toneportdirec(A6)
910 mt_ClearTonePorta
911 CLR.W n_wantedperiod(A6)
914 mt_TonePortamento
915 MOVE.B n_cmdlo(A6),D0
916 BEQ.S mt_TonePortNoChange
917 MOVE.B D0,n_toneportspeed(A6)
918 CLR.B n_cmdlo(A6)
919 mt_TonePortNoChange
920 TST.W n_wantedperiod(A6)
921 BEQ mt_Return
922 MOVEQ #0,D0
923 MOVE.B n_toneportspeed(A6),D0
924 TST.B n_toneportdirec(A6)
925 BNE.S mt_TonePortaUp
926 mt_TonePortaDown
927 ADD.W D0,n_period(A6)
928 MOVE.W n_wantedperiod(A6),D0
929 CMP.W n_period(A6),D0
930 BGT.S mt_TonePortaSetPer
931 MOVE.W n_wantedperiod(A6),n_period(A6)
932 CLR.W n_wantedperiod(A6)
933 BRA.S mt_TonePortaSetPer
935 mt_TonePortaUp
936 SUB.W D0,n_period(A6)
937 MOVE.W n_wantedperiod(A6),D0
938 CMP.W n_period(A6),D0
939 BLT.S mt_TonePortaSetPer
940 MOVE.W n_wantedperiod(A6),n_period(A6)
941 CLR.W n_wantedperiod(A6)
943 mt_TonePortaSetPer
944 MOVE.W n_period(A6),D2
945 MOVE.B n_glissfunk(A6),D0
946 AND.B #$0F,D0
947 BEQ.S mt_GlissSkip
948 MOVEQ #0,D0
949 MOVE.B n_finetune(A6),D0
950 MULU #36*2,D0
951 LEA mt_PeriodTable(PC),A0
952 ADD.L D0,A0
953 MOVEQ #0,D0
954 mt_GlissLoop
955 CMP.W (A0,D0.W),D2
956 BHS.S mt_GlissFound
957 ADDQ.W #2,D0
958 CMP.W #36*2,D0
959 BLO.S mt_GlissLoop
960 MOVEQ #35*2,D0
961 mt_GlissFound
962 MOVE.W (A0,D0.W),D2
963 mt_GlissSkip
964 ; MOVE.W D2,6(A5) ; Set period
965 move.w d2,pe_Period(a5)
966 addq.w #1,pe_NewPeriod(a5)
969 mt_Vibrato
970 MOVE.B n_cmdlo(A6),D0
971 BEQ.S mt_Vibrato2
972 MOVE.B n_vibratocmd(A6),D2
973 AND.B #$0F,D0
974 BEQ.S mt_vibskip
975 AND.B #$F0,D2
976 OR.B D0,D2
977 mt_vibskip
978 MOVE.B n_cmdlo(A6),D0
979 AND.B #$F0,D0
980 BEQ.S mt_vibskip2
981 AND.B #$0F,D2
982 OR.B D0,D2
983 mt_vibskip2
984 MOVE.B D2,n_vibratocmd(A6)
985 mt_Vibrato2
986 MOVE.B n_vibratopos(A6),D0
987 LEA mt_VibratoTable(PC),A4
988 LSR.W #2,D0
989 AND.W #$001F,D0
990 MOVEQ #0,D2
991 MOVE.B n_wavecontrol(A6),D2
992 AND.B #$03,D2
993 BEQ.S mt_vib_sine
994 LSL.B #3,D0
995 CMP.B #1,D2
996 BEQ.S mt_vib_rampdown
997 MOVE.B #255,D2
998 BRA.S mt_vib_set
999 mt_vib_rampdown
1000 TST.B n_vibratopos(A6)
1001 BPL.S mt_vib_rampdown2
1002 MOVE.B #255,D2
1003 SUB.B D0,D2
1004 BRA.S mt_vib_set
1005 mt_vib_rampdown2
1006 MOVE.B D0,D2
1007 BRA.S mt_vib_set
1008 mt_vib_sine
1009 MOVE.B (A4,D0.W),D2
1010 mt_vib_set
1011 MOVE.B n_vibratocmd(A6),D0
1012 AND.W #15,D0
1013 MULU D0,D2
1014 LSR.W #7,D2
1015 MOVE.W n_period(A6),D0
1016 TST.B n_vibratopos(A6)
1017 BMI.S mt_VibratoNeg
1018 ADD.W D2,D0
1019 BRA.S mt_Vibrato3
1020 mt_VibratoNeg
1021 SUB.W D2,D0
1022 mt_Vibrato3
1023 ; MOVE.W D0,6(A5)
1024 move.w d0,pe_Period(a5)
1025 addq.w #1,pe_NewPeriod(a5)
1026 MOVE.B n_vibratocmd(A6),D0
1027 LSR.W #2,D0
1028 AND.W #$003C,D0
1029 ADD.B D0,n_vibratopos(A6)
1032 mt_TonePlusVolSlide
1033 BSR mt_TonePortNoChange
1034 BRA mt_VolumeSlide
1036 mt_VibratoPlusVolSlide
1037 BSR.S mt_Vibrato2
1038 BRA mt_VolumeSlide
1040 mt_Tremolo
1041 MOVE.B n_cmdlo(A6),D0
1042 BEQ.S mt_Tremolo2
1043 MOVE.B n_tremolocmd(A6),D2
1044 AND.B #$0F,D0
1045 BEQ.S mt_treskip
1046 AND.B #$F0,D2
1047 OR.B D0,D2
1048 mt_treskip
1049 MOVE.B n_cmdlo(A6),D0
1050 AND.B #$F0,D0
1051 BEQ.S mt_treskip2
1052 AND.B #$0F,D2
1053 OR.B D0,D2
1054 mt_treskip2
1055 MOVE.B D2,n_tremolocmd(A6)
1056 mt_Tremolo2
1057 MOVE.B n_tremolopos(A6),D0
1058 LEA mt_VibratoTable(PC),A4
1059 LSR.W #2,D0
1060 AND.W #$001F,D0
1061 MOVEQ #0,D2
1062 MOVE.B n_wavecontrol(A6),D2
1063 LSR.B #4,D2
1064 AND.B #$03,D2
1065 BEQ.S mt_tre_sine
1066 LSL.B #3,D0
1067 CMP.B #1,D2
1068 BEQ.S mt_tre_rampdown
1069 MOVE.B #255,D2
1070 BRA.S mt_tre_set
1071 mt_tre_rampdown
1072 TST.B n_vibratopos(A6)
1073 BPL.S mt_tre_rampdown2
1074 MOVE.B #255,D2
1075 SUB.B D0,D2
1076 BRA.S mt_tre_set
1077 mt_tre_rampdown2
1078 MOVE.B D0,D2
1079 BRA.S mt_tre_set
1080 mt_tre_sine
1081 MOVE.B (A4,D0.W),D2
1082 mt_tre_set
1083 MOVE.B n_tremolocmd(A6),D0
1084 AND.W #15,D0
1085 MULU D0,D2
1086 LSR.W #6,D2
1087 MOVEQ #0,D0
1088 MOVE.B n_volume(A6),D0
1089 TST.B n_tremolopos(A6)
1090 BMI.S mt_TremoloNeg
1091 ADD.W D2,D0
1092 BRA.S mt_Tremolo3
1093 mt_TremoloNeg
1094 SUB.W D2,D0
1095 mt_Tremolo3
1096 BPL.S mt_TremoloSkip
1097 CLR.W D0
1098 mt_TremoloSkip
1099 CMP.W #$40,D0
1100 BLS.S mt_TremoloOk
1101 MOVE.W #$40,D0
1102 mt_TremoloOk
1103 ; MOVE.W D0,8(A5)
1104 move.w d0,pe_Volume(a5)
1105 addq.w #1,pe_NewVolume(a5)
1106 MOVE.B n_tremolocmd(A6),D0
1107 LSR.W #2,D0
1108 AND.W #$003C,D0
1109 ADD.B D0,n_tremolopos(A6)
1112 mt_SampleOffset
1113 MOVEQ #0,D0
1114 MOVE.B n_cmdlo(A6),D0
1115 BEQ.S mt_sononew
1116 MOVE.B D0,n_sampleoffset(A6)
1117 mt_sononew
1118 MOVE.B n_sampleoffset(A6),D0
1119 LSL.W #7,D0
1120 CMP.W n_length(A6),D0
1121 BGE.S mt_sofskip
1122 SUB.W D0,n_length(A6)
1123 LSL.W #1,D0
1124 ADD.L D0,n_start(A6)
1126 mt_sofskip
1127 MOVE.W #$0001,n_length(A6)
1130 mt_VolumeSlide
1131 MOVEQ #0,D0
1132 MOVE.B n_cmdlo(A6),D0
1133 LSR.B #4,D0
1134 TST.B D0
1135 BEQ.S mt_VolSlideDown
1136 mt_VolSlideUp
1137 ADD.B D0,n_volume(A6)
1138 CMP.B #$40,n_volume(A6)
1139 BMI.S mt_vsuskip
1140 MOVE.B #$40,n_volume(A6)
1141 mt_vsuskip
1142 MOVE.B n_volume(A6),D0
1143 ; MOVE.W D0,8(A5)
1144 move.w d0,pe_Volume(a5)
1145 addq.w #1,pe_NewVolume(a5)
1148 mt_VolSlideDown
1149 MOVEQ #0,D0
1150 MOVE.B n_cmdlo(A6),D0
1151 AND.B #$0F,D0
1152 mt_VolSlideDown2
1153 SUB.B D0,n_volume(A6)
1154 BPL.S mt_vsdskip
1155 CLR.B n_volume(A6)
1156 mt_vsdskip
1157 MOVE.B n_volume(A6),D0
1158 ; MOVE.W D0,8(A5)
1159 move.w d0,pe_Volume(a5)
1160 addq.w #1,pe_NewVolume(a5)
1163 mt_PositionJump
1164 MOVE.B n_cmdlo(A6),D0
1165 SUBQ.B #1,D0
1166 MOVE.B D0,ptd_SongPos(a2)
1167 mt_pj2 CLR.B ptd_PBreakPos(a2)
1168 ST ptd_PosJumpFlag(a2)
1171 mt_VolumeChange
1172 MOVEQ #0,D0
1173 MOVE.B n_cmdlo(A6),D0
1174 CMP.B #$40,D0
1175 BLS.S mt_VolumeOk
1176 MOVEQ #$40,D0
1177 mt_VolumeOk
1178 MOVE.B D0,n_volume(A6)
1179 ; MOVE.W D0,8(A5)
1180 move.w d0,pe_Volume(a5)
1181 addq.w #1,pe_NewVolume(a5)
1184 mt_PatternBreak
1185 MOVEQ #0,D0
1186 MOVE.B n_cmdlo(A6),D0
1187 MOVE.L D0,D2
1188 LSR.B #4,D0
1189 MULU #10,D0
1190 AND.B #$0F,D2
1191 ADD.B D2,D0
1192 CMP.B #63,D0
1193 BHI.S mt_pj2
1194 MOVE.B D0,ptd_PBreakPos(a2)
1195 ST ptd_PosJumpFlag(a2)
1198 mt_SetSpeed
1199 MOVEQ #0,D0
1200 MOVE.B 3(A6),D0
1201 BEQ mt_end
1202 CMP.B #32,D0
1203 BHS SetTempo
1204 CLR.B ptd_counter(a2)
1205 MOVE.B D0,ptd_speed(a2)
1208 mt_CheckMoreEfx
1209 BSR mt_UpdateFunk
1210 MOVE.B 2(A6),D0
1211 AND.B #$0F,D0
1212 CMP.B #$9,D0
1213 BEQ mt_SampleOffset
1214 CMP.B #$B,D0
1215 BEQ mt_PositionJump
1216 CMP.B #$D,D0
1217 BEQ.S mt_PatternBreak
1218 CMP.B #$E,D0
1219 BEQ.S mt_E_Commands
1220 CMP.B #$F,D0
1221 BEQ.S mt_SetSpeed
1222 CMP.B #$C,D0
1223 BEQ mt_VolumeChange
1224 BRA mt_PerNop
1226 mt_E_Commands
1227 MOVE.B n_cmdlo(A6),D0
1228 AND.B #$F0,D0
1229 LSR.B #4,D0
1230 BEQ.S mt_FilterOnOff
1231 CMP.B #1,D0
1232 BEQ mt_FinePortaUp
1233 CMP.B #2,D0
1234 BEQ mt_FinePortaDown
1235 CMP.B #3,D0
1236 BEQ.S mt_SetGlissControl
1237 CMP.B #4,D0
1238 BEQ mt_SetVibratoControl
1239 CMP.B #5,D0
1240 BEQ mt_SetFineTune
1241 CMP.B #6,D0
1242 BEQ mt_JumpLoop
1243 CMP.B #7,D0
1244 BEQ mt_SetTremoloControl
1245 CMP.B #9,D0
1246 BEQ mt_RetrigNote
1247 CMP.B #$A,D0
1248 BEQ mt_VolumeFineUp
1249 CMP.B #$B,D0
1250 BEQ mt_VolumeFineDown
1251 CMP.B #$C,D0
1252 BEQ mt_NoteCut
1253 CMP.B #$D,D0
1254 BEQ mt_NoteDelay
1255 CMP.B #$E,D0
1256 BEQ mt_PatternDelay
1257 CMP.B #$F,D0
1258 BEQ mt_FunkIt
1261 mt_FilterOnOff
1262 ; MOVE.B n_cmdlo(A6),D0
1263 ; AND.B #1,D0
1264 ; ASL.B #1,D0
1265 ; AND.B #$FD,$BFE001
1266 ; OR.B D0,$BFE001
1267 RTS
1269 mt_SetGlissControl
1270 MOVE.B n_cmdlo(A6),D0
1271 AND.B #$0F,D0
1272 AND.B #$F0,n_glissfunk(A6)
1273 OR.B D0,n_glissfunk(A6)
1276 mt_SetVibratoControl
1277 MOVE.B n_cmdlo(A6),D0
1278 AND.B #$0F,D0
1279 AND.B #$F0,n_wavecontrol(A6)
1280 OR.B D0,n_wavecontrol(A6)
1283 mt_SetFineTune
1284 MOVE.B n_cmdlo(A6),D0
1285 AND.B #$0F,D0
1286 MOVE.B D0,n_finetune(A6)
1289 mt_JumpLoop
1290 TST.B ptd_counter(a2)
1291 BNE mt_Return
1292 MOVE.B n_cmdlo(A6),D0
1293 AND.B #$0F,D0
1294 BEQ.S mt_SetLoop
1295 TST.B n_loopcount(A6)
1296 BEQ.S mt_jumpcnt
1297 SUBQ.B #1,n_loopcount(A6)
1298 BEQ mt_Return
1299 mt_jmploop
1300 MOVE.B n_pattpos(A6),ptd_PBreakPos(a2)
1301 ST ptd_PBreakFlag(a2)
1304 mt_jumpcnt
1305 MOVE.B D0,n_loopcount(A6)
1306 BRA.S mt_jmploop
1308 mt_SetLoop
1309 MOVE.W ptd_PatternPos(a2),D0
1310 LSR.W #4,D0
1311 MOVE.B D0,n_pattpos(A6)
1314 mt_SetTremoloControl
1315 MOVE.B n_cmdlo(A6),D0
1316 AND.B #$0F,D0
1317 LSL.B #4,D0
1318 AND.B #$0F,n_wavecontrol(A6)
1319 OR.B D0,n_wavecontrol(A6)
1322 mt_RetrigNote
1323 MOVE.L D1,-(SP)
1324 MOVEQ #0,D0
1325 MOVE.B n_cmdlo(A6),D0
1326 AND.B #$0F,D0
1327 BEQ.S mt_rtnend
1328 MOVEQ #0,D1
1329 MOVE.B ptd_counter(a2),D1
1330 BNE.S mt_rtnskp
1331 MOVE.W (A6),D1
1332 AND.W #$0FFF,D1
1333 BNE.S mt_rtnend
1334 MOVEQ #0,D1
1335 MOVE.B ptd_counter(a2),D1
1336 mt_rtnskp
1337 DIVU D0,D1
1338 SWAP D1
1339 TST.W D1
1340 BNE.S mt_rtnend
1341 mt_DoRetrig
1342 ; MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off
1343 ; MOVE.L n_start(A6),(A5) ; Set sampledata pointer
1344 ; MOVE.W n_length(A6),4(A5) ; Set length
1345 move.l n_start(A6),pe_Offset(a5)
1346 move.w n_length(A6),pe_Length(a5)
1347 addq.w #1,pe_NewSample(a5)
1349 ; MOVE.W #DMAWait,D0
1350 ;mt_rtnloop1
1351 ; DBRA D0,mt_rtnloop1
1352 ; MOVE.W n_dmabit(A6),D0
1353 ; BSET #15,D0
1354 ; MOVE.W D0,$DFF096
1355 ; MOVE.W #DMAWait,D0
1356 ;mt_rtnloop2
1357 ; DBRA D0,mt_rtnloop2
1359 ; MOVE.L n_loopstart(A6),(A5)
1360 ; MOVE.L n_replen(A6),4(A5)
1361 move.l n_loopstart(A6),pe_LoopOffset(a5)
1362 move.w n_replen(A6),pe_LoopLength(a5)
1363 addq.w #1,pe_NewLoopSample(a5)
1364 mt_rtnend
1365 MOVE.L (SP)+,D1
1368 mt_VolumeFineUp
1369 TST.B ptd_counter(a2)
1370 BNE mt_Return
1371 MOVEQ #0,D0
1372 MOVE.B n_cmdlo(A6),D0
1373 AND.B #$F,D0
1374 BRA mt_VolSlideUp
1376 mt_VolumeFineDown
1377 TST.B ptd_counter(a2)
1378 BNE mt_Return
1379 MOVEQ #0,D0
1380 MOVE.B n_cmdlo(A6),D0
1381 AND.B #$0F,D0
1382 BRA mt_VolSlideDown2
1384 mt_NoteCut
1385 MOVEQ #0,D0
1386 MOVE.B n_cmdlo(A6),D0
1387 AND.B #$0F,D0
1388 CMP.B ptd_counter(a2),D0
1389 BNE mt_Return
1390 CLR.B n_volume(A6)
1391 ; MOVE.W #0,8(A5)
1392 clr.w pe_Volume(a5)
1393 addq.w #1,pe_NewVolume(a5)
1396 mt_NoteDelay
1397 MOVEQ #0,D0
1398 MOVE.B n_cmdlo(A6),D0
1399 AND.B #$0F,D0
1400 CMP.B ptd_counter(a2),D0
1401 BNE mt_Return
1402 MOVE.W (A6),D0
1403 BEQ mt_Return
1404 MOVE.L D1,-(SP)
1405 BRA mt_DoRetrig
1407 mt_PatternDelay
1408 TST.B ptd_counter(a2)
1409 BNE mt_Return
1410 MOVEQ #0,D0
1411 MOVE.B n_cmdlo(A6),D0
1412 AND.B #$0F,D0
1413 TST.B ptd_PattDelTime2(a2)
1414 BNE mt_Return
1415 ADDQ.B #1,D0
1416 MOVE.B D0,ptd_PattDelTime(a2)
1419 mt_FunkIt
1420 ; TST.B mt_counter
1421 ; BNE mt_Return
1422 ; MOVE.B n_cmdlo(A6),D0
1423 ; AND.B #$0F,D0
1424 ; LSL.B #4,D0
1425 ; AND.B #$0F,n_glissfunk(A6)
1426 ; OR.B D0,n_glissfunk(A6)
1427 ; TST.B D0
1428 ; BEQ mt_Return
1429 mt_UpdateFunk
1430 ; MOVEM.L A0/D1,-(SP)
1431 ; MOVEQ #0,D0
1432 ; MOVE.B n_glissfunk(A6),D0
1433 ; LSR.B #4,D0
1434 ; BEQ.S mt_funkend
1435 ; LEA mt_FunkTable(PC),A0
1436 ; MOVE.B (A0,D0.W),D0
1437 ; ADD.B D0,n_funkoffset(A6)
1438 ; BTST #7,n_funkoffset(A6)
1439 ; BEQ.S mt_funkend
1440 ; CLR.B n_funkoffset(A6)
1442 ; MOVE.L n_loopstart(A6),D0
1443 ; MOVEQ #0,D1
1444 ; MOVE.W n_replen(A6),D1
1445 ; ADD.L D1,D0
1446 ; ADD.L D1,D0
1447 ; MOVE.L n_wavestart(A6),A0
1448 ; ADDQ.L #1,A0
1449 ; CMP.L D0,A0
1450 ; BLO.S mt_funkok
1451 ; MOVE.L n_loopstart(A6),A0
1452 ;mt_funkok
1453 ; MOVE.L A0,n_wavestart(A6)
1454 ; MOVEQ #-1,D0
1455 ; SUB.B (A0),D0
1456 ; MOVE.B D0,(A0)
1457 ;mt_funkend
1458 ; MOVEM.L (SP)+,A0/D1
1462 ;mt_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
1464 mt_VibratoTable
1465 dc.b 0, 24, 49, 74, 97,120,141,161
1466 dc.b 180,197,212,224,235,244,250,253
1467 dc.b 255,253,250,244,235,224,212,197
1468 dc.b 180,161,141,120, 97, 74, 49, 24
1470 mt_PeriodTable
1471 ; Tuning 0, Normal
1472 dc.w 856,808,762,720,678,640,604,570,538,508,480,453
1473 dc.w 428,404,381,360,339,320,302,285,269,254,240,226
1474 dc.w 214,202,190,180,170,160,151,143,135,127,120,113
1475 ; Tuning 1
1476 dc.w 850,802,757,715,674,637,601,567,535,505,477,450
1477 dc.w 425,401,379,357,337,318,300,284,268,253,239,225
1478 dc.w 213,201,189,179,169,159,150,142,134,126,119,113
1479 ; Tuning 2
1480 dc.w 844,796,752,709,670,632,597,563,532,502,474,447
1481 dc.w 422,398,376,355,335,316,298,282,266,251,237,224
1482 dc.w 211,199,188,177,167,158,149,141,133,125,118,112
1483 ; Tuning 3
1484 dc.w 838,791,746,704,665,628,592,559,528,498,470,444
1485 dc.w 419,395,373,352,332,314,296,280,264,249,235,222
1486 dc.w 209,198,187,176,166,157,148,140,132,125,118,111
1487 ; Tuning 4
1488 dc.w 832,785,741,699,660,623,588,555,524,495,467,441
1489 dc.w 416,392,370,350,330,312,294,278,262,247,233,220
1490 dc.w 208,196,185,175,165,156,147,139,131,124,117,110
1491 ; Tuning 5
1492 dc.w 826,779,736,694,655,619,584,551,520,491,463,437
1493 dc.w 413,390,368,347,328,309,292,276,260,245,232,219
1494 dc.w 206,195,184,174,164,155,146,138,130,123,116,109
1495 ; Tuning 6
1496 dc.w 820,774,730,689,651,614,580,547,516,487,460,434
1497 dc.w 410,387,365,345,325,307,290,274,258,244,230,217
1498 dc.w 205,193,183,172,163,154,145,137,129,122,115,109
1499 ; Tuning 7
1500 dc.w 814,768,725,684,646,610,575,543,513,484,457,431
1501 dc.w 407,384,363,342,323,305,288,272,256,242,228,216
1502 dc.w 204,192,181,171,161,152,144,136,128,121,114,108
1503 ; Tuning -8
1504 dc.w 907,856,808,762,720,678,640,604,570,538,508,480
1505 dc.w 453,428,404,381,360,339,320,302,285,269,254,240
1506 dc.w 226,214,202,190,180,170,160,151,143,135,127,120
1507 ; Tuning -7
1508 dc.w 900,850,802,757,715,675,636,601,567,535,505,477
1509 dc.w 450,425,401,379,357,337,318,300,284,268,253,238
1510 dc.w 225,212,200,189,179,169,159,150,142,134,126,119
1511 ; Tuning -6
1512 dc.w 894,844,796,752,709,670,632,597,563,532,502,474
1513 dc.w 447,422,398,376,355,335,316,298,282,266,251,237
1514 dc.w 223,211,199,188,177,167,158,149,141,133,125,118
1515 ; Tuning -5
1516 dc.w 887,838,791,746,704,665,628,592,559,528,498,470
1517 dc.w 444,419,395,373,352,332,314,296,280,264,249,235
1518 dc.w 222,209,198,187,176,166,157,148,140,132,125,118
1519 ; Tuning -4
1520 dc.w 881,832,785,741,699,660,623,588,555,524,494,467
1521 dc.w 441,416,392,370,350,330,312,294,278,262,247,233
1522 dc.w 220,208,196,185,175,165,156,147,139,131,123,117
1523 ; Tuning -3
1524 dc.w 875,826,779,736,694,655,619,584,551,520,491,463
1525 dc.w 437,413,390,368,347,328,309,292,276,260,245,232
1526 dc.w 219,206,195,184,174,164,155,146,138,130,123,116
1527 ; Tuning -2
1528 dc.w 868,820,774,730,689,651,614,580,547,516,487,460
1529 dc.w 434,410,387,365,345,325,307,290,274,258,244,230
1530 dc.w 217,205,193,183,172,163,154,145,137,129,122,115
1531 ; Tuning -1
1532 dc.w 862,814,768,725,684,646,610,575,543,513,484,457
1533 dc.w 431,407,384,363,342,323,305,288,272,256,242,228
1534 dc.w 216,203,192,181,171,161,152,144,136,128,121,114
1536 ;/* End of File */