MOVE.S 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. ; MOVE.S
  2. ; THIS FILE CONTAINS THE GENERAL MOVEMENT ROUTINE, USED BY ALL MOVING
  3. ; CHARACTERS.
  4. ; IT DOES A TWO-BYTE FIXNUM X,Y SPEED VECTOR ADD.
  5. GLBL MOVE
  6. GLBL MKSPLAT
  7. MOVE
  8. TXA ; SEE IF THIS IS A FOOD OR A CHARACTER
  9. CMP #FOODSTRT
  10. BPL MOVE0011 ; IF A FOOD, NO ANIMATE COUNTER
  11. ; BMI MOVE001 ; IT'S A CHARACTER---
  12. MOVE001
  13. DEC CFRAME+1,X ; ANIMATE COUNTER
  14. BPL MOVE0011 ; DON'T CHANGE UNTIL LESS THAN ZERO
  15. ; SINCE THE DRIVERS NEED IT AT ZERO
  16. LDA CSPEED+1,X ; IF MINUS, RESET
  17. AND #$7F
  18. CLC
  19. ADC #7
  20. STA CFRAME+1,X
  21. MOVE0011 LDA CFRAME,X ; CURRENT FRAME COUNT FOR CHARACTER
  22. AND #$7F ; TOP BIT MEANS DOUBLE SPEED
  23. BEQ DOMOVE ; MOVE IF IT'S ZERO
  24. DEC CFRAME,X ; ELSE DECREMENT AND RETURN
  25. RTS ; JMP MOVEBYE
  26. DOMOVE LDA CSPEED,X
  27. STA CFRAME,X ; RESET CFRAME FOR NEXT TIME
  28. ; TEST TO SEE IF CHARACTER HAS PASSED RIGHT OR LEFT BORDER:
  29. LDA CXPOS,X
  30. CMP #XMIN ; LEFT BORDER
  31. BCC MSKIP11 ; "BCC XLDTST"
  32. CMP #$C8 ; BIGGER THAN RIGHT SIDE
  33. BCC MSKIP1
  34. MSKIP11 JMP XLDTST ; LEFT DIRECTION TEST
  35. MSKIP1 CLC
  36. ADC CWIDTH,X ; ADD WIDTH OF CHARACTER
  37. CMP #XMAX ; RIGHT BORDER
  38. BCC ZMSKIP21
  39. JMP XRDTST ; RIGHT DIRECTION TEST
  40. ZMSKIP21
  41. XOK ; FINALLY, DO X AXIS MOVEMENT
  42. LDA CFRAME,X
  43. BPL XNODBL
  44. ; BMI XDOUBLE ; BIT 7 MEANS TWICE THE SPEED
  45. XDOUBLE LDA CXSPEEDL,X ; IDENTICAL; DOES IT TWICE
  46. CLC
  47. ADC CXPOSL,X
  48. STA CXPOSL,X
  49. LDA CXSPEED,X
  50. ADC CXPOS,X
  51. STA CXPOS,X
  52. XNODBL LDA CXSPEEDL,X
  53. CLC
  54. ADC CXPOSL,X
  55. STA CXPOSL,X
  56. LDA CXSPEED,X
  57. ADC CXPOS,X
  58. STA CXPOS,X
  59. JMP SKSKIPX
  60. SKIPX
  61. TXA
  62. CMP #FOODSTRT ; IF IT'S A FOOD, REMOVE IT
  63. BPL FWLHIT
  64. LDA CSTATE,X
  65. CMP #LEAVING
  66. BEQ CHERASE
  67. ; TEST TO SEE IF CHARACTER HAS PASSED TOP OR BOTTOM BORDER:
  68. SKSKIPX
  69. LDA CYPOS,X
  70. CMP #YMAX ; TOP BORDER
  71. BCC ZMSKIP22
  72. JMP YUDTST ; UP DIRECTION TEST
  73. ZMSKIP22 SEC
  74. SBC CHEIGHT,X ; SUBTRACT HEIGHT OF CHARACTER
  75. CMP #YMIN ; BOTTOM BORDER
  76. BCS ZMSKIP23
  77. JMP YDDTST ; DOWN DIRECTION TEST
  78. ZMSKIP23
  79. YOK
  80. LDA CFRAME,X
  81. BPL YNODBL
  82. ; BMI YDOUBLE ; BIT 7 MEANS DOUBLE SPEED
  83. YDOUBLE LDA CYSPEEDL,X
  84. CLC
  85. ADC CYPOSL,X
  86. STA CYPOSL,X
  87. LDA CYSPEED,X
  88. ADC CYPOS,X
  89. STA CYPOS,X
  90. YNODBL LDA CYSPEEDL,X
  91. CLC
  92. ADC CYPOSL,X
  93. STA CYPOSL,X
  94. LDA CYSPEED,X
  95. ADC CYPOS,X
  96. STA CYPOS,X
  97. JMP SKSKIPY
  98. SKIPY
  99. TXA
  100. CMP #FOODSTRT ; IF IT'S A FOOD, REMOVE IT
  101. BPL FWLHIT
  102. LDA CSTATE,X
  103. CMP #LEAVING
  104. BEQ CHERASE
  105. SKSKIPY
  106. MOVEBYE
  107. RTS
  108. ; THIS CODE MAKES A FOOD SPLAT ON THE SCORE
  109. FWLHIT LDA STATUS ; GIVE BONUS POINTS IF
  110. CMP #STATBON ; THIS IS A BONUS FOOD
  111. BEQ FWLH00
  112. CMP #STATHIT
  113. BNE NONIADEC
  114. DEC NUMINAIR
  115. NONIADEC LDA #0 just erase food in all other cases
  116. STA CYPOS,X
  117. RTS ; JMP MOVEBYE
  118. FWLH00 TXA
  119. TAY
  120. JSR MKSPLAT
  121. LDX #1 ; 100 POINTS BONUS FOR THE FOOD
  122. JMP ADDSCORE ; WAS JSR, FOLLOWED BY RTS
  123. ; RTS
  124. CHERASE LDA #0
  125. STA CYPOS,X
  126. STA CYPOS+1,X
  127. STA CYPOS+2,X
  128. LDA #DEAD
  129. STA CSTATE,X
  130. LDA NUMFALL
  131. CMP #4
  132. BNE CHERASE9
  133. ; ELSE, ALL THE CHEFS ARE GONE-- MAKE HIM RISE IMMEDIATELY
  134. LDA #0
  135. STA CACOUNT,X
  136. STA CACOUNT+1,X
  137. RTS ; JMP MOVEBYE
  138. CHERASE9 LDA #$1F ; SET REBIRTH TIMER
  139. STA CACOUNT,X ; LOW BYTE
  140. LDA #$01
  141. STA CACOUNT+1,X ; HIGH BYTE
  142. RTS ; JMP MOVEBYE
  143. ; THE FOUR BORDER DIRECTION TESTS FOLLOW.
  144. JSKIPX JMP SKIPX
  145. XRDTST LDA CDIR,X ; IF 1,2,3 SKIP X MOVEMENT
  146. CMP #1
  147. BPL MAYBE1 ; IF GREATER THAN 1, MAYBE SKIP
  148. LDA CXPOS,X
  149. JMP XOK ; ELSE IT'S ZERO, OK.
  150. MAYBE1 CMP #4
  151. BMI JSKIPX
  152. ZMSKIP11 LDA CXPOS,X
  153. JMP XOK ; ELSE DO IT.
  154. XLDTST LDA CDIR,X ; CAN'T BE GREATER THAN 4
  155. CMP #5
  156. BPL JSKIPX
  157. ZMSKIP12 LDA CXPOS,X
  158. JMP XOK
  159. JSKIPY JMP SKIPY
  160. YUDTST LDA STATUS ; IF HITTING SCORE, THEN THERE'S NO
  161. CMP #STATBON ; DIRECTION
  162. BEQ JSKIPY
  163. LDA CDIR,X ; CAN'T BE 0,1, OR 7
  164. CMP #7
  165. BEQ JSKIPY
  166. ZMSKIP93 CMP #2
  167. BMI JSKIPY
  168. ZMSKIP13 LDA CYPOS,X
  169. JMP YOK
  170. YDDTST LDA CDIR,X ; CAN'T BE 3,4,5
  171. CMP #3
  172. BPL MAYBE2
  173. LDA CYPOS,X
  174. JMP YOK
  175. MAYBE2 CMP #6
  176. BMI JSKIPY
  177. ZMSKIP19 LDA CYPOS,X
  178. JMP YOK