diff --git a/_custom_jump.asm b/_custom_jump.asm index 0bad719..e786b81 100644 --- a/_custom_jump.asm +++ b/_custom_jump.asm @@ -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 @@ -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 @@ -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 @@ -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 @@ -66,4 +104,45 @@ check_vcancel: STA vspint endif __vcancel_rts: - RTS \ No newline at end of file + 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 \ No newline at end of file diff --git a/offsets-jp.asm b/offsets-jp.asm index d0b8b34..0918997 100644 --- a/offsets-jp.asm +++ b/offsets-jp.asm @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/offsets-us.asm b/offsets-us.asm index 43cc5cb..7844335 100644 --- a/offsets-us.asm +++ b/offsets-us.asm @@ -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 \ No newline at end of file +CUSTOM_JUMP_BANK=$0 + +INERTIA=$40 \ No newline at end of file diff --git a/out-jp.ips b/out-jp.ips index 101a5e6..38d7c45 100644 Binary files a/out-jp.ips and b/out-jp.ips differ diff --git a/out-us.ips b/out-us.ips index 695ba79..fd2d764 100644 Binary files a/out-us.ips and b/out-us.ips differ diff --git a/pkg_readme.md b/pkg_readme.md index 295c2be..ed5152b 100644 --- a/pkg_readme.md +++ b/pkg_readme.md @@ -41,6 +41,9 @@ Similar controls hacks are available for [Castlevania](https://www.romhacking.ne ASM hacking: Sodium + +Testing: + AmarthDokuro Tools: `fceux` and `asm6f`