mapbackup

by smwagent09af

Game: SMW

Description: allows a write to 0x7E0F3F to save/load map position

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

; Write 0xFF to $F3F to save the current
;   map position to FreeRAM. Write any
;   other non-zero value to load this data.

!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
!mapbackup_dispatch = $F3F

; writes to status bar
lda #$0f
sta $f1a
lda #$03
sta $f1b
lda #$0f
sta $f1c
; checks if there is a value at $7E:0F3F
lda !mapbackup_dispatch
bne dispatch
; if not, we're done here
rtl

dispatch:
lda !mapbackup_dispatch
cmp #$FF
bne load
; if it is 0xFF, then do a backup routine
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
lda #$00
sta !mapbackup_dispatch
rtl

load:
; if it is non-zero and not 0xFF, load backup
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 #$00
sta !mapbackup_dispatch
rtl
back to listings