Skip to content

Commit

Permalink
unified jp/us hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
nstbayless committed Jul 26, 2024
1 parent 9d38b0f commit 53a1080
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 210 deletions.
109 changes: 109 additions & 0 deletions _improved_controls.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
; --------------------------------------------------------------------
BANK $E
BASE $8000

include "_hooks.asm"

; custom code
FROM empty_bank_e

stair_jumping:
; pressed jump button?
LDA joypad_pressed
AND #$80 ; (pressed jump)
BEQ __recover_step
; perform jump
LDA #$06 ; begin jump
STA simon_state
; double-return
; (quit out of stair logic as well)
PLA
PLA
RTS
__recover_step:
; here we perform the detour logic to resume a standard tick
; however, we must do different logic depending on state/call site

LDA simon_state
CMP #$14 ; stair walk
BEQ __recover_stair_walk
__recover_stair_idle:
LDA joypad_down
AND #$40
RTS
__recover_stair_walk:
JMP stair_walk_resume

crouch_direction:
LDA joypad_down
LSR A
BCC +
LDX #$00
STX facing
+
LSR A
BCC +
LDX #$01
STX facing
+
; resolve detour: trampoline
JMP crouch_resolve
custom_knockback:
BANKSWAP CUSTOM_JUMP_BANK
custom_knockback_bankswap_loc:
rts
custom_jump_then_standard_jump:
; push return address (-1)
LDA #>standard_jump
PHA
LDA #<standard_jump-1
PHA
custom_jump_jsr:
BANKSWAP CUSTOM_JUMP_BANK
custom_jump_bankswap_loc:
rts

jumping_attack:
JSR custom_jump_jsr
JMP attack_resolve ; .. not necessarily air-attacking?
LIMIT $C000

; --------------------------------------------------------------------
BANK CUSTOM_JUMP_BANK
BASE $8000

FROM empty_bank_jump
include "_custom_jump.asm"
include "_custom_knockback.asm"
end_bank_0_core:
FROM custom_knockback_bankswap_loc-5
ATLEAST end_bank_0_core
custom_knockback_bankswap_loc_pre:
BANKSWAP PLAYER_UPDATE_BANK
; (bankswap)
EXACT custom_knockback_bankswap_loc
jsr _custom_knockback
jmp custom_knockback_bankswap_loc_pre
end_custom_knockback_bankswap_tramp
FROM custom_jump_bankswap_loc-5
ATLEAST end_custom_knockback_bankswap_tramp
custom_jump_bankswap_loc_pre:
BANKSWAP PLAYER_UPDATE_BANK
; (bankswap)
EXACT custom_jump_bankswap_loc
jsr _custom_jump
jmp custom_jump_bankswap_loc_pre
end_custom_jump_bankswap_tramp:
3 changes: 2 additions & 1 deletion offsets-jp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ stair_walk_resume=$9A43
sypha_jumptable=$9C19
alucard_jumptable=$A59B
empty_bank_e=$BF39
empty_bank_jump=$BED0 ; actually can go a bit earlier
setAndSaveLowerBank=$E2D0
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$E
CUSTOM_JUMP_BANK=$1
2 changes: 1 addition & 1 deletion offsets-us.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stair_walk_resume=$9A2D
sypha_jumptable=$9C02
alucard_jumptable=$A5B4
empty_bank_e=$BFAB
empty_bank_0=$BED0 ; we actually can go a bit earlier
empty_bank_jump=$BED0 ; we actually can go a bit earlier
setAndSaveLowerBank=$E2E6
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$0
Binary file modified out-jp.ips
Binary file not shown.
99 changes: 7 additions & 92 deletions patch-jp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,102 +7,17 @@ include "offsets-jp.asm"

VSP_CONTROL_ZERO_VSPEED=$1C

; --------------------------------------------------------------------
BANK $E
BASE $8000

FROM $81FE
getting_hit:

FROM $8307
knockback_step:

FROM $8AC6
standard_state_0:


FROM $952D
standard_idle:

FROM $9624
standard_begin_jump:

FROM $9667
standard_walk:

include "_hooks.asm"

; custom code
FROM empty_bank_e
LDA #$01
STA hspint,X
custom_jump_then_standard_jump:
; push return address (-1)
LDA #>standard_jump
PHA
LDA #<standard_jump-1
PHA
custom_jump_jsr:
include "_custom_jump.asm"
MACRO BANKSWAP bank
lda #bank
jsr setAndSaveLowerBank
ENDM

jumping_attack:
JSR custom_jump_jsr
JMP attack_resolve ; .. not necessarily air-attacking?

stair_jumping:
; pressed jump button?
LDA joypad_pressed
AND #$80 ; (pressed jump)
BEQ __recover_step
; perform jump
LDA #$06 ; begin jump
STA simon_state
; double-return
; (quit out of stair logic as well)
PLA
PLA
RTS
__recover_step:
; here we perform the detour logic to resume a standard tick
; however, we must do different logic depending on state/call site

LDA simon_state
CMP #$14 ; stair walk
BEQ __recover_stair_walk
__recover_stair_idle:
LDA joypad_down
AND #$40
RTS
__recover_stair_walk:
JMP stair_walk_resume

custom_knockback:
include "_custom_knockback.asm"

crouch_direction:
LDA joypad_down
LSR A
BCC +
LDX #$00
STX facing
+
LSR A
BCC +
LDX #$01
STX facing
+
; (detour trampoline continue)
JMP crouch_resolve
LIMIT $C000
include "_improved_controls.asm"
; --------------------------------------------------------------------
BANK $F
BASE $C000

; jump by table
FROM $E814
FROM $E814
jump_by_table:
122 changes: 6 additions & 116 deletions patch-us.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,124 +7,14 @@ include "offsets-us.asm"

VSP_CONTROL_ZERO_VSPEED=$1C

; --------------------------------------------------------------------
BANK $E
BASE $8000

include "_hooks.asm"

; custom code
FROM empty_bank_e

stair_jumping:
; pressed jump button?
LDA joypad_pressed
AND #$80 ; (pressed jump)
BEQ __recover_step
; perform jump
LDA #$06 ; begin jump
STA simon_state
; double-return
; (quit out of stair logic as well)
PLA
PLA
RTS
__recover_step:
; here we perform the detour logic to resume a standard tick
; however, we must do different logic depending on state/call site

LDA simon_state
CMP #$14 ; stair walk
BEQ __recover_stair_walk
__recover_stair_idle:
LDA joypad_down
AND #$40
RTS
__recover_stair_walk:
JMP stair_walk_resume

crouch_direction:
LDA joypad_down
LSR A
BCC +
LDX #$00
STX facing
+
LSR A
BCC +
LDX #$01
STX facing
+
; resolve detour: trampoline
JMP crouch_resolve
custom_knockback:
lda #((CUSTOM_JUMP_BANK << 1) | $80)
MACRO BANKSWAP bank
; unclear why we | $80, but everyone else is doing it...
lda #((bank << 1) | $80)
jsr setAndSaveLowerBank
custom_knockback_bankswap_loc:
rts
custom_jump_then_standard_jump:
; push return address (-1)
LDA #>standard_jump
PHA
LDA #<standard_jump-1
PHA
custom_jump_jsr:
; not sure why we | #$80 but it seems everything else does
lda #((CUSTOM_JUMP_BANK << 1) | $80)
jsr setAndSaveLowerBank
custom_jump_bankswap_loc:
rts
ENDM

jumping_attack:
JSR custom_jump_jsr
JMP attack_resolve ; .. not necessarily air-attacking?
LIMIT $C000

; --------------------------------------------------------------------
BANK $0
BASE $8000

FROM empty_bank_0
include "_custom_jump.asm"
include "_custom_knockback.asm"
end_bank_0_core:
FROM custom_knockback_bankswap_loc-5
ATLEAST end_bank_0_core
custom_knockback_bankswap_loc_pre:
lda #((PLAYER_UPDATE_BANK << 1) | $80)
jsr setAndSaveLowerBank
; (bankswap)
EXACT custom_knockback_bankswap_loc
jsr _custom_knockback
jmp custom_knockback_bankswap_loc_pre
end_custom_knockback_bankswap_tramp
FROM custom_jump_bankswap_loc-5
ATLEAST end_custom_knockback_bankswap_tramp
custom_jump_bankswap_loc_pre:
lda #((PLAYER_UPDATE_BANK << 1) | $80)
jsr setAndSaveLowerBank
; (bankswap)
EXACT custom_jump_bankswap_loc
jsr _custom_jump
jmp custom_jump_bankswap_loc_pre
end_custom_jump_bankswap_tramp:
include "_improved_controls.asm"
; --------------------------------------------------------------------
BANK $F
BASE $C000

; jump by table
FROM $E814
BASE $C000
1 change: 1 addition & 0 deletions test_protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ for us and jp versions:
- falling off a cliff results in jumping instead (retain control)
- knockback is forgiving, directional input restored after a moment
- it's possible to die from enemy damage
- can jump off stairs
- (vcancel only) it's possible let go of the jump button in order to stop rising.

- (use passwords for these, and only test the vcancel rom):
Expand Down

0 comments on commit 53a1080

Please sign in to comment.