GOD.S 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. ; GOD.S
  2. ; THIS ROUTINE IS THE MAIN GAME LOOP, JUMPED TO FROM "MAIN" RIGHT
  3. ; AFTER ALL THE POWERUP INITIALIZATION IS DONE. IT
  4. ; TESTS THE "MODE" VARIABLE AND DECIDES WHICH MINOR GOD OR
  5. ; GODDESS ROUTINE TO JUMP TO ACCORDINGLY. ALL OF THESE ROUTINES
  6. ; RETURN TO GOD (ENDCYCLE)
  7. GLBL GOD
  8. GLBL XDMAON
  9. GLBL GAME
  10. GLBL LOGO
  11. GLBL ATTRACT
  12. GLBL HISCORE
  13. GLBL ENDGAME
  14. GLBL ENTER
  15. GLBL PAUSE
  16. GLBL PROMPT
  17. GLBL SELECT
  18. GLBL POLLALL
  19. GLBL MGAME,MLOGO,MATTRACT,MHISCORE,MENDGAME,MENTER
  20. GLBL MPAUSE,MBLANK,MTEXT,MSELECT
  21. GLBL TRUE,FALSE
  22. GLBL DIEWAIT
  23. GLBL MNODMA,M160X2
  24. GLBL DLLRAM
  25. GLBL DLI1,DLI4
  26. GLBL JOYTABLE
  27. GLBL MLOADER
  28. RAMDEF ; ZERO PAGE
  29. RSEG CODE1
  30. ; God's gonna change !
  31. ; All the polling is here now, instead of in DLI4.
  32. ; Also, code dispatching is handled via an indirect jump
  33. ; through GODPTR. All routines which set MODE must
  34. ; now set GODPTR as well.
  35. GOD LDA MODE
  36. CMP #MBLANK
  37. BEQ GOGOD
  38. LDA NUMCYCLE
  39. CMP MAXCYCLE
  40. BMI GOGOD
  41. LDA FRAMECNT
  42. CMP OLDFCNT
  43. BEQ GOD
  44. STA OLDFCNT
  45. LDA #0
  46. STA NUMCYCLE
  47. ; At this point, it's time to go-- do the polling, then do the
  48. ; jmp indirect
  49. ; Note that this jump takes less cycles than the old way, even if
  50. ; the first mode test failed and JMP GAME was executed.
  51. GOGOD INC NUMCYCLE
  52. ; Poll all of the controllers
  53. JSR POLLALL
  54. *********
  55. JMP (GODPTR)
  56. *********
  57. ; All these routines end with ENDCYCLE which does JMP GOD
  58. BLANK
  59. LDA HJOYDIR
  60. CMP #8
  61. BNE BLANK00 Turn on DMA
  62. LDA FPPAUSE If pause is pressed, restart the game
  63. BNE B001
  64. ; If any fp switch, or the button, is touched, turn dma back on, but don't
  65. ; restart gameplay.
  66. LDA SWCHB If no switches are pressed, value
  67. CMP #$3F will be $3f
  68. BNE BLANK00
  69. BEQ JMPGOD substitute for JMP
  70. ; AT THIS POINT, WE KNOW PAUSE HAS BEEN PRESSED AGAIN. RESTORE DMA AND
  71. ; MAKE THE GAME START AGAIN--
  72. B001 JSR TURNON
  73. JMP BLANK01 ; SETUP FOR DMA TO OCCUR
  74. ; I'LL GET HERE IF 1) THE JOYSTICK IS NOT CENTERED
  75. ; 2) ANY FRONT PANEL SWITCH IS PRESSED
  76. BLANK00 LDA #00 ; IF JOYSTICK IS CENTERED AND PAUSE
  77. STA SYSCOUNT ; WAS NOT PRESSED AGAIN, COME HERE
  78. STA SYSCOUNT+1
  79. LDA #MPAUSE
  80. STA MODE
  81. NEWSTATE PAUSE
  82. BLANK01 LDA #L(DLI1) ; Turn DMA on
  83. STA DLIADR
  84. LDA #H(DLI1)
  85. STA DLIADR+1
  86. DMAON
  87. JMPGOD ENDCYCLE
  88. PAUSE LDA SYSCOUNT
  89. SEC
  90. SBC #1
  91. STA SYSCOUNT
  92. LDA SYSCOUNT+1
  93. SBC #0
  94. STA SYSCOUNT+1
  95. BNE PAUSE00
  96. LDA SYSCOUNT
  97. BNE PAUSE00
  98. ; AT THIS POINT, 18 MINUTES HAVE PASSED. TURN THE VIDEO OFF BY CHANGING THE
  99. ; MODE TO "MBLANK"
  100. LDA #MNODMA ; TURN OFF DMA
  101. STA CTRL
  102. LDA #MBLANK
  103. STA MODE
  104. NEWSTATE BLANK
  105. JMPGOD1 JMP GOD
  106. PAUSE00 LDA FPPAUSE
  107. BEQ JMPGOD1
  108. LDA PSREADY
  109. BEQ JMPGOD1 ; IF SWITCH HAS NOT BEEN TURNED OFF
  110. ; IF THE CODE REACHES THIS POINT, THE PAUSE BUTTON HAS BEEN PUSHED. GO
  111. ; BACK TO GAMEPLAY:
  112. JSR TURNON back to game
  113. ENDCYCLE
  114. TURNON LDA #MGAME
  115. STA MODE
  116. NEWSTATE GAME
  117. LDA #FALSE
  118. STA PSREADY
  119. RTS
  120. ********************
  121. ; Poll all the registers:
  122. POLLALL LDY #TRUE
  123. LDX CURRENT
  124. LDA INPT4,X ; GET PLAYER 0 OR 1 BUTTON
  125. BPL SETBUTTN
  126. STY THREADY
  127. INY from $ff to 0
  128. SETBUTTN STY HTHROW ; BUTTON IS DOWN
  129. LDA SWCHA
  130. LDY CURRENT
  131. BNE READPL2
  132. LSR A
  133. LSR A
  134. LSR A
  135. LSR A
  136. BNE WRTJOY jump (can't be 0)
  137. READPL2 AND #$0F
  138. WRTJOY TAX
  139. LDA JOYTABLE,X ; USE UPPER NIBBLE AS TABLE INDEX
  140. STA HJOYDIR
  141. ; Now poll the front panel switches.
  142. ; Reset switch first:
  143. LDY #TRUE
  144. LDA SWCHB
  145. AND #$01 ; RESET BIT
  146. BEQ GOD0020 ; CLEAR WHEN DOWN
  147. STY RESREADY
  148. INY from $ff to 0
  149. GOD0020 STY FPRESET
  150. ; Now the Select switch:
  151. LDY #TRUE
  152. LDA SWCHB
  153. AND #$02 ; SELECT BIT
  154. BEQ GOD0022 ; CLEAR WHEN DOWN
  155. STY SELREADY
  156. INY from $ff to 0
  157. GOD0022 STY FPSELECT
  158. ; Now the Pause switch:
  159. LDY #TRUE
  160. LDA SWCHB
  161. AND #$08 ; PAUSE BIT (B/W)
  162. BEQ GOD0024 ; CLEAR WHEN DOWN
  163. STY PSREADY
  164. INY from $ff to 0
  165. GOD0024 STY FPPAUSE
  166. RTS
  167. END