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 0000000..96212ec Binary files /dev/null and b/out-jp.ips differ diff --git a/out-us.ips b/out-us.ips new file mode 100644 index 0000000..d6afd87 Binary files /dev/null and b/out-us.ips differ diff --git a/patch.asm b/patch-jp.asm similarity index 90% rename from patch.asm rename to patch-jp.asm index 4fcac3a..7e8485f 100644 --- a/patch.asm +++ b/patch-jp.asm @@ -2,7 +2,8 @@ include "pre.asm" -include "ram.asm" +include "ram-jp.asm" +include "offsets-jp.asm" VSP_CONTROL_ZERO_VSPEED=$1C @@ -16,7 +17,7 @@ getting_hit: FROM $8307 knockback_step: -FROM $8338 +FROM detour_to_custom_knockback NOP NOP JSR custom_knockback @@ -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 @@ -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 @@ -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 + 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