CMAIN.S 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. ** CMAIN.S **
  2. * CENTIPEDE MAIN LOOP
  3. * DVP 4/26/84 ALL PAUSE MODE CODE FROM GAMELOOP MOVED INTO CHKSTRT
  4. ORG $FF76
  5. DB 'GCC(C)1984'
  6. ORG $FFF8
  7. DB $FF,$C7
  8. DB L(BURP),H(BURP)
  9. DB L(RESET),H(RESET)
  10. DB L(RITS),H(RITS)
  11. ORG $D800
  12. BURP PHA ;THE RUDE ISR
  13. JMP (VECTORI)
  14. RESET
  15. SEI
  16. CLD
  17. * NOW ALIEN DOES THIS ALSO
  18. LDA #$17 ;ENCRYPTION CRAPOLA -- GO INTO MARIA
  19. STA $01 ; MODE.
  20. LDX #$7F
  21. STX CTRL
  22. LDX #$FF ;Initialize stack to be in PAGE ONE
  23. TXS
  24. INX
  25. TXA
  26. STA CTLSWA ;A=0 -- MAKE PORTS READ ONLY
  27. STA CTLSWB
  28. STA OFFSET $0038
  29. STA INTIM
  30. ZEROMEM STA $1E00,X KILL THAT LAST DL!!!!!
  31. STA $1F00,X
  32. STA $2000,X
  33. STA $2100,X
  34. STA $2700,X
  35. DEX
  36. BNE ZEROMEM
  37. JSR CLRTRACK
  38. JSR INITALL
  39. JSR ONSCREEN
  40. JSR OFFSCRN
  41. LDA #$43
  42. STA CTRL
  43. ******************************************
  44. * BEGIN MAIN LOOP OF GAME *
  45. ******************************************
  46. GAMELOOP
  47. JSR CHKSTRT ALL PAUSE MODE CODE NOW IN CHKSTRT
  48. JSR CHKEND
  49. JSR LOOSENDS
  50. JSR JOYSTICK
  51. JSR RESTOR
  52. JSR EXPLODE
  53. JSR FLEASCRP
  54. JSR MOVCENTI
  55. JSR NEWHD
  56. JSR MVSPIDER
  57. JSR SHOOT
  58. GAMEWAIT BIT OBJTBSEM ;WAIT UNTIL SEMAPHORE CLEARED BY LOADER
  59. BMI GAMEWAIT ; ENSURING THAT EVERY GAME PLAY GETS
  60. ; DISPLAYED AT LEAST ONCE
  61. LDA #$80 ;SET SEMAPHORE
  62. STA OBJTBSEM
  63. INC FRMCNT
  64. JMP GAMELOOP
  65. ******************************************
  66. * END MAIN LOOP OF GAME *
  67. ******************************************
  68. ;DEADEND JMP DEADEND ;NONMASKABLE INTERRUPT VECTOR
  69. ONSCREEN BIT MSTAT
  70. BMI ONSCREEN
  71. BIT MSTAT
  72. BMI ONSCREEN
  73. RTS
  74. OFFSCRN BIT MSTAT
  75. BPL OFFSCRN
  76. BIT MSTAT
  77. BPL OFFSCRN
  78. RTS
  79. ******************************************
  80. * Perform all initialization to get the system ready to do anything else -- sync
  81. * Maria with TV screen, etc.
  82. ******************************************
  83. INITALL
  84. LDA #L(MORPHO)
  85. STA VECTORI
  86. LDA #H(MORPHO)
  87. STA VECTORI+1
  88. LDA #H(STMPBASE)
  89. STA CHARBASE
  90. LDX #ENDLL-DLLTABLE ;LOAD DLL
  91. LODUPT LDA DLLTABLE,X
  92. STA DLL,X
  93. DEX
  94. BPL LODUPT
  95. LDA #L(DLL)
  96. STA DPL
  97. LDA #H(DLL)
  98. STA DPH
  99. LDA INPT4
  100. STA DEBOUNCE
  101. LDA #-12
  102. STA CLRINDEX
  103. LDX #$FF
  104. STX DEBOUNC1
  105. STX PANEL
  106. INX
  107. STX AUDV0
  108. STX AUDV1
  109. STX TPDL+1
  110. STX BACKGRND
  111. INX
  112. STX DIFLEVEL
  113. LDA #$80
  114. STA ATTRACT
  115. LDA #L(SHOT) ;INITIAL SHOT OFFSET
  116. STA SHOTOFST
  117. STA SHOTOFST+1
  118. LDA #60 ;ONE SECOND DELAYS
  119. STA OPTCNT2 ;NEXT OPTION
  120. STA SHOTTIMR ;GAME START
  121. *******************
  122. INITGAME LDA #0 ;GAME START INITIALIZATION, CLEAR
  123. LDX #2 ; SCORES
  124. CLRSCRLP STA SCORE0,X
  125. STA SCORE1,X
  126. STA SCORE2,X
  127. STA SCORE3,X
  128. DEX
  129. BPL CLRSCRLP
  130. JSR CLRTRACK
  131. LDX DIFLEVEL
  132. LDA DFNSEGS,X ;DFNSEGS DEFINED AT END OF INITALL
  133. STA MAXSGCNT
  134. STA CHAINSIZ
  135. STA CHAINSIZ+1
  136. *******************
  137. INITATGM LDA #0 ;ATTRACT MODE INITIALIZATION ENTRY PT.
  138. STA PAUSETMR
  139. STA FLAGS
  140. STA PLAYER
  141. STA NUMSEG
  142. STA FASTWAVE
  143. STA NEWHDFLG
  144. STA CLRINDEX+1
  145. STA HSCFLAG
  146. STA SHTRTIMR
  147. LDX #17 ;KILL ALL OBJECTS
  148. CLROBJLP STA OBJSTAT,X
  149. DEX
  150. BPL CLROBJLP
  151. STA MENLEFT ;CLEAR THE NUMBER OF MEN LEFT
  152. STA MENLEFT+1 ; VARIABLES AND DISPLAY
  153. STA P7C1 ;LOAD PALETTE 7 FOR BLANK
  154. LDA #$CA ;COLOR FOR HIGH SCORE
  155. STA P7C2
  156. LDA #$08
  157. STA P7C3 ;BORDER COLOR
  158. LDA #$10
  159. STA FASTWAVE+1
  160. LDX #0
  161. JSR CLRMAPZN
  162. LDA #$20 ;SET INITIAL BONUS VALUES
  163. STA BONUSL ; (CURRENTLY FIRST BONUS AT 12,000)
  164. STA BONUSL+1
  165. LDA #1
  166. STA BONUSM
  167. STA BONUSM+1
  168. LDA #$C0
  169. STA NHDCOUNT
  170. STA NHDCOUNT+1
  171. LDA #-12
  172. STA CLRINDEX
  173. LDA #CENTPCNT
  174. STA LETTRNUM
  175. JSR SHTRCLRS ;SUB. IN DEATH.S TO INIT. SHTR. COLORS
  176. * INITIAL SHOOTER, SHOT POSITION, STATUS, AND GRAPHICS
  177. BIT ATTRACT
  178. BMI NOPLRS
  179. JSR INITPLRS ;THIS SUBROUTINE IS IN DEATH
  180. NOPLRS JSR SCRAPALL
  181. * SET THE FIRST HEADER IN EACH DISPLAY LIST TO POINT TO THE CHARACTER MAP
  182. LOGOINIT ;LOGOINIT IS FOR HSC
  183. JSR SETATVAR
  184. JSR DLSTINIT ;SET FIRST HDR. IN EACH DL TO MAP
  185. JSR LOADPLWD
  186. JSR MAPINIT
  187. LDA ATTRACT
  188. BMI ENDINIT
  189. LDA GAMETYPE
  190. CMP #1
  191. BEQ MAP2INIT
  192. ENDINIT RTS
  193. DFNSEGS DB 10,10,11,12
  194. MAP2INIT LDA MUSHCNT
  195. STA MUSHCNT+1
  196. JSR SWAP
  197. ******************************************
  198. MAPINIT
  199. DSPLYOPT
  200. LDX #NZONES-2
  201. CLRMAPLP JSR CLRMAPZN
  202. DEX
  203. BNE CLRMAPLP
  204. LDA ATTRACT
  205. BPL LDSHROOM
  206. ************************************************************
  207. **** SUBROUTINE DSPLYOPT - - DISPLAY GAME OPTIONS IN MENU PAGE
  208. ************************************************************
  209. LDY DIFLEVEL ;DIFFICULTY LEVEL DISPLAY
  210. LDA DFLVLLOW,Y
  211. STA GTEMP1
  212. LDA DFLVLHGH,Y
  213. STA GTEMP2
  214. LDA DFPOS,Y
  215. TAX
  216. LDA DFLNGTH,Y
  217. TAY
  218. DFLVLLP LDA (GTEMP1),Y
  219. STA DFLVLDSP,X
  220. DEX
  221. DEY
  222. BPL DFLVLLP
  223. LDX GAMETYPE ;GAME OPTION DISPLAY
  224. LDA ALOW,X
  225. STA GTEMP1
  226. LDA AHIGH,X
  227. STA GTEMP2
  228. LDY #22
  229. AOPTLP LDA (GTEMP1),Y
  230. STA GMTYPDSP,Y
  231. DEY
  232. BPL AOPTLP
  233. ; CPX #1
  234. ; BNE ENDDSPOP
  235. ; LDA #L(TWOCTRLS)
  236. ; LDX #H(TWOCTRLS)
  237. ; LDY ALTCTRLS
  238. ; BEQ CTRLLN
  239. ; LDA #L(SHRTRCKB)
  240. ; LDX #H(SHRTRCKB)
  241. ;TRLLN STA GTEMP1
  242. ; STX GTEMP2
  243. ; LDY #14
  244. ;TRLLP LDA (GTEMP1),Y
  245. ; STA CTRLDSP+9,Y
  246. ; DEY
  247. ; BPL CTRLLP
  248. LDA ALTCTRLS
  249. BEQ ENDDSPOP
  250. LDY #14
  251. SHARELP LDA SHRTRCKB,Y
  252. STA CTRLDSP+9,Y
  253. DEY
  254. BPL SHARELP
  255. ENDDSPOP RTS
  256. ******************************************
  257. * Fill a mushroom map randomly.
  258. * The top 2 lines of PF don't get any mushrooms, next 14 get one or two per row,
  259. * next 6 get 1 per row, last row gets none.
  260. * Starting address of mushroom map, +3*ZONELEN, assumed to be in (GTEMP+1,GTEMP)
  261. * MUSHCNT for current player gets count of mushrooms in infield (bottom N rows)
  262. ******************************************
  263. LDSHROOM
  264. LDA #H(MUSHMAP+3*ZONELEN)
  265. STA GTEMP2
  266. LDA #L(MUSHMAP+3*ZONELEN)
  267. STA GTEMP1
  268. LDA #INFLDZN-4 ;First 9 lines, one or two mush. per
  269. STA NLOOPS ;line, no count
  270. RMLP1 LDX #2
  271. JSR RNDMUSH
  272. DEC NLOOPS
  273. BNE RMLP1
  274. LDA #0 ;PLAYER ALWAYS = 1 AT THIS POINT
  275. STA MUSHCNT ;GOING INTO INFIELD, CLEAR MUSHCNT
  276. LDA #NZONES-6-INFLDZN ;Next 5 lines, one or two per line but
  277. STA NLOOPS ;count
  278. RMLP2 LDX #2
  279. JSR RNDMUSH
  280. DEC NLOOPS
  281. BNE RMLP2
  282. LDA #6 ;Next 6 lines, one per row, count
  283. STA NLOOPS
  284. RMLP3 LDX #1
  285. JSR RNDMUSH
  286. DEC NLOOPS
  287. BNE RMLP3
  288. RTS
  289. ******************************************
  290. * Place a mushroom randomly in a row; return 0 if mushroom was already there,
  291. * 1 if new mushroom was placed
  292. * On entering, (GTEMP1+1,GTEMP1) should contain starting address of row
  293. ******************************************
  294. RNDMUSH JSR RANDOM ;Pick a random column between 1 and 32,
  295. AND #$1F
  296. BEQ ZNOMUSH
  297. TAY
  298. DEY ; then decrement onto line
  299. LDA (GTEMP1),Y ;What's already there?
  300. CMP #L(EMPTY)
  301. BNE ZNOMUSH
  302. LDA #L(LIVE) ;PUT IN MUSHROOM
  303. STA (GTEMP1),Y ;RETURN TRUE (Z=1) IF NEW MUSHROOM
  304. INC MUSHCNT
  305. ZNOMUSH DEX
  306. BNE RNDMUSH
  307. INCROW LDA GTEMP1
  308. CLC
  309. ADC #ZONELEN
  310. STA GTEMP1
  311. BCC ZNR001
  312. INC GTEMP2
  313. ZNR001 RTS
  314. CLRMAPZN LDA MMAPTBLL,X
  315. STA GTEMP1
  316. LDA MMAPTBLH,X
  317. STA GTEMP2
  318. LDY #ZONELEN-1
  319. LDA #L(EMPTY)
  320. ZCLRZNLP STA (GTEMP1),Y
  321. DEY
  322. BPL ZCLRZNLP
  323. RTS
  324. ***************************************************************************
  325. ******** SUBROUTINE LOOSENDS
  326. ******** HANDLE LOOSE ENDS (CHANGE WAVES AND PLAYERS, MAKE SHOOTERS AND
  327. ******** CENTIPEDES, ETC.
  328. ***************************************************************************
  329. LOOSENDS LDA SHTRTIMR
  330. BNE GOOP
  331. LDA DELAYSEG
  332. BNE SPDY
  333. LDA NUMSEG
  334. BEQ SPDY
  335. LDA #7
  336. CMP TUNNUM
  337. BEQ SPDY
  338. CMP TUNNUM1
  339. BEQ SPDY
  340. JSR TUNIN
  341. SPDY BIT SPDRSTAT
  342. BPL FLECK
  343. LDA SPDROFST
  344. CMP #L(POINT300)
  345. BCS FLECK
  346. LDA #1
  347. CMP TUNNUM
  348. BEQ FLECK
  349. CMP TUNNUM1
  350. BEQ FLECK
  351. JSR TUNIN
  352. FLECK LDA FLEAOFST
  353. CMP #L(EXPLOS)
  354. BCS GOOP
  355. LDA FLEASTAT
  356. AND #$C0
  357. CMP #$80
  358. BNE GOOP
  359. LDA #5
  360. CMP TUNNUM
  361. BEQ GOOP
  362. CMP TUNNUM1
  363. BEQ GOOP
  364. JSR TUNIN
  365. GOOP LDA NUMSEG
  366. BEQ SKPRTSS7
  367. ZSRTS1 RTS
  368. SKPRTSS7 BIT ATTRACT
  369. BPL NRMLMKCN
  370. LDA #12
  371. CLC
  372. ADC CLRINDEX
  373. CMP #TOPCOLOR
  374. BNE SKPRSTCL
  375. LDA #0
  376. SKPRSTCL STA CLRINDEX
  377. LDA #1
  378. STA COLORFLG
  379. DEC LETTRNUM
  380. BMI ATTROVER
  381. JMP NRML1234
  382. ATTROVER JSR HSATRACT
  383. BMI ZSRTS1 ;RETURN IF BUTTON PRESSED IN HSC
  384. LDA #$40
  385. STA ATTRACT ;CHANGE TO ATTRACT MODE GAME PLAY
  386. LDA #0
  387. STA ATGMTMR ;COUNT FOR ENDING ATTRACT MODE GAME
  388. ;BIT 7 OF ATGMTMR'S USED AS MOVEMENT
  389. ; FLAG IN JOYSTICK
  390. LDA #$80
  391. STA ATSITTMR ;COUNT FOR SHOOTER TO SIT/MOVE
  392. STA ATGMTMR+1
  393. LDA #$40
  394. STA ATSITTMR+1
  395. LDA #-1
  396. STA ATTSHTRY ;Y VECTOR FOR ATTRACT MODE SHOOTER
  397. STA ATTSHTRY+1
  398. JSR RANDOM
  399. AND #$01
  400. BNE SKPYDIR1
  401. LDA #-1
  402. SKPYDIR1 STA ATTSHTRX ;X VECTOR FOR ATTRACT MODE SHOOTER
  403. JSR RANDOM
  404. AND #$01
  405. BNE SKPYDIR2
  406. LDA #-1
  407. SKPYDIR2 STA ATTSHTRX+1 ;X VECTOR FOR ATTRACT MODE SHOOTER
  408. JMP INITATGM
  409. NRMLMKCN LDA #7 ;TURN OFF CENTIPEDE FEET SOUND
  410. JSR SCRAPONE
  411. LDX PLAYER ;ROTATE COLORS FOR NEXT CENTIEDE
  412. LDA GAMETYPE
  413. CMP #2
  414. BCC ZNRMLMK1
  415. LDX #0
  416. ZNRMLMK1 LDA CLRINDEX,X
  417. CLC
  418. ADC #12
  419. CMP #TOPCOLOR
  420. BNE SKPCLRST
  421. LDA #0
  422. SKPCLRST STA CLRINDEX,X
  423. LDA #1 ;SET FLAG TO CHANGE COLORS
  424. STA COLORFLG
  425. LDA FASTWAVE,X
  426. BEQ WVSPCHNG ;IF NOT A FAST SPEED WAVE
  427. DEC CHAINSIZ,X ;MAKE CENTIPEDE CHAIN ONE LINK SHORTER
  428. BNE SKPSGRST ;IF CHAIN SIZE IS NOT TOO SMALL
  429. LDA MAXSGCNT
  430. STA CHAINSIZ,X ;BACK TO FULL CENTIPEDE CHAIN
  431. SKPSGRST LDY PLAYER
  432. LDA GAMETYPE ;USE CORRECT SCORE FOR GAME TO
  433. CMP #2 ; DETERMINE WHETHER TO HAVE FAST/SLOW
  434. BCC FASTSLOW ; CENTIPEDES
  435. LDY #2
  436. CMP #2
  437. BNE FASTSLOW
  438. DEY
  439. LDA SCORE2+1
  440. CMP SCORE2
  441. BCS FASTSLOW
  442. DEY
  443. FASTSLOW LDA SCORE2,Y
  444. CMP #4
  445. LDA #$10
  446. BCS WAVEFAST ;IF SCORE IS >= 40,000
  447. WVSPCHNG LDA FASTWAVE,X
  448. EOR #$10
  449. WAVEFAST STA FASTWAVE,X ;CHANGE SPEED OF THE NEXT WAVE
  450. NRML1234 JMP MAKCENTI
  451. **************************************************************************
  452. ******** SUBROUTINE DLSTINIT
  453. ******** INITIALIZE DISPLAY LIST HEADERS TO POINT TO THE MUSHROOM MAP
  454. **************************************************************************
  455. DLSTINIT LDX #NZONES-2 ;MINUS 1 FOR INDEX, 1 FOR NO CHAR. MAP
  456. ; FOR LAST ROW
  457. NEXT LDA LDLTBL,X ;ADDRESS OF DL FOR ZONE X
  458. STA GTEMP1
  459. LDA HDLTBL,X
  460. STA GTEMP2
  461. LDY #0 ;WRITE HEADER
  462. LDA MMAPTBLL,X
  463. STA (GTEMP1),Y ;STORE LOW ADDRESS
  464. INY ;Y=1
  465. LDA #$60 ;INDIRECT, 160X2 WRITE MODE
  466. STA (GTEMP1),Y
  467. INY ;Y=2
  468. LDA MMAPTBLH,X
  469. STA (GTEMP1),Y ;STORE HIGH ADDRESS
  470. INY ;Y=3
  471. LDA #PALWIDTH
  472. STA (GTEMP1),Y ;STORE PALETTE AND WIDTH
  473. INY ;Y=4
  474. LDA #HORIZPOS
  475. STA (GTEMP1),Y ;STORE HORIZONTAL POSITION
  476. LDY #6
  477. LDA #0 ;END DL WITH 0 IN PALWIDTH
  478. STA (GTEMP1),Y
  479. DEX
  480. BNE NEXT ;DO ALL ZONES EXCEPT SCORE -- ZONE 1
  481. LDA ATTRACT
  482. BPL SCOREDL
  483. ******************************************
  484. * SET UP ATTRACT MODE DL'S
  485. ******************************************
  486. MKATTRDL
  487. LDX #4 ;BOTTOM HEADERS FOR LOGO DISPLAY LISTS
  488. NEXTATR LDA ATTRYBSE/8+LDLTBL,X
  489. STA GTEMP1
  490. LDA ATTRYBSE/8+HDLTBL,X
  491. STA GTEMP2
  492. LDY #0
  493. LDA LTITLGRP,X
  494. STA (GTEMP1),Y
  495. INY
  496. LDA PWATTBL,X
  497. STA (GTEMP1),Y
  498. INY
  499. LDA #H(TPG8LIN1)
  500. STA (GTEMP1),Y
  501. INY
  502. LDA XPOSOFFS,X
  503. CLC
  504. ADC #HORIZPOS
  505. STA (GTEMP1),Y
  506. LDY #5
  507. LDA #0
  508. STA (GTEMP1),Y
  509. SKPHDR2 DEX
  510. BPL NEXTATR
  511. ;;;;; LDA #0
  512. STA DL1+1
  513. LDA SCRTIMER ;IF NO PLAY FOR A WHILE, TURN SCORE OFF
  514. BMI NOSCRDL ;DURING TITLE PAGE
  515. ******************************************
  516. * SET UP SCORE ZONE DL'S
  517. ******************************************
  518. SCOREDL LDY #33 ;HIGH INDEX FOR GAME 3 SCORE DL
  519. LDA GAMETYPE
  520. CMP #3
  521. BEQ ZSCRDL
  522. LDY #16 ;HIGH INDEX FOR GAME 0, 1, 2 SCORE DL
  523. ZSCRDL LDX #16
  524. SCRDLLP LDA DLSCR012,Y
  525. STA DL1,X
  526. DEY
  527. DEX
  528. BPL SCRDLLP
  529. NOSCRDL RTS
  530. LTITLGRP DB L(TPG8LIN1),L(TPG8LIN2),L(TPG8LIN3),L(TPG8LIN4),L(TPG8LIN5)
  531. XPOSOFFS DB 16,16,0,0,40
  532. PWATTBL DB $C5,$C5,$C2,$C5,PWCOPYRT
  533. DLSCR012 DB L(MUSHMAP),$60,H(MUSHMAP),$14,HORIZPOS
  534. DB L(MUSHMAP+12),$60,H(MUSHMAP+12),$FA,12*4+HORIZPOS
  535. DB L(MUSHMAP+19),$60,H(MUSHMAP+19),$34,19*4+HORIZPOS,0,0
  536. DLSCR3 DB L(MUSHMAP),$60,H(MUSHMAP),$1A,HORIZPOS
  537. DB L(MUSHMAP+9),$60,H(MUSHMAP+9),$F2,9*4+HORIZPOS
  538. DB L(MUSHMAP+25),$60,H(MUSHMAP+25),$3A,25*4+HORIZPOS,0,0
  539. ***************************************************************************
  540. ********** SUBROUTINE LOADPLWD -- LOAD THE PALETTE/WIDTH TABLE
  541. ***************************************************************************
  542. LOADPLWD
  543. LDX MAXSGCNT
  544. DEX
  545. BMI ZNOCENTS ;IF MAXSGCNT WAS ZERO
  546. LDA #PWCENTI ;LOAD THE PAL/WD BYTES FOR CENTIPEDES
  547. ZLDPWCNT STA OBJPALWD,X
  548. DEX
  549. BPL ZLDPWCNT
  550. ZNOCENTS LDX MAXSGCNT
  551. LDA #PWSPIDER ;LOAD THE PAL/WD BYTE(S) FOR THE SPIDER
  552. ZLDPWSPI STA OBJPALWD,X
  553. INX
  554. CPX #13
  555. BNE ZLDPWSPI
  556. LDA #PWSCORP
  557. STA OBJPALWD+13
  558. LDA #PWSHOOTR ;LOAD THE PAL/WD BYTE FOR THE SHOOTER
  559. STA OBJPALWD+14
  560. ORA #$20
  561. STA OBJPALWD+15
  562. LDA #PWSHOT ;LOAD THE PAL/WD BYTE FOR THE SHOT
  563. STA OBJPALWD+16
  564. ORA #$20
  565. STA OBJPALWD+17
  566. RTS
  567. ****************************************************************
  568. * SET ATTRACT MODE DEPENDENT VARIABLES
  569. ****************************************************************
  570. SETATVAR LDA ATTRACT
  571. BMI ATTRVAR
  572. LDA #MAXX-5
  573. STA CENTRGHT
  574. LDA #MINX+2
  575. STA CENTLEFT
  576. LDA #0
  577. STA SCRLONZN
  578. STA TOPLINE
  579. LDA #8
  580. STA MINIMUMY
  581. RTS
  582. ATTRVAR LDA #MAXX-6
  583. STA CENTRGHT
  584. LDA #MINX+3
  585. STA CENTLEFT
  586. LDA #ATTRYBSE-8
  587. STA TOPLINE
  588. LDA #ATTRYBSE
  589. STA MINIMUMY
  590. LDA #ATTRYBSE/8-1
  591. STA SCRLONZN
  592. RTS
  593. RANDOM LDA FRMCNT
  594. RANDOM2 ADC RNDM
  595. ADC RNDM+1
  596. LDY RNDM
  597. STY RNDM+1
  598. STA RNDM
  599. RTS
  600. ******************************************
  601. * CHECK WHETHER WE'RE ABOUT TO MEET AN OBSTACLE (MUSHROOM)
  602. * ENTERED WITH ACC. = VERT. POS. OF MOVING OBJECT
  603. * GTEMP1 = HORIZ. POSITION
  604. * RETURNS WITH PLAYFIELD ADDRESS IN (GTEMP4,GTEMP3), CONTENTS OF ADDRESS IN ACC.
  605. ******************************************
  606. OBSTAC LSR A
  607. LSR A
  608. LSR A
  609. BPL OBBOTH ;ALWAYS
  610. COBSTAC LSR A
  611. LSR A
  612. LSR A
  613. ADC #0
  614. OBBOTH CMP #23
  615. BEQ OFFROWZZ
  616. TAY
  617. LDA GTEMP1 ; (X/4) - 4 , SAME AS (X-16)/4
  618. LSR A
  619. LSR A
  620. SEC
  621. SBC #MINX/4 ;SUBTRACTING 4, LEAVING CARRY SET
  622. BMI OFFROWZZ
  623. CMP #$1F
  624. BCC OBSTAC2
  625. OFFROWZZ LDA #0 ;SET Z FLAG
  626. RTS
  627. * ENTRY POINT FROM RESTORE ROUTINE, COLUMN IN ACC., ROW IN Y
  628. OBSTAC2 CLC
  629. ADC MMAPTBLL,Y
  630. STA GTEMP3
  631. LDA MMAPTBLH,Y ;INCREMENT HIGH BYTE IF NECESSARY
  632. ADC #0
  633. STA GTEMP4
  634. LDY #0
  635. LDA (GTEMP3),Y
  636. CMP #L(EMPTY)
  637. RTS
  638. ******************************************
  639. * ADD A MUSHROOM TO PLAYFIELD IF NOT ON LAST ROW
  640. * COUNT IF MUSHROOM ADDED TO INFIELD
  641. * ENTERED WITH ACC. = VERT. POS. OF OBJECT IN QUESTION
  642. * (GTEMP4,GTEMP3) POINTING TO PLAYFIELD ADDRESS IN QUESTION
  643. ******************************************
  644. MUSHER LSR A
  645. LSR A
  646. LSR A
  647. BPL MUBOTH ;ALWAYS
  648. CMUSHER LSR A
  649. LSR A
  650. LSR A
  651. ADC #0
  652. MUBOTH BEQ NOM001
  653. MUSHER1 CMP #23
  654. BEQ NOM001
  655. CMP #INFLDZN-1
  656. BCC NEWM001
  657. LDX PLAYER
  658. LDA GAMETYPE
  659. CMP #1
  660. BEQ INCMUSHC
  661. LDX #0 ;USE ONLY MUSHCNT, NOT MUSHCNT+1, IN
  662. ; DUAL PLAYER GAMES
  663. INCMUSHC INC MUSHCNT,X
  664. NEWM001 LDY #0
  665. LDA #L(LIVE)
  666. STA (GTEMP3),Y
  667. NOM001 RTS
  668. ******************************************
  669. * RESTORE MUSHROOMS AFTER PLAYER DIES *
  670. * FLAGS BIT 6 1=DO RESTORATION *
  671. * ROW COUNTER IN GTEMP5 *
  672. * COLUMN COUNTER IN GTEMP6 *
  673. ******************************************
  674. RESTOR BIT FLAGS
  675. BVC NOM001
  676. LDA FRMCNT
  677. AND #$07
  678. BNE NOM001
  679. LDX PLAYER
  680. LDA GAMETYPE
  681. CMP #2
  682. BCC RSTRNEXT ;NOT A DUAL PLAYER GAME
  683. LDX #1 ;ASSUME PLAYER 1 DIED
  684. LDA SHTRSTAT+1
  685. BNE RSTRNEXT ;YES -- PLAYER 2 DIDN'T DIE
  686. LDA SHTRSTAT ;PLAYER 2 DID DIE
  687. BNE DRSTR2 ; BUT PLAYER 1 DIDN'T
  688. LDA FRMCNT ;BOTH PLAYERS DIED -- TRADE OFF WHO
  689. AND #$08 ; GETS POINTS
  690. BEQ RSTRNEXT
  691. DRSTR2 DEX
  692. * START LOOP
  693. RSTRNEXT LDA GTEMP5 ;INCREMENT TO NEXT MUSHROOM
  694. CLC
  695. ADC #1
  696. CMP #NZONES-1
  697. BCC ROWRSTR
  698. INC GTEMP6
  699. LDA #1
  700. ROWRSTR STA GTEMP5
  701. TAY ;GET ROW
  702. LDA GTEMP6 ;COL IN A, ROW IN Y FOR OBSTAC2
  703. CMP #ZONELEN
  704. BCS DONERSTR
  705. JSR OBSTAC2 ;GET CONTENTS OF MUSHROOM SLOT
  706. CMP #L(EMPTY+1)
  707. BCC RSTRNEXT
  708. CMP #L(POISONED+1)
  709. BCS RSTRNEXT
  710. CMP #L(LIVE)
  711. BEQ RSTRNEXT
  712. LDA #L(LIVE)
  713. STA (GTEMP3),Y
  714. LDA #2
  715. JSR SCRAPONE
  716. LDA #2
  717. JSR TUNIN
  718. LDA #5
  719. ; LDY #0
  720. JSR ADDSCORE
  721. *PUT IN AN OBJECT EXPLOSION HERE
  722. LDX #14
  723. LDA SHTRSTAT
  724. BEQ USESHTR1
  725. INX
  726. USESHTR1 LDA #L(EXPLOS)
  727. STA OBJOFFST,X
  728. LDA GTEMP6
  729. ASL A
  730. ASL A
  731. ; CLC
  732. ADC #MINX
  733. STA OBJX,X
  734. LDA GTEMP5
  735. ASL A
  736. ASL A
  737. ASL A
  738. STA OBJY,X
  739. LDA #$80
  740. STA OBJSTAT,X
  741. RSTROK RTS
  742. DONERSTR LDA FLAGS ;CLEAR MUSHROOM RESTORATION FLAG,
  743. AND #$BF ; ALLOWING GAME TO CONTINUE
  744. STA FLAGS
  745. COMPOVER LDA GAMETYPE ;DUAL PLAYER COMPETITION GAME?
  746. CMP #2
  747. BNE RSTROK ;NO
  748. LDA FLAGS ;EITHER PLAYER DEAD?
  749. BPL RSTROK ;NO
  750. LDX #0 ;DEAD PLAYER'S SCORE >= LIVE PLAYER'S?
  751. BIT SHTRSTAT+1
  752. BVC HGHRYET
  753. INX
  754. HGHRYET JSR CMPSCORE
  755. BCS RSTROK ;YES
  756. LDA #0 ;NO, LIVE PLAYER AHEAD, AND WE HAVE A
  757. STA MENLEFT,Y ; DEFINITE WINNER
  758. LDA #15
  759. STA SHTRTIMR
  760. RTS
  761. * ADD TO SCORE
  762. * ENTERED WITH (A) = SCORE TO ADD TO TENS, ONES DIGITS
  763. * (Y) = SCORE TO ADD TO HUNDREDS, THOUSANDS
  764. * (X) = WHICH PLAYER GETS THE POINTS
  765. ADDSCORE BIT ATTRACT
  766. BVS RSTROK
  767. SED
  768. PHA
  769. LDA GAMETYPE
  770. CMP #3
  771. BNE ZADD1
  772. PLA ;IN TWO PLAYER TEAM PLAY MODE,
  773. PHA ; ADD TO INDIVIDUAL PLAYER'S SCORE
  774. CLC ; FIRST, THEN DOWN BELOW ADD TO TEAM
  775. ADC SCORE0,X ; SCORE
  776. STA SCORE0,X ;NO BONUSES OR ANYTHING ARE BASED ON
  777. TYA ; THE INDIVIDUAL SCORE
  778. ADC SCORE1,X
  779. STA SCORE1,X
  780. BCC TEAMADD
  781. LDA SCORE2,X
  782. ADC #0
  783. STA SCORE2,X
  784. TEAMADD LDX #2 ;TEAM SCORE INDEX
  785. ZADD1 PLA
  786. CLC
  787. ADC SCORE0,X
  788. STA SCORE0,X
  789. TYA
  790. ADC SCORE1,X
  791. STA SCORE1,X
  792. BCC BONUSCHK
  793. TXA
  794. TAY
  795. CPY #2
  796. BCC NHDPLYR
  797. LDY #0
  798. NHDPLYR LDA NHDCOUNT,Y ;CHANGE SPEED AT WHICH HEADS COME OUT
  799. SEC
  800. SBC #2 ; YES -- DECIMAL MODE
  801. CMP #4
  802. BCS SKPNHRST ;IF NEW HEAD TIMER IS ABOVE MINIMUM
  803. LDA #$C0
  804. SKPNHRST STA NHDCOUNT,Y ;BACK TO ITS SLOWEST RATE. WHEW!!
  805. LDA SCORE2,X ;NEED TO DO THIS DUE TO DECIMAL MODE
  806. CLC
  807. ADC #1
  808. STA SCORE2,X
  809. BCC BONUSCHK
  810. LDA SCORE3,X
  811. CLC
  812. ADC #1
  813. STA SCORE3,X
  814. BONUSCHK CLD ;CHECK FOR BONUS
  815. LDA GAMETYPE
  816. CMP #3
  817. BNE ZBONUSCH
  818. LDX #0
  819. LDA SCORE1+2
  820. CMP BONUSL
  821. LDA SCORE2+2
  822. JMP ZBONUSZ
  823. ZBONUSCH LDA SCORE1,X
  824. CMP BONUSL,X
  825. LDA SCORE2,X
  826. ZBONUSZ SBC BONUSM,X
  827. BCC NOBONUS
  828. CMP #$90
  829. BCS NOBONUS
  830. SED ;YES, GOT A BONUS--SET NEXT BONUS VALUE
  831. LDA #$20 ; (ONE EVERY 12,000 POINTS, NOW)
  832. ;;;; CLC
  833. ADC BONUSL,X
  834. STA BONUSL,X
  835. LDA #1
  836. ADC BONUSM,X
  837. STA BONUSM,X
  838. CLD
  839. LDA MENLEFT,X ;ADD A LIFE, IF POSSIBLE
  840. CMP #6
  841. BCS NOBONUS
  842. LDY GAMETYPE
  843. CPY #3
  844. BNE NORESMAN
  845. BIT FLAGS ;DURING MUSHROOM RESTORATION, JUST ADD
  846. BVS NORESMAN ; MAN TO TOTAL
  847. LDA SHTRSTAT ;IN TEAM PLAY, IF ONLY ONE PLAYER ALIVE
  848. AND SHTRSTAT+1 ; RES THE OTHER ONE IN
  849. BPL RESMAN
  850. NORESMAN LDA SHTRSTAT,X ;ONCE HE'S DEAD IN NON-TEAM PLAY, DON'T
  851. AND #$40 ; EVER BRING HIM BACK
  852. BNE NOBONUS
  853. LDA MENLEFT,X
  854. CLC
  855. ADC #1
  856. STA MENLEFT,X
  857. CPX #0
  858. BEQ ADDLIFE1
  859. ADDLIFE2 EOR #$FF
  860. CLC
  861. ADC #21
  862. ADDLIFE1 ;LDY GAMETYPE
  863. CPY #3
  864. BNE ADD1
  865. CLC
  866. ADC #TEAMMEN-6
  867. ADD1 TAY
  868. LDA #L(ELF320)
  869. STA MUSHMAP+6-1,Y
  870. MANSOUND LDA #6 ;TURN ON EXTRA MAN SOUND
  871. JSR TUNIN
  872. NOBONUS BIT FLAGS
  873. BVS ENDBONUS
  874. JMP COMPOVER
  875. ENDBONUS RTS
  876. RESMAN ;RES A MAN INTO PLAY, TEAM PLAY
  877. LDX #0
  878. LDA SHTRSTAT
  879. BPL RESBACK
  880. LDX #1
  881. RESBACK LDA FLAGS
  882. AND #$7F
  883. STA FLAGS
  884. LDA #CNTRCLMN
  885. STA SHOOTERX,X
  886. LDA #CNTRCLMN+2
  887. STA SHOTX,X
  888. LDY #184
  889. STY SHOOTERY,X
  890. DEY
  891. STY SHOTY,X
  892. LDA #L(ELF)
  893. CPX #0
  894. BEQ RESELF
  895. LDA #L(ELFB)
  896. RESELF STA SHTROFST,X
  897. LDA #$90 ;TURN HIM BACK ON, RES HIM IN
  898. RESFRONT STA SHTRSTAT,X
  899. JMP MANSOUND
  900. SCALE CLC
  901. BPL NOTNEG
  902. EOR #$FF
  903. ADC #2 ;TWOS COMP AND ADD 1
  904. LSR A ;DIVIDED BY 2
  905. CMP #$3
  906. BCC OKDOKEY
  907. LDA #$3
  908. OKDOKEY
  909. EOR #$FF ;RENEGE
  910. CLC
  911. ADC #1
  912. RTS ;SCALED VALUE IN ACC
  913. NOTNEG
  914. ADC #1
  915. LSR A
  916. CMP #$3
  917. BCC RETUX
  918. LDA #$3
  919. RETUX RTS
  920. CLRTRACK LDX #$06 ;CLEAR OUT ALL TBALL STUFF
  921. LDA #$00
  922. TLOOPY STA DELTAY,X
  923. DEX
  924. BPL TLOOPY
  925. STX BUTNIB
  926. STX BUTNIB+1
  927. STX SCHTICK
  928. LDA YCOUNT
  929. STA OLDY
  930. LDA YCOUNT1
  931. STA OLDY1
  932. LDA XCOUNT
  933. STA OLDX
  934. LDA XCOUNT1
  935. STA OLDX1
  936. RTS