SNILE.S 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492
  1. * NILE FLYER - ALIAS SPHINX - SENEMIES
  2. * MAY 8 VERSION. PROGRAMMING NEW FLEAS.
  3. * NO NEED FOR SHADOWS TO HAVE X,Y AND Z
  4. org $F000
  5. NFLS EQU 8 ; POSSIBLE NUMBER OF FLEAS
  6. NFL2 EQU $0F ; TWICE NUMBER OF FLEAS
  7. SCRWID EQU 160 ; HPOS SCREEN WIDTH
  8. FLEXPL EQU 8 ; START OF NON EXPLODING FLEAS
  9. *** FOR FLEA MOVEMENT ***
  10. FLYHI EQU $2E
  11. FLYLO EQU $06
  12. FLXHI EQU $78
  13. FLXLO EQU $38
  14. * POSITION INITIALIZATIONS *
  15. XSTARTS: .dc.b $39,$3D,$41,$47,$4D,$50,$54,$57
  16. .dc.b $5D,$60,$65,$69,$6B,$6E,$72,$76
  17. YSTARTS: .dc.b $07,$09,$0B,$0F,$12,$14,$16,$19
  18. .dc.b $1B,$1D,$20,$23,$26,$28,$2A,$2D
  19. ZSTART EQU 210
  20. ************************************************************
  21. * ENEMY INITIALIZER
  22. * THIS ROUTINE INITIALIZES X,Y,Z,SM,SH,SL AND PW FOR THE GLIDERS AND THE
  23. * SHADOWS. THE DRIVER ACTUALLY INSERTS THE OBJECT WHEN IT IS TIME.
  24. FLEAINIT: ;CLASS IS ALREADY LOADED
  25. JSR RANDOM
  26. AND #$0F ;RANDOM # <= 15
  27. TAX
  28. LDA XSTARTS,X ;GET RANDOM XSTART POSITION
  29. STA SPNX ;PUSH X COORD
  30. JSR RANDOM ;37
  31. AND #$0F ;<=15
  32. TAX
  33. LDA YSTARTS,X ;GET RANDOM Y POSTION
  34. STA SPNY ;PUSH Y COORD
  35. LDA #ZSTART
  36. STA SPNZ ;PUSH Z COORD
  37. JSR SPAWN
  38. RTS
  39. ** SPAWN A NEW FLYING ENEMY (FLEA) **
  40. ZSHADPW EQU $3D ;PW FOR SHADOWS
  41. SPAWN:
  42. STY TEMP0 ;SAVE X,Y REGISTERS
  43. STX TEMP1
  44. jmp .enter
  45. LDX #UWEDEX+2 ;LOOK FOR AVAILABLE UWE
  46. .LOP1: LDA UWESTATE-UWEDEX,X
  47. BNE ERROR1 ;CAN'T HAVE UWE AND FLEA AT SAME TIME.
  48. DEX
  49. CPX #UWEDEX ;ANY MORE UWES TO CHECK?
  50. BCS .LOP1
  51. .enter:
  52. ** RETURN IN Y THE INDEX OF AN AVAIL FLEA **
  53. LDY #NFLS-1
  54. FLOOP: LDA FLEASTAT,Y ;CHECK FOR AVAIL FLEA
  55. ORA FLEASTAT+NFLS,Y
  56. BEQ HAVEY
  57. DEY
  58. BPL FLOOP
  59. ERROR1: LDY TEMP0 ; THIS WAS A TRAP ;NO AVAILABLE FLEAS
  60. RTS
  61. HAVEY:
  62. * PLAY A TUNE *
  63. LDA #SPTUNE
  64. JSR TUNIN
  65. * Y NOW CONTAINS NEW FLEA INDEX (0-7) *
  66. LDA #3 ;INITIALLY MAKE IT OFF SCREEN
  67. STA FLEASTAT,Y
  68. STA FLEASTAT+NFLS,Y
  69. LDA #FLEACOL
  70. STA COLSTAT+FLEADEX,Y
  71. DEC NUMFLEAS ;DEC NUM OF AVAIL FLYING ENEMIES
  72. * INITIALIZE FLEA TARGET *
  73. LDX SPNCLASS ;X = CLASS
  74. LDA TARLOAD,X
  75. STA FLEACNT,Y ;INIT MT PROG COUNTER
  76. LDA #0
  77. STA FXRUN,Y ;INIT X VELOCITY
  78. LDA #0
  79. STA FYRUN,Y ;INIT Y VELOCITY
  80. JSR RANDOM
  81. ORA #$FE
  82. STA FZRUN,Y ;INIT Z VELOCITY
  83. LDA TARPW,X ;LOAD PALETTE WIDTH BYTE
  84. STA PWTBL+FLEADEX,Y
  85. LDA #ZSHADPW ;LOAD SHADOW PALETTE WIDTH
  86. STA PWTBL+FLSHDEX,Y
  87. LDA TARTYPE,X ;LOAD FLEA TYPE (0 GL, 1 SC, ETC)
  88. STA FLEATYPE,Y
  89. TAX ;X = TYPE OF FLEA
  90. ** X NOW CONTAINS TYPE OF FLEA **
  91. ** SET POSITION OF FLEA **
  92. * ZCOORD *
  93. LDA SPNZ
  94. STA ZTBL+FLEADEX,Y ;Z STORED
  95. STA ZTBL+FLSHDEX,Y ;Z STORED FOR SHADOW
  96. SEC
  97. SBC FCOLDZ1,X
  98. STA COLZ1+FLEADEX,Y ;STUFF COLZ1
  99. CLC
  100. ADC FCOLDZ2,X
  101. STA COLZ2+FLEADEX,Y ;STUFF COLZ2
  102. * Y COORD *
  103. LDA #0
  104. STA YTBL+FLSHDEX,Y ;Y STORED FOR SHADOW
  105. LDA SPNY
  106. STA YTBL+FLEADEX,Y ;Y STORED
  107. SEC
  108. SBC FCOLDY1,X
  109. STA COLY1+FLEADEX,Y ;STUFF COLY1
  110. CLC
  111. ADC FCOLDY2,X
  112. STA COLY2+FLEADEX,Y ;STUFF COLY2
  113. * XCOORD *
  114. LDA SPNX
  115. STA XTBL+FLEADEX,Y ;X STORED
  116. STA XTBL+FLSHDEX,Y ;X STORED FOR SHADOW
  117. SEC
  118. SBC FCOLDX1,X
  119. STA COLX1+FLEADEX,Y ;STUFF COLX1
  120. CLC
  121. ADC FCOLDX2,X
  122. STA COLX2+FLEADEX,Y ;STUFF COLX2
  123. * X CONTAINS TYPE (0-3) *
  124. * Y CONTAINS FLEA INDEX (0-7) *
  125. * INITIALIZE FLEA ANIMATION *
  126. LDA FLIFTBL,X ;LOAD INITIAL FRAME FOR THIS TYPE
  127. STA FLEANIM,Y
  128. TAX
  129. LDA FLSHAPES,X ;LOAD IN ANIMATION NUMBER OF FRAME
  130. TAX
  131. LDA FLSHPTBL-1,X ;LOAD IN SHAPE
  132. STA SLTBL+FLEADEX,Y
  133. LDA FLSHDTBL-1,X ;LOAD IN SHADOW
  134. STA SLTBL+FLSHDEX,Y
  135. LDA #UNFOLD0/256 ;LOAD HI BYTE OF INIT SHAPE
  136. STA SHTBL+FLEADEX,Y
  137. STA SHTBL+FLSHDEX,Y
  138. LDA #(UNFOLD0-$1600+$1700)/256 ;LOAD 16 TALL
  139. ;SM:=SH-#ZNUMLINS+17 OBJ IS NOW 16 TALL
  140. STA SMTBL+FLEADEX,Y
  141. STA SMTBL+FLSHDEX,Y
  142. LDY TEMP0
  143. LDX TEMP1
  144. RTS
  145. * ENEMY DRIVER
  146. *CHECKS SCREEN BOUNDS, INSERTS, DELETES AND
  147. * MOVES OBJECTS ON SCREEN
  148. FLITBL: .dc.b FLEADEX,FLEADEX+1,FLEADEX+2,FLEADEX+3
  149. .dc.b FLEADEX+4,FLEADEX+5,FLEADEX+6,FLEADEX+7
  150. .dc.b FLSHDEX,FLSHDEX+1,FLSHDEX+2,FLSHDEX+3
  151. .dc.b FLSHDEX+4,FLSHDEX+5,FLSHDEX+6,FLSHDEX+7
  152. ANIMFLEA:
  153. JSR ADVFRMS ;ADVANCE THE FRAMES
  154. JSR MOVEFLEA
  155. * CHECK FOR COLLISIONS *
  156. LDY #NFLS-1
  157. MVDETCOL:
  158. LDA FLEASTAT,Y
  159. CMP #1 ;SHOULD FIX STUCK FLEA
  160. BEQ MVDETC1
  161. BNE MVEND
  162. MVDETC1: LDA COLSTAT+FLEADEX,Y
  163. BEQ MVEND ;ALREADY EXPLODING
  164. JSR FLEADET ;CHECK FOR COLLISION
  165. MVEND: DEY
  166. BPL MVDETCOL
  167. *** MOVE ONTO, AROUND OR OFF OF SCREEN ***
  168. LDY #NFL2 ;SIXTEEN OBJECTS TOTAL
  169. FSCRLOOP:
  170. LDA FLEASTAT,Y ;INSPECT FLAG
  171. BEQ NEXTONE ;IF ZERO TRY NEXT FLEA/SHADOW
  172. LDA FLITBL,Y
  173. TAX ;PUT REAL INDEX IN X
  174. LDA FLEASTAT,Y ;LOAD SCREEN STATE OF FLEA
  175. CMP #1
  176. BEQ ONSCREEN
  177. CMP #3 ;<> 3 ==> ON SCREEN
  178. TRAP: BNE TRAP
  179. ** PRESCREEN DRIVER **
  180. JSR HPDO ;HORIZ POSITION
  181. CMP #SCRWID+8 ;IF HP>172 THEN PUNT
  182. BCS NEXTONE
  183. STA HPTBL,X ;OK TO STORE TO HPTBL
  184. JSR VPDO ;VERTICAL POSITION
  185. CMP #$F4 ;EMPIRICALLY DETERMINED. BOO HOO
  186. BCS BRINGON ;IF BETWEEN -12 AND SCREEN BOTTOM
  187. CMP #SCRENBOT ;THEN BRING FLEA ON SCREEN
  188. BCS NEXTONE
  189. BRINGON: STA VPTBL,X ;ELSE STORE VP AND BRING ON
  190. ** INSERT OBJECT WITH A CERTAIN PRIORITY **
  191. CPY #NFLS
  192. STY TEMPY
  193. BCC NOTSHAD ;HANDLE SHADOWS DIFFERENTLY
  194. LDA #$FE ;SHADOW GETS PRIORITY OF $FE
  195. STA TEMP6
  196. STA TEMP10
  197. BCS ISHAD
  198. NOTSHAD: JSR DXDO ;CALCULATE DX OF OBJECT TO BE INSERTED
  199. ISHAD: JSR OBJINS
  200. LDY TEMPY
  201. LDA #1 ;SET FLAG TO 1 TO SIGNAL ONSCREEN
  202. STA FLEASTAT,Y
  203. ** GO FOR THE NEXT FLEA **
  204. NEXTONE: DEY ;NEXT ENEMY AND/OR SHADOW
  205. BPL FSCRLOOP
  206. ; JSR LISTEST ;MARK THOSE ELEMENTS
  207. ; LDX #NFL2
  208. ; STATLIST LDY FLITBL,X
  209. ; LDA TESTLIST,Y
  210. ; BNE INLIST
  211. ; LDA FLEASTAT,X
  212. ; CMP #1
  213. ; BEQ ATWAP
  214. ; INLIST DEX
  215. ; BPL STATLIST
  216. RTS
  217. ; ATWAP BEQ ATWAP
  218. ** ONSCREEN DRIVER **
  219. ONSCREEN:
  220. JSR HPDO ;CALCULATE HP
  221. STA HPTBL,X
  222. CMP #$F4
  223. BCS KEEPGOIN
  224. CMP #SCRWID+12 ;WHEN HPOS+12 = 0 THEN DELETE
  225. BCS GETRID
  226. KEEPGOIN:
  227. JSR VPDO ;CALCULATE VP
  228. STA VPTBL,X
  229. CMP #$D8 ;IF BETWEEN -40 AND SCREEN BOTTOM
  230. BCS FLOBJMV ;THEN MOVE OBJECT
  231. CMP #SCRENBOT
  232. BCC FLOBJMV
  233. ** REMOVE A FLEA OR SHADOW FROM THE SCREEN **
  234. GETRID: ;ELSE PUNT OBJECT
  235. JSR OBJDEL
  236. ;RECALL FLEA/SHAD INDEX
  237. LDA #0
  238. STA FLEASTAT,Y ;CLEAR SCREEN STATUS
  239. CPY #NFLS ;IF SHADOW
  240. BCS CHCH ;GO CHECK FLEA
  241. STA COLSTAT+FLEADEX,Y ;DELETE FLEA FROM COLLISON TABLES
  242. LDA FLEASTAT+NFLS,Y ;CHECK SHADOW
  243. BNE NEXTONE ;STAT IF ALSO ZERO THEN DEC NUMSCABS
  244. INCNUM: INC NUMFLEAS
  245. BPL NEXTONE ;JMP
  246. CHCH: LDA FLEASTAT-NFLS,Y ;LOAD STATUS OF FLEA
  247. BEQ INCNUM ;IF ALSO ZERO THEN INC NUMFLEAS
  248. BNE NEXTONE ;ELSE NEXT MOVE
  249. ** DO AN OBJECT MOVE ON A FLEA **
  250. FLOBJMV: CPY #NFLS
  251. BCS NEXTONE ;IF SHADOW NO NEED TO DO AN OBJECT MOVE
  252. STY TEMPY
  253. JSR DXDO ;UPDATE DX
  254. JSR OBJMOV ;MOVE IN LINKED LIST
  255. LDY TEMPY
  256. JMP NEXTONE
  257. ** HPDO: HP CALCULATE ROUTINE **
  258. HPDO: LDA XTBL,X
  259. CLC
  260. ADC ZTBL,X
  261. SBC #NUMBER ;SUBTRACT THE MAGIC NUMBER
  262. ; ADC HPDOTBL,Y
  263. RTS
  264. ;HPDOTBL .dc.b 0-NUMBER,-1-NUMBER ;GLID,SCAB HP CONSTANTS
  265. ** VPD0 VP CALCULATE ROUTINE **
  266. VPDO: LDA XTBL,X
  267. SEC
  268. SBC YTBL,X
  269. SBC ZTBL,X
  270. CLC
  271. ADC #NUMBER-13
  272. ; ADC VPDOTBL,Y
  273. RTS
  274. ;VPDOTBL .dc.b -14+NUMBER,-13+NUMBER ;GLID,SCAB VP CONSTANTS
  275. ** DXDO: DX CALCULATE ROUTINE **
  276. DXDO: LDA ZTBL,X
  277. SEC
  278. SBC XTBL,X
  279. CLC
  280. ADC #NUMBER+13+DXADJ
  281. ; ADC DXDFTBL,Y ; THIS IS DF
  282. STA TEMP10
  283. SEC
  284. SBC #18
  285. ; SBC DXDCTBL,Y ; THIS IS DC
  286. STA TEMP6
  287. RTS
  288. ;DXDFTBL .dc.b NUMBER+13+DXADJ ;GLIDER DISP FAR CONST
  289. ; .dc.b NUMBER+10+DXADJ ;SCARAB FAR CONST
  290. ;DXDCTBL .dc.b 18,12 ;DISPLAY CLOSE CONST
  291. ** ANIMATE THE ENEMIES - ADVANCE FRAMES **
  292. ADVFRMS:
  293. LDY #NFLS-1 ;EIGHT ENEMIES
  294. ANIMLOOP: LDA FLEASTAT,Y
  295. BEQ NEXTAN ;OFF SCREEN ALREADY SO PUNT
  296. CMP #3
  297. BEQ NEXTAN ;NOT ON SCREEN YET SO PUNT
  298. LDX FLEANIM,Y
  299. LDA FLSHAPES,X
  300. BEQ KLFLEA
  301. BPL ADV1
  302. AND #$7F
  303. TAX
  304. LDA FLSHAPES,X
  305. ADV1:
  306. INX
  307. STX FLEANIM,Y
  308. TAX
  309. LDA FLSHPTBL-1,X
  310. STA SLTBL+FLEADEX,Y
  311. LDA FLSHDTBL-1,X
  312. STA SLTBL+FLSHDEX,Y
  313. LDA FLEANIM,Y
  314. JMP NEXTAN
  315. KLFLEA:
  316. LDX FLITBL,Y ;LOAD REAL INDEX
  317. JSR OBJDEL ;AND DELETE FLEA
  318. LDA #0 ;ZERO OUT FLEASTAT
  319. STA FLEASTAT,Y
  320. LDX FLITBL+NFLS,Y ;AND ITS SHADOW
  321. LDA FLEASTAT+NFLS,Y
  322. BEQ KLFLEA1
  323. JSR OBJDEL
  324. LDA #0
  325. STA FLEASTAT+NFLS,Y
  326. KLFLEA1: INC NUMFLEAS ;ONE LESS FLEA
  327. NEXTAN: DEY
  328. BPL ANIMLOOP
  329. RTS
  330. * FLEA EXPLOSION TUNES *
  331. FLTUNE:
  332. .dc.b GLDEXPL
  333. .dc.b SCBEXPL
  334. .dc.b GLDEXPL
  335. .dc.b SCBEXPL
  336. * INITIAL FRAME INDEX *
  337. FLIFTBL:
  338. .dc.b $00 ;GLIDER
  339. .dc.b $0C ;SCARAB
  340. .dc.b $18 ;PING
  341. .dc.b $22 ;NEUFY
  342. * COLDATA - COLX1,X2,COLY1,Y2,COLZ1,Z2 BY TYPE *
  343. FCOLDX1: .dc.b 5,4,3,5
  344. FCOLDX2: .dc.b 10,8,6,10
  345. FCOLDY1: .dc.b 2,3,3,3
  346. FCOLDY2: .dc.b 5,7,6,7
  347. FCOLDZ1: .dc.b 2,2,2,2
  348. FCOLDZ2: .dc.b 8,8,8,10
  349. * EXPLOSION FRAME INDEX *
  350. FXITBL:
  351. .dc.b $0F ;GLIDER
  352. .dc.b $12 ;SCARAB
  353. .dc.b $1D ;PING
  354. .dc.b $25 ;NEUFY
  355. * POINT VALUE OF FLEAS *
  356. FLSCORE:
  357. .dc.b $1 ;GLIDER
  358. .dc.b $3 ;SCARAB
  359. .dc.b $2 ;PING
  360. .dc.b $5 ;NEUFY
  361. * ANIMATION SEQUENCES *
  362. FLSHAPES:
  363. .dc.b $0B ;0 FOLDED GLIDER
  364. .dc.b $80 ;GOTO 0
  365. .dc.b $0A,$0A,$0A,$0A
  366. .dc.b $09,$09,$09,$09
  367. .dc.b $08 ;A GLIDER
  368. .dc.b $8A ;GOTO A
  369. .dc.b $0C ;C BUZZING SCARAB
  370. .dc.b $0D
  371. .dc.b $8C ;GOTO C
  372. .dc.b $07 ;F EXPLODING GLIDER
  373. .dc.b $06
  374. .dc.b $94 ;GOTO 14
  375. .dc.b $05 ;EXPLODING SCARAB
  376. .dc.b $04
  377. .dc.b $03 ;14
  378. .dc.b $02 ;GENERIC EXPLOSIONS
  379. .dc.b $01
  380. .dc.b $00 ;DEATH
  381. .dc.b $0E,$0E,$0F,$0F,$98 ;18 PING
  382. .dc.b $10,$10,$10,$10 ;1D PING EXPL
  383. .dc.b $94 ;GOTO 14
  384. .dc.b $11,$12 ;22 DRAGFLY
  385. .dc.b $A2 ;GOTO 22
  386. .dc.b $13,$13,$13,$13 ;25 DRAGFLY EXPL
  387. .dc.b $94
  388. * SHAPES *
  389. FLSHPTBL:
  390. .dc.b GENERXP2&$FF ;1 NEXT TO DEATH
  391. .dc.b GENERXP1&$FF ;2
  392. .dc.b GENERXP0&$FF ;3
  393. .dc.b SCRBEXP2&$FF ;4
  394. .dc.b SCRBEXP1&$FF ;5
  395. .dc.b GLIDEXP1&$FF ;6
  396. .dc.b GLIDEXP0&$FF ;7
  397. .dc.b GLIDER&$FF ;8
  398. .dc.b UNFOLD2&$FF ;9
  399. .dc.b UNFOLD1&$FF ;A
  400. .dc.b UNFOLD0&$FF ;B
  401. .dc.b SCARAB5&$FF ;C
  402. .dc.b SCARAB4&$FF ;D
  403. .dc.b PING1&$FF ;E
  404. .dc.b PING2&$FF ;F
  405. .dc.b PINGEXPL&$FF ;10
  406. .dc.b NEUFY1&$FF ;11
  407. .dc.b NEUFY2&$FF ;12
  408. .dc.b NEUFYXPL&$FF ;13
  409. * SHADOWS *
  410. FLSHDTBL:
  411. .dc.b GENERXP2&$FF ;1 DEATH
  412. .dc.b GENERXP1&$FF ;2
  413. .dc.b GENERXP0&$FF ;3
  414. .dc.b SCRBEXP2&$FF ;4
  415. .dc.b SCRBEXP1&$FF ;5
  416. .dc.b GLIDEXP1&$FF ;6
  417. .dc.b GLIDEXP0&$FF ;7
  418. .dc.b GLSHAD&$FF ;8
  419. .dc.b UNFOLD2&$FF ;9
  420. .dc.b UNFOLD1&$FF ;A
  421. .dc.b UNFOLD0&$FF ;B
  422. .dc.b SCARAB5&$FF ;C
  423. .dc.b SCARAB4&$FF ;D
  424. .dc.b PING1&$FF ;E
  425. .dc.b PING2&$FF ;F
  426. .dc.b PINGEXPL&$FF ;10
  427. .dc.b NEUFY1&$FF ;11
  428. .dc.b NEUFY2&$FF ;12
  429. .dc.b NEUFYXPL&$FF ;13
  430. ** COLLISION DETECTION **
  431. FLEADET: LDA XTBL+FLEADEX,Y ;X
  432. STA COLPX
  433. LDA COLY1+FLEADEX,Y ;Y - DELTA
  434. STA COLPY
  435. LDA ZTBL+FLEADEX,Y ;Z
  436. STA COLPZ
  437. LDX FLITBL,Y ;LOAD IN REAL INDEX
  438. JSR COLDET
  439. BNE AXPLO ;EXPLOSION IF NOT ZERO
  440. ;
  441. LDA COLX1+FLEADEX,Y ;X-DELTA
  442. STA COLPX
  443. LDA COLY2+FLEADEX,Y ;Y+DELTA
  444. STA COLPY
  445. LDA COLZ2+FLEADEX,Y ;Z+DELTA
  446. STA COLPZ
  447. LDX FLITBL,Y ;LOAD REAL INDEX
  448. JSR COLDET
  449. BNE AXPLO ;NON-ZERO MEANS COLLISION
  450. ;
  451. LDA COLX1+FLEADEX,Y ;X+DELTA
  452. STA COLPX
  453. LDX FLITBL,Y
  454. JSR COLDET
  455. BEQ ENDFLDET ;NON-ZERO MEANS COLLISION
  456. AXPLO:
  457. LDX FLEATYPE,Y
  458. LDA FXITBL,X ;LOOK UP EXPLOSION SEQUENCE START
  459. STA FLEANIM,Y
  460. LDA #0
  461. STA FLEACNT,Y ;FREEZE MOVEMENT
  462. STA COLSTAT+FLEADEX,Y
  463. LDA FLTUNE,X ;JUST FOR JOHN, HONEST.
  464. JSR TUNIN
  465. ENDFLDET: RTS
  466. KILLFLEA: ;CALL WITH FLEA INDEX IN A
  467. STX TEMP2
  468. LDA FLEATYPE-FLEADEX,X
  469. TAX
  470. LDA FLTUNE,X
  471. JSR TUNIN ;PLAY FLEA DEATH TUNE
  472. LDA FLSCORE,X ;DO SOME SCORING
  473. STA HUNDS
  474. JSR ADDSCORE
  475. JSR ADDTRVAL ;DO TREASURE VALUE UPDATE AS WELL
  476. LDA FXITBL,X ;LOOK UP EXPLOSION SEQ START
  477. LDX TEMP2
  478. STA FLEANIM-FLEADEX,X
  479. LDA #0
  480. STA FLEACNT-FLEADEX,X ;FREEZE MOVEMENT
  481. STA COLSTAT,X
  482. RTS
  483. ** FLEA MOVEMENT ROUTINE **
  484. MOVEFLEA:
  485. LDX #NFLS-1
  486. MVFLOOP:
  487. LDA FLEASTAT,X
  488. BEQ FMNEXT
  489. * Z COORDINATES *
  490. LDA FZRUN,X
  491. SEC
  492. SBC SCROLLS
  493. TAY
  494. CLC
  495. ADC ZTBL+FLEADEX,X
  496. STA ZTBL+FLEADEX,X
  497. CLC
  498. TYA
  499. ADC ZTBL+FLSHDEX,X
  500. STA ZTBL+FLSHDEX,X
  501. CLC
  502. TYA
  503. ADC COLZ1+FLEADEX,X
  504. STA COLZ1+FLEADEX,X
  505. CLC
  506. TYA
  507. ADC COLZ2+FLEADEX,X
  508. STA COLZ2+FLEADEX,X
  509. * Y COORDINATES *
  510. LDY FYRUN,X
  511. CLC
  512. TYA
  513. ADC YTBL+FLEADEX,X
  514. CMP #FLYLO ;BOUNDS CHECKS
  515. BCC FMXCOORD
  516. CMP #FLYHI
  517. BCS FMXCOORD
  518. STA YTBL+FLEADEX,X
  519. CLC
  520. TYA
  521. ADC COLY1+FLEADEX,X
  522. STA COLY1+FLEADEX,X
  523. CLC
  524. TYA
  525. ADC COLY2+FLEADEX,X
  526. STA COLY2+FLEADEX,X
  527. * X COORDINATES *
  528. FMXCOORD: LDY FXRUN,X
  529. CLC
  530. TYA
  531. ADC XTBL+FLEADEX,X
  532. CMP #FLXLO ;BOUNDS CHECKS
  533. BCC FMNEXT
  534. CMP #FLXHI
  535. BCS FMNEXT
  536. STA XTBL+FLEADEX,X
  537. CLC
  538. TYA
  539. ADC XTBL+FLSHDEX,X
  540. STA XTBL+FLSHDEX,X
  541. CLC
  542. TYA
  543. ADC COLX1+FLEADEX,X
  544. STA COLX1+FLEADEX,X
  545. CLC
  546. TYA
  547. ADC COLX2+FLEADEX,X
  548. STA COLX2+FLEADEX,X
  549. FMNEXT: DEX
  550. BPL MVFLOOP
  551. ** INTELLIGENTLY MOVE ONE OF THE FLEAS **
  552. LDA MAINCNT
  553. AND #$03 ;INDEX OF FLEA
  554. TAX
  555. LDA FLEASTAT,X
  556. BEQ FMVCPL
  557. JSR FDSPATCH
  558. FMVCPL: TXA
  559. ORA #4
  560. TAX
  561. LDA FLEASTAT,X
  562. BNE FDSPATCH
  563. FMRTS: RTS
  564. ** ATTACK INTERPRETER **
  565. FDSPATCH:
  566. LDY FLEACNT,X
  567. LDA MT,Y
  568. INC FLEACNT,X
  569. STA TEMP0
  570. LSR
  571. LSR
  572. LSR
  573. LSR
  574. TAY
  575. LDA TEMP0
  576. AND #$F
  577. STA TEMP0
  578. LDA FJMPLO,Y
  579. STA PTR0
  580. LDA FJMPHI,Y
  581. STA PTR0+1
  582. JMP (PTR0)
  583. *** INSTRUCTION SET FOR FLEA MOVEMENT INTERPRETER ***
  584. ** STX SET X TO BE THE LOW NIBBLE **
  585. FSTX:
  586. LDA TEMP0
  587. CMP #8
  588. BCC FSTX1
  589. ORA #$F0
  590. FSTX1: STA FXRUN,X
  591. JMP FDSPATCH
  592. ** STY SET Y TO BE THE LOW NIBBLE **
  593. FSTY:
  594. LDA TEMP0
  595. CMP #8
  596. BCC FSTY1
  597. ORA #$F0
  598. FSTY1: STA FYRUN,X
  599. JMP FDSPATCH
  600. ** STZ SET Z TO BE THE LOW NIBBLE **
  601. FSTZ:
  602. LDA TEMP0
  603. CMP #8
  604. BCC FSTZ1
  605. ORA #$F0
  606. FSTZ1: STA FZRUN,X
  607. JMP FDSPATCH
  608. ** HBX HOME TOWARDS BIRD IN X DIRECTION **
  609. FHBX:
  610. LDA NOHOMING
  611. BNE FHBX0
  612. LDA XTBL+ZBIRD
  613. FHBX0: SEC ;CALC COORD DIFFERENCE
  614. SBC XTBL+FLEADEX,X
  615. ADC #5
  616. BMI FHBXDEC ;FL>BD, DEC FLEA
  617. CMP #10
  618. BCC FHBXNIL
  619. LDA TEMP0
  620. BNE FHBX1
  621. FHBXDEC: SEC
  622. LDA #0
  623. SBC TEMP0
  624. BNE FHBX1
  625. FHBXNIL: LDA #0
  626. FHBX1: STA FXRUN,X
  627. JMP FDSPATCH
  628. ** HBY HOME TOWARDS BIRD IN Y DIRECTION **
  629. FHBY:
  630. LDA NOHOMING
  631. LSR
  632. BNE FHBY0
  633. LDA YTBL+ZBIRD
  634. FHBY0: SEC
  635. SBC YTBL+FLEADEX,X
  636. ADC #5
  637. BMI FHBYDEC ;FL>BD, DEC FLEA
  638. CMP #10
  639. BCC FHBYNIL
  640. LDA TEMP0
  641. BNE FHBY1
  642. FHBYDEC: SEC
  643. LDA #0
  644. SBC TEMP0
  645. BNE FHBY1
  646. FHBYNIL: LDA #0
  647. FHBY1: STA FYRUN,X
  648. JMP FDSPATCH
  649. ** RTS RETURN FROM INTERPRETER **
  650. FRTS:
  651. RTS
  652. ** CYC CYCLE BACK N STEPS **
  653. FCYC: LDA FLEACNT,X
  654. CLC ;SUBT ONE MORE
  655. SBC TEMP0
  656. STA FLEACNT,X
  657. JMP FDSPATCH
  658. ** LAN LOAD ANIMATION INDEX WITH X **
  659. FLAN:
  660. LDA TEMP0
  661. STA FLEANIM,X
  662. JMP FDSPATCH
  663. ** DIS IF Z WITHIN A CERTAIN DISTANCE, JUMP **
  664. FDIS: LDY TEMP0
  665. LDA FDISTBL,Y
  666. CMP ZTBL+FLEADEX,X
  667. BCC FDIS1
  668. LDY FLEACNT,X
  669. LDA MT,Y
  670. STA FLEACNT,X
  671. JMP FDSPATCH
  672. FDIS1: INC FLEACNT,X
  673. JMP FDSPATCH
  674. ** RND JUMP WITH PROBABILITY 1/ARG **
  675. FRND: JSR RANDOM
  676. AND TEMP0
  677. BEQ FJMP
  678. INC FLEACNT,X
  679. JMP FDSPATCH
  680. ** JMP UNCONDITIONAL JUMP **
  681. FJMP:
  682. LDY FLEACNT,X
  683. LDA MT,Y
  684. STA FLEACNT,X
  685. JMP FDSPATCH
  686. ** SPN SPAWN A NEW FLEA **
  687. FSPN:
  688. LDA TEMP0 ;X = CLASS OF SPAWNED FLEA
  689. STA SPNCLASS
  690. LDA NUMFLEAS
  691. BEQ FSPNEND ;ARE THERE ANY AVAIL FLEAS?
  692. * FIX POSITION *
  693. LDA XTBL+FLEADEX,X
  694. STA SPNX
  695. LDA YTBL+FLEADEX,X
  696. STA SPNY
  697. LDA ZTBL+FLEADEX,X
  698. ADC #12
  699. STA SPNZ
  700. JSR SPAWN
  701. FSPNEND:
  702. JMP FDSPATCH
  703. FJMPLO: .dc.b FSTX&$FF,FSTY&$FF,FSTZ&$FF,FRTS&$FF
  704. .dc.b FHBX&$FF,FHBY&$FF,FCYC&$FF,FDIS&$FF
  705. .dc.b FSPN&$FF,FLAN&$FF,FJMP&$FF,FRND&$FF
  706. FJMPHI: .dc.b FSTX/256,FSTY/256,FSTZ/256,FRTS/256
  707. .dc.b FHBX/256,FHBY/256,FCYC/256,FDIS/256
  708. .dc.b FSPN/256,FLAN/256,FJMP/256,FRND/256
  709. MSTX EQU 0
  710. MSTY EQU $10
  711. MSTZ EQU $20
  712. MRTS EQU $30
  713. MHBX EQU $40
  714. MHBY EQU $50
  715. MCYC EQU $60
  716. MDIS EQU $70
  717. MSPN EQU $80
  718. MLAN EQU $90
  719. MJMP EQU $A0
  720. MRND EQU $B0
  721. TARLOAD:
  722. .dc.b MGLID1-MT,MGLID2-MT,MGLID3-MT,MGLID4-MT
  723. .dc.b MSCAB1-MT,MSCAB2-MT,MSCAB3-MT,MSCAB4-MT
  724. .dc.b MPING1-MT,MPING2-MT,MPING3-MT,MPING4-MT
  725. .dc.b MDRAG1-MT,MDRAG2-MT,MDRAG3-MT,MDRAG4-MT
  726. TARPW:
  727. .dc.b $9D,$BD,$DD,$1D,$9D,$BD,$DD,$1D
  728. .dc.b $9D,$BD,$DD,$1D,$9D,$BD,$DD,$1D ;PALWIDTH FOR FLEAS
  729. TARTYPE:
  730. .dc.b $00,$00,$00,$00,$01,$01,$01,$01
  731. .dc.b $02,$02,$02,$02,$03,$03,$03,$03
  732. * DISTANCE TABLE *
  733. FDISTBL: .dc.b $B0,$A0,$90,$80
  734. MIGLID1 EQU 0
  735. MISCAB1 EQU 4
  736. MIPING1 EQU 8
  737. MIDRAG3 EQU $E
  738. *** MOVEMENT TABLE ***
  739. MT:
  740. MEXPL: .dc.b (MSTZ+$0)&$FF,(MSTY+$0)&$FF,(MSTX+$0)&$FF
  741. .dc.b (MRTS)&$FF,(MCYC+$1)&$FF
  742. MGLID1P: .dc.b (MLAN+$2)&$FF,(MSTZ+$F)&$FF,(MRTS)&$FF,(MCYC+$1)&$FF
  743. MGLID1: .dc.b (MSTZ+$E)&$FF,(MDIS+1)&$FF,(MGLID1P-MT)&$FF
  744. .dc.b (MRTS)&$FF,(MCYC+$3)&$FF
  745. MGLID2P: .dc.b (MLAN+$2)&$FF,(MSTZ+$F)&$FF
  746. .dc.b (MSTY+$1)&$FF,(MRTS)&$FF,(MRTS)&$FF,(MSTY+$F)&$FF
  747. .dc.b (MRTS)&$FF,(MRTS)&$FF,(MCYC+$6)&$FF
  748. MGLID2: .dc.b (MSTZ+$E)&$FF,(MDIS+3)&$FF,(MGLID2P-MT)&$FF
  749. .dc.b (MHBY+$1)&$FF,(MRTS)&$FF,(MCYC+$4)&$FF
  750. MGLID3P: .dc.b (MLAN+$2)&$FF,(MSTZ+$D)&$FF,(MRTS)&$FF,(MSTZ+$E)&$FF
  751. .dc.b (MHBY+$1)&$FF,(MRTS)&$FF,(MCYC+$2)&$FF
  752. MGLID3: .dc.b (MSTZ+$D)&$FF,(MDIS+2)&$FF,(MGLID3P-MT)&$FF
  753. .dc.b (MHBY+$2)&$FF,(MRTS)&$FF,(MCYC+$4)&$FF
  754. MGLID4P: .dc.b (MLAN+$2)&$FF,(MSTZ+$D)&$FF,(MRTS)&$FF,(MSTZ+$E)&$FF
  755. .dc.b (MSTY+$1)&$FF,(MRTS)&$FF,(MHBY+$1)&$FF,(MRTS)&$FF
  756. .dc.b (MSTY+$F)&$FF,(MRTS)&$FF,(MHBY+$1)&$FF,(MRTS)&$FF
  757. .dc.b (MCYC+$8)&$FF
  758. MGLID4: .dc.b (MSTZ+$D)&$FF,(MDIS+0)&$FF,(MGLID4P-MT)&$FF
  759. .dc.b (MHBY+$1)&$FF,(MRTS)&$FF,(MCYC+$4)&$FF
  760. MPING1: .dc.b (MSTZ+$F)&$FF,(MHBX+$1)&$FF,(MHBY+$1)&$FF
  761. .dc.b (MRTS)&$FF,(MCYC+$3)&$FF
  762. MPING2: .dc.b (MHBY+$1)&$FF,(MSTX+$2)&$FF,(MRTS)&$FF,(MRTS)&$FF
  763. .dc.b (MHBY+$1)&$FF,(MSTX+$E)&$FF,(MRTS)&$FF,(MRTS)&$FF
  764. .dc.b (MCYC+$8)&$FF
  765. MPING3: .dc.b (MDIS+$2)&$FF,(MPING1-MT)&$FF,(MRTS)&$FF,(MCYC+$3)&$FF
  766. MPING4: .dc.b (MSTZ+$E)&$FF,(MHBY+$1)&$FF,(MHBX+$2)&$FF,(MRTS)&$FF
  767. .dc.b (MHBY+$2)&$FF,(MSTX+$1)&$FF,(MRTS)&$FF
  768. .dc.b (MHBY+$2)&$FF,(MSTX+$F)&$FF,(MRTS)&$FF
  769. .dc.b (MHBY+$2)&$FF,(MRTS)&$FF,(MCYC+$B)&$FF
  770. MSCAB1A: .dc.b (MSTZ+$0)&$FF,(MSTY+$0)&$FF,(MSTX+$0)&$FF,MRTS&$FF
  771. .dc.b MRTS&$FF,MRTS&$FF,MRTS&$FF,MJMP&$FF,(MPING1-MT)&$FF
  772. MSCAB1: .dc.b (MSTZ+$F)&$FF,(MDIS+1)&$FF,(MSCAB1A-MT)&$FF
  773. .dc.b MRTS&$FF,(MCYC+$3)&$FF
  774. MSCAB2A: .dc.b (MSTZ+$0)&$FF,(MSTY+$0)&$FF,(MSTX+$0)&$FF,MRTS&$FF
  775. .dc.b MRTS&$FF,MRTS&$FF,MJMP&$FF,(MPING4-MT)&$FF
  776. MSCAB2: .dc.b (MSTZ+$F)&$FF,(MDIS+2)&$FF,(MSCAB2A-MT)&$FF
  777. .dc.b (MHBX+$1)&$FF,MRTS&$FF,(MCYC+$4)&$FF
  778. MSCAB3A: .dc.b (MSTZ+$0)&$FF,(MSTX+$0)&$FF
  779. .dc.b (MHBY+$2)&$FF,MRTS&$FF,(MSTY+$E)&$FF,MRTS&$FF
  780. .dc.b (MSTZ+$E)&$FF,(MHBX+$2)&$FF,(MHBY+$1)&$FF
  781. .dc.b (MRTS)&$FF,(MCYC+$3)&$FF
  782. MSCAB3: .dc.b (MDIS+$1)&$FF,(MSCAB3A-MT)&$FF,(MSTX+$1)&$FF
  783. .dc.b (MRTS)&$FF,(MSTX+$F)&$FF,(MRTS)&$FF,(MCYC+$6)&$FF
  784. MSCAB4A: .dc.b (MSTZ+$0)&$FF,(MSTY+$1)&$FF,(MSTX+$1)&$FF,MRTS&$FF
  785. .dc.b (MSTY+$F)&$FF,MRTS&$FF,(MSTX+$F)&$FF,MRTS&$FF
  786. .dc.b (MSTY+$0)&$FF
  787. .dc.b MRTS&$FF,(MSTX+$0)&$FF
  788. .dc.b MRTS&$FF,(MSTZ+$D)&$FF,(MHBY+$4)&$FF,(MHBX+$4)&$FF
  789. .dc.b MRTS&$FF
  790. .dc.b (MHBY+$2)&$FF,(MHBX+$2)&$FF,MRTS&$FF,(MCYC+$3)&$FF
  791. MSCAB4: .dc.b (MSTZ+$F)&$FF,(MDIS+1)&$FF,(MSCAB4A-MT)&$FF
  792. .dc.b MRTS&$FF,(MCYC+$3)&$FF
  793. MDRAG1A: .dc.b (MSTZ+$0)&$FF,(MSTY+$0)&$FF,(MSTX+$0)&$FF,MRTS&$FF
  794. .dc.b MRTS&$FF,(MSPN+MISCAB1)&$FF
  795. .dc.b (MSTZ+$E)&$FF,MJMP&$FF,(MPING2-MT)&$FF
  796. MDRAG1: .dc.b (MSTZ+$F)&$FF,(MDIS+0)&$FF,(MDRAG1A-MT)&$FF
  797. .dc.b MRTS&$FF,(MCYC+$3)&$FF
  798. MDRAG2A: .dc.b (MSTZ+$0)&$FF,(MSTX+$0)&$FF,MRTS&$FF
  799. ; .dc.b (MSTY+$F)&$FF,MRTS&$FF,(MSTY+$1)&$FF,MRTS&$FF
  800. .dc.b (MSTY+$F)&$FF,MRTS&$FF,(MSTY+$1)&$FF,MRTS&$FF
  801. .dc.b (MSPN+MIGLID1)&$FF
  802. MDRAG2: .dc.b (MSTZ+$E)&$FF,(MSTX+$2)&$FF,MRTS&$FF,MRTS&$FF
  803. .dc.b (MSTX+$E)&$FF,MRTS&$FF,MRTS&$FF
  804. .dc.b (MRND+$1)&$FF,(MDRAG2A-MT)&$FF,(MCYC+$8)&$FF
  805. MDRAG3A: .dc.b (MSTZ+$0)&$FF,(MSTY+$0)&$FF,(MSTX+$0)&$FF,MRTS&$FF
  806. .dc.b MRTS&$FF,MRTS&$FF,MRTS&$FF
  807. .dc.b (MSPN+MIDRAG3)&$FF,MJMP&$FF,(MPING4-MT)&$FF
  808. MDRAG3: .dc.b (MSTZ+$F)&$FF,(MDIS+1)&$FF,(MDRAG3A-MT)&$FF
  809. .dc.b MRTS&$FF,(MCYC+$3)&$FF
  810. MDRAG4A: .dc.b (MSPN+MIPING1)&$FF,MRTS&$FF
  811. MDRAG4: .dc.b (MSTZ+$D)&$FF,(MRND+$1)&$FF,(MDRAG4A-MT)&$FF
  812. .dc.b MRTS&$FF,(MCYC+$3)&$FF
  813. *******************************************
  814. ** UWE ENEMY DRIVER **
  815. *******************************************
  816. UWEOFFH EQU 2
  817. UWEOFFV EQU -13
  818. NOUWE EQU 0 ;NO UWE AT ALL
  819. WCTRLFL EQU TEMP8
  820. ** INITIALIZE A UWE **
  821. DOUWE:
  822. jmp .enter
  823. LDY #NFLS-1 ;CAN'T BE ANY FLEAS FOR NEW UWE.
  824. .LOP1: LDA FLEASTAT,Y ;CHECK FOR AVAIL FLEA
  825. ORA FLEASTAT+NFLS,Y
  826. BNE .EXIT1 ;EXIT IF FLEA FOUND.
  827. DEY
  828. BPL .LOP1
  829. .enter:
  830. LDX #UWEDEX+2 ;LOOK FOR AVAILABLE UWE
  831. .LOP2: LDA UWESTATE-UWEDEX,X ;THIS USED TO LOOK FOR VPTBL = TO
  832. BEQ THISISX ;SCREENBOT+1. NOW LOOKS FOR ZERO
  833. DEX ;UWESTATE
  834. CPX #UWEDEX ;WE CAN PROBABLY PUNT THIS SCREENBOT+1
  835. BCS .LOP2 ;SHIT AT THIS POINT
  836. ;
  837. .EXIT1: LDA #$00 ;TELLS JOHN NOT TO DO UWES
  838. STA UWEOK
  839. RTS
  840. THISISX:
  841. TXA ;IS THIS LAST UWE
  842. CMP #UWEDEX
  843. BNE TISX
  844. LDA #$00
  845. STA UWEOK
  846. * INITIALIZE COORDS *
  847. TISX: JSR RANDOM ;RANDOM X FOR UWE
  848. AND #$3F
  849. ADC #58
  850. STA XTBL,X
  851. LDA #5 ;AND 5 Y
  852. STA YTBL,X
  853. JSR RANDOM ;AND SOME RANDOM DISTANCE IN FRONT
  854. AND #$1F
  855. ADC ZTBL+ZBIRD
  856. ADC #50
  857. STA ZTBL,X
  858. LDA #200 ;HP SHOULD BE OFF SCREEN
  859. STA HPTBL,X
  860. JSR UWEVP ;DO THE VP
  861. STA VPTBL,X
  862. * INITIALIZE COLLISION DATA *
  863. LDA XTBL,X ;THESE COLLISION PARAMETERS ARE
  864. SEC ;GUESSES
  865. SBC #4
  866. STA COLX1,X
  867. CLC
  868. ADC #8
  869. STA COLX2,X
  870. LDA #1
  871. STA COLY1,X
  872. LDA #17
  873. STA COLY2,X
  874. LDA ZTBL,X
  875. STA COLZ1,X
  876. CLC
  877. ADC #10
  878. STA COLZ2,X
  879. * INITIAL STATE *
  880. JSR RANDOM
  881. AND #1
  882. STA UWETYPE-UWEDEX,X
  883. LDA #$DC ;PAL AND WIDTH
  884. STA PWTBL,X
  885. LDA #1 ;START UNDERGROUND
  886. JSR WSTINIT
  887. JSR UWEDX
  888. JSR OBJINS
  889. RTS
  890. ;
  891. ; IN: A = 1 to start uwe underground.
  892. ; = 7 to blow-up uwe up.
  893. ; X = index to uwe.
  894. ;
  895. WSTINIT:
  896. STA UWESTATE-UWEDEX,X
  897. TAY
  898. LDA WCOLST-1,Y
  899. STA COLSTAT,X
  900. ;
  901. LDA WSTST-1,Y
  902. STA WANIMCNT-UWEDEX,X
  903. TAY
  904. LDA UWESH,Y
  905. ORA #$80
  906. STA SHTBL,X
  907. LDA UWESL,Y
  908. STA SLTBL,X
  909. RTS
  910. ;
  911. ;
  912. ;=====================================
  913. ; UWE ANIMATION ROUTINE.
  914. ;=====================================
  915. ;
  916. UWEANIM:
  917. LDX #UWEDEX+2
  918. .loop: LDA UWESTATE-UWEDEX,X
  919. beq .next ;Is there a Uwe to handle?
  920. jsr .handleUwe
  921. .next: dex
  922. cpx #UWEDEX
  923. bcs .loop
  924. rts
  925. ;
  926. ;
  927. ; = = = = = = = = = = = = = = = =
  928. ; Uwe handler routine.
  929. ; = = = = = = = = = = = = = = = =
  930. ;
  931. ; IN: x = uwe's index.
  932. ;
  933. .handleUwe:
  934. JSR UWEMOVE ;MOVE UWES
  935. JSR UWECOLD ;DO COLLISION DETECTION
  936. ;
  937. ;
  938. ; --- UWE ANIMATION ---------------------------------------
  939. ;
  940. LDA #0 ;Clear control flag.
  941. STA WCTRLFL
  942. ;
  943. LDA MAINCNT ;Frame counter.
  944. AND #$03 ;Time to change state?
  945. BNE .projection
  946. ;
  947. ;
  948. ; --- Map Uwe's state to graphic image --------------------
  949. ;
  950. LDY WANIMCNT-UWEDEX,X ;Get the animation count.
  951. LDA ZTBL,X
  952. CMP #30 ;Off bottom of screen?
  953. bcs .ok
  954. .toKill:
  955. jmp .removeUwe
  956. .ok:
  957. LDA UWESH,Y ;LOAD HIGH BYTE OF STAMP
  958. BEQ .toKill ;Time to remove the desd Uwe?
  959. BMI .skip2
  960. ;
  961. ORA #$80 ;END OF SEQUENCE FLAG
  962. STA WCTRLFL ;CONTROL SHOULD CHANGE ANIMCNT
  963. ;
  964. .skip2: STA SHTBL,X
  965. LDA UWESL,Y
  966. STA SLTBL,X
  967. INC WANIMCNT-UWEDEX,X ;UPDATE ANIMCNT
  968. ;
  969. ;
  970. ; --- Compute Uwe's projection ----------------------
  971. ;
  972. .projection:
  973. JSR UWEHP
  974. STA HPTBL,X
  975. ;
  976. JSR UWEVP
  977. STA VPTBL,X
  978. ;
  979. JSR UWEDX
  980. ;
  981. JSR OBJMOV ;MOVE HIM IN LINKED LIST
  982. ;
  983. LDA UWESTATE-UWEDEX,X
  984. CMP #7
  985. BEQ .exit
  986. ;
  987. ;
  988. ; --- GROUND TYPE CHECK --------------------
  989. ;
  990. LDY UWESTATE-UWEDEX,X
  991. LDA WCGTBL,Y ;FIND OUT WHAT TO CHECK
  992. BEQ .control
  993. ;
  994. LDA #0
  995. JSR GRNDTYPE
  996. CMP #78 ;EMPIRICALLY DETERMINED
  997. BCS .water
  998. LDA WGTRANS,Y ;GROUND TYPE TRANSITION
  999. BNE .storeState
  1000. BEQ .control
  1001. ;
  1002. .water: LDA WWTRANS,Y ;WATER TYPE TRANSITION
  1003. BNE .storeState
  1004. ;
  1005. ;
  1006. ; --- UWE CONTROL ----------------------------------------
  1007. ;
  1008. .control:
  1009. LDA WCTRLFL
  1010. BEQ .exit
  1011. ;
  1012. LDA #UWERUN
  1013. JSR SCRAPONE
  1014. ;
  1015. LDA UWESTATE-UWEDEX,X
  1016. SEC
  1017. SBC #1 ;TAKE OUT NULL
  1018. ASL
  1019. ASL
  1020. STA TEMP9
  1021. ;
  1022. ;
  1023. ; --- CALCULATE CHANGE INDEX (0-3) -----------------------
  1024. ;
  1025. LDY UWETYPE-UWEDEX,X
  1026. LDA WHOMEP,Y
  1027. BEQ .random
  1028. ;
  1029. LDA NOHOMING
  1030. BNE .ok1
  1031. LDA XTBL+ZBIRD
  1032. .ok1: SEC
  1033. SBC XTBL,X
  1034. ADC #8
  1035. BMI .right ;BIRD IS ON UWE'S RIGHT
  1036. ;
  1037. CMP #16
  1038. BCC .one
  1039. ;
  1040. LDA #3
  1041. BNE .ok2
  1042. ;
  1043. .right: LDA #2
  1044. BNE .ok2
  1045. ;
  1046. .one: LDA #1
  1047. BNE .ok2
  1048. ;
  1049. .random:
  1050. JSR RANDOM ;PICK RND OF FOUR POSSIBLE STATES
  1051. AND #3
  1052. .ok2: ORA TEMP9
  1053. TAY
  1054. LDA WNEWST,Y
  1055. .storeState:
  1056. STA UWESTATE-UWEDEX,X ;NEW STATE ESTABLISHED
  1057. TAY
  1058. LDA WCOLST-1,Y
  1059. STA COLSTAT,X
  1060. LDA WSTST-1,Y
  1061. STA WANIMCNT-UWEDEX,X ;NEW ANIMATION ESTABLISHED
  1062. ;
  1063. .exit: rts
  1064. ;
  1065. ;
  1066. ;=========================================
  1067. ; DELETE UWE AND CLEAR STATE.
  1068. ;=========================================
  1069. ;
  1070. ; IN: x = uwe index.
  1071. ;
  1072. .removeUwe:
  1073. ;KLUWE:
  1074. JSR OBJDEL ;Remove uwe's object.
  1075. LDA #$80
  1076. STA UWEOK
  1077. ;
  1078. LDA #0 ;Mark uwe as gone.
  1079. STA UWESTATE-UWEDEX,X
  1080. ;
  1081. LDA #SCRENBOT+1
  1082. STA VPTBL,X
  1083. ;
  1084. LDA #UWERUN ;Something about tunes.
  1085. JSR SCRAPONE
  1086. rts
  1087. ;
  1088. ;
  1089. * TRANSITIONS - NEW STATES *
  1090. WCGTBL: ;'CHECK GROUND?' TABLE
  1091. .dc.b 0,1,1,1,1,0,0 ;UWESTATES 0-6 1=YES 0=NO
  1092. WGTRANS: ;GROUND TYPE TRANSITIONS
  1093. .dc.b 0,6,0,0,0,0,0 ;UNDERGROUND TO RISING
  1094. WWTRANS: ;WATER TYPE TRANSITIONS
  1095. .dc.b 0,0,5,5,5,0,0 ;RUNNING TO DIVING
  1096. WNEWST: ;0 1 2 3 CONTROL
  1097. .dc.b 1,1,1,1 ;UNDER
  1098. .dc.b 2,2,3,4 ;! RUN
  1099. .dc.b 3,2,3,4 ;/ RUN
  1100. .dc.b 4,2,3,4 ;\ RUN
  1101. .dc.b 1,1,1,1 ;BURY
  1102. .dc.b 2,2,2,2 ;RISE
  1103. * MOVEMENTS *
  1104. WZMOV: .dc.b 0,$FF,$FE,$FF,$FF,0,0,0
  1105. WXMOV: .dc.b 0,0,0,$FF,1,0,0,0
  1106. WLIMCTRL: .dc.b 0,1,2,2,2,5,6,7
  1107. WHOMEP: .dc.b 0,1 ;TYPE TO WHETHER IT HOMES
  1108. * COLSTATS *
  1109. WCOLST: .dc.b 0,UWECOL,UWECOL,UWECOL,UWECOL,UWECOL,UWECOL
  1110. * STATE STARTS *
  1111. WSTST: .dc.b 19 ;UNDERGROUND
  1112. .dc.b 0 ;STRAIGHT
  1113. .dc.b 2 ;RIGHT
  1114. .dc.b 4 ;LEFT
  1115. .dc.b 6 ;BURY
  1116. .dc.b 9 ;RISE
  1117. .dc.b 13 ;EXPLODE
  1118. UWESL: .dc.b EWERUN1&$FF,EWERUN2&$FF ;STRAIGHT 0
  1119. .dc.b EWERITE1&$FF,EWERITE2&$FF ;RIGHT 2
  1120. .dc.b EWELEFT1&$FF,EWELEFT2&$FF ;LEFT 4
  1121. .dc.b EWEDIG3&$FF,EWEDIG2&$FF,EWEDIG1&$FF ;BURY 6
  1122. .dc.b EWEDIG1&$FF,EWEDIG2&$FF,EWEDIG3&$FF ;RISE 9
  1123. .dc.b EWEJUMP&$FF
  1124. .dc.b UWEEXPL1&$FF,UWEEXPL2&$FF ;EXPLODE 13
  1125. .dc.b GENERXP0&$FF,GENERXP1&$FF,GENERXP2&$FF,0
  1126. .dc.b UWEBLANK&$FF
  1127. * HIGH BYTE TABLE DOUBLES AS CONTROL *
  1128. UWESH: .dc.b EWERUN1/256,$40
  1129. .dc.b EWERITE1/256,$40
  1130. .dc.b EWELEFT1/256,$40
  1131. .dc.b EWEDIG3/256,EWEDIG2/256,$40
  1132. .dc.b EWEDIG1/256,EWEDIG2/256,EWEDIG3/256
  1133. .dc.b $40
  1134. .dc.b UWEEXPL1/256,UWEEXPL2/256
  1135. .dc.b GENERXP0/256,GENERXP1/256,GENERXP2/256,0
  1136. .dc.b $40
  1137. * HPDO: HP CALCULATE ROUTINE
  1138. ;THE CONSTANTS IN THIS ROUTINE ARE RUMORED TO BE CLOSE
  1139. UWEHP: LDA XTBL,X
  1140. SEC
  1141. SBC #126-UWEOFFH
  1142. CLC
  1143. ADC ZTBL,X
  1144. RTS
  1145. * VPDO: VP CALCULATE ROUTINE
  1146. UWEVP: LDA XTBL,X
  1147. SEC
  1148. SBC ZTBL,X
  1149. CLC
  1150. ADC #126+UWEOFFV
  1151. SEC
  1152. SBC YTBL,X
  1153. RTS
  1154. * DXDO: DX CALCULATE ROUTINE
  1155. UWEDX: LDA ZTBL,X
  1156. SEC
  1157. SBC XTBL,X
  1158. CLC
  1159. ADC #NUMBER+10+DXADJ ; THIS IS DF
  1160. STA TEMP10
  1161. SEC
  1162. SBC #12 ; THIS IS DC
  1163. STA TEMP6
  1164. RTS
  1165. KILLUWE:
  1166. STX TEMP9
  1167. LDA #1 ;SCORE SOME MEGA POINTS
  1168. STA HUNDS
  1169. LDA #$50
  1170. STA TENS
  1171. JSR ADDSCORE
  1172. JMP WSTEXPL2
  1173. ** UWE MOVEMENT **
  1174. UWEMOVE:
  1175. LDY UWESTATE-UWEDEX,X
  1176. LDA WZMOV,Y
  1177. SEC
  1178. SBC SCROLLS
  1179. STA TEMP9
  1180. BEQ WXMOVEM
  1181. LDA #UWERUN
  1182. CMP TUNNUM
  1183. BEQ .ok1
  1184. CMP TUNNUM+1
  1185. BEQ .ok1
  1186. JSR TUNIN
  1187. .ok1:
  1188. LDA TEMP9
  1189. TAY
  1190. CLC
  1191. ADC ZTBL,X
  1192. STA ZTBL,X
  1193. TYA
  1194. CLC
  1195. ADC COLZ1,X
  1196. STA COLZ1,X
  1197. TYA
  1198. CLC
  1199. ADC COLZ2,X
  1200. STA COLZ2,X
  1201. WXMOVEM: LDY UWESTATE-UWEDEX,X
  1202. LDA WXMOV,Y
  1203. BEQ WMOVEND
  1204. BMI WXDEC
  1205. WXINC:
  1206. LDA XTBL,X
  1207. CMP #FLXHI
  1208. BCS WSTRAIT
  1209. WXINC1: INC XTBL,X
  1210. INC COLX1,X
  1211. INC COLX2,X
  1212. JMP WMOVEND
  1213. WXDEC:
  1214. LDA XTBL,X
  1215. CMP #FLXLO
  1216. BCC WSTRAIT
  1217. WXDEC1: DEC XTBL,X
  1218. DEC COLX1,X
  1219. DEC COLX2,X
  1220. JMP WMOVEND
  1221. WSTRAIT: LDA WLIMCTRL-1,Y
  1222. JSR WSTINIT
  1223. WMOVEND:
  1224. RTS
  1225. ** COLLISION DETECTION WITH OBJECTS OTHER THAN SHOTS AND BIRD ***
  1226. UWECOLD:
  1227. LDA UWESTATE-UWEDEX,X
  1228. CMP #7
  1229. BEQ WNOCOL1
  1230. STX TEMP9
  1231. LDA ZTBL,X
  1232. CLC
  1233. ADC #2
  1234. STA COLPZ
  1235. LDA #5
  1236. STA COLPY
  1237. LDA XTBL,X
  1238. CLC
  1239. ADC #4
  1240. STA COLPX
  1241. JSR COLDET
  1242. ; jmp WSTEXPL2 ;!!!!!!!Always blowup uwes!!!!DEBUG!!
  1243. BNE WSTEXPL2
  1244. LDX TEMP9
  1245. WNOCOL0:
  1246. LDA XTBL,X
  1247. SEC
  1248. SBC #4
  1249. STA COLPX
  1250. JSR COLDET
  1251. BNE WSTEXPL2
  1252. LDX TEMP9
  1253. WNOCOL1:
  1254. RTS
  1255. WSTEXPL2:
  1256. LDX TEMP9
  1257. ;
  1258. LDA #7 ;Start uwe explosion.
  1259. JSR WSTINIT ;!!!!!!!!!
  1260. ;
  1261. LDA #UWEEXP
  1262. JSR TUNIN
  1263. ;
  1264. LDX TEMP9
  1265. RTS
  1266. ;
  1267. ;
  1268. ** REMOVE ALL ON SCREEN ENEMIES AFTER BIRD DEATH **
  1269. CLEAN:
  1270. LDY #FLEADEX+15
  1271. FLEADELP: LDA FLEASTAT-FLEADEX,Y
  1272. CMP #1
  1273. BNE NEXTXOX ;IF FLEA NOT ON SCREEN, NEXT FLEA
  1274. LDA FLITBL-FLEADEX,Y
  1275. TAX
  1276. JSR OBJDEL
  1277. NEXTXOX: LDA #0
  1278. STA FLEASTAT-FLEADEX,Y
  1279. DEY
  1280. CPY #FLEADEX
  1281. BCS FLEADELP
  1282. LDA #0
  1283. STA NOHOMING
  1284. LDA #8
  1285. STA NUMFLEAS
  1286. * CLEAN OUT UWES *
  1287. LDX #UWEDEX+2
  1288. UWEDELP: LDA UWESTATE-UWEDEX,X
  1289. BEQ NEXTOXO
  1290. JSR OBJDEL
  1291. NEXTOXO:
  1292. LDA #0
  1293. STA UWESTATE-UWEDEX,X
  1294. LDA #SCRENBOT+1
  1295. STA VPTBL,X
  1296. DEX
  1297. CPX #UWEDEX
  1298. BCS UWEDELP
  1299. LDA #$80
  1300. STA UWEOK
  1301. RTS
  1302. ** KILL ALL FLEAS - ALIAS SMART BOMB **
  1303. KAFLEAS:
  1304. LDX #FLEADEX+NFLS-1
  1305. FLPOW: ;KILL EACH FLEA
  1306. LDA FLEASTAT-FLEADEX,X
  1307. BEQ FLPOWNXT
  1308. JSR KILLFLEA
  1309. FLPOWNXT: DEX
  1310. CPX #FLEADEX
  1311. BCS FLPOW
  1312. RTS
  1313. ** KILL ALL UWES **
  1314. KAUWES:
  1315. LDX #UWEDEX+2
  1316. UWPOW: ;KILL EACH UWE
  1317. LDA UWESTATE-UWEDEX,X
  1318. BEQ UWPOWNXT
  1319. JSR KILLUWE
  1320. UWPOWNXT: DEX
  1321. CPX #UWEDEX
  1322. BCS UWPOW
  1323. RTS
  1324. *** FREEZE FLEAS ***
  1325. FRFLEAS:
  1326. LDX #NFLS-1
  1327. FLFRZ: ;FREEZE EACH FLEA
  1328. LDA #MEXPL-MT
  1329. STA FLEACNT,X
  1330. FLFRZNXT: DEX
  1331. BPL FLFRZ
  1332. RTS
  1333. ; END