Guest User

Untitled

a guest
Aug 24th, 2011
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print "INIT ",pc
  2. JSR SUB_HORZ_POS
  3. TYA
  4. STA $157C,x
  5. LDA #$19
  6. STA $1528,x
  7. RTL
  8.  
  9. print "MAIN ",pc
  10. PHB ;\
  11. PHK ; | Change the data bank to the one our code is running from.
  12. PLB ; | This is a good practice.
  13. JSR SpriteCode ; | Jump to the sprite's function.
  14. PLB ; | Restore old data bank.
  15. RTL ;/ And return.
  16.  
  17. ;===================================
  18. ;Sprite Function
  19. ;===================================
  20.  
  21. RETURN: RTS
  22.  
  23. LeftSpd: db $00,$9D,$A0,$A3,$A5,$A8,$AA,$B0,$B4,$B8,$BB,$BD,$C0,$C7,$C8,$C9,$CA,$D0,$D1,$D8,$D9,$E0,$E1,$F6,$F7,$F8
  24. RightSpd: db $00,$75,$72,$6F,$6C,$6A,$67,$5F,$58,$53,$4F,$4B,$49,$3F,$3D,$3B,$3A,$31,$30,$2F,$2E,$21,$20,$0E,$0D,$0C
  25.  
  26. NameTable: db $11,$19,$78 ;HP:
  27. !NameSize = $02
  28. !Position = $0F24
  29.  
  30. SpriteCode:
  31. JSR SUB_GFX
  32. PHX
  33. JSR DrawTilemaps ; Draw the tilemaps.
  34. PLX
  35. LDA $1528,x
  36. PHX
  37. JSR HexDec
  38. STX !Position+!NameSize+1
  39. STA !Position+!NameSize+2
  40. PLX
  41. LDA $14C8,x ;\
  42. CMP #$08 ; | If sprite dead,
  43. BNE RETURN ;/ Return.
  44. LDA $9D ;\
  45. BNE RETURN ;/ If locked, return.
  46.  
  47. LDA $1588,x
  48. AND #$03
  49. BEQ NoFlip ; If touching an object ...
  50. LDA $157C,x
  51. EOR #$01 ; Flip direction.
  52. STA $157C,x
  53.  
  54. NoFlip:
  55. JSR SUB_OFF_SCREEN_X0 ; Handle offscreen.
  56.  
  57. LDY $1528,x
  58. LDA $157C,x
  59. BEQ Right
  60. LDA LeftSpd,y
  61. BRA DoSpeed
  62. Right:
  63. LDA RightSpd,y
  64. DoSpeed:
  65. STA $B6,x
  66. LDA #$10
  67. STA $AA,x
  68. JSL $01802A
  69.  
  70. LDA $1594,x
  71. CMP #$D5
  72. BEQ TIME_TO_SHOOT
  73. INC $1594,x
  74. BRA SHARED
  75.  
  76. TIME_TO_SHOOT:
  77. JSR DrawSmoke
  78. JSR SUB_FIRE_THROW
  79. STZ $1594,x
  80.  
  81. SHARED:
  82. JSL $01802A
  83. JSL $03B664
  84. JSR GetSpriteClipping
  85. JSL $03B72B
  86. BCC NoContact
  87.  
  88. JSR SUB_VERT_POS
  89. LDA $0E
  90. CMP #$E6
  91. BPL SpriteWins
  92.  
  93. JSL $01AB99
  94. JSL $01AA33
  95. LDA #$A0
  96. STA $7D
  97. DEC $1528,x
  98. LDA $1528,x
  99. BEQ KillSprite
  100. LDA #$54
  101. STA $1DFC ; SFX When jumping on the sprite.
  102. RTS
  103.  
  104. SpriteWins:
  105. LDA $1490
  106. BNE NoContact ; NOTE: Don't kill the sprite when having a star.
  107. JSL $00F5B7
  108. NoContact:
  109. RTS
  110.  
  111. KillSprite:
  112. STZ $14C8,x ; die
  113. LDA #$3C
  114. STA $1DFC
  115. JSR DrawSmoke
  116. JSL $07FC3B
  117. LDA #$80
  118. STA $1DFB
  119. LDA #$FF
  120. STA $1493 ; activate "end level" flag
  121. LDA #$00
  122. STA $141C ; normal path
  123. LDA #$0B
  124. STA $71
  125. RTS
  126.  
  127. ;==================================================================
  128. ;Draw Tiles To Status Bar.
  129. ;==================================================================
  130. DrawTilemaps:
  131. LDX #!NameSize
  132. DrawLoop:
  133. LDA NameTable,x ; Load the tile data indexed by the size.
  134. STA !Position,x ; .. and store to appriopriate tile.
  135. DEX
  136. BPL DrawLoop ; So far, it draws "AAAA"
  137. RTS ; We draw the health routine later, after pulling X.
  138. ; ORLY
  139. ;==================================================================
  140. ;Hex/Dec Subroutine.
  141. ;==================================================================
  142. HexDec:
  143. LDX #$00
  144. HexLoop:
  145. CMP #$0A ; While (A == $0A) {
  146. BCC NoConvo ; }
  147. SBC #$0A ; Else { DrawLine.(A - 10); Fail C++ ftw.
  148. INX ; (X + 1) }
  149. BRA HexLoop ; Cout << ("C++ Fail ftw");
  150. NoConvo: ; Oh wait where's the cin command?!
  151. RTS
  152.  
  153. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  154. ; fire routine
  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156.  
  157. XF_OFFSET: db $13,$FC
  158. XF_OFFSET2: db $00,$FF
  159.  
  160. RETURN68: RTS
  161. SUB_FIRE_THROW: ;LDA $15A0,x ; no fire if off screen
  162. LDA $186C,x
  163. ORA $15D0,x
  164. BNE RETURN68
  165.  
  166. JSL $02A9DE ; \ get an index to an unused sprite slot, return if all slots full
  167. BMI RETURN68 ; / after: Y has index of sprite being generated
  168.  
  169. LDA #$01 ; \ set sprite status for new sprite
  170. STA $14C8,y ; /
  171.  
  172. LDA #$B6 ;sprite to fire
  173. STA $009E,y
  174.  
  175. PHY ; set x position for new sprite
  176. LDA $157C,x
  177. TAY
  178. LDA $E4,x
  179. CLC
  180. ADC XF_OFFSET,y
  181. PLY
  182. STA $00E4,y
  183.  
  184. PHY ; set x position for new sprite
  185. LDA $157C,x
  186. TAY
  187. LDA $14E0,x
  188. ADC XF_OFFSET2,y
  189. PLY
  190. STA $14E0,y
  191.  
  192. LDA $D8,x ; \ set y position for new sprite
  193. SEC ; | (y position of generator - 1)
  194. SBC #$03 ; |
  195. STA $00D8,y ; |
  196. LDA $14D4,x ; |
  197. SBC #$00 ; |
  198. STA $14D4,y ; /
  199.  
  200. PHX ; \ before: X must have index of sprite being generated
  201. TYX ; | routine clears *all* old sprite values...
  202. JSL $07F7D2 ; | ...and loads in new values for the 6 main sprite tables
  203. PLX ; /
  204.  
  205.  
  206. LDA #$09
  207. STA $1DFC
  208.  
  209. RETURN67: RTS ; return
  210.  
  211. DrawSmoke: LDY #$03 ; \ find a free slot to display effect
  212. FINDFREE: LDA $17C0,y ; |
  213. BEQ FOUNDONE ; |
  214. DEY ; |
  215. BPL FINDFREE ; |
  216. RTS ; / return if no slots open
  217.  
  218. FOUNDONE: LDA #$01 ; \ set effect graphic to smoke graphic
  219. STA $17C0,y ; /
  220. LDA #$1B ; \ set time to show smoke
  221. STA $17CC,y ; /
  222. LDA $D8,x ; \ smoke y position = generator y position
  223. STA $17C4,y ; /
  224. LDA $E4,x ; \ load generator x position and store it for later
  225. STA $17C8,y ; /
  226. RTS
  227.  
  228. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  229. ; sprite clipping routine
  230. ; ripped and modified by Roy, then modified more by Sonikku
  231. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  232. GetSpriteClipping:
  233. PHY
  234. PHX
  235. TXY
  236. LDA $00E4,y
  237. CLC
  238. ADC #$04 ; Starting X pos of sprite clipping = sprite center position - $0C ($0C pixels to the left)
  239. STA $04
  240. LDA $14E0,y
  241. ADC #$00
  242. STA $0A
  243. LDA #$30 ; Width of sprite clipping
  244. STA $06
  245. LDA $00D8,y
  246. SEC
  247. SBC #$20 ; Starting Y pos of sprite clipping = sprite center position - $2C ($2C pixels above)
  248. STA $05
  249. LDA $14D4,y
  250. SBC #$00
  251. STA $0B
  252. LDA #$30 ; Height of sprite clipping
  253. STA $07
  254. PLX
  255. PLY
  256. RTS
  257.  
  258. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  259. ; graphics routine
  260. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  261. TILEMAP: db $84,$82,$80 ; facing right
  262. db $A4,$A2,$A0
  263. db $C4,$C2,$C0
  264.  
  265. db $80,$82,$84 ; facing left
  266. db $A0,$A2,$A4
  267. db $C0,$C2,$C4
  268.  
  269. db $8A,$88,$86 ; facing right
  270. db $AA,$A8,$A6
  271. db $CA,$C8,$C6
  272.  
  273. db $86,$88,$8A ; facing left
  274. db $A6,$A8,$AA
  275. db $C6,$C8,$CA
  276.  
  277. X_OFFSET: db $00,$10,$20
  278. db $00,$10,$20
  279. db $00,$10,$20
  280.  
  281. Y_OFFSET: db $E0,$E0,$E0
  282. db $F0,$F0,$F0
  283. db $00,$00,$00
  284.  
  285. PROPERTIES: db $40,$40,$40
  286. db $40,$40,$40
  287. db $40,$40,$40
  288.  
  289. db $00,$00,$00
  290. db $00,$00,$00
  291. db $00,$00,$00
  292.  
  293. SUB_GFX: JSR GET_DRAW_INFO ; sets y = OAM offset
  294. LDA $157C,x
  295. STA $04
  296. ASL A
  297. ASL A
  298. ASL A
  299. CLC
  300. ADC $04
  301. STA $02
  302.  
  303. PHX
  304. LDX #$08
  305. LOOP_START: PHX
  306. LDA X_OFFSET,x
  307. CLC
  308. ADC $00 ; \ tile x position = sprite y location ($01)
  309. STA $0300,y ; /
  310.  
  311. LDA Y_OFFSET,x
  312. CLC
  313. ADC $01 ; \ tile y position = sprite x location ($00)
  314. STA $0301,y ; /
  315.  
  316. TXA
  317. CLC
  318. ADC $02
  319. TAX
  320.  
  321. PHX
  322. LDA $14
  323. LSR A
  324. LSR A
  325. LSR A
  326. AND #$01
  327. BNE SKIP
  328. TXA
  329. CLC
  330. ADC #$12
  331. TAX
  332. SKIP: LDA TILEMAP,x
  333. STA $0302,y
  334. PLX
  335.  
  336. PHX
  337. LDX $15E9
  338. LDA $15F6,x ; tile properties xyppccct, format
  339. PLX
  340. ORA PROPERTIES,x
  341. ORA $64 ; add in tile priority of level
  342. STA $0303,y ; store tile properties
  343. PLX
  344.  
  345. INY ; \ increase index to sprite tile map ($300)...
  346. INY ; | ...we wrote 1 16x16 tile...
  347. INY ; | ...sprite OAM is 8x8...
  348. INY ; / ...so increment 4 times
  349. DEX
  350. BPL LOOP_START
  351.  
  352. PLX
  353. LDY #$02 ; \ 460 = 2 (all 16x16 tiles)
  354. LDA #$08 ; | A = (number of tiles drawn - 1)
  355. JSL $01B7B3 ; / don't draw if offscreen
  356. RTS ; return
  357.  
  358. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  359. ; GET_DRAW_INFO
  360. ; This is a helper for the graphics routine. It sets off screen flags, and sets up
  361. ; variables. It will return with the following:
  362. ;
  363. ; Y = index to sprite OAM ($300)
  364. ; $00 = sprite x position relative to screen boarder
  365. ; $01 = sprite y position relative to screen boarder
  366. ;
  367. ; It is adapted from the subroutine at $03B760
  368. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  369.  
  370. SPR_T1: db $0C,$1C
  371. SPR_T2: db $01,$02
  372.  
  373. GET_DRAW_INFO: STZ $186C,x ; reset sprite offscreen flag, vertical
  374. STZ $15A0,x ; reset sprite offscreen flag, horizontal
  375. LDA $E4,x ; \
  376. CMP $1A ; | set horizontal offscreen if necessary
  377. LDA $14E0,x ; |
  378. SBC $1B ; |
  379. BEQ ON_SCREEN_X ; |
  380. INC $15A0,x ; /
  381.  
  382. ON_SCREEN_X: LDA $14E0,x ; \
  383. XBA ; |
  384. LDA $E4,x ; |
  385. REP #$20 ; |
  386. SEC ; |
  387. SBC $1A ; | mark sprite invalid if far enough off screen
  388. CLC ; |
  389. ADC.w #$0040 ; |
  390. CMP.w #$0180 ; |
  391. SEP #$20 ; |
  392. ROL A ; |
  393. AND #$01 ; |
  394. STA $15C4,x ; /
  395. BNE INVALID ;
  396.  
  397. LDY #$00 ; \ set up loop:
  398. LDA $1662,x ; |
  399. AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
  400. BEQ ON_SCREEN_LOOP ; | else, go through loop once
  401. INY ; /
  402. ON_SCREEN_LOOP: LDA $D8,x ; \
  403. CLC ; | set vertical offscreen if necessary
  404. ADC SPR_T1,y ; |
  405. PHP ; |
  406. CMP $1C ; | (vert screen boundry)
  407. ROL $00 ; |
  408. PLP ; |
  409. LDA $14D4,x ; |
  410. ADC #$00 ; |
  411. LSR $00 ; |
  412. SBC $1D ; |
  413. BEQ ON_SCREEN_Y ; |
  414. LDA $186C,x ; | (vert offscreen)
  415. ORA SPR_T2,y ; |
  416. STA $186C,x ; |
  417. ON_SCREEN_Y: DEY ; |
  418. BPL ON_SCREEN_LOOP ; /
  419.  
  420. LDY $15EA,x ; get offset to sprite OAM
  421. LDA $E4,x ; \
  422. SEC ; |
  423. SBC $1A ; | $00 = sprite x position relative to screen boarder
  424. STA $00 ; /
  425. LDA $D8,x ; \
  426. SEC ; |
  427. SBC $1C ; | $01 = sprite y position relative to screen boarder
  428. STA $01 ; /
  429. RTS ; return
  430.  
  431. INVALID: PLA ; \ return from *main gfx routine* subroutine...
  432. PLA ; | ...(not just this subroutine)
  433. RTS ; /
  434.  
  435. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  436. ; SUB_OFF_SCREEN
  437. ; This subroutine deals with sprites that have moved off screen
  438. ; It is adapted from the subroutine at $01AC0D
  439. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  440.  
  441. SPR_T12: db $40,$B0
  442. SPR_T13: db $01,$FF
  443. SPR_T14: db $30,$C0,$A0,$C0,$A0,$F0,$60,$90 ;bank 1 sizes
  444. db $30,$C0,$A0,$80,$A0,$40,$60,$B0 ;bank 3 sizes
  445. SPR_T15: db $01,$FF,$01,$FF,$01,$FF,$01,$FF ;bank 1 sizes
  446. db $01,$FF,$01,$FF,$01,$00,$01,$FF ;bank 3 sizes
  447.  
  448. SUB_OFF_SCREEN_X1: LDA #$02 ; \ entry point of routine determines value of $03
  449. BRA STORE_03 ; | (table entry to use on horizontal levels)
  450. SUB_OFF_SCREEN_X2: LDA #$04 ; |
  451. BRA STORE_03 ; |
  452. SUB_OFF_SCREEN_X3: LDA #$06 ; |
  453. BRA STORE_03 ; |
  454. SUB_OFF_SCREEN_X4: LDA #$08 ; |
  455. BRA STORE_03 ; |
  456. SUB_OFF_SCREEN_X5: LDA #$0A ; |
  457. BRA STORE_03 ; |
  458. SUB_OFF_SCREEN_X6: LDA #$0C ; |
  459. BRA STORE_03 ; |
  460. SUB_OFF_SCREEN_X7: LDA #$0E ; |
  461. STORE_03: STA $03 ; |
  462. BRA START_SUB ; |
  463. SUB_OFF_SCREEN_X0: STZ $03 ; /
  464.  
  465. START_SUB: JSR SUB_IS_OFF_SCREEN ; \ if sprite is not off screen, return
  466. BEQ RETURN_35 ; /
  467. LDA $5B ; \ goto VERTICAL_LEVEL if vertical level
  468. AND #$01 ; |
  469. BNE VERTICAL_LEVEL ; /
  470. LDA $D8,x ; \
  471. CLC ; |
  472. ADC #$50 ; | if the sprite has gone off the bottom of the level...
  473. LDA $14D4,x ; | (if adding 0x50 to the sprite y position would make the high byte >= 2)
  474. ADC #$00 ; |
  475. CMP #$02 ; |
  476. BPL ERASE_SPRITE ; / ...erase the sprite
  477. LDA $167A,x ; \ if "process offscreen" flag is set, return
  478. AND #$04 ; |
  479. BNE RETURN_35 ; /
  480. LDA $13 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0756 VC:176 00 FL:205
  481. AND #$01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0780 VC:176 00 FL:205
  482. ORA $03 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0796 VC:176 00 FL:205
  483. STA $01 ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0820 VC:176 00 FL:205
  484. TAY ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0844 VC:176 00 FL:205
  485. LDA $1A ;A:8A01 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizcHC:0858 VC:176 00 FL:205
  486. CLC ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0882 VC:176 00 FL:205
  487. ADC SPR_T14,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZcHC:0896 VC:176 00 FL:205
  488. ROL $00 ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizcHC:0928 VC:176 00 FL:205
  489. CMP $E4,x ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:0966 VC:176 00 FL:205
  490. PHP ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:0996 VC:176 00 FL:205
  491. LDA $1B ;A:8AC0 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizCHC:1018 VC:176 00 FL:205
  492. LSR $00 ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdiZCHC:1042 VC:176 00 FL:205
  493. ADC SPR_T15,y ;A:8A00 X:0009 Y:0001 D:0000 DB:01 S:01F0 P:envMXdizcHC:1080 VC:176 00 FL:205
  494. PLP ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F0 P:eNvMXdizcHC:1112 VC:176 00 FL:205
  495. SBC $14E0,x ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1140 VC:176 00 FL:205
  496. STA $00 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1172 VC:176 00 FL:205
  497. LSR $01 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:eNvMXdizCHC:1196 VC:176 00 FL:205
  498. BCC SPR_L31 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1234 VC:176 00 FL:205
  499. EOR #$80 ;A:8AFF X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdiZCHC:1250 VC:176 00 FL:205
  500. STA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1266 VC:176 00 FL:205
  501. SPR_L31: LDA $00 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1290 VC:176 00 FL:205
  502. BPL RETURN_35 ;A:8A7F X:0009 Y:0001 D:0000 DB:01 S:01F1 P:envMXdizCHC:1314 VC:176 00 FL:205
  503. ERASE_SPRITE: LDA $14C8,x ; \ if sprite status < 8, permanently erase sprite
  504. CMP #$08 ; |
  505. BCC KILL_SPRITE ; /
  506. LDY $161A,x ;A:FF08 X:0007 Y:0001 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1108 VC:059 00 FL:2878
  507. CPY #$FF ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZCHC:1140 VC:059 00 FL:2878
  508. BEQ KILL_SPRITE ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1156 VC:059 00 FL:2878
  509. LDA #$00 ;A:FF08 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdizcHC:1172 VC:059 00 FL:2878
  510. STA $1938,y ;A:FF00 X:0007 Y:0000 D:0000 DB:01 S:01F3 P:envMXdiZcHC:1188 VC:059 00 FL:2878
  511. KILL_SPRITE: STZ $14C8,x ; erase sprite
  512. RETURN_35: RTS ; return
  513.  
  514. VERTICAL_LEVEL: LDA $167A,x ; \ if "process offscreen" flag is set, return
  515. AND #$04 ; |
  516. BNE RETURN_35 ; /
  517. LDA $13 ; \
  518. LSR A ; |
  519. BCS RETURN_35 ; /
  520. LDA $E4,x ; \
  521. CMP #$00 ; | if the sprite has gone off the side of the level...
  522. LDA $14E0,x ; |
  523. SBC #$00 ; |
  524. CMP #$02 ; |
  525. BCS ERASE_SPRITE ; / ...erase the sprite
  526. LDA $13 ;A:0000 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:1218 VC:250 00 FL:5379
  527. LSR A ;A:0016 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1242 VC:250 00 FL:5379
  528. AND #$01 ;A:000B X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1256 VC:250 00 FL:5379
  529. STA $01 ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1272 VC:250 00 FL:5379
  530. TAY ;A:0001 X:0009 Y:00E4 D:0000 DB:01 S:01F3 P:envMXdizcHC:1296 VC:250 00 FL:5379
  531. LDA $1C ;A:001A X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0052 VC:251 00 FL:5379
  532. CLC ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0076 VC:251 00 FL:5379
  533. ADC SPR_T12,y ;A:00BD X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0090 VC:251 00 FL:5379
  534. ROL $00 ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:enVMXdizCHC:0122 VC:251 00 FL:5379
  535. CMP $D8,x ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0160 VC:251 00 FL:5379
  536. PHP ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0190 VC:251 00 FL:5379
  537. LDA $001D ;A:006D X:0009 Y:0001 D:0000 DB:01 S:01F2 P:eNVMXdizcHC:0212 VC:251 00 FL:5379
  538. LSR $00 ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdiZcHC:0244 VC:251 00 FL:5379
  539. ADC SPR_T13,y ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:enVMXdizCHC:0282 VC:251 00 FL:5379
  540. PLP ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F2 P:envMXdiZCHC:0314 VC:251 00 FL:5379
  541. SBC $14D4,x ;A:0000 X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNVMXdizcHC:0342 VC:251 00 FL:5379
  542. STA $00 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0374 VC:251 00 FL:5379
  543. LDY $01 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0398 VC:251 00 FL:5379
  544. BEQ SPR_L38 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0422 VC:251 00 FL:5379
  545. EOR #$80 ;A:00FF X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0438 VC:251 00 FL:5379
  546. STA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0454 VC:251 00 FL:5379
  547. SPR_L38: LDA $00 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0478 VC:251 00 FL:5379
  548. BPL RETURN_35 ;A:007F X:0009 Y:0001 D:0000 DB:01 S:01F3 P:envMXdizcHC:0502 VC:251 00 FL:5379
  549. BMI ERASE_SPRITE ;A:8AFF X:0002 Y:0000 D:0000 DB:01 S:01F3 P:eNvMXdizcHC:0704 VC:184 00 FL:5490
  550.  
  551. SUB_IS_OFF_SCREEN: LDA $15A0,x ; \ if sprite is on screen, accumulator = 0
  552. ORA $186C,x ; |
  553. RTS ; / return
  554.  
  555. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  556. ; SUB_VERT_POS
  557. ; This routine determines if Mario is above or below the sprite. It sets the Y register
  558. ; to the direction such that the sprite would face Mario
  559. ; It is ripped from $03B829
  560. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  561.  
  562. SUB_VERT_POS: LDY #$00 ;A:25A1 X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizCHC:0130 VC:085 00 FL:924
  563. LDA $96 ;A:25A1 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdiZCHC:0146 VC:085 00 FL:924
  564. SEC ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0170 VC:085 00 FL:924
  565. SBC $D8,x ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0184 VC:085 00 FL:924
  566. CLC
  567. ADC #$20
  568. STA $0E ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0214 VC:085 00 FL:924
  569. LDA $97 ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0238 VC:085 00 FL:924
  570. SBC $14D4,x ;A:2501 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizcHC:0262 VC:085 00 FL:924
  571. BPL SPR_L11 ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0294 VC:085 00 FL:924
  572. INY ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0310 VC:085 00 FL:924
  573. SPR_L11: RTS ;A:25FF X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizcHC:0324 VC:085 00 FL:924
  574.  
  575. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  576. ; SUB HORZ POS
  577. ;
  578. ; $B817 - horizontal mario/sprite check - shared
  579. ; Y = 1 if mario left of sprite??
  580. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  581.  
  582. ;org $03B817
  583.  
  584. 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
  585. LDA $94 ;A:25D0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZCHC:1036 VC:097 00 FL:31642
  586. SEC ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1060 VC:097 00 FL:31642
  587. SBC $E4,x ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1074 VC:097 00 FL:31642
  588. STA $0F ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1104 VC:097 00 FL:31642
  589. LDA $95 ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1128 VC:097 00 FL:31642
  590. SBC $14E0,x ;A:2500 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZcHC:1152 VC:097 00 FL:31642
  591. BPL LABEL16 ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1184 VC:097 00 FL:31642
  592. INY ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1200 VC:097 00 FL:31642
  593. LABEL16: RTS ;A:25FF X:0006 Y:0001 D:0000 DB:03 S:01ED P:envMXdizcHC:1214 VC:097 00 FL:31642
  594.  
  595. print 'Insert size: ',bytes
RAW Paste Data