ATTRACT.S 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. ; ATTRACT.S
  2. ; THIS ROUTINE IS CALLED BY "GOD" WHEN THE "MODE==MATTRACT".
  3. ; IF THIS IS THE FIRST GAME, CHUCK USES RANDOM DIRECTIONS,
  4. ; FOR RANDOM AMOUNTS OF TIME.
  5. ; IF THIS ISN'T THE FIRST GAME, USE THE INSTANT REPLAY TABLE
  6. ; FOR ATTRACT MODES.
  7. ;
  8. GLBL DIRTABL,DIRTABH
  9. GLBL CDIR
  10. GLBL RANDOM
  11. GLBL DOGAME
  12. GLBL REPLAY
  13. GLBL GAMEINIT
  14. GLBL AWOLDRAW
  15. GLBL ATTRACT
  16. GLBL MKAUTO
  17. GLBL MKLOGO
  18. GLBL CINFO,FINFO,NEWRACK,MATTRACT
  19. GLBL WON,FALSE
  20. GLBL NEWGAME
  21. GLBL GOD
  22. GLBL STATEND,STATDIE,GLCONT21
  23. GLBL THRWTIME
  24. GLBL DRIPTIME
  25. GLBL ASET
  26. RAMDEF ; ZERO PAGE
  27. RSEG CODE1
  28. ATTRACT LDA STATUS ; IF THIS IS A DEATH WAIT LOOP,
  29. CMP #STATEND ; THEN DON'T CHECK CONTROLLERS
  30. BEQ DOAUTO
  31. LDA NUMCYCLE ; MAKE SURE THAT TIMERS ARE STILL
  32. CMP #1 ; BASED ON REAL (INTERRUPT) TIME
  33. BNE ASKIPINC
  34. INC CYCLECNT ; MAKE SURE THIS IS ONLY ONCE
  35. ; PER FRAME
  36. DEC DRIPTIME ; ICE CREAM CONE TIMER FOR ANIMATION
  37. DEC SYSCOUNT ; GENERAL PURPOSE SYSTEM COUNTER
  38. LDA CYCLECNT update FINFO every odd frame
  39. LSR A
  40. BCC ATTCONTZ
  41. DEC FINFO
  42. ASKIPINC JMP DOAUTO
  43. ATTCONTZ LSR A update direction and button every
  44. ;fourth frame
  45. BCS ASKIPINC a jump -- not a fourth frame
  46. ; ONCE WE REACH HERE, EVERYTHING THAT FOLLOWS IS BEING EXECUTED ONCE
  47. ; EVERY TWO FRAMES, REGARDLESS OF "MAXCYCLE"
  48. ATTCONT0 LDA STATUS ; IF HIS EYES ARE ROLLING
  49. CMP #STATDIE
  50. BPL DOAUTO jump-- he's dying
  51. ATTCONT1 LDA GAMECNT use IR tables if its not the first
  52. BEQ ATTCONT2 game, and at least one rack is
  53. LDA ASET completed
  54. ; BEQ ATTCONT2
  55. BNE USEIR a jump
  56. ATTCONT2 LDA #6 just make him go left, if no tables
  57. STA JOYDIR
  58. STA CDIR
  59. BNE DOAUTO jump
  60. USEIR JSR REPLAY ; IN "MAIN.S"
  61. ; ONLY INCREMENT "CYCLEIDX" AND "THROWIDX" FOR CYCLES
  62. ; DURING WHICH CONTROLLERS ARE POLLED
  63. INC CYCLEIDX each table is $80 values of CYCLEIDX
  64. BPL ZATT001
  65. INC CYCLEIDX+1 ; GO TO NEXT BLOCK OF STORAGE
  66. LDX #0
  67. STX CYCLEIDX
  68. ZATT001 LDA CYCLEIDX
  69. AND #$07
  70. BNE DOAUTO
  71. INC THROWIDX ; INCREMENT EVERY 8 TIMES
  72. ; TEST FOR THROW, RESET, AND SELECT BUTTONS BEFORE EXECUTING THE GAME
  73. ; DRIVER CODE.
  74. ; ADDED: TEST THE JOYSTICK: IF "HJOYDIR != CENTER" THEN GO TO LOGO MODE
  75. DOAUTO LDX HTHROW ; SEE IF WE SHOULD START A GAME
  76. BEQ DOAUTO1
  77. LDX THREADY
  78. BEQ DOAUTO1
  79. INX will be TRUE ($FF) if we get here
  80. STX THREADY
  81. BEQ NGJSR a jump
  82. ; ELSE, TEST FOR THE RESET BUTTON:
  83. DOAUTO1 LDA FPRESET ; IF RESET BUTTON IS PUSHED, NEW GAME
  84. BEQ DOAUTO2
  85. LDA RESREADY ; MUST BE READY ALSO !
  86. BEQ DOAUTO2
  87. STX RESREADY X=0, the value of FALSE
  88. NGJSR JMP NEWGAME ; BUTTON WAS JUST PUSHED
  89. ; ENDCYCLE
  90. DOAUTO2 LDA FPSELECT ; TEST THE SELECT BUTTON
  91. BEQ DOAUTO3
  92. LDA SELREADY
  93. ; BEQ DOAUTO3
  94. BNE MKLJMP ; BACK TO THE MENU
  95. ; a jump
  96. DOAUTO3 LDA HJOYDIR ; IF THE JOYSTICK HAS BEEN TOUCHED
  97. CMP #08
  98. BEQ DOAUTO4
  99. MKLJMP JMP MKLOGO ; GO TO THE MENU
  100. ; SAME AS AT THE BEGINNING OF "GAME"; HANDLES THE WAIT LOOPS AT THE END OF THE
  101. ; RACK
  102. DOAUTO4 LDA STATUS
  103. CMP #STATEND
  104. ; BEQ ATTCONTA
  105. BNE AUTOON a jump
  106. ATTCONTA DEC WAITCNT ; IF WAITCNT HAS REACHED 0,
  107. BNE ATTCONTB
  108. JMP GLCONT21 ; TIME TO COMPLETE WAIT
  109. ATTCONTB ENDCYCLE
  110. AUTOON JMP DOGAME ; IN "MAIN.S"
  111. ; THIS ROUTINE INITIATES THE ATTRACT MODE. IT CALLS ALL THE SAME
  112. ; CODE AS "NEWRACK".
  113. MKAUTO LDA #MATTRACT
  114. STA MODE
  115. NEWSTATE ATTRACT
  116. ; DMAOFF turn off while loading
  117. LDA GAMECNT ; IF USING THE LAST IR, DON'T RESET
  118. BNE MKAUTO1 ; GAME VARIABLES
  119. JSR GAMEINIT ; SETS APPROPRIATE VARIABLES
  120. MKAUTO1 JSR AWOLDRAW ; DRAWS THE PLAYFIELD WALLS
  121. LDA #FALSE
  122. STA DOITOVER ; SO THAT "RACKINIT" WILL DO IT
  123. LDA #WON
  124. STA CSTATE
  125. JMP NEWRACK same as JSR followed by RTS
  126. ; turns DMA back on
  127. END