Skip to content

Commit

Permalink
inertia
Browse files Browse the repository at this point in the history
  • Loading branch information
nstbayless committed Jul 27, 2024
1 parent 53a1080 commit 670ba41
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 9 deletions.
91 changes: 85 additions & 6 deletions _custom_jump.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
_custom_jump:
if CUSTOM_JUMP_BANK == PLAYER_UPDATE_BANK
jsr rts_if_cutscene
if INERTIA != 0
ERROR INERTIA must be 0 if PLAYER_UPDATE_BANK=E
endif
JSR zero_hspfra
else
; return if in cutscene
Expand All @@ -11,9 +14,12 @@ else
rts
__continue

if INERTIA == 0
; zero out fractional hspeed
lda #$00
sta hspfra
endif

endif
LDA joypad_down
AND #$03 ; 1=right, 2=left
Expand All @@ -27,14 +33,22 @@ air_control_right:
BCS hcancel
; standard right
if INERTIA == 0
LDX #$01
STX hspint
else
jsr apply_inertia_rightward_full
endif
LDY #$00
LDX #$01
STX hspint
BPL __jumping_contd ; guaranteed
BEQ __jumping_contd ; guaranteed
air_control_left:
if INERTIA == 0
LDX #$FF
STX hspint
else
jsr apply_inertia_leftward_full
endif
LDY #$01
LDX #$FF
STX hspint
__jumping_contd

; decide whether or not to set facing
Expand All @@ -50,7 +64,31 @@ set_facing:
BNE check_vcancel ; guaranteed
hcancel:
if INERTIA == 0
STA hspint
else

; apply positive or negative inertia as necessary
; zero out hspfra *if* within INERTIA of #$0
lda hspint
bne standard_hcancel:
ldy #$0
lda hspfra
sty hspfra
cmp #INERTIA
bcc check_vcancel
CMP #($100-INERTIA)
bcs check_vcancel
sta hspfra
standard_hcancel
bit hspint
bmi +
jsr apply_inertia_leftward_full
jmp check_vcancel
+
jsr apply_inertia_rightward_full
endif
check_vcancel:
ifdef VCANCEL
Expand All @@ -66,4 +104,45 @@ check_vcancel:
STA vspint
endif
__vcancel_rts:
RTS
RTS
if INERTIA != 0
apply_inertia_rightward_full:
clc
lda #INERTIA
adc hspfra
sta hspfra
lda #$0
adc hspint
; clamp hspint
cmp #$01
bpl __apply_inertia_rts_r
sta hspint
rts

__apply_inertia_rts_r
lda #$01
__apply_inertia_rts
sta hspint
zero_hspfra_custom_bank:
lda #$0
sta hspfra
rts

apply_inertia_leftward_full:
sec
lda hspfra
sbc #INERTIA
sta hspfra
lda hspint
sbc #0
cmp #$FF
bmi __apply_inertia_l_rts
sta hspint
rts
__apply_inertia_l_rts:
lda #$FF
bne __apply_inertia_rts ; guaranteed
endif
9 changes: 7 additions & 2 deletions offsets-jp.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ standard_stair_walk=$9AAB
stair_walk_resume=$9A43
sypha_jumptable=$9C19
alucard_jumptable=$A59B
empty_bank_e=$BF39
empty_bank_e=$BF90 ; actually $BF39
empty_bank_jump=$BED0 ; actually can go a bit earlier
setAndSaveLowerBank=$E2D0
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$1
CUSTOM_JUMP_BANK=$1

; if $0, disabled
; otherwise, between $1 and $255 enabled
; higher values are actually less inertia, with $1 being the weightiest.
INERTIA=$40
4 changes: 3 additions & 1 deletion offsets-us.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ empty_bank_e=$BFAB
empty_bank_jump=$BED0 ; we actually can go a bit earlier
setAndSaveLowerBank=$E2E6
PLAYER_UPDATE_BANK=$E
CUSTOM_JUMP_BANK=$0
CUSTOM_JUMP_BANK=$0

INERTIA=$40
Binary file modified out-jp.ips
Binary file not shown.
Binary file modified out-us.ips
Binary file not shown.
3 changes: 3 additions & 0 deletions pkg_readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Similar controls hacks are available for [Castlevania](https://www.romhacking.ne

ASM hacking:
Sodium

Testing:
AmarthDokuro

Tools:
`fceux` and `asm6f`
Expand Down

0 comments on commit 670ba41

Please sign in to comment.