Skip to content

Commit

Permalink
introduce patch-us
Browse files Browse the repository at this point in the history
  • Loading branch information
nstbayless committed Jul 25, 2024
1 parent 2f8aefe commit ddee96e
Show file tree
Hide file tree
Showing 12 changed files with 449 additions and 53 deletions.
67 changes: 67 additions & 0 deletions _custom_jump.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
_custom_jump:
if CUSTOM_JUMP_BANK == PLAYER_UPDATE_BANK
jsr rts_if_cutscene
JSR zero_hspfra
else
; return if in cutscene
lda cutscene_timer
beq __continue
lda cutscene_input
beq __continue
rts
__continue

; zero out fractional hspeed
lda #$00
sta hspfra
endif
LDA joypad_down
AND #$03 ; 1=right, 2=left
BEQ hcancel
LSR A
BCC air_control_left
air_control_right:
; if left and right, hcancel
LSR A
BCS hcancel
; standard right
LDY #$00
LDX #$01
STX hspint
BPL __jumping_contd ; guaranteed
air_control_left:
LDY #$01
LDX #$FF
STX hspint
__jumping_contd

; decide whether or not to set facing
LDA simon_state
CMP #8 ; jumping
BNE check_vcancel
LDA imgsin
CMP #$10
set_facing:
BEQ check_vcancel
STY facing
BNE check_vcancel ; guaranteed
hcancel:
STA hspint
check_vcancel:
LDA joypad_down
AND #$80 ; holding jump button?
BNE __vcancel_rts
LDA vspint ; already moving downward?
BPL __vcancel_rts
LDA #VSP_CONTROL_ZERO_VSPEED
STA vsp_control
LDA #$00
STA vspint
__vcancel_rts:
RTS
30 changes: 30 additions & 0 deletions _custom_knockback.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
_custom_knockback:
; if 0 hp, do normal knockback
LDA hitpoints
BEQ __return_to_knockback

LDA vspint
BMI custom_knockback_moving_upward

LDA #8 ; jumping
STA simon_state
LDA $49
BEQ custom_knockback_moving_upward
LDA $48
CMP #$02
BNE custom_knockback_moving_upward
LDA #$38
STA vsp_control
LDA #$16
STA imgsin
JMP __return_to_knockback

custom_knockback_moving_upward:
LDA #VSP_CONTROL_ZERO_VSPEED
STA vsp_control
LDA $A689,Y
__return_to_knockback:
; resolve detour
LDA #8
LDY hspint
RTS
40 changes: 24 additions & 16 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
BASE=base.nes
SRC=patch.asm
BASE=base
SRC=patch
OUT=out

echo "INCNES \"$BASE\"" > inc-base.asm
which asm6f > /dev/null
if [ $? != 0 ]
then
echo "asm6f is not on the PATH."
continue
fi
builds=("us" "jp")

asm6f -c -n -i "-dUSEBASE" "$SRC" "$OUT.nes"
for build in "${builds[@]}"; do
if [ ! -f $BASE-$build.nes ]; then
echo "no base: $BASE-$build.nes"
continue
fi
echo "INCNES \"$BASE-$build.nes\"" > inc-base.asm
which asm6f > /dev/null
if [ $? != 0 ]
then
echo "asm6f is not on the PATH."
continue
fi

if [ $? != 0 ]
then
echo "error building."
exit
fi
asm6f -c -n -i "-dUSEBASE" "-dBUILD_${build^^}" "$SRC-$build.asm" "$OUT-$build.nes"

ipsnect "$OUT.ips" > "$OUT.map"
if [ $? != 0 ]
then
echo "error building."
exit
fi

ipsnect "$OUT-$build.ips" > "$OUT-$build.map"
done
16 changes: 16 additions & 0 deletions offsets-jp.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
detour_to_custom_knockback=$8338
standard_crouch=$9920
trevor_jump_table=$9376
attack=$942F
jump_attack_step=$94C9
set_fall_state=$974F
fall_adjust=$9756
standard_jump=$9777
standard_stair_idle=$99A4
standard_stair_walk=$9AAB
sypha_jumptable=$9C19
alucard_jumptable=$A59B
empty_bank_e=$BF39
setAndSaveLowerBank=$E2D0
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$E
17 changes: 17 additions & 0 deletions offsets-us.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
detour_to_custom_knockback=$834D
standard_crouch=$9919
trevor_jump_table=$9381
attack=$943A
jump_attack_step=$94D4
set_fall_state=$9748
fall_adjust=$974F
standard_jump=$9770
standard_stair_idle=$998E
standard_stair_walk=$9A93
sypha_jumptable=$9C02
alucard_jumptable=$A5B4
empty_bank_e=$BFAB
empty_bank_0=$BED0 ; we actually can go a bit earlier
setAndSaveLowerBank=$E2E6
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$0
Binary file added out-jp.ips
Binary file not shown.
Binary file added out-us.ips
Binary file not shown.
53 changes: 21 additions & 32 deletions patch.asm → patch-jp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

include "pre.asm"

include "ram.asm"
include "ram-jp.asm"
include "offsets-jp.asm"

VSP_CONTROL_ZERO_VSPEED=$1C

Expand All @@ -16,7 +17,7 @@ getting_hit:
FROM $8307
knockback_step:

FROM $8338
FROM detour_to_custom_knockback
NOP
NOP
JSR custom_knockback
Expand All @@ -25,20 +26,16 @@ FROM $8AC6
standard_state_0:

; in Trevor state jump table ($9376)
FROM $9376
trevor_jump_table:

FROM $937E
FROM trevor_jump_table
SKIP $8
; state 8 (jumping)
; jump replacement
DW custom_jump_then_standard_jump

FROM $942F
attack:
FROM attack
jsr jumping_attack

FROM $94C9
jump_attack_step:
FROM jump_attack_step
jsr jumping_attack

FROM $952D
Expand All @@ -50,11 +47,11 @@ standard_begin_jump:
FROM $9667
standard_walk:

FROM $974F
FROM set_fall_state
; go to jump state (instead of falling state)
lda #$08

FROM $9756
FROM fall_adjust
; x=0 before this
lda #VSP_CONTROL_ZERO_VSPEED
STA vsp_control,X
Expand All @@ -75,50 +72,42 @@ rts_if_cutscene:
pla
pla
rts
LIMIT $9777

FROM $9777
standard_jump:
LIMIT standard_jump

FROM $9920
standard_crouch:
FROM standard_crouch
jsr crouch_direction

FROM $99A4
standard_stair_idle:
FROM standard_stair_idle
; replaces:
; LDA joypad_down
; AND #$40 ; down ?
JSR stair_jumping
NOP
FROM $9AAB
standard_stair_walk:
FROM standard_stair_walk
; replaces:
; JSR $9A43
JSR stair_jumping

FROM $9C19
sypha_jumptable:
FROM sypha_jumptable

FROM $9C21
SKIP $8
; jump
DW custom_jump_then_standard_jump

FROM $A59B
alucard_jumptable:

FROM $A5A3
FROM alucard_jumptable
SKIP $8
DW custom_jump_then_standard_jump

; custom code
FROM $BF39
FROM empty_bank_e
LDA #$01
STA hspint,X
custom_jump_then_standard_jump:
; push return address (-1)
LDA #$97
LDA #>standard_jump
PHA
LDA #$76
LDA #<standard_jump-1
PHA
custom_jump_jsr:
jsr rts_if_cutscene
Expand Down
Loading

0 comments on commit ddee96e

Please sign in to comment.