SKERNEL.S 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971
  1. * SPHINX--SKERNEL.S
  2. ; ZERODEF
  3. ; RSEG CODE9
  4. *************** ALL DLI'S MUST START ON SAME PAGE!!!!!! ***********
  5. * DLITOP ;FIRST DLI TAKES PLACE AT TOP OF SCREEN
  6. DLITOP: ;SAVE REGISTERS
  7. PHA ;A,X,Y USED
  8. TXA
  9. PHA
  10. TYA
  11. PHA
  12. LDA #$50 ;RESTORE CTRL TO ITS OWN STATE
  13. STA CTRL
  14. LDA P0C2SHAD ;RESTUFF PALETTES FOR GAME SCREEN
  15. STA P0C2 ;SHOULD PROBABLY BE DONE WITH SHADOWS
  16. LDA P1C2SHAD
  17. STA P1C2 ;5/25/84
  18. LDA P2C2SHAD
  19. STA P2C2
  20. LDA P5C2SHAD ;TO UNDO OTHER HACK JEM: 5/14/84
  21. STA P5C2
  22. CLD ;RANDOM IS CALLED HERE, SO CLD
  23. ; BIT FUCKFLAG ;PUT THESE BACK TO SEE IF LOADER IS
  24. ; BPL FINE ;INTERRUPTED BY THIS DLI
  25. ; GOTCHA NOP
  26. ;REMEMBER THIS DLI HAPPENS EARLIER NOW!
  27. FINE: LDA DLZDEST ;CHANGE DLIPTR
  28. STA DLIPTR
  29. JSR RANDOM ;RANDOM NUMBER GENERATOR
  30. STA WSYNC
  31. LDA BACKCOL ;TURN ON BACKGROUND COLOR
  32. STA BACKGRND
  33. BIT FUCKFLAG
  34. BPL DONTFUCK
  35. JSR DOZEROS ;PUT ZEROS AT END OF DISPLAY LISTS
  36. DONTFUCK: PLA ;RESTORE REGISTERS
  37. TAY
  38. PLA
  39. TAX
  40. PLA
  41. RTI
  42. * DLIZ11 ;THIS MUST BE DONE AT END OF ZONE10 TO
  43. * SET CHARBASE FOR ZONE11. POTENTIALLY A SHORT ZONE AND MAY BE FOLLOWED BY ONE
  44. DLIZ11:
  45. PHA
  46. LDA D11CBASE
  47. STA WSYNC ;WAIT UNTIL END OF ZONE 10
  48. STA CHARBASE
  49. LDA #DLIBOT&$FF
  50. ;DMA SHOULD KICK IN HERE
  51. STA DLIPTR ;NEED TO HAVE TIME TO DO THIS STORE
  52. PLA
  53. RTI
  54. * DLISNCTT SYNCING DLI FOR TITLE PAGE
  55. DLISNCTT:
  56. PHA
  57. LDA #DLITIT&$FF
  58. JMP SYNCSAME
  59. * DLISYNC SYNCING DLI FOR REGULAR SCREEN
  60. DLISYNC: ;THIS IS THE SYNCIN' DLI
  61. PHA ;ARE WE SURE THIS IS CORRECT??
  62. LDA #DLITOP&$00FF
  63. SYNCSAME: STA WSYNC
  64. STA WSYNC ;THIS SHOULD BE END OF KERNEL
  65. BIT MSTAT
  66. BPL UNSYNC ;PUNT IF IN KERNEL
  67. BIT MSTAT
  68. BPL UNSYNC
  69. STA DLIPTR
  70. UNSYNC:
  71. PLA
  72. RTI
  73. * DLZ11A ;ALTRNTE. DLI HANDLER FOR 1 LINE ZONE11
  74. DLZ11A:
  75. PHA
  76. LDA D11CBASE
  77. STA WSYNC ;WSYNC TO FINISH ZONE 10
  78. STA CHARBASE ;NEW CHARBASE FOR ZONE 11
  79. * THIS IS FUNCTIONALITY OF DLIBOT WHICH IS SKIPPED WHEN ZONE11 IS 1 HIGH
  80. LDA #DLISYNC&$00FF
  81. STA DLIPTR
  82. STA WSYNC ;THIS SHOULD FINISH ZONE 11
  83. LDA #CHARS/256
  84. STA CHARBASE ;THIS IS CHARBASE FOR SCORE
  85. LDA #$43
  86. STA WSYNC
  87. STA CTRL ;CTROL VALUE FOR 320 MODE
  88. LDA #0 ;BLACK BACKGROUND
  89. STA BACKGRND
  90. JMP NOWLOAD
  91. * DLITIT TITLE PAGE DLI
  92. DLITIT: ;ALL THESE REGISTERS MAY NOT HAVE TO
  93. PHA ;BE SAVED
  94. TXA
  95. PHA
  96. TYA
  97. PHA
  98. LDA #TITCHR1/256
  99. STA CHARBASE
  100. LDA #$50 ;COMMENT
  101. STA CTRL
  102. JSR DOALLIO
  103. INC FRMCNT
  104. BNE SHITT
  105. INC STATIMER
  106. SHITT:
  107. LDA #DLITIT2&$FF
  108. STA DLIPTR
  109. LDA #DLITIT2/256
  110. STA DLIPTR+1
  111. PLA
  112. TAY
  113. PLA
  114. TAX
  115. PLA
  116. RTI
  117. * DLITIT2 ;SETS CHARBASE FOR CHAR FONT AT BOTTOM
  118. DLITIT2: ;SECOND TITLE PAGE DLI
  119. PHA
  120. LDA #CHARS/256
  121. STA CHARBASE
  122. LDA #$43
  123. STA CTRL
  124. LDA #DLISNCTT&$00FF
  125. STA DLIPTR
  126. LDA #DLISNCTT/256
  127. STA DLIPTR+1
  128. PLA
  129. RTI
  130. * DLIBOT ;THIS MUST BE DONE IN DLI AT END OF
  131. DLIBOT: ;REGULAR ZONES
  132. PHA
  133. ;DLI TO CHANGE BACKGROUND COLOR
  134. LDA #CHARS/256
  135. STA CHARBASE
  136. STA WSYNC ;THIS SHOULD FINISH ZONE 11
  137. LDA #DLISYNC&$00FF
  138. STA DLIPTR
  139. LDA #$43 ;CTRL FOR 320 MODE
  140. STA WSYNC
  141. STA CTRL
  142. LDA #0 ;BLACKGROUND
  143. STA BACKGRND
  144. NOWLOAD:
  145. * COLOR CHANGES FOR BOTTOM OF SCREEN DISPLAY
  146. LDA #$06 ;THESE ARE HARDWIRED NOT THE ONES AT
  147. STA P5C2 ;TOP OF SCREEN
  148. LDA P1C2SHDB ;SHADOW NEEDED HERE
  149. STA P1C2 ;FOR TOPMSMAP
  150. LDA #$3E
  151. STA P2C2 ;FOR BOTMSMAP
  152. LDA #$EF
  153. STA P0C2 ;FOR SCORE AND XTRA LIVES
  154. TXA
  155. PHA
  156. TYA
  157. PHA
  158. CLD ;ONLY NEEDED FOR DLI'S WHICH ADD OR SUB
  159. * FREEZE FRAMER
  160. FRZFRMR: BIT FREEZEP
  161. BPL DOTODO
  162. LDA PERIOD
  163. beq .toNothing
  164. DEC NEXFRAME
  165. beq .ok1
  166. .toNothing: jmp NOTHING
  167. .ok1:
  168. STA NEXFRAME
  169. LDX HOWMANY
  170. BEQ DOTODO
  171. DEX
  172. STX HOWMANY
  173. BNE DOTODO
  174. LDX #0
  175. STX PERIOD
  176. INX
  177. STX NEXFRAME
  178. DOTODO: INC FRMCNT ;GO FOR FRMCNT
  179. BNE BLAH
  180. INC STATIMER ;IT IS TWO BYTES
  181. BLAH: lda ENDCOUNT
  182. beq .skip
  183. dec ENDCOUNT
  184. .skip:
  185. DEC SECOND ;SECOND COUNTER
  186. BPL NOTSECND
  187. LDA #59 ;START NEXT SECOND
  188. STA SECOND
  189. LDA PHASE ;TIME THE BONUS RACK
  190. CMP #$FE
  191. BNE NOTBONUS ;NOT IN BONUS RACK
  192. SED
  193. LDA BNSTIMER
  194. SEC
  195. SBC #1
  196. STA BNSTIMER
  197. CLD
  198. BNE NOTBONUS ;NOT DONE WITH BONUS
  199. JSR LDTREAS ;DISPLAY ZERO SECONDS
  200. DEC PHASE ;GOTO FLASH PHASE
  201. LDA #FLASHT0
  202. JSR TUNIN
  203. LDA #FLASHT1
  204. JSR TUNIN
  205. NOTBONUS:
  206. LDA PTIMER ;POWER TIMER
  207. BEQ .ok1
  208. jsr decTimer ;Decrement power timer and flash power.
  209. jmp NOTSECND
  210. .ok1: ldx PLAYER
  211. lda RACK,x ;Round one?
  212. bne NOTSECND ;Only give help message in round 1.
  213. lda DIFCULTY ;Novice or Standard game?
  214. cmp #2
  215. bcs NOTSECND ;Only give help in Novice and Standard.
  216. lda PGPOWER,x ;Does player currently have a power?
  217. bne .ok2
  218. lda #$1F ;Flash "GET 3 HIERO" message.
  219. sta ROTATE
  220. .ok2:
  221. NOTSECND: LDA FRMCNT ;DISPATCH ON ODD OR EVEN
  222. LSR
  223. BCC DOTUNE
  224. DOLOAD: BIT RUNLOAD
  225. BPL DOTUNE
  226. JSR SCROLL ;ON ODD, SCROL CMAPS AND RUN LOADER
  227. JSR LOADER
  228. LDA #0
  229. STA RUNLOAD
  230. DOTUNE: JSR TUNER ;TUNE DRIVER
  231. JSR RUNBACK ;UPDATE BACKGROUND TUNE
  232. JSR BACKON ;CHECK TO PUT ON BACKGOUND TUNE. IF
  233. ;SO, SWAP IT IN
  234. NOTHING:
  235. JSR DOALLIO
  236. INTEROUT:
  237. PLA ;RESTORE REGISTERS
  238. TAY
  239. PLA
  240. TAX
  241. PLA
  242. RTI
  243. ZERO = 0
  244. DLIHSC0:
  245. PHA
  246. TXA
  247. PHA
  248. TYA
  249. PHA
  250. ;DO COLORS, CHARBASE, AND CONTROL
  251. LDA #TITCHR1/256
  252. STA CHARBASE
  253. LDA #$50
  254. STA CTRL
  255. LDA #DLIHSC1&$FF ;SAME PAGE I HOPE
  256. STA DLIPTR
  257. LDA #$0F
  258. STA P0C2
  259. LDA #$3A
  260. STA P1C2
  261. LDA #$00
  262. STA P2C2
  263. LDA #$10
  264. STA P3C2
  265. LDA #$37
  266. STA P4C2
  267. JSR TUNER ;RUN THE TUNES
  268. PLA
  269. TAY
  270. PLA
  271. TAX
  272. PLA
  273. RTI
  274. DLIHSC1:
  275. PHA
  276. TXA
  277. PHA
  278. TYA
  279. PHA
  280. LDA #DLIHSC0&$00FF
  281. STA DLIPTR
  282. JSR HSCSETRS ;RESETS WAT'S REG'S
  283. JMP INTEROUT
  284. ********************************************************************************
  285. * *
  286. * STARTUP *
  287. * *
  288. ********************************************************************************
  289. STARTUP: SEI ;HARDWARE DEPENDENT INITS
  290. CLD
  291. ; LDA #$07 ;LOCK ME IN MARIA MODE
  292. LDA #$87 ;PUT THIS IN WHEN WE HAVE 2BUT HARDWARE
  293. STA $1
  294. LDA #0 ;FOR FUTURE EXPANSION AND IMPERIALISM
  295. STA OFFSET
  296. LDX #$FF ;STACK POINTER AT $1FF
  297. TXS
  298. LDX #$7F ;KEEP COLOR BURST ON
  299. STX CTRL ;TURN OFF DMA
  300. LDY #$FF ;zero out zero page
  301. ZERLOOP:
  302. CPY #CTRL ;DON'T STORE TO CTRL AGAIN
  303. BEQ NOSTOR ;TO AVOID TURNING ON DMA
  304. STA ZERO,Y
  305. NOSTOR: DEY
  306. BNE ZERLOOP
  307. LDA #0 ;ENOUGH TIME HAS ELAPSED TO ALLOW CAPS
  308. STA $1 ;TO DISCHARGE SO CONTINUE FUCKING WITH
  309. LDA #$14 ;IO HARDWARE
  310. STA CTLSWB
  311. LDA #0 ;SELECT TWO BUTTON MODE
  312. STA SWCHB
  313. LDX #$40 ;POWER UP GETS THIS ONE
  314. LDA #0
  315. LEVEL1LP: STA ZERO,X
  316. INX
  317. BNE LEVEL1LP
  318. JSR PREINIT ;THIS SETS UP THE POWER UP DEFAULT
  319. JSR INITIT
  320. ;MODES FOR THE GAME
  321. JMP VBLNK
  322. GAMEDO: ;RESETS GO TO HERE
  323. LDX #FUTEXP1
  324. LDA #0
  325. LEVEL2LP: STA ZERO,X
  326. INX
  327. BNE LEVEL2LP
  328. ;
  329. JSR TOTINIT
  330. JSR MCPINIT ;TAKEN OUT OF TOTINIT
  331. JSR TOTINIT2
  332. ;
  333. BIT GAMEU
  334. BPL SHINIT
  335. ;
  336. JSR INITGAME
  337. JMP SHINIT
  338. NEWPLYDO: ;AUTOPLAY GOES HERE
  339. LDX #FUTEXP3 ;!!!!!!!!!
  340. LDA #0
  341. LEVEL3LP: STA ZERO,X
  342. INX
  343. BNE LEVEL3LP
  344. JSR TOTINIT
  345. JSR TOTINIT2
  346. ;
  347. BIT TITLMENU ;TITLMENU?
  348. BMI CKPLR
  349. JSR INITIT ;YES, JSR INITIT AND CONTINUE
  350. JMP VBLNK
  351. CKPLR: BIT NEWPLYR
  352. BPL ATOCK
  353. JSR INITNPLR
  354. JMP SHINIT
  355. ATOCK: BIT AUTOPLAY
  356. BPL SHINIT
  357. JSR INITAUTO
  358. JMP SHINIT
  359. SHINIT:
  360. VBLNK: BIT MSTAT ;WAIT FOR V BLANK
  361. BPL VBLNK
  362. BIT MSTAT ;DO WE STILL NEED TWO OF THESE???
  363. BPL VBLNK ;NO
  364. LDA #$50 ;FINALLY TURN ON DMA
  365. STA CTRL
  366. BIT NEWPLYR
  367. BMI JFK
  368. LDA #ALADIN1 ;START TUNE THIS IS BULLSHIT
  369. JSR TUNIN ;COMMENTED OUT CAUSE I CANT STAND IT
  370. LDA #ALADIN0
  371. JSR TUNIN
  372. JFK: LDA #0 ;FLAGS JOB IS DONE SO RESET
  373. STA NEWPLYR
  374. MAINLOOP:
  375. LDA SWCHBIO ;GET CURRENT STATE OF IO
  376. TAY ;TUCK SWCHBIO AWAY FOR NOW
  377. EOR OLDSWCHB
  378. BEQ CONTGAME ;NO CHANGE IN IO SO BRANCH
  379. * CHANGE! IS IT A RESET?
  380. LSR ;CHECK FOR CHANGE IN RESET
  381. BCC PCHKSLCT ;NO CHANGE SO CHECK SELECT
  382. LSR OLDSWCHB ;CHECK OLD RESET BIT IF ZERO
  383. ;THEN WE'VE GOT A RESET
  384. BCS CHEKSLCT ;OTHERWISE CHECK FOR SELECT
  385. ;CARRY CLEAR SO CHANGE IN RESET BIT
  386. ;& OLD VALUE OF ZERO INDICATES A RESET
  387. GOTOGAME: LDX #$7F ;DONT'T TURN OFF COLOR BURST
  388. STX CTRL ;BUT DONT TURN OFF DMA
  389. LDX #$FF
  390. STX TITLMENU ;TURN OFF TITLMENU FLAG
  391. STX GAMEU ;TURN ON GAME FLAG
  392. INX
  393. STX NEWPLYR ;MAKE SURE NEWPLYR IS OFF
  394. STX PAUSE ;TURN OFF ALL OTHER STATE FLAGS
  395. STX HSC ;FOR SECURITY
  396. STX AUTOPLAY
  397. STX DMA
  398. STX GAMEOVR
  399. STX PLAYER ;PLAYER 1 IS FIRST
  400. JMP GAMEDO
  401. * IS IT A SELECT?
  402. PCHKSLCT: LSR OLDSWCHB ;ACCUM. HAS EOR OF SWCHB AND OLDSWCHB
  403. CHEKSLCT: LSR ;CHECK FOR SELECT BIT
  404. BCC PPAWS ;NO SELECT CHECK FOR PAUSE NEXT
  405. LSR OLDSWCHB ;POSSIBLE SELECT CHECK FOR 0 TO 1 TRANS
  406. BCC MENOPAWS ;1 TO 0 TRANSITION SO IGNORE
  407. ;LOOKS LIKE A SELECT TO ME
  408. BIT TITLMENU ;BUT ARE WE ALREADY IN TIT PGE. IF SO
  409. BPL MENOPAWS ;PUNT
  410. GOTOTIT: LDX #0
  411. STX STATIMER ;RESET STATIMER
  412. STX GAMEU ;TURN OFF GAME IF ON
  413. STX NEWPLYR ;TURN OFF NEWPLYR
  414. STX TITLMENU ;TURN ON TITLMENU
  415. STX AUTOPLAY ;TURN OFF AUTOPLAY
  416. STX DMA ;TURN OFF DMA FLAG
  417. STX GAMEOVR ;TURN OFF GAME OVER FLAG IF SET
  418. NEWPLR: LDX #$7F ;SWITCH PLAYERS BUT
  419. STX CTRL
  420. LDX #$FF
  421. TXS ;THIS IS PROBABLY NOT NECESSARY
  422. JMP NEWPLYDO ;GO TO TITLE PAGE
  423. PPAWS: LSR OLDSWCHB
  424. MENOPAWS: LSR ;THIS JUST SETS A FLAG WHICH GAME LOOKS
  425. LSR ;AT. SHIFT TO CHECK PAUSE BIT
  426. BCC CONTGAME
  427. LSR OLDSWCHB ;CHECK TO SEE IF OLD VALUE IS LOW
  428. LSR OLDSWCHB
  429. BCS CONTGAME ;NOT LOW SO PUNT
  430. LDA #$FF ;PAUSE BUTTON HAS BEEN PRESSED
  431. STA PAWSTWID
  432. CONTGAME: STY OLDSWCHB
  433. JMP (STATEPTR) ;JUMP TO APPROPRIATE STATE
  434. * GAME STATE
  435. GAMSTATE: BIT GAMEOVR ;IF OVER BOOGIE ON TO TITLE PAGE
  436. BPL NOGOTIT
  437. LDX #$7F ;WHO THE FUCK KNOWS ANYWAY
  438. STX CTRL
  439. JSR HSPOWNIT
  440. JSR HSGAMOVR
  441. JMP GOTOTIT
  442. NOGOTIT: BIT NEWPLYR ;IF NOT OVER BUT NEW PLAYER RESET
  443. BMI NEWPLR
  444. BIT PAWSTWID
  445. BPL JPDOGAME
  446. ;SET UP PAUSE STATE
  447. LDX #$FF
  448. STX FREEZEP ;TURN ON FREEZE FRAME
  449. LDA #PSESTATE&$FF ;INITIALIZE POINTER TO PAUSE
  450. STA STATEPTR
  451. LDA #PSESTATE/256
  452. STA STATEPTR+1
  453. INX
  454. STX GAMEU ;TURN OFF GAME FLAG
  455. STX PAWSTWID ;TURN OFF PAUSE TWIDDLE
  456. STX AUDV0 ;KILL SOUNDS
  457. STX AUDV1 ;TUNER NEVER CALLED WHEN IN FREEZE MODE
  458. JMP MAINLOOP
  459. JPDOGAME: JMP DOGAME
  460. * PAUSE STATE
  461. PSESTATE:
  462. BIT PAWSTWID
  463. BPL JMNLP ;PAUSE TWIDDLE NOT SET SO JMP MAINLOOP
  464. LDX #$FF ;GO BACK TO GAME STATE
  465. STX GAMEU
  466. INX
  467. STX PAWSTWID
  468. STX FREEZEP ;TURN OFF FREEZE FRAMER
  469. STX PAUSE ;TURN OFF PAUSE
  470. LDA #GAMSTATE&$00FF ;INITIALIZE POINTER FOR GAME STATE
  471. STA STATEPTR
  472. LDA #GAMSTATE/256
  473. STA STATEPTR+1
  474. JMNLP: JMP MAINLOOP
  475. * TIT STATE
  476. TITSTATE: ;ONLY DO IT ONCE A FRAME???
  477. LDA FRMCNT
  478. CMP TITCNT
  479. BEQ JMNLP
  480. LDA FRMCNT
  481. STA TITCNT
  482. DEC OTIMER ;HAVE WE WAITED AFTER INITIAL START
  483. BNE JMNLP ;OF TITLE PAGE
  484. LDA #1 ;HACK TO DEACTIVATE OTIMER
  485. STA OTIMER
  486. BIT LEFTBUT ;CHECK FOR TRIGGER RESET
  487. BMI SLDKFJ
  488. JMP GOTOGAME ;BUTTON PRESSED, SO RESET TO GAME MODE
  489. SLDKFJ: LDA SWCHA ;ANY PLAYER ONE JOYSTICK INPUT RESET
  490. AND #$F0 ;TIMER
  491. CMP #$F0
  492. BEQ NOTIMRST
  493. LDA #0
  494. STA STATIMER
  495. NOTIMRST: LDA SWCHB ;IS SELECT DEPRESSED?
  496. AND #$02
  497. BEQ CHKSTIM ;YES, BRANCH
  498. LDA #$80 ;NO MAKE SURE TIMER ISN'T STARTED
  499. STA STIMER
  500. BMI DIFFCHK ;AND CONTINUE TO OTHER CODE
  501. CHKSTIM: LDA #0 ;IO HAS OCCURRED SO RESET TIT. PGE TIMR
  502. STA STATIMER
  503. LDA #$80 ;BLOW OTHER TIMERS OUT OF THE WATER
  504. STA ETIMER ;SELECT SWITCH HAS PRIORITY OVER
  505. STA WTIMER ;JOYSTICK
  506. BIT STIMER ;HAS TIMER BEEN SET?
  507. BMI CHGSETNG ;NO SO GO AHEAD AND CHANGE SETTING
  508. DEC STIMER ;TIMER IS SET SO DECREMENT IT
  509. BNE JMNLP ;PUNT IF NOT AT ZERO
  510. CHGSETNG: INC DIFCULTY ;CYCLE THROUGH DIFFICULTIES
  511. LDA DIFCULTY
  512. AND #$03
  513. STA DIFCULTY ;Range 0-3
  514. BNE TWIDIL
  515. LDA NUMPLYRS
  516. EOR #$03
  517. STA NUMPLYRS
  518. JSR PLAYTWID
  519. TWIDIL: JSR DIFFTWID
  520. LDA #35
  521. STA STIMER
  522. JMP MAINLOOP
  523. DIFFCHK: LDA SWCHA
  524. AND #$80 ;CHECK EAST BIT
  525. BEQ CHKETIM ;YES
  526. LDA #$80 ;NO, SO ENABLE EAST MOVEMENT
  527. STA ETIMER
  528. BMI CHKWEST
  529. CHKETIM: BIT ETIMER ;IS EAST MOVEMENT ENABLED?
  530. BMI INCDIFF ;YES SO INC DIFFICULTY
  531. DEC ETIMER ;NOT ENABLED SO WE MUST COUNT DOWN
  532. BNE CHKWEST ;AND THEN GO AWAY
  533. INCDIFF: INC DIFCULTY ;INCREMENT DIFFICULTY LEVEL
  534. LDA DIFCULTY
  535. AND #$03
  536. STA DIFCULTY ;Range 0-3
  537. JSR DIFFTWID
  538. LDA #35
  539. STA ETIMER ;DISABLE EAST MOVEMENT AND SET TIMRE
  540. CHKWEST: LDA SWCHA
  541. AND #$40
  542. BEQ CHKWTIM
  543. LDA #$80
  544. STA WTIMER
  545. BMI SELCHK
  546. CHKWTIM: BIT WTIMER
  547. BMI DECDIFF
  548. DEC WTIMER
  549. BNE SELCHK
  550. DECDIFF: DEC DIFCULTY
  551. LDA DIFCULTY
  552. AND #$03
  553. STA DIFCULTY ;Range 0-3
  554. JSR DIFFTWID
  555. LDA #35
  556. STA WTIMER
  557. SELCHK: LDA SWCHA ;CHECK NORTH BIT FOR NUMBER OF PLAYERS
  558. AND #$F0
  559. CMP #$E0 ;SELECT
  560. BNE CHKSOUTH
  561. LDX #2
  562. STX NUMPLYRS ;TWO PLAYERS
  563. JSR PLAYTWID
  564. JMP TIMCHK
  565. CHKSOUTH: ;A STILL HAD SWCHA AND F0
  566. CMP #$D0 ;CHECK SOUTH BIT
  567. BNE TIMCHK ;ACCUMULATOR STILL SET FROM LDA ABOVE
  568. LDX #1
  569. STX NUMPLYRS ;SET NUMBER OF PLAYERS TO ONE
  570. JSR PLAYTWID
  571. TIMCHK: LDA STATIMER ;CHECK FOR TIMEOUT
  572. CMP #4
  573. BNE .MJMP
  574. LDX #$7F ;DONT' TURN OFF COLOR BURST
  575. STX CTRL ;BUT TURN OFF DMA
  576. JSR HSPOWNIT
  577. JSR HSDISP ;DO HIGH SCORE CART DISPLAY
  578. LDX #$7F ;WHEN IN DOUBT TURN OFF CTRL
  579. STX CTRL
  580. LDX #$FF
  581. TXS
  582. STX TITLMENU ;TURN OFF TITLEMENU
  583. STX AUTOPLAY ;TURN ON AUTOPLAY
  584. INX
  585. STX STATIMER ;CLEAR TIMING FLAG
  586. JSR EXTRAINIT ;!!!!!!!!!
  587. JMP NEWPLYDO
  588. .MJMP: JMP MAINLOOP
  589. * AUTOPLAY STATE
  590. ATOSTATE: BIT LEFTBUT ;CHECK FOR TRIGGER RESTART
  591. BMI TIMCHKA
  592. JMP GOTOGAME ;GO TO GAME STATE TRIGGER PRESSED
  593. TIMCHKA: LDA STATIMER ;MORE TIMEOUT CHECKS
  594. CMP #5
  595. BNE CHKSTK
  596. GOTOSEL: JMP GOTOTIT ;DON'T TURN OFF COLOR
  597. CHKSTK: LDA SWCHA ;CHECK FOR SELECT
  598. AND #$F0
  599. CMP #$F0
  600. BNE GOTOSEL
  601. DOGAME: LDA FRMCNT ;MAIN LOOP
  602. SEC
  603. SBC OLDFRM
  604. CMP #2 ;ONLY EXECUTE EVERY OTHER FRAME
  605. BCS DOALL
  606. JSR RANDOM ;DO RANDOM IF NOTHING LEFT TO DO
  607. JMP MAINLOOP
  608. DOALL: LDA FRMCNT ;THIS IS THE MAMA LOOP
  609. STA OLDFRM
  610. INC MAINCNT
  611. BNE DOALL1
  612. LDX PLAYER
  613. ; INC GAMETIME,X
  614. DOALL1:
  615. BIT RUNLOAD
  616. BMI DOALL1
  617. LDA PHASE
  618. BPL .NOFLASH
  619. CMP #$FE
  620. BCC FLASH ;FLASH STARTS AT -3
  621. .NOFLASH: JSR VSCRP
  622. LDA #$80
  623. STA RUNLOAD
  624. JSR ENEMYMCP ;MCP FOR NON-SCROLL RELATED ENEMIES
  625. JSR GRNDMCP ;CALL MCP FOR SCROLLING COUPLED ENEMIES
  626. JSR GAME ;BIRD AND SHOT DRIVER AND OTHER THINGS
  627. JSR ANIMFLEA ;FLEA DRIVER
  628. JSR UWEANIM ;UWE DRIVER
  629. JSR SCRLOAD
  630. JSR DOMINIS
  631. JSR DOSPHINX
  632. JSR DOSXSHTS
  633. JSR DOFIRE
  634. JSR DOHIEROS
  635. JSR NEWBLOCK
  636. JSR LDSCORE ;LOAD SCORE DISPLAY
  637. JSR LDLIVES ;LOAD LIVES DISPLAY
  638. JSR LDTREAS ;LOADS TREASURE DISPLAY
  639. JSR LDHIEROS ;LOAD HEIROGLYPH DISPLAY
  640. * JSR LDPOWER ;LOAD POWER DISPLAY
  641. *****
  642. LDA #0
  643. STA GSCRFLAG
  644. STA GCOARSE
  645. JMP MAINLOOP ;AND AGAIN AND AGAIN
  646. ** FLASH COLORS ON THE SCREEN **
  647. FLASH: DEC PHASE
  648. LDA PHASE
  649. CMP #$C4 ;TIME THE FLASH, -60.
  650. BNE CCFL0
  651. LDX PLAYER
  652. INC RACK,X
  653. LDA #0
  654. STA SVDIST,X
  655. STA SVDIST+2,X
  656. STA SVHDIST,X
  657. STA SVHDIST+2,X
  658. LDA #$FF
  659. STA NEWPLYR
  660. JSR ENDBONUS
  661. LDA #0
  662. STA PHASE
  663. JMP MAINLOOP
  664. * SET RANDOM COLORS INTO ALL PALLETTES *
  665. CCFL0: LDX #$1F
  666. CCFL1:
  667. JSR RANDOM
  668. STA BACKGRND,X
  669. CCFL2: DEX
  670. BMI FNOMORE
  671. TXA
  672. AND #3
  673. BNE CCFL1
  674. BEQ CCFL2
  675. FNOMORE:
  676. JSR RANDOM
  677. STA BACKCOL
  678. JMP MAINLOOP
  679. RANDOM: ADC FRMCNT ;RANDOM NUMBER GENERATOR
  680. ADC RNDOM
  681. ADC RNDOM1
  682. PHA
  683. LDA RNDOM
  684. STA RNDOM1
  685. PLA
  686. STA RNDOM
  687. clc
  688. RTS
  689. * DOALLIO MAPS HARDWARE FIREBUTTON INTO SOFTWARE REGS. SAME FOR
  690. * SWCHB. COMPLEMENTS OF ETHAN
  691. DOALLIO:
  692. LDA SWCHA ;FOR TRIGGERING BREAKPOINTS. WILL BE
  693. ;MADE INTO MECHANISM TO STUFF SOFTWARE
  694. ;REGISTERS
  695. LDA SWCHB ;GET SWCHB FOR RESETS AND SUCH
  696. AND #$0B
  697. STA SWCHBIO
  698. CKJOY: LDX #1 ;DO PLAYERS 1 AND 0
  699. ZNXTRJ: JSR READJOY ;READ HIS JOYSTICK
  700. DEX
  701. BPL ZNXTRJ
  702. RTS
  703. * READJOY: READ JOYSTICK/BUTTONS. ON ENTRY X = PLAYER. Y GETS TRASHED
  704. READJOY: LDY INPT4,X
  705. BPL GOTONE ;IF BIT 7 IS LO, OLD-STYLE BUTTON HIT
  706. LDA ONEBUT ;ARE WE ALREADY IN OLD-STYLE MODE?
  707. AND RJBITS,X
  708. BNE GOTONE2 ;YES. GO RIGHT TO ONE-BUTTON HANDLER.
  709. TXA ;OTHERWISE, COMPUTE INDEX INTO
  710. ASL ; PADDLE PORTS, FOR PLAYER X,
  711. TAY ; IN Y (X * 2)
  712. LDA INPT4L,Y ;READ LEFT BUTTON
  713. EOR #$FF ;INVERT SENSE
  714. STA LEFTBUT,X
  715. LDA INPT4R,Y ; RIGHT BUTTON
  716. EOR #$FF ;INVERT SENSE
  717. RJSTORE: STA RIGHTBUT,X
  718. RJRTS: RTS
  719. ;HERE ON OLD-STYLE SINGLE BUTTON JOYSTICK PRESS.
  720. GOTONE: LDA ONEBUT ;SET ONE-BUTTON MODE IMMEDIATELY
  721. ORA RJBITS,X ; TO AVOID DESTROYING HARDWARE!
  722. STA SWCHB
  723. STA ONEBUT ;UPDATE ONE BUTTON FLAG BYTE
  724. ;HERE ON ANY OLD-STYLE JOYSTICK, WHETHER PRESSED OR NOT
  725. GOTONE2: TYA
  726. STA LEFTBUT,X ; (Y CONTAINS CURRENT VALUE OF INPT4)
  727. STA RIGHTBUT,X ;CLEAR RIGHT BUTTON COPY
  728. RTS
  729. RJBITS: .dc.b $04,$10 ;MASK OF "ONE-BUTTON" BITS PER PLAYER
  730. RTS
  731. * PUT ZEROS AT THE END OF EACH DISPLAY LIST
  732. DOZEROS: TXA
  733. PHA
  734. TYA
  735. PHA
  736. LDA #0 ;STORE ZEROES AT END OF DLISTS
  737. TAX ;TRADE ROM FOR TIME
  738. LDY #1 ;TWO ZEROS EACH
  739. STA (ZNDLPOS,X)
  740. STA (ZNDLPOS),Y
  741. STA (ZNDLPOS+2,X)
  742. STA (ZNDLPOS+2),Y
  743. STA (ZNDLPOS+4,X)
  744. STA (ZNDLPOS+4),Y
  745. STA (ZNDLPOS+6,X)
  746. STA (ZNDLPOS+6),Y
  747. STA (ZNDLPOS+8,X)
  748. STA (ZNDLPOS+8),Y
  749. STA (ZNDLPOS+10,X)
  750. STA (ZNDLPOS+10),Y
  751. STA (ZNDLPOS+12,X)
  752. STA (ZNDLPOS+12),Y
  753. STA (ZNDLPOS+14,X)
  754. STA (ZNDLPOS+14),Y
  755. STA (ZNDLPOS+16,X)
  756. STA (ZNDLPOS+16),Y
  757. STA (ZNDLPOS+18,X)
  758. STA (ZNDLPOS+18),Y
  759. STA (ZNDLPOS+20,X)
  760. STA (ZNDLPOS+20),Y
  761. STA (ZNDLPOS+22,X)
  762. STA (ZNDLPOS+22),Y
  763. PLA
  764. TAY
  765. PLA
  766. TAX
  767. RTS