APR30GOD.S 6.0 KB

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