CHEFHIT.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ; CHEFHIT.S
  2. ; THIS ROUTINE TESTS TO SEE IF CHUCK HAS DIED DUE TO HITTING A CHEF.
  3. GLBL HEROKILL
  4. GLBL MKDIE
  5. GLBL MKAREJOY
  6. GLBL CHEFHIT
  7. GLBL SCRAPALL,TUNIN
  8. GLBL FALLING,DYHERO,DXHERO,CHEFSTRT
  9. GLBL STATDIE,AFDERASE,NULLCHAR
  10. GLBL CSTAMP,CCRUNL,CINFO
  11. GLBL PL0LIVES
  12. GLBL IRCHTIME,IRDXHERO,IRDYHERO
  13. GLBL HELDFOOD,CARRYING
  14. GLBL HYCENTER,DYHCHAR
  15. GLBL ERASEIT
  16. GLBL GOD
  17. DXHCHEF EQU $04
  18. DYHCHEF EQU $08
  19. EXTRA EQU 1
  20. DRIPSTRT EQU $1F
  21. RAMDEF ; ZERO PAGE
  22. RSEG CODE1
  23. PRINT GEN
  24. CHEFHIT
  25. LDX #12 ; #CHEFSTRT + #NUMCHEFS - 3
  26. LDY #3 ; INDEX TO CENTER AND DELTA TABLES
  27. LDA CSTATE If the hero is falling, no
  28. CMP #FALLING intersection with chefs
  29. BMI ZCHEFH0
  30. RTS
  31. ZCHEFH0 LDA CSTATE,X ; CHEF'S STATE
  32. CMP #FALLING ; IF RISING OR FALLING, IGNORE
  33. BPL NXTCHTST
  34. LDA #0 ; TELLS ME THIS IS THE NEARNESS TEST
  35. STA TEMP2
  36. LDA #IRDXHERO ; NEARNESS TEST FIRST
  37. STA TEMP0
  38. LDA #IRDYHERO
  39. STA TEMP1
  40. JMP IRLOOP2
  41. AAAAX
  42. IRLOOP1 LDA #DXHERO+DXHCHEF ; COME HERE IF NEARNESS TEST IS
  43. STA TEMP0 ; SUCCESSFUL-- TEST FOR REAL
  44. LDA DYHCHAR,Y
  45. STA TEMP1
  46. ; to get y delta, do chefy - (chucky - normalize)
  47. IRLOOP2 LDA CYPOS,X ; TEST Y COORD.
  48. BEQ NXTCHTST ; IF HE'S NOT ON SCREEN
  49. SEC
  50. SBC CYPOS ; HERO'S Y
  51. CLC
  52. AAA1 ADC HYCENTER,Y ; CHEFS ARE SHORTER- ADD TO NORMALIZE
  53. BPL CHHYPOS ; Y DIFF POSITIVE
  54. EOR #$FF ; ELSE, 2'S COMPLEMENT
  55. CLC
  56. ADC #1
  57. CHHYPOS CMP TEMP1 ; IR CLOSENESS OR CHEF
  58. ; BMI CHXTST ; TEST X DIFFERENCE
  59. BPL NXTCHTST ; ELSE, GO ON TO NEXT CHEF
  60. ; the x delta is chefx - (chuckx + extra)
  61. CHXTST LDA CXPOS,X
  62. SEC
  63. SBC CXPOS ; HERO'S X
  64. SEC
  65. AAA3 SBC #EXTRA
  66. BPL CHHXPOS ; POSITIVE X DIFFERENCE
  67. EOR #$FF ; ELSE, 2'S COMPLEMENT
  68. CLC
  69. ADC #1
  70. CHHXPOS CMP TEMP0
  71. ; BMI CHNEAR
  72. BPL NXTCHTST
  73. CHNEAR LDA TEMP2
  74. BNE HEROKILL this will jump to GOD
  75. INC IRCHTIME
  76. INC TEMP2
  77. JMP IRLOOP1
  78. NXTCHTST DEX
  79. DEX
  80. DEX
  81. DEY ; DELTA TABLE INDEX
  82. BPL ZCHEFH0
  83. CHHITBYE RTS
  84. *************** END OF CHEFHIT ROUTINE ************************
  85. ; THIS ROUTINE IS CALLED FROM "CHEFHIT", "HOLEHIT", AND "FOODHIT"
  86. ; IF THE HERO IS KILLED BY ONE OF THESE THINGS.
  87. ; IT SETS THE HERO APPROPRIATELY AND DOES SUITABLE ANIMATIONS.
  88. HEROKILL LDA #STATDIE
  89. STA STATUS
  90. JSR SCRAPALL
  91. LDA CXPOS ; USED BY "FOODMOVE" TO GO FOR CHUCK
  92. STA GOALX
  93. LDA CYPOS
  94. STA GOALY
  95. LDA CYCLECNT
  96. CLC
  97. ADC #02
  98. STA CINFO ; ANIMATE TIMER
  99. LDA #70
  100. STA SYSCOUNT
  101. JSR MKDIE ; HANDLE DEATH STUFF
  102. LDX CURRENT
  103. LDA PL0LIVES,X
  104. CMP #1
  105. BEQ ZHKLASTS ; LAST DEATH THIS GAME
  106. LDA #1
  107. JSR TUNIN
  108. LDA #2
  109. JMP TUNIN same as jsr and rts
  110. ZHKLASTS LDA #10
  111. JSR TUNIN
  112. LDA #11
  113. JMP TUNIN same as jsr and rts
  114. ; THIS ROUTINE IS CALLED FROM "MKHFALL" AND "HEROKILL"
  115. MKDIE
  116. LDA #1
  117. STA MAXCYCLE
  118. LDA #0 ; MAKE CONE DRIP GO AWAY
  119. STA CYPOS+DRIPSTRT
  120. STA CYPOS+2 erase carrying arms, if any
  121. LDA CSTATE
  122. CMP #CARRYING
  123. BNE MKSKIP
  124. LDX #0 chuck index
  125. JSR ERASEIT erase carried food
  126. MKSKIP
  127. LDA CCRUNL+2 ; GIVE CHUCK A BODY
  128. STA CSTAMP+1
  129. ; FOR FINAL VERSION, MOVE "MKAREJOY" INTO THIS ROUTINE--
  130. JMP MKAREJOY ; IN "HOLEHIT.S"
  131. ; same as jsr and rts
  132. END