Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.57 KB | None | 0 0
  1. ;smb3 status bar
  2. ;by Ladida
  3.  
  4. !base = $0000
  5. if read1($00FFD5) == $23
  6. sa1rom
  7. !base = $6000
  8. endif
  9.  
  10.  
  11.  
  12. ;SMB3 and SMW differ in which counters keep leading zeros and which replace them
  13. ;with spaces. the below defines are defaulted to SMB3 behavior
  14. ;0 = false (no leading zeroes, replace with spaces)
  15. ;1 = true (keep the leading zeroes)
  16.  
  17. !ZERO_coins = 0
  18. !ZERO_lives = 0
  19. !ZERO_score = 1
  20. !ZERO_time = 1
  21. !ZERO_bonus = 0
  22.  
  23.  
  24. !NULL = $FE ;fill tile in GFX28/29 (used for replacing leading zeroes)
  25.  
  26.  
  27. !Sound = $01 ;[P-Meter] Sound effect to play when you are at full speed
  28. !SoundBank = $1DFC|!base ;[P-Meter] Sound bank for above sound effect
  29.  
  30.  
  31. ;DONT edit these unless you know what you're doing
  32. !status_tile = $0BF6|!base
  33. !status_prop = $0C76|!base
  34. !statusloc = !status_tile+$22
  35. !status_palette = $0CF6|!base ;status bar palette is here (64 bytes max)
  36. !status_OAM = $0EFC|!base ;status bar OAM is here (5 tiles max + 32 byte high table)
  37. !altram = $0D36|!base
  38. !l3_line1 = !altram
  39. !l3_line2 = !altram+$2
  40. !l1y_mirror = !altram+$4
  41. !l1y_mirror_alt = !altram+$6
  42. !l2y_mirror = !altram+$8
  43. !l2y_mirror_alt = !altram+$A
  44. !l1y_end = !altram+$C
  45. !hdmatbl = !altram+$E
  46.  
  47.  
  48.  
  49. ;location of counters in status bar. only change the added value. the bottom row is +$20
  50. ;if you want the counter disabled, set it equal to 0 instead of !statusloc+whatever
  51. ;note that disabling a counter only affects the display, not the functionality
  52.  
  53. !world = !statusloc+$04 ;1 tile
  54. !pmeter = !statusloc+$06 ;8 tiles
  55. !coins = !statusloc+$10 ;2 tiles
  56. !bonus = !statusloc+$17 ;4 tiles, 2 at !bonus and 2 at !bonus+$20
  57. !player = !statusloc+$20+$00 ;2 tiles
  58. !lives = !statusloc+$20+$03 ;2 tiles
  59. !score = !statusloc+$20+$06 ;6 tiles (final zero is not included)
  60. !time = !statusloc+$20+$0F ;3 tiles
  61. !yicoins = !statusloc+$20+$15 ;1 tile
  62.  
  63. !itembox = $C7E0 ;high = Y, low = X. $0000 = disable
  64.  
  65.  
  66. ;below defines are for the P-Meter
  67.  
  68. !EmptyTri = $0F ;Empty tile of triangle
  69. !EmptyPal = $28
  70. !FillTri = $0E ;Filled tile of triangle
  71. !FillPal = $20
  72.  
  73. !EmptyLP = $0A ;Empty tile of P, left side
  74. !EmptyRP = $0B ;Empty tile of P, right side
  75.  
  76. !FillLP = $0C ;Filled tile of P, left side
  77. !FillRP = $0D ;Filled tile of P, right side
  78.  
  79.  
  80.  
  81.  
  82.  
  83. org read3($0081E3)+7 ;LM hijack that skips position update during lag
  84. dl LagFix ;but we need to run the sprite DMA so we rewrite it
  85.  
  86.  
  87. org $05B129
  88. NOP #3 ;STZ $0D9F
  89.  
  90. org $05B296
  91. db $0C ;$8D
  92.  
  93.  
  94. org $008292
  95. LDY #$C0 ;run IRQ on this scanline
  96.  
  97. org $0082A4 ;NMI hijack
  98. autoclean JML PreStatusBar
  99. NOP #2
  100.  
  101. org $00838F ;IRQ hijack
  102. autoclean JML PostStatusBar
  103. NOP
  104.  
  105.  
  106.  
  107. org $05BEA2
  108. JML UploadStatusBar
  109.  
  110. org $0082E8
  111. BRA $01 : NOP
  112. org $0081F4
  113. BRA $01 : NOP
  114.  
  115. org $008DAC
  116. UploadStatusBar:
  117. LDX $0100|!base
  118. CPX #$12
  119. BNE +
  120. LDX #$80 : STX $2115
  121. LDA #$4000 : STA $2116
  122. LDA #$1801 : STA $4310
  123. LDA.w #StatusBarGFX : STA $4312
  124. LDX.b #StatusBarGFX>>16 : STX $4314
  125. LDA #$0380 : STA $4315
  126. LDX #$02 : STX $420B
  127. LDX #$3F
  128. -
  129. LDA.l StatusBarPAL,x
  130. STA !status_palette,x
  131. DEX : BPL -
  132. +
  133. SEP #$20 ;restore hijack
  134. PLB : RTL
  135.  
  136.  
  137. LagFix:
  138. ;JSR $A300 ;MarioGFXDMA
  139. JSR $8449 ;SpriteDMA
  140. JMP $8275 ;skip everything else
  141.  
  142. warnpc $008DF5
  143.  
  144.  
  145.  
  146. org $008CFF ;initialize !statusloc
  147. LDA $0D9B|!base
  148. BMI +
  149. LDX #$FE
  150. LDY #$7F
  151. -
  152. LDA.l StatusBarMAP,x
  153. STA !status_tile,y
  154. LDA.l StatusBarMAP+1,x
  155. STA !status_prop,y
  156. DEX #2
  157. DEY : BPL -
  158. LDX #$33
  159. -
  160. LDA.l OAMTABLE,x
  161. STA !status_OAM,x
  162. DEX : BPL -
  163. LDX.b #hdmatbl_end-hdmatbl-1
  164. -
  165. LDA.l hdmatbl,x
  166. STA !hdmatbl,x
  167. DEX : BPL -
  168. STZ !l3_line1
  169. STZ !l3_line1+1
  170. STZ !l3_line2
  171. STZ !l3_line2+1
  172. +
  173. LDA #$28
  174. STA $0F30|!base
  175. RTS
  176.  
  177.  
  178.  
  179. NoItemFix:
  180. LDA #$30 : XBA
  181. LDY $0DC2|!base
  182. BNE +
  183. LDA $0D9B|!base
  184. BMI ++
  185. LDA #$00 : XBA
  186. +
  187. JMP $9095
  188. ++
  189. JMP $90D0
  190.  
  191. ;item box item should go at the top of the screen in boss battles
  192.  
  193. ItemBossFix:
  194. LDA $0D9B|!base
  195. BPL +
  196. LDA #$78 ;item box X position (boss)
  197. STA $0200|!base,y
  198. LDA #$00 ;item box Y position (boss)
  199. STA $0201|!base,y
  200. JMP $90B7
  201. +
  202. XBA
  203. ORA $00
  204. STA !status_OAM+3
  205. LDX $0DC2|!base
  206. LDA $8DF9,x
  207. STA !status_OAM+2
  208. JMP $90D0
  209.  
  210. warnpc $008D8A
  211.  
  212. org $009090
  213. JMP NoItemFix
  214. NOP #2
  215.  
  216. org $0090AD
  217. JMP ItemBossFix
  218. NOP #7
  219.  
  220. org $028060
  221. db $00 ;Y pos of dropped item
  222.  
  223.  
  224.  
  225.  
  226. ;;;;;;;;;;;;;;;;;;;;;;
  227. org $00A4D1
  228. JSR $AE41
  229.  
  230. org $00AE41
  231. REP #$20
  232. LDA $0701|!base
  233. ASL #3
  234. SEP #$21
  235. ROR #3
  236. XBA
  237. ORA #$40
  238. STA $2132
  239. LDA $0702|!base
  240. LSR A
  241. SEC : ROR
  242. STA $2132
  243. XBA
  244. STA $2132
  245. RTS
  246. NOP #3
  247. ;;;;;;;;;;;;;;;;;;;;;;
  248.  
  249.  
  250.  
  251.  
  252. ;multiple status bar edits
  253.  
  254. org $008E6F ;Time hijack
  255. if !time
  256. LDA $0F31|!base
  257. STA !time
  258. LDA $0F32|!base
  259. STA !time+$1
  260. LDA $0F33|!base
  261. STA !time+$2
  262. if !ZERO_time
  263. BRA + ;[Time] dont convert leading zero to space (like SMB3)
  264. else
  265. BVS +
  266. endif
  267. LDY #$00
  268. -
  269. LDA $0F31|!base,y
  270. BNE +
  271. LDA #!NULL
  272. STA !time,y
  273. INY
  274. CPY #$02
  275. BNE -
  276. NOP
  277. +
  278. warnpc $008E95
  279. else
  280. BRA +
  281. org $008E95
  282. +
  283. endif
  284.  
  285. org $008F51 ;Lives hijack
  286. if !lives
  287. if !ZERO_lives
  288. BRA +
  289. else
  290. BNE +
  291. endif
  292. LDX #!NULL
  293. +
  294. STX !lives
  295. STA !lives+$1
  296. else
  297. BRA +
  298. org $008F5B
  299. +
  300. endif
  301.  
  302. org $008F7A ;Coins hijack
  303. if !coins
  304. if !ZERO_coins
  305. BRA +
  306. else
  307. BNE +
  308. endif
  309. LDX #!NULL
  310. +
  311. STA !coins+$1
  312. STX !coins
  313. else
  314. BRA +
  315. org $008F84
  316. +
  317. endif
  318.  
  319. org $008EE0 ;Score hijacks
  320. LDA !score,x
  321. org $008F0E
  322. LDA !score,x
  323. org $008EE7
  324. if !score
  325. STA !score,x
  326. else
  327. NOP #3
  328. endif
  329. org $008F15
  330. if !score
  331. STA !score,x
  332. else
  333. NOP #3
  334. endif
  335. org $008ED7
  336. LDX #$00
  337. org $008F05
  338. LDX #$00
  339. org $009014
  340. if !score
  341. STZ !score,x
  342. else
  343. NOP #3
  344. endif
  345. org $009034
  346. if !score
  347. INC !score,x
  348. else
  349. NOP #3
  350. endif
  351.  
  352. org $008EE5
  353. LDA #!NULL
  354.  
  355. org $008F13
  356. LDA #!NULL
  357.  
  358. org $008EDE
  359. if !ZERO_score
  360. BRA + ;[Mario score] dont convert leading zero to space (like SMB3)
  361. else
  362. LDX #$00
  363. endif
  364. org $008EEF
  365. +
  366.  
  367. org $008F0C
  368. if !ZERO_score
  369. BRA + ;[Luigi score] dont convert leading zero to space (like SMB3)
  370. else
  371. LDX #$00
  372. endif
  373. org $008F1D
  374. +
  375.  
  376.  
  377. org $008F86 ;near end of status bar routine, let's overwrite everything
  378.  
  379. if !player
  380. LDX $0DB3|!base
  381. LDA.w chartable,x
  382. STA !player
  383. INC : STA !player+1
  384. LDA.w chartable+2,x
  385. STA !player+$80
  386. STA !player+$80+1
  387. endif
  388.  
  389. if !bonus
  390. LDA $0F48|!base,x ;Rewritten Bonus Stars
  391. JSR $9045
  392. CLC : ADC #$20
  393. STA !bonus+1
  394. ADC #$0A : STA !bonus+1+$20
  395. TXA
  396. if !ZERO_bonus
  397. BRA +
  398. else
  399. BNE +
  400. endif
  401. LDA #!NULL
  402. STA !bonus
  403. STA !bonus+$20
  404. BRA ++
  405. +
  406. CLC : ADC #$20
  407. STA !bonus
  408. ADC #$0A : STA !bonus+$20
  409. ++
  410. endif
  411.  
  412. if !yicoins
  413. LDA $1422|!base
  414. STA !yicoins ;Rewritten Dragon Coins
  415. endif
  416.  
  417. if !world
  418. LDX $13BF|!base
  419. LDA.l Worlds,x ;new counter: current world number
  420. STA !world
  421. endif
  422.  
  423. JSR PMeter
  424.  
  425. autoclean JSL Counters
  426.  
  427. JMP $9079 ;handles item box item
  428.  
  429. chartable:
  430. db $19,$1B
  431. db $20,$24
  432.  
  433. warnpc $008FF5
  434.  
  435.  
  436.  
  437.  
  438. org $008C81 ;let's overwrite the original status bar tilemap
  439. PMeter: ;P-meter code below. heavily tweaked from Ersanio's version
  440.  
  441. if !pmeter
  442. REP #$20
  443. LDA.w #!EmptyTri<<8|!EmptyTri
  444. STA !pmeter
  445. STA !pmeter+2
  446. STA !pmeter+4
  447. LDA.w #!EmptyRP<<8|!EmptyLP
  448. STA !pmeter+6
  449. LDA.w #!EmptyPal<<8|!EmptyPal
  450. STA !pmeter+$80
  451. STA !pmeter+$80+2
  452. STA !pmeter+$80+4
  453. STA !pmeter+$80+6
  454. SEP #$20
  455.  
  456. LDA $13E4|!base
  457. AND #$F0
  458. LSR #4
  459. BEQ .skip
  460. TAY
  461. CMP #$07
  462. BCC .notfull
  463. DEY
  464.  
  465. LDA $14
  466. BIT #$07 : BNE +
  467. LDX #!Sound : STX !SoundBank
  468. +
  469.  
  470. ASL #4 : BCC +
  471. LDA #!FillLP : STA !pmeter+$6
  472. LDA #!FillRP : STA !pmeter+$7
  473. LDA #!FillPal : STA !pmeter+$80+$6 : STA !pmeter+$80+$7
  474. +
  475.  
  476. .notfull
  477. LDA #!FillPal
  478. XBA
  479. LDA #!FillTri
  480. -
  481. STA !pmeter-1,y
  482. XBA
  483. STA !pmeter+$80-1,y
  484. XBA
  485. DEY : BNE -
  486. endif
  487. .skip
  488. RTS
  489. warnpc $008CFF
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497. ;level end is broken. here we try to fix it (hint: try)
  498.  
  499. org $00C9A1 ;dont fade back colors after fade to black
  500. NOP #3 ;STZ $1495
  501.  
  502. org $00B046 ;disable sprites from fading during boss battles
  503. BRA $48 ;BNE $48
  504.  
  505. org $00C924 ;vertical level has proper fade
  506. BCS $08 ;BCS $1E
  507.  
  508. org $05CC16
  509. db $51,$0D,$00,$09 ;MARIO
  510. db $0C,$39
  511. db $00,$39
  512. db $11,$39
  513. db $08,$39
  514. db $0E,$39
  515. db $51,$49,$00,$19 ;COURSE_CLEAR!
  516. db $02,$39
  517. db $0E,$39
  518. db $14,$39
  519. db $11,$39
  520. db $12,$39
  521. db $04,$39
  522. db $1F,$39
  523. db $02,$39
  524. db $0B,$39
  525. db $04,$39
  526. db $00,$39
  527. db $11,$39
  528. db $1A,$39
  529. db $51,$A9,$00,$19 ;#___x50=_____
  530. db $76,$38
  531. db $FC,$38
  532. db $FC,$38
  533. db $FC,$38
  534. db $1D,$38
  535. db $05,$38
  536. db $00,$38
  537. db $77,$38
  538. db $FC,$38
  539. db $FC,$38
  540. db $FC,$38
  541. db $FC,$38
  542. db $FC,$38
  543. db $FF
  544. warnpc $05CC61
  545.  
  546. org $05CC61
  547. db $0B,$14,$08,$06,$08 ;LUIGI
  548.  
  549. org $05CD3F
  550. db $52,$0A,$00,$15 ;BONUS!_*x__--
  551. db $01,$39
  552. db $0E,$39
  553. db $0D,$39
  554. db $14,$39
  555. db $12,$39
  556. db $1A,$39
  557. db $FC,$38
  558. db $64,$28
  559. db $1D,$38
  560. db $FC,$38
  561. db $FC,$38
  562. db $51,$F3,$00,$03 ;--
  563. db $FC,$38
  564. db $FC,$38
  565. db $FF
  566. warnpc $05CD62
  567.  
  568.  
  569.  
  570. freecode
  571. incsrc counters.asm
  572.  
  573. -
  574. LDA #$53 : STA $2109
  575. STZ $2111
  576. STZ $2111
  577. STZ $2112
  578. STZ $2112
  579. JML $0082B0
  580.  
  581. ;below code is for the normal screen
  582.  
  583. PreStatusBar:
  584. LDA $0D9B|!base
  585. BNE -
  586. LDA #$53 : STA $2109
  587. LDA $22 : STA $2111 : STA !hdmatbl+1 : STA !hdmatbl+6
  588. LDA $23 : STA $2111 : STA !hdmatbl+2 : STA !hdmatbl+7
  589. LDA $24 : STA $2112 : STA !hdmatbl+3 : STA !hdmatbl+8
  590. LDA $25 : STA $2112 : STA !hdmatbl+4 : STA !hdmatbl+9
  591. LDA $3E : STA $2105
  592. LDA $40 : STA $2131 ;color math
  593. LDA #$53 : STA $2109 ;layer 3 tilemap location
  594. STZ $2121 : STZ $4314
  595. LDA $0703|!base : STA $2122
  596. LDA $0704|!base : STA $2122
  597. STZ $2115
  598. REP #$21
  599. JSR LayerUpdatePost
  600. LDA $0D9D|!base : STA $212C : STA $212E
  601. LDA #$0907|!base : STA $4312
  602. LDA #$003E : STA $4315
  603. LDA #$2202 : STA $4310
  604. TAX : STX $420B
  605. ;LDA $1426|!base ;fix message box
  606. ;AND #$0003 : BNE +
  607. LDA #$1800 : STA $4310
  608. LDA.w #!status_tile : STA $4312
  609. LDA !l3_line1 : BEQ + ;fix initial write
  610. STA $2116
  611. LDY #$20 : STY $4315
  612. STX $420B
  613. ORA #$0400 : STA $2116
  614. STY $4315
  615. STX $420B
  616. LDA !l3_line2 : STA $2116
  617. STY $4315
  618. STX $420B
  619. ORA #$0400 : STA $2116
  620. STY $4315
  621. STX $420B
  622. LDA #$0080 : STA $2115
  623. INC $4311
  624. LDA.w #!status_prop : STA $4312
  625. LDA !l3_line1 : STA $2116
  626. STY $4315
  627. STX $420B
  628. ORA #$0400 : STA $2116
  629. STY $4315
  630. STX $420B
  631. LDA !l3_line2 : STA $2116
  632. STY $4315
  633. STX $420B
  634. ORA #$0400 : STA $2116
  635. STY $4315
  636. STX $420B
  637. +
  638. LDA #$1103 : STA $4300 ;layer 3 X/Y HDMA
  639. LDA.w #!hdmatbl : STA $4302
  640. SEP #$20
  641. STZ $4304
  642. LDA $0D9F
  643. ORA #$01
  644. STA $0D9F
  645. JML $0082B0
  646.  
  647.  
  648.  
  649.  
  650. ;below code is for the status bar
  651.  
  652. -
  653. BIT $4212 : BVC $FB ;wait for h-blank
  654. JML $008394
  655.  
  656. PostStatusBar:
  657. BNE -
  658. PHD
  659. REP #$30
  660. LDA #$2100 : TCD ;set direct page to $2100
  661. LDA.w #!status_palette : STA $4312
  662. LDA #$4000 : STA $4314
  663. LDA #$2202 : STA $4310 ;set up first DMA (palette)
  664. SEP #$30
  665. TAY
  666. LDA #$01
  667. STA $420C
  668. LDA #$33
  669. LDX #$80
  670. BIT $4212 : BVC $FB ;wait for h-blank
  671.  
  672. STX $00 ;f-blank the scanline
  673. STZ $21 ;initialize color upload
  674. STZ $15
  675. STA $09 ;layer 3 tilemap location & size
  676. STY $420B
  677. LDA #$03 : STA $25 ;inverted clipping window for sprites
  678. LSR : STA $05 ;gfx mode 1 (layer 3 standard priority)
  679. LDA #$14 : STA $2C ;layer 3 & sprites on mainscreen
  680. AND #$10 : STA $2E ;no window for layer 3
  681. REP #$20
  682. STZ $30 ;disable subscreen & color math
  683. LDA #$FF08 : STA $26 ;window borders
  684. LDA #$00F6 : STA $02 ;FirstSprite = x7F
  685. LDX #$34 : STX $4315
  686. LDA #$0400 : STA $4310
  687. LDA.w #!status_OAM : STA $4312
  688. ;if !itembox
  689. STY $420B
  690. ;endif
  691.  
  692. SEP #$20
  693.  
  694. BIT $4212 : BVC $FB ;wait for h-blank again
  695. LDA $0DAE|!base : STA $00 ;restore brightness
  696. PLD
  697. JSR LayerUpdate
  698. JML $0083B2
  699.  
  700. hdmatbl:
  701. db $80 : dw $0000,$0000
  702. db $40 : dw $0000,$0000
  703. db $07 : dw $0000,$0000
  704. db $08 : dw $0100,$0000
  705. db $08 : dw $0000,$0000
  706. db $08 : dw $0100,$0000
  707. db $01 : dw $0000,$0000
  708. db $00
  709. .end
  710.  
  711. LayerUpdate:
  712. REP #$31
  713.  
  714. LDA $1C
  715. ADC #$00F0
  716. AND #$00F8
  717. ASL #2
  718. ORA #$3000
  719. STA !l3_line1
  720. LDA $1C
  721. AND #$00F8
  722. CMP #$0010
  723. BCS +
  724. ADC #$0100
  725. +
  726. CLC : ADC #$0130
  727. STA !l1y_mirror
  728. SEC : SBC #$0008
  729. STA !l1y_mirror_alt
  730. SBC #$0018
  731. STA !l1y_end
  732.  
  733. LDA $20
  734. CLC : ADC #$00F0
  735. AND #$00F8
  736. ASL #2
  737. ORA #$3800
  738. STA !l3_line2
  739. LDA $20
  740. AND #$00F8
  741. CMP #$0010
  742. BCS +
  743. ADC #$0100
  744. +
  745. CLC : ADC #$0020
  746. STA !l2y_mirror
  747. SEC : SBC #$0008
  748. STA !l2y_mirror_alt
  749. SEP #$30
  750. RTS
  751.  
  752. LayerUpdatePost:
  753. LDA !l1y_mirror : STA !hdmatbl+10+3
  754. LDA !l1y_mirror_alt : STA !hdmatbl+10+8
  755. LDA !l2y_mirror : STA !hdmatbl+10+13
  756. LDA !l2y_mirror_alt : STA !hdmatbl+10+18
  757. LDA !l1y_end : STA !hdmatbl+10+23
  758. RTS
  759.  
  760.  
  761. OAMTABLE: ;OAM table mirrored to RAM (and uploaded from there during IRQ)
  762. dw !itembox,$0000
  763. dw $F000,$0000 ;extra sprite 1
  764. dw $F000,$0000 ;extra sprite 2
  765. dw $F000,$0000 ;extra sprite 3
  766. dw $F000,$0000 ;extra sprite 4
  767. rep 30 : db $55
  768. db %10010101 ;item box @ high 2 bits
  769. db %10101010 ;extra sprites
  770.  
  771. Worlds:
  772. incsrc worlds.asm
  773.  
  774. StatusBarGFX:
  775. incbin smb3_status_gfx.bin:0-380
  776. StatusBarMAP:
  777. incbin smb3_status_map.bin:0-100
  778. StatusBarPAL:
  779. incbin smb3_status_pal.bin:0-40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement