CHUCK.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. ; CHUCK.S
  2. ;
  3. ; THE CHUCK DRIVER FIRST POLES THE JOYSTICK AND SETS HERODIR AND HEROSTAT
  4. ; APPROPRIATELY. THE JOYSTICK IS READ AS 8-POSITION; 0 IS NORTH,
  5. ; AND THE OTHER DIRECTIONS ARE NUMBERED CLOCKWISE.
  6. ; IT THEN DOES MOTION AND ANIMATION IF THE COUNTERS HAVE DECREMENTED TO
  7. ; 0.
  8. GLBL CHUCK
  9. GLBL SCRAPALL,TUNIN
  10. GLBL GAME
  11. GLBL AFDERASE
  12. GLBL CCHEADS
  13. GLBL MKPROMPT
  14. GLBL FLYCHAR,FLYPALW ; IN "PILEHIT.S"
  15. GLBL CCRUNL,CHHEADS,MUNCHPW,MUNCHLOW,MUNCHHI
  16. GLBL COLRINIT,NEWGAME
  17. GLBL KERNEL,MKLOGO,LOGOLOOP,CHARINIT,RACKINIT,PUTSCORE
  18. GLBL PUTSC2
  19. GLBL DPPINIT
  20. GLBL STATDISP
  21. BASEBON EQU 11 ; FIRST BONUS SCORE INDEX
  22. RSEG CODE3
  23. CHUCK LDA STATUS
  24. CMP #STATINIT ; IF CHEFS ARE RISING, ONLY SET DIR.
  25. BEQ ZCKCONT2
  26. CMP #STATWAIT
  27. BEQ ZCKCONT2
  28. CMP #STATHIT ; IF FOOD IS HITTING CHUCK, DO NOTHING
  29. BNE ZCKCONTA
  30. RTS ; JMP HEROBYE
  31. ZCKCONTA CMP #STATDIE ; IF EYES ARE ROLLING
  32. BMI ZCKCONT9
  33. JMP EYEROLL
  34. ZCKCONT9 CMP #STATWON
  35. BNE ZCKCONT8
  36. JMP MUNCH ; IF HERO IS EATING THE CONE
  37. ZCKCONT8 CMP #STATBON ; IF FOOD IS FLYING, DO NOTHING
  38. BNE ZCKCONT7
  39. RTS ; JMP HEROBYE
  40. ZCKCONT7 LDA CSTATE
  41. CMP #FEETFALL
  42. BNE ZCKCONT1
  43. JMP CFTFALL ; IF HIS FEET ARE FALLING, HEAD OK
  44. ZCKCONT1 CMP #HEADFALL
  45. BNE ZCKCONT2
  46. JMP CHDFALL ; IF THE FEET ARE GONE, HEAD FALLING
  47. ZCKCONT2
  48. LDA JOYDIR ; IF JOYSTICK CENTERED, DON'T
  49. CMP #8 ; MOVE OR ANIMATE
  50. BNE ZCHK011
  51. JMP ZCHUCK00
  52. ZCHK011 STA CDIR ; ELSE, USE THIS DIRECTION FOR
  53. ; ANIMATION, MOVEMENT, ETC.
  54. TAY ; SET THE HEAD FACING STAMP
  55. LDA CCHEADS,Y
  56. STA CSTAMP
  57. ; NOTE: THE CARRYING ARM STAMP IS ALWAYS SET, EVEN IF JOYSTICK IS CENTERED,
  58. ; IN "ZCHUCK04" BELOW.
  59. ZCHK002 LDA STATUS
  60. CMP #STATINIT ; DON'T CONTINUE IF RACK IS STARTING
  61. BEQ ZCKJMP3
  62. CMP #STATWAIT ; DON'T CONTINUE IF CHEFS ARE WAITING
  63. BNE ZCKCONT4
  64. ZCKJMP3 LDA CSTATE ; COME HERE IF STATUS IS "INIT" OR
  65. CMP #CARRYING ; "WAIT"
  66. BNE ZCKJMP4
  67. JMP ZCHUCK04 ; ADJUST ARMS AND FOOD
  68. ZCKJMP4 JMP ZCHUCK05 ; NOT CARRYING-- LEAVE ROUTINE
  69. ZCKCONT4 TYA ; NEW DIRECTION
  70. CMP OLDDIR
  71. BEQ ZCKCONT5 ; NO NEED TO SET IF NOT CHANGED
  72. LDA CSINDEX
  73. TAX
  74. LDA MTABINC,X
  75. ASL A
  76. ASL A
  77. ASL A
  78. ADC CDIR ; NOW CONTAINS AN INDEX TO THE
  79. TAX ; DELTA TABLES
  80. LDA STABXH,X ; SET SPEED FOR THIS DIRECTION
  81. STA CXSPEED
  82. LDA STABXL,X
  83. STA CXSPEEDL
  84. LDA STABYH,X
  85. STA CYSPEED
  86. LDA STABYL,X
  87. STA CYSPEEDL
  88. STY OLDDIR
  89. ZCKCONT5 LDX #HEROSTRT ; ARGUMENT FOR "MOVE" ROUTINE
  90. JSR MOVE ; MOVE THE HERO
  91. LDA CFRAME+1 ; ANIMATE COUNT IS AFTER FRAME COUNT
  92. ; IF ZERO, ANIMATE
  93. BNE ZCHUCK00 ; ELSE, LEAVE THE ROUTINE
  94. CHANIM LDA CDIR
  95. BEQ ZCHKA00 ; STRAIGHT UP-- RUN LEFT
  96. LSR A
  97. LSR A
  98. JMP ZCHKA01
  99. ZCHKA00 LDA #1 ; BIT 0 IS LEFT/RIGHT
  100. ZCHKA01 ORA CSTATE ; BIT 1 IS CARRYING/ NOT
  101. TAX
  102. LDA CHKCHOFF,X
  103. CLC
  104. ADC CACOUNT ; CURRENT FRAME
  105. TAX
  106. LDA CHUCKRUN,X ; CHOOSES PROPER STAMP FROM 4 TABLES
  107. STA CSTAMP+1
  108. DEC CACOUNT
  109. LDA CACOUNT
  110. BPL ZCHUCK31 ; NO NEED TO RESET IF >= 0
  111. LDA #5 ; 6 FRAMES OF FEET ANIMATION
  112. STA CACOUNT
  113. JMP ZCHUCK00 ; DOWN END OF BOUNCE
  114. ; NOW HANDLE THE BOUNCE IN HIS STEP ON THE 3RD AND 0TH FRAMES:
  115. ZCHUCK31 CMP #4
  116. BEQ ZCHUCK33 ; BOUNCE IN STEP
  117. CMP #1 ; AT 4 AND 1
  118. BEQ ZCHUCK33
  119. CMP #3 ; DOWN OF BOUNCE, AND FOOTSTEP SOUND
  120. BEQ ZCHUCK34
  121. CMP #0
  122. BEQ ZCHUCK34
  123. BNE ZCHUCK00 ; SAME AS A JUMP
  124. ZCHUCK33 LDA CYPOS
  125. CLC
  126. ADC #1
  127. STA CYPOS
  128. JMP ZCHUCK00
  129. ZCHUCK34 LDA #5
  130. JSR TUNIN
  131. LDA CYPOS
  132. SEC
  133. SBC #1
  134. STA CYPOS
  135. ; MOVEMENT AND ANIMATION ARE OVER, OR JUST NOT DONE. CHECK TO SEE IF
  136. ; CHUCK SHOULD THROW AND/OR CALL "CFOODADJ":
  137. ZCHUCK00 LDA CSTATE
  138. CMP #CARRYING
  139. BEQ ZTHTEST ; IF CARRYING, TEST THE THROW BUTTON
  140. JMP ZCHUCK05 ; IF NOT CARRYING, LEAVE ROUTINE
  141. ZTHTEST LDA STATUS don't let him throw if chefs are
  142. CMP #STATINIT rising
  143. BEQ ZJMP4 a jump
  144. CMP #STATWAIT
  145. BEQ ZJMP4 a jump
  146. ZTHTESTA LDA THRWTIME
  147. BEQ ZTHTEST1
  148. DEC THRWTIME
  149. ZJMP4 JMP ZCHUCK04 ; IF NOT DEBOUNCED, ADJUST FOOD AND
  150. ; ARMS
  151. ZTHTEST1 LDA THROWBUT
  152. BNE THROW
  153. JMP ZCHUCK04 ; ADJUST FOOD AND ARMS
  154. THROW LDA #10
  155. STA THRWTIME ; DEBOUNCING FOR THROW BUTTON
  156. LDA #3
  157. JSR TUNIN
  158. LDY HELDFOOD
  159. LDA CDIR
  160. STA CDIR,Y
  161. TAX ; USE AS INDEX FOR POSITIONING
  162. LDA CXPOS
  163. CLC
  164. ADC CTHXPOS,X ; ADJUST FOOD TO CENTER OF HEAD
  165. STA CXPOS,Y
  166. LDA CYPOS
  167. CLC
  168. ADC CTHYPOS,X
  169. STA CYPOS,Y
  170. LDA #FLYING ; SO THAT FOOD DRIVER MOVES IT
  171. STA CSTATE,Y
  172. ; CTYPE SHOULD HAVE BEEN COPIED FROM CINFO BY "TAKEFOOD", SINCE "CINFO"
  173. ; IS NOW A TIMER.
  174. LDA CTYPE,Y
  175. CMP #2 ; PIE TYPE IS 2
  176. BEQ ZTH004
  177. CMP #1 ; PEAS
  178. BEQ ZTH0041
  179. ZTH0042 LDA #01 ; ANYTHING NOT PEAS
  180. STA CINFO,Y ; FOR ALL TYPES OTHER THAN PEAS
  181. LDA #0
  182. STA CACOUNT,Y
  183. JMP ZTH005
  184. ZTH004 LDA CDIR ; USE DIRECTION AS TABLE INDEX
  185. TAX
  186. LDA PIEFLY,X ; GET STAMP
  187. STA CSTAMP,Y ; STORE IT
  188. LDA PIEFLYPW,X ; GET PALETTE WIDTH
  189. STA CPALW,Y
  190. JMP ZTH005
  191. ZTH0041 LDA #1 ; IF IT'S PEAS, SET UP FOR DISPERSAL
  192. STA CACOUNT,Y ; FRAME INDEX
  193. LDA #8
  194. STA CINFO,Y
  195. ; calculate throw speed. Vary speed with MAXSET-- multiply by 4
  196. ; to get base address of a table to be indexed by food type.
  197. ZTH005 JSR MAXSET
  198. DEX
  199. TXA
  200. ASL A
  201. ASL A
  202. STA TEMP0
  203. LDA CTYPE,Y ; MODIFY FLYING SPEED BASED ON
  204. CMP #4
  205. BNE ATH0051 ; NOT WATERMELON
  206. JSR RANDOM ; WATERMELON CHOOSES RANDOMLY
  207. AND #$3
  208. ATH0051 TAX
  209. LDA FLYDIST,X ; MODIFY DISTANCE BASED ON TYPE OF
  210. STA CFLYTIME,Y ; FOOD
  211. TXA
  212. ORA TEMP0
  213. TAX
  214. ; GET THE "CSINDEX" AND SET "CSPEED" AND THE DELTAS ACCORDINGLY.
  215. LDA FLYSPEED,X ; BASED ON FOOD TYPE
  216. JSR SETFSPD in chefmove.s
  217. LDA #RUNNING ; FREE HIM TO PICK UP MORE FOOD
  218. STA CSTATE
  219. LDA CCRUNL ; JUST SO THAT THERE'S NO BLANK SPACE
  220. STA CSTAMP+1
  221. LDA #0 ; ERASE THE ARM STAMP
  222. STA CYPOS+2
  223. JMP ZCHUCK05
  224. ; AT THIS POINT, ADJUST CARRIED FOOD AND SET CARRYING ARM STAMP:
  225. ZCHUCK04
  226. JSR CFOODADJ ; ADJUST THE FOOD BY THE HERO
  227. LDA CDIR ; SET THE PROPER ARM STAMP
  228. TAY
  229. LDA CCARMS,Y
  230. STA CSTAMP+2
  231. ; WHEN I GET HERE, ALL PROCESSING IS DONE-- JUST SET THE BODY AND FEET
  232. ; TO FOLLOW THE HEAD.
  233. ZCHUCK05
  234. LDA CXPOS
  235. STA CXPOS+1 ; SAME FOR UPPER AND LOWER HALF
  236. LDA CYPOS
  237. SEC
  238. SBC #12 ; 12 SCAN LINES DOWN
  239. STA CYPOS+1 ; FOR LOWER HALF
  240. LDA CSTATE ; IF CARRYING, ADJUST ARMS
  241. CMP #CARRYING
  242. BNE HEROBYE
  243. LDA CDIR
  244. BEQ ZCHK021 ; UP IS "LEFT"
  245. CMP #4
  246. BPL ZCHK021
  247. LDA CXPOS ; RIGHT
  248. SEC
  249. SBC #3
  250. STA CXPOS+2
  251. JMP ZCHK022
  252. ZCHK021 LDA CXPOS
  253. SBC #2 ; CARRY MUST BE SET
  254. STA CXPOS+2
  255. ZCHK022 LDA CYPOS
  256. SEC
  257. SBC #4 ; MOVE ARMS DOWN 4 PIXELS
  258. STA CYPOS+2
  259. HEROBYE RTS
  260. ; THE FOLLOWING CODE HANDLES THE HERO FALLING THROUGH A HOLE.
  261. CFTFALL DEC CACOUNT
  262. BNE HEROBYE
  263. LDA #FSPEED ; FALL FRAME COUNTER
  264. STA CACOUNT
  265. DEC CYPOS ; LOWER HEAD ONE
  266. DEC CYPOS+1 ; LOWER FEET ONE
  267. LDA CYPOS+1
  268. CMP CFRAME ; IF FEET HAVE PASSED BOTTOM OF ZONE,
  269. BMI ZCHFL010 ; THEN ERASE THE FEET.
  270. RTS ; JMP HEROBYE
  271. ; MAKE THE HEAD START TO FALL; ERASE THE FEET ALTOGETHER--
  272. ZCHFL010 LDA #HEADFALL
  273. STA CSTATE
  274. LDA #$FF ; RANDOM NON-ZERO VALUE
  275. STA CSECOND ; HEAD STAMP
  276. LDA CFRAME
  277. CLC
  278. ADC #14 ; POSITION TOP OF HEAD AT TOP OF ZONE
  279. STA CYPOS
  280. LDA #0
  281. STA CYPOS+1 ; MAKE FEET STAMP INVISIBLE
  282. RTS ; JMP HEROBYE
  283. CHDFALL DEC CACOUNT
  284. BNE HEROBYE
  285. LDA #FSPEED ; RESET ANIMATE COUNTER
  286. STA CACOUNT
  287. DEC CYPOS ; LOWER HEAD ONE
  288. LDA CYPOS
  289. CMP CFRAME ; IF HEAD HAS REACHED BOTTOM OF ZONE,
  290. BMI CFLEND ; ERASE IT !
  291. RTS ; JMP HEROBYE
  292. CFLEND LDA #0
  293. STA CYPOS
  294. JSR AFDERASE ; ERASE ALL CURRENT FOODS
  295. LDA #STATEND ; MAKE "GAME" LOOP 3 SECONDS
  296. STA STATUS
  297. LDA #95
  298. STA WAITCNT
  299. LDA #DEAD
  300. STA CSTATE ; THIS WILL MAKE GAMELOOP EXIT
  301. RTS ; JMP HEROBYE
  302. ; IF THE STATUS == "STATDIE", JUMP HERE AND HANDLE THE EYES ROLLING.
  303. EYEROLL LDA CYCLECNT
  304. CMP CINFO
  305. BCS ZIROLL0 ; WAIT TILL CYCLECNT REACHES CINFO
  306. RTS ; JMP HEROBYE
  307. ZIROLL0 CLC ; "CYCLECNT" IS ALREADY IN A
  308. ADC #2
  309. STA CINFO
  310. DEC CDIR
  311. BMI ZIROLL2
  312. LDA CDIR
  313. JMP ZIROLL3
  314. ZIROLL2 LDA #7
  315. STA CDIR
  316. ZIROLL3 TAY ; USE DIRECTION AS INDEX
  317. LDA CCHEADS,Y
  318. STA CSTAMP ; MAKE EYES ROLL
  319. LDA SYSCOUNT
  320. CMP #245
  321. BCS ENDROLL
  322. RTS ; JMP HEROBYE
  323. ENDROLL LDA #STATHIT ; MAKE FOOD HIT CHUCK
  324. STA STATUS
  325. JSR AFDERASE
  326. LDA #SADCHAR
  327. STA CSTAMP
  328. LDA #2
  329. STA MAXCYCLE
  330. LDA #BLOCK2
  331. STA CHSTAMP
  332. RTS ; JMP HEROBYE
  333. ; THE ROUTINE BRANCHES HERE IF CHUCK IS EATING THE CONE
  334. MUNCH DEC CACOUNT ; ANIMATE COUNTER
  335. BEQ ZMUNCH00
  336. RTS ; JMP MUNCHBYE
  337. ZMUNCH00 LDA CSPEED
  338. STA CACOUNT
  339. LDA CFRAME
  340. BMI ZMCLOSE ; BIT 8 SET MEANS MOUTH CLOSING
  341. JMP ZMOPEN
  342. ZMCLOSE INC CFRAME
  343. LDA CFRAME
  344. AND #$7F
  345. CMP #6
  346. BMI ZMCONT01
  347. JMP MKSMILE ; MUNCH IS FINISHED
  348. ZMCONT01 STA TEMP0
  349. LDA #5
  350. SEC
  351. SBC TEMP0
  352. STA TEMPX ; USED FOR TONGUE ANIMATION
  353. JMP ZMUNCH01
  354. ZMOPEN DEC CFRAME
  355. BMI AMKCLOSE ; IF OPEN IS FINISHED
  356. LDA CFRAME
  357. CLC
  358. ADC #6
  359. STA TEMPX ; USED FOR TONGUE ANIMATION
  360. JMP ZMUNCH01
  361. AMKCLOSE LDA #$80 ; VALUE OF 0; HIGH BIT SET
  362. STA CFRAME
  363. LDA DOITOVER
  364. BNE ZMKCL00 ; IF IR, DON'T CLEAR TUNE !
  365. JSR SCRAPALL
  366. LDA #28
  367. JSR TUNIN
  368. LDA #29
  369. JSR TUNIN
  370. ZMKCL00 LDA #5