Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;smb3 status bar
- ;by Ladida
- !base = $0000
- if read1($00FFD5) == $23
- sa1rom
- !base = $6000
- endif
- ;SMB3 and SMW differ in which counters keep leading zeros and which replace them
- ;with spaces. the below defines are defaulted to SMB3 behavior
- ;0 = false (no leading zeroes, replace with spaces)
- ;1 = true (keep the leading zeroes)
- !ZERO_coins = 0
- !ZERO_lives = 0
- !ZERO_score = 1
- !ZERO_time = 1
- !ZERO_bonus = 0
- !NULL = $FE ;fill tile in GFX28/29 (used for replacing leading zeroes)
- !Sound = $01 ;[P-Meter] Sound effect to play when you are at full speed
- !SoundBank = $1DFC|!base ;[P-Meter] Sound bank for above sound effect
- ;DONT edit these unless you know what you're doing
- !status_tile = $0BF6|!base
- !status_prop = $0C76|!base
- !statusloc = !status_tile+$22
- !status_palette = $0CF6|!base ;status bar palette is here (64 bytes max)
- !status_OAM = $0EFC|!base ;status bar OAM is here (5 tiles max + 32 byte high table)
- !altram = $0D36|!base
- !l3_line1 = !altram
- !l3_line2 = !altram+$2
- !l1y_mirror = !altram+$4
- !l1y_mirror_alt = !altram+$6
- !l2y_mirror = !altram+$8
- !l2y_mirror_alt = !altram+$A
- !l1y_end = !altram+$C
- !hdmatbl = !altram+$E
- ;location of counters in status bar. only change the added value. the bottom row is +$20
- ;if you want the counter disabled, set it equal to 0 instead of !statusloc+whatever
- ;note that disabling a counter only affects the display, not the functionality
- !world = !statusloc+$04 ;1 tile
- !pmeter = !statusloc+$06 ;8 tiles
- !coins = !statusloc+$10 ;2 tiles
- !bonus = !statusloc+$17 ;4 tiles, 2 at !bonus and 2 at !bonus+$20
- !player = !statusloc+$20+$00 ;2 tiles
- !lives = !statusloc+$20+$03 ;2 tiles
- !score = !statusloc+$20+$06 ;6 tiles (final zero is not included)
- !time = !statusloc+$20+$0F ;3 tiles
- !yicoins = !statusloc+$20+$15 ;1 tile
- !itembox = $C7E0 ;high = Y, low = X. $0000 = disable
- ;below defines are for the P-Meter
- !EmptyTri = $0F ;Empty tile of triangle
- !EmptyPal = $28
- !FillTri = $0E ;Filled tile of triangle
- !FillPal = $20
- !EmptyLP = $0A ;Empty tile of P, left side
- !EmptyRP = $0B ;Empty tile of P, right side
- !FillLP = $0C ;Filled tile of P, left side
- !FillRP = $0D ;Filled tile of P, right side
- org read3($0081E3)+7 ;LM hijack that skips position update during lag
- dl LagFix ;but we need to run the sprite DMA so we rewrite it
- org $05B129
- NOP #3 ;STZ $0D9F
- org $05B296
- db $0C ;$8D
- org $008292
- LDY #$C0 ;run IRQ on this scanline
- org $0082A4 ;NMI hijack
- autoclean JML PreStatusBar
- NOP #2
- org $00838F ;IRQ hijack
- autoclean JML PostStatusBar
- NOP
- org $05BEA2
- JML UploadStatusBar
- org $0082E8
- BRA $01 : NOP
- org $0081F4
- BRA $01 : NOP
- org $008DAC
- UploadStatusBar:
- LDX $0100|!base
- CPX #$12
- BNE +
- LDX #$80 : STX $2115
- LDA #$4000 : STA $2116
- LDA #$1801 : STA $4310
- LDA.w #StatusBarGFX : STA $4312
- LDX.b #StatusBarGFX>>16 : STX $4314
- LDA #$0380 : STA $4315
- LDX #$02 : STX $420B
- LDX #$3F
- -
- LDA.l StatusBarPAL,x
- STA !status_palette,x
- DEX : BPL -
- +
- SEP #$20 ;restore hijack
- PLB : RTL
- LagFix:
- ;JSR $A300 ;MarioGFXDMA
- JSR $8449 ;SpriteDMA
- JMP $8275 ;skip everything else
- warnpc $008DF5
- org $008CFF ;initialize !statusloc
- LDA $0D9B|!base
- BMI +
- LDX #$FE
- LDY #$7F
- -
- LDA.l StatusBarMAP,x
- STA !status_tile,y
- LDA.l StatusBarMAP+1,x
- STA !status_prop,y
- DEX #2
- DEY : BPL -
- LDX #$33
- -
- LDA.l OAMTABLE,x
- STA !status_OAM,x
- DEX : BPL -
- LDX.b #hdmatbl_end-hdmatbl-1
- -
- LDA.l hdmatbl,x
- STA !hdmatbl,x
- DEX : BPL -
- STZ !l3_line1
- STZ !l3_line1+1
- STZ !l3_line2
- STZ !l3_line2+1
- +
- LDA #$28
- STA $0F30|!base
- RTS
- NoItemFix:
- LDA #$30 : XBA
- LDY $0DC2|!base
- BNE +
- LDA $0D9B|!base
- BMI ++
- LDA #$00 : XBA
- +
- JMP $9095
- ++
- JMP $90D0
- ;item box item should go at the top of the screen in boss battles
- ItemBossFix:
- LDA $0D9B|!base
- BPL +
- LDA #$78 ;item box X position (boss)
- STA $0200|!base,y
- LDA #$00 ;item box Y position (boss)
- STA $0201|!base,y
- JMP $90B7
- +
- XBA
- ORA $00
- STA !status_OAM+3
- LDX $0DC2|!base
- LDA $8DF9,x
- STA !status_OAM+2
- JMP $90D0
- warnpc $008D8A
- org $009090
- JMP NoItemFix
- NOP #2
- org $0090AD
- JMP ItemBossFix
- NOP #7
- org $028060
- db $00 ;Y pos of dropped item
- ;;;;;;;;;;;;;;;;;;;;;;
- org $00A4D1
- JSR $AE41
- org $00AE41
- REP #$20
- LDA $0701|!base
- ASL #3
- SEP #$21
- ROR #3
- XBA
- ORA #$40
- STA $2132
- LDA $0702|!base
- LSR A
- SEC : ROR
- STA $2132
- XBA
- STA $2132
- RTS
- NOP #3
- ;;;;;;;;;;;;;;;;;;;;;;
- ;multiple status bar edits
- org $008E6F ;Time hijack
- if !time
- LDA $0F31|!base
- STA !time
- LDA $0F32|!base
- STA !time+$1
- LDA $0F33|!base
- STA !time+$2
- if !ZERO_time
- BRA + ;[Time] dont convert leading zero to space (like SMB3)
- else
- BVS +
- endif
- LDY #$00
- -
- LDA $0F31|!base,y
- BNE +
- LDA #!NULL
- STA !time,y
- INY
- CPY #$02
- BNE -
- NOP
- +
- warnpc $008E95
- else
- BRA +
- org $008E95
- +
- endif
- org $008F51 ;Lives hijack
- if !lives
- if !ZERO_lives
- BRA +
- else
- BNE +
- endif
- LDX #!NULL
- +
- STX !lives
- STA !lives+$1
- else
- BRA +
- org $008F5B
- +
- endif
- org $008F7A ;Coins hijack
- if !coins
- if !ZERO_coins
- BRA +
- else
- BNE +
- endif
- LDX #!NULL
- +
- STA !coins+$1
- STX !coins
- else
- BRA +
- org $008F84
- +
- endif
- org $008EE0 ;Score hijacks
- LDA !score,x
- org $008F0E
- LDA !score,x
- org $008EE7
- if !score
- STA !score,x
- else
- NOP #3
- endif
- org $008F15
- if !score
- STA !score,x
- else
- NOP #3
- endif
- org $008ED7
- LDX #$00
- org $008F05
- LDX #$00
- org $009014
- if !score
- STZ !score,x
- else
- NOP #3
- endif
- org $009034
- if !score
- INC !score,x
- else
- NOP #3
- endif
- org $008EE5
- LDA #!NULL
- org $008F13
- LDA #!NULL
- org $008EDE
- if !ZERO_score
- BRA + ;[Mario score] dont convert leading zero to space (like SMB3)
- else
- LDX #$00
- endif
- org $008EEF
- +
- org $008F0C
- if !ZERO_score
- BRA + ;[Luigi score] dont convert leading zero to space (like SMB3)
- else
- LDX #$00
- endif
- org $008F1D
- +
- org $008F86 ;near end of status bar routine, let's overwrite everything
- if !player
- LDX $0DB3|!base
- LDA.w chartable,x
- STA !player
- INC : STA !player+1
- LDA.w chartable+2,x
- STA !player+$80
- STA !player+$80+1
- endif
- if !bonus
- LDA $0F48|!base,x ;Rewritten Bonus Stars
- JSR $9045
- CLC : ADC #$20
- STA !bonus+1
- ADC #$0A : STA !bonus+1+$20
- TXA
- if !ZERO_bonus
- BRA +
- else
- BNE +
- endif
- LDA #!NULL
- STA !bonus
- STA !bonus+$20
- BRA ++
- +
- CLC : ADC #$20
- STA !bonus
- ADC #$0A : STA !bonus+$20
- ++
- endif
- if !yicoins
- LDA $1422|!base
- STA !yicoins ;Rewritten Dragon Coins
- endif
- if !world
- LDX $13BF|!base
- LDA.l Worlds,x ;new counter: current world number
- STA !world
- endif
- JSR PMeter
- autoclean JSL Counters
- JMP $9079 ;handles item box item
- chartable:
- db $19,$1B
- db $20,$24
- warnpc $008FF5
- org $008C81 ;let's overwrite the original status bar tilemap
- PMeter: ;P-meter code below. heavily tweaked from Ersanio's version
- if !pmeter
- REP #$20
- LDA.w #!EmptyTri<<8|!EmptyTri
- STA !pmeter
- STA !pmeter+2
- STA !pmeter+4
- LDA.w #!EmptyRP<<8|!EmptyLP
- STA !pmeter+6
- LDA.w #!EmptyPal<<8|!EmptyPal
- STA !pmeter+$80
- STA !pmeter+$80+2
- STA !pmeter+$80+4
- STA !pmeter+$80+6
- SEP #$20
- LDA $13E4|!base
- AND #$F0
- LSR #4
- BEQ .skip
- TAY
- CMP #$07
- BCC .notfull
- DEY
- LDA $14
- BIT #$07 : BNE +
- LDX #!Sound : STX !SoundBank
- +
- ASL #4 : BCC +
- LDA #!FillLP : STA !pmeter+$6
- LDA #!FillRP : STA !pmeter+$7
- LDA #!FillPal : STA !pmeter+$80+$6 : STA !pmeter+$80+$7
- +
- .notfull
- LDA #!FillPal
- XBA
- LDA #!FillTri
- -
- STA !pmeter-1,y
- XBA
- STA !pmeter+$80-1,y
- XBA
- DEY : BNE -
- endif
- .skip
- RTS
- warnpc $008CFF
- ;level end is broken. here we try to fix it (hint: try)
- org $00C9A1 ;dont fade back colors after fade to black
- NOP #3 ;STZ $1495
- org $00B046 ;disable sprites from fading during boss battles
- BRA $48 ;BNE $48
- org $00C924 ;vertical level has proper fade
- BCS $08 ;BCS $1E
- org $05CC16
- db $51,$0D,$00,$09 ;MARIO
- db $0C,$39
- db $00,$39
- db $11,$39
- db $08,$39
- db $0E,$39
- db $51,$49,$00,$19 ;COURSE_CLEAR!
- db $02,$39
- db $0E,$39
- db $14,$39
- db $11,$39
- db $12,$39
- db $04,$39
- db $1F,$39
- db $02,$39
- db $0B,$39
- db $04,$39
- db $00,$39
- db $11,$39
- db $1A,$39
- db $51,$A9,$00,$19 ;#___x50=_____
- db $76,$38
- db $FC,$38
- db $FC,$38
- db $FC,$38
- db $1D,$38
- db $05,$38
- db $00,$38
- db $77,$38
- db $FC,$38
- db $FC,$38
- db $FC,$38
- db $FC,$38
- db $FC,$38
- db $FF
- warnpc $05CC61
- org $05CC61
- db $0B,$14,$08,$06,$08 ;LUIGI
- org $05CD3F
- db $52,$0A,$00,$15 ;BONUS!_*x__--
- db $01,$39
- db $0E,$39
- db $0D,$39
- db $14,$39
- db $12,$39
- db $1A,$39
- db $FC,$38
- db $64,$28
- db $1D,$38
- db $FC,$38
- db $FC,$38
- db $51,$F3,$00,$03 ;--
- db $FC,$38
- db $FC,$38
- db $FF
- warnpc $05CD62
- freecode
- incsrc counters.asm
- -
- LDA #$53 : STA $2109
- STZ $2111
- STZ $2111
- STZ $2112
- STZ $2112
- JML $0082B0
- ;below code is for the normal screen
- PreStatusBar:
- LDA $0D9B|!base
- BNE -
- LDA #$53 : STA $2109
- LDA $22 : STA $2111 : STA !hdmatbl+1 : STA !hdmatbl+6
- LDA $23 : STA $2111 : STA !hdmatbl+2 : STA !hdmatbl+7
- LDA $24 : STA $2112 : STA !hdmatbl+3 : STA !hdmatbl+8
- LDA $25 : STA $2112 : STA !hdmatbl+4 : STA !hdmatbl+9
- LDA $3E : STA $2105
- LDA $40 : STA $2131 ;color math
- LDA #$53 : STA $2109 ;layer 3 tilemap location
- STZ $2121 : STZ $4314
- LDA $0703|!base : STA $2122
- LDA $0704|!base : STA $2122
- STZ $2115
- REP #$21
- JSR LayerUpdatePost
- LDA $0D9D|!base : STA $212C : STA $212E
- LDA #$0907|!base : STA $4312
- LDA #$003E : STA $4315
- LDA #$2202 : STA $4310
- TAX : STX $420B
- ;LDA $1426|!base ;fix message box
- ;AND #$0003 : BNE +
- LDA #$1800 : STA $4310
- LDA.w #!status_tile : STA $4312
- LDA !l3_line1 : BEQ + ;fix initial write
- STA $2116
- LDY #$20 : STY $4315
- STX $420B
- ORA #$0400 : STA $2116
- STY $4315
- STX $420B
- LDA !l3_line2 : STA $2116
- STY $4315
- STX $420B
- ORA #$0400 : STA $2116
- STY $4315
- STX $420B
- LDA #$0080 : STA $2115
- INC $4311
- LDA.w #!status_prop : STA $4312
- LDA !l3_line1 : STA $2116
- STY $4315
- STX $420B
- ORA #$0400 : STA $2116
- STY $4315
- STX $420B
- LDA !l3_line2 : STA $2116
- STY $4315
- STX $420B
- ORA #$0400 : STA $2116
- STY $4315
- STX $420B
- +
- LDA #$1103 : STA $4300 ;layer 3 X/Y HDMA
- LDA.w #!hdmatbl : STA $4302
- SEP #$20
- STZ $4304
- LDA $0D9F
- ORA #$01
- STA $0D9F
- JML $0082B0
- ;below code is for the status bar
- -
- BIT $4212 : BVC $FB ;wait for h-blank
- JML $008394
- PostStatusBar:
- BNE -
- PHD
- REP #$30
- LDA #$2100 : TCD ;set direct page to $2100
- LDA.w #!status_palette : STA $4312
- LDA #$4000 : STA $4314
- LDA #$2202 : STA $4310 ;set up first DMA (palette)
- SEP #$30
- TAY
- LDA #$01
- STA $420C
- LDA #$33
- LDX #$80
- BIT $4212 : BVC $FB ;wait for h-blank
- STX $00 ;f-blank the scanline
- STZ $21 ;initialize color upload
- STZ $15
- STA $09 ;layer 3 tilemap location & size
- STY $420B
- LDA #$03 : STA $25 ;inverted clipping window for sprites
- LSR : STA $05 ;gfx mode 1 (layer 3 standard priority)
- LDA #$14 : STA $2C ;layer 3 & sprites on mainscreen
- AND #$10 : STA $2E ;no window for layer 3
- REP #$20
- STZ $30 ;disable subscreen & color math
- LDA #$FF08 : STA $26 ;window borders
- LDA #$00F6 : STA $02 ;FirstSprite = x7F
- LDX #$34 : STX $4315
- LDA #$0400 : STA $4310
- LDA.w #!status_OAM : STA $4312
- ;if !itembox
- STY $420B
- ;endif
- SEP #$20
- BIT $4212 : BVC $FB ;wait for h-blank again
- LDA $0DAE|!base : STA $00 ;restore brightness
- PLD
- JSR LayerUpdate
- JML $0083B2
- hdmatbl:
- db $80 : dw $0000,$0000
- db $40 : dw $0000,$0000
- db $07 : dw $0000,$0000
- db $08 : dw $0100,$0000
- db $08 : dw $0000,$0000
- db $08 : dw $0100,$0000
- db $01 : dw $0000,$0000
- db $00
- .end
- LayerUpdate:
- REP #$31
- LDA $1C
- ADC #$00F0
- AND #$00F8
- ASL #2
- ORA #$3000
- STA !l3_line1
- LDA $1C
- AND #$00F8
- CMP #$0010
- BCS +
- ADC #$0100
- +
- CLC : ADC #$0130
- STA !l1y_mirror
- SEC : SBC #$0008
- STA !l1y_mirror_alt
- SBC #$0018
- STA !l1y_end
- LDA $20
- CLC : ADC #$00F0
- AND #$00F8
- ASL #2
- ORA #$3800
- STA !l3_line2
- LDA $20
- AND #$00F8
- CMP #$0010
- BCS +
- ADC #$0100
- +
- CLC : ADC #$0020
- STA !l2y_mirror
- SEC : SBC #$0008
- STA !l2y_mirror_alt
- SEP #$30
- RTS
- LayerUpdatePost:
- LDA !l1y_mirror : STA !hdmatbl+10+3
- LDA !l1y_mirror_alt : STA !hdmatbl+10+8
- LDA !l2y_mirror : STA !hdmatbl+10+13
- LDA !l2y_mirror_alt : STA !hdmatbl+10+18
- LDA !l1y_end : STA !hdmatbl+10+23
- RTS
- OAMTABLE: ;OAM table mirrored to RAM (and uploaded from there during IRQ)
- dw !itembox,$0000
- dw $F000,$0000 ;extra sprite 1
- dw $F000,$0000 ;extra sprite 2
- dw $F000,$0000 ;extra sprite 3
- dw $F000,$0000 ;extra sprite 4
- rep 30 : db $55
- db %10010101 ;item box @ high 2 bits
- db %10101010 ;extra sprites
- Worlds:
- incsrc worlds.asm
- StatusBarGFX:
- incbin smb3_status_gfx.bin:0-380
- StatusBarMAP:
- incbin smb3_status_map.bin:0-100
- StatusBarPAL:
- incbin smb3_status_pal.bin:0-40
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement