MOVCENTI.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. ******************************************************************************
  2. **** CENTIPEDE MOTION
  3. **** SMD 7/15/83
  4. ******************************************************************************
  5. MOVCENTI LDA NUMSEG
  6. BEQ SEEYA ;IF NO LIVE SEGMENTS
  7. CMP #1
  8. BNE SKPSPDUP ;IF NOT TIME TO SPEED UP LAST HEAD
  9. LDA DIFLEVEL ;DON'T SPEED UP LAST HEAD IN NOVICE GM
  10. BEQ SKPSPDUP
  11. LDA #0
  12. STA SPDCTRL ;SPEED UP LAST HEAD
  13. SKPSPDUP LDA SHTRTIMR
  14. BNE SEEYA ;IF THE SHOOTER IS DEAD
  15. LDA DELAYSEG
  16. BEQ NOSEGDLY ;IF NO DELAY OCCURS BEFORE MOTION
  17. DEC DELAYSEG ;DECREMENT THE DELAY COUNTER
  18. BNE ZDELAY
  19. LDA #7 ;TURN ON FEET SOUND
  20. JSR TUNIN
  21. ZDELAY RTS
  22. NOSEGDLY LDX #0
  23. DOCENT LDA OBJSTAT,X
  24. BMI SEGALIVE ;IF SEGMENT ALIVE
  25. LDA #0
  26. STA GTEMP2
  27. SEGSKIP INX
  28. CPX MAXSGCNT
  29. BNE DOCENT ;IF MORE SEGMENTS LEFT
  30. SEEYA RTS ;IT'S BEEN FUN, BUT WE'RE DONE
  31. SEGALIVE LDA OBJOFFST,X
  32. CMP #L(EXPLOS)
  33. BCS SEGSKIP
  34. JSR SHTRCOLL ;DID THIS SEGMENT HIT SHOOTER?
  35. LDA SHTRTIMR
  36. BNE SEEYA ;YES, SHOOTER DEAD
  37. LDA OBJSTAT,X
  38. AND #$10
  39. BNE FASTSEG ;IF THIS IS A FAST MOVING SEGMENT
  40. LDA FRMCNT
  41. AND SPDCTRL ;SPDCTRL = 0 IF ONLY ONE SEGMENT LEFT
  42. BNE SEGSKIP ;IF NOT TIME TO MOVE A SLOW SEGMENT
  43. FASTSEG LDA OBJSTAT,X
  44. AND #$20
  45. BNE SKPHMP1 ;IF SEGMENT IS NOT A HEAD
  46. JMP NOTHEAD
  47. SKPHMP1 LDA #0
  48. STA GTEMP2 ;RESET TURN FLAG FROM PREVIOUS CHAIN
  49. LDA OBJSTAT,X
  50. AND #$03
  51. BEQ SGNTTURN
  52. JMP SEGTURN ;IF HEAD IS IN THE PROCESS OF TURNING
  53. SGNTTURN LDA OBJSTAT,X
  54. AND #$40
  55. BEQ SGNTPOIS ;IF HEAD IS NOT POISONED
  56. MAKETURN LDA OBJSTAT,X
  57. ORA #$03
  58. STA OBJSTAT,X ;PUT HEAD IN STAGE 3 OF TURNING
  59. JMP SEGTURN3 ;ALWAYS
  60. SGNTPOIS LDA OBJOFFST,X ;CHECK DIRECTION OF HEAD
  61. AND #$04
  62. BNE HDNGLEFT ;IF HEAD IS HEADING LEFT
  63. LDA OBJX,X
  64. CMP CENTRGHT ;135 IN GAME PLAY, 134 IN TITLE
  65. BCC NOSGEDGE ;IF OBJECT ISN'T ABOUT TO HIT RT. EDGE
  66. SGATEDGE LDA OBJY,X
  67. CMP #184
  68. BNE MAKETURN ;IF HEAD ISN'T ON BOTTOM ROW
  69. LDA OBJSTAT,X
  70. AND #$08
  71. BEQ SKPBNCE2
  72. BOUNC LDA OBJSTAT,X
  73. EOR #$08
  74. STA OBJSTAT,X
  75. LDA OBJOFFST,X
  76. EOR #$04
  77. STA OBJOFFST,X
  78. JMP XMOVESEG
  79. SKPBNCE2 TXA
  80. TAY
  81. INY
  82. CPY MAXSGCNT
  83. BEQ MAKETURN ;IF HEAD HAS NO BODY
  84. LDA OBJSTAT,Y
  85. BPL MAKETURN ;" " " " "
  86. AND #$20
  87. BNE MAKETURN ;" " " " "
  88. NXTSGBCK INY
  89. CPY MAXSGCNT
  90. BEQ SGBOUNCE ;IF LAST LINK
  91. LDA OBJSTAT,Y
  92. BPL SGBOUNCE ;IF END OF LAST CHAIN
  93. AND #$20
  94. BEQ NXTSGBCK ;IF SEGMENT IS NOT A HEAD
  95. SGBOUNCE DEY
  96. LDA OBJY,Y
  97. CMP #184
  98. BNE MAKETURN ;IF TAIL IS NOT ON THE BOTTOM ROW
  99. LDA OBJSTAT,Y
  100. EOR #$28
  101. STA OBJSTAT,Y ;CONVERT IT TO A HEAD
  102. LDA OBJOFFST,Y
  103. EOR #$34
  104. STA OBJOFFST,Y ;REVERSE HIS DIRECTION, TOO
  105. BNE MAKETURN ;ALWAYS
  106. HDNGLEFT LDA OBJX,X
  107. CMP CENTLEFT ;18 IN GAME PLAY, 19 IN TITLE PAGE
  108. BCC SGATEDGE ;IF HEAD IS ABOUT TO HIT LEFT EDGE
  109. ; SEC
  110. SBC #7
  111. NOSGEDGE CLC
  112. ADC #5
  113. STA GTEMP1
  114. LDA OBJY,X
  115. BEQ MAKETRN1
  116. JSR COBSTAC ;LOOK FOR COLLISION WITH A CHARACTER
  117. BEQ NODETECT ;IF NO COLLISION WAS FOUND
  118. MDETCT AND #$FC ;CHECK FOR COLLISION W/POISONED MUSH
  119. CMP #$4C
  120. BNE MAKETRN1 ;IF NOT A POISONED SHROOM COLLISION
  121. LDA OBJSTAT,X
  122. ORA #$E7 ;CHANGE HEAD TO A POISONED ONE
  123. STA OBJSTAT,X
  124. ; LDA OBJOFFST,X ;different graphics for poison heads
  125. ; ORA #$10 ; no longer exists
  126. ; STA OBJOFFST,X
  127. BNE SEGTURN3 ;ALWAYS
  128. NODETECT JSR OVRLAP ;LOOK FOR COLLISION WITH OTHER OBJECTS
  129. BCC SEGANIM ;IF NO COLLISION WAS DETECTED
  130. MAKETRN1 LDA OBJSTAT,X
  131. AND #$08
  132. BNE JMPBOUNC
  133. JMP MAKETURN ;ALWAYS
  134. JMPBOUNC LDA OBJOFFST,X ;BUMP IT OVER TWO PIXELS ON BOTTOM ROW
  135. AND #$04
  136. BEQ JMPBOUNL
  137. INC OBJX,X
  138. INC OBJX,X
  139. JMP BOUNC
  140. JMPBOUNL DEC OBJX,X
  141. DEC OBJX,X
  142. JMP BOUNC
  143. NOTHEAD LDA OBJSTAT,X
  144. AND #$03
  145. BNE SEGTURN ;IF SEGMENT IS CURRENTLY TURNING
  146. LDA GTEMP2 ;CHECK TURN FLAG FOR CHAIN
  147. BEQ SEGANIM ;IF NO TURN SHOULD COMMENCE
  148. LDA #0
  149. STA GTEMP2 ;RESET TURN FLAG
  150. LDA OBJSTAT,X
  151. ORA #$03
  152. STA OBJSTAT,X ;MAKE OBJECT TURN ON NEXT MOTION PASS
  153. SEGANIM LDA FRMCNT ;CHANGE CENTIPEDE ANIMATION
  154. AND #$03
  155. BNE XMOVESEG ;IF NOT RIGHT FRAME TO CHANGE ANIM.
  156. LDA OBJOFFST,X
  157. AND #$03
  158. BNE NOANMRST
  159. LDA OBJOFFST,X
  160. ORA #$03
  161. STA OBJOFFST,X ;RESET ANIMATION SEQUENCE
  162. BNE XMOVESEG ;ALWAYS
  163. NOANMRST DEC OBJOFFST,X ;NEXT ANIMATION IN SEQUENCE
  164. XMOVESEG LDA OBJOFFST,X ;MODIFY X POSITION OF CENTIPEDE
  165. AND #$04
  166. BNE SEGLEFT ;IF SEGMENT IS GOING LEFT
  167. INC OBJX,X ;MOVE RIGHT ONE PIXEL
  168. JMP SEGSKIP ;ALWAYS
  169. SEGLEFT DEC OBJX,X ;MOVE LEFT ONE PIXEL
  170. JMP SEGSKIP ;ALWAYS
  171. SEGTURN CMP #3
  172. BNE SEGTURN2 ;IF NOT IN STAGE 3 OF TURNING
  173. SEGTURN3 LDA OBJSTAT,X ;GET UP/DOWN BIT FROM STATUS
  174. AND #$04
  175. LSR A
  176. STA GTEMP1 ;SAVE IT FOR JUST A MOMENT
  177. LDA OBJOFFST,X ;CHANGE OFFSET TO APPROPRIATE STAMP
  178. ORA #$0B
  179. AND #$FD
  180. ORA GTEMP1
  181. STATCHNG DEC OBJSTAT,X ;CHANGE TO NEXT TURNING STATE
  182. YMOVESEG STA OBJOFFST,X ;MODIFY CENTIPEDE'S Y POSITION
  183. YMOVE2 AND #$02
  184. BEQ SEGUP ;IF SEGMENT IS MOVING UP
  185. LDA OBJY,X
  186. CLC
  187. ADC #2
  188. STA OBJY,X ;MOVE SEGMENT DOWN TWO PIXELS
  189. BNE XMOVESEG ;ALWAYS
  190. SEGUP LDA OBJY,X
  191. SEC
  192. SBC #2
  193. STA OBJY,X ;MOVE OBJECT UP TWO PIXELS
  194. BNE XMOVESEG ;ALWAYS
  195. SEGTURN2 CMP #2
  196. BNE SEGTURN1 ;IF NOT IN STATE 2 OF TURNING
  197. LDA OBJOFFST,X
  198. AND #$FE ;CHANGE STAMP TO VERTICAL CENTIPEDE
  199. BNE STATCHNG ;ALWAYS
  200. SEGTURN1 LDA OBJOFFST,X
  201. AND #$01
  202. BNE FINALTRN ;IF ON LAST STAGE OF TURN
  203. LDA OBJOFFST,X
  204. EOR #$05 ;CHANGE STAMP
  205. BNE YMOVESEG ;ALWAYS
  206. FINALTRN LDY OBJY,X
  207. LDA ATTRACT
  208. BPL SKPATTR2 ;IF NOT IN ATTRACT MODE
  209. CPY #YBTMATTR+6
  210. BNE SKPATTR2
  211. STA GTEMP2
  212. LDA #0
  213. STA OBJSTAT,X
  214. DEC NUMSEG
  215. JMP SEGSKIP
  216. SKPATTR2 LDA OBJSTAT,X
  217. AND #$04
  218. BNE DWNWRDSG ;IF SEGMENT IS TRAVELLING DOWN
  219. CPY #146
  220. BEQ CHNGUPDN ;CHANGE VERTICAL DIRECTION
  221. BNE NOREVRSE ;ALWAYS
  222. DWNWRDSG CPY #182
  223. BNE NOREVRSE ;IF NOT ON BOTTOM ROW
  224. LDA OBJSTAT,X
  225. CMP #$C0
  226. BCC STRTNEWD ;IF NOT POISONED
  227. EOR #$41 ;UNPOISON, MAKE VERT. DIR. = UP, AND
  228. STA OBJSTAT,X ;INITIALIZE START OF TURN
  229. LDA OBJOFFST,X
  230. AND #$E6
  231. STA GTEMP2 ;TURN FLAG FOR NEXT SEGMENT IN CHAIN
  232. BNE STATCHNG ;ALWAYS
  233. STRTNEWD AND #$20
  234. BEQ CHNGUPDN ;IF OBJECT ON BOTTOM ISN'T A HEAD
  235. STA NEWHDFLG
  236. CHNGUPDN LDA OBJSTAT,X
  237. EOR #$04 ;CHANGE UP/DOWN BIT
  238. STA OBJSTAT,X
  239. NOREVRSE LDY #1 ;NON-ZERO VALUE FOR TURN FLAG
  240. SKIPFLAG LDA GTEMP2 ;TURN FLAG FOR NEXT SEGEMENT IN CHAIN
  241. BEQ NOQUIKTN ;IF NO TURN IS TO BE DONE IMMEDIATELY
  242. LDA OBJSTAT,X ;CHANGE STATUS TO 'SEGMENT ABOUT TO
  243. CLC ;TURN' (AFTER IT IS DECREMENTED)
  244. ADC #3
  245. STA OBJSTAT,X
  246. NOQUIKTN STY GTEMP2
  247. LDA OBJOFFST-1,X
  248. AND #$03
  249. STA GTEMP6
  250. LDA OBJOFFST,X
  251. TAY
  252. AND #$F4
  253. ORA GTEMP6
  254. STA OBJOFFST,X
  255. DEC OBJSTAT,X
  256. TYA
  257. JMP YMOVE2 ;ALWAYS
  258. ********* OBJECT COLLISION DETECTION TO BE BUILT ON THIS SITE
  259. OVRLAP NOP
  260. LDY #$FF
  261. LDA OBJOFFST,X
  262. AND #$04
  263. OVRLAP2 BNE STYGTMP3
  264. INY
  265. STYGTMP3 STY GTEMP3
  266. STX GTEMP4
  267. LDY #13
  268. OVRLOOP CPY #12
  269. BEQ OFFROW
  270. LDA OBJY,Y ;IN SAME ROW?
  271. CMP OBJY,X
  272. BNE OFFROW
  273. LDA OBJSTAT,Y ;LIVE OBJECT?
  274. BPL OFFROW
  275. LDA OBJOFFST,Y
  276. CMP #L(EXPLOS)
  277. BCS OFFROW
  278. CPY GTEMP4 ;COMPARING WITH SELF?
  279. BEQ OFFROW
  280. LDA OBJX,X ;IN SAME COLUMN (ONLY LOOKING AHEAD)?
  281. SEC
  282. SBC OBJX,Y
  283. EOR GTEMP3
  284. CMP #$FA
  285. BCS FNDOVRLP
  286. OFFROW DEY
  287. BPL OVRLOOP
  288. NOVRLAP CLC
  289. RTS
  290. FNDOVRLP CPX #12 ;DID WE TEST FOR SPIDER OVERLAPPING
  291. BCS FOUNDOUT ; WITH CENTIPEDE? JMP IF YES
  292. CPY GTEMP4 ;IS Y < X? (IF SO, DIFFERENT CHAINS,
  293. BCC FOUNDOUT ; SINCE X IS A HEAD)
  294. SAMECHN LDA OBJSTAT,Y ;ANY HEADS BETWEENS X AND Y?
  295. AND #$20
  296. BNE FOUNDOUT ;IF SO, DIFFERENT CHAINS
  297. DEY
  298. CPY GTEMP4
  299. BNE SAMECHN
  300. BEQ NOVRLAP ;IF NOT, SAME CHAIN, NO OVERLAP
  301. FOUNDOUT SEC
  302. RTS
  303. ****************************************************************************
  304. ********* NEWHD -- ADD NEW HEADS
  305. ****************************************************************************
  306. NEWHD LDA ATTRACT
  307. BMI AUREVOIR ;FRENCH FOR GOODBYE
  308. LDA NEWHDFLG
  309. BEQ AUREVOIR ;IF NEW HEADS SHOULDN'T COME OUT YET
  310. LDA SHTRTIMR
  311. BNE AUREVOIR ;IF SHOOTER IS EXPLODING
  312. LDA NHDTIMER
  313. BEQ LAUNCHED
  314. DEC NHDTIMER
  315. AUREVOIR RTS
  316. LAUNCHED LDY PLAYER
  317. LDA GAMETYPE
  318. CMP #1
  319. BEQ ZGMTPMV1
  320. LDY #0
  321. ZGMTPMV1 LDX MAXSGCNT
  322. NEXTGUY DEX
  323. BMI AUREVOIR
  324. LDA OBJSTAT,X
  325. BPL CANDIDAT ;FOUND A CANDIDATE TO MAKE A NEW HEAD
  326. BMI NEXTGUY ;ALWAYS
  327. CANDIDAT LDA DIFLEVEL
  328. BNE NHDFAST
  329. LDA #$A4 ;ALL NEW HEADS GO SLOW IN NOVICE GAME
  330. BNE NHDSPD
  331. NHDFAST LDA #$B4
  332. NHDSPD STA OBJSTAT,X ;OBJECT STATUS OF NEW HEAD
  333. LDA #$63
  334. STA OBJOFFST,X ;OBJECT OFFSET
  335. LDA #136
  336. STA OBJY,X ;YPOS OF OBJECT
  337. LDA #12
  338. STA OBJX,X ;XPOS
  339. LDA NHDCOUNT,Y
  340. CMP #$60 ;SHORTEST TIME (EXCEPT FROM SCORE)
  341. BCC ZSKIPDC1
  342. ;;;;; SEC
  343. SBC #4
  344. STA NHDCOUNT,Y
  345. LDA DIFLEVEL
  346. BEQ ZSKIPDC1
  347. LDA NHDCOUNT,Y
  348. SEC ;SUBTRACT 8 FROM TIME IF STANDARD
  349. SBC #4 ; DIFFICULTY GAME
  350. STA NHDCOUNT,Y
  351. ZSKIPDC1 LDA NHDCOUNT,Y
  352. STA NHDTIMER
  353. JSR RANDOM
  354. BMI ZNHDRGT ;IF THE NEW HEAD SHOULD MOVE RIGHT
  355. LDA #140
  356. STA OBJX,X
  357. LDA #$67
  358. STA OBJOFFST,X
  359. ZNHDRGT INC NUMSEG ;ONE MORE OF THESE CRITTERS NOW
  360. RTS