Advertisement
KnightofTime

Pushable Stone Block

May 27th, 2012
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.21 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Adapted from Yoshi's Island Chomp Rock (NON DYNAMIC VERSION)
  3. ; Programmed by SMWEdit, modified by ICB. Give credit to both if used, please.
  4. ;
  5. ;This is a wooden crate that Mario can push left or right and then stand on top
  6. ;of to get an extra boost. It also goes up hills and kills sprites while it's
  7. ;moving. It moves a couple of tiles before stopping and repeats
  8. ;after a few seconds, mimicking the giant pushable blocks in Zelda:OOT, MM,
  9. ;and Wind Waker. Comes with ExGFX image which you will want to paste into your
  10. ;SP4 file if you are using other SP4 sprites for a particular level, or just use the
  11. ;SP4 by itself if you want.
  12. ;
  13. ; Uses first extra bit: NO
  14. ;
  15. ; uses SP4
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17.  
  18. SPRITEKILLSND = $37
  19.  
  20. OFFSET = $1528
  21. STARTOFFSET = $1504
  22. FLIPXY = $151C
  23.  
  24. STANDINGLASTFRAME = $1626
  25.  
  26. LASTXLO = $1534
  27. LASTXHI = $1570
  28. LASTYLO = $1594
  29. LASTYHI = $1602
  30.  
  31. SPRXTMP = $04
  32. SPRYTMP = $06
  33.  
  34. SPRXTMP2 = $08
  35. SPRYTMP2 = $0A
  36.  
  37. GENERICTMP = $0C
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. ; INIT and MAIN JSL targets
  41. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  42.  
  43. dcb "INIT"
  44. LDA $E4,x
  45. STA STARTOFFSET,x
  46. JSR STORE_POS
  47. RTL
  48.  
  49. dcb "MAIN"
  50. PHB
  51. PHK
  52. PLB
  53. JSR SPRITE_ROUTINE
  54. LDA $1588,x
  55. AND #$04
  56. BNE a
  57. STZ $B6,x
  58. a:
  59. PLB
  60. RTL
  61.  
  62.  
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64. ; SPRITE_ROUTINE
  65. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  66.  
  67. STAND_YPOS = $FFD0 ; Y position of platform relative to sprite
  68. STAND_XMIN = $FFEC ; Left X boundary
  69. STAND_XMAX = $0012 ; Right X boundary
  70.  
  71. LPUSH_YMIN = $FFD8 ; Y position of top of left push area
  72. LPUSH_YMAX = $0000 ; Y position of bottom of left push area
  73. LPUSH_XMIN = $FFE1 ; X position for pushing
  74. LPUSH_XMAX = $0000 ; extent (forward) of interaction field
  75.  
  76. RPUSH_YMIN = $FFD8 ; Y position of top of left push area
  77. RPUSH_YMAX = $0000 ; Y position of bottom of left push area
  78. RPUSH_XMIN = $000F ; X position for pushing
  79. RPUSH_XMAX = $0001 ; extent (backward) of interaction field
  80.  
  81. LROLL_XMAX = $FFEA ; max for standing and making rock roll left
  82. RROLL_XMAX = $0015 ; max for standing and making rock roll right
  83.  
  84. STORE_POS LDA $E4,x ; \
  85. STA LASTXLO,x ; | store current position
  86. LDA $14E0,x ; | to sprite tables for
  87. STA LASTXHI,x ; | use next time sprite
  88. LDA $D8,x ; | routine is called.
  89. STA LASTYLO,x ; | It's used for moving mario
  90. LDA $14D4,x ; | while he's standing on it
  91. STA LASTYHI,x ; /
  92. RETURN1 RTS
  93.  
  94. SPRITE_ROUTINE JSR SUB_GFX
  95. LDA $14C8,x ; \ return if
  96. CMP #$08 ; | sprite
  97. BNE RETURN1 ; / status != 8
  98. LDA $9D ; \ return if
  99. BNE RETURN1 ; / sprites locked
  100. LDA $13F9
  101. BNE RETURN1
  102. JSR SUB_OFF_SCREEN_X0 ; only process sprite while on screen
  103.  
  104. JSR POSOFFSETSTART ; interaction improvement offset
  105.  
  106. LDA $187A ; \ don't shift
  107. BEQ NOYOSHI ; / if not on Yoshi
  108. LDA $96 ; \
  109. CLC ; | offset Y
  110. ADC #$10 ; | by #$10
  111. STA $96 ; | again to
  112. LDA $97 ; | compensate
  113. ADC #$00 ; | for yoshi
  114. STA $97 ; /
  115.  
  116. NOYOSHI
  117.  
  118. LDA LASTXLO,x ; \
  119. STA SPRXTMP2 ; | store sprite's old
  120. LDA LASTXHI,x ; | X and Y positions
  121. STA SPRXTMP2+1 ; | into scratch
  122. LDA LASTYLO,x ; | RAM for use
  123. STA SPRYTMP2 ; | in some of the
  124. LDA LASTYHI,x ; | following code
  125. STA SPRYTMP2+1 ; /
  126. LDA $E4,x ; \
  127. STA SPRXTMP ; | store sprite X
  128. LDA $14E0,x ; | and Y position
  129. STA SPRXTMP+1 ; | into scratch
  130. LDA $D8,x ; | RAM for use
  131. STA SPRYTMP ; | in some of the
  132. LDA $14D4,x ; | following code
  133. STA SPRYTMP+1 ; /
  134. LDA $E4,x ; \
  135. SEC ; | set offsets
  136. SBC STARTOFFSET,x ; | for rotation
  137. PHA ; |
  138. AND #%00001111 ; |
  139. STA OFFSET,x ; |
  140. PLA ; |
  141. AND #%00000000 ; |
  142. STA FLIPXY,x ; /
  143. LDA STANDINGLASTFRAME,x ; \ check if mario was
  144. BEQ NOT_STANDING_LAST_FRAME ; / standing last frame
  145. LDA $77 ; \ don't move mario if
  146. AND #%00000011 ; | he is hitting the side
  147. BNE NO_MOVE_MARIO ; / of an object
  148. PHP ; \
  149. REP #%00100000 ; | move mario
  150. LDA SPRXTMP ; | 2 pixels for
  151. SEC ; | every pixel
  152. SBC SPRXTMP2 ; | the sprite
  153. ASL A ; | moves
  154. CLC ; |
  155. ADC $94 ; |
  156. STA $94 ; |
  157. PLP ; /
  158.  
  159. NO_MOVE_MARIO
  160. STZ STANDINGLASTFRAME,x ; zero this in case it won't be set this frame
  161. NOT_STANDING_LAST_FRAME
  162. BRA NO_NO_STAND_JMP ; \ this is used when a standard
  163. NO_STAND_JMP JMP NO_STAND ; / branch is out of range
  164. NO_NO_STAND_JMP
  165. LDA $7D ; \ don't stand on if
  166. BMI NO_STAND_JMP ; / mario not moving down
  167. PHP ; back up processor bits
  168. REP #%00100000 ; set 16 bit A/math
  169. LDY #$00 ; Y register = 0
  170. LDA SPRYTMP ; get sprite's Y position
  171. CLC ; \ offset to get minimum
  172. ADC.w #STAND_YPOS-1 ; / Y area for standing
  173. CMP $96 ; compare with mario's Y position
  174. BCS NO_STAND_1 ; don't execute next command if area is under mario
  175. LDY #$01 ; set Y register = 1
  176. NO_STAND_1 PLP ; load backed up processor bits
  177. CPY #$00 ; \ if Y is not set
  178. BEQ NO_STAND_JMP ; / then don't stand
  179. PHP ; back up processor bits
  180. REP #%00100000 ; set 16 bit A/math
  181. LDY #$00 ; Y register = 0
  182. LDA SPRYTMP ; get sprite's Y position
  183. CLC ; \ offset to get maximum
  184. ADC.w #STAND_YPOS+5 ; / Y area for standing
  185. CMP $96 ; compare with mario's Y position
  186. BCC NO_STAND_2 ; don't execute next command if area is over mario
  187. LDY #$01 ; set Y register = 1
  188. NO_STAND_2 PLP ; load backed up processor bits
  189. CPY #$00 ; \ if Y is not set
  190. BEQ NO_STAND_JMP ; / then don't stand
  191. PHP ; back up processor bits
  192. REP #%00100000 ; 16 bit A/math
  193. LDY #$00 ; Y register = 0
  194. LDA SPRXTMP ; get sprite's X position
  195. CLC ; \ offset to get minimum
  196. ADC.w #STAND_XMIN ; / X area for standing
  197. BPL CMP1 ; \ if area goes backward past
  198. LDA.w #$0000 ; / level start then assume zero
  199. CMP1 CMP $94 ; compare with mario's X position
  200. BCS NO_STAND_3 ; don't execute next command if area is after mario
  201. LDY #$01 ; set Y register = 1
  202. NO_STAND_3 PLP ; load backed up processor bits
  203. CPY #$00 ; \ if Y is not set
  204. BEQ NO_STAND_JMP ; / then don't stand
  205. PHP ; back up processor bits
  206. REP #%00100000 ; set 16 bit A/math
  207. LDY #$00 ; Y register = 0
  208. LDA SPRXTMP ; get sprite's X position
  209. CLC ; \ offset to get maximum
  210. ADC.w #STAND_XMAX ; / X area for standing
  211. BPL CMP2 ; \ if X area goes backward past
  212. LDA.w #$0000 ; / level start then assume zero
  213. CMP2 CMP $94 ; compare with mario's X position
  214. BCC NO_STAND_4 ; don't execute next command if area is before mario
  215. LDY #$01 ; set Y register = 1
  216. NO_STAND_4 PLP ; load backed up processor bits
  217. CPY #$00 ; \ if Y is not set
  218. BEQ NO_STAND_JMP ; / then don't stand
  219. PHP ; \
  220. REP #%00100000 ; | offset mario's
  221. LDA SPRYTMP ; | Y position so
  222. CLC ; | that he is
  223. ADC.w #STAND_YPOS ; | standing at
  224. STA $96 ; | specified offset
  225. PLP ; /
  226. LDA #$01 ; \ set standing
  227. STA $1471 ; / mode
  228. PHP ; back up processor bits
  229. REP #%00100000 ; 16 bit A/math
  230. LDY #$00 ; Y register = 0
  231. LDA SPRXTMP ; get sprite's X position
  232. CLC ; \ offset to get maximum X
  233. ADC.w #LROLL_XMAX ; / area for left stand-rolling
  234. BPL CMP7 ; \ if area goes backward past
  235. LDA.w #$0000 ; / level start then assume zero
  236. CMP7 CMP $94 ; compare with mario's X position
  237. BCC NO_LROLL_1 ; don't execute next command if area is after mario
  238. LDY #$01 ; set Y register = 1
  239. NO_LROLL_1 PLP ; load backed up processor bits
  240. CPY #$00 ; \ if Y is not set
  241. BEQ NO_LROLL ; / then don't stand
  242. LDA $14 ; \
  243. AND #%00000011 ; | "slowly" increase
  244. BNE NO_LROLL ; | speed of rock
  245. DEC $B6,x ; |
  246. NO_LROLL ; /
  247. PHP ; back up processor bits
  248. REP #%00100000 ; 16 bit A/math
  249. LDY #$00 ; Y register = 0
  250. LDA SPRXTMP ; get sprite's X position
  251. CLC ; \ offset to get maximum X
  252. ADC.w #RROLL_XMAX+1 ; / area for left stand-rolling
  253. BPL CMP8 ; \ if area goes backward past
  254. LDA.w #$0000 ; / level start then assume zero
  255. CMP8 CMP $94 ; compare with mario's X position
  256. BCS NO_RROLL_1 ; don't execute next command if area is after mario
  257. LDY #$01 ; set Y register = 1
  258. NO_RROLL_1 PLP ; load backed up processor bits
  259. CPY #$00 ; \ if Y is not set
  260. BEQ NO_RROLL ; / then don't stand
  261. LDA $14 ; \
  262. AND #%00000011 ; | "slowly" increase
  263. BNE NO_RROLL ; | speed of rock
  264. INC $B6,x ; |
  265. NO_RROLL ; /
  266. LDA #$01 ; \ for the next frame, indicate mario
  267. STA STANDINGLASTFRAME,x ; / was standing during this frame
  268. NO_STAND
  269. BRA NO_NO_LPUSH_JMP ; \ this is used when a standard
  270. NO_LPUSH_JMP JMP NO_LPUSH ; / branch is out of range
  271. NO_NO_LPUSH_JMP
  272. PHP ; back up processor bits
  273. REP #%00100000 ; set 16 bit A/math
  274. LDY #$00 ; Y register = 0
  275. LDA SPRYTMP ; get sprite's Y position
  276. CLC ; \ offset to get top
  277. ADC.w #LPUSH_YMIN-1 ; / boundary for pushing
  278. CMP $96 ; compare with mario's Y position
  279. BCS NO_LPUSH_1 ; don't execute next command if area is under mario
  280. LDY #$01 ; set Y register = 1
  281. NO_LPUSH_1 PLP ; load backed up processor bits
  282. CPY #$00 ; \ if Y is not set
  283. BEQ NO_LPUSH_JMP ; / then don't stand
  284. PHP ; back up processor bits
  285. REP #%00100000 ; set 16 bit A/math
  286. LDY #$00 ; Y register = 0
  287. LDA SPRYTMP ; get sprite's Y position
  288. CLC ; \ offset to get bottom
  289. ADC.w #LPUSH_YMAX ; / boundary for pushing
  290. PHY ; back up Y
  291. LDY $187A ; \
  292. BEQ NOT_YOSHI1 ; | boundary is lower
  293. CLC ; | if mario is on Yoshi
  294. ADC.w #$0010 ; /
  295. NOT_YOSHI1 LDY $73 ; \
  296. BNE NOT_BIG1 ; | boundary is lower
  297. LDY $19 ; | if mario is ducking
  298. BEQ NOT_BIG1 ; | or if he is not big
  299. CLC ; |
  300. ADC.w #$0008 ; /
  301. NOT_BIG1 PLY ; load backed up Y
  302. CMP $96 ; compare low boundary with mario's Y position
  303. BCC NO_LPUSH_2 ; don't execute next command if area is above mario
  304. LDY #$01 ; set Y register = 1
  305. NO_LPUSH_2 PLP ; load backed up processor bits
  306. CPY #$00 ; \ if Y is not set then
  307. BEQ NO_LPUSH ; / don't push from left
  308. PHP ; back up processor bits
  309. REP #%00100000 ; set 16 bit A/math
  310. LDY #$00 ; Y register = 0
  311. LDA SPRXTMP ; get sprite's X position
  312. CLC ; \ offset to get left
  313. ADC.w #LPUSH_XMIN-1 ; / boundary for pushing
  314. BPL CMP3 ; \ if area goes backwards past
  315. LDA.w #$0000 ; / level start then assume zero
  316. CMP3 CMP $94 ; compare with mario's X position
  317. BCS NO_LPUSH_3 ; don't execute next command if area is after mario
  318. LDY #$01 ; set Y register = 1
  319. NO_LPUSH_3 PLP ; load backed up processor bits
  320. CPY #$00 ; \ if Y is not set then
  321. BEQ NO_LPUSH ; / don't push from left
  322. PHP ; back up processor bits
  323. REP #%00100000 ; set 16 bit A/math
  324. LDY #$00 ; Y register = 0
  325. LDA SPRXTMP ; get sprite's X position
  326. CLC ; \ offset to get right
  327. ADC.w #LPUSH_XMAX ; / boundary for pushing
  328. BPL CMP4 ; \ if area goes backwards past
  329. LDA.w #$0000 ; / level start then assume zero
  330. CMP4 CMP $94 ; compare with mario's X position
  331. BCC NO_LPUSH_4 ; don't execute next command if area is before mario
  332. LDY #$01 ; set Y register = 1
  333. NO_LPUSH_4 PLP ; load backed up processor bits
  334. CPY #$00 ; \ if Y is not set then
  335. BEQ NO_LPUSH ; / don't push from left
  336. PHP ; back up processor bits
  337. REP #%00100000 ; set 16 bit A/math
  338. LDA SPRXTMP ; \
  339. CLC ; | keep mario at
  340. ADC.w #LPUSH_XMIN ; | push offset position
  341. STA $94 ; /
  342. PLP ; load backed up processor bits
  343. LDA $14 ; \
  344. AND #%00010001 ; | "slowly" increase
  345. BNE NO_INC_SPD_L ; | speed of rock
  346. INC $B6,x ; |
  347. NO_INC_SPD_L ; /
  348. LDA $B6,x ; \
  349. CMP $7B ; | prevent mario's speed from
  350. BCS OKX1 ; | exceeding that of the rock
  351. STA $7B ; /
  352. OKX1
  353. LDA $B6,x ; \
  354. BPL NOT_HITTING_WALL_L ; | if mario is wedged
  355. LDA $77 ; | in between the rock
  356. AND #%00000010 ; | and the wall, then
  357. BEQ NOT_HITTING_WALL_L ; | bounce off of him
  358. JSR HIT_WALL ; | (so not to kill him)
  359. NOT_HITTING_WALL_L ; /
  360. NO_LPUSH
  361. BRA NO_NO_RPUSH_JMP ; \ this is used when a standard
  362. NO_RPUSH_JMP JMP NO_RPUSH ; / branch is out of range
  363. NO_NO_RPUSH_JMP
  364. PHP ; back up processor bits
  365. REP #%00100000 ; set 16 bit A/math
  366. LDY #$00 ; Y register = 0
  367. LDA SPRYTMP ; get sprite's Y position
  368. CLC ; \ offset to get top
  369. ADC.w #RPUSH_YMIN-1 ; / boundary for pushing
  370. CMP $96 ; compare with mario's Y position
  371. BCS NO_RPUSH_1 ; don't execute next command if area is below mario
  372. LDY #$01 ; set Y register = 1
  373. NO_RPUSH_1 PLP ; load backed up processor bits
  374. CPY #$00 ; \ if Y is not set then
  375. BEQ NO_RPUSH_JMP ; / don't push from right
  376. PHP ; back up processor bits
  377. REP #%00100000 ; set 16 bit A/math
  378. LDY #$00 ; Y register = 0
  379. LDA SPRYTMP ; get sprite's Y position
  380. CLC ; \ offset to get bottom
  381. ADC.w #RPUSH_YMAX ; / boundary for pushing
  382. PHY ; back up Y
  383. LDY $187A ; \
  384. BEQ NOT_YOSHI2 ; | boundary is lower
  385. CLC ; | if mario is on Yoshi
  386. ADC.w #$0010 ; /
  387. NOT_YOSHI2 LDY $73 ; \
  388. BNE NOT_BIG2 ; | boundary is lower
  389. LDY $19 ; | if mario is ducking
  390. BEQ NOT_BIG2 ; | or if he is not big
  391. CLC ; |
  392. ADC.w #$0008 ; /
  393. NOT_BIG2 PLY ; load backed up Y
  394. CMP $96 ; compare with mario's Y position
  395. BCC NO_RPUSH_2 ; don't execute next command if area is above mario
  396. LDY #$01 ; set Y register = 1
  397. NO_RPUSH_2 PLP ; load backed up processor bits
  398. CPY #$00 ; \ if Y is not set then
  399. BEQ NO_RPUSH ; / don't push from right
  400. PHP ; back up processor bits
  401. REP #%00100000 ; set 16 bit A/math
  402. LDY #$00 ; Y register = 0
  403. LDA SPRXTMP ; get sprite's X position
  404. CLC ; \ offset to get right
  405. ADC.w #RPUSH_XMIN ; / boundary for pushing
  406. BPL CMP5 ; \ if area goes backward past
  407. LDA.w #$0000 ; / level start then assume zero
  408. CMP5 CMP $94 ; compare with sprite's X position
  409. BCC NO_RPUSH_3 ; don't execute next command if area is before mario
  410. LDY #$01 ; set Y register = 1
  411. NO_RPUSH_3 PLP ; load backed up processor bits
  412. CPY #$00 ; \ if Y is not set then
  413. BEQ NO_RPUSH ; / don't push from right
  414. PHP ; back up processor bits
  415. REP #%00100000 ; set 16 bit A/math
  416. LDY #$00 ; Y register = 0
  417. LDA SPRXTMP ; get sprite's X position
  418. CLC ; \ offset to get left
  419. ADC.w #RPUSH_XMAX ; / boundary for pushing
  420. BPL CMP6 ; \ if area goes backward past
  421. LDA.w #$0000 ; / level start the assume zero
  422. CMP6 CMP $94 ; compare with sprite's X position
  423. BCS NO_RPUSH_4 ; don't execute next command if area is before mario
  424. LDY #$01 ; set Y register = 1
  425. NO_RPUSH_4 PLP ; load backed up processor bits
  426. CPY #$00 ; \ if Y is not set then
  427. BEQ NO_RPUSH ; / don't push from right
  428. PHP ; back up processor bits
  429. REP #%00100000 ; set 16 bit A/math
  430. LDA SPRXTMP ; \
  431. CLC ; | keep mario at
  432. ADC.w #RPUSH_XMIN ; | push offset position
  433. STA $94 ; /
  434. PLP ; load backed up processor bits
  435. LDA $14 ; \
  436. AND #%00010001 ; | "slowly" increase
  437. BNE NO_INC_SPD_R ; | speed of rock
  438. DEC $B6,x ; |
  439. NO_INC_SPD_R ; /
  440. LDA $B6,x ; \
  441. CMP $7B ; | prevent mario's speed from
  442. BCC OKX2 ; | exceeding that of the rock
  443. STA $7B ; /
  444. OKX2
  445. LDA $B6,x ; \
  446. BMI NOT_HITTING_WALL_R ; | if mario is wedged
  447. LDA $77 ; | in between the rock
  448. AND #%00000001 ; | and the wall then
  449. BEQ NOT_HITTING_WALL_R ; | bounce off of him
  450. JSR HIT_WALL ; | (so not to kill him)
  451. NOT_HITTING_WALL_R ; /
  452. NO_RPUSH
  453. LDA $B6,x ; \ don't execute following
  454. BEQ NOT_ROLLING ; / code if rock is not rolling
  455. JSR POSOFFSETEND ; reverse interaction improvement offset
  456. JSR KILLSPRITES ; kill sprites
  457. JSR POSOFFSETSTART ; re-do interaction improvement offset
  458. LDA $14 ; \
  459. AND #%01000000 ; | make the rock
  460. BNE END_SLOWDOWN ; | slow down
  461. LDA $B6,x ; |
  462. BPL MINUS ; |
  463. PLUS INC $B6,x ; |
  464. BRA END_SLOWDOWN ; |
  465. MINUS DEC $B6,x ; /
  466. END_SLOWDOWN
  467. NOT_ROLLING
  468. LDA $1588,x ; \
  469. AND #%00000011 ; | bounce off of
  470. BEQ NOT_HITTING_WALL ; | walls
  471. JSR HIT_WALL ; /
  472. NOT_HITTING_WALL
  473. LDA $187A ; \ don't shift
  474. BEQ NOYOSHI2 ; / if not on Yoshi
  475. LDA $96 ; \ reverse
  476. SEC ; | offset Y
  477. SBC #$10 ; | by #$10
  478. STA $96 ; | again to
  479. LDA $97 ; | compensate
  480. SBC #$00 ; | for yoshi
  481. STA $97 ; /
  482. NOYOSHI2
  483. JSR STORE_POS ; store sprite's current position for reference in next frame
  484. JSR POSOFFSETEND ; reverse interaction improvement offset
  485.  
  486. JSL $01802A ; update position based on speed values
  487. JSL $018032 ; interact with other sprites
  488. RETURN RTS
  489.  
  490. ;; This temporarily offsets mario's and the sprite's
  491. ;; Y positions so rock doesn't have a push glitch
  492. ;; when it's at the top of the level
  493.  
  494. PERCEPTIONOFFSET = $40
  495.  
  496. POSOFFSETSTART LDA $96 ; \
  497. CLC ; | add specified
  498. ADC #PERCEPTIONOFFSET ; | offset to
  499. STA $96 ; | mario
  500. LDA $97 ; |
  501. ADC #$00 ; |
  502. STA $97 ; /
  503. LDA $D8,x ; \
  504. CLC ; | add specified
  505. ADC #PERCEPTIONOFFSET ; | offset to
  506. STA $D8,x ; | sprite
  507. LDA $14D4,x ; |
  508. ADC #$00 ; |
  509. STA $14D4,x ; /
  510. RTS ; \
  511. POSOFFSETEND LDA $96 ; | subtract
  512. SEC ; | specified
  513. SBC #PERCEPTIONOFFSET ; | offset from
  514. STA $96 ; | mario
  515. LDA $97 ; |
  516. SBC #$00 ; |
  517. STA $97 ; /
  518. LDA $D8,x ; \
  519. SEC ; | subtract
  520. SBC #PERCEPTIONOFFSET ; | specified
  521. STA $D8,x ; | offset from
  522. LDA $14D4,x ; | sprite
  523. SBC #$00 ; |
  524. STA $14D4,x ; /
  525. RTS
  526.  
  527. ;; SPRITE KILLER - kills enemies
  528. ;; - important note: the reason I only check for "interact with stars/cape/fire/bricks"
  529. ;; is because some sprites with specially programmed shell interaction have this
  530. ;; as the only way to tell if they should be killed.
  531.  
  532. KILLSPRITES
  533. LDY #$0C ; load number of times to go through loop
  534. KILL_LOOP CPY #$00 ; \ zero? if so,
  535. BEQ END_KILL_LOOP ; / end loop
  536. DEY ; decrease # of times left+get index
  537. STX $06 ; \ if sprite is
  538. CPY $06 ; | this sprite
  539. BEQ KILL_LOOP ; / then ignore it
  540. LDA $14C8,y ; \ if sprite is not
  541. CMP #$08 ; | in a "tangible"
  542. BCC KILL_LOOP ; / mode, don't kill
  543. LDA $167A,y ; \ if sprite doesn't
  544. AND #%00000010 ; | interact with stars/cape/fire/bricks
  545. BNE KILL_LOOP ; / don't continue
  546. JSL $03B69F ; \
  547. PHX ; | if sprite is
  548. TYX ; | not touching
  549. JSL $03B6E5 ; | this sprite
  550. PLX ; | don't continue
  551. JSL $03B72B ; |
  552. BCC KILL_LOOP ; /
  553. LDA #SPRITEKILLSND ; \ play kill
  554. STA $1DFC ; / sound
  555. LDA $1656,y ; \ force sprite
  556. ORA #%10000000 ; | to disappear
  557. STA $1656,y ; / in smoke
  558. LDA #$02 ; \ set sprite into
  559. STA $14C8,y ; / death mode (status=2)
  560. END_KILL_LOOP RTS
  561.  
  562. ;; subroutine for bouncing
  563. ;; I put the code in a subroutine
  564. ;; because it is used more than once
  565. ;; throughout the main code
  566.  
  567. HIT_WALL LDA $B6,x ; \ decide which way rock is going to
  568. BPL HIT_POS ; / determine which handler code to use
  569. HIT_NEG LDA #$00 ; \
  570. SEC ; | if speed is negative
  571. SBC $B6,x ; | (which means left movement)
  572. LSR A ; | then handle it properly
  573. STA $B6,x ; |
  574. INC STARTOFFSET,x ; | .. also alter base position for rock
  575. BRA END_HIT ; /
  576. HIT_POS LDA $B6,x ; \
  577. LSR A ; | if speed is positive
  578. STA $B6,x ; | (which means right movement)
  579. LDA #$00 ; | then handle it properly
  580. SEC ; |
  581. SBC $B6,x ; |
  582. STA $B6,x ; | .. also alter base position for rock
  583. DEC STARTOFFSET,x ; /
  584. END_HIT RTS
  585.  
  586.  
  587. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  588. ; GRAPHICS ROUTINE
  589. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  590.  
  591. ROCK_YOFF = $F8 ; shift for whole rock
  592.  
  593. TILESDRAWN = $08 ; \ scratch RAM
  594. TEMP_FOR_TILE = $03 ; / addresses
  595.  
  596. FRAMES dcb $00,$00,$00,$00
  597. dcb $00,$00,$00,$00
  598. dcb $00,$00,$00,$00
  599. dcb $00,$00,$00,$00
  600.  
  601. ROCK_TILES dcb $CC,$CE,$EC,$EE ;$CC,$CE,$EC,$EE
  602. ROCK_XPOS dcb $F0,$00,$F0,$00
  603. ROCK_YPOS dcb $F8,$F8,$08,$08
  604.  
  605. SUB_GFX JSR GET_DRAW_INFO ; get info to draw tiles
  606. LDA FLIPXY,x ; \ store flip
  607. STA $02 ; / to scratch RAM
  608. STZ TILESDRAWN ; zero tiles drawn
  609. JSR DRAW_ROCK ; draw rock
  610. JSR SETTILES ; set tiles / don't draw offscreen
  611. ENDSUB RTS
  612.  
  613. DRAW_ROCK LDA OFFSET,x ; \
  614. PHY ; | set frame according
  615. TAY ; | to offset
  616. LDA FRAMES,y ; |
  617. PLY ; /
  618. STA TEMP_FOR_TILE ; store tile into scratch RAM
  619.  
  620. PHX ; back up X
  621. LDX #$00 ; load X with zero
  622. TILELP CPX #$04 ; end of loop?
  623. BNE NORETFRML ; if not, then don't end
  624. BRA RETFRML ; if so, end
  625. NORETFRML
  626. LDA $00 ; get sprite's X position
  627. PHY ; \
  628. LDY $02 ; | offset by
  629. BEQ NO_FLIP_R ; | this tile's
  630. SEC ; | X position
  631. SBC ROCK_XPOS,x ; | (add or
  632. BRA END_FLIP_R ; | subtract
  633. NO_FLIP_R CLC ; | depending on
  634. ADC ROCK_XPOS,x ; | direction)
  635. END_FLIP_R PLY ; /
  636. STA $0300,y ; set tile's X position
  637. LDA $01 ; get sprite's Y position
  638. PHY ; \
  639. LDY $02 ; | offset by
  640. BEQ NO_FLIP_R2 ; | this tile's
  641. SEC ; | Y position
  642. SBC ROCK_YPOS,x ; | (add or
  643. BRA END_FLIP_R2 ; | subtract
  644. NO_FLIP_R2 CLC ; | depending on
  645. ADC ROCK_YPOS,x ; | direction)
  646. END_FLIP_R2 PLY ; /
  647. CLC ; \ rock Y
  648. ADC #ROCK_YOFF ; / offset
  649. STA $0301,y ; set tile's Y position
  650. LDA TEMP_FOR_TILE ; load tile # from scratch RAM
  651. CLC ; \ shift tile right/down
  652. ADC ROCK_TILES,x ; / according to which part
  653. STA $0302,y ; set tile #
  654. PHX ; back up X (index to tile data)
  655. LDX $15E9 ; load X with index to sprite
  656. LDA $15F6,x ; load palette info
  657. ORA $64 ; add in priority bits
  658. PHX ; \
  659. LDX $02 ; | flip the tile
  660. BEQ NO_FLIP_XY ; | X and Y if
  661. ORA #%11000000 ; | address set
  662. NO_FLIP_XY PLX ; /
  663. STA $0303,y ; set extra info
  664. PLX ; load backed up X
  665. INC TILESDRAWN ; another tile was drawn
  666. INY ; \
  667. INY ; | index to next slot
  668. INY ; |
  669. INY ; /
  670. INX ; next tile to draw
  671. JMP TILELP ; loop (BRA is out of range)
  672. RETFRML PLX ; load backed up X
  673. ENDROCK RTS
  674.  
  675. SETTILES LDA TILESDRAWN ; \ don't do it
  676. BEQ NODRAW ; / if no tiles
  677. LDY #$02 ; #$02 means 16x16
  678. DEC A ; A = # tiles - 1
  679. JSL $01B7B3 ; don't draw if offscreen
  680. NODRAW RTS
  681.  
  682. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  683. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  684. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  685. ; ROUTINES FROM THE LIBRARY ARE PASTED BELOW
  686. ; You should never have to modify this code
  687. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  688. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  689. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  690.  
  691.  
  692.  
  693. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  694. ; GET_DRAW_INFO
  695. ; This is a helper for the graphics routine. It sets off screen flags, and sets up
  696. ; variables. It will return with the following:
  697. ;
  698. ; Y = index to sprite OAM ($300)
  699. ; $00 = sprite x position relative to screen boarder
  700. ; $01 = sprite y position relative to screen boarder
  701. ;
  702. ; It is adapted from the subroutine at $03B760
  703. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  704.  
  705. SPR_T1 dcb $0C,$1C
  706. SPR_T2 dcb $01,$02
  707.  
  708. GET_DRAW_INFO STZ $186C,x ; reset sprite offscreen flag, vertical
  709. STZ $15A0,x ; reset sprite offscreen flag, horizontal
  710. LDA $E4,x ; \
  711. CMP $1A ; | set horizontal offscreen if necessary
  712. LDA $14E0,x ; |
  713. SBC $1B ; |
  714. BEQ ON_SCREEN_X ; |
  715. INC $15A0,x ; /
  716.  
  717. ON_SCREEN_X LDA $14E0,x ; \
  718. XBA ; |
  719. LDA $E4,x ; |
  720. REP #$20 ; |
  721. SEC ; |
  722. SBC $1A ; | mark sprite invalid if far enough off screen
  723. CLC ; |
  724. ADC.W #$0040 ; |
  725. CMP.W #$0180 ; |
  726. SEP #$20 ; |
  727. ROL A ; |
  728. AND #$01 ; |
  729. STA $15C4,x ; /
  730. BNE INVALID ;
  731.  
  732. LDY #$00 ; \ set up loop:
  733. LDA $1662,x ; |
  734. AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
  735. BEQ ON_SCREEN_LOOP ; | else, go through loop once
  736. INY ; /
  737. ON_SCREEN_LOOP LDA $D8,x ; \
  738. CLC ; | set vertical offscreen if necessary
  739. ADC SPR_T1,y ; |
  740. PHP ; |
  741. CMP $1C ; | (vert screen boundry)
  742. ROL $00 ; |
  743. PLP ; |
  744. LDA $14D4,x ; |
  745. ADC #$00 ; |
  746. LSR $00 ; |
  747. SBC $1D ; |
  748. BEQ ON_SCREEN_Y ; |
  749. LDA $186C,x ; | (vert offscreen)
  750. ORA SPR_T2,y ; |
  751. STA $186C,x ; |
  752. ON_SCREEN_Y DEY ; |
  753. BPL ON_SCREEN_LOOP ; /
  754.  
  755. LDY $15EA,x ; get offset to sprite OAM
  756. LDA $E4,x ; \
  757. SEC ; |
  758. SBC $1A ; | $00 = sprite x position relative to screen boarder
  759. STA $00 ; /
  760. LDA $D8,x ; \
  761. SEC ; |
  762. SBC $1C ; | $01 = sprite y position relative to screen boarder
  763. STA $01 ; /
  764. RTS ; return
  765.  
  766. INVALID PLA ; \ return from *main gfx routine* subroutine...
  767. PLA ; | ...(not just this subroutine)
  768. RTS ; /
  769.  
  770.  
  771. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  772. ; SUB_OFF_SCREEN
  773. ; This subroutine deals with sprites that have moved off screen
  774. ; It is adapted from the subroutine at $01AC0D
  775. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  776.  
  777. SPR_T12 dcb $40,$B0
  778. SPR_T13 dcb $01,$FF
  779. SPR_T14 dcb $30,$C0,$A0,$C0,$A0,$F0,$60,$90 ;bank 1 sizes
  780. dcb $30,$C0,$A0,$80,$A0,$40,$60,$B0 ;bank 3 sizes
  781. SPR_T15 dcb $01,$FF,$01,$FF,$01,$FF,$01,$FF ;bank 1 sizes
  782. dcb $01,$FF,$01,$FF,$01,$00,$01,$FF ;bank 3 sizes
  783.  
  784. SUB_OFF_SCREEN_X1 LDA #$02 ; \ entry point of routine determines value of $03
  785. BRA STORE_03 ; | (table entry to use on horizontal levels)
  786. SUB_OFF_SCREEN_X2 LDA #$04 ; |
  787. BRA STORE_03 ; |
  788. SUB_OFF_SCREEN_X3 LDA #$06 ; |
  789. BRA STORE_03 ; |
  790. SUB_OFF_SCREEN_X4 LDA #$08 ; |
  791. BRA STORE_03 ; |
  792. SUB_OFF_SCREEN_X5 LDA #$0A ; |
  793. BRA STORE_03 ; |
  794. SUB_OFF_SCREEN_X6 LDA #$0C ; |
  795. BRA STORE_03 ; |
  796. SUB_OFF_SCREEN_X7 LDA #$0E ; |
  797. STORE_03 STA $03 ; |
  798. BRA START_SUB ; |
  799. SUB_OFF_SCREEN_X0 STZ $03 ; /
  800.  
  801. START_SUB JSR SUB_IS_OFF_SCREEN ; \ if sprite is not off screen, return
  802. BEQ RETURN_35 ; /
  803. LDA $5B ; \ goto VERTICAL_LEVEL if vertical level
  804. AND #$01 ; |
  805. BNE VERTICAL_LEVEL ; /
  806. LDA $D8,x ; \
  807. CLC ; |
  808. ADC #$50 ; | if the sprite has gone off the bottom of the level...
  809. LDA $14D4,x ; | (if adding 0x50 to the sprite y position would make the high byte >= 2)
  810. ADC #$00 ; |
  811. CMP #$02 ; |
  812. BPL ERASE_SPRITE ; / ...erase the sprite
  813. LDA $167A,x ; \ if "process offscreen" flag is set, return
  814. AND #$04 ; |
  815. BNE RETURN_35 ; /
  816. LDA $13 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0756 VC:176 00 FL:205
  817. AND #$01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0780 VC:176 00 FL:205
  818. ORA $03 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0796 VC:176 00 FL:205
  819. STA $01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0820 VC:176 00 FL:205
  820. TAY ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0844 VC:176 00 FL:205
  821. LDA $1A ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0858 VC:176 00 FL:205
  822. CLC ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0882 VC:176 00 FL:205
  823. ADC SPR_T14,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0896 VC:176 00 FL:205
  824. ROL $00 ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizcHC:0928 VC:176 00 FL:205
  825. CMP $E4,x ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:0966 VC:176 00 FL:205
  826. PHP ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:0996 VC:176 00 FL:205
  827. LDA $1B ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizCHC:1018 VC:176 00 FL:205
  828. LSR $00 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdiZCHC:1042 VC:176 00 FL:205
  829. ADC SPR_T15,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizcHC:1080 VC:176 00 FL:205
  830. PLP ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F0 P:eNvMXdizcHC:1112 VC:176 00 FL:205
  831. SBC $14E0,x ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1140 VC:176 00 FL:205
  832. STA $00 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1172 VC:176 00 FL:205
  833. LSR $01 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1196 VC:176 00 FL:205
  834. BCC SPR_L31 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1234 VC:176 00 FL:205
  835. EOR #$80 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1250 VC:176 00 FL:205
  836. STA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1266 VC:176 00 FL:205
  837. SPR_L31 LDA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1290 VC:176 00 FL:205
  838. BPL RETURN_35 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1314 VC:176 00 FL:205
  839. ERASE_SPRITE LDA $14C8,x ; \ if sprite status < 8, permanently erase sprite
  840. CMP #$08 ; |
  841. BCC KILL_SPRITE ; /
  842. LDY $161A,x ;A:FF08 X:0007 Y:0001 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1108 VC:059 00 FL:2878
  843. CPY #$FF ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1140 VC:059 00 FL:2878
  844. BEQ KILL_SPRITE ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1156 VC:059 00 FL:2878
  845. LDA #$00 ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1172 VC:059 00 FL:2878
  846. STA $1938,y ;A:FF00 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZcHC:1188 VC:059 00 FL:2878
  847. KILL_SPRITE STZ $14C8,x ; erase sprite
  848. RETURN_35 RTS ; return
  849.  
  850. VERTICAL_LEVEL LDA $167A,x ; \ if "process offscreen" flag is set, return
  851. AND #$04 ; |
  852. BNE RETURN_35 ; /
  853. LDA $13 ; \
  854. LSR A ; |
  855. BCS RETURN_35 ; /
  856. LDA $E4,x ; \
  857. CMP #$00 ; | if the sprite has gone off the side of the level...
  858. LDA $14E0,x ; |
  859. SBC #$00 ; |
  860. CMP #$02 ; |
  861. BCS ERASE_SPRITE ; / ...erase the sprite
  862. LDA $13 ;A:0000 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:1218 VC:250 00 FL:5379
  863. LSR A ;A:0016 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1242 VC:250 00 FL:5379
  864. AND #$01 ;A:000B X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1256 VC:250 00 FL:5379
  865. STA $01 ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1272 VC:250 00 FL:5379
  866. TAY ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1296 VC:250 00 FL:5379
  867. LDA $1C ;A:001A X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0052 VC:251 00 FL:5379
  868. CLC ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0076 VC:251 00 FL:5379
  869. ADC SPR_T12,y ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0090 VC:251 00 FL:5379
  870. ROL $00 ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:enVMXdizCHC:0122 VC:251 00 FL:5379
  871. CMP $D8,x ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0160 VC:251 00 FL:5379
  872. PHP ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0190 VC:251 00 FL:5379
  873. LDA.W $001D ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F2 P:eNVMXdizcHC:0212 VC:251 00 FL:5379
  874. LSR $00 ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdiZcHC:0244 VC:251 00 FL:5379
  875. ADC SPR_T13,y ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdizCHC:0282 VC:251 00 FL:5379
  876. PLP ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:envMXdiZCHC:0314 VC:251 00 FL:5379
  877. SBC $14D4,x ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0342 VC:251 00 FL:5379
  878. STA $00 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0374 VC:251 00 FL:5379
  879. LDY $01 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0398 VC:251 00 FL:5379
  880. BEQ SPR_L38 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0422 VC:251 00 FL:5379
  881. EOR #$80 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0438 VC:251 00 FL:5379
  882. STA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0454 VC:251 00 FL:5379
  883. SPR_L38 LDA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0478 VC:251 00 FL:5379
  884. BPL RETURN_35 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0502 VC:251 00 FL:5379
  885. BMI ERASE_SPRITE ;A:8AFF X:0002 Y:0000 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0704 VC:184 00 FL:5490
  886.  
  887. SUB_IS_OFF_SCREEN LDA $15A0,x ; \ if sprite is on screen, accumulator = 0
  888. ORA $186C,x ; |
  889. RTS ; / return
  890.  
  891.  
  892. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  893. ; SUB_HORZ_POS
  894. ; This routine determines which side of the sprite Mario is on. It sets the Y register
  895. ; to the direction such that the sprite would face Mario
  896. ; It is ripped from $03B817
  897. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  898.  
  899. SUB_HORZ_POS LDY #$00 ;A:25D0 X:0006 Y:0001 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1020 VC:097 00 FL:31642
  900. LDA $94 ;A:25D0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZCHC:1036 VC:097 00 FL:31642
  901. SEC ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1060 VC:097 00 FL:31642
  902. SBC $E4,x ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1074 VC:097 00 FL:31642
  903. STA $0F ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1104 VC:097 00 FL:31642
  904. LDA $95 ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1128 VC:097 00 FL:31642
  905. SBC $14E0,x ;A:2500 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZcHC:1152 VC:097 00 FL:31642
  906. BPL SPR_L16 ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1184 VC:097 00 FL:31642
  907. INY ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1200 VC:097 00 FL:31642
  908. SPR_L16 RTS ;A:25FF X:0006 Y:0001 D:0000 DB:03 S:01ED P:envMXdizcHC:1214 VC:097 00 FL:31642
  909.  
  910. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement