ATOMS.ASM 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. ; Watch out! It's The ATOMS game on the Amiga!!!! Done by Tom. Excellent.
  2. openlibrary = -552
  3. allocmem = -198
  4. freemem = -210
  5. logosize = 40*44*3
  6. memsize = 40*200*4+logosize
  7. bplcon0 = $100
  8. bplcon1 = $102
  9. bplcon2 = $104
  10. bpl1mod = $108
  11. bpl2mod = $10a
  12. ddfstrt = $92
  13. ddfstop = $94
  14. diwstrt = $8e
  15. diwstop = $90
  16. bpl1pth = $e0
  17. bpl1ptl = $e2
  18. bpl2pth = $e4
  19. bpl2ptl = $e6
  20. bpl3pth = $e8
  21. bpl3ptl = $ea
  22. bpl4pth = $ec
  23. bpl4ptl = $ee
  24. col00 = $180
  25. col01 = $182
  26. col02 = $184
  27. col03 = $186
  28. col04 = $188
  29. col05 = $18a
  30. col06 = $18c
  31. col07 = $18e
  32. col08 = $190
  33. col09 = $192
  34. col10 = $194
  35. col11 = $196
  36. col12 = $198
  37. col13 = $19a
  38. col14 = $19c
  39. col15 = $19e
  40. col16 = $1a0
  41. col17 = $1a2
  42. col18 = $1a4
  43. col19 = $1a6
  44. spr0pth = $120
  45. spr0ptl = $122
  46. spr1pth = $124
  47. spr1ptl = $126
  48. spr2pth = $128
  49. spr2ptl = $12a
  50. spr3pth = $12c
  51. spr3ptl = $12e
  52. spr4pth = $130
  53. spr4ptl = $132
  54. spr5pth = $134
  55. spr5ptl = $136
  56. spr6pth = $138
  57. spr6ptl = $13a
  58. spr7pth = $13c
  59. spr7ptl = $13e
  60. section Atoms+++++++++,CODE_C
  61. start:
  62. lea $dff000,a5
  63. bsr killsystem
  64. bsr waitblit
  65. bsr allocate
  66. tst.l d0
  67. beq.s error
  68. bsr initvars2
  69. bsr newcopper
  70. playagain:
  71. jsr mt_init
  72. bsr initvariables
  73. bsr askplayers
  74. bsr initcolours
  75. st musicflag
  76. bsr startscreen
  77. bsr mainloop
  78. tst.b d4
  79. beq.s playagain
  80. bsr waitblit
  81. bsr oldcopper
  82. bsr free
  83. jsr mt_end
  84. error:
  85. bsr freesystem
  86. clr.l d0
  87. rts
  88. waitblit:
  89. btst #14,2(a5)
  90. bne.s waitblit
  91. rts
  92. blankplane:
  93. btst #14,2(a5)
  94. bne.s blankplane
  95. move.l planeaddr,$54(a5)
  96. clr.w $42(a5)
  97. clr.w $66(a5)
  98. move.l #-1,$44(a5)
  99. move.w #%100000000,$40(a5)
  100. move.w #200*64+20,$58(a5)
  101. rts
  102. blankplane2:
  103. btst #14,2(a5)
  104. bne.s blankplane2
  105. move.l planeaddr,$54(a5)
  106. clr.w $42(a5)
  107. clr.w $66(a5)
  108. move.l #-1,$44(a5)
  109. move.w #%100000000,$40(a5)
  110. move.w #800*64+20,$58(a5)
  111. rts
  112. askplayers:
  113. bsr blankplane2
  114. bsr waitblit
  115. lea text1,a0
  116. move.w #40*20,d0
  117. bsr textoutput
  118. lea text2,a0
  119. move.w #40*50+16,d0
  120. bsr textoutput
  121. wb:
  122. btst #6,$bfe001
  123. bne.s wb
  124. move.w mousex,d0
  125. move.w mousey,d1
  126. cmp.w #45,d1
  127. blt.s wb
  128. cmp.w #60,d1
  129. bgt.s wb
  130. cmp.w #118,d0
  131. blt.s wb
  132. moveq #2,d4
  133. cmp.w #145,d0
  134. blt.s hit
  135. moveq #3,d4
  136. cmp.w #178,d0
  137. blt.s hit
  138. moveq #4,d4
  139. cmp.w #208,d0
  140. bgt.s wb
  141. hit:
  142. subq #1,d4
  143. move.w d4,players
  144. move.w d4,playerno
  145. rts
  146. textoutput:
  147. lea font,a2
  148. move.l planeaddr,a1
  149. add.w d0,a1
  150. nextchar:
  151. clr.w d0
  152. move.b (a0)+,d0
  153. blt.s endtext
  154. sub.b #'a',d0
  155. blt.s space
  156. add.w d0,d0
  157. moveq #15,d7
  158. move.l a1,a3
  159. textloop:
  160. move.w 0(a2,d0.w),(a3)
  161. add.w #480/8,d0
  162. lea 40(a3),a3
  163. dbf d7,textloop
  164. space:
  165. lea 2(a1),a1
  166. bra.s nextchar
  167. endtext:
  168. rts
  169. startscreen:
  170. cmp.w #1,framecount
  171. blt.s startscreen
  172. clr.w framecount
  173. move.w #1590,d0
  174. sub.w distance,d0
  175. move.w d0,rot
  176. bsr rotateaxis
  177. bsr blankplane
  178. bsr drawgrid
  179. add.w #20,distance
  180. cmp.w #1610,distance
  181. ble.s startscreen
  182. bsr initscreen
  183. rts
  184. rotateaxis:
  185. move.w rot,d0
  186. add.w d0,d0
  187. lea sinewave,a0
  188. lea 1800(a0),a1
  189. move.w 0(a1,d0.w),d1
  190. move.w 0(a0,d0.w),d0
  191. move.w d0,sin1+2
  192. move.w d0,sin2+2
  193. move.w d1,cos1+2
  194. move.w d1,cos2+2
  195. rts
  196. rotate:
  197. movem.w d0-1,-(sp)
  198. move.w d2,d0
  199. move.w d3,d1
  200. sin1 muls #0,d2
  201. cos1 muls #0,d3
  202. add.l d2,d3
  203. asr.l #7,d3
  204. sin2 muls #0,d1
  205. cos2 muls #0,d0
  206. sub.l d1,d0
  207. asr.l #7,d0
  208. move.w d0,d2
  209. movem.w (sp)+,d0-1
  210. rts
  211. drawgrid:
  212. lea coords,a0
  213. move.w (a0)+,d7
  214. nextline:
  215. move.w (a0)+,d2
  216. move.w (a0)+,d3
  217. bsr rotate
  218. move.w distance,d4
  219. move.w d2,d0
  220. move.w d3,d1
  221. ext.l d0
  222. ext.l d1
  223. asl.l #8,d0
  224. asl.l #8,d1
  225. divs d4,d0
  226. divs d4,d1
  227. add.w #160,d0
  228. add.w #96,d1
  229. move.w (a0)+,d2
  230. move.w (a0)+,d3
  231. bsr rotate
  232. move.w distance,d4
  233. ext.l d2
  234. ext.l d3
  235. asl.l #8,d2
  236. asl.l #8,d3
  237. divs d4,d2
  238. divs d4,d3
  239. add.w #160,d2
  240. add.w #96,d3
  241. bsr drawline
  242. dbf d7,nextline
  243. rts
  244. initvars2:
  245. clr.w musicflag
  246. clr.w colours+6
  247. st fadeflag
  248. clr.w slider
  249. clr.w framecount
  250. move.w #-16,slider2
  251. clr.w mousex
  252. clr.w mousey
  253. clr.w oldmousex
  254. clr.w oldmousey
  255. rts
  256. initvariables:
  257. clr.w xrot
  258. move.w #650,yrot
  259. clr.w rot
  260. clr.w explosion
  261. move.w #-1,winner
  262. move.w #20,distance
  263. clr.w quitflag
  264. clr.w player
  265. lea playersin,a0
  266. move.l #$01010101,(a0)
  267. lea startdata,a0
  268. lea enddata,a1
  269. loop10:
  270. clr.b (a0)+
  271. cmp.l a0,a1
  272. bne.s loop10
  273. lea blocklookup,a0
  274. lea tiles+32,a1
  275. move.w #255,d7
  276. clr.l d2
  277. loop13:
  278. move.l d2,d3
  279. divu #19,d3
  280. move.l d3,d4
  281. swap d4
  282. add.w d4,d4
  283. mulu #38*16,d3
  284. add.w d4,d3
  285. lea 0(a1,d3.w),a2
  286. move.l a2,(a0)+
  287. add.w #1,d2
  288. dbf d7,loop13
  289. rts
  290. drawline:
  291. movem.l d0-7/a0-6,-(sp)
  292. bsr clipping
  293. tst.w d5
  294. bne noline
  295. moveq #40,d4
  296. muls d1,d4
  297. moveq #-$10,d5
  298. and.w d0,d5
  299. asr.w #3,d5
  300. add.w d5,d4
  301. add.l planeaddr,d4
  302. clr.l d5
  303. sub.w d1,d3
  304. roxl.b #1,d5
  305. tst.w d3
  306. bge.s y2gy1
  307. neg.w d3
  308. y2gy1:
  309. sub.w d0,d2
  310. roxl.b #1,d5
  311. tst.w d2
  312. bge.s x2gx1
  313. neg.w d2
  314. x2gx1:
  315. move.w d3,d1
  316. sub.w d2,d1
  317. bge.s dygdx
  318. exg d2,d3
  319. dygdx:
  320. roxl.b #1,d5
  321. tst.w d3
  322. beq noline
  323. wblit:
  324. btst #14,2(a5)
  325. bne.s wblit
  326. move.b octant_table(pc,d5.w),d5
  327. add.w d2,d2
  328. move.w d2,$62(a5)
  329. sub.w d3,d2
  330. bgt.s signn1
  331. or.b #$40,d5
  332. signn1:
  333. move.w d2,$52(a5)
  334. sub.w d3,d2
  335. move.w d2,$64(a5)
  336. move.w #$8000,$74(a5)
  337. move.w #$ffff,$72(a5)
  338. move.w #$ffff,$44(a5)
  339. and.w #$f,d0
  340. ror.w #4,d0
  341. or.w #$bca,d0
  342. move.w d0,$40(a5)
  343. move.w d5,$42(a5)
  344. move.l d4,$54(a5)
  345. move.l d4,$48(a5)
  346. move.w #40,$66(a5)
  347. move.w #40,$60(a5)
  348. lsl.w #6,d3
  349. addq #2,d3
  350. move.w d3,$58(a5)
  351. noline:
  352. movem.l (sp)+,d0-7/a0-6
  353. rts
  354. octant_table dc.b 1,17,9,21,5,25,13,29
  355. initscreen:
  356. lea blocksequ,a0
  357. move.w #59,d7
  358. nextblock6:
  359. cmp.w #1,framecount
  360. blt.s nextblock6
  361. clr.w framecount
  362. move.w (a0)+,d0
  363. ext.l d0
  364. divu #10,d0
  365. move.l d0,d1
  366. swap d0
  367. move.w #19*12,d2
  368. bsr drawblock
  369. dbf d7,nextblock6
  370. lea playersin,a0
  371. move.w #19*12+2,d2
  372. clr.w d0
  373. moveq #6,d1
  374. move.w players,d7
  375. playerloop:
  376. bsr drawblock
  377. addq #1,d0
  378. addq #1,d2
  379. dbf d7,playerloop
  380. rts
  381. mainloop:
  382. cmp.w #1,framecount
  383. blt.s mainloop
  384. clr.w framecount
  385. bsr morphhandle
  386. bsr leftclick
  387. bsr playerhandler
  388. btst #10,$16(a5)
  389. beq nowinn
  390. add.w #1,toggler
  391. and.w #1,toggler
  392. tst.w quitflag
  393. beq.s mainloop
  394. sf musicflag
  395. jsr mt_end
  396. lea text3,a0
  397. move.w #40*8+12,d0
  398. bsr textoutput
  399. lea text4,a0
  400. move.w #40*26+6,d0
  401. bsr textoutput
  402. wb2:
  403. btst #6,$bfe001
  404. bne.s wb2
  405. cmp.w #25,mousey
  406. blt.s wb2
  407. cmp.w #40,mousey
  408. bgt.s wb2
  409. cmp.w #230,mousex
  410. blt.s wb2
  411. clr.w d4
  412. cmp.w #260,mousex
  413. blt.s exit
  414. st d4
  415. cmp.w #290,mousex
  416. bgt.s wb2
  417. exit:
  418. rts
  419. nowinn:
  420. st d4
  421. rts
  422. playerhandler:
  423. move.w player,d0
  424. lea collook,a0
  425. add.w d0,d0
  426. move.w 0(a0,d0.w),pointercol
  427. rts
  428. morphhandle:
  429. lea sequences,a1
  430. lea datatable,a2
  431. lea inusetable,a4
  432. lea morphtable,a0
  433. tst.w (a0)
  434. beq.s nomorphs
  435. move.w 2(a0),d0
  436. move.w 4(a0),d1
  437. move.w d0,d4
  438. move.w d1,d5
  439. mulu #10,d5
  440. add.w d5,d4
  441. clr.l d5
  442. move.b 0(a2,d4.w),d5
  443. add.w d5,d5
  444. add.w d5,d5
  445. move.l 0(a1,d5.w),a3
  446. add.w 6(a0),a3
  447. add.w #2,6(a0)
  448. move.w (a3),d2
  449. blt.s endmorph
  450. move.w 8(a0),d3
  451. mulu #19*3,d3
  452. add.w d3,d2
  453. bsr drawblock
  454. nomorphs:
  455. rts
  456. endmorph:
  457. add.b #1,0(a2,d4.w)
  458. clr.w (a0)
  459. clr.b 0(a4,d4.w)
  460. bsr checkreactions
  461. bsr rubexplosion
  462. lea playersin,a0
  463. playerout:
  464. add.w #1,player
  465. move.w players,d6
  466. cmp.w player,d6
  467. bge.s firstplayer
  468. clr.w player
  469. firstplayer:
  470. move.w player,d0
  471. tst.b 0(a0,d0.w)
  472. beq.s playerout
  473. rts
  474. noreact:
  475. rts
  476. checkreactions:
  477. tst.w quitflag
  478. bne.s noreact
  479. movem.l d0-7/a0-6,-(sp)
  480. move.w d0,d2
  481. move.w d1,d3
  482. mulu #10,d3
  483. add.w d2,d3
  484. move.w d3,d4
  485. move.w d0,d2
  486. move.w d1,d3
  487. ext.l d2
  488. ext.l d3
  489. divu #10,d2
  490. divu #6,d3
  491. swap d2
  492. swap d3
  493. tst.w d2
  494. beq.s edge1
  495. cmp.w #9,d2
  496. beq.s edge1
  497. tst.w d3
  498. beq.s edge2
  499. cmp.w #5,d3
  500. beq.s edge2
  501. centre:
  502. move.w #4,d3
  503. bra.s checkexplode
  504. edge1:
  505. tst.w d3
  506. beq.s corner
  507. cmp.w #5,d3
  508. beq.s corner
  509. bra.s edge3
  510. edge2:
  511. tst.w d2
  512. beq.s corner
  513. cmp.w #9,d2
  514. beq.s corner
  515. edge3:
  516. move.w #3,d3
  517. bra.s checkexplode
  518. corner:
  519. move.w #2,d3
  520. checkexplode:
  521. lea datatable,a2
  522. cmp.b 0(a2,d4.w),d3
  523. ble.s explode
  524. movem.l (sp)+,d0-7/a0-6
  525. rts
  526. explode:
  527. bsr rubexplosion
  528. lea ownertable,a3
  529. lea inusetable,a4
  530. clr.b 0(a2,d4.w)
  531. clr.b 0(a4,d4.w)
  532. clr.b 0(a3,d4.w)
  533. move.w #19*12+1,d2
  534. move.w #1,explosion
  535. move.w d0,explosion+2
  536. move.w d1,explosion+4
  537. bsr drawblock
  538. waitframe:
  539. cmp.w #5,framecount
  540. blt.s waitframe
  541. clr.w framecount
  542. move.w d1,-(sp)
  543. addq #1,d1
  544. bsr spread
  545. subq #2,d1
  546. bsr spread
  547. move.w (sp)+,d1
  548. addq #1,d0
  549. bsr spread
  550. subq #2,d0
  551. bsr spread
  552. bsr checkforwinner
  553. movem.l (sp)+,d0-7/a0-6
  554. rts
  555. rubexplosion:
  556. tst.w explosion
  557. beq.s oldexplosion
  558. movem.w d0-2,-(sp)
  559. move.w explosion+2,d0
  560. move.w explosion+4,d1
  561. move.w #19*12,d2
  562. clr.w explosion
  563. bsr drawblock
  564. movem.w (sp)+,d0-2
  565. oldexplosion:
  566. rts
  567. checkforwinner:
  568. movem.l d3-4/d7/a0,-(sp)
  569. lea flags,a1
  570. clr.l (a1)
  571. lea ownertable,a0
  572. move.w #10*6-1,d7
  573. loop19:
  574. clr.w d4
  575. move.b (a0)+,d4
  576. subq #1,d4
  577. blt.s emptysquare2
  578. add.b #1,0(a1,d4.w)
  579. emptysquare2:
  580. dbf d7,loop19
  581. lea playersin,a0
  582. move.w players,d7
  583. clr.w d2
  584. loop21:
  585. tst.b (a0)
  586. beq.s stillthere
  587. tst.b (a1)
  588. bne.s stillthere
  589. movem.w d0-2,-(sp)
  590. move.w d2,d0
  591. add.w #19*12+6,d2
  592. moveq #6,d1
  593. bsr drawblock
  594. movem.w (sp)+,d0-2
  595. clr.b (a0)
  596. sub.w #1,playerno
  597. bne.s stillthere
  598. st quitflag
  599. lea playersin,a0
  600. clr.w d2
  601. testnext:
  602. move.w d2,winner
  603. tst.b (a0)+
  604. bne.s gameover
  605. addq #1,d2
  606. bra.s testnext
  607. stillthere:
  608. add.l #1,a0
  609. add.l #1,a1
  610. addq #1,d2
  611. dbf d7,loop21
  612. gameover:
  613. movem.l (sp)+,d3-4/d7/a0
  614. rts
  615. spread:
  616. movem.w d0-7/a0-2,-(sp)
  617. tst.w d0
  618. blt.s nospread
  619. tst.w d1
  620. blt.s nospread
  621. cmp.w #5,d1
  622. bgt.s nospread
  623. cmp.w #9,d0
  624. bgt.s nospread
  625. move.w d0,d2
  626. move.w d1,d3
  627. mulu #10,d3
  628. add.w d2,d3
  629. lea ownertable,a0
  630. lea datatable,a1
  631. lea sequ,a2
  632. move.w player,d4
  633. move.w d4,d5
  634. addq #1,d4
  635. move.b d4,0(a0,d3.w)
  636. add.b #1,0(a1,d3.w)
  637. clr.w d2
  638. move.b 0(a1,d3.w),d2
  639. add.w d2,d2
  640. move.w 0(a2,d2.w),d2
  641. mulu #19*3,d5
  642. add.w d5,d2
  643. bsr drawblock
  644. bsr checkreactions
  645. nospread:
  646. movem.w (sp)+,d0-7/a0-2
  647. rts
  648. drawblock:
  649. movem.l d0-7/a0-6,-(sp)
  650. mulu #40*16,d1
  651. add.w d0,d0
  652. add.w d0,d1
  653. move.l planeaddr,a0
  654. add.w d1,a0
  655. add.l #10+48*40,a0
  656. lea blocklookup,a1
  657. add.w d2,d2
  658. add.w d2,d2
  659. move.l 0(a1,d2.w),a1
  660. move.w #15,d7
  661. loop12:
  662. move.w (a1),(a0)
  663. move.w 208*38(a1),200*40(a0)
  664. move.w 2*208*38(a1),2*200*40(a0)
  665. move.w 3*208*38(a1),3*200*40(a0)
  666. lea 38(a1),a1
  667. lea 40(a0),a0
  668. dbf d7,loop12
  669. movem.l (sp)+,d0-7/a0-6
  670. rts
  671. leftclick:
  672. btst #6,$bfe001
  673. beq.s buttondown
  674. clr.w buttonflag
  675. rts
  676. buttondown:
  677. tst.w buttonflag
  678. bne.s nohit
  679. st buttonflag
  680. move.w mousex,d0
  681. move.w mousey,d1
  682. lsr.w #4,d0
  683. lsr.w #4,d1
  684. sub.w #5,d0
  685. blt.s nohit
  686. sub.w #3,d1
  687. blt.s nohit
  688. cmp.w #10,d0
  689. bge.s nohit
  690. cmp.w #6,d1
  691. bge.s nohit
  692. bsr startmorph
  693. nohit:
  694. rts
  695. startmorph:
  696. move.w d0,d4
  697. move.w d1,d5
  698. mulu #10,d5
  699. add.w d5,d4
  700. lea inusetable,a1
  701. lea datatable,a2
  702. lea ownertable,a3
  703. move.w player,d3
  704. addq.w #1,d3
  705. move.b 0(a3,d4.w),d2
  706. beq.s emptysquare
  707. cmp.b d3,d2
  708. bne.s inusemate
  709. emptysquare:
  710. cmp.b #4,0(a2,d4.w)
  711. beq.s inusemate
  712. tst.b 0(a1,d4.w)
  713. bne.s inusemate
  714. lea morphtable,a0
  715. tst.w (a0)
  716. beq.s foundspace
  717. rts
  718. foundspace:
  719. move.b #1,0(a1,d4.w)
  720. move.w #1,(a0)
  721. move.w d0,2(a0)
  722. move.w d1,4(a0)
  723. clr.w 6(a0)
  724. move.w player,8(a0)
  725. move.b d3,0(a3,d4.w)
  726. inusemate:
  727. rts
  728. allocate:
  729. move.l #$10002,d1
  730. move.l #memsize,d0
  731. move.l 4,a6
  732. jsr allocmem(a6)
  733. move.l d0,planeaddr
  734. move.l d0,d1
  735. add.l #40*200*4,d1
  736. move.l d1,logoaddr
  737. rts
  738. free:
  739. move.l planeaddr,a1
  740. move.l #memsize,d0
  741. move.l 4,a6
  742. jsr freemem(a6)
  743. rts
  744. newcopper:
  745. bsr initplanes
  746. bsr initcolours2
  747. bsr initsprites
  748. move.l #copperlist,$80(a5)
  749. clr.w $88(a5)
  750. move.w #$83e0,$96(a5)
  751. move.w #$c010,$9a(a5)
  752. rts
  753. initsprites:
  754. lea sprites,a0
  755. move.l #mousepointer,d0
  756. move.w d0,2(a0)
  757. swap d0
  758. move.w d0,6(a0)
  759. lea 8(a0),a0
  760. move.l #blanksprite,d0
  761. move.w #6,d7
  762. loop7:
  763. move.w d0,2(a0)
  764. swap d0
  765. move.w d0,6(a0)
  766. swap d0
  767. lea 8(a0),a0
  768. dbf d7,loop7
  769. rts
  770. initcolours:
  771. lea colours,a0
  772. lea tiles,a1
  773. moveq #15,d7
  774. loop2:
  775. move.w (a1)+,2(a0)
  776. lea 4(a0),a0
  777. dbf d7,loop2
  778. rts
  779. initcolours2:
  780. lea colours2,a0
  781. moveq #7,d7
  782. loop91:
  783. clr.w 2(a0)
  784. lea 4(a0),a0
  785. dbf d7,loop91
  786. rts
  787. initplanes:
  788. lea planes,a0
  789. move.l planeaddr,d0
  790. moveq #3,d7
  791. loop1:
  792. move.w d0,2(a0)
  793. swap d0
  794. move.w d0,6(a0)
  795. swap d0
  796. add.l #40*200,d0
  797. lea 8(a0),a0
  798. dbf d7,loop1
  799. lea planes2,a0
  800. move.l logoaddr,d0
  801. moveq #2,d7
  802. loop90:
  803. move.w d0,2(a0)
  804. swap d0
  805. move.w d0,6(a0)
  806. swap d0
  807. add.l #44*40,d0
  808. lea 8(a0),a0
  809. dbf d7,loop90
  810. rts
  811. oldcopper:
  812. clr.l d0
  813. lea grname,a1
  814. move.l 4,a6
  815. jsr openlibrary(a6)
  816. move.l d0,a1
  817. move.l 38(a1),$80(a5)
  818. clr.w $88(a5)
  819. rts
  820. killsystem:
  821. move.w 2(a5),d0
  822. or.w #$8000,d0
  823. move.w d0,dmasave+2
  824. move.w $1c(a5),d0
  825. or.w #$c000,d0
  826. move.w d0,intsave+2
  827. move.l $6c,vecsave+2
  828. move.w #$7fff,d0
  829. move.w d0,$96(a5)
  830. move.w d0,$9a(a5)
  831. move.l #inter,$6c
  832. rts
  833. freesystem:
  834. vecsave move.l #0,$6c
  835. dmasave move.w #0,$96(a5)
  836. intsave move.w #0,$9a(a5)
  837. rts
  838. inter:
  839. movem.l d0-7/a0-6,-(sp)
  840. lea $dff000,a5
  841. add.w #1,framecount
  842. bsr readmouse
  843. bsr drawlogo
  844. bsr fades
  845. move.w slider,colours+6
  846. cmp.w #$fff,slider
  847. beq.s white
  848. add.w #$111,slider
  849. white:
  850. tst.w musicflag
  851. beq.s nomusic
  852. jsr mt_music
  853. nomusic:
  854. lea $dff000,a5
  855. move.w #$10,$9c(a5)
  856. movem.l (sp)+,d0-7/a0-6
  857. rte
  858. drawlogo:
  859. btst #14,2(a5)
  860. bne.s drawlogo
  861. move.l logoaddr,d0
  862. add.l #10,d0
  863. move.l d0,$54(a5)
  864. clr.w $42(a5)
  865. move.w #%100000000,$40(a5)
  866. move.l #-1,$44(a5)
  867. move.w #40-20,$66(a5)
  868. move.w #44*3*64+10,$58(a5)
  869. lea sinewave,a0
  870. lea 1800(a0),a1
  871. move.w xrot,d0
  872. move.w yrot,d2
  873. add.w d0,d0
  874. add.w d2,d2
  875. move.w 0(a1,d0.w),d1
  876. move.w 0(a0,d0.w),d0
  877. move.w 0(a1,d2.w),d3
  878. move.w 0(a1,d2.w),d2
  879. move.l d2,-(sp)
  880. add.w #128,d2
  881. muls d0,d2
  882. blt.s behind
  883. move.l (sp)+,d2
  884. bsr blitlogo
  885. asr.w #3,d0
  886. asr.w #3,d1
  887. asr.w #3,d2
  888. muls d2,d0
  889. asr.w #4,d0
  890. add.w #154,d0
  891. add.w #16,d1
  892. bsr bob
  893. bra.s infront
  894. behind:
  895. move.l (sp)+,d2
  896. asr.w #3,d0
  897. asr.w #3,d1
  898. asr.w #3,d2
  899. muls d2,d0
  900. asr.w #4,d0
  901. add.w #154,d0
  902. add.w #16,d1
  903. bsr bob
  904. bsr blitlogo
  905. infront:
  906. sub.w #100,xrot
  907. bge.s nolim
  908. add.w #3600,xrot
  909. nolim:
  910. sub.w #5,yrot
  911. bge.s nolim2
  912. add.w #3600,yrot
  913. nolim2:
  914. rts
  915. blitlogo:
  916. movem.w d0-3,-(sp)
  917. move.l #logo+16,d3
  918. move.l #mask,d4
  919. wblit8:
  920. btst #14,2(a5)
  921. bne.s wblit8
  922. move.l logoaddr,d0
  923. add.l #10,d0
  924. move.l d3,$50(a5)
  925. move.w #40-20,$60(a5)
  926. clr.w $42(a5)
  927. move.w #40-20,$66(a5)
  928. move.w #4,$64(a5)
  929. move.w #4,$62(a5)
  930. move.l #-1,$44(a5)
  931. move.w #%111111110010,$40(a5)
  932. moveq #2,d7
  933. wblit7:
  934. btst #14,2(a5)
  935. bne.s wblit7
  936. move.l d0,$54(a5)
  937. move.l d0,$48(a5)
  938. move.l d4,$4c(a5)
  939. move.w #44*64+10,$58(a5)
  940. add.l #44*40,d0
  941. dbf d7,wblit7
  942. movem.w (sp)+,d0-3
  943. rts
  944. bob:
  945. movem.l d0-7/a0-6,-(sp)
  946. wblt9:
  947. btst #14,2(a5)
  948. bne.s wblt9
  949. mulu #40,d1
  950. move.l logoaddr,d2
  951. add.l d1,d2
  952. move.w d0,d3
  953. lsr.w #3,d0
  954. bclr #0,d0
  955. add.w d0,d2
  956. and.w #15,d3
  957. ror.w #4,d3
  958. move.w d3,$42(a5)
  959. or.w #%111111110010,d3
  960. move.w d3,$40(a5)
  961. move.l #$ffff0000,$44(a5)
  962. move.l #logo+16+20,d0
  963. move.l #mask+20,d1
  964. move.w #40-4,$66(a5)
  965. move.w #40-4,$60(a5)
  966. move.w #20,$64(a5)
  967. move.w #20,$62(a5)
  968. moveq #2,d7
  969. nextplane:
  970. btst #14,2(a5)
  971. bne.s nextplane
  972. move.l d0,$50(a5)
  973. move.l d1,$4c(a5)
  974. move.l d2,$54(a5)
  975. move.l d2,$48(a5)
  976. move.w #8*64+2,$58(a5)
  977. add.l #44*40,d2
  978. add.l #44*24,d0
  979. dbf d7,nextplane
  980. movem.l (sp)+,d0-7/a0-6
  981. rts
  982. fades:
  983. tst.w fadeflag
  984. beq.s nomorefades
  985. tst.w slider2
  986. beq.s nomorefades
  987. add.w #1,slider2
  988. move.w slider2,d4
  989. lea logo,a0
  990. lea colours2,a1
  991. moveq #7,d7
  992. loop901:
  993. move.w (a0)+,d0
  994. move.w d0,d1
  995. move.w d0,d2
  996. and.w #$f,d0
  997. and.w #$f0,d1
  998. and.w #$f00,d2
  999. lsr.w #4,d1
  1000. lsr.w #8,d2
  1001. add.w d4,d0
  1002. bge.s norm1
  1003. clr.w d0
  1004. norm1:
  1005. add.w d4,d1
  1006. bge.s norm2
  1007. clr.w d1
  1008. norm2:
  1009. add.w d4,d2
  1010. bge.s norm3
  1011. clr.w d2
  1012. norm3:
  1013. lsl.w #4,d1
  1014. lsl.w #8,d2
  1015. or.w d1,d0
  1016. or.w d2,d0
  1017. move.w d0,2(a1)
  1018. lea 4(a1),a1
  1019. dbf d7,loop901
  1020. nomorefades:
  1021. rts
  1022. readmouse:
  1023. move.w $a(a5),d0
  1024. move.w d0,d1
  1025. and.w #$ff,d0
  1026. lsr.w #8,d1
  1027. move.w oldmousex,d2
  1028. move.w oldmousey,d3
  1029. move.w d0,oldmousex
  1030. move.w d1,oldmousey
  1031. sub.w d2,d0
  1032. sub.w d3,d1
  1033. cmp.w #-127,d0
  1034. bgt.s nounder1
  1035. add.w #255,d0
  1036. nounder1:
  1037. cmp.w #-127,d1
  1038. bgt.s nounder2
  1039. add.w #255,d1
  1040. nounder2:
  1041. cmp.w #127,d0
  1042. blt.s noover1
  1043. sub.w #255,d0
  1044. noover1:
  1045. cmp.w #127,d1
  1046. blt.s noover2
  1047. sub.w #255,d1
  1048. noover2:
  1049. add.w mousex,d0
  1050. bge.s border1
  1051. clr.w d0
  1052. border1:
  1053. add.w mousey,d1
  1054. bge.s border2
  1055. clr.w d1
  1056. border2:
  1057. cmp.w #318,d0
  1058. blt.s border3
  1059. move.w #317,d0
  1060. border3:
  1061. cmp.w #148,d1
  1062. blt.s border4
  1063. move.w #147,d1
  1064. border4:
  1065. move.w d0,mousex
  1066. move.w d1,mousey
  1067. bsr setsprite
  1068. rts
  1069. clipping:
  1070. movem.l d6-7,-(sp)
  1071. move.w d6,d7
  1072. clr.w d5
  1073. cmp.w d1,d3
  1074. blt.s greater
  1075. exg d1,d3
  1076. exg d0,d2
  1077. greater:
  1078. tst.w d1
  1079. blt.s offscreen
  1080. cmp.w #200,d3
  1081. bge.s offscreen
  1082. cmp.w #200,d1
  1083. blt.s notd1down
  1084. bsr clipd1down
  1085. notd1down:
  1086. tst.w d3
  1087. bge.s notd3up
  1088. bsr clipd3up
  1089. notd3up:
  1090. cmp.w d0,d2
  1091. blt.s greater2
  1092. exg d1,d3
  1093. exg d0,d2
  1094. greater2:
  1095. tst.w d0
  1096. blt.s offscreen
  1097. cmp.w #320,d2
  1098. bge.s offscreen
  1099. tst.w d2
  1100. bge.s notd2left
  1101. bsr clipd2left
  1102. notd2left:
  1103. cmp.w #320,d0
  1104. blt.s notd0right
  1105. bsr clipd0right
  1106. notd0right:
  1107. movem.l (sp)+,d6-7
  1108. rts
  1109. offscreen:
  1110. move.w #1,d5
  1111. movem.l (sp)+,d6-7
  1112. rts
  1113. clipd1down:
  1114. move.w d3,d4
  1115. sub.w d1,d3
  1116. beq.s vertical2
  1117. sub.w #200,d1
  1118. move.w d0,d6
  1119. sub.w d2,d6
  1120. muls d1,d6
  1121. divs d3,d6
  1122. add.w d6,d0
  1123. vertical2:
  1124. move.w #199,d1
  1125. move.w d4,d3
  1126. rts
  1127. clipd0right:
  1128. move.w d2,d4
  1129. sub.w d0,d2
  1130. beq.s vertical4
  1131. sub.w #320,d0
  1132. move.w d1,d6
  1133. move.w d1,d7
  1134. sub.w d3,d6
  1135. muls d0,d6
  1136. divs d2,d6
  1137. add.w d6,d1
  1138. vertical4:
  1139. move.w #319,d0
  1140. move.w d4,d2
  1141. rts
  1142. clipd3up:
  1143. move.w d1,d4
  1144. sub.w d3,d1
  1145. beq.s vertical1
  1146. move.w d2,d6
  1147. sub.w d0,d6
  1148. muls d3,d6
  1149. divs d1,d6
  1150. add.w d6,d2
  1151. vertical1:
  1152. clr.w d3
  1153. move.w d4,d1
  1154. rts
  1155. clipd2left:
  1156. move.w d0,d4
  1157. sub.w d2,d0
  1158. beq.s vertical3
  1159. move.w d3,d6
  1160. sub.w d1,d6
  1161. muls d2,d6
  1162. divs d0,d6
  1163. add.w d6,d3
  1164. vertical3:
  1165. clr.w d2
  1166. move.w d4,d0
  1167. rts
  1168. setsprite:
  1169. add.w #$2c+3*16,d1
  1170. add.w #$81,d0
  1171. move.w d1,d3
  1172. clr.w d2
  1173. lsl.w #8,d1
  1174. roxl.b #1,d2
  1175. add.w #19,d3
  1176. lsl.w #8,d3
  1177. roxl.b #1,d2
  1178. lsr.w #1,d0
  1179. roxl.b #1,d2
  1180. or.w d2,d3
  1181. or.w d0,d1
  1182. lea mousepointer,a0
  1183. move.w d3,2(a0)
  1184. move.w d1,(a0)
  1185. rts
  1186. copperlist:
  1187. sprites:
  1188. dc.w spr0ptl,0,spr0pth,0,spr1ptl,0,spr1pth,0,spr2ptl,0,spr2pth,0,spr3ptl,0,spr3pth,0,spr4ptl,0,spr4pth,0,spr5ptl,0,spr5pth,0,spr6ptl,0,spr6pth,0,spr7ptl,0,spr7pth,0
  1189. dc.w ddfstrt,$38,ddfstop,$d0
  1190. dc.w diwstrt,$3081,diwstop,$0ac1
  1191. dc.w bplcon0,$3000,bplcon1,0,bplcon2,0,bpl1mod,0,bpl2mod,0
  1192. planes2:
  1193. dc.w bpl1ptl,0,bpl1pth,0,bpl2ptl,0,bpl2pth,0,bpl3ptl,0,bpl3pth,0
  1194. colours2:
  1195. dc.w col00,0,col01,0,col02,0,col03,0,col04,0,col05,0,col06,0,col07,0
  1196. dc.w $5ad9,$fffe
  1197. dc.w bplcon0,$4000,bplcon1,0,bplcon2,%100100,bpl1mod,0,bpl2mod,0
  1198. planes:
  1199. dc.w bpl1ptl,0,bpl1pth,0,bpl2ptl,0,bpl2pth,0,bpl3ptl,0,bpl3pth,0,bpl4ptl,0,bpl4pth,0
  1200. colours:
  1201. dc.w col00,0,col01,0,col02,0,col03,0,col04,0,col05,0,col06,0,col07,0,col08,0,col09,0,col10,0,col11,0,col12,0,col13,0,col14,0,col15,0
  1202. dc.w col16,0,col17
  1203. pointercol:
  1204. dc.w $fff,col18,0,col19,0
  1205. dc.w $d009,$fffe,$9c,$8010
  1206. dc.w $ffff,$fffe
  1207. blanksprite dc.w 0,0
  1208. mousepointer dc.w 0,0
  1209. dc.w %0000000000000000,%1100000000000000
  1210. dc.w %0100000000000000,%1010000000000000
  1211. dc.w %0110000000000000,%1001000000000000
  1212. dc.w %0111000000000000,%1000100000000000
  1213. dc.w %0111100000000000,%1000010000000000
  1214. dc.w %0111110000000000,%1000001000000000
  1215. dc.w %0111111000000000,%1000000100000000
  1216. dc.w %0111111100000000,%1000000010000000
  1217. dc.w %0111111110000000,%1000000001000000
  1218. dc.w %0111111100000000,%1000000010000000
  1219. dc.w %0111111000000000,%1000000100000000
  1220. dc.w %0111111100000000,%1000000010000000
  1221. dc.w %0111111100000000,%1000000010000000
  1222. dc.w %0111011110000000,%1000100001000000
  1223. dc.w %0110011110000000,%1001100001000000
  1224. dc.w %0100001111000000,%1010010000100000
  1225. dc.w %0000001110000000,%0100010001000000
  1226. dc.w %0000000000000000,%0000001110000000
  1227. dc.w 0,0
  1228. grname dc.b 'graphics.library',0
  1229. even
  1230. planeaddr dc.l 0
  1231. logoaddr dc.l 0
  1232. musicflag dc.w 0
  1233. player dc.w 0
  1234. oldmousex dc.w 0
  1235. slider dc.w 0
  1236. players dc.w 0
  1237. rot dc.w 0
  1238. winner dc.w 0
  1239. distance dc.w 0
  1240. oldmousey dc.w 0
  1241. slider2 dc.w 0
  1242. fadeflag dc.w 0
  1243. mousex dc.w 0
  1244. mousey dc.w 0
  1245. quitflag dc.w 0
  1246. toggler dc.w 0
  1247. buttonflag dc.w 0
  1248. framecount dc.w 0
  1249. xrot dc.w 0
  1250. yrot dc.w 0
  1251. startdata:
  1252. datatable dcb.b 10*6,0
  1253. inusetable dcb.b 10*6,0
  1254. ownertable dcb.b 10*6,0
  1255. morphtable dcb.w 1*10,0
  1256. enddata:
  1257. coords dc.w 17,-500,-300,500,-300,-500,-200,500,-200,-500,-100,500,-100,-500,0,500,0,-500,100,500,100,-500,200,500,200,-500,300,500,300
  1258. dc.w -500,-300,-500,300,-400,-300,-400,300,-300,-300,-300,300,-200,-300,-200,300,-100,-300,-100,300,0,-300,0,300,100,-300,100,300,200,-300,200,300,300,-300,300,300,400,-300,400,300,500,-300,500,300
  1259. blocksequ dc.w 59,58,49,57,48,39,56,47,38,29,55,46,37,28,19,54,45,36,27,18,09,53,44,35,26,17,08
  1260. dc.w 52,43,34,25,16,07,51,42,33,24,15,06,50,41,32,23,14,05,40,31,22,13,04,30,21,12,03
  1261. dc.w 20,11,02,10,01,00
  1262. playersin dc.b 0,0,0,0
  1263. flags dc.b 0,0,0,0
  1264. playerno dc.w 0
  1265. explosion dc.w 0,0,0
  1266. collook dc.w $f00,$0f0,$f80,$00f
  1267. sequences dc.l sequence1,sequence2,sequence3,sequence4
  1268. sequence1 dc.w 0,-1
  1269. sequence2 dc.w 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,-1
  1270. sequence3 dc.w 19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,-1
  1271. sequence4 dc.w 38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,-1
  1272. sequ dc.w 0,0,18,37,56
  1273. text1 dc.b ' how many players',-1
  1274. text2 dc.b 124,0,125,0,126,-1
  1275. text3 dc.b 'well done ',-1
  1276. text4 dc.b 'play again y n',-1
  1277. even
  1278. blocklookup dcb.l 256,0
  1279. tiles incbin "ram:atomtiles.bitmap"
  1280. sinewave incbin "ram:sinewavetable2"
  1281. logo incbin "ram:atomslogo.bitmap"
  1282. mask incbin "ram:atomslogo.mask"
  1283. font incbin "ram:atomfont.bitmap"
  1284. mt_init:lea mt_data,a0
  1285. lea $3b8(a0),a1
  1286. moveq #$7f,d0
  1287. moveq #0,d2
  1288. moveq #0,d1
  1289. mt_lop2:move.b (a1)+,d1
  1290. cmp.b d2,d1
  1291. ble.s mt_lop
  1292. move.l d1,d2
  1293. mt_lop: dbf d0,mt_lop2
  1294. addq.b #1,d2
  1295. asl.l #8,d2
  1296. asl.l #2,d2
  1297. lea 4(a1,d2.l),a2
  1298. lea mt_samplestarts(pc),a1
  1299. add.w #42,a0
  1300. moveq #$1e,d0
  1301. mt_lop3:clr.l (a2)
  1302. move.l a2,(a1)+
  1303. moveq #0,d1
  1304. move.w (a0),d1
  1305. clr.b 2(a0)
  1306. asl.l #1,d1
  1307. add.l d1,a2
  1308. add.l #$1e,a0
  1309. dbf d0,mt_lop3
  1310. or.b #2,$bfe001
  1311. move.b #6,mt_speed
  1312. moveq #0,d0
  1313. lea $dff000,a0
  1314. move.w d0,$a8(a0)
  1315. move.w d0,$b8(a0)
  1316. move.w d0,$c8(a0)
  1317. move.w d0,$d8(a0)
  1318. clr.b mt_songpos
  1319. clr.b mt_counter
  1320. clr.w mt_pattpos
  1321. rts
  1322. mt_end: clr.w $dff0a8
  1323. clr.w $dff0b8
  1324. clr.w $dff0c8
  1325. clr.w $dff0d8
  1326. move.w #$f,$dff096
  1327. rts
  1328. mt_music:
  1329. lea mt_data,a0
  1330. addq.b #1,mt_counter
  1331. move.b mt_counter(pc),d0
  1332. cmp.b mt_speed(pc),d0
  1333. blt mt_nonew
  1334. clr.b mt_counter
  1335. lea mt_data,a0
  1336. lea $c(a0),a3
  1337. lea $3b8(a0),a2
  1338. lea $43c(a0),a0
  1339. moveq #0,d0
  1340. moveq #0,d1
  1341. move.b mt_songpos(pc),d0
  1342. move.b (a2,d0.w),d1
  1343. lsl.w #8,d1
  1344. lsl.w #2,d1
  1345. add.w mt_pattpos(pc),d1
  1346. clr.w mt_dmacon
  1347. lea $dff0a0,a5
  1348. lea mt_voice1(pc),a4
  1349. bsr mt_playvoice
  1350. addq.l #4,d1
  1351. lea $dff0b0,a5
  1352. lea mt_voice2(pc),a4
  1353. bsr mt_playvoice
  1354. addq.l #4,d1
  1355. lea $dff0c0,a5
  1356. lea mt_voice3(pc),a4
  1357. bsr mt_playvoice
  1358. addq.l #4,d1
  1359. lea $dff0d0,a5
  1360. lea mt_voice4(pc),a4
  1361. bsr mt_playvoice
  1362. move.w mt_dmacon(pc),d0
  1363. beq.s mt_nodma
  1364. bsr mt_wait
  1365. or.w #$8000,d0
  1366. move.w d0,$dff096
  1367. bsr mt_wait
  1368. mt_nodma:
  1369. lea mt_voice1(pc),a4
  1370. lea $dff000,a3
  1371. move.l $a(a4),$a0(a3)
  1372. move.w $e(a4),$a4(a3)
  1373. move.l $a+$1c(a4),$b0(a3)
  1374. move.w $e+$1c(a4),$b4(a3)
  1375. move.l $a+$38(a4),$c0(a3)
  1376. move.w $e+$38(a4),$c4(a3)
  1377. move.l $a+$54(a4),$d0(a3)
  1378. move.w $e+$54(a4),$d4(a3)
  1379. add.w #$10,mt_pattpos
  1380. cmp.w #$400,mt_pattpos
  1381. bne.s mt_exit
  1382. mt_next:clr.w mt_pattpos
  1383. clr.b mt_break
  1384. addq.b #1,mt_songpos
  1385. and.b #$7f,mt_songpos
  1386. move.b -2(a2),d0
  1387. cmp.b mt_songpos(pc),d0
  1388. bne.s mt_exit
  1389. move.b -1(a2),mt_songpos
  1390. mt_exit:tst.b mt_break
  1391. bne.s mt_next
  1392. rts
  1393. mt_wait:moveq #3,d3
  1394. mt_wai2:move.b $dff006,d2
  1395. mt_wai3:cmp.b $dff006,d2
  1396. beq.s mt_wai3
  1397. dbf d3,mt_wai2
  1398. moveq #8,d2
  1399. mt_wai4:dbf d2,mt_wai4
  1400. rts
  1401. mt_nonew:
  1402. lea mt_voice1(pc),a4
  1403. lea $dff0a0,a5
  1404. bsr mt_com
  1405. lea mt_voice2(pc),a4
  1406. lea $dff0b0,a5
  1407. bsr mt_com
  1408. lea mt_voice3(pc),a4
  1409. lea $dff0c0,a5
  1410. bsr mt_com
  1411. lea mt_voice4(pc),a4
  1412. lea $dff0d0,a5
  1413. bsr mt_com
  1414. bra.s mt_exit
  1415. mt_mulu:
  1416. dc.w 0,$1e,$3c,$5a,$78,$96,$b4,$d2,$f0,$10e,$12c,$14a
  1417. dc.w $168,$186,$1a4,$1c2,$1e0,$1fe,$21c,$23a,$258,$276
  1418. dc.w $294,$2b2,$2d0,$2ee,$30c,$32a,$348,$366,$384,$3a2
  1419. mt_playvoice:
  1420. move.l (a0,d1.l),(a4)
  1421. moveq #0,d2
  1422. move.b 2(a4),d2
  1423. lsr.b #4,d2
  1424. move.b (a4),d0
  1425. and.b #$f0,d0
  1426. or.b d0,d2
  1427. beq.s mt_oldinstr
  1428. lea mt_samplestarts-4(pc),a1
  1429. asl.w #2,d2
  1430. move.l (a1,d2.l),4(a4)
  1431. lsr.w #1,d2
  1432. move.w mt_mulu(pc,d2.w),d2
  1433. move.w (a3,d2.w),8(a4)
  1434. move.w 2(a3,d2.w),$12(a4)
  1435. moveq #0,d3
  1436. move.w 4(a3,d2.w),d3
  1437. tst.w d3
  1438. beq.s mt_noloop
  1439. move.l 4(a4),d0
  1440. asl.w #1,d3
  1441. add.l d3,d0
  1442. move.l d0,$a(a4)
  1443. move.w 4(a3,d2.w),d0
  1444. add.w 6(a3,d2.w),d0
  1445. move.w d0,8(a4)
  1446. bra.s mt_hejaSverige
  1447. mt_noloop:
  1448. move.l 4(a4),d0
  1449. add.l d3,d0
  1450. move.l d0,$a(a4)
  1451. mt_hejaSverige:
  1452. move.w 6(a3,d2.w),$e(a4)
  1453. moveq #0,d0
  1454. move.b $13(a4),d0
  1455. move.w d0,8(a5)
  1456. mt_oldinstr:
  1457. move.w (a4),d0
  1458. and.w #$fff,d0
  1459. beq mt_com2
  1460. tst.w 8(a4)
  1461. beq.s mt_stopsound
  1462. tst.b $12(a4)
  1463. bne.s mt_stopsound
  1464. move.b 2(a4),d0
  1465. and.b #$f,d0
  1466. cmp.b #5,d0
  1467. beq.s mt_setport
  1468. cmp.b #3,d0
  1469. beq.s mt_setport
  1470. move.w (a4),$10(a4)
  1471. and.w #$fff,$10(a4)
  1472. move.w $1a(a4),$dff096
  1473. clr.b $19(a4)
  1474. move.l 4(a4),(a5)
  1475. move.w 8(a4),4(a5)
  1476. move.w $10(a4),6(a5)
  1477. move.w $1a(a4),d0
  1478. or.w d0,mt_dmacon
  1479. bra mt_com2
  1480. mt_stopsound:
  1481. move.w $1a(a4),$dff096
  1482. bra mt_com2
  1483. mt_setport:
  1484. move.w (a4),d2
  1485. and.w #$fff,d2
  1486. move.w d2,$16(a4)
  1487. move.w $10(a4),d0
  1488. clr.b $14(a4)
  1489. cmp.w d0,d2
  1490. beq.s mt_clrport
  1491. bge mt_com2
  1492. move.b #1,$14(a4)
  1493. bra mt_com2
  1494. mt_clrport:
  1495. clr.w $16(a4)
  1496. rts
  1497. mt_port:move.b 3(a4),d0
  1498. beq.s mt_port2
  1499. move.b d0,$15(a4)
  1500. clr.b 3(a4)
  1501. mt_port2:
  1502. tst.w $16(a4)
  1503. beq.s mt_rts
  1504. moveq #0,d0
  1505. move.b $15(a4),d0
  1506. tst.b $14(a4)
  1507. bne.s mt_sub
  1508. add.w d0,$10(a4)
  1509. move.w $16(a4),d0
  1510. cmp.w $10(a4),d0
  1511. bgt.s mt_portok
  1512. move.w $16(a4),$10(a4)
  1513. clr.w $16(a4)
  1514. mt_portok:
  1515. move.w $10(a4),6(a5)
  1516. mt_rts: rts
  1517. mt_sub: sub.w d0,$10(a4)
  1518. move.w $16(a4),d0
  1519. cmp.w $10(a4),d0
  1520. blt.s mt_portok
  1521. move.w $16(a4),$10(a4)
  1522. clr.w $16(a4)
  1523. move.w $10(a4),6(a5)
  1524. rts
  1525. mt_sin:
  1526. dc.b 0,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4
  1527. dc.b $fa,$fd
  1528. dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61
  1529. dc.b $4a,$31,$18
  1530. mt_vib: move.b $3(a4),d0
  1531. beq.s mt_vib2
  1532. move.b d0,$18(a4)
  1533. mt_vib2:move.b $19(a4),d0
  1534. lsr.w #2,d0
  1535. and.w #$1f,d0
  1536. moveq #0,d2
  1537. move.b mt_sin(pc,d0.w),d2
  1538. move.b $18(a4),d0
  1539. and.w #$f,d0
  1540. mulu d0,d2
  1541. lsr.w #7,d2
  1542. move.w $10(a4),d0
  1543. tst.b $19(a4)
  1544. bmi.s mt_vibsub
  1545. add.w d2,d0
  1546. bra.s mt_vib3
  1547. mt_vibsub:
  1548. sub.w d2,d0
  1549. mt_vib3:move.w d0,6(a5)
  1550. move.b $18(a4),d0
  1551. lsr.w #2,d0
  1552. and.w #$3c,d0
  1553. add.b d0,$19(a4)
  1554. rts
  1555. mt_arplist:
  1556. dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0
  1557. dc.b 1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
  1558. mt_arp: moveq #0,d0
  1559. move.b mt_counter(pc),d0
  1560. move.b mt_arplist(pc,d0.w),d0
  1561. beq.s mt_arp0
  1562. cmp.b #2,d0
  1563. beq.s mt_arp2
  1564. mt_arp1:moveq #0,d0
  1565. move.b 3(a4),d0
  1566. lsr.b #4,d0
  1567. bra.s mt_arpdo
  1568. mt_arp2:moveq #0,d0
  1569. move.b 3(a4),d0
  1570. and.b #$f,d0
  1571. mt_arpdo:
  1572. asl.w #1,d0
  1573. move.w $10(a4),d1
  1574. and.w #$fff,d1
  1575. lea mt_periods(pc),a0
  1576. moveq #$24,d2
  1577. mt_arp3:cmp.w (a0)+,d1
  1578. bge.s mt_arpfound
  1579. dbf d2,mt_arp3
  1580. mt_arp0:move.w $10(a4),6(a5)
  1581. rts
  1582. mt_arpfound:
  1583. move.w -2(a0,d0.w),6(a5)
  1584. rts
  1585. mt_normper:
  1586. move.w $10(a4),6(a5)
  1587. rts
  1588. mt_com: move.w 2(a4),d0
  1589. and.w #$fff,d0
  1590. beq.s mt_normper
  1591. move.b 2(a4),d0
  1592. and.b #$f,d0
  1593. tst.b d0
  1594. beq.s mt_arp
  1595. cmp.b #1,d0
  1596. beq.s mt_portup
  1597. cmp.b #2,d0
  1598. beq.s mt_portdown
  1599. cmp.b #3,d0
  1600. beq mt_port
  1601. cmp.b #4,d0
  1602. beq mt_vib
  1603. cmp.b #5,d0
  1604. beq.s mt_volport
  1605. cmp.b #6,d0
  1606. beq.s mt_volvib
  1607. move.w $10(a4),6(a5)
  1608. cmp.b #$a,d0
  1609. beq.s mt_volslide
  1610. rts
  1611. mt_portup:
  1612. moveq #0,d0
  1613. move.b 3(a4),d0
  1614. sub.w d0,$10(a4)
  1615. move.w $10(a4),d0
  1616. cmp.w #$71,d0
  1617. bpl.s mt_portup2
  1618. move.w #$71,$10(a4)
  1619. mt_portup2:
  1620. move.w $10(a4),6(a5)
  1621. rts
  1622. mt_portdown:
  1623. moveq #0,d0
  1624. move.b 3(a4),d0
  1625. add.w d0,$10(a4)
  1626. move.w $10(a4),d0
  1627. cmp.w #$358,d0
  1628. bmi.s mt_portdown2
  1629. move.w #$358,$10(a4)
  1630. mt_portdown2:
  1631. move.w $10(a4),6(a5)
  1632. rts
  1633. mt_volvib:
  1634. bsr mt_vib2
  1635. bra.s mt_volslide
  1636. mt_volport:
  1637. bsr mt_port2
  1638. mt_volslide:
  1639. moveq #0,d0
  1640. move.b 3(a4),d0
  1641. lsr.b #4,d0
  1642. beq.s mt_vol3
  1643. add.b d0,$13(a4)
  1644. cmp.b #$40,$13(a4)
  1645. bmi.s mt_vol2
  1646. move.b #$40,$13(a4)
  1647. mt_vol2:moveq #0,d0
  1648. move.b $13(a4),d0
  1649. move.w d0,8(a5)
  1650. rts
  1651. mt_vol3:move.b 3(a4),d0
  1652. and.b #$f,d0
  1653. sub.b d0,$13(a4)
  1654. bpl.s mt_vol4
  1655. clr.b $13(a4)
  1656. mt_vol4:moveq #0,d0
  1657. move.b $13(a4),d0
  1658. move.w d0,8(a5)
  1659. rts
  1660. mt_com2:move.b $2(a4),d0
  1661. and.b #$f,d0
  1662. cmp.b #$e,d0
  1663. beq.s mt_filter
  1664. cmp.b #$d,d0
  1665. beq.s mt_pattbreak
  1666. cmp.b #$b,d0
  1667. beq.s mt_songjmp
  1668. cmp.b #$c,d0
  1669. beq.s mt_setvol
  1670. cmp.b #$f,d0
  1671. beq.s mt_setspeed
  1672. rts
  1673. mt_filter:
  1674. move.b 3(a4),d0
  1675. and.b #1,d0
  1676. asl.b #1,d0
  1677. and.b #$fd,$bfe001
  1678. or.b d0,$bfe001
  1679. rts
  1680. mt_pattbreak:
  1681. move.b #1,mt_break
  1682. rts
  1683. mt_songjmp:
  1684. move.b #1,mt_break
  1685. move.b 3(a4),d0
  1686. subq.b #1,d0
  1687. move.b d0,mt_songpos
  1688. rts
  1689. mt_setvol:
  1690. cmp.b #$40,3(a4)
  1691. bls.s mt_sv2
  1692. move.b #$40,3(a4)
  1693. mt_sv2: moveq #0,d0
  1694. move.b 3(a4),d0
  1695. move.b d0,$13(a4)
  1696. move.w d0,8(a5)
  1697. rts
  1698. mt_setspeed:
  1699. moveq #0,d0
  1700. move.b 3(a4),d0
  1701. cmp.b #$1f,d0
  1702. bls.s mt_sp2
  1703. moveq #$1f,d0
  1704. mt_sp2: tst.w d0
  1705. bne.s mt_sp3
  1706. moveq #1,d0
  1707. mt_sp3: move.b d0,mt_speed
  1708. rts
  1709. mt_periods:
  1710. dc.w $358,$328,$2fa,$2d0,$2a6,$280,$25c,$23a,$21a,$1fc,$1e0
  1711. dc.w $1c5,$1ac,$194,$17d,$168,$153,$140,$12e,$11d,$10d,$fe
  1712. dc.w $f0,$e2,$d6,$ca,$be,$b4,$aa,$a0,$97,$8f,$87
  1713. dc.w $7f,$78,$71,0
  1714. mt_speed: dc.b 6
  1715. mt_counter: dc.b 0
  1716. mt_pattpos: dc.w 0
  1717. mt_songpos: dc.b 0
  1718. mt_break: dc.b 0
  1719. mt_dmacon: dc.w 0
  1720. mt_samplestarts:dcb.l $1f,0
  1721. mt_voice1: dcb.w 13,0
  1722. dc.w 1
  1723. mt_voice2: dcb.w 13,0
  1724. dc.w 2
  1725. mt_voice3: dcb.w 13,0
  1726. dc.w 4
  1727. mt_voice4: dcb.w 13,0
  1728. dc.w 8
  1729. mt_data incbin "df0:mod.mainmod"
  1730. end: