DEATH.S 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812
  1. *** DEATH.S ***
  2. * DVP 4/26/84 ALL PAUSE MODE CODE NOW LOCALIZED IN CHKSTRT
  3. * DVP 8/12 CHECK FOR START AND END OF GAME, COLLISIONS WITH SHOOTER,
  4. * AND HANDLE FIRING AND EXPLOSIONS
  5. STRTMEN EQU 3 ;HOW MANY MEN DO WE START GAME WITH?
  6. STRTDUAL EQU 6 ;START DUAL GAME WITH 2 ON SCREEN, 4
  7. ; EXTRA
  8. TEAMMEN EQU 17 ;LEFTMOST MAN LOCATION IN TEAM MAN POOL
  9. CHKSTRT JSR STICKIT0 ;DO TRACKBALL CRAP
  10. LDA FRMCNT ;DISPLAY OF THE SCORE IS DISABLED
  11. BNE CHKSTRT1 ; WHEN SCRTIMER IS NEGATIVE
  12. LDA ATTRACT ; THIS CHUNK INCREMENTS THE VALUE
  13. BEQ CHKSTRT1 ; DURING ATTRACT MODE; LATER IN THIS
  14. LDX SCRTIMER ; ROUTINE, ANY INPUT SETS SCRTIMER
  15. BMI CHKSTRT1 ; BACK TO 0
  16. INC SCRTIMER
  17. CHKSTRT1 LDA PANEL ;TEST RESET SWITCH
  18. LSR A
  19. BCS RSTDBNC
  20. STA DEBOUNC1
  21. RTS
  22. RSTDBNC LDA #$FF
  23. EOR DEBOUNC1
  24. BPL SKPGMRST
  25. STA DEBOUNC1 DEBOUNC1 SHOULD BE NEGATIVE ON LEAVING
  26. JMP GMRESET
  27. SKPGMRST LDA ATTRACT ;NO RESET -- IN GAME SELECT?
  28. BPL NOOPTSET
  29. JMP SETGMOPT
  30. * GAME PLAY OR ATTRACT
  31. NOOPTSET
  32. LDA PANEL ;TEST GAME SELECT SWITCH DURING GAME
  33. AND #$02
  34. BNE THATSALL ;BRANCH IF SWITCH NOT PRESSED
  35. JMP GOINTOTP
  36. THATSALL LDA ATTRACT
  37. BEQ PAUSEME
  38. JMP SKPNORST
  39. * GAME PLAY
  40. * PAUSE HANDLING
  41. PAUSEME
  42. LDA PANEL
  43. LDX PAUSETMR CURRENTLY PAUSED?
  44. BNE PAUSED YES
  45. *********** NOT CURRENTLY PAUSED
  46. AND #$08 IS BUTTON PRESSED?
  47. BEQ STRTPAUS
  48. RTS NO
  49. STRTPAUS LDX #1 THIS DISABLES TUNER FROM RUNNING
  50. STX PAUSETMR
  51. DEX
  52. STX AUDV0 YES, START PAUSE
  53. STX AUDV1
  54. WAITPSE LDA PANEL AND WAIT FOR BUTTON TO BE RELEASED
  55. AND #$08 (PANEL IS UPDATED AT 60 HZ.)
  56. BEQ WAITPSE
  57. STAYPSD LDA PANEL INTERNAL PAUSE LOOP CHECK OF RESET
  58. LSR A BUTTON
  59. BCS NOOPTSET NOT PRESSED
  60. WAITRST LDA PANEL PRESSED, WAIT FOR RELEASE
  61. LSR A
  62. BCC WAITRST
  63. JMP GMRESET
  64. *********** CURRENTLY PAUSED WITH DMA STILL ON
  65. PAUSED AND #$08 IS BUTTON PRESSED?
  66. BEQ ENDPAUSE YES, ENDPAUSE
  67. JSR ONSCREEN
  68. JSR OFFSCRN
  69. INC PAUSETMR+1 NO, INCREMENT TIME. EVERY FRAME
  70. BNE STAYPSD
  71. INC PAUSETMR EVERY 256 FRAMES
  72. LDA PAUSETMR
  73. CMP #$FF
  74. BNE STAYPSD
  75. *********** 18 MINUTE TIMEOUT
  76. LDX #$7F TURN DMA OFF
  77. STX CTRL
  78. LDA #L(MORPHO) TOP OF SCREEN VECTOR
  79. STA VECTORI
  80. LDA #H(MORPHO)
  81. STA VECTORI+1
  82. BLANKLP JSR ONSCREEN
  83. JSR OFFSCRN SINCE DMA IS OFF ...
  84. JSR TRACKIT FOR COMING OUT OF PAUSE WITH TRACKBALL
  85. LDX #1 RESET PAUSE TIMER AND TURN SCREEN BACK
  86. JSR STICKIT ON IF WE SEE ANY ...
  87. CMP #$F0 JOYSTICK MOVEMENT
  88. BMI UNBLANK
  89. JSR STICKIT0
  90. CMP #$F0
  91. BMI UNBLANK
  92. LDA BUTNIB OR BUTTON PUSHES
  93. AND BUTNIB+1
  94. BPL UNBLANK
  95. LDA PANEL OR SELECT OR RESET PUSHES
  96. AND #$03
  97. CMP #$03
  98. BNE ENDBLANK
  99. LDA PANEL PAUSE BUTTON PRESSED?
  100. AND #$08
  101. BNE BLANKLP NO
  102. *********** RESTART GAME AFTER TIMEOUT
  103. ENDBLANK JSR TURNON TURN DMA ON
  104. ENDPAUSE LDA PANEL WAIT FOR BUTTON TO BE RELEASED
  105. AND #$08
  106. BEQ ENDPAUSE
  107. LDA PANEL DID RESET BRING US OUT OF BLANK?
  108. LSR A
  109. BCS RESUME NO
  110. WAITRST2 LDA PANEL RESET PRESSED, WAIT FOR RELEASE
  111. LSR A DON'T TURN PAUSE OFF YET SO SOUND
  112. BCC WAITRST2 STAYS OFF
  113. JMP GMRESET
  114. RESUME LDA #0 TURN PAUSE OFF, RESUME GAME PLAY
  115. STA PAUSETMR
  116. RTS
  117. *********** RESTART PAUSE AFTER SELECT OR RESET WHEN SCREEN BLANK
  118. UNBLANK LDA #1
  119. STA PAUSETMR
  120. JSR TURNON
  121. JMP STAYPSD
  122. *********** RESTART DISPLAY
  123. TURNON JSR ONSCREEN TURN DMA ON
  124. JSR OFFSCRN
  125. LDX #$43
  126. STX CTRL
  127. RTS
  128. * ATTRACT MODE
  129. SKPNORST
  130. LDA SCHTICK ;CHECK JOYSTICK DURING ATTRACT GAME
  131. ORA #$0F ; PLAY; ANY MOVEMENT GOES INTO
  132. EOR #$FF ; TITLE PAGE TO START GAME SELECT
  133. BEQ SWTCHCLR
  134. LDA #1
  135. STA DEBOUNC2
  136. SKMNPGJP JMP SKPMENPG ;ALWAYS
  137. SWTCHCLR LDA DEBOUNC2
  138. BEQ SKMNPGJP
  139. GOINTOTP LDA #60
  140. STA OPTCNT2
  141. LDA #0
  142. STA DEBOUNC2
  143. ;;;;; LDA #0
  144. STA SCRTIMER
  145. JSR SCOREDL ;DISPLAY SCORES AGAIN IN TITLE PAGE
  146. LDA #$80
  147. STA ATTRACT
  148. JMP INITATGM
  149. * TITLE PAGE
  150. SETGMOPT LDA PANEL ;CHECK GAME SELECT SWITCH IN TITLE PAGE
  151. AND #$02
  152. BEQ SELECTIT
  153. LDA #$00 ;SET NEXT CHANGE TO HAPPEN WHEN SWITCH
  154. STA OPTCNT2 ; PRESSED
  155. BEQ NOGMSEL ;ALWAYS
  156. SELECTIT LDA #0 ;SWITCH WAS PRESSED
  157. STA SCRTIMER ; DISPLAY SCORES AGAIN IN TITLE PAGE
  158. JSR SCOREDL
  159. DEC OPTCNT2 ;DELAY BETWEEN CHANGES WHILE SWITCH
  160. BPL NOGMSEL ; DOWN
  161. LDA #45
  162. STA OPTCNT2
  163. JSR NXTGMOPT ;SWITCH PRESSED, GO TO NEXT OPTION
  164. JMP UPDATDSP
  165. NOGMSEL LDA SCHTICK ;CHECK FOR JOYSTICK MOVEMENT DURING
  166. STA GTEMP1 ; TITLE PAGE GAME SELECT
  167. ORA #$0F
  168. EOR #$FF
  169. BNE SKPOPCTZ
  170. LDA #0 ;NO INPUT
  171. STA OPTCNT1
  172. GOSKPMN JMP LVMENUPG ;ALWAYS
  173. SKPOPCTZ LDA #0
  174. STA SCRTIMER
  175. JSR SCOREDL ;DISPLAY SCORE AGAIN IN TITLE PAGE
  176. DEC OPTCNT1 ;WHAT IS OPTCNT1, 2?
  177. BPL GOSKPMN
  178. LDA #30
  179. STA OPTCNT1
  180. LDA GTEMP1
  181. BMI NOATEAST
  182. LDA DIFLEVEL
  183. CMP #3
  184. BEQ UPDATDSP
  185. INC DIFLEVEL ;INCREASE DIFFICULTY
  186. BNE UPDATDSP ;ALWAYS
  187. NOATEAST ASL A
  188. BMI CHKPLYNM
  189. DFWEST LDA DIFLEVEL
  190. BEQ UPDATDSP
  191. DEC DIFLEVEL ;DECREASE DIFFICULTY
  192. BPL UPDATDSP ;ALWAYS
  193. CHKPLYNM ;LDA GTEMP1
  194. ;ASL A
  195. ASL A
  196. BMI NOATSTH
  197. LDA GAMETYPE
  198. AND ALTCTRLS
  199. CMP #1
  200. BNE ALTTP2
  201. LDA #0
  202. STA ALTCTRLS
  203. BEQ UPDATDSP
  204. ALTTP2 LDA GAMETYPE
  205. CMP #2
  206. BNE INCGMTP2
  207. LDA TRACKF
  208. BEQ INCGMTP2
  209. LDA TRACKF+1
  210. BNE INCGMTP2 ;TWO TRACKBALLS
  211. NXTGMTP2 LDA #1 ;SHARE THE TRACKBALL
  212. STA ALTCTRLS
  213. INCGMTP2 LDA GAMETYPE
  214. BEQ UPDATDSP
  215. DEC GAMETYPE ;DECREASE GAMETYPE
  216. BPL UPDATDSP
  217. NOATSTH ASL A
  218. BMI UPDATDSP
  219. JSR INCALT
  220. BNE UPDATDSP
  221. LDA GAMETYPE
  222. CMP #3
  223. BEQ UPDATDSP
  224. INC GAMETYPE ;INCREASE GAMETYPE
  225. UPDATDSP
  226. LDA #0
  227. LDX #2
  228. ZSCRLP STA SCORE0,X
  229. STA SCORE1,X
  230. STA SCORE2,X
  231. DEX
  232. BPL ZSCRLP
  233. LDX #0
  234. JSR CLRMAPZN
  235. LDA #1 ;WHEN AN INPUT HAS BEEN RECEIVED, KEEP
  236. STA LETTRNUM ; TITLE PAGE UP THERE LONGER
  237. LVMENUPG JSR DSPLYOPT
  238. SKPMENPG LDA SHOTTIMR ;CHECK FOR BUTTON RESTART
  239. BEQ CHKBTTN
  240. DEC SHOTTIMR
  241. BNE NORESET
  242. CHKBTTN LDA BUTNIB ;GAME START WHEN BUTTON COMES UP
  243. BMI BTNUP
  244. STA DEBOUNCE ;INPT4 LOW (BTN. DOWN), SET DEBOUNCE LO
  245. NORESET RTS
  246. BTNUP EOR DEBOUNCE
  247. BPL NORESET
  248. STA DEBOUNCE ;INPT4 HIGH (BTN. UP), DEBOUNCE LOW
  249. ; =START, DEBOUNCE HIGH
  250. ******************************************
  251. * RESET -- START A NEW GAME
  252. ******************************************
  253. GMRESET LDA #$00 ;TURN ON GAME AND INITIALIZE
  254. STA SCRTIMER
  255. STA ATTRACT
  256. JSR INITGAME
  257. LDX #STRTMEN-1 ;SET THE NUMBER OF MEN LEFT IN GAME
  258. STX MENLEFT ; AND DISPLAY IT
  259. LDY GAMETYPE
  260. BEQ ZINITLV1 ;ONE PLAYER GAME
  261. DEY
  262. BEQ ZINITLVX ;TWO PLAYER ALTERNATING
  263. DEY
  264. BEQ ZINITLV2 ;TWO PLAYER SIMULTANEOUS
  265. LDX #STRTDUAL-2 ;TEAM PLAY -- MEN LEFT POOL
  266. STX MENLEFT
  267. LDA #L(ELF320)
  268. INITLVB STA MUSHMAP+TEAMMEN-1,X
  269. DEX
  270. BNE INITLVB
  271. RTS
  272. ZINITLVX INX
  273. ZINITLV2 STX MENLEFT+1
  274. LDY #5
  275. LDA #L(ELF320)
  276. INITLV2 STA MUSHMAP+ZONELEN-12,Y
  277. DEY
  278. DEX
  279. BNE INITLV2
  280. ZINITLV1 LDX MENLEFT
  281. LDA #L(ELF320)
  282. INITLV1 STA MUSHMAP+6-1,X
  283. DEX
  284. BNE INITLV1
  285. RTS
  286. ******************************************
  287. *** CHANGE GAME OPTIONS
  288. ******************************************
  289. NXTGMOPT
  290. INC DIFLEVEL
  291. LDA DIFLEVEL
  292. CMP #4
  293. BNE NOGMEND
  294. LDX #0
  295. STX DIFLEVEL
  296. JSR INCALT
  297. BNE NOGMEND
  298. INCGMTP INC GAMETYPE
  299. LDA GAMETYPE
  300. CMP #4
  301. BNE NOGMEND
  302. WRAPGMTP STX GAMETYPE
  303. NOGMEND RTS
  304. INCALT LDA GAMETYPE
  305. CMP #1
  306. BNE NEXTGMTP
  307. LDA ALTCTRLS
  308. BNE NEXTGMTP
  309. LDA TRACKF
  310. BEQ NEXTGMTP
  311. LDA TRACKF+1
  312. BNE NEXTGMTP ;TWO TRACKBALLS
  313. LDA #1
  314. STA ALTCTRLS ;SHARE THE TRACKBALL
  315. BNE INCALTND
  316. NEXTGMTP LDA #0
  317. STA ALTCTRLS
  318. INCALTND RTS
  319. ********************************************************************************
  320. * CHKEND *
  321. * CHECK FOR THE END OF A GAME AND THE END OF EACH PLAYER'S TURN *
  322. ********************************************************************************
  323. CHKEND LDA SHTRTIMR
  324. BEQ NOGMEND
  325. * CHECK TO MAKE SURE MUSHROOM RESTORATION HAS FINISHED BEFORE PROCEEDING
  326. BIT FLAGS
  327. BVS NOGMEND
  328. SEC
  329. SBC #1
  330. STA SHTRTIMR
  331. AND #$7F
  332. BNE NOGMEND
  333. LDA GAMETYPE
  334. CMP #2
  335. BCC CHKEND1 ;NOT A DUAL PLAYER MODE
  336. LDX #0
  337. STX PLAYER
  338. ;;;;; LDA GAMETYPE
  339. CMP #3
  340. BEQ CHKEND1
  341. LDA MENLEFT ;IS THERE A MESSAGE UP?
  342. AND #$C0
  343. BNE CHKEND1
  344. LDA MENLEFT+1
  345. AND #$C0
  346. BNE CHKEND2
  347. LDA SHTRSTAT ;ONLY CHECK SHOOTER WITH POSITIVE
  348. BEQ CHKEND1 ; STATUS (HAS BEEN BLOWN AWAY)
  349. CHKEND2 INC PLAYER
  350. CHKEND1 BIT ATTRACT
  351. BMI NOGMEND
  352. BVC SKPGMATR
  353. ******************************************
  354. * ATTRACT MODE GAME OVER?
  355. ******************************************
  356. LDA ATGMTMR
  357. AND #$7F
  358. CMP #20
  359. BCC ZGAME
  360. JMP GAMEDONE
  361. ZGAME LDA #-1
  362. STA ATTSHTRY
  363. STA ATTSHTRY+1
  364. JMP INATGAME
  365. ******************************************
  366. * "PLAYER X" MESSAGE DISPLAYED LONG ENOUGH, START PLAYING AGAIN
  367. ******************************************
  368. OTHERPLR ;GET RID OF "PLAYER x " MESSAGE AT
  369. LDA MENLEFT,X ; START OF A PLAYER'S TURN
  370. AND #$07
  371. STA MENLEFT,X
  372. LDA #0
  373. STA SHTRTIMR
  374. ERSPLR LDY #8
  375. ERASEPLR LDA MSGSTORE+9,Y
  376. STA MUSHMAP+13*ZONELEN+11,Y
  377. DEY
  378. BPL ERASEPLR
  379. RTS
  380. ******************************************
  381. * SOMEBODY DIED RECENTLY, DO SOMETHING ABOUT IT
  382. ******************************************
  383. SKPGMATR
  384. LDX PLAYER
  385. LDA MENLEFT,X
  386. BEQ OUTOFGM ;SOMEBODY'S GAME JUST ENDED
  387. BPL ZCONTGM
  388. JMP ZMSGOVER ;"GAME OVER" MESSAGE DONE DISPLAYING
  389. ZCONTGM AND #$40
  390. BNE OTHERPLR ;"PLAYER X" MESSAGE DONE, RESUME PLAY
  391. JMPINGM JMP INGAME ;GAME STILL IN PROGRESS
  392. ******************************************
  393. * SOMEBODY'S GAME JUST ENDED, DISPLAY
  394. * "GAME OVER , PLAYER X" MESSAGE
  395. ******************************************
  396. OUTOFGM LDA GAMETYPE
  397. CMP #3
  398. BNE GAMEOUT
  399. LDA SHTRSTAT ;A TEAM PLAY GAME DOESN'T END UNTIL
  400. ORA SHTRSTAT+1 ; BOTH PLAYERS HAVE DIED
  401. BPL GAMEOUT
  402. LDA #$40
  403. LDY SHTRSTAT
  404. BMI NOTDEAD1
  405. STA SHTRSTAT
  406. BPL DEAD1 ;ALWAYS
  407. NOTDEAD1 STA SHTRSTAT+1
  408. DEAD1 LDA FLAGS
  409. ORA #$80
  410. STA FLAGS
  411. JMP INATGAME
  412. GAMEOUT LDY #8 ;DISPLAY "GAME OVER"
  413. ZDSPGOVR LDA MUSHMAP+12*ZONELEN+11,Y
  414. STA MSGSTORE,Y
  415. LDA MGMOVER,Y
  416. STA MUSHMAP+12*ZONELEN+11,Y
  417. DEY
  418. BPL ZDSPGOVR
  419. LDY GAMETYPE ;IN ONE PLAYER OR TEAM PLAY GAMES,
  420. DEY ; DON'T CARE WHICH PLAYER
  421. CPY #2
  422. BCS STMSGTMR
  423. * ALTERNATING OR COMPETITION GAME
  424. LDA SHTRTIMR ;DID BOTH PLAYERS LOSE A LIFE?
  425. BPL COMPCHK ;NO
  426. LDA MENLEFT ;DID BOTH PLAYERS GAMES END?
  427. ORA MENLEFT+1
  428. BEQ STBTHVR ;YES
  429. LDA MENLEFT ;IF OTHER PLAYER GOT BROUGHT BACK TO
  430. AND MENLEFT+1 ; LIFE BY MY MUSHROOM RESTORATION,
  431. BEQ COMPCHK ; CLEAR THE FLAG
  432. LDA FLAGS
  433. AND #$7F
  434. STA FLAGS
  435. COMPCHK DEY ;AFTER THIS, Y=#$FF=ALT, Y=0=COMP
  436. BNE PLRXOVER ;ALTERNATING
  437. BIT FLAGS ;IS OTHER PLAYER ALSO DEAD?
  438. BMI WHOWINS ;YES
  439. ;;;;; LDX PLAYER ;IS SCORE OF PLAYER WHO DIED HIGHER
  440. JSR CMPSCORE ; THAN OR SAME AS PLAYER WHO LIVED?
  441. BCS PLRXOVER ;YES--KEEP PLAYING
  442. LDA FLAGS ;NO, OTHER PLAYER WON AND GAME IS OVER
  443. ORA #$80
  444. STA FLAGS
  445. BCC OTHRWINS
  446. * DISPLAY "PLAYER X"
  447. PLRXOVER JSR SHOWPLR1 ;"PLAYER 1" MESSAGE
  448. LDX PLAYER ;GET CORRECT PLAYER NUMBER
  449. TXA
  450. CLC
  451. ADC #L(DGT1)
  452. STA MUSHMAP+13*ZONELEN+19 ;PUT CORRECT PLAYER NUMBER UP
  453. JMP STMSGTMR
  454. * SET BOTH-GAMES-OVER FLAG
  455. STBTHVR LDA FLAGS ;BOTH DIED, SET FLAG TO SHOW OTHER
  456. ORA #$80 ; PLAYER'S GAME HAS ENDED
  457. STA FLAGS
  458. * DECIDE WHICH PLAYER WON
  459. WHOWINS
  460. ;;;;; LDX PLAYER
  461. JSR CMPSCORE
  462. BCC OTHRWINS ;OTHER PLAYER DEFINITELY WON
  463. TYA
  464. TAX ;SWITCH PLAYERS
  465. JSR CMPSCORE
  466. BCS GAMETIED
  467. ;SWITCH BACK
  468. OTHRWINS TYA
  469. TAX
  470. * DISPLAY "PLAYER X WINS"
  471. PLRXWINS LDY #12 ;PUT UP "PLAYER 1WINS"
  472. ZDSPWINR LDA MPLAYER,Y
  473. STA MUSHMAP+14*ZONELEN+9,Y
  474. DEY
  475. BPL ZDSPWINR
  476. TXA
  477. CLC
  478. ADC #L(DGT1)
  479. STA MUSHMAP+14*ZONELEN+16 ;PUT CORRECT PLAYER NUMBER UP
  480. LDA #L(EMPTY)
  481. STA MUSHMAP+14*ZONELEN+17
  482. * SET TIMER FOR MESSAGE
  483. STMSGTMR DEC MENLEFT,X ;SET MENLEFT,X = #$FF AS "GAME OVER"
  484. ; DISPLAY FLAG
  485. LDA SHTRTIMR
  486. ORA #$7F ;SET TIMER TO LEAVE GAME OVER MESSAGE
  487. STA SHTRTIMR ; UP
  488. RTS
  489. GAMETIED LDY #12 ;PUT UP "YOU HAVE TIED"
  490. ZDSPTIE LDA MTIE,Y
  491. STA MUSHMAP+14*ZONELEN+9,Y
  492. DEY
  493. BPL ZDSPTIE
  494. BMI STMSGTMR
  495. ******************************************
  496. * "GAME OVER" MESSAGE DISPLAYED LONG ENOUGH
  497. ******************************************
  498. ZMSGOVER LDA GAMETYPE
  499. BEQ DONEHSCR ;ALWAYS HIGH SCORE IN ONE PLAYER
  500. CMP #3
  501. BEQ GMEDONE ;NEVER HIGH SCORE AT TOP IN TEAM PLAY
  502. LDA FLAGS ;IN TWO PLAYER MODES, WE'RE STILL IN
  503. BPL NOTGMVR ; GAME IF OTHER PLAYER HADN'T ALREADY
  504. ; DIED
  505. ******************************************
  506. * ALL GAMES HAVE ENDED -- DO SOMETHING ABOUT IT
  507. ******************************************
  508. DONEHSCR JSR CHKHSCR ;CHECK HIGH SCORE AT TOP OF DISPLAY
  509. GMEDONE LDX #0
  510. LDA GAMETYPE ;TEAM PLAY?
  511. BEQ TMHSC0
  512. CMP #3
  513. BNE NOTMHSC
  514. JSR CMPSCORE ;YES--IS PLAYER 1'S SCORE HIGHER?
  515. BCS TMHSC0 ; YES
  516. BCC TMHSC1 ; NO--USE PLAYER 2
  517. NOTMHSC JSR HSCNTR1
  518. TMHSC1 LDX #1
  519. TMHSC0 JSR HSCNTR1
  520. GAMEDONE LDA #$80
  521. STA ATTRACT
  522. JMP INITATGM ;INITIALIZE GAME ATTRACT MODE
  523. ******************************************
  524. * RESTART THE OTHER PLAYER IN A TWO PLAYER ALTERNATING OR SIMULTANEOUS GAME
  525. * AFTER OTHER PLAYER'S GAME JUST ENDED
  526. ******************************************
  527. NOTGMVR ORA #$80
  528. STA FLAGS ;SET THAT FLAG
  529. LDA #0 ;DELETE "GAME OVER" DISPLAY FLAG
  530. STA MENLEFT,X
  531. LDA #$40 ;INDICATE THAT THIS PLAYER'S GAME IS
  532. STA SHTRSTAT,X ; OVER
  533. LDA GAMETYPE
  534. CMP #2
  535. BNE ALTGM ;BRANCH IF ALTERNATING GAME
  536. LDY #8 ;IN SIMULTANEOUS GAME, MUST ERASE
  537. ZERSGOVR LDA MSGSTORE,Y ; "GAME OVER" FROM MUSHROOM FIELD
  538. STA MUSHMAP+12*ZONELEN+11,Y
  539. DEY
  540. BPL ZERSGOVR
  541. BMI SIMULTGM ;"PLAYER X" MESSAGE STAYS UP AS READY
  542. ; MESSAGE
  543. ******************************************
  544. * ENTRY POINT FOR RESTARTING GAMES AFTER LOSING A LIFE, NOT A GAME
  545. ******************************************
  546. INGAME LDA GAMETYPE
  547. CMP #1
  548. BNE INGAME1P
  549. * TWO PLAYER ALTERNATING GAME, SWITCH PLAYERS IF BOTH ALIVE
  550. LDA FLAGS
  551. BMI INGAME1P ;BRANCH IF ONLY ONE ALIVE
  552. ALTGM JSR SWAP
  553. JSR SHOWPLR1 ;DISPLAY "PLAYER 1"
  554. SIMULTGM LDA #1
  555. STA COLORFLG
  556. EOR PLAYER
  557. TAX
  558. STX PLAYER
  559. CLC
  560. ADC #L(DGT1)
  561. STA MUSHMAP+13*ZONELEN+19 ;PUT CORRECT PLAYER NUMBER UP
  562. LDA MENLEFT,X ;SET "PLAYER X" MESSAGE FLAG
  563. ORA #$40
  564. STA MENLEFT,X
  565. LDA SHTRTIMR
  566. ORA #$7F ;TIME TO LEAVE IT UP
  567. STA SHTRTIMR
  568. BMI KILL1 ;HANDLES CASE OF BOTH PLAYERS DYING
  569. ; OTHER PLAYER LOST GAME, THIS ONE
  570. ; DIDN'T
  571. LDA GAMETYPE ;AT THIS POINT IN SIMULT. GAME, OTHER
  572. CMP #2 ; PLAYER'S GAME JUST ENDED AND THIS
  573. BEQ INATGAME ; PLAYER SHOULDN'T LOSE A LIFE
  574. ******************************************
  575. * REMOVE AN EXTRA MAN TO BE USED AS CURRENT MAN
  576. ******************************************
  577. INGAME1P
  578. LDA SHTRTIMR ;SHTRTIMR IS NEGATIVE IF BOTH PLAYERS
  579. BPL KILL1 ; DIED IN SAME FRAME
  580. * BOTH PLAYERS LOST A LIFE
  581. LDA GAMETYPE ;TEAM PLAY?
  582. CMP #3
  583. BNE KILL2 ;NO
  584. LDA MENLEFT
  585. BNE STILLTM
  586. JMP GAMEOUT ;LOST TWO LIVES, ENDING THE GAME
  587. STILLTM
  588. ;;;;; LDX #0 ;YES
  589. JSR TAKEMAN
  590. DEC MENLEFT ;IN GAME 3 PLAYER ALWAYS IS 0
  591. BNE KILL1
  592. * AT THIS POINT IN TEAM PLAY GAME, ONLY ONE PLAYER CONTINUES -- DECIDE WHICH
  593. LDX #1
  594. JSR CMPSCORE
  595. LDA #$40 ;PLAYER 2 CONTINUES
  596. LDY #$80
  597. BCS GOPLR2
  598. TAY ;PLAYER 1 CONTINUES
  599. ASL A
  600. GOPLR2 STA SHTRSTAT
  601. STY SHTRSTAT+1
  602. LDA FLAGS
  603. ORA #$80
  604. STA FLAGS
  605. BNE INATGAME
  606. KILL2 LDX #1 ;DUAL PLAYER COMPETITION, BOTH PLAYERS
  607. STX PLAYER ; LOST A LIFE. WE KNOW PLAYER 1'S
  608. LDA MENLEFT+1 ; GAME ISN'T OVER, HOW ABOUT PLAYER
  609. BNE DOKILL2 ; 2'S?
  610. JMP OUTOFGM
  611. DOKILL2 JSR TAKEMAN
  612. DEC MENLEFT+1
  613. LDX #0
  614. STX PLAYER
  615. KILL1 ; LDX PLAYER
  616. JSR TAKEMAN
  617. DEC MENLEFT,X ;DEDUCT A LIFE
  618. ******************************************
  619. * INITIALIZE TO START PLAYING AGAIN
  620. ******************************************
  621. INATGAME LDA #$00
  622. ;;;;; STA SHOTSTAT ;THIS IS ALWAYS SET TO $80 LATER
  623. STA SHOTSTAT+1
  624. LDA SHTRTIMR
  625. AND #$7F
  626. STA SHTRTIMR
  627. JSR MAKCENTI
  628. LDA #$00
  629. STA FLEASTAT
  630. STA SPDRSTAT
  631. LDX DIFLEVEL
  632. LDA SPDRWTDF,X
  633. STA SPDRTIMR
  634. * PUT THE SHOOTERS BACK TOGETHER
  635. INITPLRS LDA #CNTRCLMN ;CALLED AS SUBROUTINE FROM CMAIN
  636. STA SHOOTERX
  637. STA SHOOTERX+1
  638. LDA #CNTRCLMN+2
  639. STA SHOTX
  640. STA SHOTX+1
  641. LDY #184
  642. STY SHOOTERY
  643. STY SHOOTERY+1
  644. DEY
  645. STY SHOTY
  646. STY SHOTY+1
  647. LDA #L(ELF)
  648. STA SHTROFST
  649. LDA #L(ELFB)
  650. STA SHTROFST+1
  651. JSR SHTRCLRS
  652. LDA GAMETYPE
  653. CMP #2
  654. BCC SNGLSHIT ;GAMES 0 OR 1 -- NOT DUAL PLAY
  655. BEQ CHKFLAGS
  656. LDX #1 ;TEAM PLAY
  657. LDA SHTRSTAT+1
  658. BMI SHTEMUP
  659. LDX #0
  660. SHTEMUP STX PLAYER
  661. CHKFLAGS LDA FLAGS ;IS EITHER PLAYER DEAD?
  662. BPL DUALSHIT ;NO
  663. SNGLSHIT LDX PLAYER
  664. LDA #$80
  665. STA SHTRSTAT,X
  666. STA SHOTSTAT,X
  667. TXA
  668. EOR #$01
  669. TAX
  670. LDA #$40
  671. STA SHTRSTAT,X
  672. LDA #$00
  673. STA SHOTSTAT,X
  674. RTS
  675. DUALSHIT LDA #$80
  676. STA SHTRSTAT
  677. STA SHTRSTAT+1
  678. STA SHOTSTAT
  679. STA SHOTSTAT+1
  680. LDA #CNTRCLMN-8
  681. STA SHOOTERX
  682. LDA #CNTRCLMN-8+2
  683. STA SHOTX
  684. LDA #CNTRCLMN+8
  685. STA SHOOTERX+1
  686. LDA #CNTRCLMN+8+2
  687. STA SHOTX+1
  688. RTS
  689. SHTRCLRS LDA #$18 ;SHOOTER1
  690. STA P0C1
  691. STA P0C2
  692. LDA #$6E
  693. STA P0C3
  694. LDA #$97 ;SHOOTER2
  695. STA P1C1
  696. STA P1C2
  697. LDA #$0F
  698. STA P1C3
  699. RTS
  700. ******************************************
  701. SHOWPLR1 LDY #8 ;PUT UP "PLAYER 1 " OR "PLAYER 2 "
  702. ZDSPPLR1 LDA MUSHMAP+13*ZONELEN+11,Y ;MESSAGE AT THE START OF A
  703. STA MSGSTORE+9,Y ;PLAYER'S TURN, AND GET RID OF IT
  704. LDA MPLAYER,Y ;WITH OTHERPLR CODE ABOVE
  705. STA MUSHMAP+13*ZONELEN+11,Y
  706. DEY
  707. BPL ZDSPPLR1
  708. RTS
  709. ******************************************
  710. * REMOVE A MAN FROM EXTRA MAN POOL
  711. ******************************************
  712. TAKEMAN LDX PLAYER
  713. LDA MENLEFT,X
  714. AND #$07
  715. CPX #0
  716. BEQ SUBLIFE1
  717. SUBLIFE2 EOR #$FF
  718. CLC
  719. ADC #21
  720. SUBLIFE1 LDY GAMETYPE
  721. CPY #3
  722. BNE SUB1
  723. SUBTEAM CLC
  724. ADC #TEAMMEN-6
  725. SUB1 TAY
  726. LDA #L(EMPTY)
  727. STA MUSHMAP+6-1,Y
  728. RTS
  729. ******************************************
  730. * COMPARE THE TWO PLAYER'S SCORES
  731. ******************************************
  732. CMPSCORE TXA ;RETURNS CARRY SET IF PLAYER X'S SCORE
  733. EOR #$01 ; GREATER THAN OR EQUAL TO OTHER
  734. TAY ; PLAYER'S
  735. LDA SCORE0,X
  736. CMP SCORE0,Y
  737. LDA SCORE1,X
  738. SBC SCORE1,Y
  739. LDA SCORE2,X
  740. SBC SCORE2,Y
  741. LDA SCORE3,X
  742. SBC SCORE3,Y
  743. RTS
  744. ******************************************
  745. * CHECK HIGH SCORE, PUT INTO TOP ROW OF SCREEN
  746. ******************************************
  747. ;FIRST CHECK FOR THE PRESENSE OF HIGH SCORE CART
  748. CHKHSCR
  749. LDY DIFLEVEL ;HIGH SCORE IN DIFFERENT GAME VERSIONS?
  750. LDX GAMETYPE ;CHECK SCORES OF BOTH PLAYERS
  751. BEQ HSCORELP
  752. LDX #1
  753. HSCORELP LDA HSCORE0,Y
  754. CMP SCORE0,X
  755. LDA HSCORE1,Y
  756. SBC SCORE1,X
  757. LDA HSCORE2,Y
  758. SBC SCORE2,X
  759. BCS HSCNXTPL
  760. LDA SCORE0,X
  761. STA HSCORE0,Y
  762. LDA SCORE1,X
  763. STA HSCORE1,Y
  764. LDA SCORE2,X
  765. STA HSCORE2,Y
  766. HSCNXTPL DEX
  767. BPL HSCORELP
  768. RTS
  769. ************************************************
  770. * SWAP THE MUSHROOM MAPS FOR TWO PLAYER GAME
  771. ************************************************
  772. SWAP LDX #1 ;IGNORE ROW 0 (SCORE ROW)
  773. LDA #L(MUSHMAP+ZONELEN) ;INITIAL ROW, MUSHMAP
  774. STA GTEMP1
  775. LDA #H(MUSHMAP+ZONELEN)
  776. STA GTEMP2
  777. LDA #L(MAP2) ;INITIAL ROW, MAP2
  778. STA GTEMP3
  779. LDA #H(MAP2)
  780. STA GTEMP4
  781. SWTCHLP1 LDY #ZONELEN-1 ;LOOP THROUGH ROW
  782. SWTCHLP2 LDA (GTEMP1),Y ;READ OUT OF MUSHMAP, INTO A TEMP.
  783. STA GTEMP5
  784. LDA (GTEMP3),Y ;READ OUT OF MAP2, INTO MUSHMAP
  785. STA (GTEMP1),Y
  786. LDA GTEMP5 ;READ OUT OF TEMP., INTO MAP2
  787. STA (GTEMP3),Y
  788. DEY
  789. BPL SWTCHLP2
  790. INX ;NEXT ROW
  791. CPX #NZONES-1 ;THERE IS NO MAP FOR LAST ROW
  792. BEQ SWTCHOUT
  793. LDA GTEMP1
  794. CLC
  795. ADC #ZONELEN
  796. STA GTEMP1
  797. BCC NROWMAP2
  798. INC GTEMP2
  799. NROWMAP2 LDA GTEMP3
  800. CLC
  801. ADC #ZONELEN
  802. STA GTEMP3
  803. BCC SWTCHLP1
  804. INC GTEMP4
  805. BNE SWTCHLP1
  806. SWTCHOUT RTS
  807. ******************************************
  808. * COLLISION DETECTION ROUTINE FOR SHOOTER
  809. * CALLED BY THE INDIVIDUAL OBJECT MOVEMENT ROUTINES
  810. * X = OBJECT NUMBER
  811. ******************************************
  812. SHTRCOLL BIT ATTRACT
  813. BMI SWTCHOUT
  814. LDA GAMETYPE
  815. CMP #2
  816. BCC ZSHTRCOL
  817. LDA #0
  818. STA PLAYER
  819. LDA SHTRSTAT+1
  820. AND #$D0
  821. CMP #$80
  822. BNE ZSHTRCOL
  823. LDA SHTRSTAT
  824. AND #$D0
  825. CMP #$80
  826. BNE SHTRCOL2
  827. JSR ZSHTRCOL
  828. SHTRCOL2 INC PLAYER
  829. ZSHTRCOL LDY PLAYER
  830. LDA OBJX,X
  831. SEC
  832. SBC SHOOTERX,Y
  833. CPX #SPDROBJ
  834. CLC
  835. BNE NOTSPCLL
  836. ADC #SPDRWDTH-1 ;DO IF X=12
  837. CMP #SPDRWDTH+5-2
  838. BCC HITSHTRX
  839. RTS
  840. NOTSPCLL BPL FLEAPLXX ;BRANCH IF X=13
  841. ADC #SEGWDTH-1
  842. CMP #SEGWDTH+5-2
  843. BCS SHCLRTS
  844. BCC HITSHTRX
  845. * COLLISION RANGE FOR FLEA: -2 <= (OBJX-SHTRX) <= 3
  846. * SO ADD 2 AND COMPARE: 0 <= (OBJX-SHTRX) <= 5
  847. FLEAPLXX ADC #2 ;FLEAWDTH-3
  848. CMP #6 ;
  849. BCS SHCLRTS
  850. HITSHTRX
  851. LDA OBJY,X
  852. SEC
  853. SBC SHOOTERY,Y
  854. BPL NOTNEGC2
  855. EOR #$FF
  856. CLC
  857. ADC #$01
  858. NOTNEGC2 CMP #6
  859. BCS SHCLRTS
  860. HITPLAY LDA SHTRTIMR
  861. BEQ ONEDEAD
  862. LDA #$80
  863. ONEDEAD ORA #$30
  864. STA SHTRTIMR
  865. LDA #L(EXPLOS) ;DIFFERENT EXPLOSION?
  866. STA SHTROFST,Y
  867. * START PLAYER DEATH SOUND?
  868. JSR SCRAPALL
  869. LDA #3
  870. JSR TUNIN
  871. LDA #0
  872. STA SHOTSTAT,Y
  873. SHCLRTS RTS
  874. ******************************************
  875. *** SHOT.S ***
  876. ******************************************
  877. * DVP 7/29
  878. SHOOT BIT ATTRACT
  879. BMI SHCLRTS
  880. LDA GAMETYPE
  881. CMP #2
  882. BCC SHOOTZ
  883. LDA #0
  884. STA PLAYER
  885. BIT SHTRSTAT+1
  886. BVS SHOOTZ
  887. BIT SHTRSTAT
  888. BVS SHOOTHR
  889. LDA FRMCNT
  890. AND #$01
  891. STA PLAYER
  892. JSR SHOOTZ
  893. LDA PLAYER
  894. SHOOTHR EOR #$01
  895. STA PLAYER
  896. SHOOTZ LDA SHTRTIMR
  897. BNE SHOTOUT ;IF SHOOTER IS DEAD
  898. LDX PLAYER
  899. LDA SHOTSTAT,X
  900. LSR A
  901. BCS SHOTCOLL ;DID SHOT HIT ANYTHING?
  902. LDA SHTRSTAT,X ;IS THE SHOOTER RESING IN?
  903. AND #$90
  904. CMP #$90
  905. BNE RESIN2
  906. LDA FRMCNT
  907. AND #$0F
  908. ORA #$10
  909. CPX #1
  910. BNE RESIN1
  911. ORA #$80
  912. STA P1C2
  913. BNE RESIN2
  914. RESIN1 STA P0C2
  915. RESIN2 JMP CHKSHOT
  916. *CHECK FOR COLLISION OF SHOT AND OBJECT
  917. SHOTCOLL ;LDX PLAYER
  918. LDA SHOTX,X
  919. STA GTEMP1
  920. LDA SHOTY,X
  921. CLC ;IF THIS IS CHANGED, ALSO CHANGE WHERE
  922. ADC #2 ; MUSHCNT IS DECREMENTED BELOW
  923. JSR OBSTAC ;CHECK FOR MUSHROOM
  924. CMP #L(EMPTY+1)
  925. BCC NOMSHHIT
  926. CMP #L(POISONED+1)
  927. BCS NOMSHHIT
  928. ;;;;; CMP #L(FLOWER) ;FLOWER STOPS THE SHOT
  929. ;;;;; BEQ ENDSHOT
  930. TAX ;GET VALUE FOR MUSHROOM AFTER HIT
  931. LDA MUSHHIT-$41,X
  932. STA (GTEMP3),Y
  933. CMP #L(EMPTY)
  934. BNE ENDSHOT
  935. LDA #1 ;KILLED A MUSHROOM--ADD 1 TO SCORE
  936. ; LDY #0
  937. LDX PLAYER
  938. JSR ADDSCORE
  939. LDX PLAYER ;X WAS TRASHED BY ADDSCORE, MAYBE
  940. LDA SHOTY,X ;DECREMENT MUSHROOM COUNT, IF NECESSARY
  941. CLC
  942. ADC #2
  943. LSR A
  944. LSR A
  945. LSR A
  946. CMP #INFLDZN-1
  947. BCC ENDSHOT
  948. LDA GAMETYPE
  949. CMP #1
  950. BEQ ZDECMSH
  951. LDX #0 ;USE ONLY MUSHCNT, NOT MUSHCNT+1, IN
  952. ZDECMSH DEC MUSHCNT,X ; DUAL PLAYER GAMES
  953. ENDSHOT LDX PLAYER
  954. LDA #$80
  955. STA SHOTSTAT,X
  956. LDA SHOOTERX,X
  957. CLC
  958. ADC #2
  959. STA SHOTX,X
  960. LDA SHOOTERY,X
  961. SEC
  962. SBC #1
  963. STA SHOTY,X
  964. ;;;;; LDA #L(ELFWSHOT)
  965. ;;;;; STA SHTROFST,X
  966. SHOTOUT RTS
  967. ;USHHIT DB L(EMPTY),L(QDYING),L(HDYING)
  968. ; DB L(EMPTY),L(QLIVE),L(HLIVE),L(TLIVE)
  969. ; DB L(HGROWN),L(QGROWN),L(EMPTY),L(FLOWER)
  970. ; DB L(EMPTY),L(QPOIS),L(HPOIS),L(TPOIS)
  971. MUSHHIT DB L(ZERO),L(ZERO),L(ELF320)
  972. DB L(EMPTY),L(QLIVE),L(HLIVE),L(TLIVE)
  973. DB L(ZERO),L(ZERO),L(ZERO),L(ZERO)
  974. DB L(EMPTY),L(QPOIS),L(HPOIS),L(TPOIS)
  975. NOMSHHIT
  976. LDA PLAYER
  977. CLC
  978. EOR #$01
  979. ADC #14
  980. TAX
  981. SHOTOBJC LDA OBJSTAT,X
  982. BPL NXTOB ;NEXTOBJC
  983. LDA OBJOFFST,X
  984. CMP #L(POINT300)
  985. BCS NXTOB
  986. LDY PLAYER
  987. LDA SHOTY,Y ;SHOTY-OBJY
  988. SEC
  989. SBC OBJY,X
  990. BPL POSDIFF
  991. EOR #$FF
  992. CLC
  993. ADC #1
  994. POSDIFF CMP #8
  995. BCS NXTOB
  996. LDA SHOOTERY,Y ;CHECK TO MAKE SURE OBJECT IS ABOVE
  997. SEC ;SHOOTER
  998. SBC OBJY,X ;SHOOTERY-OBJY
  999. SBC #6
  1000. CMP #200
  1001. BCS NXTOB
  1002. LDA SHOTX,Y
  1003. SEC
  1004. SBC OBJX,X
  1005. CPX #13
  1006. BEQ FLSCSHOT
  1007. BCS JMPPLRHT
  1008. CPX #12
  1009. BCS NOTSEGSH
  1010. JMP SEGSHOT
  1011. NOTSEGSH CMP #SPDRWDTH
  1012. BCC SPDRPNTS
  1013. NXTOB JMP NEXTOBJC
  1014. JMPPLRHT CMP #FLEAWDTH
  1015. BCS NXTOB
  1016. LDA GAMETYPE
  1017. CMP #2
  1018. BNE NXTOB
  1019. TXA ;GET PLAYER NUMBER OF PLAYER WHO DIED
  1020. SEC
  1021. SBC #14
  1022. TAY
  1023. JMP HITPLAY
  1024. SPDRPNTS LDX PLAYER
  1025. LDY #0
  1026. LDA SHOOTERY,X
  1027. SEC
  1028. SBC SPDRY
  1029. CMP #40
  1030. BCS SPDREXPL
  1031. LDY #2
  1032. CMP #16
  1033. BCC SPDREXPL
  1034. LDY #1
  1035. SPDREXPL LDA POINTSPR,Y
  1036. STA SPDROFST
  1037. * CHANGE PALETTE FOR SPIDER POINTS TO THAT OF PLAYER WHO SHOT IT
  1038. LDA OBJPALWD+12
  1039. AND #$1F
  1040. LDX PLAYER
  1041. BEQ PNTSCLR
  1042. ORA #$20
  1043. PNTSCLR STA OBJPALWD+12
  1044. LDA FRMCNT
  1045. AND #$18
  1046. EOR #$80
  1047. STA SPDRSTAT
  1048. LDA #$10
  1049. STA SPDRTIMR
  1050. LDA #MINX
  1051. CMP SPDRX
  1052. BCS PNTSON
  1053. LDA #MAXX-SPDRWDTH-3
  1054. CMP SPDRX
  1055. BCS GOSPOUT
  1056. PNTSON STA SPDRX
  1057. GOSPOUT LDA MULT3SP,Y
  1058. TAY
  1059. LDA #1
  1060. JSR SCRAPONE
  1061. JMP SKER ;USED TO BE SHOTSCR
  1062. FLSCSHOT TAY
  1063. LDA FLEASTAT
  1064. AND #$40
  1065. BEQ SCRPSHOT
  1066. FLEASHOT CPY #FLEAWDTH
  1067. BCC HITFLEA
  1068. NXOB JMP NEXTOBJC
  1069. HITFLEA LDY #2
  1070. LDA DIFLEVEL
  1071. CMP #2
  1072. BCC ICPTYOG ;ONLY ONE SHOT KILLS FLEA IN EASY
  1073. LDA FLEASTAT
  1074. ORA #$03
  1075. CMP FLEASTAT
  1076. BEQ ICPTYOG
  1077. STA FLEASTAT
  1078. JMP ENDSHOT
  1079. ICPTYOG LDA #4
  1080. JMP SHOTSCR
  1081. SCRPSHOT CPY #SCRPWDTH
  1082. BCS NXOB
  1083. INC FLEAX ;ADJUST EXPLOSION POSITION
  1084. LDY #10
  1085. LDA #5 ;TURN OFF SCORPION SOUND
  1086. JMPSHTSC JMP SHOTSCR
  1087. SEGSHOT CMP #SEGWDTH
  1088. BCS NEXTOBJC
  1089. LDA OBJY,X
  1090. CMP #2
  1091. BCC NEXTOBJC
  1092. * WE HAVE HIT A SEGMENT
  1093. * MIDDLE OF A CHAIN? -- IF SO, MAKE NEXT SEG. NEW HEAD
  1094. CPX #11
  1095. BEQ KILLSEGM
  1096. LDA OBJOFFST+1,X
  1097. CMP #L(EXPLOS)
  1098. BCS KILLSEGM
  1099. LDA OBJSTAT+1,X
  1100. AND #$A0
  1101. CMP #$80
  1102. BNE KILLSEGM
  1103. LDA OBJSTAT+1,X
  1104. ORA #$20
  1105. STA OBJSTAT+1,X
  1106. LDA OBJOFFST+1,X
  1107. EOR #$30
  1108. STA OBJOFFST+1,X
  1109. * PUT MUSHROOM UP, KILL SEGM
  1110. KILLSEGM LDA OBJOFFST,X
  1111. AND #$04
  1112. EOR #$04
  1113. BNE SKIPFC
  1114. LDA #$FE
  1115. SKIPFC ORA #$02 ;X-2 OR X+6
  1116. CLC
  1117. ADC OBJX,X ;PUT UP A MUSHROOM IN SEGMENT'S PLACE
  1118. CMP #MINX
  1119. BCS SEGML
  1120. LDA #MINX
  1121. SEGML CMP #MAXX
  1122. BCC SEGMR
  1123. LDA #MAXX-1
  1124. SEGMR STA GTEMP1
  1125. LDA OBJY,X
  1126. JSR COBSTAC
  1127. BNE KILLIT
  1128. TXA
  1129. PHA
  1130. LDA OBJY,X
  1131. JSR CMUSHER
  1132. PLA
  1133. TAX
  1134. KILLIT LDA #L(EXPLOS)
  1135. STA OBJOFFST,X
  1136. DEC NUMSEG ;ONE LESS SEG. ON SCREEN
  1137. LDA #2
  1138. JSR TUNIN
  1139. * SCORE A CENTIPEDE SEGMENT
  1140. SEGSCORE LDY #$00 ;ADDING SCORE FOR CENTIPEDE SEGMENT
  1141. LDA OBJSTAT,X ;IF BODY SEGMENT -- ADD 10 POINTS
  1142. AND #$20
  1143. LSR A
  1144. EOR #$10
  1145. BNE BODYSCR
  1146. INY ;HEAD -- ADD 100 POINTS
  1147. BODYSCR LDX PLAYER
  1148. JSR ADDSCORE
  1149. JMP ENDSHOT
  1150. NEXTOBJC DEX
  1151. BMI SHOTUP
  1152. CPX #13
  1153. BCC JUMPSHOT
  1154. LDX #13
  1155. JUMPSHOT JMP SHOTOBJC
  1156. SHOTSCR
  1157. * EXPLOSION PICTURE, SOUND
  1158. JSR SCRAPONE
  1159. LDA #L(EXPLOS)
  1160. STA OBJOFFST,X
  1161. SKER
  1162. LDA #2
  1163. JSR TUNIN
  1164. LDX PLAYER
  1165. LDA #0
  1166. JSR ADDSCORE
  1167. JENDS JMP ENDSHOT ;JENDS CALLED FROM SHOTUP BELOW
  1168. * CHECK FOR NEW SHOT
  1169. CHKSHOT LDX PLAYER
  1170. BIT ATTRACT
  1171. BMI NOSHOT
  1172. BVS ATTRSHOT
  1173. LDA BUTNIB,X ;CHECK FIRE BUTTON
  1174. BMI NOSHOT
  1175. ATTRSHOT ;LDA #L(ELF)
  1176. ;;;;; STA SHTROFST,X
  1177. JSR STOPRES
  1178. LDA #$81 ;MARK SHOT AS FIRED -- ALWAYS AT RIGHT
  1179. STA SHOTSTAT,X ; POSITION
  1180. LDA #0 ;START A NEW SHOT
  1181. JSR SCRAPONE
  1182. LDA #0
  1183. JMP TUNIN
  1184. SHOTUP LDX PLAYER
  1185. LDA SHOTY,X
  1186. CMP #8 ;AT TOP?
  1187. BCC JENDS
  1188. SBC #8 ;SHOT NOT AT TOP -- MOVE UP
  1189. STA SHOTY,X
  1190. NOSHOT RTS
  1191. STOPRES LDA SHTRSTAT,X ;TAKE OUT OF RES MODE
  1192. AND #$EF
  1193. STA SHTRSTAT,X
  1194. JMP SHTRCLRS
  1195. ******************************************
  1196. * ADVANCE ALL OBJECT EXPLOSION ANIMATIONS
  1197. ******************************************
  1198. EXPLODE LDA FRMCNT
  1199. AND #1
  1200. BNE NOSHOT
  1201. LDX #15
  1202. EXPLLP LDY OBJOFFST,X
  1203. CPY #L(POINT300)
  1204. BCC EXPLNEXT ;EXPLOSION STAMP PUNT, TRY NEXT
  1205. CPX #12
  1206. BCC NRMLEXPL ;CENTIPEDE EXPLOSION
  1207. BEQ SPIDEY ;SPIDER EXPLOSION
  1208. CPX #13
  1209. BEQ NRMLEXPL ;FLEA EXPLOSION
  1210. ;ELSE SHOOTER EXPLOSION
  1211. BIT FLAGS ;IF MUSHROOM RESTORATION, USE NORMAL
  1212. BVS NRMLEXPL ; EXPLOSION
  1213. LDA FRMCNT ;SHOOTER EXPLOSION IS SLOWED DOWN
  1214. AND #$07
  1215. BNE EXPLNEXT
  1216. CPY #L(EXPLOS+4)
  1217. BNE ZNRMLEXP
  1218. LDA FLAGS ;SHOOTER EXPLOSION DONE, TURN ON
  1219. ORA #$40 ; MUSHROOM RESTORATION
  1220. STA FLAGS
  1221. LDA #0 ;ROW, COLUMN OF FIRST MUSHROOM
  1222. STA GTEMP5
  1223. STA GTEMP6
  1224. BEQ NOTHING ;ALWAYS
  1225. ***********
  1226. NRMLEXPL CPY #L(EXPLOS+4)
  1227. BEQ NOTHING
  1228. ZNRMLEXP INC OBJOFFST,X
  1229. INC OBJOFFST,X
  1230. BNE EXPLNEXT ;ALWAYS
  1231. ***********
  1232. SPIDEY DEC SPDRTIMR ;LEAVE SPIDER POINTS UP FOR A WHILE
  1233. BNE EXPLNEXT
  1234. LDY DIFLEVEL ;SET TIMER FOR REAPPEARANCE
  1235. LDA SPDRWTDF,Y
  1236. STA SPDRTIMR
  1237. ***********
  1238. NOTHING LDA #0
  1239. STA OBJOFFST,X
  1240. STA OBJSTAT,X
  1241. EXPLNEXT DEX
  1242. BPL EXPLLP
  1243. RTS
  1244. ;HSCSETUP FIRST DETERMINES IF THERE IS A HSC PLUGGED IN IF IT IS A ZERO IS
  1245. ;RETUNED AND THE ARGUMENT BLOCK IS SETUP. IF THE CART IS NOT PRESENT, THE ZERO
  1246. ;FLAG IS RESET. DURATION IS SET TO ZERO FOR HSCENTER. ANY OTHER VALUE MUST BE
  1247. ;STORED AFTER CALLING HSCSETUP. ACTUAL SCORES MUST BE MOVED INTO THE SCORE BLOCK
  1248. ;OUTSIDE THIS ROUTINE.
  1249. ;FIRST CHECK FOR THE PRESENSE OF HIGH SCORE CART
  1250. HSCSETUP
  1251. LDA $3900 ;HSC THERE?
  1252. CMP #$C6
  1253. BNE NOHSC
  1254. LDA $3904
  1255. CMP #$FE
  1256. BNE NOHSC
  1257. TXA
  1258. PHA
  1259. LDA #$80
  1260. STA ATTRACT
  1261. LDX #14 ;LOAD FIXED HSC ARGS INTO DATA BLOCK
  1262. HSLOADLP LDA HSCARGS,X ;this argument loading must come first
  1263. STA HSDATA,X ;in setup, since some args are
  1264. DEX ;variable and get reloaded
  1265. BPL HSLOADLP
  1266. LDA #$7F
  1267. STA CTRL
  1268. LDA #0
  1269. LDX #5
  1270. HSCOBJCL STA OBJSTAT+12,X
  1271. DEX
  1272. BPL HSCOBJCL
  1273. LDA #5 ;SO THAT COLOR LOADING ROUTINE ONLY
  1274. STA HSCFLAG ; DOES PAL.S 5,6
  1275. JSR LOGOINIT ;LOGO BOTTOM
  1276. LDA #1
  1277. STA COLORFLG
  1278. LDA #L(HSTOPDLI)
  1279. STA VECTORI
  1280. LDA #H(HSTOPDLI)
  1281. STA VECTORI+1
  1282. LDX GAMETYPE ;NO GAME TYPE DISPLAY IF IN A SINGLE
  1283. LDA HSGMTYP,X ; PLAYER AT A TIME GAME
  1284. BNE NOTYPDSP
  1285. ;;;;; LDA #0
  1286. STA DL16+1
  1287. NOTYPDSP LDA DIFLEVEL
  1288. ASL A
  1289. ASL A
  1290. ORA HSGMTYP,X
  1291. ASL A
  1292. ASL A
  1293. STA GTEMP3
  1294. PLA
  1295. TAX
  1296. ORA GTEMP3
  1297. STA HSDATA+2 ;DIFFY PLAYNUM
  1298. LDA #0 ;MAKE EQUAL ON RETURN
  1299. ;MUST RETURN WITH INITIAL X RESTORED
  1300. NOHSC RTS ; AND ZERO FLAG SET
  1301. HSCNTR1 ;ENTER THE INITIALS FOR PLAYER1
  1302. JSR HSCSETUP
  1303. BNE RHS1
  1304. TXA
  1305. PHA
  1306. JSR MAKCENTI ;CENTIPEDE FOR HSC LOGO
  1307. PLA
  1308. TAX
  1309. LDA GAMETYPE
  1310. BEQ DOSCREG ;ONE PLAYER GAME
  1311. CMP #3
  1312. BEQ TMSCREG ;TEAM
  1313. CPX #0
  1314. BNE DOSCREG
  1315. STX HSDATA+$E ;NO WAIT AFTER FIRST PLAYER IN TWO PLR
  1316. BEQ DOSCREG
  1317. TMSCREG LDX #2 ;USE TEAM SCORE IN TEAM PLAY GAME
  1318. DOSCREG LDA SCORE3,X
  1319. STA SCOREBLK
  1320. LDA SCORE2,X ;INITIALIZE SCORE INFO TO BE PASSED
  1321. STA SCOREBLK+1
  1322. LDA SCORE1,X
  1323. STA SCOREBLK+2
  1324. LDA SCORE0,X
  1325. STA SCOREBLK+3
  1326. LDY #H(HSDATA)
  1327. JSR $3FFD ;HSCENTER
  1328. HSCREC LDX #$7F ;RECOVER FROM HSC
  1329. STX CTRL
  1330. LDA #H(DLL)
  1331. STA DPH
  1332. LDA #L(DLL)
  1333. STA DPL
  1334. LDA #H(STMPBASE)
  1335. STA CHARBASE
  1336. LDA #L(MORPHO)
  1337. STA VECTORI
  1338. LDA #H(MORPHO)
  1339. STA VECTORI+1
  1340. JSR TURNON WAIT FOR TOP OF SCREEN AND TURN DMA ON
  1341. LDX #0
  1342. STX HSCFLAG
  1343. INX
  1344. STX COLORFLG
  1345. RHS1 RTS
  1346. HSATRACT LDA #11 ;LOOP FOR ALL GAME LEVELS
  1347. STA HSATRGM
  1348. JSR MAKCENTI
  1349. LDA GAMETYPE
  1350. PHA
  1351. LDA DIFLEVEL
  1352. PHA
  1353. HSATRLP LDX HSATRGM
  1354. LDA GAMETBL,X
  1355. LSR A
  1356. LSR A
  1357. AND #$03
  1358. TAY
  1359. BEQ ZXABD
  1360. INY
  1361. ZXABD STY GAMETYPE ;GAMETYPE
  1362. LDA GAMETBL,X
  1363. LSR A
  1364. LSR A
  1365. LSR A
  1366. LSR A
  1367. STA DIFLEVEL ;DIFLEVEL
  1368. LDX #0
  1369. JSR HSCSETUP
  1370. BNE ATRREC
  1371. LDA #0
  1372. STA HSDATA+$E
  1373. LDY #H(HSDATA)
  1374. JSR $3FF7 ;HSCSTAT
  1375. LDX HSDATA+4
  1376. CPX #5
  1377. BCC ZNHSOK
  1378. LDX #5
  1379. ZNHSOK LDA HSTIME,X
  1380. STA HSDATA+$E ;DURATION OF HSC
  1381. LDA #L(STICKIT)
  1382. STA HSDATA+4
  1383. LDA #H(STICKIT)
  1384. STA HSDATA+5
  1385. LDY #H(HSDATA)
  1386. JSR $3FFA ;HSCATRCT
  1387. LDA PANEL
  1388. LSR A
  1389. BCC ATRLEAVE ;RESET SWITCH PRESSED
  1390. LSR A
  1391. BCC ATRREC ;SELECT SWITCH PRESSED
  1392. LDA BUTNIB
  1393. BPL ATRLEAVE
  1394. JSR STICKIT0
  1395. ;; LDA SCHTICK
  1396. AND #$F0
  1397. CMP #$F0
  1398. BNE ATRREC
  1399. DEC HSATRGM
  1400. BPL HSATRLP
  1401. ATRREC PLA
  1402. STA DIFLEVEL
  1403. PLA
  1404. STA GAMETYPE
  1405. JMP HSCREC
  1406. ATRLEAVE LDA #$60
  1407. STA DL16+1
  1408. PLA
  1409. STA DIFLEVEL
  1410. PLA
  1411. STA GAMETYPE
  1412. JSR HSCREC
  1413. LDA #$FF ;MAKE FLAG NEG
  1414. NOSOUND RTS
  1415. GAMETBL DB $38,$28,$18,$08,$34,$24,$14,$04,$30,$20,$10,$00
  1416. HSTIME DB 0,9,6,5,4,3
  1417. HSCARGS DB 1,1,0,2,L(STICKIT),H(STICKIT),0,0,L(SCOREBLK),H(SCOREBLK)
  1418. DB L(HSCDLL),H(HSCDLL),L(NOSOUND),H(NOSOUND),9
  1419. HSGMTYP DB 0,0,1,2
  1420. HSTOPDLI
  1421. TXA
  1422. PHA
  1423. TYA
  1424. PHA
  1425. CLD
  1426. LDA #$40
  1427. STA CTRL
  1428. LDA #H(STMPBASE+$100)
  1429. STA CHARBASE
  1430. LDA #$80 ;GROUND CAPS
  1431. STA VBLANK
  1432. LDA #L(HSBTMDLI)
  1433. LDY #H(HSBTMDLI)
  1434. ENDHSDLI STA VECTORI
  1435. STY VECTORI+1
  1436. PLA
  1437. TAY
  1438. PLA
  1439. TAX
  1440. PLA
  1441. RTI
  1442. HSBTMDLI
  1443. TXA
  1444. PHA
  1445. TYA
  1446. PHA
  1447. CLD
  1448. LDA #0
  1449. STA VBLANK ;UNGROUND CAPS
  1450. STA WSYNC
  1451. STA WSYNC
  1452. LDA #$39
  1453. STA CHARBASE
  1454. LDA #$4B
  1455. STA CTRL
  1456. INC FRMCNT
  1457. JSR LOADIT
  1458. JSR MOVCENTI
  1459. JSR TRACKIT
  1460. LDA NUMSEG
  1461. BNE HSLMST
  1462. LDA #12
  1463. CLC
  1464. ADC CLRINDEX
  1465. CMP #TOPCOLOR
  1466. BNE HSNOCLR
  1467. LDA #0
  1468. HSNOCLR STA CLRINDEX
  1469. LDA #1
  1470. STA COLORFLG
  1471. JSR MAKCENTI
  1472. HSLMST JSR LMST STUPID NAME FOR COLOR LOAD ROUTINE
  1473. LDA #L(HSTOPDLI)
  1474. LDY #H(HSTOPDLI)
  1475. JMP ENDHSDLI
  1476. STICKIT
  1477. CPX #0
  1478. BEQ ZSTICK ;IF PLAYER 0 GO AHEAD
  1479. LDX #1 ;ENSURE THAT IT'S PLAYER 1
  1480. LDA ALTCTRLS ;SHARE TRACKBALL?
  1481. BEQ ZSTICK ; NO
  1482. ;YES
  1483. STICKIT0 LDX #0
  1484. ZSTICK LDY BUTNIB,X
  1485. LDA TRACKF,X
  1486. BNE DOMOVM ;DO TRACKBALL
  1487. CPX #1
  1488. BNE STIKI
  1489. LDA ALTCTRLS
  1490. CMP #$1
  1491. BNE STIKI ;THE PLAYER WANTS TO SHARE TRACKBALL
  1492. LDX #0 ;coerce track0 for two play alt
  1493. DOMOVM LDA FRMCNT
  1494. AND #$7
  1495. BNE ROTSI
  1496. LDA DELTAX,X
  1497. BNE CALCIT
  1498. LDA DELTAY,X
  1499. BNE CALCIT
  1500. LDA #$FF
  1501. BMI DITTY ;NO MOVEMENT
  1502. CALCIT LDA DELTAX,X
  1503. BPL POSIT
  1504. EOR #$FF
  1505. CLC
  1506. ADC #1
  1507. POSIT STA TTEMP1
  1508. LDA DELTAY,X
  1509. BPL YSOT
  1510. EOR #$FF
  1511. CLC
  1512. ADC #1
  1513. YSOT STA TTEMP2
  1514. CMP TTEMP1
  1515. BCC EW
  1516. NS LDA DELTAY,X ;SET FLAGS
  1517. BPL SOU
  1518. LDA #$EF
  1519. DITTY STA SCHTICK
  1520. RTS
  1521. SOU
  1522. LDA #$DF ;SOUTH JOYSTICK VALUE
  1523. STA SCHTICK
  1524. RTS
  1525. EW LDA DELTAX,X
  1526. BPL EAS
  1527. LDA #$BF
  1528. STA SCHTICK
  1529. RTS
  1530. EAS LDA #$7F
  1531. STA SCHTICK
  1532. RTS
  1533. STIKI LDA #0
  1534. STA CTLSWA
  1535. LDA SWCHA ;joystick
  1536. CPX #0
  1537. BEQ ZSTIKI
  1538. ASL A
  1539. ASL A
  1540. ASL A
  1541. ASL A
  1542. ZSTIKI STA SCHTICK
  1543. RTS
  1544. ROTSI LDA SCHTICK
  1545. RTS