mapbackup2

by soapagent

Game: SMW

Description: Automatic map backup. Press select on OW to load

; Chat Hacks Map Backup 2 ASM by SMWAgent09AF
; (uses FreeRAM addresses 7E:0F3A - F3E)

; Automatically stores map values.
; Press select on the map screen to reload
; previous backup.

!backup_mario_submap = $F3A
!backup_mario_overworld_x_lo = $F3B
!backup_mario_overworld_x_hi = $F3C
!backup_mario_overworld_y_lo = $F3D
!backup_mario_overworld_y_hi = $F3E

; checks if we're on the overworld
lda $100
cmp #$0e
bne done
; then checks if we've pressed select
lda $16
and #$20
bne load

; if not, checks if we're stopped on a tile 
lda $13d9
cmp #$03
bne done
; and just pressed a button
lda $16
beq done
lda $18
beq done
; if both those checks passed, backup the map
lda !mario_submap
sta !backup_mario_submap
lda !mario_overworld_x_lo
sta !backup_mario_overworld_x_lo
lda !mario_overworld_x_hi
sta !backup_mario_overworld_x_hi
lda !mario_overworld_y_lo
sta !backup_mario_overworld_y_lo
lda !mario_overworld_y_hi
sta !backup_mario_overworld_y_hi
rtl

load:
lda !backup_mario_submap
sta !mario_submap
lda !backup_mario_overworld_x_lo
sta !mario_overworld_x_lo
lda !backup_mario_overworld_x_hi
sta !mario_overworld_x_hi
lda !backup_mario_overworld_y_lo
sta !mario_overworld_y_lo
lda !backup_mario_overworld_y_hi
sta !mario_overworld_y_hi
lda #$0b
sta $100

done:
rtl
back to listings