pt-play.s 22 KB

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