123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971 |
- * SPHINX--SKERNEL.S
- ; ZERODEF
- ; RSEG CODE9
- *************** ALL DLI'S MUST START ON SAME PAGE!!!!!! ***********
- * DLITOP ;FIRST DLI TAKES PLACE AT TOP OF SCREEN
- DLITOP: ;SAVE REGISTERS
- PHA ;A,X,Y USED
- TXA
- PHA
- TYA
- PHA
- LDA #$50 ;RESTORE CTRL TO ITS OWN STATE
- STA CTRL
- LDA P0C2SHAD ;RESTUFF PALETTES FOR GAME SCREEN
- STA P0C2 ;SHOULD PROBABLY BE DONE WITH SHADOWS
- LDA P1C2SHAD
- STA P1C2 ;5/25/84
- LDA P2C2SHAD
- STA P2C2
- LDA P5C2SHAD ;TO UNDO OTHER HACK JEM: 5/14/84
- STA P5C2
- CLD ;RANDOM IS CALLED HERE, SO CLD
- ; BIT FUCKFLAG ;PUT THESE BACK TO SEE IF LOADER IS
- ; BPL FINE ;INTERRUPTED BY THIS DLI
- ; GOTCHA NOP
- ;REMEMBER THIS DLI HAPPENS EARLIER NOW!
- FINE: LDA DLZDEST ;CHANGE DLIPTR
- STA DLIPTR
- JSR RANDOM ;RANDOM NUMBER GENERATOR
- STA WSYNC
- LDA BACKCOL ;TURN ON BACKGROUND COLOR
- STA BACKGRND
- BIT FUCKFLAG
- BPL DONTFUCK
- JSR DOZEROS ;PUT ZEROS AT END OF DISPLAY LISTS
- DONTFUCK: PLA ;RESTORE REGISTERS
- TAY
- PLA
- TAX
- PLA
- RTI
- * DLIZ11 ;THIS MUST BE DONE AT END OF ZONE10 TO
- * SET CHARBASE FOR ZONE11. POTENTIALLY A SHORT ZONE AND MAY BE FOLLOWED BY ONE
- DLIZ11:
- PHA
- LDA D11CBASE
- STA WSYNC ;WAIT UNTIL END OF ZONE 10
- STA CHARBASE
- LDA #DLIBOT&$FF
- ;DMA SHOULD KICK IN HERE
- STA DLIPTR ;NEED TO HAVE TIME TO DO THIS STORE
- PLA
- RTI
- * DLISNCTT SYNCING DLI FOR TITLE PAGE
- DLISNCTT:
- PHA
- LDA #DLITIT&$FF
- JMP SYNCSAME
- * DLISYNC SYNCING DLI FOR REGULAR SCREEN
- DLISYNC: ;THIS IS THE SYNCIN' DLI
- PHA ;ARE WE SURE THIS IS CORRECT??
- LDA #DLITOP&$00FF
- SYNCSAME: STA WSYNC
- STA WSYNC ;THIS SHOULD BE END OF KERNEL
- BIT MSTAT
- BPL UNSYNC ;PUNT IF IN KERNEL
- BIT MSTAT
- BPL UNSYNC
- STA DLIPTR
- UNSYNC:
- PLA
- RTI
- * DLZ11A ;ALTRNTE. DLI HANDLER FOR 1 LINE ZONE11
- DLZ11A:
- PHA
- LDA D11CBASE
- STA WSYNC ;WSYNC TO FINISH ZONE 10
- STA CHARBASE ;NEW CHARBASE FOR ZONE 11
- * THIS IS FUNCTIONALITY OF DLIBOT WHICH IS SKIPPED WHEN ZONE11 IS 1 HIGH
- LDA #DLISYNC&$00FF
- STA DLIPTR
- STA WSYNC ;THIS SHOULD FINISH ZONE 11
- LDA #CHARS/256
- STA CHARBASE ;THIS IS CHARBASE FOR SCORE
- LDA #$43
- STA WSYNC
- STA CTRL ;CTROL VALUE FOR 320 MODE
- LDA #0 ;BLACK BACKGROUND
- STA BACKGRND
- JMP NOWLOAD
- * DLITIT TITLE PAGE DLI
- DLITIT: ;ALL THESE REGISTERS MAY NOT HAVE TO
- PHA ;BE SAVED
- TXA
- PHA
- TYA
- PHA
- LDA #TITCHR1/256
- STA CHARBASE
- LDA #$50 ;COMMENT
- STA CTRL
- JSR DOALLIO
- INC FRMCNT
- BNE SHITT
- INC STATIMER
- SHITT:
- LDA #DLITIT2&$FF
- STA DLIPTR
- LDA #DLITIT2/256
- STA DLIPTR+1
- PLA
- TAY
- PLA
- TAX
- PLA
- RTI
- * DLITIT2 ;SETS CHARBASE FOR CHAR FONT AT BOTTOM
- DLITIT2: ;SECOND TITLE PAGE DLI
- PHA
- LDA #CHARS/256
- STA CHARBASE
- LDA #$43
- STA CTRL
- LDA #DLISNCTT&$00FF
- STA DLIPTR
- LDA #DLISNCTT/256
- STA DLIPTR+1
- PLA
- RTI
- * DLIBOT ;THIS MUST BE DONE IN DLI AT END OF
- DLIBOT: ;REGULAR ZONES
- PHA
- ;DLI TO CHANGE BACKGROUND COLOR
- LDA #CHARS/256
- STA CHARBASE
- STA WSYNC ;THIS SHOULD FINISH ZONE 11
- LDA #DLISYNC&$00FF
- STA DLIPTR
- LDA #$43 ;CTRL FOR 320 MODE
- STA WSYNC
- STA CTRL
- LDA #0 ;BLACKGROUND
- STA BACKGRND
- NOWLOAD:
- * COLOR CHANGES FOR BOTTOM OF SCREEN DISPLAY
- LDA #$06 ;THESE ARE HARDWIRED NOT THE ONES AT
- STA P5C2 ;TOP OF SCREEN
- LDA P1C2SHDB ;SHADOW NEEDED HERE
- STA P1C2 ;FOR TOPMSMAP
- LDA #$3E
- STA P2C2 ;FOR BOTMSMAP
- LDA #$EF
- STA P0C2 ;FOR SCORE AND XTRA LIVES
- TXA
- PHA
- TYA
- PHA
- CLD ;ONLY NEEDED FOR DLI'S WHICH ADD OR SUB
- * FREEZE FRAMER
- FRZFRMR: BIT FREEZEP
- BPL DOTODO
- LDA PERIOD
- beq .toNothing
- DEC NEXFRAME
- beq .ok1
- .toNothing: jmp NOTHING
- .ok1:
- STA NEXFRAME
- LDX HOWMANY
- BEQ DOTODO
- DEX
- STX HOWMANY
- BNE DOTODO
- LDX #0
- STX PERIOD
- INX
- STX NEXFRAME
- DOTODO: INC FRMCNT ;GO FOR FRMCNT
- BNE BLAH
- INC STATIMER ;IT IS TWO BYTES
- BLAH: lda ENDCOUNT
- beq .skip
- dec ENDCOUNT
- .skip:
- DEC SECOND ;SECOND COUNTER
- BPL NOTSECND
- LDA #59 ;START NEXT SECOND
- STA SECOND
- LDA PHASE ;TIME THE BONUS RACK
- CMP #$FE
- BNE NOTBONUS ;NOT IN BONUS RACK
- SED
- LDA BNSTIMER
- SEC
- SBC #1
- STA BNSTIMER
- CLD
- BNE NOTBONUS ;NOT DONE WITH BONUS
- JSR LDTREAS ;DISPLAY ZERO SECONDS
- DEC PHASE ;GOTO FLASH PHASE
- LDA #FLASHT0
- JSR TUNIN
- LDA #FLASHT1
- JSR TUNIN
- NOTBONUS:
- LDA PTIMER ;POWER TIMER
- BEQ .ok1
- jsr decTimer ;Decrement power timer and flash power.
- jmp NOTSECND
- .ok1: ldx PLAYER
- lda RACK,x ;Round one?
- bne NOTSECND ;Only give help message in round 1.
- lda DIFCULTY ;Novice or Standard game?
- cmp #2
- bcs NOTSECND ;Only give help in Novice and Standard.
- lda PGPOWER,x ;Does player currently have a power?
- bne .ok2
- lda #$1F ;Flash "GET 3 HIERO" message.
- sta ROTATE
- .ok2:
- NOTSECND: LDA FRMCNT ;DISPATCH ON ODD OR EVEN
- LSR
- BCC DOTUNE
- DOLOAD: BIT RUNLOAD
- BPL DOTUNE
- JSR SCROLL ;ON ODD, SCROL CMAPS AND RUN LOADER
- JSR LOADER
- LDA #0
- STA RUNLOAD
- DOTUNE: JSR TUNER ;TUNE DRIVER
- JSR RUNBACK ;UPDATE BACKGROUND TUNE
- JSR BACKON ;CHECK TO PUT ON BACKGOUND TUNE. IF
- ;SO, SWAP IT IN
- NOTHING:
- JSR DOALLIO
- INTEROUT:
- PLA ;RESTORE REGISTERS
- TAY
- PLA
- TAX
- PLA
- RTI
- ZERO = 0
- DLIHSC0:
- PHA
- TXA
- PHA
- TYA
- PHA
- ;DO COLORS, CHARBASE, AND CONTROL
- LDA #TITCHR1/256
- STA CHARBASE
- LDA #$50
- STA CTRL
- LDA #DLIHSC1&$FF ;SAME PAGE I HOPE
- STA DLIPTR
- LDA #$0F
- STA P0C2
- LDA #$3A
- STA P1C2
- LDA #$00
- STA P2C2
- LDA #$10
- STA P3C2
- LDA #$37
- STA P4C2
- JSR TUNER ;RUN THE TUNES
- PLA
- TAY
- PLA
- TAX
- PLA
- RTI
- DLIHSC1:
- PHA
- TXA
- PHA
- TYA
- PHA
- LDA #DLIHSC0&$00FF
- STA DLIPTR
- JSR HSCSETRS ;RESETS WAT'S REG'S
- JMP INTEROUT
- ********************************************************************************
- * *
- * STARTUP *
- * *
- ********************************************************************************
- STARTUP: SEI ;HARDWARE DEPENDENT INITS
- CLD
- ; LDA #$07 ;LOCK ME IN MARIA MODE
- LDA #$87 ;PUT THIS IN WHEN WE HAVE 2BUT HARDWARE
- STA $1
- LDA #0 ;FOR FUTURE EXPANSION AND IMPERIALISM
- STA OFFSET
- LDX #$FF ;STACK POINTER AT $1FF
- TXS
- LDX #$7F ;KEEP COLOR BURST ON
- STX CTRL ;TURN OFF DMA
- LDY #$FF ;zero out zero page
- ZERLOOP:
- CPY #CTRL ;DON'T STORE TO CTRL AGAIN
- BEQ NOSTOR ;TO AVOID TURNING ON DMA
- STA ZERO,Y
- NOSTOR: DEY
- BNE ZERLOOP
- LDA #0 ;ENOUGH TIME HAS ELAPSED TO ALLOW CAPS
- STA $1 ;TO DISCHARGE SO CONTINUE FUCKING WITH
- LDA #$14 ;IO HARDWARE
- STA CTLSWB
- LDA #0 ;SELECT TWO BUTTON MODE
- STA SWCHB
- LDX #$40 ;POWER UP GETS THIS ONE
- LDA #0
- LEVEL1LP: STA ZERO,X
- INX
- BNE LEVEL1LP
- JSR PREINIT ;THIS SETS UP THE POWER UP DEFAULT
- JSR INITIT
- ;MODES FOR THE GAME
- JMP VBLNK
- GAMEDO: ;RESETS GO TO HERE
- LDX #FUTEXP1
- LDA #0
- LEVEL2LP: STA ZERO,X
- INX
- BNE LEVEL2LP
- ;
- JSR TOTINIT
- JSR MCPINIT ;TAKEN OUT OF TOTINIT
- JSR TOTINIT2
- ;
- BIT GAMEU
- BPL SHINIT
- ;
- JSR INITGAME
- JMP SHINIT
- NEWPLYDO: ;AUTOPLAY GOES HERE
- LDX #FUTEXP3 ;!!!!!!!!!
- LDA #0
- LEVEL3LP: STA ZERO,X
- INX
- BNE LEVEL3LP
- JSR TOTINIT
- JSR TOTINIT2
- ;
- BIT TITLMENU ;TITLMENU?
- BMI CKPLR
- JSR INITIT ;YES, JSR INITIT AND CONTINUE
- JMP VBLNK
- CKPLR: BIT NEWPLYR
- BPL ATOCK
- JSR INITNPLR
- JMP SHINIT
- ATOCK: BIT AUTOPLAY
- BPL SHINIT
- JSR INITAUTO
- JMP SHINIT
- SHINIT:
- VBLNK: BIT MSTAT ;WAIT FOR V BLANK
- BPL VBLNK
- BIT MSTAT ;DO WE STILL NEED TWO OF THESE???
- BPL VBLNK ;NO
- LDA #$50 ;FINALLY TURN ON DMA
- STA CTRL
- BIT NEWPLYR
- BMI JFK
- LDA #ALADIN1 ;START TUNE THIS IS BULLSHIT
- JSR TUNIN ;COMMENTED OUT CAUSE I CANT STAND IT
- LDA #ALADIN0
- JSR TUNIN
- JFK: LDA #0 ;FLAGS JOB IS DONE SO RESET
- STA NEWPLYR
- MAINLOOP:
- LDA SWCHBIO ;GET CURRENT STATE OF IO
- TAY ;TUCK SWCHBIO AWAY FOR NOW
- EOR OLDSWCHB
- BEQ CONTGAME ;NO CHANGE IN IO SO BRANCH
- * CHANGE! IS IT A RESET?
- LSR ;CHECK FOR CHANGE IN RESET
- BCC PCHKSLCT ;NO CHANGE SO CHECK SELECT
- LSR OLDSWCHB ;CHECK OLD RESET BIT IF ZERO
- ;THEN WE'VE GOT A RESET
- BCS CHEKSLCT ;OTHERWISE CHECK FOR SELECT
- ;CARRY CLEAR SO CHANGE IN RESET BIT
- ;& OLD VALUE OF ZERO INDICATES A RESET
- GOTOGAME: LDX #$7F ;DONT'T TURN OFF COLOR BURST
- STX CTRL ;BUT DONT TURN OFF DMA
- LDX #$FF
- STX TITLMENU ;TURN OFF TITLMENU FLAG
- STX GAMEU ;TURN ON GAME FLAG
- INX
- STX NEWPLYR ;MAKE SURE NEWPLYR IS OFF
- STX PAUSE ;TURN OFF ALL OTHER STATE FLAGS
- STX HSC ;FOR SECURITY
- STX AUTOPLAY
- STX DMA
- STX GAMEOVR
- STX PLAYER ;PLAYER 1 IS FIRST
- JMP GAMEDO
- * IS IT A SELECT?
- PCHKSLCT: LSR OLDSWCHB ;ACCUM. HAS EOR OF SWCHB AND OLDSWCHB
- CHEKSLCT: LSR ;CHECK FOR SELECT BIT
- BCC PPAWS ;NO SELECT CHECK FOR PAUSE NEXT
- LSR OLDSWCHB ;POSSIBLE SELECT CHECK FOR 0 TO 1 TRANS
- BCC MENOPAWS ;1 TO 0 TRANSITION SO IGNORE
- ;LOOKS LIKE A SELECT TO ME
- BIT TITLMENU ;BUT ARE WE ALREADY IN TIT PGE. IF SO
- BPL MENOPAWS ;PUNT
- GOTOTIT: LDX #0
- STX STATIMER ;RESET STATIMER
- STX GAMEU ;TURN OFF GAME IF ON
- STX NEWPLYR ;TURN OFF NEWPLYR
- STX TITLMENU ;TURN ON TITLMENU
- STX AUTOPLAY ;TURN OFF AUTOPLAY
- STX DMA ;TURN OFF DMA FLAG
- STX GAMEOVR ;TURN OFF GAME OVER FLAG IF SET
- NEWPLR: LDX #$7F ;SWITCH PLAYERS BUT
- STX CTRL
- LDX #$FF
- TXS ;THIS IS PROBABLY NOT NECESSARY
- JMP NEWPLYDO ;GO TO TITLE PAGE
- PPAWS: LSR OLDSWCHB
- MENOPAWS: LSR ;THIS JUST SETS A FLAG WHICH GAME LOOKS
- LSR ;AT. SHIFT TO CHECK PAUSE BIT
- BCC CONTGAME
- LSR OLDSWCHB ;CHECK TO SEE IF OLD VALUE IS LOW
- LSR OLDSWCHB
- BCS CONTGAME ;NOT LOW SO PUNT
- LDA #$FF ;PAUSE BUTTON HAS BEEN PRESSED
- STA PAWSTWID
- CONTGAME: STY OLDSWCHB
- JMP (STATEPTR) ;JUMP TO APPROPRIATE STATE
- * GAME STATE
- GAMSTATE: BIT GAMEOVR ;IF OVER BOOGIE ON TO TITLE PAGE
- BPL NOGOTIT
- LDX #$7F ;WHO THE FUCK KNOWS ANYWAY
- STX CTRL
- JSR HSPOWNIT
- JSR HSGAMOVR
- JMP GOTOTIT
- NOGOTIT: BIT NEWPLYR ;IF NOT OVER BUT NEW PLAYER RESET
- BMI NEWPLR
- BIT PAWSTWID
- BPL JPDOGAME
- ;SET UP PAUSE STATE
- LDX #$FF
- STX FREEZEP ;TURN ON FREEZE FRAME
- LDA #PSESTATE&$FF ;INITIALIZE POINTER TO PAUSE
- STA STATEPTR
- LDA #PSESTATE/256
- STA STATEPTR+1
- INX
- STX GAMEU ;TURN OFF GAME FLAG
- STX PAWSTWID ;TURN OFF PAUSE TWIDDLE
- STX AUDV0 ;KILL SOUNDS
- STX AUDV1 ;TUNER NEVER CALLED WHEN IN FREEZE MODE
- JMP MAINLOOP
- JPDOGAME: JMP DOGAME
- * PAUSE STATE
- PSESTATE:
- BIT PAWSTWID
- BPL JMNLP ;PAUSE TWIDDLE NOT SET SO JMP MAINLOOP
- LDX #$FF ;GO BACK TO GAME STATE
- STX GAMEU
- INX
- STX PAWSTWID
- STX FREEZEP ;TURN OFF FREEZE FRAMER
- STX PAUSE ;TURN OFF PAUSE
- LDA #GAMSTATE&$00FF ;INITIALIZE POINTER FOR GAME STATE
- STA STATEPTR
- LDA #GAMSTATE/256
- STA STATEPTR+1
- JMNLP: JMP MAINLOOP
- * TIT STATE
- TITSTATE: ;ONLY DO IT ONCE A FRAME???
- LDA FRMCNT
- CMP TITCNT
- BEQ JMNLP
- LDA FRMCNT
- STA TITCNT
- DEC OTIMER ;HAVE WE WAITED AFTER INITIAL START
- BNE JMNLP ;OF TITLE PAGE
- LDA #1 ;HACK TO DEACTIVATE OTIMER
- STA OTIMER
- BIT LEFTBUT ;CHECK FOR TRIGGER RESET
- BMI SLDKFJ
- JMP GOTOGAME ;BUTTON PRESSED, SO RESET TO GAME MODE
- SLDKFJ: LDA SWCHA ;ANY PLAYER ONE JOYSTICK INPUT RESET
- AND #$F0 ;TIMER
- CMP #$F0
- BEQ NOTIMRST
- LDA #0
- STA STATIMER
- NOTIMRST: LDA SWCHB ;IS SELECT DEPRESSED?
- AND #$02
- BEQ CHKSTIM ;YES, BRANCH
- LDA #$80 ;NO MAKE SURE TIMER ISN'T STARTED
- STA STIMER
- BMI DIFFCHK ;AND CONTINUE TO OTHER CODE
- CHKSTIM: LDA #0 ;IO HAS OCCURRED SO RESET TIT. PGE TIMR
- STA STATIMER
- LDA #$80 ;BLOW OTHER TIMERS OUT OF THE WATER
- STA ETIMER ;SELECT SWITCH HAS PRIORITY OVER
- STA WTIMER ;JOYSTICK
- BIT STIMER ;HAS TIMER BEEN SET?
- BMI CHGSETNG ;NO SO GO AHEAD AND CHANGE SETTING
- DEC STIMER ;TIMER IS SET SO DECREMENT IT
- BNE JMNLP ;PUNT IF NOT AT ZERO
- CHGSETNG: INC DIFCULTY ;CYCLE THROUGH DIFFICULTIES
- LDA DIFCULTY
- AND #$03
- STA DIFCULTY ;Range 0-3
- BNE TWIDIL
- LDA NUMPLYRS
- EOR #$03
- STA NUMPLYRS
- JSR PLAYTWID
- TWIDIL: JSR DIFFTWID
- LDA #35
- STA STIMER
- JMP MAINLOOP
- DIFFCHK: LDA SWCHA
- AND #$80 ;CHECK EAST BIT
- BEQ CHKETIM ;YES
- LDA #$80 ;NO, SO ENABLE EAST MOVEMENT
- STA ETIMER
- BMI CHKWEST
- CHKETIM: BIT ETIMER ;IS EAST MOVEMENT ENABLED?
- BMI INCDIFF ;YES SO INC DIFFICULTY
- DEC ETIMER ;NOT ENABLED SO WE MUST COUNT DOWN
- BNE CHKWEST ;AND THEN GO AWAY
- INCDIFF: INC DIFCULTY ;INCREMENT DIFFICULTY LEVEL
- LDA DIFCULTY
- AND #$03
- STA DIFCULTY ;Range 0-3
- JSR DIFFTWID
- LDA #35
- STA ETIMER ;DISABLE EAST MOVEMENT AND SET TIMRE
- CHKWEST: LDA SWCHA
- AND #$40
- BEQ CHKWTIM
- LDA #$80
- STA WTIMER
- BMI SELCHK
- CHKWTIM: BIT WTIMER
- BMI DECDIFF
- DEC WTIMER
- BNE SELCHK
- DECDIFF: DEC DIFCULTY
- LDA DIFCULTY
- AND #$03
- STA DIFCULTY ;Range 0-3
- JSR DIFFTWID
- LDA #35
- STA WTIMER
- SELCHK: LDA SWCHA ;CHECK NORTH BIT FOR NUMBER OF PLAYERS
- AND #$F0
- CMP #$E0 ;SELECT
- BNE CHKSOUTH
- LDX #2
- STX NUMPLYRS ;TWO PLAYERS
- JSR PLAYTWID
- JMP TIMCHK
- CHKSOUTH: ;A STILL HAD SWCHA AND F0
- CMP #$D0 ;CHECK SOUTH BIT
- BNE TIMCHK ;ACCUMULATOR STILL SET FROM LDA ABOVE
- LDX #1
- STX NUMPLYRS ;SET NUMBER OF PLAYERS TO ONE
- JSR PLAYTWID
- TIMCHK: LDA STATIMER ;CHECK FOR TIMEOUT
- CMP #4
- BNE .MJMP
- LDX #$7F ;DONT' TURN OFF COLOR BURST
- STX CTRL ;BUT TURN OFF DMA
- JSR HSPOWNIT
- JSR HSDISP ;DO HIGH SCORE CART DISPLAY
- LDX #$7F ;WHEN IN DOUBT TURN OFF CTRL
- STX CTRL
- LDX #$FF
- TXS
- STX TITLMENU ;TURN OFF TITLEMENU
- STX AUTOPLAY ;TURN ON AUTOPLAY
- INX
- STX STATIMER ;CLEAR TIMING FLAG
- JSR EXTRAINIT ;!!!!!!!!!
- JMP NEWPLYDO
- .MJMP: JMP MAINLOOP
- * AUTOPLAY STATE
- ATOSTATE: BIT LEFTBUT ;CHECK FOR TRIGGER RESTART
- BMI TIMCHKA
- JMP GOTOGAME ;GO TO GAME STATE TRIGGER PRESSED
- TIMCHKA: LDA STATIMER ;MORE TIMEOUT CHECKS
- CMP #5
- BNE CHKSTK
- GOTOSEL: JMP GOTOTIT ;DON'T TURN OFF COLOR
- CHKSTK: LDA SWCHA ;CHECK FOR SELECT
- AND #$F0
- CMP #$F0
- BNE GOTOSEL
- DOGAME: LDA FRMCNT ;MAIN LOOP
- SEC
- SBC OLDFRM
- CMP #2 ;ONLY EXECUTE EVERY OTHER FRAME
- BCS DOALL
- JSR RANDOM ;DO RANDOM IF NOTHING LEFT TO DO
- JMP MAINLOOP
- DOALL: LDA FRMCNT ;THIS IS THE MAMA LOOP
- STA OLDFRM
- INC MAINCNT
- BNE DOALL1
- LDX PLAYER
- ; INC GAMETIME,X
- DOALL1:
- BIT RUNLOAD
- BMI DOALL1
- LDA PHASE
- BPL .NOFLASH
- CMP #$FE
- BCC FLASH ;FLASH STARTS AT -3
- .NOFLASH: JSR VSCRP
- LDA #$80
- STA RUNLOAD
- JSR ENEMYMCP ;MCP FOR NON-SCROLL RELATED ENEMIES
- JSR GRNDMCP ;CALL MCP FOR SCROLLING COUPLED ENEMIES
- JSR GAME ;BIRD AND SHOT DRIVER AND OTHER THINGS
- JSR ANIMFLEA ;FLEA DRIVER
- JSR UWEANIM ;UWE DRIVER
- JSR SCRLOAD
- JSR DOMINIS
- JSR DOSPHINX
- JSR DOSXSHTS
- JSR DOFIRE
- JSR DOHIEROS
- JSR NEWBLOCK
- JSR LDSCORE ;LOAD SCORE DISPLAY
- JSR LDLIVES ;LOAD LIVES DISPLAY
- JSR LDTREAS ;LOADS TREASURE DISPLAY
- JSR LDHIEROS ;LOAD HEIROGLYPH DISPLAY
- * JSR LDPOWER ;LOAD POWER DISPLAY
- *****
- LDA #0
- STA GSCRFLAG
- STA GCOARSE
- JMP MAINLOOP ;AND AGAIN AND AGAIN
- ** FLASH COLORS ON THE SCREEN **
- FLASH: DEC PHASE
- LDA PHASE
- CMP #$C4 ;TIME THE FLASH, -60.
- BNE CCFL0
- LDX PLAYER
- INC RACK,X
- LDA #0
- STA SVDIST,X
- STA SVDIST+2,X
- STA SVHDIST,X
- STA SVHDIST+2,X
- LDA #$FF
- STA NEWPLYR
- JSR ENDBONUS
- LDA #0
- STA PHASE
- JMP MAINLOOP
- * SET RANDOM COLORS INTO ALL PALLETTES *
- CCFL0: LDX #$1F
- CCFL1:
- JSR RANDOM
- STA BACKGRND,X
- CCFL2: DEX
- BMI FNOMORE
- TXA
- AND #3
- BNE CCFL1
- BEQ CCFL2
- FNOMORE:
- JSR RANDOM
- STA BACKCOL
- JMP MAINLOOP
- RANDOM: ADC FRMCNT ;RANDOM NUMBER GENERATOR
- ADC RNDOM
- ADC RNDOM1
- PHA
- LDA RNDOM
- STA RNDOM1
- PLA
- STA RNDOM
- clc
- RTS
- * DOALLIO MAPS HARDWARE FIREBUTTON INTO SOFTWARE REGS. SAME FOR
- * SWCHB. COMPLEMENTS OF ETHAN
- DOALLIO:
- LDA SWCHA ;FOR TRIGGERING BREAKPOINTS. WILL BE
- ;MADE INTO MECHANISM TO STUFF SOFTWARE
- ;REGISTERS
- LDA SWCHB ;GET SWCHB FOR RESETS AND SUCH
- AND #$0B
- STA SWCHBIO
- CKJOY: LDX #1 ;DO PLAYERS 1 AND 0
- ZNXTRJ: JSR READJOY ;READ HIS JOYSTICK
- DEX
- BPL ZNXTRJ
- RTS
- * READJOY: READ JOYSTICK/BUTTONS. ON ENTRY X = PLAYER. Y GETS TRASHED
- READJOY: LDY INPT4,X
- BPL GOTONE ;IF BIT 7 IS LO, OLD-STYLE BUTTON HIT
- LDA ONEBUT ;ARE WE ALREADY IN OLD-STYLE MODE?
- AND RJBITS,X
- BNE GOTONE2 ;YES. GO RIGHT TO ONE-BUTTON HANDLER.
- TXA ;OTHERWISE, COMPUTE INDEX INTO
- ASL ; PADDLE PORTS, FOR PLAYER X,
- TAY ; IN Y (X * 2)
- LDA INPT4L,Y ;READ LEFT BUTTON
- EOR #$FF ;INVERT SENSE
- STA LEFTBUT,X
- LDA INPT4R,Y ; RIGHT BUTTON
- EOR #$FF ;INVERT SENSE
- RJSTORE: STA RIGHTBUT,X
- RJRTS: RTS
- ;HERE ON OLD-STYLE SINGLE BUTTON JOYSTICK PRESS.
- GOTONE: LDA ONEBUT ;SET ONE-BUTTON MODE IMMEDIATELY
- ORA RJBITS,X ; TO AVOID DESTROYING HARDWARE!
- STA SWCHB
- STA ONEBUT ;UPDATE ONE BUTTON FLAG BYTE
- ;HERE ON ANY OLD-STYLE JOYSTICK, WHETHER PRESSED OR NOT
- GOTONE2: TYA
- STA LEFTBUT,X ; (Y CONTAINS CURRENT VALUE OF INPT4)
- STA RIGHTBUT,X ;CLEAR RIGHT BUTTON COPY
- RTS
- RJBITS: .dc.b $04,$10 ;MASK OF "ONE-BUTTON" BITS PER PLAYER
- RTS
- * PUT ZEROS AT THE END OF EACH DISPLAY LIST
- DOZEROS: TXA
- PHA
- TYA
- PHA
- LDA #0 ;STORE ZEROES AT END OF DLISTS
- TAX ;TRADE ROM FOR TIME
- LDY #1 ;TWO ZEROS EACH
- STA (ZNDLPOS,X)
- STA (ZNDLPOS),Y
- STA (ZNDLPOS+2,X)
- STA (ZNDLPOS+2),Y
- STA (ZNDLPOS+4,X)
- STA (ZNDLPOS+4),Y
- STA (ZNDLPOS+6,X)
- STA (ZNDLPOS+6),Y
- STA (ZNDLPOS+8,X)
- STA (ZNDLPOS+8),Y
- STA (ZNDLPOS+10,X)
- STA (ZNDLPOS+10),Y
- STA (ZNDLPOS+12,X)
- STA (ZNDLPOS+12),Y
- STA (ZNDLPOS+14,X)
- STA (ZNDLPOS+14),Y
- STA (ZNDLPOS+16,X)
- STA (ZNDLPOS+16),Y
- STA (ZNDLPOS+18,X)
- STA (ZNDLPOS+18),Y
- STA (ZNDLPOS+20,X)
- STA (ZNDLPOS+20),Y
- STA (ZNDLPOS+22,X)
- STA (ZNDLPOS+22),Y
- PLA
- TAY
- PLA
- TAX
- RTS
|