SGNDOBJ.S 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. ******* SGNDOBJ.S THE AMAZING SPHINX
  2. * THIS FILE CONTAINS THE CODE THAT ANIMATES AND CONTROLS THE BIG SPHINX, THE
  3. * MINI SPHINXES, AND THE FIRE POTS.
  4. org $B000
  5. MINIINIT: LDY #MININUMB-1 ; CALLED WITH SLOT NUMBER IN X
  6. MINILP: LDA MINITBL,Y
  7. BMI MINIFND
  8. DEY
  9. BPL MINILP
  10. RTS ; IGNORE IF NO SLOT AVAILABLE
  11. MINIFND: TXA ; X IS THE LOADER TABLE SLOT NUMBER
  12. STA MINITBL,Y
  13. LDA #0 ; ALIVE STATE
  14. STA XTBL,X ; THIS IS WHERE MINISTATE IS KEPT NOW
  15. RTS
  16. KAMINIS: LDY #MININUMB-1 ; KILL ALL MINIS
  17. KAMINILP: LDX MINITBL,Y
  18. BMI KNMINI ; THIS ONES DEAD
  19. JSR MINIKILL
  20. KNMINI: DEY
  21. BPL KAMINILP
  22. RTS
  23. MINIKILL: LDA XTBL,X
  24. BNE MINIDEAD ; MINI IS ALREADY DYING OR DEAD
  25. LDA #1
  26. STA XTBL,X ; SET MINI STATE TO START EXPLOSION
  27. LDA #MINIBM ;THE BIG BANG
  28. JSR TUNIN
  29. LDA #$10
  30. STA HUNDS
  31. JSR ADDSCORE
  32. MINIDEAD: RTS
  33. ; ANIMATE MINI SPHINX EXPLOSION IF NECESSARY - CONTROLLED BY MINISTAT
  34. ;
  35. ; 0 ; STILL ALIVE
  36. ; 1 ; START EXPLOSION
  37. MXREM EQU 2 ; REMOVE OVERLAY
  38. MXREP EQU 4 ; REPLACE OVERLAY
  39. MXLOW EQU 15 ; LOWER OVERLAY AND REMOVE HEAD
  40. MXDONE EQU 21 ; EXPLOSION IS OVER
  41. ; XTBL IS USED TO STORE THE MINI STATE SO THAT IT CAN EASILY BE SET TO ONE
  42. ; TO INITIATE THE EXPLOSION WHEN A COLISION IS DETECTED
  43. DOMINIS: LDY #MININUMB-1
  44. DOMINILP: LDA MINITBL,Y
  45. BMI DOMINIDN ; NO MINI HERE
  46. TAX
  47. LDA VPTBL,X
  48. CMP #SCRENBOT+1
  49. BNE DOMINI1
  50. LDA #$FF
  51. STA MINITBL,Y
  52. DOMINIDN: DEY
  53. BPL DOMINILP
  54. RTS
  55. DOMSHOTS: LDA SPHXSHTD
  56. BNE MINIDONE
  57. LDA COLX1,X ;THE OFFSETS NEED ADJUSTING
  58. CLC
  59. ADC #3 ;FUDGE FACTOR
  60. STA TEMP2 ; X POS FOR LAUNCHER
  61. SEC
  62. SBC XTBL+ZBIRD
  63. CMP #$F8 ;LAUNCH SHOT WHEN BIRD IS IN FRONT
  64. BCS ENOGINIM ;OF MINI SPHINX (FOR NOW)
  65. CMP #8
  66. BCS MINIDONE
  67. ENOGINIM: LDA VPTBL,X ; MINI SPHINX MUST BE ON THE SCREEN
  68. CMP #SCRENBOT-25
  69. BCS MINIDONE
  70. LDA HPTBL,X
  71. CMP #15
  72. BCC MINIDONE
  73. CMP #145
  74. BCS MINIDONE
  75. LDA #0
  76. STA TEMP0 ;TEMP0 = 0 MEANS MINI SPHINX
  77. LDA #15 ; Y POS
  78. STA TEMP7
  79. LDA COLZ1,X
  80. SEC
  81. SBC #1 ; PREVENT SUICIDE
  82. STA TEMP9
  83. JSR LAUNCHER
  84. MINIDONE: LDY TEMP1
  85. JMP DOMINIDN
  86. DOMINI1: STY TEMP1
  87. LDA XTBL,X ; THIS IS THE MINI STATE
  88. BEQ DOMSHOTS ; THE MINI IS ALIVE
  89. RBOOR: CMP #MXDONE ; THE MINI IS DEAD OR DYING
  90. BEQ MINIDONE ; ALREADY DEAD
  91. INC XTBL,X ; NEXT STATE NEXT TIME
  92. STX TEMP0
  93. CMP #1
  94. BEQ MEXPINIT ; START THE EXPLOSION UP
  95. LDX TEMP1 ; OTHERWISE CONTINUE ANIMATION
  96. LDY MINIOVER,X ; Y IS OVERLAY SLOT NUMBER
  97. TAX ; X IS CURRENT ANIMATION NUMBER
  98. LDA MINIEXSL-2,X
  99. STA SLTBL,Y
  100. LDA MINIEXPW-2,X
  101. STA PWTBL,Y
  102. CPX #MXREM
  103. BEQ MEXPREM ; REMOVE OVERLAY
  104. CPX #MXREP
  105. BEQ MEXPREP ; REPLACE OVERLAY
  106. CPX #MXLOW
  107. BEQ MEXPLOW ; LOWER OVERLAY
  108. MEXPFNSH: LDX TEMP0
  109. JMP MINIDONE ; ALL DONE WITH THIS ANIMATION
  110. MEXPREM: LDA #200 ; OFF SCREEN HP
  111. STA HPTBL,Y ; OVERLAY'S HP
  112. JMP MEXPFNSH
  113. MEXPREP: LDX TEMP1 ; GET MINI SPHINX NUMBER
  114. LDA MINITBL,X ; GET SLOT NUMBER OF TOP
  115. TAX
  116. LDA HPTBL,X
  117. STA HPTBL,Y ; RESTORE HP
  118. JMP MEXPFNSH
  119. MEXPLOW: LDA VPTBL,Y ; LOWER THE OVERLAY
  120. CLC
  121. ADC #3
  122. STA VPTBL,Y
  123. LDX TEMP1 ; AND REMOVE THE HEAD FROM THE TOP
  124. LDA MINITBL,X
  125. TAX
  126. LDA SLTBL,X
  127. CLC
  128. ADC #3
  129. STA SLTBL,X ; BYPASS HEAD IN STAMP
  130. LDA HPTBL,X
  131. CLC
  132. ADC #12
  133. STA HPTBL,X ; NEW HP FOR TOP
  134. LDA PWTBL,X
  135. CLC
  136. ADC #3
  137. STA PWTBL,X ; AND SHRINK THE WIDTH
  138. LDA COLY2,X
  139. SEC
  140. SBC #10
  141. STA COLY2,X ; ALSO LOWER TOP OF COLISION BOX
  142. BNE MEXPFNSH
  143. MEXPINIT: JSR GETASLOT ; X IS NOW OVERLAY SLOT NUMBER
  144. BMI MEXPWAIT ; NO SLOT AVAILABLE
  145. LDY TEMP1 ; Y IS NOW MINI SPHINX NUMBER
  146. TXA
  147. STA MINIOVER,Y
  148. LDA MINITBL,Y
  149. TAY ; Y IS NOW TOP SLOT NUMBER
  150. LDA VPTBL,Y
  151. CLC
  152. ADC #5
  153. STA VPTBL,X ; OVERLAY INITIAL VP
  154. LDA HPTBL,Y
  155. STA HPTBL,X ; OVERLAY HP
  156. LDA YTBL,Y
  157. CLC
  158. ADC #6
  159. STA YTBL,X ; OVERLAY Y
  160. LDA #MINIEXP1&$FF
  161. STA SLTBL,X ; FIRST EXPLOSION ANIMATION
  162. LDA #MINIEXP1/256
  163. STA SHTBL,X
  164. LDA #$9C ; FIRST EXPLOSION PALETTE
  165. STA PWTBL,X ;PALW/WIDTH
  166. LDA #(MINIEXP1+$1700-$1600)/256
  167. STA SMTBL,X
  168. LDA DXTBL,Y
  169. SEC
  170. SBC #6
  171. STA TEMP6
  172. CLC
  173. ADC #2
  174. STA TEMP10
  175. LDA #0 ; NO COLISION BOX FOR OVERLAY
  176. STA COLSTAT,X
  177. JSR OBJINS ; INSERT OVERLAY INTO LINKED LIST
  178. JMP MEXPFNSH
  179. MEXPWAIT: LDX TEMP0
  180. DEC XTBL,X ; RESTORE OLD STATE FOR NEXT TIME
  181. JMP MINIDONE
  182. ; TABLES FOR MINI SPHINX EXPLOSION ANIMATION - STARTING WITH SECOND ANIMATION
  183. MINIEXSL: .dc.b 0 ; 2 - NO OVERLAY
  184. .dc.b 0 ; 3 - NO OVERLAY
  185. .dc.b MINIEXP1&$FF ; 4
  186. .dc.b MINIEXP1&$FF ; 5
  187. .dc.b MINIEXP2&$FF ; 6
  188. .dc.b MINIEXP1&$FF ; 7
  189. .dc.b MINIEXP1&$FF ; 8
  190. .dc.b MINIEXP2&$FF ; 9
  191. .dc.b MINIEXP2&$FF ; 10
  192. .dc.b MINIEXP1&$FF ; 11
  193. .dc.b MINIEXP1&$FF ; 12
  194. .dc.b MINIEXP2&$FF ; 13
  195. .dc.b MINIEXP1&$FF ; 14
  196. .dc.b MINIEXP3&$FF ; 15
  197. .dc.b MINIEXP1&$FF ; 16
  198. .dc.b MINIEXP2&$FF ; 17
  199. .dc.b MINIEXP3&$FF ; 18
  200. .dc.b MINIEXP1&$FF ; 19
  201. .dc.b MINIEXP3&$FF ; 20
  202. MINIEXPW: .dc.b $9C ; 2 - NO OVERLAY
  203. .dc.b $9C ; 3 - NO OVERLAY
  204. .dc.b $9C ; 4
  205. .dc.b $9C ; 5
  206. .dc.b $9C ; 6
  207. .dc.b $9C ; 7
  208. .dc.b $9C ; 8
  209. .dc.b $9C ; 9
  210. .dc.b $9C ; 10
  211. .dc.b $9C ; 11
  212. .dc.b $9C ; 12
  213. .dc.b $9C ; 13
  214. .dc.b $9C ; 14
  215. .dc.b $FC ; 15
  216. .dc.b $9C ; 16
  217. .dc.b $9C ; 17
  218. .dc.b $FC ; 18
  219. .dc.b $9C ; 19
  220. .dc.b $FC ; 20
  221. SXFLINIT: LDA PHASE
  222. BNE SLIDONE ; PUNT IF NOT NORMAL GAME PLAY
  223. TXA ; REMEMBER INDEX OF BOTTOM OF SPHINX FACE
  224. STA LOWFACE
  225. LDA COLX1,X ; GET X POSITION OF SPHINX NOSE
  226. CLC
  227. ADC #2
  228. STA SPHNXNSX
  229. LDA #3 ; ADJUST THIS
  230. SEC
  231. SBC DIFCULTY
  232. STA TEMP4 ; AMOUNT OF EXTRA COLISION BOX
  233. LDA COLX1,X
  234. SEC
  235. SBC TEMP4
  236. STA COLX1,X
  237. LDA COLX2,X
  238. CLC
  239. ADC TEMP4
  240. STA COLX2,X
  241. LDA COLY1,X
  242. SEC
  243. SBC TEMP4
  244. STA COLY1,X
  245. LDA COLY2,X
  246. CLC
  247. ADC TEMP4
  248. STA COLY2,X
  249. SLIDONE: RTS
  250. SXFHINIT: LDA PHASE
  251. BNE SLIDONE ; PUNT IF NOT NORMAL GAME PLAY
  252. TXA ; REMEMBER INDEX OF TOP OF SPHINX FACE
  253. STA HIFACE
  254. INC PHASE ; SET TO PHASE 1
  255. LDA #0
  256. STA FACER ; INITIALIZE ANIMATION
  257. RTS
  258. DSEXCLPS: LDA #CRATERL&$FF
  259. LDX LOWFACE
  260. STA SLTBL,X
  261. LDA #CRATERH&$FF
  262. LDX HIFACE
  263. STA SLTBL,X
  264. JMP DSEXANIM
  265. DSEXDONE: LDX SEXP1 ; DELETE THE OVERLAYS
  266. JSR OBJDEL
  267. JSR RETASLOT
  268. LDX SEXP2
  269. JSR OBJDEL
  270. JSR RETASLOT
  271. LDX SEXP3
  272. JSR OBJDEL
  273. JSR RETASLOT
  274. LDA #$FE ; GO TO TIMED BONUS PHASE
  275. STA PHASE
  276. RTS
  277. DSEXINIT: LDX LOWFACE
  278. LDA HPTBL,X
  279. STA TEMP3
  280. LDA VPTBL,X
  281. STA TEMP4
  282. LDA DXTBL,X
  283. SEC
  284. SBC #4
  285. STA TEMP6 ; ASSUMING THIS DOESN'T GO AWAY
  286. CLC
  287. ADC #2
  288. STA TEMP10 ; SAME HERE
  289. LDY #2
  290. DSEXINLP: JSR GETASLOT
  291. TXA
  292. STA SEXP1,Y
  293. LDA #SPHXGLMR/256
  294. STA SHTBL,X
  295. LDA #(SPHXGLMR+1700-1600)/256
  296. STA SMTBL,X
  297. LDA #$9E
  298. STA PWTBL,X
  299. LDA #30
  300. STA YTBL,X
  301. LDA TEMP3
  302. CLC
  303. ADC SEXHPOFF,Y
  304. STA HPTBL,X
  305. LDA TEMP4
  306. CLC
  307. ADC SEXVPOFF,Y
  308. STA VPTBL,X
  309. LDA #0
  310. STA COLSTAT,X
  311. JSR OBJINS
  312. DEY
  313. BPL DSEXINLP
  314. LDY #0
  315. JMP DSEXANIM
  316. DSEXPL: CMP #$FF ; PHASE IS IN A
  317. BNE ANRTS ; PHASE EQUALS -1 DURING EXPLOSION
  318. LDA MAINCNT
  319. LSR
  320. BCC ANRTS
  321. INC FACER
  322. LDY FACER
  323. CPY #0
  324. BEQ DSEXINIT
  325. CPY #15
  326. BEQ DSEXDONJ
  327. CPY #11
  328. BNE DSEXANIM
  329. JMP DSEXCLPS
  330. DSEXDONJ: JMP DSEXDONE
  331. DSEXANIM: LDX SEXP1
  332. LDA SEXAN1,Y
  333. STA SLTBL,X
  334. LDX SEXP2
  335. LDA SEXAN2,Y
  336. STA SLTBL,X
  337. LDX SEXP3
  338. LDA SEXAN3,Y
  339. STA SLTBL,X
  340. ANRTS: RTS
  341. SPHNXNSY EQU 22
  342. DOSPHINX: LDX LOWFACE
  343. LDA PHASE
  344. BEQ ANRTS ; IF IN NORMAL PLAY
  345. BMI DSEXPL ; IF IN EXPLOSION OR BONUS PHASE
  346. CMP #1
  347. BNE DSTUNE ; ALREADY STOPPED SCROLLING
  348. LDA COLZ1,X
  349. CMP #140
  350. BCS DSTUNE ; KEEP SCROLLING
  351. INC PHASE ; NOW IN PHASE 2
  352. DSTUNE: LDA #SFINKS
  353. CMP TUNNUM
  354. BEQ DSSHOOT ; STILL PLAYING
  355. CMP TUNNUM+1
  356. BEQ DSSHOOT ; STILL PLAYING
  357. JSR TUNIN ; PLAY AGAIN - IT GOT BOOTED
  358. DSSHOOT:
  359. BIT PARASPHX
  360. BMI ANRTS
  361. LDA SPHXSHTD
  362. BNE DSSPAWN
  363. LDA #1
  364. STA TEMP0 ;TEMP0 = 1 MEANS BIG SPHINX
  365. LDA SPHNXNSX
  366. STA TEMP2
  367. LDA #SPHNXNSY+7 ; Y POS
  368. STA TEMP7
  369. LDA COLZ1,X
  370. SEC
  371. SBC #6 ; PREVENT SUICIDE
  372. STA TEMP9
  373. JSR LAUNCHER
  374. DSSPAWN: LDA PHASE
  375. CMP #2
  376. BNE DSANIM ; SPAWN ONLY WHEN SCROLLING IS STOPPED
  377. DEC SPNCNT
  378. BNE DSANIM
  379. LDX LOWFACE
  380. LDA #20
  381. STA SPNCNT
  382. LDA SPHNXNSX
  383. STA SPNX
  384. LDA #SPHNXNSY-6
  385. STA SPNY
  386. LDA COLZ1,X
  387. SEC
  388. SBC #5
  389. STA SPNZ
  390. JSR RANDOM
  391. AND #3
  392. LDX PLAYER
  393. ADC RACK,X
  394. CMP #$C
  395. BCC DSSPCLS
  396. LDA #$B
  397. DSSPCLS:
  398. STA SPNCLASS
  399. JSR SPAWN
  400. DSANIM: LDA MAINCNT
  401. AND #3
  402. BNE DSDONE
  403. LDY FACER
  404. LDA FACEADV,Y
  405. BPL FACESTA
  406. LDA RNDOM
  407. AND #4
  408. FACESTA: STA FACER
  409. TAY
  410. LDA FACEHI,Y
  411. LDX HIFACE
  412. STA SLTBL,X
  413. LDA FACELO,Y
  414. LDX LOWFACE
  415. STA SLTBL,X
  416. DSDONE: RTS
  417. FACEADV: .dc.b 1,2,3,$80,5,6,7,$80
  418. SEXHPOFF: .dc.b 0,5,3
  419. SEXVPOFF: .dc.b -17,-16,-8
  420. SEXAN1: .dc.b SPHXGLMR&$FF ;0
  421. .dc.b BLANK&$FF ;1
  422. .dc.b SPHXGLMR&$FF ;2
  423. .dc.b SPHXFLSH&$FF ;3
  424. .dc.b SPHXGLMR&$FF ;4
  425. .dc.b SPHXGLMR&$FF ;5
  426. .dc.b SPHXFLSH&$FF ;6
  427. .dc.b SPHXEXPL&$FF ;7
  428. .dc.b SPHXFLSH&$FF ;8
  429. .dc.b SPHXEXPL&$FF ;9
  430. .dc.b SPHXEXPL&$FF ;10
  431. .dc.b SPHXEXPL&$FF ;11
  432. .dc.b SPHXFLSH&$FF ;12
  433. .dc.b SPHXEXPL&$FF ;13
  434. .dc.b SPHXEXPL&$FF ;14
  435. SEXAN2: .dc.b BLANK&$FF ;0
  436. .dc.b SPHXGLMR&$FF ;1
  437. .dc.b BLANK&$FF ;2
  438. .dc.b SPHXGLMR&$FF ;3
  439. .dc.b SPHXFLSH&$FF ;4
  440. .dc.b SPHXGLMR&$FF ;5
  441. .dc.b SPHXGLMR&$FF ;6
  442. .dc.b SPHXFLSH&$FF ;7
  443. .dc.b SPHXEXPL&$FF ;8
  444. .dc.b SPHXEXPL&$FF ;9
  445. .dc.b SPHXFLSH&$FF ;10
  446. .dc.b SPHXEXPL&$FF ;11
  447. .dc.b SPHXEXPL&$FF ;12
  448. .dc.b SPHXFLSH&$FF ;13
  449. .dc.b SPHXEXPL&$FF ;14
  450. SEXAN3: .dc.b BLANK&$FF ;0
  451. .dc.b BLANK&$FF ;1
  452. .dc.b SPHXGLMR&$FF ;2
  453. .dc.b BLANK&$FF ;3
  454. .dc.b SPHXGLMR&$FF ;4
  455. .dc.b SPHXFLSH&$FF ;5
  456. .dc.b SPHXGLMR&$FF ;6
  457. .dc.b SPHXFLSH&$FF ;7
  458. .dc.b SPHXEXPL&$FF ;8
  459. .dc.b SPHXFLSH&$FF ;9
  460. .dc.b SPHXEXPL&$FF ;10
  461. .dc.b SPHXEXPL&$FF ;11
  462. .dc.b SPHXFLSH&$FF ;12
  463. .dc.b SPHXEXPL&$FF ;13
  464. .dc.b SPHXEXPL&$FF ;14
  465. FACELO: .dc.b SPFACE1L&$FF,SPFACE4L&$FF,SPFACE5L&$FF
  466. .dc.b SPFACE4L&$FF,SPFACE1L&$FF
  467. .dc.b SPFACE2L&$FF,SPFACE1L&$FF,SPFACE3L&$FF
  468. FACEHI: .dc.b SPFACE1H&$FF,SPFACE4H&$FF,SPFACE5H&$FF
  469. .dc.b SPFACE4H&$FF,SPFACE1H&$FF
  470. .dc.b SPFACE2H&$FF,SPFACE1H&$FF,SPFACE3H&$FF
  471. KILLSPHX: LDA PHASE ; A SHOT HIT THE SPHINX
  472. BEQ KSDONE
  473. BMI KSDONE ; ITS ALREADY BEEN HIT
  474. JSR INITBNS ; TELL STUFF IN SMAGIC
  475. LDA #$FF
  476. STA FACER ; START OF FACE EXPLOSION ANIMATION
  477. LDA #SFINKS ; DO WE NEED THIS IF WE HAVE A TWO
  478. JSR SCRAPONE ; CHANNEL SOUND??
  479. LDA #SPHXBM0
  480. JSR TUNIN
  481. LDA #SPHXBM1
  482. JSR TUNIN
  483. LDA RACK ;SCORE FOR SPHINX IS (RACK+5)*1000
  484. ASL ;RACK STARTS AT 0
  485. ASL
  486. ASL
  487. ASL ;MOVE TO UPPER NIBBLE
  488. SED
  489. CLC
  490. ADC #$50 ;ADD RACK TO 5000
  491. STA HUNDS
  492. LDA #0
  493. ADC #0
  494. STA HUNTHOUS
  495. CLD
  496. JSR ADDSCORE
  497. KSDONE: RTS
  498. * KILL ALL FIRE POTS POWER
  499. KAFIRES: LDX #FIRENUMB-1 ; KILL ALL FIRES
  500. KAFIRELP: LDA FIRETIP,X
  501. BMI KNFIRE ; NOT AN ACTIVE FIRE POT
  502. LDA #0
  503. STA FIREGOAL,X
  504. KNFIRE: DEX
  505. BPL KAFIRELP
  506. RTS
  507. FIREINIT: LDY #FIRENUMB-1 ; CALLED WITH SLOT NUMBER IN X
  508. FIRELP: LDA FIRETIP,Y
  509. BMI FIREFND
  510. DEY
  511. BPL FIRELP
  512. FIREKILL: LDA #SCRENBOT+1
  513. STA VPTBL,X
  514. JSR OBJDEL ; DELETE FIRE IF WE CAN'T ANIMATE IT
  515. JSR RETASLOT
  516. RTS
  517. FIREFND: STX TEMP2 ; TIP SLOT NUMBER
  518. TXA ; TIP SLOT IN A AND X
  519. STA FIRETIP,Y
  520. JSR RANDOM ; START WITH RANDOM ANIMATION
  521. STA FIREANIM,Y
  522. LDA #2
  523. STA FIREHGHT,Y
  524. ; LDA #2 ;2 IS ALREADY IN A
  525. STA FIREGOAL,Y
  526. LDA DIFIND ;0 IS LOW DIFF., 255 IS HIGH
  527. ASL ;PUT TOP TWO BITS INTO BOTTOM TWO BITS
  528. ROL ;SHIFTED TOP BIT INTO BIT0
  529. ROL ;SHIFTED NEXT BIT INTO BIT0
  530. AND #$3 ;MASK OUT REMAINING BITS
  531. ;NOW WE HAVE TWO LOW ORDER BITS BASED ON DIFFICULTY
  532. STA TEMP3 ;I KNOW I CAN USE THIS
  533. JSR RANDOM
  534. AND #$0C
  535. ORA TEMP3
  536. TAX
  537. LDA MODETABL,X
  538. STA FIREMODE,Y
  539. LDA #$FF
  540. STA FIRECOL1,Y
  541. STA FIRECOL2,Y
  542. STY TEMP3 ; FIRE TABLE INDEX
  543. ;Y HAS NOT CHANGED, BUT I USED TEMP3 AS A TEMP ABOVE
  544. RTS
  545. MODETABL:
  546. .dc.b 0,2,2,1,1,1,1,3,0,0,2,2,1,1,0,3
  547. DOFIRE: LDX #FIRENUMB-1
  548. DFLOOP: LDY FIRETIP,X
  549. BPL DFYES ; AN ACTIVE ENTRY
  550. DFNEXT: DEX
  551. BPL DFLOOP
  552. RTS
  553. DFFREE: LDA #$FF
  554. STA FIRETIP,X ; MARK TABLE ENTRY AS UNUSED
  555. BMI DFNEXT ; ALWAYS
  556. DFYES: STX TEMP0 ; FIRE TABLE INDEX
  557. STY TEMP1 ; TIP SLOT NUMBER
  558. LDA VPTBL,Y
  559. CMP #SCRENBOT+1
  560. BEQ DFFREE ; THE TIP HAS SCROLLED OFF
  561. INC FIREANIM,X
  562. LDA FIREANIM,X
  563. AND #3
  564. BNE DFNEXT ; ONLY DO EVERY 4TH GAME LOOP
  565. LDA FIREHGHT,X ; COMPARE HEIGHT AND GOAL TO GET
  566. CMP FIREGOAL,X ; DIRECTION TO MOVE
  567. BEQ DFMCFALL ; DF IS A RELATIVE OF ROSALIE
  568. BCC JDRISE
  569. JMP DFFALL
  570. JDRISE: JMP DFRISE
  571. HIBND: .dc.b 17,49,49,49 ;TABLE OF FLAME HI BOUNDS BY MODE
  572. GOALBASE: .dc.b 40,2 ;BASE OF SPAZ GOAL
  573. DFMCFALL:
  574. ;THERE ARE FOUR FIREMODES -- 0) MELLOW 1) RANDOM 2) SPASTIC 3) HARDCORE
  575. LDA FIREMODE,X
  576. TAY ; MODE STAYS IN Y FOR NOW
  577. JSR RANDOM ; GET NEW GOAL
  578. AND #$3F
  579. CMP #2
  580. BCC DFANIM ; LEAVE SAME IF TO LOW
  581. CMP HIBND,Y ; GET HIGH BOUND BASED ON MODE
  582. BCS DFANIM ; LEAVE SAME IF TO HIGH
  583. CPY #2 ; LOOK FOR MORE COMPLICATED MODES
  584. BCC STGOAL ; IF SIMPLE, STORE GOAL
  585. ;THIS IS WHERE THE FUN BEGINS -- WE NEED SOME GOAL SELECTION INTELLIGENCE
  586. STA TEMP2 ; SAVE CALCULATED RANDOM GOAL FOR LATER
  587. BEQ SPAZ ; IF MODE = 2, GO TO SPAZ DRIVER
  588. ;THIS MUST BE THE HARDCORE DRIVER. WE KEEP GOAL RANDOM IF NOT IN
  589. ;RANGE OF X. IF IN X RANGE, WE KEEP GOAL LOW UNTIL IN Z RANGE. THEN
  590. ;WE RAISE GOAL TO ZAP THE DESERT FUCKIN' FALCON
  591. ;SEE IF BIRD IS NEAR
  592. LDY TEMP1 ;INDEX OF TIP
  593. LDA COLX1,Y ;9 BIT AVERAGE OF COLLISION X'ES
  594. CLC
  595. ADC COLX2,Y
  596. ROR ;DON'T LOSE TOP BIT
  597. SEC
  598. SBC XTBL ;COMPARE TO BIRD'S X
  599. CMP #$EE ;IF OUT OF X RANGE, USE RANDOM GOAL
  600. BCS CHEQUEZ
  601. CMP #18
  602. BCS USETE2 ;WE TAKE THIS BRANCH TO USE RANDOM GOAL
  603. ;NOW WE KNOW IT IS IN X RANGE
  604. ;CHECK Z RANGE FOR LOW OR HIGH GOAL
  605. CHEQUEZ:
  606. LDA COLZ1,Y ;9 BIT AVERAGE OF COLLISION Z'ES
  607. CLC
  608. ADC COLZ2,Y
  609. ROR ;DON'T LOSE TOP BIT
  610. SEC
  611. SBC ZTBL
  612. BMI USETE2 ;POT IS BEHIND BIRD
  613. CMP #$1C ;LOTS O' LEAD TIME
  614. LDA #0 ;CARRY SET MAKES THIS A 1 (>= 1C)
  615. ROL ;USE CARRY TO MAKE THIS A 0 OR 1. 0 IS
  616. ;FOR HIGOAL, 1 IS FOR LOW GOAL
  617. TAY ;SAVE THIS FOR INDEXING SOON
  618. JSR RANDOM ;GET RANDOM GOAL BASED IN RGHT PLACE
  619. AND #7
  620. ADC GOALBASE,Y
  621. BNE STGOAL ;JMP
  622. SPAZ:
  623. TAY ;SAVE TEMP2 IN Y ALSO FOR QUICK COMPARE
  624. LDA #16 ;SEE WHAT LAST GOAL WAS (HI OR LO)
  625. CMP FIREGOAL,X
  626. TYA ;GET RANDOM GOAL IN A
  627. BCS HIGOAL ;IF GOAL >16, THEN MAKE NEW ONE <16
  628. CMP #16 ;CHECK NEW GOAL FOR LOWNESS
  629. BCS DFANIM
  630. BCC STGOAL
  631. HIGOAL:
  632. CMP #40 ;IS GOAL HIGH ENOUGH?
  633. BCC DFANIM ;IF NOT, DON'T CHANGE GOAL
  634. USETE2:
  635. LDA TEMP2 ;I KNOW THIS IS ALREADY IN A
  636. STGOAL:
  637. STA FIREGOAL,X
  638. DFANIM: LDA FIREANIM,X ; DERIVE ANIMATION INDEX
  639. LSR
  640. LSR
  641. CMP #6
  642. BCC DFANIMOK
  643. LDA #0
  644. STA FIREANIM,X
  645. DFANIMOK: TAY
  646. LDA COLANIM,Y
  647. STA TEMP2
  648. LDA TIPANIM,Y
  649. LDY TEMP1 ; INDEX OF TIP
  650. STA SLTBL,Y
  651. LDY FIRECOL1,X ; DO UPPER COLUMN
  652. BMI DFC1GONE ; IT MUST HAVE SCROLLED OFF
  653. LDA VPTBL,Y ; SEE IF IT JUST SCROLLED OFF
  654. CMP #SCRENBOT+1
  655. BNE DFC1HERE ; NOPE
  656. LDA #$FF
  657. STA FIRECOL1,X ; MARK IT
  658. BMI DFC1GONE ; ALWAYS
  659. DFC1HERE: LDA TEMP2 ; COLUMN ANIMATION
  660. STA SLTBL,Y
  661. DFC1GONE: LDY FIRECOL2,X ; DO LOWER COLUMN
  662. BMI DFNEXTJ ; IT MUST HAVE SCROLLED OFF
  663. LDA VPTBL,Y ; SEE IF IT JUST SCROLLED OFF
  664. CMP #SCRENBOT+1
  665. BNE DFC2HERE ; NOPE
  666. LDA #$FF
  667. STA FIRECOL2,X ; MARK IT
  668. BMI DFNEXTJ ; ALWAYS
  669. DFC2HERE: LDA TEMP2 ; COLUMN ANIMATION
  670. STA SLTBL,Y
  671. DFNEXTJ: JMP DFNEXT
  672. DFRISE: LDA VPTBL,Y
  673. CMP #$F6
  674. BCS DFRISE1 ; LET IT GO PAST TOP OF SCREEN
  675. CMP #$EC
  676. BCC DFRISE1 ; BUT NOT TOO FAR
  677. DEC FIREGOAL,X ; TO PREVENT IT FROM STICKING HERE
  678. JMP DFDONE
  679. DFRISE1: JSR RANDOM ; HOW MUCH DO WE RISE ?
  680. AND #7
  681. STA TEMP3
  682. INC TEMP3 ; MAKE BETWEEN 1 AND 8
  683. LDA FIREHGHT,X
  684. STA TEMP5 ; NEED TO KEEP OLD HEIGHT
  685. CLC
  686. ADC TEMP3
  687. CMP #49
  688. BCS DFDONE ; DON'T GET TOO HIGH
  689. STA FIREHGHT,X
  690. STA TEMP7 ; NEED THIS LATER WITHOUT INDEXING
  691. LDX TEMP1 ; FIRE TIP SLOT
  692. LDY TEMP0 ; FIRE TABLE INDEX
  693. LDA COLY2,X ; ADJUST COLISION BOX
  694. CLC
  695. ADC TEMP3
  696. STA COLY2,X
  697. LDA VPTBL,X ; DO TIP FIRST
  698. SEC
  699. SBC TEMP3
  700. STA VPTBL,X
  701. LDA TEMP7 ; NEW HEIGHT
  702. CMP #17
  703. BCC DFDONE ; NO OTHER PIECES
  704. LDA TEMP5 ; OLD HEIGHT
  705. CMP #17 ; DOES COLUMN 1 ALREADY EXIST
  706. BCC DFADDC1J ; NEED A NEW PIECE
  707. LDA TEMP7 ; NEW HEIGHT
  708. CMP #33
  709. BCC DFDONE ; NO OTHER PIECES
  710. LDA TEMP5 ; OLD HEIGHT
  711. CMP #33 ; DOES COLUMN 2 ALREADY EXIST
  712. BCC DFADDC2J ; NEED A NEW PIECE
  713. DFDONE: LDX TEMP0
  714. LDY TEMP1
  715. JMP DFANIM
  716. DFADDC1J: JMP DFADDC1
  717. DFADDC2J: JMP DFADDC2
  718. DFDELC1J: JMP DFDELC1
  719. DFDELC2J: JMP DFDELC2
  720. DFFALL: JSR RANDOM ; HOW MUCH DO WE FALL ?
  721. AND #7
  722. STA TEMP3
  723. INC TEMP3 ; MAKE BETWEEN 1 AND 8
  724. LDA FIREHGHT,X
  725. STA TEMP5 ; NEED TO KEEP OLD HEIGHT
  726. SEC
  727. SBC TEMP3
  728. CMP #2
  729. BCC DFLOW ; DON'T GET TOO LOW
  730. CMP #$F8
  731. BCS DFLOW ; WATCH FOR NEGATIVES
  732. STA FIREHGHT,X
  733. STA TEMP7 ; NEED THIS LATER WITHOUT INDEXING
  734. LDX TEMP1 ; FIRE TIP SLOT
  735. LDY TEMP0 ; FIRE TABLE INDEX
  736. LDA COLY2,X ; ADJUST COLISION BOX
  737. SEC
  738. SBC TEMP3
  739. STA COLY2,X
  740. LDA VPTBL,X ; DO TIP FIRST
  741. CLC
  742. ADC TEMP3
  743. STA VPTBL,X
  744. LDA TEMP5 ; OLD HEIGHT
  745. CMP #17
  746. BCC DFDONE ; NO OTHER PIECES
  747. LDA TEMP7 ; NEW HEIGHT
  748. CMP #17 ; DOES COLUMN 1 ALREADY EXIST
  749. BCC DFDELC1J ; DELETE A PIECE
  750. LDA TEMP5 ; OLD HEIGHT
  751. CMP #33
  752. BCC DFDONE ; NO OTHER PIECES
  753. LDA TEMP7 ; NEW HEIGHT
  754. CMP #33 ; DOES COLUMN 2 ALREADY EXIST
  755. BCC DFDELC2J ; DELETE A PIECE
  756. JMP DFDONE
  757. DFLOW: LDA FIREGOAL,X ; CALLED WHEN FIRE HEIGHT LESS THAN 2
  758. BNE DFDONE
  759. LDY FIRETIP,X
  760. LDA #$FF
  761. STA FIRETIP,X
  762. TYA
  763. TAX
  764. JSR FIREKILL ; EXTINGUISH IT
  765. LDX TEMP0
  766. JMP DFNEXT
  767. DFADDC1: JSR GETASLOT ; GET COLUMN SLOT NUMBER IN X
  768. BMI DFDONEJ ; THIS NEEDS TO BE HANDLED BETTER
  769. LDY TEMP1 ; TIP SLOT NUMBER
  770. LDA VPTBL,Y ; COL1 VP = TIP VP + HGHT - 16
  771. CLC
  772. ADC TEMP7 ; NEW HEIGHT
  773. SEC
  774. SBC #16
  775. STA VPTBL,X
  776. LDA #0
  777. STA COLSTAT,X ; NO COLISION BOX
  778. LDA HPTBL,Y
  779. SEC
  780. SBC #2
  781. STA HPTBL,X
  782. LDA #COL1/256
  783. STA SHTBL,X
  784. LDA #COL1&$FF
  785. STA SLTBL,X
  786. LDA #(COL1+$1100-$1000)/256 ; NON-HACKED STAMP
  787. STA SMTBL,X
  788. LDA #$9D
  789. STA PWTBL,X
  790. LDA #16
  791. STA YTBL,X
  792. LDA DXTBL,Y ; SAME DX AS TIP
  793. STA TEMP6
  794. LDA DFTBL,Y
  795. STA TEMP10
  796. JSR OBJINS
  797. LDY TEMP0 ; FIRE SLOT NUMBER
  798. TXA
  799. STA FIRECOL1,Y ; MARK IT
  800. DFDONEJ: JMP DFDONE
  801. DFADDC2: JSR GETASLOT ; GET COLUMN SLOT NUMBER IN X
  802. BMI DFDONEJ ; THIS NEEDS TO BE HANDLED BETTER
  803. LDY TEMP1 ; TIP SLOT NUMBER
  804. LDA VPTBL,Y ; COL2 VP = TIP VP + HGHT - 32
  805. CLC
  806. ADC TEMP7 ; NEW HEIGHT
  807. SEC
  808. SBC #32
  809. STA VPTBL,X
  810. LDA #0
  811. STA COLSTAT,X ; NO COLISION BOX
  812. LDA HPTBL,Y
  813. SEC
  814. SBC #2
  815. STA HPTBL,X
  816. LDA #COL1/256
  817. STA SHTBL,X
  818. LDA #COL1&$FF
  819. STA SLTBL,X
  820. LDA #(COL1+$1100-$1000)/256 ; NON-HACKED STAMP
  821. STA SMTBL,X
  822. LDA #$9D
  823. STA PWTBL,X
  824. LDA #32
  825. STA YTBL,X
  826. LDA DXTBL,Y ; SAME DX AS TIP
  827. STA TEMP6
  828. LDA DFTBL,Y
  829. STA TEMP10
  830. JSR OBJINS
  831. LDY TEMP0 ; FIRE SLOT NUMBER
  832. TXA
  833. STA FIRECOL2,Y ; MARK IT
  834. JMP DFDONE
  835. DFDELC1: LDX FIRECOL1,Y
  836. BMI DFDONEJ
  837. LDA #SCRENBOT+1
  838. CMP VPTBL,X
  839. BEQ DFDONEJ
  840. STA VPTBL,X
  841. JSR OBJDEL
  842. JSR RETASLOT
  843. LDY TEMP0 ; FIRE SLOT NUMBER
  844. LDA #$FF
  845. STA FIRECOL1,Y
  846. JMP DFDONE
  847. DFDELC2: LDX FIRECOL2,Y
  848. BMI DFDONEJ
  849. LDA #SCRENBOT+1
  850. CMP VPTBL,X
  851. BEQ DFDONEJ
  852. STA VPTBL,X
  853. JSR OBJDEL
  854. JSR RETASLOT
  855. LDY TEMP0 ; FIRE SLOT NUMBER
  856. LDA #$FF
  857. STA FIRECOL2,Y
  858. JMP DFDONE
  859. ;SEQUENCE OF FLAME ANIMATIONS
  860. COLANIM: .dc.b COL1&$FF,COL2&$FF,COL1&$FF,COL2&$FF,COL1&$FF,COL2&$FF
  861. TIPANIM: .dc.b TIP1&$FF,TIP2&$FF,TIP3&$FF,TIP1&$FF,TIP2&$FF,TIP3&$FF
  862. ; ROUTINE TO LAUNCH SPHINX AND MINISPHINX SHOTS
  863. ; TYPE = TEMP0
  864. ; X = TEMP2
  865. ; Y = TEMP7
  866. ; Z = TEMP9
  867. LAUNCHER:
  868. LDX #3
  869. LOOK4SHT: LDA SXSHTSTT,X
  870. BEQ AFREESHT
  871. DEX
  872. BPL LOOK4SHT
  873. RTS
  874. AFREESHT:
  875. LDY TEMP0
  876. INY ;1 FOR MINI SPHINX, 2 FOR SPHINX
  877. TYA
  878. STA SXSHTSTT,X ;MARK SHOT AS USED
  879. LDA #MINISHOT
  880. JSR TUNIN
  881. JSR RANDOM ; DELAY TIL NEXT SHOT
  882. AND #$4F
  883. LDY DIFCULTY
  884. CLC
  885. ADC SXSHTMTD,Y
  886. STA SPHXSHTD
  887. LDA TEMP2
  888. STA XTBL+SPHXSHOT,X
  889. STA XTBL+SPXSHTSH,X
  890. SEC
  891. SBC #3
  892. STA COLX1+SPHXSHOT,X
  893. CLC
  894. ADC #7
  895. STA COLX2+SPHXSHOT,X
  896. LDA TEMP7
  897. STA YTBL+SPHXSHOT,X
  898. SEC
  899. SBC #3
  900. STA COLY1+SPHXSHOT,X
  901. CLC
  902. ADC #7
  903. STA COLY2+SPHXSHOT,X
  904. LDA #0
  905. STA YTBL+SPXSHTSH,X
  906. LDA TEMP9
  907. STA ZTBL+SPHXSHOT,X
  908. STA ZTBL+SPXSHTSH,X
  909. SEC
  910. SBC #3
  911. STA COLZ1+SPHXSHOT,X
  912. CLC
  913. ADC #7
  914. STA COLZ2+SPHXSHOT,X
  915. LDA TEMP2 ; PROJECT HP'S
  916. CLC
  917. ADC TEMP9
  918. ADC #(-NUMBER-7)&$FF ;-7 IS HPOFF FOR BOTH SHOT ANIMATIONS
  919. STA HPTBL+SPHXSHOT,X ;HERE ARE THE SHOT AND SHADOW HP'S
  920. STA HPTBL+SPXSHTSH,X
  921. LDA TEMP2 ; PROJECT VP'S
  922. SEC
  923. SBC TEMP9
  924. CLC
  925. ADC #NUMBER
  926. STA VPTBL+SPXSHTSH,X ;HERE IS SHADOW VP
  927. SEC
  928. SBC TEMP7
  929. STA VPTBL+SPHXSHOT,X ;HERE IS SHOT VP
  930. LDA TEMP9 ; CALCULATE DX AND DF
  931. SEC
  932. SBC TEMP2
  933. CLC
  934. ADC #NUMBER+DXADJ+10 ; THIS IS DF
  935. STA TEMP10
  936. SEC
  937. SBC #5 ; THIS IS DS
  938. STA TEMP6 ;PRIORITY OF SHOT
  939. LDA #SXSHTCOL
  940. STA COLSTAT+SPHXSHOT,X ;STORE THE COLSTAT
  941. TXA ; GET REAL INDEX FOR SHOT
  942. CLC
  943. ADC #SPHXSHOT
  944. TAX
  945. JSR OBJINS
  946. LDA #$FE
  947. STA TEMP6
  948. STA TEMP10
  949. TXA ; GET REAL INDEX FOR SHADOW
  950. CLC
  951. ADC #SPXSHTSH-SPHXSHOT
  952. TAX
  953. JSR OBJINS
  954. RTS
  955. SXSHTMTD: .dc.b 18,14,10,8 ; MINIMUM SPHINX SHOT DELAY
  956. ;THIS DRIVES SPHINX AND MINI SPHINX SHOTS
  957. DOSXSHTS: DEC SPHXSHTD
  958. BPL MVSHOTS
  959. LDA #0
  960. STA SPHXSHTD
  961. MVSHOTS: LDX #3
  962. MVSHOTLP: LDA SXSHTSTT,X
  963. BNE SHOTALIV ; SEE IF SHOT EXISTS
  964. NEXTSHOT2:
  965. DEX
  966. BPL MVSHOTLP
  967. RTS
  968. SHOTALIV: STX TEMP9 ; SAVE FOR LATER
  969. LDA #0
  970. STA TEMP4 ; DEFAULT X MOTION
  971. STA TEMP5 ; DEFAULT Y MOTION
  972. LDA DIFCULTY
  973. BEQ GOLEVEL ; DON'T TRACK AT NOVICE LEVEL
  974. LDA ZTBL+SPHXSHOT,X
  975. CMP #ZBIRDZ+10
  976. BCC GOLEVEL ; DON'T TRACK ONCE PAST BIRD
  977. LDA XTBL+SPHXSHOT,X ; CALCULATE X MOTION
  978. SEC
  979. SBC XTBL+ZBIRD
  980. BEQ GOSTRAIT
  981. BMI GORIGHT
  982. LDA #$FF
  983. BNE STOREX ; ALWAYS
  984. GORIGHT: LDA #1
  985. STOREX: STA TEMP4 ; X MOTION
  986. GOSTRAIT: LDA SXSHTSTT,X ; CALCULATE Y MOTION
  987. CMP #2
  988. BNE GOLEVEL ; DO Y ONLY FOR BIG SPHINX
  989. LDA DIFCULTY
  990. CMP #2
  991. BCC GOLEVEL ; TRACK IN Y ONLY AT ADV AND EXP LEVELS
  992. LDA YTBL+SPHXSHOT,X
  993. SEC
  994. SBC YTBL+ZBIRD
  995. BEQ GOLEVEL
  996. BMI GOUP
  997. LDA #$FF
  998. BNE STOREY ; ALWAYS
  999. GOUP: LDA #1
  1000. STOREY: STA TEMP5 ; Y MOTION
  1001. GOLEVEL: LDA RACK ; CALCULATE Z MOTION
  1002. LSR
  1003. ; LSR
  1004. CLC
  1005. ADC SXSHTSTT,X
  1006. ADC SCROLLS ; MAKE RELATIVE TO GROUND
  1007. STA TEMP7 ; Z MOTION - TOWARDS SCREEN
  1008. LDA HPTBL+SPHXSHOT,X ; DO SHOT AND SHAD HP
  1009. CLC
  1010. ADC TEMP4 ; X
  1011. SEC
  1012. SBC TEMP7 ; Z
  1013. STA HPTBL+SPHXSHOT,X
  1014. STA HPTBL+SPXSHTSH,X
  1015. LDA VPTBL+SPHXSHOT,X ; DO SHOT VP
  1016. CLC
  1017. ADC TEMP4 ; X
  1018. SEC
  1019. SBC TEMP5 ; Y
  1020. CLC
  1021. ADC TEMP7 ; Z
  1022. CMP #$E0
  1023. BCS VPOKAY
  1024. CMP #SCRENBOT
  1025. BCS SXSHTDEL ; IT'S OFF THE BOTTOM OF THE SCREEN
  1026. VPOKAY: STA VPTBL+SPHXSHOT,X
  1027. LDA VPTBL+SPXSHTSH,X ; DO SHAD VP
  1028. CLC
  1029. ADC TEMP4 ; X
  1030. CLC
  1031. ADC TEMP7 ; Z
  1032. STA VPTBL+SPXSHTSH,X
  1033. LDA XTBL+SPHXSHOT,X ; DO SHOT X
  1034. CLC
  1035. ADC TEMP4 ; X
  1036. STA XTBL+SPHXSHOT,X
  1037. STA COLPX
  1038. LDA YTBL+SPHXSHOT,X ; DO SHOT Y
  1039. CLC
  1040. ADC TEMP5 ; Y
  1041. STA YTBL+SPHXSHOT,X
  1042. STA COLPY
  1043. LDA ZTBL+SPHXSHOT,X ; DO SHOT Z
  1044. SEC
  1045. SBC TEMP7 ; Z
  1046. STA ZTBL+SPHXSHOT,X
  1047. STA COLPZ
  1048. LDA COLX1+SPHXSHOT,X ; DO COLISION X'S
  1049. CLC
  1050. ADC TEMP4 ; X
  1051. STA COLX1+SPHXSHOT,X
  1052. CLC
  1053. ADC #7
  1054. STA COLX2+SPHXSHOT,X
  1055. LDA COLY1+SPHXSHOT,X ; DO COLISION Y'S
  1056. CLC
  1057. ADC TEMP5 ; Y
  1058. STA COLY1+SPHXSHOT,X
  1059. CLC
  1060. ADC #7
  1061. STA COLY2+SPHXSHOT,X
  1062. LDA COLZ1+SPHXSHOT,X ; DO COLISION Z'S
  1063. SEC
  1064. SBC TEMP7 ; Z
  1065. STA COLZ1+SPHXSHOT,X
  1066. CLC
  1067. ADC #7
  1068. STA COLZ2+SPHXSHOT,X
  1069. LDA DXTBL+SPHXSHOT,X ; DO SHOT DX AND DF
  1070. SEC
  1071. SBC TEMP4 ; X
  1072. SEC
  1073. SBC TEMP7 ; Z
  1074. STA TEMP6
  1075. CLC
  1076. ADC #5
  1077. STA TEMP10
  1078. TXA ; GET REAL SLOT NUMBER
  1079. CLC
  1080. ADC #SPHXSHOT
  1081. TAX
  1082. JSR OBJMOV ; MOVE THE SHOT
  1083. JSR COLDET
  1084. BNE SXSHTDEL
  1085. LDX TEMP9
  1086. JMP NEXTSHOT2 ; DO NEXT SHOT
  1087. SXSHTDEL: LDX TEMP9
  1088. LDA #0
  1089. STA SXSHTSTT,X
  1090. TXA ; GET REAL SHOT INDEX
  1091. CLC
  1092. ADC #SPHXSHOT
  1093. TAX
  1094. JSR OBJDEL ; DELETE SHOT
  1095. TXA ; GET REAL SHADOW INDEX
  1096. CLC
  1097. ADC #SPXSHTSH-SPHXSHOT
  1098. TAX
  1099. JSR OBJDEL ; DELETE SHADOW
  1100. LDX TEMP9
  1101. JMP NEXTSHOT2 ; DO NEXT SHOT
  1102. ; REMOVE A TREASURE FROM THE SCREEN - INDEX IN X
  1103. DELTREAS: LDA #SCRENBOT+1
  1104. STA VPTBL,X
  1105. JSR OBJDEL
  1106. JSR RETASLOT
  1107. RTS
  1108. ; START THE GLOW ANIMATION FOR A HIEROGLYPH
  1109. GLOHIERO: STX TEMP1 ; REMEMBER WHERE IT IS
  1110. STA TEMP0 ; REMEMBER WHAT IT IS
  1111. LDX HIEROSLT ; SEE IF ONE IS STILL ANIMATING
  1112. BMI NOPROB
  1113. JSR DHDONE ; REMOVE OLD ONE
  1114. NOPROB: LDX TEMP1 ; SLOT NUMBER
  1115. STX HIEROSLT
  1116. LDA #0
  1117. STA COLSTAT,X ; DISABLE FURTHER COLISIONS
  1118. LDA #$FE ; TWO BYTES, FIRE PALETTE
  1119. STA TEMP6 ; INCREASE ITS PRIORITY ABOVE THAT
  1120. STA TEMP10 ; OF SHADOWS
  1121. JSR OBJMOV
  1122. LDA #30
  1123. STA XTBL,X ; SET ANIMATION TIMER
  1124. RTS
  1125. ; CODE TO ANIMATE A HIERO
  1126. DOHIEROS: LDX HIEROSLT
  1127. BMI DHNONE ; NO HIERO BEING ANIMATED
  1128. LDA VPTBL,X
  1129. CMP #SCRENBOT+1
  1130. BEQ DHGONE ; IT SCROLLED OFF THE SCREEN
  1131. DEC XTBL,X
  1132. BEQ DHDONE ; THE ANIMATION IS DONE
  1133. LDA PWTBL,X
  1134. CLC
  1135. ADC #$20
  1136. STA PWTBL,X
  1137. DHNONE: RTS
  1138. DHDONE: LDA #SCRENBOT+1
  1139. STA VPTBL,X
  1140. JSR OBJDEL
  1141. JSR RETASLOT
  1142. DHGONE: LDA #$FF
  1143. STA HIEROSLT ; MARK THAT ITS GONE
  1144. RTS
  1145. ; END