1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-10 19:20:13 +00:00
oot/tools/reencode.sh
Dragorn421 bdee3d33b4
No longer use asm-processor (#1824)
* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "b3bfa14cf"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "b3bfa14cf"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "110b9eb"

* use CS_FLOAT

* update csdis

* update committed csdata

* finish updating csdis.py

* add script to reextract committed csdata

* dont use asm-processor, use iconv for reencoding utf8 to eucjp

* remove asm-processor csdata usage remnants

* --cs-float hex

* delete tempfile at end of reencode.sh (may want to rm even if compilation fails though?)

* comment reencode.sh

* comment CMD_F

* do not break permuter guessing compile command, by not reencode.sh-wrapping compilation under PERMUTER (thanks anghelo)

* fix the permuter fix

* pad -> sBssDummyNeg1

* reencode.sh: rm tempfile on script exit (including on error)

* renumber sBssDummy vars in zcolchk from 0

* Revert "--cs-float hex"

This reverts commit 85267dc348.

* Revert BSS changes

* Add linemarker to reencoded files for better error message

* fix audio/general.c bss

* make reencode.sh work on macOS

* touch up csdis, csdis_re

---------

Co-authored-by: cadmic <cadmic24@gmail.com>
2024-03-01 16:12:22 -05:00

26 lines
1,022 B
Bash
Executable file

#!/bin/bash
# The repo uses UTF-8 for text encoding, but the strings in the ROM are encoded in EUC-JP.
# This means for matching the source must be re-encoded to EUC-JP before IDO compiles it.
# This is conceptually equivalent to `gcc --finput-charset=UTF-8 --fexec-charset=EUC-JP`,
# except IDO has no equivalent arguments.
# Usage: reencode.sh [compile command minus input file...] [single input file]
set -e
# The last argument, the input source file to be compiled
srcfile="${@: -1}"
# Create a temporary file, and remove it on script exit
tempfile=`mktemp`_oot.c
trap "rm -f $tempfile" EXIT
# Re-encode from UTF-8 to EUC-JP
{
printf '#line 1 "%s"\n' "$srcfile" # linemarker
cat "$srcfile"
} | iconv -f UTF-8 -t EUC-JP > "$tempfile"
# All arguments but the last, forming the compile command
# Also include the source file's directory to have the include path as if we compiled the original source.
# Pass the EUC-JP encoded temporary file for compilation.
"${@:1:$# - 1}" -I `dirname $srcfile` $tempfile