123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- ; GOD.S
- ; THIS ROUTINE IS THE MAIN GAME LOOP, JUMPED TO FROM "MAIN" RIGHT
- ; AFTER ALL THE POWERUP INITIALIZATION IS DONE. IT
- ; TESTS THE "MODE" VARIABLE AND DECIDES WHICH MINOR GOD OR
- ; GODDESS ROUTINE TO JUMP TO ACCORDINGLY. ALL OF THESE ROUTINES
- ; RETURN TO GOD (ENDCYCLE)
- GLBL GOD
- GLBL GAME
- GLBL LOGO
- GLBL ATTRACT
- GLBL HISCORE
- GLBL ENDGAME
- GLBL ENTER
- GLBL PAUSE
- GLBL PROMPT
- GLBL SELECT
- GLBL POLLALL
- GLBL MGAME,MLOGO,MATTRACT,MHISCORE,MENDGAME,MENTER
- GLBL MPAUSE,MBLANK,MTEXT,MSELECT
- GLBL TRUE,FALSE
- GLBL DIEWAIT
- GLBL MNODMA,M160X2
- GLBL DLLRAM
- GLBL DLI1,DLI4
- GLBL JOYTABLE
- GLBL MLOADER
- RAMDEF ; ZERO PAGE
- RSEG CODE1
- ; God's gonna change !
- ; All the polling is here now, instead of in DLI4.
- ; Also, code dispatching is handled via an indirect jump
- ; through GODPTR. All routines which set MODE must
- ; now set GODPTR as well.
- GOD LDA MODE
- CMP #MBLANK
- BEQ GOGOD
- LDA NUMCYCLE
- CMP MAXCYCLE
- BMI GOGOD
- LDA FRAMECNT
- CMP OLDFCNT
- BEQ GOD
- STA OLDFCNT
- LDA #0
- STA NUMCYCLE
- ; At this point, it's time to go-- do the polling, then do the
- ; jmp indirect
- ; Note that this jump takes less cycles than the old way, even if
- ; the first mode test failed and JMP GAME was executed.
- GOGOD INC NUMCYCLE
- ; Poll all of the controllers
- JSR POLLALL
- *********
- JMP (GODPTR)
- *********
- ; All these routines end with ENDCYCLE which does JMP GOD
- BLANK
- LDA HJOYDIR
- CMP #8
- BNE BLANK00 Turn on DMA
- LDA FPPAUSE If pause is pressed, restart the game
- BNE B001
- ; If any fp switch, or the button, is touched, turn dma back on, but don't
- ; restart gameplay.
- LDA SWCHB If no switches are pressed, value
- CMP #$3F will be $3f
- BNE BLANK00
- BEQ JMPGOD substitute for JMP
- ; AT THIS POINT, WE KNOW PAUSE HAS BEEN PRESSED AGAIN. RESTORE DMA AND
- ; MAKE THE GAME START AGAIN--
- B001 JSR TURNON
- JMP BLANK01 ; SETUP FOR DMA TO OCCUR
- ; I'LL GET HERE IF 1) THE JOYSTICK IS NOT CENTERED
- ; 2) ANY FRONT PANEL SWITCH IS PRESSED
- BLANK00 LDA #00 ; IF JOYSTICK IS CENTERED AND PAUSE
- STA SYSCOUNT ; WAS NOT PRESSED AGAIN, COME HERE
- STA SYSCOUNT+1
- LDA #MPAUSE
- STA MODE
- NEWSTATE PAUSE
- BLANK01 LDA #L(DLI1) ; Turn DMA on
- STA DLIADR
- LDA #H(DLI1)
- STA DLIADR+1
- DMAON
- JMPGOD ENDCYCLE
- PAUSE LDA SYSCOUNT
- SEC
- SBC #1
- STA SYSCOUNT
- LDA SYSCOUNT+1
- SBC #0
- STA SYSCOUNT+1
- BNE PAUSE00
- LDA SYSCOUNT
- BNE PAUSE00
- ; AT THIS POINT, 18 MINUTES HAVE PASSED. TURN THE VIDEO OFF BY CHANGING THE
- ; MODE TO "MBLANK"
- LDA #MNODMA ; TURN OFF DMA
- STA CTRL
- LDA #MBLANK
- STA MODE
- NEWSTATE BLANK
- JMPGOD1 JMP GOD
- PAUSE00 LDA FPPAUSE
- BEQ JMPGOD1
- LDA PSREADY
- BEQ JMPGOD1 ; IF SWITCH HAS NOT BEEN TURNED OFF
- ; IF THE CODE REACHES THIS POINT, THE PAUSE BUTTON HAS BEEN PUSHED. GO
- ; BACK TO GAMEPLAY:
- JSR TURNON back to game
- ENDCYCLE
- TURNON LDA #MGAME
- STA MODE
- NEWSTATE GAME
- LDA #FALSE
- STA PSREADY
- RTS
- ********************
- ; Poll all the registers:
- POLLALL LDY #TRUE
- LDX CURRENT
- LDA INPT4,X ; GET PLAYER 0 OR 1 BUTTON
- BPL SETBUTTN
- STY THREADY
- INY from $ff to 0
- SETBUTTN STY HTHROW ; BUTTON IS DOWN
- LDA SWCHA
- LDY CURRENT
- BNE READPL2
- LSR A
- LSR A
- LSR A
- LSR A
- BNE WRTJOY jump (can't be 0)
- READPL2 AND #$0F
- WRTJOY TAX
- LDA JOYTABLE,X ; USE UPPER NIBBLE AS TABLE INDEX
- STA HJOYDIR
- ; Now poll the front panel switches.
- ; Reset switch first:
- LDY #TRUE
- LDA SWCHB
- AND #$01 ; RESET BIT
- BEQ GOD0020 ; CLEAR WHEN DOWN
- STY RESREADY
- INY from $ff to 0
- GOD0020 STY FPRESET
- ; Now the Select switch:
- LDY #TRUE
- LDA SWCHB
- AND #$02 ; SELECT BIT
- BEQ GOD0022 ; CLEAR WHEN DOWN
- STY SELREADY
- INY from $ff to 0
- GOD0022 STY FPSELECT
- ; Now the Pause switch:
- LDY #TRUE
- LDA SWCHB
- AND #$08 ; PAUSE BIT (B/W)
- BEQ GOD0024 ; CLEAR WHEN DOWN
- STY PSREADY
- INY from $ff to 0
- GOD0024 STY FPPAUSE
- RTS
- END
|