PSTT-Play.s 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
  1. opt c-,d+
  2. opt NODEBUG
  3. ;********************************************
  4. ;* VBLANK Interrupt Version *
  5. ;********************************************
  6. ;* ----- PSTTracker V1.xß Playroutine ----- *
  7. ;* John 'SHAYERA' Hinge / PARASITE 1992 *
  8. ;********************************************
  9. DMAWait = 300 ; Set this as low as possible without losing low notes.
  10. n_note EQU 0 ; W
  11. n_cmd EQU 2 ; W
  12. n_cmdlo EQU 3 ; B
  13. n_start EQU 4 ; L
  14. n_length EQU 8 ; W
  15. n_loopstart EQU 10 ; L
  16. n_replen EQU 14 ; W
  17. n_period EQU 16 ; W
  18. n_finetune EQU 18 ; B
  19. n_volume EQU 19 ; B
  20. n_dmabit EQU 20 ; W
  21. n_toneportdirec EQU 22 ; B
  22. n_toneportspeed EQU 23 ; B
  23. n_wantedperiod EQU 24 ; W
  24. n_vibratocmd EQU 26 ; B
  25. n_vibratopos EQU 27 ; B
  26. n_tremolocmd EQU 28 ; B
  27. n_tremolopos EQU 29 ; B
  28. n_wavecontrol EQU 30 ; B
  29. n_glissfunk EQU 31 ; B
  30. n_sampleoffset EQU 32 ; B
  31. n_pattpos EQU 33 ; B
  32. n_loopcount EQU 34 ; B
  33. n_funkoffset EQU 35 ; B
  34. n_wavestart EQU 36 ; L
  35. n_reallength EQU 40 ; W
  36. mt_init
  37. move.w #64,master_volume ;my stuff
  38. clr.w fade_music
  39. move.l current_song_ptr,A0
  40. MOVE.L A0,mt_SongDataPtr
  41. MOVE.L A0,A1
  42. LEA 952(A1),A1
  43. MOVEQ #127,D0
  44. MOVEQ #0,D1
  45. mtloop MOVE.L D1,D2
  46. SUBQ.W #1,D0
  47. mtloop2 MOVE.B (A1)+,D1
  48. CMP.B D2,D1
  49. BGT.S mtloop
  50. DBRA D0,mtloop2
  51. ADDQ.B #1,D2
  52. LEA mt_SampleStarts(PC),A1
  53. ASL.L #8,D2
  54. ASL.L #2,D2
  55. ADD.L #1084,D2
  56. ADD.L A0,D2
  57. MOVE.L D2,A2
  58. MOVEQ #30,D0
  59. mtloop3 CLR.L (A2)
  60. MOVE.L A2,(A1)+
  61. MOVEQ #0,D1
  62. MOVE.W 42(A0),D1
  63. ASL.L #1,D1
  64. ADD.L D1,A2
  65. ADD.L #30,A0
  66. DBRA D0,mtloop3
  67. OR.B #2,$BFE001
  68. MOVE.B #6,mt_speed
  69. CLR.B mt_counter
  70. CLR.B mt_SongPos
  71. CLR.W mt_PatternPos
  72. mt_end CLR.W $DFF0A8
  73. CLR.W $DFF0B8
  74. CLR.W $DFF0C8
  75. CLR.W $DFF0D8
  76. MOVE.W #$F,$DFF096
  77. RTS
  78. mt_music
  79. MOVEM.L D0-D4/A0-A6,-(SP)
  80. ADDQ.B #1,mt_counter
  81. MOVE.B mt_counter(PC),D0
  82. CMP.B mt_speed(PC),D0
  83. BLO.S mt_NoNewNote
  84. CLR.B mt_counter
  85. TST.B mt_PattDelTime2
  86. BEQ.S mt_GetNewNote
  87. BSR.S mt_NoNewAllChannels
  88. BRA mt_dskip
  89. mt_NoNewNote
  90. BSR.S mt_NoNewAllChannels
  91. BRA mt_NoNewPosYet
  92. mt_NoNewAllChannels
  93. LEA $DFF0A0,A5
  94. LEA mt_chan1temp(PC),A6
  95. BSR mt_CheckEfx
  96. LEA $DFF0B0,A5
  97. LEA mt_chan2temp(PC),A6
  98. BSR mt_CheckEfx
  99. LEA $DFF0C0,A5
  100. LEA mt_chan3temp(PC),A6
  101. BSR mt_CheckEfx
  102. LEA $DFF0D0,A5
  103. LEA mt_chan4temp(PC),A6
  104. BRA mt_CheckEfx
  105. mt_GetNewNote
  106. MOVE.L mt_SongDataPtr(PC),A0
  107. LEA 12(A0),A3
  108. LEA 952(A0),A2 ;pattpo
  109. LEA 1084(A0),A0 ;patterndata
  110. MOVEQ #0,D0
  111. MOVEQ #0,D1
  112. MOVE.B mt_SongPos(PC),D0
  113. MOVE.B (A2,D0.W),D1
  114. ASL.L #8,D1
  115. ASL.L #2,D1
  116. ADD.W mt_PatternPos(PC),D1
  117. CLR.W mt_DMACONtemp
  118. LEA $DFF0A0,A5
  119. LEA mt_chan1temp(PC),A6
  120. BSR.S mt_PlayVoice
  121. LEA $DFF0B0,A5
  122. LEA mt_chan2temp(PC),A6
  123. BSR.S mt_PlayVoice
  124. tst.w music_chans_2
  125. bne.s skip_2_chans
  126. LEA $DFF0C0,A5
  127. LEA mt_chan3temp(PC),A6
  128. BSR.S mt_PlayVoice
  129. LEA $DFF0D0,A5
  130. LEA mt_chan4temp(PC),A6
  131. BSR.S mt_PlayVoice
  132. skip_2_chans
  133. BRA mt_SetDMA
  134. mt_PlayVoice
  135. TST.L (A6)
  136. BNE.S mt_plvskip
  137. BSR mt_PerNop
  138. mt_plvskip
  139. MOVE.L (A0,D1.L),(A6)
  140. ADDQ.L #4,D1
  141. MOVEQ #0,D2
  142. MOVE.B n_cmd(A6),D2
  143. AND.B #$F0,D2
  144. LSR.B #4,D2
  145. MOVE.B (A6),D0
  146. AND.B #$F0,D0
  147. OR.B D0,D2
  148. TST.B D2
  149. BEQ mt_SetRegs
  150. MOVEQ #0,D3
  151. LEA mt_SampleStarts(PC),A1
  152. MOVE D2,D4
  153. SUBQ.L #1,D2
  154. ASL.L #2,D2
  155. MULU #30,D4
  156. MOVE.L (A1,D2.L),n_start(A6)
  157. MOVE.W (A3,D4.L),n_length(A6)
  158. MOVE.W (A3,D4.L),n_reallength(A6)
  159. MOVE.B 2(A3,D4.L),n_finetune(A6)
  160. MOVE.B 3(A3,D4.L),n_volume(A6)
  161. MOVE.W 4(A3,D4.L),D3 ; Get repeat
  162. TST.W D3
  163. BEQ.S mt_NoLoop
  164. MOVE.L n_start(A6),D2 ; Get start
  165. ASL.W #1,D3
  166. ADD.L D3,D2 ; Add repeat
  167. MOVE.L D2,n_loopstart(A6)
  168. MOVE.L D2,n_wavestart(A6)
  169. MOVE.W 4(A3,D4.L),D0 ; Get repeat
  170. ADD.W 6(A3,D4.L),D0 ; Add replen
  171. MOVE.W D0,n_length(A6)
  172. MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
  173. MOVEQ #0,D0
  174. MOVE.B n_volume(A6),D0
  175. ****
  176. mulu master_volume,d0
  177. lsr #6,d0
  178. MOVE.W D0,8(A5) ; Set volume
  179. BRA.S mt_SetRegs
  180. mt_NoLoop
  181. MOVE.L n_start(A6),D2
  182. ADD.L D3,D2
  183. MOVE.L D2,n_loopstart(A6)
  184. MOVE.L D2,n_wavestart(A6)
  185. MOVE.W 6(A3,D4.L),n_replen(A6) ; Save replen
  186. MOVEQ #0,D0
  187. MOVE.B n_volume(A6),D0
  188. ****
  189. mulu master_volume,d0
  190. lsr #6,d0
  191. MOVE.W D0,8(A5) ; Set volume
  192. mt_SetRegs
  193. MOVE.W (A6),D0
  194. AND.W #$0FFF,D0
  195. BEQ mt_CheckMoreEfx ; If no note
  196. MOVE.W 2(A6),D0
  197. AND.W #$0FF0,D0
  198. CMP.W #$0E50,D0
  199. BEQ.S mt_DoSetFineTune
  200. MOVE.B 2(A6),D0
  201. AND.B #$0F,D0
  202. CMP.B #3,D0 ; TonePortamento
  203. BEQ.S mt_ChkTonePorta
  204. CMP.B #5,D0
  205. BEQ.S mt_ChkTonePorta
  206. CMP.B #9,D0 ; Sample Offset
  207. BNE.S mt_SetPeriod
  208. BSR mt_CheckMoreEfx
  209. BRA.S mt_SetPeriod
  210. mt_DoSetFineTune
  211. BSR mt_SetFineTune
  212. BRA.S mt_SetPeriod
  213. mt_ChkTonePorta
  214. BSR mt_SetTonePorta
  215. BRA mt_CheckMoreEfx
  216. mt_SetPeriod
  217. MOVEM.L D0-D1/A0-A1,-(SP)
  218. MOVE.W (A6),D1
  219. AND.W #$0FFF,D1
  220. LEA mt_PeriodTable(PC),A1
  221. MOVEQ #0,D0
  222. MOVEQ #36,D7
  223. mt_ftuloop
  224. CMP.W (A1,D0.W),D1
  225. BHS.S mt_ftufound
  226. ADDQ.L #2,D0
  227. DBRA D7,mt_ftuloop
  228. mt_ftufound
  229. MOVEQ #0,D1
  230. MOVE.B n_finetune(A6),D1
  231. MULU #36*2,D1
  232. ADD.L D1,A1
  233. MOVE.W (A1,D0.W),n_period(A6)
  234. MOVEM.L (SP)+,D0-D1/A0-A1
  235. MOVE.W 2(A6),D0
  236. AND.W #$0FF0,D0
  237. CMP.W #$0ED0,D0 ; Notedelay
  238. BEQ mt_CheckMoreEfx
  239. MOVE.W n_dmabit(A6),$DFF096
  240. BTST #2,n_wavecontrol(A6)
  241. BNE.S mt_vibnoc
  242. CLR.B n_vibratopos(A6)
  243. mt_vibnoc
  244. BTST #6,n_wavecontrol(A6)
  245. BNE.S mt_trenoc
  246. CLR.B n_tremolopos(A6)
  247. mt_trenoc
  248. MOVE.L n_start(A6),(A5) ; Set start
  249. MOVE.W n_length(A6),4(A5) ; Set length
  250. MOVE.W n_period(A6),D0
  251. MOVE.W D0,6(A5) ; Set period
  252. MOVE.W n_dmabit(A6),D0
  253. OR.W D0,mt_DMACONtemp
  254. BRA mt_CheckMoreEfx
  255. mt_SetDMA
  256. BSR RasterWait
  257. MOVE.W mt_DMACONtemp(PC),D0
  258. OR.W #$8000,D0
  259. MOVE.W D0,$DFF096
  260. BSR RasterWait
  261. LEA $DFF000,A5
  262. LEA mt_chan4temp(PC),A6
  263. MOVE.L n_loopstart(A6),$D0(A5)
  264. MOVE.W n_replen(A6),$D4(A5)
  265. LEA mt_chan3temp(PC),A6
  266. MOVE.L n_loopstart(A6),$C0(A5)
  267. MOVE.W n_replen(A6),$C4(A5)
  268. LEA mt_chan2temp(PC),A6
  269. MOVE.L n_loopstart(A6),$B0(A5)
  270. MOVE.W n_replen(A6),$B4(A5)
  271. LEA mt_chan1temp(PC),A6
  272. MOVE.L n_loopstart(A6),$A0(A5)
  273. MOVE.W n_replen(A6),$A4(A5)
  274. mt_dskip
  275. ADD.W #16,mt_PatternPos
  276. MOVE.B mt_PattDelTime,D0
  277. BEQ.S mt_dskc
  278. MOVE.B D0,mt_PattDelTime2
  279. CLR.B mt_PattDelTime
  280. mt_dskc TST.B mt_PattDelTime2
  281. BEQ.S mt_dska
  282. SUBQ.B #1,mt_PattDelTime2
  283. BEQ.S mt_dska
  284. SUB.W #16,mt_PatternPos
  285. mt_dska TST.B mt_PBreakFlag
  286. BEQ.S mt_nnpysk
  287. SF mt_PBreakFlag
  288. MOVEQ #0,D0
  289. MOVE.B mt_PBreakPos(PC),D0
  290. CLR.B mt_PBreakPos
  291. LSL.W #4,D0
  292. MOVE.W D0,mt_PatternPos
  293. mt_nnpysk
  294. CMP.W #1024,mt_PatternPos
  295. BLO.S mt_NoNewPosYet
  296. mt_NextPosition
  297. MOVEQ #0,D0
  298. MOVE.B mt_PBreakPos(PC),D0
  299. LSL.W #4,D0
  300. MOVE.W D0,mt_PatternPos
  301. CLR.B mt_PBreakPos
  302. CLR.B mt_PosJumpFlag
  303. ADDQ.B #1,mt_SongPos
  304. AND.B #$7F,mt_SongPos
  305. MOVE.B mt_SongPos(PC),D1
  306. MOVE.L mt_SongDataPtr(PC),A0
  307. CMP.B 950(A0),D1
  308. BLO.S mt_NoNewPosYet
  309. CLR.B mt_SongPos
  310. mt_NoNewPosYet
  311. TST.B mt_PosJumpFlag
  312. BNE.S mt_NextPosition
  313. MOVEM.L (SP)+,D0-D4/A0-A6
  314. RTS
  315. mt_CheckEfx
  316. BSR mt_UpdateFunk
  317. MOVE.W n_cmd(A6),D0
  318. AND.W #$0FFF,D0
  319. BEQ.S mt_PerNop
  320. MOVE.B n_cmd(A6),D0
  321. AND.B #$0F,D0
  322. BEQ.S mt_Arpeggio
  323. CMP.B #1,D0
  324. BEQ mt_PortaUp
  325. CMP.B #2,D0
  326. BEQ mt_PortaDown
  327. CMP.B #3,D0
  328. BEQ mt_TonePortamento
  329. CMP.B #4,D0
  330. BEQ mt_Vibrato
  331. CMP.B #5,D0
  332. BEQ mt_TonePlusVolSlide
  333. CMP.B #6,D0
  334. BEQ mt_VibratoPlusVolSlide
  335. CMP.B #$E,D0
  336. BEQ mt_E_Commands
  337. SetBack MOVE.W n_period(A6),6(A5)
  338. CMP.B #7,D0
  339. BEQ mt_Tremolo
  340. CMP.B #$A,D0
  341. BEQ mt_VolumeSlide
  342. mt_Return2
  343. RTS
  344. mt_PerNop
  345. MOVE.W n_period(A6),6(A5)
  346. RTS
  347. mt_Arpeggio
  348. MOVEQ #0,D0
  349. MOVE.B mt_counter(PC),D0
  350. DIVS #3,D0
  351. SWAP D0
  352. CMP.W #0,D0
  353. BEQ.S mt_Arpeggio2
  354. CMP.W #2,D0
  355. BEQ.S mt_Arpeggio1
  356. MOVEQ #0,D0
  357. MOVE.B n_cmdlo(A6),D0
  358. LSR.B #4,D0
  359. BRA.S mt_Arpeggio3
  360. mt_Arpeggio1
  361. MOVEQ #0,D0
  362. MOVE.B n_cmdlo(A6),D0
  363. AND.B #15,D0
  364. BRA.S mt_Arpeggio3
  365. mt_Arpeggio2
  366. MOVE.W n_period(A6),D2
  367. BRA.S mt_Arpeggio4
  368. mt_Arpeggio3
  369. ASL.W #1,D0
  370. MOVEQ #0,D1
  371. MOVE.B n_finetune(A6),D1
  372. MULU #36*2,D1
  373. LEA mt_PeriodTable(PC),A0
  374. ADD.L D1,A0
  375. MOVEQ #0,D1
  376. MOVE.W n_period(A6),D1
  377. MOVEQ #36,D7
  378. mt_arploop
  379. MOVE.W (A0,D0.W),D2
  380. CMP.W (A0),D1
  381. BHS.S mt_Arpeggio4
  382. ADDQ.L #2,A0
  383. DBRA D7,mt_arploop
  384. RTS
  385. mt_Arpeggio4
  386. MOVE.W D2,6(A5)
  387. RTS
  388. mt_FinePortaUp
  389. TST.B mt_counter
  390. BNE.S mt_Return2
  391. MOVE.B #$0F,mt_LowMask
  392. mt_PortaUp
  393. MOVEQ #0,D0
  394. MOVE.B n_cmdlo(A6),D0
  395. AND.B mt_LowMask(PC),D0
  396. MOVE.B #$FF,mt_LowMask
  397. SUB.W D0,n_period(A6)
  398. MOVE.W n_period(A6),D0
  399. AND.W #$0FFF,D0
  400. CMP.W #113,D0
  401. BPL.S mt_PortaUskip
  402. AND.W #$F000,n_period(A6)
  403. OR.W #113,n_period(A6)
  404. mt_PortaUskip
  405. MOVE.W n_period(A6),D0
  406. AND.W #$0FFF,D0
  407. MOVE.W D0,6(A5)
  408. RTS
  409. mt_FinePortaDown
  410. TST.B mt_counter
  411. BNE mt_Return2
  412. MOVE.B #$0F,mt_LowMask
  413. mt_PortaDown
  414. CLR.W D0
  415. MOVE.B n_cmdlo(A6),D0
  416. AND.B mt_LowMask(PC),D0
  417. MOVE.B #$FF,mt_LowMask
  418. ADD.W D0,n_period(A6)
  419. MOVE.W n_period(A6),D0
  420. AND.W #$0FFF,D0
  421. CMP.W #856,D0
  422. BMI.S mt_PortaDskip
  423. AND.W #$F000,n_period(A6)
  424. OR.W #856,n_period(A6)
  425. mt_PortaDskip
  426. MOVE.W n_period(A6),D0
  427. AND.W #$0FFF,D0
  428. MOVE.W D0,6(A5)
  429. RTS
  430. mt_SetTonePorta
  431. MOVE.L A0,-(SP)
  432. MOVE.W (A6),D2
  433. AND.W #$0FFF,D2
  434. MOVEQ #0,D0
  435. MOVE.B n_finetune(A6),D0
  436. MULU #36*2,D0
  437. LEA mt_PeriodTable(PC),A0
  438. ADD.L D0,A0
  439. MOVEQ #0,D0
  440. mt_StpLoop
  441. CMP.W (A0,D0.W),D2
  442. BHS.S mt_StpFound
  443. ADDQ.W #2,D0
  444. CMP.W #36*2,D0
  445. BLO.S mt_StpLoop
  446. MOVEQ #35*2,D0
  447. mt_StpFound
  448. MOVE.B n_finetune(A6),D2
  449. AND.B #8,D2
  450. BEQ.S mt_StpGoss
  451. TST.W D0
  452. BEQ.S mt_StpGoss
  453. SUBQ.W #2,D0
  454. mt_StpGoss
  455. MOVE.W (A0,D0.W),D2
  456. MOVE.L (SP)+,A0
  457. MOVE.W D2,n_wantedperiod(A6)
  458. MOVE.W n_period(A6),D0
  459. CLR.B n_toneportdirec(A6)
  460. CMP.W D0,D2
  461. BEQ.S mt_ClearTonePorta
  462. BGE mt_Return2
  463. MOVE.B #1,n_toneportdirec(A6)
  464. RTS
  465. mt_ClearTonePorta
  466. CLR.W n_wantedperiod(A6)
  467. RTS
  468. mt_TonePortamento
  469. MOVE.B n_cmdlo(A6),D0
  470. BEQ.S mt_TonePortNoChange
  471. MOVE.B D0,n_toneportspeed(A6)
  472. CLR.B n_cmdlo(A6)
  473. mt_TonePortNoChange
  474. TST.W n_wantedperiod(A6)
  475. BEQ mt_Return2
  476. MOVEQ #0,D0
  477. MOVE.B n_toneportspeed(A6),D0
  478. TST.B n_toneportdirec(A6)
  479. BNE.S mt_TonePortaUp
  480. mt_TonePortaDown
  481. ADD.W D0,n_period(A6)
  482. MOVE.W n_wantedperiod(A6),D0
  483. CMP.W n_period(A6),D0
  484. BGT.S mt_TonePortaSetPer
  485. MOVE.W n_wantedperiod(A6),n_period(A6)
  486. CLR.W n_wantedperiod(A6)
  487. BRA.S mt_TonePortaSetPer
  488. mt_TonePortaUp
  489. SUB.W D0,n_period(A6)
  490. MOVE.W n_wantedperiod(A6),D0
  491. CMP.W n_period(A6),D0
  492. BLT.S mt_TonePortaSetPer
  493. MOVE.W n_wantedperiod(A6),n_period(A6)
  494. CLR.W n_wantedperiod(A6)
  495. mt_TonePortaSetPer
  496. MOVE.W n_period(A6),D2
  497. MOVE.B n_glissfunk(A6),D0
  498. AND.B #$0F,D0
  499. BEQ.S mt_GlissSkip
  500. MOVEQ #0,D0
  501. MOVE.B n_finetune(A6),D0
  502. MULU #36*2,D0
  503. LEA mt_PeriodTable(PC),A0
  504. ADD.W D0,A0
  505. MOVEQ #0,D0
  506. mt_GlissLoop
  507. CMP.W (A0,D0.W),D2
  508. BHS.S mt_GlissFound
  509. ADDQ.W #2,D0
  510. CMP.W #36*2,D0
  511. BLO.S mt_GlissLoop
  512. MOVEQ #35*2,D0
  513. mt_GlissFound
  514. MOVE.W (A0,D0.W),D2
  515. mt_GlissSkip
  516. MOVE.W D2,6(A5) ; Set period
  517. RTS
  518. mt_Vibrato
  519. MOVE.B n_cmdlo(A6),D0
  520. BEQ.S mt_Vibrato2
  521. MOVE.B n_vibratocmd(A6),D2
  522. AND.B #$0F,D0
  523. BEQ.S mt_vibskip
  524. AND.B #$F0,D2
  525. OR.B D0,D2
  526. mt_vibskip
  527. MOVE.B n_cmdlo(A6),D0
  528. AND.B #$F0,D0
  529. BEQ.S mt_vibskip2
  530. AND.B #$0F,D2
  531. OR.B D0,D2
  532. mt_vibskip2
  533. MOVE.B D2,n_vibratocmd(A6)
  534. mt_Vibrato2
  535. MOVE.B n_vibratopos(A6),D0
  536. LEA mt_VibratoTable(PC),A4
  537. LSR.W #2,D0
  538. AND.W #$001F,D0
  539. MOVEQ #0,D2
  540. MOVE.B n_wavecontrol(A6),D2
  541. AND.B #$03,D2
  542. BEQ.S mt_vib_sine
  543. LSL.B #3,D0
  544. CMP.B #1,D2
  545. BEQ.S mt_vib_rampdown
  546. MOVE.B #255,D2
  547. BRA.S mt_vib_set
  548. mt_vib_rampdown
  549. TST.B n_vibratopos(A6)
  550. BPL.S mt_vib_rampdown2
  551. MOVE.B #255,D2
  552. SUB.B D0,D2
  553. BRA.S mt_vib_set
  554. mt_vib_rampdown2
  555. MOVE.B D0,D2
  556. BRA.S mt_vib_set
  557. mt_vib_sine
  558. MOVE.B 0(A4,D0.W),D2
  559. mt_vib_set
  560. MOVE.B n_vibratocmd(A6),D0
  561. AND.W #15,D0
  562. MULU D0,D2
  563. LSR.W #7,D2
  564. MOVE.W n_period(A6),D0
  565. TST.B n_vibratopos(A6)
  566. BMI.S mt_VibratoNeg
  567. ADD.W D2,D0
  568. BRA.S mt_Vibrato3
  569. mt_VibratoNeg
  570. SUB.W D2,D0
  571. mt_Vibrato3
  572. MOVE.W D0,6(A5)
  573. MOVE.B n_vibratocmd(A6),D0
  574. LSR.W #2,D0
  575. AND.W #$003C,D0
  576. ADD.B D0,n_vibratopos(A6)
  577. RTS
  578. mt_TonePlusVolSlide
  579. BSR mt_TonePortNoChange
  580. BRA mt_VolumeSlide
  581. mt_VibratoPlusVolSlide
  582. BSR.S mt_Vibrato2
  583. BRA mt_VolumeSlide
  584. mt_Tremolo
  585. MOVE.B n_cmdlo(A6),D0
  586. BEQ.S mt_Tremolo2
  587. MOVE.B n_tremolocmd(A6),D2
  588. AND.B #$0F,D0
  589. BEQ.S mt_treskip
  590. AND.B #$F0,D2
  591. OR.B D0,D2
  592. mt_treskip
  593. MOVE.B n_cmdlo(A6),D0
  594. AND.B #$F0,D0
  595. BEQ.S mt_treskip2
  596. AND.B #$0F,D2
  597. OR.B D0,D2
  598. mt_treskip2
  599. MOVE.B D2,n_tremolocmd(A6)
  600. mt_Tremolo2
  601. MOVE.B n_tremolopos(A6),D0
  602. LEA mt_VibratoTable(PC),A4
  603. LSR.W #2,D0
  604. AND.W #$001F,D0
  605. MOVEQ #0,D2
  606. MOVE.B n_wavecontrol(A6),D2
  607. LSR.B #4,D2
  608. AND.B #$03,D2
  609. BEQ.S mt_tre_sine
  610. LSL.B #3,D0
  611. CMP.B #1,D2
  612. BEQ.S mt_tre_rampdown
  613. MOVE.B #255,D2
  614. BRA.S mt_tre_set
  615. mt_tre_rampdown
  616. TST.B n_vibratopos(A6)
  617. BPL.S mt_tre_rampdown2
  618. MOVE.B #255,D2
  619. SUB.B D0,D2
  620. BRA.S mt_tre_set
  621. mt_tre_rampdown2
  622. MOVE.B D0,D2
  623. BRA.S mt_tre_set
  624. mt_tre_sine
  625. MOVE.B 0(A4,D0.W),D2
  626. mt_tre_set
  627. MOVE.B n_tremolocmd(A6),D0
  628. AND.W #15,D0
  629. MULU D0,D2
  630. LSR.W #6,D2
  631. MOVEQ #0,D0
  632. MOVE.B n_volume(A6),D0
  633. TST.B n_tremolopos(A6)
  634. BMI.S mt_TremoloNeg
  635. ADD.W D2,D0
  636. BRA.S mt_Tremolo3
  637. mt_TremoloNeg
  638. SUB.W D2,D0
  639. mt_Tremolo3
  640. BPL.S mt_TremoloSkip
  641. CLR.W D0
  642. mt_TremoloSkip
  643. CMP.W #$40,D0
  644. BLS.S mt_TremoloOk
  645. MOVE.W #$40,D0
  646. mt_TremoloOk
  647. ****
  648. mulu master_volume,d0
  649. lsr #6,d0
  650. MOVE.W D0,8(A5)
  651. MOVE.B n_tremolocmd(A6),D0
  652. LSR.W #2,D0
  653. AND.W #$003C,D0
  654. ADD.B D0,n_tremolopos(A6)
  655. RTS
  656. mt_SampleOffset
  657. MOVEQ #0,D0
  658. MOVE.B n_cmdlo(A6),D0
  659. BEQ.S mt_sononew
  660. MOVE.B D0,n_sampleoffset(A6)
  661. mt_sononew
  662. MOVE.B n_sampleoffset(A6),D0
  663. LSL.W #7,D0
  664. CMP.W n_length(A6),D0
  665. BGE.S mt_sofskip
  666. SUB.W D0,n_length(A6)
  667. LSL.W #1,D0
  668. ADD.L D0,n_start(A6)
  669. RTS
  670. mt_sofskip
  671. MOVE.W #$0001,n_length(A6)
  672. RTS
  673. mt_VolumeSlide
  674. MOVEQ #0,D0
  675. MOVE.B n_cmdlo(A6),D0
  676. LSR.B #4,D0
  677. TST.B D0
  678. BEQ.S mt_VolSlideDown
  679. mt_VolSlideUp
  680. ADD.B D0,n_volume(A6)
  681. CMP.B #$40,n_volume(A6)
  682. BMI.S mt_vsuskip
  683. MOVE.B #$40,n_volume(A6)
  684. mt_vsuskip
  685. MOVE.B n_volume(A6),D0
  686. ****
  687. mulu master_volume,d0
  688. lsr #6,d0
  689. MOVE.W D0,8(A5)
  690. RTS
  691. mt_VolSlideDown
  692. MOVEQ #0,D0
  693. MOVE.B n_cmdlo(A6),D0
  694. AND.B #$0F,D0
  695. mt_VolSlideDown2
  696. SUB.B D0,n_volume(A6)
  697. BPL.S mt_vsdskip
  698. CLR.B n_volume(A6)
  699. mt_vsdskip
  700. MOVE.B n_volume(A6),D0
  701. ****
  702. mulu master_volume,d0
  703. lsr #6,d0
  704. MOVE.W D0,8(A5)
  705. RTS
  706. mt_PositionJump
  707. MOVE.B n_cmdlo(A6),D0
  708. SUBQ.B #1,D0
  709. MOVE.B D0,mt_SongPos
  710. mt_pj2 CLR.B mt_PBreakPos
  711. ST mt_PosJumpFlag
  712. RTS
  713. mt_VolumeChange
  714. MOVEQ #0,D0
  715. MOVE.B n_cmdlo(A6),D0
  716. CMP.B #$40,D0
  717. BLS.S mt_VolumeOk
  718. MOVEQ #$40,D0
  719. mt_VolumeOk
  720. MOVE.B D0,n_volume(A6)
  721. ****
  722. mulu master_volume,d0
  723. lsr #6,d0
  724. MOVE.W D0,8(A5)
  725. RTS
  726. mt_PatternBreak
  727. MOVEQ #0,D0
  728. MOVE.B n_cmdlo(A6),D0
  729. MOVE.L D0,D2
  730. LSR.B #4,D0
  731. MULU #10,D0
  732. AND.B #$0F,D2
  733. ADD.B D2,D0
  734. CMP.B #63,D0
  735. BHI.S mt_pj2
  736. MOVE.B D0,mt_PBreakPos
  737. ST mt_PosJumpFlag
  738. RTS
  739. mt_SetSpeed
  740. MOVE.B 3(A6),D0
  741. BEQ mt_Return2
  742. CLR.B mt_counter
  743. MOVE.B D0,mt_speed
  744. RTS
  745. mt_CheckMoreEfx
  746. BSR mt_UpdateFunk
  747. MOVE.B 2(A6),D0
  748. AND.B #$0F,D0
  749. CMP.B #$9,D0
  750. BEQ mt_SampleOffset
  751. CMP.B #$B,D0
  752. BEQ mt_PositionJump
  753. CMP.B #$D,D0
  754. BEQ.S mt_PatternBreak
  755. CMP.B #$E,D0
  756. BEQ.S mt_E_Commands
  757. CMP.B #$F,D0
  758. BEQ.S mt_SetSpeed
  759. CMP.B #$C,D0
  760. BEQ mt_VolumeChange
  761. BRA mt_PerNop
  762. mt_E_Commands
  763. MOVE.B n_cmdlo(A6),D0
  764. AND.B #$F0,D0
  765. LSR.B #4,D0
  766. BEQ.S mt_FilterOnOff
  767. CMP.B #1,D0
  768. BEQ mt_FinePortaUp
  769. CMP.B #2,D0
  770. BEQ mt_FinePortaDown
  771. CMP.B #3,D0
  772. BEQ.S mt_SetGlissControl
  773. CMP.B #4,D0
  774. BEQ mt_SetVibratoControl
  775. CMP.B #5,D0
  776. BEQ mt_SetFineTune
  777. CMP.B #6,D0
  778. BEQ mt_JumpLoop
  779. CMP.B #7,D0
  780. BEQ mt_SetTremoloControl
  781. CMP.B #9,D0
  782. BEQ mt_RetrigNote
  783. CMP.B #$A,D0
  784. BEQ mt_VolumeFineUp
  785. CMP.B #$B,D0
  786. BEQ mt_VolumeFineDown
  787. CMP.B #$C,D0
  788. BEQ mt_NoteCut
  789. CMP.B #$D,D0
  790. BEQ mt_NoteDelay
  791. CMP.B #$E,D0
  792. BEQ mt_PatternDelay
  793. CMP.B #$F,D0
  794. BEQ mt_FunkIt
  795. RTS
  796. mt_FilterOnOff
  797. * MOVE.B n_cmdlo(A6),D0
  798. * AND.B #1,D0
  799. * ASL.B #1,D0
  800. * AND.B #$FD,$BFE001
  801. * OR.B D0,$BFE001
  802. RTS
  803. mt_SetGlissControl
  804. MOVE.B n_cmdlo(A6),D0
  805. AND.B #$0F,D0
  806. AND.B #$F0,n_glissfunk(A6)
  807. OR.B D0,n_glissfunk(A6)
  808. RTS
  809. mt_SetVibratoControl
  810. MOVE.B n_cmdlo(A6),D0
  811. AND.B #$0F,D0
  812. AND.B #$F0,n_wavecontrol(A6)
  813. OR.B D0,n_wavecontrol(A6)
  814. RTS
  815. mt_SetFineTune
  816. MOVE.B n_cmdlo(A6),D0
  817. AND.B #$0F,D0
  818. MOVE.B D0,n_finetune(A6)
  819. RTS
  820. mt_JumpLoop
  821. TST.B mt_counter
  822. BNE mt_Return2
  823. MOVE.B n_cmdlo(A6),D0
  824. AND.B #$0F,D0
  825. BEQ.S mt_SetLoop
  826. TST.B n_loopcount(A6)
  827. BEQ.S mt_jumpcnt
  828. SUBQ.B #1,n_loopcount(A6)
  829. BEQ mt_Return2
  830. mt_jmploop MOVE.B n_pattpos(A6),mt_PBreakPos
  831. ST mt_PBreakFlag
  832. RTS
  833. mt_jumpcnt
  834. MOVE.B D0,n_loopcount(A6)
  835. BRA.S mt_jmploop
  836. mt_SetLoop
  837. MOVE.W mt_PatternPos(PC),D0
  838. LSR.W #4,D0
  839. MOVE.B D0,n_pattpos(A6)
  840. RTS
  841. mt_SetTremoloControl
  842. MOVE.B n_cmdlo(A6),D0
  843. AND.B #$0F,D0
  844. LSL.B #4,D0
  845. AND.B #$0F,n_wavecontrol(A6)
  846. OR.B D0,n_wavecontrol(A6)
  847. RTS
  848. mt_RetrigNote
  849. MOVE.L D1,-(SP)
  850. MOVEQ #0,D0
  851. MOVE.B n_cmdlo(A6),D0
  852. AND.B #$0F,D0
  853. BEQ.S mt_rtnend
  854. MOVEQ #0,D1
  855. MOVE.B mt_counter(PC),D1
  856. BNE.S mt_rtnskp
  857. MOVE.W (A6),D1
  858. AND.W #$0FFF,D1
  859. BNE.S mt_rtnend
  860. MOVEQ #0,D1
  861. MOVE.B mt_counter(PC),D1
  862. mt_rtnskp
  863. DIVU D0,D1
  864. SWAP D1
  865. TST.W D1
  866. BNE.S mt_rtnend
  867. mt_DoRetrig
  868. MOVE.W n_dmabit(A6),$DFF096 ; Channel DMA off
  869. MOVE.L n_start(A6),(A5) ; Set sampledata pointer
  870. MOVE.W n_length(A6),4(A5) ; Set length
  871. BSR RasterWait
  872. MOVE.W n_dmabit(A6),D0
  873. BSET #15,D0
  874. MOVE.W D0,$DFF096
  875. BSR RasterWait
  876. MOVE.L n_loopstart(A6),(A5)
  877. MOVE.L n_replen(A6),4(A5)
  878. mt_rtnend
  879. MOVE.L (SP)+,D1
  880. RTS
  881. mt_VolumeFineUp
  882. TST.B mt_counter
  883. BNE mt_Return2
  884. MOVEQ #0,D0
  885. MOVE.B n_cmdlo(A6),D0
  886. AND.B #$F,D0
  887. BRA mt_VolSlideUp
  888. mt_VolumeFineDown
  889. TST.B mt_counter
  890. BNE mt_Return2
  891. MOVEQ #0,D0
  892. MOVE.B n_cmdlo(A6),D0
  893. AND.B #$0F,D0
  894. BRA mt_VolSlideDown2
  895. mt_NoteCut
  896. MOVEQ #0,D0
  897. MOVE.B n_cmdlo(A6),D0
  898. AND.B #$0F,D0
  899. CMP.B mt_counter(PC),D0
  900. BNE mt_Return2
  901. CLR.B n_volume(A6)
  902. MOVE.W #0,8(A5)
  903. RTS
  904. mt_NoteDelay
  905. MOVEQ #0,D0
  906. MOVE.B n_cmdlo(A6),D0
  907. AND.B #$0F,D0
  908. CMP.B mt_Counter,D0
  909. BNE mt_Return2
  910. MOVE.W (A6),D0
  911. BEQ mt_Return2
  912. MOVE.L D1,-(SP)
  913. BRA mt_DoRetrig
  914. mt_PatternDelay
  915. TST.B mt_counter
  916. BNE mt_Return2
  917. MOVEQ #0,D0
  918. MOVE.B n_cmdlo(A6),D0
  919. AND.B #$0F,D0
  920. TST.B mt_PattDelTime2
  921. BNE mt_Return2
  922. ADDQ.B #1,D0
  923. MOVE.B D0,mt_PattDelTime
  924. RTS
  925. mt_FunkIt
  926. TST.B mt_counter
  927. BNE mt_Return2
  928. MOVE.B n_cmdlo(A6),D0
  929. AND.B #$0F,D0
  930. LSL.B #4,D0
  931. AND.B #$0F,n_glissfunk(A6)
  932. OR.B D0,n_glissfunk(A6)
  933. TST.B D0
  934. BEQ mt_Return2
  935. mt_UpdateFunk
  936. MOVEM.L D1/A0,-(SP)
  937. MOVEQ #0,D0
  938. MOVE.B n_glissfunk(A6),D0
  939. LSR.B #4,D0
  940. BEQ.S mt_funkend
  941. LEA mt_FunkTable(PC),A0
  942. MOVE.B (A0,D0.W),D0
  943. ADD.B D0,n_funkoffset(A6)
  944. BTST #7,n_funkoffset(A6)
  945. BEQ.S mt_funkend
  946. CLR.B n_funkoffset(A6)
  947. MOVE.L n_loopstart(A6),D0
  948. MOVEQ #0,D1
  949. MOVE.W n_replen(A6),D1
  950. ADD.L D1,D0
  951. ADD.L D1,D0
  952. MOVE.L n_wavestart(A6),A0
  953. ADDQ.L #1,A0
  954. CMP.L D0,A0
  955. BLO.S mt_funkok
  956. MOVE.L n_loopstart(A6),A0
  957. mt_funkok
  958. MOVE.L A0,n_wavestart(A6)
  959. MOVEQ #-1,D0
  960. SUB.B (A0),D0
  961. MOVE.B D0,(A0)
  962. mt_funkend
  963. MOVEM.L (SP)+,D1/A0
  964. RTS
  965. RasterWait ;Wait 7 rasterlines
  966. movem.w d0-d1,-(sp)
  967. move.b $dff006,d0
  968. addq.b #7,d0
  969. 1$ move.b $dff006,d1
  970. cmp.b d1,d0
  971. bne.s 1$
  972. movem.w (sp)+,d0-d1
  973. rts
  974. mt_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  975. mt_VibratoTable
  976. dc.b 0, 24, 49, 74, 97,120,141,161
  977. dc.b 180,197,212,224,235,244,250,253
  978. dc.b 255,253,250,244,235,224,212,197
  979. dc.b 180,161,141,120, 97, 74, 49, 24
  980. mt_PeriodTable
  981. ; Tuning 0, Normal
  982. dc.w 856,808,762,720,678,640,604,570,538,508,480,453
  983. dc.w 428,404,381,360,339,320,302,285,269,254,240,226
  984. dc.w 214,202,190,180,170,160,151,143,135,127,120,113
  985. ; Tuning 1
  986. dc.w 850,802,757,715,674,637,601,567,535,505,477,450
  987. dc.w 425,401,379,357,337,318,300,284,268,253,239,225
  988. dc.w 213,201,189,179,169,159,150,142,134,126,119,113
  989. ; Tuning 2
  990. dc.w 844,796,752,709,670,632,597,563,532,502,474,447
  991. dc.w 422,398,376,355,335,316,298,282,266,251,237,224
  992. dc.w 211,199,188,177,167,158,149,141,133,125,118,112
  993. ; Tuning 3
  994. dc.w 838,791,746,704,665,628,592,559,528,498,470,444
  995. dc.w 419,395,373,352,332,314,296,280,264,249,235,222
  996. dc.w 209,198,187,176,166,157,148,140,132,125,118,111
  997. ; Tuning 4
  998. dc.w 832,785,741,699,660,623,588,555,524,495,467,441
  999. dc.w 416,392,370,350,330,312,294,278,262,247,233,220
  1000. dc.w 208,196,185,175,165,156,147,139,131,124,117,110
  1001. ; Tuning 5
  1002. dc.w 826,779,736,694,655,619,584,551,520,491,463,437
  1003. dc.w 413,390,368,347,328,309,292,276,260,245,232,219
  1004. dc.w 206,195,184,174,164,155,146,138,130,123,116,109
  1005. ; Tuning 6
  1006. dc.w 820,774,730,689,651,614,580,547,516,487,460,434
  1007. dc.w 410,387,365,345,325,307,290,274,258,244,230,217
  1008. dc.w 205,193,183,172,163,154,145,137,129,122,115,109
  1009. ; Tuning 7
  1010. dc.w 814,768,725,684,646,610,575,543,513,484,457,431
  1011. dc.w 407,384,363,342,323,305,288,272,256,242,228,216
  1012. dc.w 204,192,181,171,161,152,144,136,128,121,114,108
  1013. ; Tuning -8
  1014. dc.w 907,856,808,762,720,678,640,604,570,538,508,480
  1015. dc.w 453,428,404,381,360,339,320,302,285,269,254,240
  1016. dc.w 226,214,202,190,180,170,160,151,143,135,127,120
  1017. ; Tuning -7
  1018. dc.w 900,850,802,757,715,675,636,601,567,535,505,477
  1019. dc.w 450,425,401,379,357,337,318,300,284,268,253,238
  1020. dc.w 225,212,200,189,179,169,159,150,142,134,126,119
  1021. ; Tuning -6
  1022. dc.w 894,844,796,752,709,670,632,597,563,532,502,474
  1023. dc.w 447,422,398,376,355,335,316,298,282,266,251,237
  1024. dc.w 223,211,199,188,177,167,158,149,141,133,125,118
  1025. ; Tuning -5
  1026. dc.w 887,838,791,746,704,665,628,592,559,528,498,470
  1027. dc.w 444,419,395,373,352,332,314,296,280,264,249,235
  1028. dc.w 222,209,198,187,176,166,157,148,140,132,125,118
  1029. ; Tuning -4
  1030. dc.w 881,832,785,741,699,660,623,588,555,524,494,467
  1031. dc.w 441,416,392,370,350,330,312,294,278,262,247,233
  1032. dc.w 220,208,196,185,175,165,156,147,139,131,123,117
  1033. ; Tuning -3
  1034. dc.w 875,826,779,736,694,655,619,584,551,520,491,463
  1035. dc.w 437,413,390,368,347,328,309,292,276,260,245,232
  1036. dc.w 219,206,195,184,174,164,155,146,138,130,123,116
  1037. ; Tuning -2
  1038. dc.w 868,820,774,730,689,651,614,580,547,516,487,460
  1039. dc.w 434,410,387,365,345,325,307,290,274,258,244,230
  1040. dc.w 217,205,193,183,172,163,154,145,137,129,122,115
  1041. ; Tuning -1
  1042. dc.w 862,814,768,725,684,646,610,575,543,513,484,457
  1043. dc.w 431,407,384,363,342,323,305,288,272,256,242,228
  1044. dc.w 216,203,192,181,171,161,152,144,136,128,121,114
  1045. mt_chan1temp dc.l 0,0,0,0,0,$00010000,0, 0,0,0,0
  1046. mt_chan2temp dc.l 0,0,0,0,0,$00020000,0, 0,0,0,0
  1047. mt_chan3temp dc.l 0,0,0,0,0,$00040000,0, 0,0,0,0
  1048. mt_chan4temp dc.l 0,0,0,0,0,$00080000,0, 0,0,0,0
  1049. mt_SampleStarts dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1050. dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  1051. mt_SongDataPtr dc.l 0
  1052. mt_speed dc.b 6
  1053. mt_counter dc.b 0
  1054. mt_SongPos dc.b 0
  1055. mt_PBreakPos dc.b 0
  1056. mt_PosJumpFlag dc.b 0
  1057. mt_PBreakFlag dc.b 0
  1058. mt_LowMask dc.b 0
  1059. mt_PattDelTime dc.b 0
  1060. mt_PattDelTime2 dc.b 0,0
  1061. mt_PatternPos dc.w 0
  1062. mt_DMACONtemp dc.w 0
  1063. master_volume dc.w 64
  1064. current_song_ptr dc.l 0
  1065. ;/* End of File */
  1066. xref.w fade_music
  1067. xref.w music_chans_2
  1068. xdef.w master_volume
  1069. xdef.l current_song_ptr
  1070. xdef mt_init
  1071. xdef mt_music
  1072. xdef mt_end