;======================== ;This patch is designed to make further use of Mario's orignal powerup ;address, by hijacking the routines that use $19 as an index. As the ;patch is, it will allow you to set $19 to #$0F or under. To change ;certain effects, such as the number of running frames your powerup uses ;(Small Mario has 2, while the rest have 3), edit the tables under ;"Custom Routine (new)". To change the palette, edit the tables ;under "Custom Routine (old)" and read Roy's readme that came with the ;patch. ;======================== ;This patch was built from Roy's Custom Mario Palette patch, ;and still contains most of its original code (marked by 'old' in the ;section titles) with very minor tweaks. The rest is mostly ripped ;straight from all.log with more tweaking. I don't need any credit for ;the use of this patch, but Frould you decide to, it'd be nFre to credit ;Roy too. ;======================== HEADER LOROM ;======================== ; DEFINES ;======================== !CodeFreeSpace = $188000 ; Change as needed !FreeRAM = $010B !AnotherRAM = $58 !ThirdRam = $5C ; You may want to change this. !DefaultMarSm = $00B2C8 ; \ You may not want to change these. !DefaultLuiSm = $00B2DC ; | !DefaultMarBg = $00B2C8 ; | !DefaultLuiBg = $00B2DC ; | !DefaultMarCp = $00B2C8 ; | !DefaultLuFrp = $00B2DC ; | !DefaultMarFr = $00B2F0 ; | !DefaultLuiFr = $00B304 ; / ;---------------- ; Hijacks. (new) ;---------------- ORG $00CFEE NOP JSL WalkFrames ORG $00E3AB NOP JSL IndexSet ORG $00FB00 JML LvlEndPow ORG $01C53B JML PowerupItemRoutines ORG $00EB79 JML Interact1 ORG $01B4C0 JML Interact2 ORG $03B67C JML Interact3 ORG $00D081 JML PowerRoutines ORG $00D640 JML SpinJumpHijack NOP ;---------------- ; Hijacks. (old) ;---------------- org $00A328 JSL Palette1 NOP ORG $00A31A JML NotQuiteMain ORG $00B048 JSL LessMainThanThat ORG $00E31B JML Main org $00A309 JML PalSkip ;========================== ; FROM LEVELASM, NOT BY ME ;========================== ORG $05D8B9 JSR Levelnummain ORG $05DC46 Levelnummain: LDA $0E ;Load level number STA !FreeRAM ;Store it in free stack RAM ASL A ;Multiply A by 2, probably to recover old code? STZ !AnotherRAM RTS ;Return from subroutine ORG !CodeFreeSpace !CodeSize = End-Main db "STAR" dw !CodeSize-$01 dw !CodeSize-$01^$FFFF PalSkip: LDY #$86 STY $2121 SEP #$20 LDA $0100 CMP #$2B BCC + REP #$20 JML $00A328 + REP #$20 JML $00A30E ;----------------------- ; Custom Routine (new) ;----------------------- LvlEndPow: LDA $19 AND #$03 TAX LDA $1490 JML $00FB5 WalkFrames: PHX LDX $19 LDA NumWalkingFrames,X PLX RTL IndexSet: BCS CODE_00E3B0 PHX TYX ADC TilesetIndex,X PLX CODE_00E3B0: RTL ;;;Below values are the number of frames used for walking (minus 1) indexed by Mario's form NumWalkingFrames: db $01,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 ; $19 = #$00 to #$0F ;;;;Below are Mario's tileset index, indexed by Mario's form ; 00 - Small Mario tiles ; 46 - Big Mario tiles (used by Fire Mario too) ; 83 - Cape Mario tiles (used to access unique Cape poses) TilesetIndex: db $00,$46,$83,$46,$46,$46,$46,$46,$46,$46,$46,$46,$46,$46,$46,$46 ; $19 = #$00 to #$0F ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PowerupItemRoutines: ASL ASL ASL ASL ORA $19 PHX TAX LDA ItemBoxSprite,X ; \ Put appropriate item in item box BEQ NoItem ; | STA $0DC2 ; / LDA #$0B ; \ STA $1DFC ; / Play sound effect NoItem: LDA GivePowerPtrIndex,X ; Call routine to change Mario's status PLX JML $01C550 ;;;Below values are the itembox item numbers ItemBoxSprite: ; Item to put into item box, indexed by Mario's form and touched powerup db $00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F Item = Mushroom db $00,$01,$04,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 ; $19 = #$00 to #$0F Item = Flower db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; $19 = #$00 to #$0F Item = Star db $00,$01,$04,$02,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04,$04 ; $19 = #$00 to #$0F Item = Feather db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; $19 = #$00 to #$0F Item = 1-UP ;;;Below values are: ; 00 - Big (uses INC instead of loading #$01, so don't use with your powerups) ; 01 - No change ; 02 - Star ; 03 - Cape ; 04 - Fire ; 05 - 1Up GivePowerPtrIndex: ; Routine to run, indexed by Mario's form and touched powerup db $00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F Item = Mushroom db $04,$04,$04,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F Item = Flower db $02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02,$02 ; $19 = #$00 to #$0F Item = Star db $03,$03,$01,$03,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F Item = Feather db $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05 ; $19 = #$00 to #$0F Item = 1-UP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SpinJumpHijack: PHX ;\ LDX $19 ; | LDA SpinJumpTable,X ; | Load the new spin jump flag based on the current power... PLX ; | CMP #$00 ; | BEQ CODE_00D65E ;/ and disable spin jumping if it's #$00 LDA $148F ;\ Also disable it if holding something BNE CODE_00D65E ;/ JML $00D645 ; Otherwise, jump to spin jump routine CODE_00D65E: JML $00D65E ;;;Below values are: ; 00 - Spin jump off ; 01 - Spin jump on SpinJumpTable: db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interact1: PHX LDX $19 LDA InteractTable,X PLX CMP #$00 BEQ CODE_00EB83 JML $00EB7D CODE_00EB83: JML $00EB83 Interact2: PHA PHX LDX $19 LDA InteractTable,X TAY PLX PLA CPY #$00 BNE CODE_01B4C6 JML $01B4C4 CODE_01B4C6: JML $01B4C6 Interact3: PHX LDX $19 LDA InteractTable,X PLX CMP #$00 BNE CODE_03B681 ; | JML $03B680 CODE_03B681: JML $03B681 ;;;Below values are: ; 00 - 16x16 hitbox ; 01 - 16x32 hitbox InteractTable: db $00,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01 ; $19 = #$00 to #$0F ;----------------------- ; The actual routines for the powerups ; ;----------------------- PowerRoutines: CMP #$03 ; A is $19 BNE NewPowerups JML $00D085 ; If Fire Mario, run it's original routine NewPowerups: REP #$30 ; AND #$00FF STA $00 ASL A CLC ADC $00 TAX LDA PowTable,X STA $00 SEP #$20 LDA PowTable+2,X STA $02 SEP #$10 JML [$0000] PowTable: dl NormalMario,NormalMario,NormalMario,NormalMario dl NewPowerups04,NewPowerups05,NewPowerups06,NewPowerups07,NewPowerups08,NewPowerups09 dl NewPowerups0A,NewPowerups0B,NewPowerups0C,NewPowerups0D,NewPowerups0E,NewPowerups0F NewPowerupsEnd: JML $00D0AD ; Jump back to original bank for RTS ;;;Put your routines for your powerup below. These run every frame. NormalMario: NewPowerups04: NewPowerups05: NewPowerups06: NewPowerups07: NewPowerups08: NewPowerups09: NewPowerups0A: NewPowerups0B: NewPowerups0C: NewPowerups0D: NewPowerups0E: NewPowerups0F: JMP NewPowerupsEnd ;----------------------- ; Custom Routine (old) ;----------------------- Main: LDA $19 ASL CLC ADC $19 TAX ; / Result of that into X. REP #$20 LDA PalPtr,X ; \ Get low and middle byte into $0D82. STA $0D82 ; / SEP #$20 LDA PalPtr+2,X ; Get bank byte into !ThirdRam. STA !ThirdRam SEP #$10 JumpBack: JML $00E326 NotQuiteMain: LDY !ThirdRam STY $4324 STY $60 JML $00A31F LessMainThanThat: LDA !ThirdRam STA $02 RTL Palette1: ;SEP #$20 ;LDA $0100 ;CMP #$14 ;BNE + ;+ ;REP #$20 LDY #$80 STY $2115 RTL ;;;Below are the new palette tables, indexed by powerup number and level number ;Create a labeled palette below these tables, and then replace !Default-whatever with that label ;for the appropriate powerup number and level number PalPtr: dl !DefaultMarSm,!DefaultMarBg,!DefaultMarCp,!DefaultMarFr,pal4,pal5,pal6,pal7,pal8,pal9,palA,!palB dl palC,palD,palE,palF ;----------------------------------------------------------------------------------------- ; Custom Palettes ; Format: SNES RGB values. ; You can get these with the LM palette viewer. ; If you want, you can insert more palettes underneath this. ; Give them a label (such as Pal10: and on), then make colours for them. ; Amount of colours Frould be 10 per custom palette (replace colours 6-F from palette 8) ;----------------------------------------------------------------------------------------- Pal4: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF Pal5: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF Pal6: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF Pal7: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF Pal8: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF Pal9: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalA: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalB: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalC: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalD: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalE: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF PalF: dw $635F,$581D,$000A,$391F,$44C4,$4E08,$6770,$30B6,$35DF,$03FF End: