Codeheader
lorom
;################################################
; DEFINITIONS
;################################################
; \ Point to some free ROM space!!!!!
; | (Note: If our ROM is at least 1MB
!FreeSpace = $1C8000 ; | and you haven't applied any other
; | patches before, you don't need to
; / change this.)
!LevelNum = $010B ; Where the current level number is stored at
; \ Change this to $01
!AlwaysShwPwrup = $00 ; | to always show your current powerup
; / in the status bar
;################################################
; LEVELNUM.IPS DISASSEMBLY
;################################################
org $05D8B9 ; \
JSR Levelnummain ; |
; | Store current level number
org $05DC46 ; | to $010B and $010C
Levelnummain: ; |
LDA $0E ; | (Code by BMF54123,
STA !LevelNum ; | disassembled by Ersanio)
ASL A ; |
RTS ; /
;################################################
; STATUS BAR HIJACKS
;################################################
org $008CC9
db $FC,$2C,$FC,$3C ; \ Change the palettes of some empty tiles
db $FC,$28,$FC,$28 ; | and move bonus star counter
db $64,$28,$26,$38 ; / to the right
org $008CAB
db $FC,$3C,$76,$38 ; \ Use the clock tile instead of the "TIME" text
db $FC,$3C ; / so we can use that for custom GFX
;################################################
; ROUTINE HIJACKS
;################################################
org $008F49
JSL CustomCode ; Custom code that makes you invisible, stay on Yoshi etc.
org $01F71D
JML RunAway ; handles sprite contact
NOP ; ("hurt Yoshi or make him run away?")
org $02A481
JML RunAwayExt ; handles extended sprite contact
NOP
org !FreeSpace
db "STAR" ; \
dw End-Start-$01 ; | Write RAT / RATS Tag / whatever
dw End-Start-$01^$FFFF ; /
Start:
RunAway:
PHB ; \
PHK ; |
PLB ; |
PHY ; |
PHX ; |
REP #$30 ; |
LDA !LevelNum ; |
PHA ; |
LSR #3 ; | Code by Roy:
TAY ; | Load the bit that corresponds
PLA ; | to the current level
AND #$0007 ; |
TAX ; |
SEP #$20 ; |
LDA.w LevelTable,y ; |
AND.w ANDTable,x ; |
SEP #$10 ; |
PLX ; |
PLY ; /
CMP #$00 ; \ If zero,
BEQ .UseOldRoutine ; / use the old routine
JSL $00F5B7 ; \ If not zero, hurt Mario/Yoshi
PLB : JML $01F74B ; / and return from the routine
.UseOldRoutine ; \
LDA #$13 ; | If zero, restore some hijacked code
STA $1DFC ; | and continue the routine normally
PLB : JML $01F722 ; /
RunAwayExt:
PHB ; \
PHK ; |
PLB ; |
PHY ; |
PHX ; |
REP #$30 ; |
LDA !LevelNum ; |
PHA ; |
LSR #3 ; | Code by Roy:
TAY ; | Load the bit that corresponds
PLA ; | to the current level
AND #$0007 ; |
TAX ; |
SEP #$20 ; |
LDA.w LevelTable,y ; |
AND.w ANDTable,x ; |
SEP #$10 ; |
PLX ; |
PLY ; /
CMP #$00 ; \ If zero,
BEQ .UseOldRoutine ; / use the old routine
JSL $00F5B7 ; \ If not zero, hurt Mario/Yoshi
PLB : JML $02A4AC ; / and return from the routine
.UseOldRoutine ; \
LDA #$13 ; | If zero, restore some hijacked code
STA $1DFC ; | and continue the routine normally
PLB : JML $02A486 ; /
CustomCode:
LDA #!AlwaysShwPwrup ; \
BEQ + ; | Always display powerup
JSR DispPowerup ; | in the status bar
+ ; /
PHB ; \
PHK ; |
PLB ; |
PHY ; |
PHX ; |
REP #$30 ; |
LDA !LevelNum ; |
PHA ; |
LSR #3 ; | Code by Roy:
TAY ; | Load the bit that corresponds
PLA ; | to the current level
AND #$0007 ; |
TAX ; |
SEP #$20 ; |
LDA.w LevelTable,y ; |
AND.w ANDTable,x ; |
SEP #$10 ; |
PLX ; |
PLY ; /
CMP #$00 ; \ If zero,
BEQ Return ; / do nothing
LDA #!AlwaysShwPwrup ; \
BNE + ; | Display powerup
JSR DispPowerup ; | in the status bar
+ ; /
LDA #$40 ; \
STA $13E0 ; | Make Mario
LDA #$9D ; | invisible
STA $13DF ; /
REP #$20 ; \
LDA $17 ; |
AND #$7F7F ; | Disable A button (spin jump)
STA $17 ; |
SEP #$20 ; /
LDA #$22 ; \
STA $0EF9 ; |
LDA #$18 ; |
STA $0EFA ; |
LDA #$1C ; | Display "YOSHI" as the player name
STA $0EFB ; | in the status bar
LDA #$11 ; |
STA $0EFC ; |
LDA #$12 ; |
STA $0EFD ; /
Return:
LDA $0DBE ; \ Hijacked code
INC A ; / (don't touch this)
PLB : RTL ; Return
DispPowerup:
LDA #$FC ; \
STA $0F19 ; | Clear all tiles in the powerup section
STA $0F1A ; | before drawing new ones so that no two
STA $0F1B ; | powerups are shown at the same time
STA $0F1C ; /
PHX ; \
LDX $19 ; |
CPX #$00 ; | Display current powerup in the
BEQ DontDisp ; | status bar (so that you know what
DEX ; | powerup you are - Mario is invisible,
LDA.l PowerupTiles,x ; | after all - and if you're going to
STA $0F19,x ; | die on the next hit or not)
DontDisp: ; |
PLX ; /
RTS ; Return from subroutine
PowerupTiles: db $3D,$3F,$3E ; Tiles used as powerup symbols
ANDTable:
db $80,$40,$20,$10,$08,$04,$02,$01 ; Don't change.
;################################################
; LEVEL TABLE (Change this)
;################################################
LevelTable:
db %00000000,%00000000 ; Levels 0-F
db %00000000,%00000000 ; Levels 10-1F
db %00000000,%00000000 ; Levels 20-2F
db %00000000,%00000000 ; Levels 30-3F
db %00000000,%00000000 ; Levels 40-4F
db %00000000,%00000000 ; Levels 50-5F
db %00000000,%00000000 ; Levels 60-6F
db %00000000,%00000000 ; Levels 70-7F
db %00000000,%00000000 ; Levels 80-8F
db %00000000,%00000000 ; Levels 90-9F
db %00000000,%00000000 ; Levels A0-AF
db %00000000,%00000000 ; Levels B0-BF
db %00000000,%00000000 ; Levels C0-CF
db %00000000,%00000000 ; Levels D0-DF
db %00000000,%00000000 ; Levels E0-EF
db %00000000,%00000000 ; Levels F0-FF
db %00000100,%00000000 ; Levels 100-10F
db %00000000,%00000000 ; Levels 110-11F
db %00000000,%00000000 ; Levels 120-12F
db %00000000,%00000000 ; Levels 130-13F
db %00000000,%00000000 ; Levels 140-14F
db %00000000,%00000000 ; Levels 150-15F
db %00000000,%00000000 ; Levels 160-16F
db %00000000,%00000000 ; Levels 170-17F
db %00000000,%00000000 ; Levels 180-18F
db %00000000,%00000000 ; Levels 190-19F
db %00000000,%00000000 ; Levels 1A0-1AF
db %00000000,%00000000 ; Levels 1B0-1BF
db %00000000,%00000000 ; Levels 1C0-1CF
db %00000000,%00000000 ; Levels 1D0-1DF
db %00000000,%00000000 ; Levels 1E0-1EF
db %00000000,%00000000 ; Levels 1F0-1FF
End: ; This is the end. Don't remove this.