Skip to content

Commit

Permalink
better fix for #71, added build scripts for old VWF code (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
eadmaster committed Jan 19, 2025
1 parent 951ebae commit e3b27d3
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 4 deletions.
4 changes: 2 additions & 2 deletions script/eng/events/041_00_1.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
31|
<CC03F0=002E00320000001903FF00000000>|
32|
<CC03EA><color=0004><string=00F8><lineend><color=0001>Your Majesty, we're certain about it.<pause><lineend><CC03EA>A red-haired witch is in a cave on the <color=0005>southwest path to Amberstep.<color=0001><pause><lineend>|
<CC03EA><color=0004><string=00F8><lineend><color=0001>Your Majesty, if I remember correctly, a red-haired witch is in a cave at the end of the side path <color=0005>between this town and Amberstep<color=0001>, right?<pause><lineend>|
33|
<CC03EA><color=0002><string=0000><lineend><color=0001>This is certain.<lineend>The cavern was said to be in the <color=0002>southwest.<color=0001><pause><lineend>|
<CC03EA><color=0002><string=0000><lineend><color=0001>Yes, the cavern was said to be in the <color=0002>southwest.<color=0001><pause><lineend>|
34|
<CC03F0=000000880001000A03FF00000000>|
35|
Expand Down
7 changes: 5 additions & 2 deletions src/buildcd/_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cp "Princess Crown (Japan) (1M) (Track 01).bin" "$PATCHED_IMAGE_FILE"

# patch font, items and names -> alters 0.BIN, KANJI.BIN
source _patch_items.sh
#WIP: source _patch_items_vwf.sh

# patch events
7z e -y "Princess Crown (Japan) (1M) (Track 01).iso" '*.EVN'
Expand Down Expand Up @@ -59,8 +60,10 @@ cd-replace "$PATCHED_IMAGE_FILE" 015_00_1.EVN 015_00_1.EVN.fixed
xdelta3 -f -d -s 176_00_0.EVN 176_00_0.EVN.xdelta 176_00_0.EVN.fixed
cd-replace "$PATCHED_IMAGE_FILE" 176_00_0.EVN 176_00_0.EVN.fixed
# temp. fix for PEOPLE FULL bug in Cado Bado (add missing cmds) https://github.com/eadmaster/pcrown/issues/71
xdelta3 -f -d -s 041_00_1.EVN 041_00_1.EVN.xdelta 041_00_1.EVN.fixed
cd-replace "$PATCHED_IMAGE_FILE" 041_00_1.EVN 041_00_1.EVN.fixed
#xdelta3 -f -d -s 041_00_1.EVN 041_00_1.EVN.xdelta 041_00_1.EVN.fixed
#cd-replace "$PATCHED_IMAGE_FILE" 041_00_1.EVN 041_00_1.EVN.fixed
sfk partcopy 041_00_1.EVN 0x3DD 190 041_00_1.EVN.eng 0x3DD -yes
cd-replace "$PATCHED_IMAGE_FILE" 041_00_1.EVN 041_00_1.EVN.eng
# temp. fix for softlock at dialog with the wizard turned into a frog () https://github.com/eadmaster/pcrown/issues/89
sfk setbytes 061_00_2.EVN.eng 0x1002 0x0190 -yes
sfk setbytes 061_00_1.EVN.eng 0x1002 0x0190 -yes # not sure if really needed
Expand Down
66 changes: 66 additions & 0 deletions src/buildcd/_patch_items_vwf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

export CD_PATH=../../cd
export TRANSLATED_SCRIPT_PATH=../../script/eng
#export PATCHED_IMAGE_FILE="Princess Crown (Japan) (1M) (Track 01) (English).iso"
export PATCHED_IMAGE_FILE="Princess Crown (Japan) (1M) (Track 01) (patched).bin"

7z e -y "Princess Crown (Japan) (1M) (Track 01).iso" KANJI.BIN
7z e -y "Princess Crown (Japan) (1M) (Track 01).iso" 0.BIN

# unnecessary:
# fontgen -2 -b ${BMFONTGEN} ${FONTGEN_DIR}/pcrown.txt -o KANJI.BIN
# fontgen [options] [filename].txt -o [filename].bin
#wine prgutil.exe [options] [list of prg or text files]

# inject VWF code https://github.com/eadmaster/pcrown/issues/99
# satcode_insert.exe compiled_code.bin(patch file) target_file.bin
wine satcode_insert.exe ../satcode.old/satcode_patch.bin 0.BIN

# patch the font
xdelta3 -f -d -s KANJI.BIN KANJI.BIN.xdelta KANJI_ENG.BIN # apply English font patch

# patch items and names
iconv -f UTF-8 -t SHIFT-JIS ${TRANSLATED_SCRIPT_PATH}/items.txt -o ${TRANSLATED_SCRIPT_PATH}/items.txt.sjis
wine itemsutil.exe -i ${TRANSLATED_SCRIPT_PATH}/names.txt ${TRANSLATED_SCRIPT_PATH}/items.txt.sjis 0.BIN KANJI_ENG.BIN 0xEA0 # 0xEA0 = starting write offset in KANJI_ENG.BIN, ranges are in itemsutils/main.cpp

# fix Engrish text in main program (opening, etc) https://github.com/eadmaster/pcrown/issues/94
# "A LONG LONG AGO..." -> "LONG LONG AGO..."
sfk setbytes 0.BIN 0xACC85 "LONG LONG AGO... " -yes
# PROSERPINA RUN A WAY AT TOP SPEED -> PROSERPINA RAN AWAY AT FULL SPEED
sfk setbytes 0.BIN 0xACDFD "RAN AWAY AT FULL" -yes
# "PARSONS HAPPENED TO BE REAL PORTGUS" -> "PARSON HAPPENED TO BE PORTGUS "
sfk setbytes 0.BIN 0xACE35 "PARSON HAPPENED TO BE " 0x04 "PORTGUS " -yes
# "BUT THIS CAUSED THE GATE TO UNDERWORLD" -> "AND THIS OPENED THE DEMON REALM'S GATE"
sfk setbytes 0.BIN 0xACE91 "AND" -yes
sfk setbytes 0.BIN 0xACE9A "OPEN" -yes
sfk setbytes 0.BIN 0xACEA5 0x04 -yes
sfk setbytes 0.BIN 0xACEA6 "DEMON REALM'S GATE" -yes
# "GRADRIEL WENT TO FACE THE GREATERDEMONS" -> "GRADRIEL WENT TO FACE THE DEMON KING"
sfk setbytes 0.BIN 0xACED8 "DEMON KING " -yes
# "FALLDOWN FROM THE BOOKWORLD" (gameover screen) -> "FALLEN FROM THE BOOKWORLD"
sfk setbytes 0.BIN 0xACC3A "E" -yes
sfk setbytes 0.BIN 0xACC3C "N" -yes
sfk setbytes 0.BIN 0xACC3E " " -yes
sfk setbytes 0.BIN 0xACC40 " " -yes

# fix Engrish in the save manager https://github.com/eadmaster/pcrown/issues/94
# "The SAVE-FILE has crashed." -> "The SaveFile is corrupted"
sfk setbytes 0.BIN 0xA4099 "FILE is corrupt" -yes
# "BACK-UP RAM is lacking." -> "BACK-UP RAM is full. "
sfk setbytes 0.BIN 0xA40E0 "full. " -yes

# statically enable debug mode (press Start on 2nd pad to navigate event files) https://web.archive.org/web/20200918203538/https://github.com/cyberwarriorx/pcrown/wiki/Debugging
#sfk setbytes 0.BIN 0x1EB7F 0x01 -yes

# add splashscreen -> freezes with cheats enabled during boot https://github.com/eadmaster/pcrown/issues/96
#mv 0.BIN 0_org.BIN
#wine mksplash.exe ../mksplash/splash_loader.bin ../mksplash/splash.bmp 0_org.BIN 0.BIN
#rm 0_org.BIN

# add version number in title screen https://github.com/eadmaster/pcrown/issues/96
# "@SEGA ENTERPRISES,LTD.& ATLUS,1997" -> "@SEGA & ATLUS,1997 T-ENG V0.8.1"
sfk setbytes 0.BIN 0xA4137 "& ATLUS,1997 T-ENG V0.8.2" -yes

cd-replace "$PATCHED_IMAGE_FILE" 0.BIN 0.BIN
cd-replace "$PATCHED_IMAGE_FILE" KANJI.BIN KANJI_ENG.BIN
Binary file added src/buildcd/satcode_insert.exe
Binary file not shown.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/satcode-insert.old/_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


x86_64-w64-mingw32-g++ -w -fpermissive *.c -lcomdlg32 -lmingw32 -o ../buildcd/satcode_insert.exe
File renamed without changes.
11 changes: 11 additions & 0 deletions src/satcode.old/_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# PRE: install into $HOME/opt/sh2-elf-gcc https://github.com/kentosama/sh2-elf-gcc

export PATH="${PATH}:$HOME/opt/sh2-elf-gcc/sh2-toolchain/bin"
export KPITOUTPUT=elf

sh2-elf-gcc -o satcode_patch.elf patch.s -O2 -Wall -m2 -nostartfiles -Wl,--script,bart.lk -Wl,-Map,main.map
# --small

# Generating stripped patch.bin
sh2-elf-strip satcode_patch.elf --strip-all --output-target=binary -o satcode_patch.bin

0 comments on commit e3b27d3

Please sign in to comment.