Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added patches/ips/extra_setup.ips
Binary file not shown.
Binary file modified patches/ips/hazard_markers.ips
Binary file not shown.
45 changes: 45 additions & 0 deletions patches/src/extra_setup.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
lorom

incsrc "constants.asm"


!bank_b8_free_space_start = $B88000
!bank_b8_free_space_end = $B88100

!bank_8f_free_space_start = $8FFE80
!bank_8f_free_space_end = $8FFF00


; hook extra setup ASM to run right before normal setup ASM
; (careful: escape.asm hijacks the instruction after this)
org $8FE893
jsr run_extra_setup_asm_wrapper

org !bank_b8_free_space_start

run_extra_setup_asm:
; get extra setup ASM pointer to run in bank B5 (using pointer in room state almost completely unused by vanilla, only for X-ray override in BT Room in escape)
ldx $07bb ; x <- room state pointer
lda $8F0010,x
tax ; x <- extra room data pointer
lda $B80001,x ; a <- [extra room data pointer + 1]
beq .skip
sta $1F68 ; write setup ASM pointer temporarily to $1F68, so we can jump to it with JSR. (Is there a less awkward way to do this?)
ldx #$0000
jsr ($1F68, x)

.skip:
; run hi-jacked instructions
ldx $07BB
lda $0018,x
rtl

assert pc() <= !bank_b8_free_space_end

org !bank_8f_free_space_start

run_extra_setup_asm_wrapper:
jsl run_extra_setup_asm
rts

assert pc() <= !bank_8f_free_space_end
43 changes: 2 additions & 41 deletions patches/src/hazard_markers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,19 @@ incsrc "constants.asm"

!bank_84_free_space_start = $84F800 ; must match address in patch.rs
!bank_84_free_space_end = $84F900
!bank_8f_free_space_start = $8FFE80
!bank_8f_free_space_end = $8FFF00

!bank_b8_free_space_start = $B88000
!bank_b8_free_space_end = $B88100

!hazard_tilemap_size = #$0020

org $82E845
jsl load_hazard_tilemap_initial_hook
rep 3 : nop
nop #3

; hook door transition
org $82EB20
jsl reload_hazard_tiles
nop : nop

; hook extra setup ASM to run right before normal setup ASM
; (careful: escape.asm hijacks the instruction after this)
org $8FE893
jsr run_extra_setup_asm_wrapper

org !bank_b8_free_space_start

run_extra_setup_asm:
; get extra setup ASM pointer to run in bank B5 (using pointer in room state almost completely unused by vanilla, only for X-ray override in BT Room in escape)
ldx $07bb ; x <- room state pointer
lda $8F0010,x
tax ; x <- extra room data pointer
lda $B80001,x ; a <- [extra room data pointer + 1]
beq .skip
sta $1F68 ; write setup ASM pointer temporarily to $1F68, so we can jump to it with JSR. (Is there a less awkward way to do this?)
ldx #$0000
jsr ($1F68, x)

.skip:
; run hi-jacked instructions
ldx $07BB
lda $0018,x
rtl

warnpc !bank_b8_free_space_end

org !bank_8f_free_space_start

run_extra_setup_asm_wrapper:
jsl run_extra_setup_asm
rts

warnpc !bank_8f_free_space_end


org !bank_84_free_space_start

; These PLMs definitions must go here first, as they are referenced in patch.rs
Expand Down Expand Up @@ -158,4 +119,4 @@ elevator_hazard_with_scroll_draw:
dw $0002, $00E5, $34E5 ; use special air block type, to preserve scroll PLM
dw $0000

warnpc !bank_84_free_space_end
assert pc() <= !bank_84_free_space_end
1 change: 1 addition & 0 deletions rust/maprando/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ impl Patcher<'_> {
"fix_kraid_hud",
"fix_kraid_door",
"boss_exit",
"extra_setup",
"load_plms_early",
"spin_lock",
"fix_transition_bad_tiles",
Expand Down
Loading