From 8ffd5e2d0a9471273915e91acff53680226c6cf8 Mon Sep 17 00:00:00 2001 From: nstbayless Date: Thu, 25 Jul 2024 14:20:05 -0700 Subject: [PATCH] clean up --- .gitignore | 5 +- README.md | 9 ++- _custom_jump.asm | 22 ++++--- _hooks.asm | 72 +++++++++++++++++++++ build.sh | 66 ++++++++++++++----- offsets-jp.asm | 3 + offsets-us.asm | 3 + out-jp.ips | Bin 325 -> 304 bytes out-us.ips | Bin 379 -> 358 bytes patch-jp.asm | 157 ++-------------------------------------------- patch-us.asm | 85 ++----------------------- pkg_readme.md | 64 +++++++++++++++++++ ram-us.asm | 2 +- test_protocol.txt | 7 +++ 14 files changed, 232 insertions(+), 263 deletions(-) create mode 100644 _hooks.asm create mode 100644 pkg_readme.md create mode 100644 test_protocol.txt diff --git a/.gitignore b/.gitignore index 3ebba07..ab1f431 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ *.nes .patch-prev.ips +*.ips *.dbg inc-base.asm *.map *.cdl -*.nl \ No newline at end of file +*.nl +*.zip +cv3-controls \ No newline at end of file diff --git a/README.md b/README.md index 1bb9813..f7be029 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ ## Castlevania 3 Improved Controls Hack -### Contributing to this repository +### Building -Run the `setup.sh` script before starting in order to enable githooks. +**Prerequisite**: you need asm6f [with rom patching directives](https://github.com/freem/asm6f/pull/30). -You must supply your own ROM for Akumajou Densetsu (J). Paste the ROM +Please add `base-us.nes` and/or `base-jp.nes` to the repo, then run `./build.sh`. -CRC32 for ROM: 2E93CE72 -SHA-1: A0F3B31D4E3B0D2CA2E8A34F91F14AD99A5AD11F +Produces `out-us.nes`, `out-jp.nes` etc., as well as `out-us.ips` and `out-jp.ips`, and packages the result \ No newline at end of file diff --git a/_custom_jump.asm b/_custom_jump.asm index 899c1e2..0bad719 100644 --- a/_custom_jump.asm +++ b/_custom_jump.asm @@ -53,15 +53,17 @@ 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 + ifdef 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 + endif __vcancel_rts: RTS \ No newline at end of file diff --git a/_hooks.asm b/_hooks.asm new file mode 100644 index 0000000..e5ce1d7 --- /dev/null +++ b/_hooks.asm @@ -0,0 +1,72 @@ +FROM detour_to_custom_knockback + ; replacement: + ; lda #$08 + ; ldy $04F2 + NOP + NOP + JSR custom_knockback + +; in Trevor state jump table ($9376) +FROM trevor_jump_table +SKIP $8 + ; state 8 (jumping) + ; jump replacement + DW custom_jump_then_standard_jump + +FROM attack + jsr jumping_attack + +FROM jump_attack_step + jsr jumping_attack + +FROM set_fall_state + ; go to jump state (instead of falling state) + lda #$08 + +FROM fall_adjust + ; x=0 before this + lda #VSP_CONTROL_ZERO_VSPEED + STA vsp_control,X + STX simon_fall_objphase + lda #$16 + sta imgsin +zero_hspfra: + lda #$00 + sta hspfra +__standard_rts: + rts +rts_if_cutscene: + lda cutscene_timer + beq __standard_rts + lda cutscene_input + beq __standard_rts + ; double-rts -- rts caller + pla + pla + rts +LIMIT standard_jump + +FROM standard_crouch + jsr crouch_direction + +FROM standard_stair_idle + ; replaces: + ; LDA joypad_down + ; AND #$40 ; down ? + JSR stair_jumping + NOP + +FROM standard_stair_walk + ; replaces: + ; JSR stair_walk_resume + JSR stair_jumping + +FROM sypha_jumptable + +SKIP $8 + ; jump + DW custom_jump_then_standard_jump + +FROM alucard_jumptable + SKIP $8 + DW custom_jump_then_standard_jump \ No newline at end of file diff --git a/build.sh b/build.sh index 6a6c527..4897bd6 100755 --- a/build.sh +++ b/build.sh @@ -3,6 +3,24 @@ SRC=patch OUT=out builds=("us" "jp") +vcancel_cfgs=("vcancel" "no-vcancel") + +export="cv3-controls" +set -e + +which asm6f > /dev/null +if [ $? != 0 ] +then + echo "asm6f is not on the PATH. asm6f with patching directives is required: https://github.com/freem/asm6f/pull/30" + exit 1 +fi + +if [ -d "$export" ] +then + rm -r $export +fi +mkdir $export +cp pkg_readme.md $export/README.md for build in "${builds[@]}"; do if [ ! -f $BASE-$build.nes ]; then @@ -10,20 +28,40 @@ for build in "${builds[@]}"; do 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 + mkdir $export/$build + + for vcancel in "${vcancel_cfgs[@]}"; do + + defines="" + + suffix="$build" + if [ "$vcancel" == "vcancel" ]; then + suffix="$build-$vcancel" + defines="$defines -dVCANCEL" + fi + + echo "building $suffix" + + asm6f -c -n -i "-dUSEBASE" "-dBUILD_${build^^}" $defines "$SRC-$build.asm" "$OUT-$suffix.nes" - asm6f -c -n -i "-dUSEBASE" "-dBUILD_${build^^}" "$SRC-$build.asm" "$OUT-$build.nes" + if [ $? != 0 ] + then + echo "error building." + exit + fi + + cp "$OUT-$suffix.ips" "$export/$build/$export-$suffix.ips" + + if command -v ipsnect >/dev/null 2>&1; then + ipsnect "$OUT-$suffix.ips" > "$OUT-$suffix.map" + fi + done +done - if [ $? != 0 ] - then - echo "error building." - exit - fi +echo "============================================" +echo "Assembling export." - ipsnect "$OUT-$build.ips" > "$OUT-$build.map" -done \ No newline at end of file +if [ -f cv3-controls.zip ]; then + rm cv3-controls.zip +fi +zip -r cv3-controls.zip $export/* \ No newline at end of file diff --git a/offsets-jp.asm b/offsets-jp.asm index 2ac4020..b426623 100644 --- a/offsets-jp.asm +++ b/offsets-jp.asm @@ -1,13 +1,16 @@ detour_to_custom_knockback=$8338 standard_crouch=$9920 +crouch_resolve=$840C trevor_jump_table=$9376 attack=$942F jump_attack_step=$94C9 +attack_resolve=$97A3 set_fall_state=$974F fall_adjust=$9756 standard_jump=$9777 standard_stair_idle=$99A4 standard_stair_walk=$9AAB +stair_walk_resume=$9A43 sypha_jumptable=$9C19 alucard_jumptable=$A59B empty_bank_e=$BF39 diff --git a/offsets-us.asm b/offsets-us.asm index 95a504a..83ffdf2 100644 --- a/offsets-us.asm +++ b/offsets-us.asm @@ -1,13 +1,16 @@ detour_to_custom_knockback=$834D standard_crouch=$9919 +crouch_resolve=$8421 trevor_jump_table=$9381 attack=$943A jump_attack_step=$94D4 +attack_resolve=$979C set_fall_state=$9748 fall_adjust=$974F standard_jump=$9770 standard_stair_idle=$998E standard_stair_walk=$9A93 +stair_walk_resume=$9A2D sypha_jumptable=$9C02 alucard_jumptable=$A5B4 empty_bank_e=$BFAB diff --git a/out-jp.ips b/out-jp.ips index 96212ecf8626fd24002a254463e5169c814c3a4d..cfd0a6d655c73c1d52665fead7300a2d6c4b7370 100644 GIT binary patch delta 96 zcmX@gw1G)Az%j(xgSpv*f%VlZg$4VWC-*Th+3jbZV$Z;=Pz$7Qg6N5=#%h=MGtb<@ rz@pH+{}uDB-9XXi{mgR=!HSn|22=Yz8P-p%bDnt3o$>5sIYxB=C}<%i delta 118 zcmdnMbd*Uoz%j(xgSpv*f%VlZg{}LUC-*Th+3jbZV$Z;=FbPQC1kn>!jn!W4XP&u* zfkk1){#VSib^}Fc>}Q^12v)pwGnm@%$#7(1owMjtEzO1t{A(3h1-Mqq^xj}y$}y0dfHN{%(3SP~fQ-!gEo toTKpUk%I8Vg)78#XD!w6n!vh

G8Xh-L)RK8lm$8O2%WOn3En0|5KlAu9j? delta 107 zcmaFH^qYw*z%j(xgTd|rL-#~3CyAvRnhh8D*DA0IaIKW-y}`PYp;v)5VX4(be?`X7 ziG@;(8WVd~7&*^cs^K+(brD0~3KkH}2&8>@T2?kFJbRR|a=ORLd=Cg);pKjx#nWB= F-2lkKD2f08 diff --git a/patch-jp.asm b/patch-jp.asm index 7e8485f..68f619b 100644 --- a/patch-jp.asm +++ b/patch-jp.asm @@ -17,26 +17,9 @@ getting_hit: FROM $8307 knockback_step: -FROM detour_to_custom_knockback - NOP - NOP - JSR custom_knockback - FROM $8AC6 standard_state_0: -; in Trevor state jump table ($9376) -FROM trevor_jump_table -SKIP $8 - ; state 8 (jumping) - ; jump replacement - DW custom_jump_then_standard_jump - -FROM attack - jsr jumping_attack - -FROM jump_attack_step - jsr jumping_attack FROM $952D standard_idle: @@ -47,57 +30,7 @@ standard_begin_jump: FROM $9667 standard_walk: -FROM set_fall_state - ; go to jump state (instead of falling state) - lda #$08 - -FROM fall_adjust - ; x=0 before this - lda #VSP_CONTROL_ZERO_VSPEED - STA vsp_control,X - STX simon_fall_objphase - lda #$16 - sta imgsin -zero_hspfra: - lda #$00 - sta hspfra -__standard_rts: - rts -rts_if_cutscene: - lda cutscene_timer - beq __standard_rts - lda cutscene_input - beq __standard_rts - ; double-rts -- rts caller - pla - pla - rts -LIMIT standard_jump - -FROM standard_crouch - jsr crouch_direction - -FROM standard_stair_idle - ; replaces: - ; LDA joypad_down - ; AND #$40 ; down ? - JSR stair_jumping - NOP - -FROM standard_stair_walk - ; replaces: - ; JSR $9A43 - JSR stair_jumping - -FROM sypha_jumptable - -SKIP $8 - ; jump - DW custom_jump_then_standard_jump - -FROM alucard_jumptable - SKIP $8 - DW custom_jump_then_standard_jump +include "_hooks.asm" ; custom code FROM empty_bank_e @@ -110,62 +43,11 @@ custom_jump_then_standard_jump: LDA #