From ddee96ef24ec27b592e7a9c77ef7e34a6b4bcef7 Mon Sep 17 00:00:00 2001 From: nstbayless Date: Thu, 25 Jul 2024 11:55:31 -0700 Subject: [PATCH] introduce patch-us --- _custom_jump.asm | 67 ++++++++++++ _custom_knockback.asm | 30 ++++++ build.sh | 40 +++++--- offsets-jp.asm | 16 +++ offsets-us.asm | 17 ++++ out-jp.ips | Bin 0 -> 325 bytes out-us.ips | Bin 0 -> 379 bytes patch.asm => patch-jp.asm | 53 ++++------ patch-us.asm | 207 ++++++++++++++++++++++++++++++++++++++ pre.asm | 6 ++ ram.asm => ram-jp.asm | 6 +- ram-us.asm | 60 +++++++++++ 12 files changed, 449 insertions(+), 53 deletions(-) create mode 100644 _custom_jump.asm create mode 100644 _custom_knockback.asm create mode 100644 offsets-jp.asm create mode 100644 offsets-us.asm create mode 100644 out-jp.ips create mode 100644 out-us.ips rename patch.asm => patch-jp.asm (90%) create mode 100644 patch-us.asm rename ram.asm => ram-jp.asm (96%) create mode 100644 ram-us.asm diff --git a/_custom_jump.asm b/_custom_jump.asm new file mode 100644 index 0000000..899c1e2 --- /dev/null +++ b/_custom_jump.asm @@ -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 \ No newline at end of file diff --git a/_custom_knockback.asm b/_custom_knockback.asm new file mode 100644 index 0000000..f4a87b5 --- /dev/null +++ b/_custom_knockback.asm @@ -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 \ No newline at end of file diff --git a/build.sh b/build.sh index 08508ba..6a6c527 100755 --- a/build.sh +++ b/build.sh @@ -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" \ No newline at end of file + if [ $? != 0 ] + then + echo "error building." + exit + fi + + ipsnect "$OUT-$build.ips" > "$OUT-$build.map" +done \ No newline at end of file diff --git a/offsets-jp.asm b/offsets-jp.asm new file mode 100644 index 0000000..2ac4020 --- /dev/null +++ b/offsets-jp.asm @@ -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 \ No newline at end of file diff --git a/offsets-us.asm b/offsets-us.asm new file mode 100644 index 0000000..95a504a --- /dev/null +++ b/offsets-us.asm @@ -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 \ No newline at end of file diff --git a/out-jp.ips b/out-jp.ips new file mode 100644 index 0000000000000000000000000000000000000000..96212ecf8626fd24002a254463e5169c814c3a4d GIT binary patch literal 325 zcmXAkze~eF7=|yoI}@d1L2=4(;9@$}&B-5BB@F=`+zm*j{sYc|x(Fr|71EX#O5~&m z1_X5wheL45ma(o*lIaMzxacKL&&T`mynNrm_F=<<9Sh(rBhMUO2SDB6@MaT0awYlk z&+rJSOo!nKAj}v|aqx!OvJVgg{w#K5PZK|JM-$)ewhQ}p>3nh6e*%c~cm@ZrGU#zQ zTr0cjV+q~_?@Srxh=mqAv&d;kjzd~Ap)l=k#eP^BgGdQ-RMo~x^eczBg%dqphyhBf zLcg4#6#6-mh9^UUt8>ior&wM@uuFEha~slC(-S(I@mp9PR`^Q-OJU1(8UtzzQ)+dC w>2gn-Vv$;jn$ENJqNRAw`Q&Bg%f%hj?{nnRn%%__2qvhYBI#7lclY=H04Aq;EdT%j literal 0 HcmV?d00001 diff --git a/out-us.ips b/out-us.ips new file mode 100644 index 0000000000000000000000000000000000000000..d6afd877086562a6ee6025b2b633837d62231a62 GIT binary patch literal 379 zcmXw#u}i~16vkhAcWu;)1;s%+90<~Ej^bdIqQnr;LBU1LQt0Nt5U7i2NR;Vo#kP+44p$Yl7184*5e)iQHcFJqKR f14=C%sv^})9x+=|Sj^Sgp+2fstandard_jump PHA - LDA #$76 + LDA #standard_jump + PHA + LDA # pos + endif +ENDM + MACRO LIMIT pos if ($ > pos) ERROR exceeded room! $ > pos diff --git a/ram.asm b/ram-jp.asm similarity index 96% rename from ram.asm rename to ram-jp.asm index 829e75e..0865235 100644 --- a/ram.asm +++ b/ram-jp.asm @@ -91,7 +91,6 @@ BASE $0028: BASE $002A: joypad_down: - BASE $0506: dagger_hspint: @@ -134,11 +133,8 @@ BASE $000B: BASE $0008: tmp_y: -BASE $003A - partner_us: - BASE $0048 - partner_jp: + partner: BASE $780 cutscene_timer: diff --git a/ram-us.asm b/ram-us.asm new file mode 100644 index 0000000..c5697b7 --- /dev/null +++ b/ram-us.asm @@ -0,0 +1,60 @@ +BASE $0021: + _bank: + +BASE $0026: + joypad_pressed: + +BASE $0028: + joypad_down: + +BASE $003A + partner: + +BASE $0565: + simon_state: + +BASE $0520: + vspint: + +BASE $05D8: + vsp_control: + +BASE $003A: + hitpoints: + +BASE $0400: + imgsin: + +BASE $04A8: + facing: + +BASE $04F2: + hspint: + +BASE $041C: + yint: + +BASE $0438: + xint: + +BASE $0509: + hspfra: + +BASE $0537: + vspfra: + +BASE $04C4: + xfra: + +BASE $04DB: + yfra: + +; TODO: double check these! +BASE $780 + cutscene_timer: + +BASE $783 + cutscene_input: + +BASE $05C1: + simon_fall_objphase: \ No newline at end of file