FOODHIT.S 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. ; FOODHIT.S
  2. ;
  3. ; THIS ROUTINE HAS TWO NESTED LOOPS-- ONE FOR ALL THE FLYING FOODS, AND
  4. ; ONE FOR THE 5 CHARACTERS.
  5. GLBL FOODHIT
  6. GLBL MKSPLAT
  7. GLBL ERASEIT
  8. GLBL TUNIN
  9. GLBL STATHIT,STATDIE,FALLING,YCENTER
  10. GLBL NUMFOOD,FLYING,CREATOR,DYCHAR,DXCHAR,CDIR
  11. GLBL HEROKILL,CPALW,CARRYING,HELDFOOD,LEAVING
  12. GLBL CSPEED,CFRAME,NUMCHHIT,CHSTAMP,BLOCK2,NUMFALL,ADDSCORE
  13. GLBL LASTCHEF,CACOUNT,SPLAT,SPLATCH,SPLATPW,CSTAMP
  14. GLBL ANGLE
  15. GLBL NUMSTUCK,NUMINAIR
  16. GLBL STICKING,CTYPE,PIEFLY,PIEFLYPW
  17. GLBL REJOYING
  18. GLBL FCENTERY,DYFCHAR,STUKXPOS,STUKYPOS
  19. FCHKCTR EQU 2
  20. FCHFCTR EQU 0
  21. FCHEFDX EQU $04
  22. FCHUCKDX EQU $03
  23. FOODSTRT EQU $0F
  24. FOODDEC EQU $0E one less than FOODSTRT
  25. DXFOOD EQU $02
  26. DYFOOD EQU $03
  27. RAMDEF ; ZERO PAGE
  28. RSEG CODE1
  29. FOODHIT LDX #0
  30. LDA STATUS
  31. CMP #STATHIT only test chuck if STATHIT
  32. BEQ FHLOOP1
  33. LDX #$0C else test everyone
  34. FHLOOP1 LDA CSTATE,X
  35. CMP #REJOYING test if he's rejoicing !
  36. BEQ FHSKIP1
  37. CMP #FALLING ; IF FALLING OR RISING,
  38. BMI FHSKIP1
  39. FHNXTJMP JMP FHNXTCH ; DON'T TEST FOR INTERSECTION.
  40. FHSKIP1 LDA CYPOS,X ; IF ZERO, HE'S NOT VISIBLE
  41. ; BNE FHSKIP11
  42. BEQ FHNXTJMP ; GO ON TO NEXT CHARACTER
  43. FHSKIP11 SEC
  44. SBC FCENTERY,X ; CHARACTERS ARE TALLER- NORMALIZE
  45. STA TEMP0 ; USE AS TESTED Y COORDINATE
  46. AAF1 LDY #FCHKCTR
  47. TXA
  48. BEQ NOTCHEF1
  49. LDY #FCHFCTR
  50. NOTCHEF1 STY TEMP1
  51. LDA CXPOS,X
  52. CLC
  53. ADC TEMP1 center for chef or chuck
  54. STA TEMP1 tested x coordinate
  55. AAF2 LDY #FCHUCKDX use a different DX for chefs
  56. TXA
  57. BEQ NOTCHEF
  58. LDY #FCHEFDX it's a chef-- gets killed easier
  59. NOTCHEF STY TEMP2
  60. LDY #NUMFOOD+FOODDEC ; START AT LAST HOLE AND DECREMENT
  61. ; THE LAST INDEX IS ONE LESS
  62. FHLOOP2 LDA CYPOS,Y ; IF NO FOOD IS HERE, DON'T TEST IT
  63. ; BNE FHSKIP4
  64. BEQ FHFDJMP ; IF NOT VISIBLE, Y == 0
  65. ; a jump
  66. FHSKIP4 LDA CSTATE,Y ; SEE IF IT'S FLYING
  67. CMP #FLYING
  68. BEQ FHSKIP5
  69. CMP #ANGLE
  70. BEQ FHSKIP6 ; DON'T USE "CREATOR"
  71. FHFDJMP JMP FHNXTFD ; IF IT'S NOT FLYING, SKIP IT
  72. FHSKIP5 TXA ; GET CHARACTER INTO A
  73. CMP CREATOR,Y ; SEE IF HE'S THE THROWER
  74. ; BNE FHSKIP6
  75. BEQ FHFDJMP ; IF SO, SKIP THIS FOOD
  76. ; a jump
  77. FHSKIP6 LDA CYPOS,Y ; GET FOOD'S Y
  78. SEC
  79. SBC TEMP0 ; SUBTRACT CHAR'S Y
  80. BPL ZFHYPOS ; Y DIFF IS POSITIVE
  81. EOR #$FF ; ELSE, DO TWO'S COMPLEMENT
  82. CLC
  83. ADC #1
  84. ; AT THIS POINT, ACC CONTAINS THE ABSOLUTE VALUE OF X DIFFERENCE.
  85. ZFHYPOS CMP DYFCHAR,X
  86. ; BMI ZFHXTST ; Y IS NEAR-- CHECK X
  87. BPL FHFDJMP ; ELSE, GO TO NEXT FOOD
  88. ; a jump
  89. ZFHXTST LDA CXPOS,Y
  90. SEC
  91. SBC TEMP1 ; CHARACTER X
  92. BPL ZFHXPOS ; X DIFF IS POSITIVE
  93. EOR #$FF ; ELSE, DO TWO'S COMPLEMENT
  94. CLC
  95. ADC #1
  96. ZFHXPOS CMP TEMP2 DX for character + food
  97. ; BMI FDKILL
  98. BPL FHFDJMP a jump
  99. ; If this is a chef, make the food splat. If it's chuck, just make the
  100. ; food stick to him, and update the flying food variables.
  101. FDKILL STX TEMPX
  102. LDA STATUS ; IF IT'S HITTING HERO, MAKE IT
  103. CMP #STATHIT ; SURROUND CHUCK.
  104. BNE FDKILL01 not hitting-- don't adjust food
  105. LDA #6 the splat sound (even though it
  106. JSR TUNIN doesn't splat)
  107. DEC NUMINAIR update counters for food
  108. INC NUMSTUCK
  109. LDA #STICKING ; HITTING THE HERO-- MAKE IT STICK
  110. STA CSTATE,Y
  111. LDA CTYPE,Y
  112. CMP #2 ; PIES
  113. BNE ZENDSP12 ; ANY OTHER FOOD
  114. LDX CDIR,Y ; IF PIE, BASE ON DIRECTION
  115. LDA PIEFLY,X
  116. STA CSTAMP,Y
  117. LDA PIEFLYPW,X
  118. STA CPALW,Y
  119. LDX TEMPX
  120. ZENDSP12 LDA CXPOS,X
  121. CLC
  122. ADC STUKXPOS-15,Y ; FIRST FOOD IS AT 15
  123. STA CXPOS,Y
  124. LDA CYPOS,X
  125. CLC
  126. ADC STUKYPOS-15,Y
  127. STA CYPOS,Y
  128. FDKILL01 TXA ; CHARACTER INDEX
  129. BNE FCHKILL
  130. ; IF CHARLIE, DO IT TO HIM
  131. ; ELSE, KILL THE CHEF
  132. FHKILL LDA #STICKING state for sitting on top of hero
  133. STA CSTATE,Y keep the same stamp and position
  134. LDA STATUS
  135. CMP #STATDIE
  136. BMI FHKILL1
  137. RTS
  138. FHKILL1 JMP HEROKILL same as a JSR followed by RTS
  139. FCHKILL LDA CPALW,Y
  140. AND #$E0 ; GET JUST THE PALETTE
  141. STA TEMP0
  142. LDA CPALW,X
  143. AND #$1F
  144. ORA TEMP0
  145. STA CPALW,X
  146. LDA CPALW+1,X
  147. AND #$1F
  148. ORA TEMP0
  149. STA CPALW+1,X
  150. LDA CPALW+2,X
  151. AND #$1F
  152. ORA TEMP0
  153. STA CPALW+2,X
  154. STX TEMPX
  155. JSR MKSPLAT make the food splat on the chef
  156. LDX TEMPX
  157. LDA CSTATE,X ; SEE IF HE'S CARRYING
  158. CMP #CARRYING
  159. BNE FCH0010
  160. JSR ERASEIT erase carried food
  161. FCH0010 LDA CDIR,Y
  162. STA CDIR,X
  163. LDA #LEAVING
  164. STA CSTATE,X
  165. LDA #0
  166. STA CFRAME,X
  167. STA CSPEED,X
  168. LDA #2 ; ANIMATION COUNTER
  169. STA CFRAME+1,X
  170. LDA CREATOR,Y ; CREATOR OF THE FOOD
  171. BNE FHSKIPSC
  172. ; IF THE HERO, GIVE POINTS
  173. ; ELSE, DON'T
  174. FHGIVESC INC NUMCHHIT ; ONE MORE CHEF HIT
  175. STX TEMPX ; SAVE INDEX
  176. LDX #10
  177. LDA NUMCHHIT ; 100 X NUMBER HIT
  178. CMP #11 ; IF GREATER THAN 10, USE 10
  179. BPL ZFH013
  180. TAX
  181. ZFH013 JSR ADDSCORE
  182. LDX TEMPX ; RESTORE CHEF INDEX
  183. FHSKIPSC INC NUMFALL ; IF IT'S 4, ALL CHEFS HAVE FALLEN
  184. LDA NUMFALL
  185. CMP #4
  186. BNE ZFH020
  187. ZFH010 STX TEMPX ; SAVE CURRENT CHEF INDEX
  188. LDX LASTCHEF ; LOAD LAST CHEF TO HAVE FALLEN
  189. LDA #0
  190. STA CACOUNT,X ; SET COUNTER TO 0 SO IT RISES
  191. STA CACOUNT+1,X
  192. LDX TEMPX ; RESTORE CURRENT CHEF INDEX
  193. ZFH020 STX LASTCHEF ; IN CASE ALL HAVE FALLEN AT ONCE
  194. JMP FHNXTCH go right to the next chef
  195. ; since this chef is dead
  196. ; END OF THE TWO LOOPS:
  197. FHNXTFD DEY ; TEST FOR END OF FOOD LOOOP
  198. CPY #FOODSTRT
  199. BMI FHSKIP3
  200. JMP FHLOOP2 ; IF POSITIVE, MORE FOOD
  201. ; ELSE GO ON TO NEXT CHARACTER
  202. FHSKIP3
  203. FHNXTCH DEX
  204. DEX
  205. DEX
  206. BMI FHSKIP2
  207. JMP FHLOOP1
  208. FHSKIP2
  209. FHBYE RTS
  210. ; THIS ROUTINE IS ALSO CALLED FROM "MOVE" WHEN A FOOD HITS THE WALL
  211. ; REGISTERX GETS TRASHED
  212. MKSPLAT LDA #SPLAT
  213. STA CSTATE,Y
  214. LDA #2
  215. STA CACOUNT,Y
  216. LDA #4
  217. STA CFRAME,Y ; 5 FRAMES OF ANIMATION
  218. TAX
  219. LDA SPLATCH,X
  220. STA CSTAMP,Y
  221. LDA CPALW,Y
  222. AND #$E0 ; TOP THREE BITS ARE PALETTE
  223. ORA SPLATPW,X
  224. STA CPALW,Y
  225. LDA #BLOCK2
  226. STA CHSTAMP,Y
  227. LDA #6 ; THE SPLAT SOUND
  228. JMP TUNIN same as JSR followed by RTS
  229. ; This routine also called from HOLEHIT-- "MKREJOY" to erase foods of
  230. ; rejoicing chefs
  231. ERASEIT STY TEMPY ; SAVE INDEX REGISTER
  232. LDY HELDFOOD,X ; ERASE FOOD
  233. LDA #0
  234. STA CYPOS,Y ; STORE 0 INTO FOOD'S YPOS
  235. LDY TEMPY
  236. RTS
  237. END