mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 22:44:30 +00:00
Set up build system and disassembly for ntsc-1.2 (#2021)
* Set up build system for ntsc-1.2 * Set up disassembly for ntsc-1.2 * Add all unnamed functions to functions.txt * Update docs/retail_versions.md for ntsc-1.2 * Format * Update docs/retail_versions.md Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Remove mention of US * OOT_N64 -> PLATFORM_N64, OOT_GC -> PLATFORM_GC * Move mtxutil to libultra/gu * Fix libultra/io bss splits * Fix merge --------- Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
9ff6758458
commit
8366b8731e
28 changed files with 17138 additions and 54 deletions
|
@ -1,18 +1,17 @@
|
|||
# Decompiling retail versions
|
||||
|
||||
The next decompilation target for OOT is the PAL GameCube Master Quest ROM
|
||||
(`gc-eu-mq`), because it is the retail version that is most similar to the Debug
|
||||
ROM. Unfortunately there are still a lot of differences, many of which are
|
||||
register or stack allocation differences because retail ROMs were built with
|
||||
different compiler flags. However, once this version is done, future
|
||||
retail versions should be much easier, as the changes between retail versions are
|
||||
The next decompilation target for OOT is NTSC version 1.2
|
||||
(`ntsc-1.2`), because it is the N64 version that is most similar to the GC
|
||||
versions. Unfortunately there are still a lot of differences,
|
||||
but once this version is done, future
|
||||
N64 versions should be much easier, as the changes between N64 versions are
|
||||
small in comparison.
|
||||
|
||||
Instead of `cp`ing a matching build into `expected/`, the target ROM is disassembled as `.s` files then
|
||||
reassembled as `.o` files directly into `expected/build/gc-eu-mq` for diff tools.
|
||||
reassembled as `.o` files directly into `expected/build/ntsc-1.2` for diff tools.
|
||||
This allows us to make progress matching code in parallel with solving other
|
||||
problems (such as the build system, ROM organization, and BSS ordering). The
|
||||
files in `tools/disasm/gc-eu-mq` say how to split the source files and where the
|
||||
files in `tools/disasm/ntsc-1.2` say how to split the source files and where the
|
||||
functions and variables are in the target ROM, and these may need to be updated
|
||||
if there are mistakes or if function names change due to documentation work.
|
||||
|
||||
|
@ -21,55 +20,44 @@ still show diffs with data symbols. We might improve this later, but these data
|
|||
diffs are fine to ignore for now.
|
||||
|
||||
For register and stack allocation differences, often the code can be tweaked so
|
||||
that it matches both the retail ROM while continuing to match the Debug ROM (for
|
||||
that it matches both the retail ROM while continuing to match GC versions and the Debug ROM (for
|
||||
example, by reordering assignments or moving a local variable declaration inside
|
||||
an `if` block). Since retail MM versions use the same compiler flags as retail
|
||||
OOT, checking MM decomp for similar code can help.
|
||||
an `if` block). Since retail MM versions currently target N64, checking MM decomp for similar code can help.
|
||||
|
||||
We can disable code that was removed in retail builds by adding
|
||||
`#if OOT_DEBUG ... #endif` or `if (OOT_DEBUG) { ... }` around these parts of the
|
||||
We can handle code that is different between versions by adding
|
||||
`#if PLATFORM_N64 ... #endif` or `#if PLATFORM_GC ... #endif` around these parts of the
|
||||
code. In order to keep the code readable, we should try to minimize the amount of
|
||||
`#if` noise whenever possible.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Copy your target PAL GameCube Master Quest ROM (non-debug) to
|
||||
`baseroms/gc-eu-mq/baserom.z64`
|
||||
|
||||
1. Extract assets and ROM files **from the Debug ROM** by running
|
||||
|
||||
```sh
|
||||
make setup -jN
|
||||
```
|
||||
|
||||
if necessary, where `N` is the number of cores on your machine.
|
||||
1. Copy your target JP NTSC 1.2 ROM to `baseroms/ntsc-1.2/baserom.z64`
|
||||
|
||||
1. Build the non-matching test ROM by running
|
||||
|
||||
```sh
|
||||
make setup -jN VERSION=gc-eu-mq
|
||||
make -jN VERSION=gc-eu-mq
|
||||
make setup -jN VERSION=ntsc-1.2
|
||||
make -jN VERSION=ntsc-1.2
|
||||
```
|
||||
|
||||
where `N` is the number of cores on your machine. This will build into
|
||||
`build/gc-eu-mq` and produce `build/gc-eu-mq/oot-gc-eu-mq.z64`.
|
||||
`build/ntsc-1.2` and produce `build/ntsc-1.2/oot-ntsc-1.2.z64`.
|
||||
|
||||
If you later want to delete all output files, run
|
||||
|
||||
```sh
|
||||
make clean VERSION=gc-eu-mq
|
||||
make clean VERSION=ntsc-1.2
|
||||
```
|
||||
|
||||
1. Disassemble the target ROM by running
|
||||
|
||||
```sh
|
||||
make disasm -jN VERSION=gc-eu-mq
|
||||
make disasm VERSION=ntsc-1.2
|
||||
```
|
||||
|
||||
where `N` is the number of cores on your machine. The outputs will be written to
|
||||
`expected/build/gc-eu-mq`.
|
||||
The outputs will be written to `expected/build/ntsc-1.2`.
|
||||
|
||||
Note that if you need to copy a matching build for the Debug ROM, you can use
|
||||
Note that if you need to copy a matching build for another version, you can use e.g.
|
||||
|
||||
```sh
|
||||
mkdir -p expected/build
|
||||
|
@ -90,37 +78,32 @@ source .venv/bin/activate
|
|||
### retail_progress.py
|
||||
|
||||
Running `./retail_progress.py path/to/file.c` will attempt to figure out which functions
|
||||
in a file still need to match for `gc-eu-mq`. To get an overview of diffs for
|
||||
in a file still need to match for `ntsc-1.2`. To get an overview of diffs for
|
||||
all files, run `./retail_progress.py` with no arguments.
|
||||
|
||||
### asm-differ / diff.py
|
||||
|
||||
To diff assembly for a single function in `gc-eu-mq`, run e.g.
|
||||
To diff assembly for a single function in `ntsc-1.2`, run e.g.
|
||||
|
||||
```sh
|
||||
./diff.py -mwo3 -v gc-eu-mq Math3D_CylTriVsIntersect
|
||||
./diff.py -mwo3 -v ntsc-1.2 Math3D_CylTriVsIntersect
|
||||
```
|
||||
|
||||
The `-v` flag tells `diff.py` to compare between `build/gc-eu-mq` and
|
||||
`expected/build/gc-eu-mq`, and to use `make VERSION=gc-eu-mq` when rebuilding.
|
||||
|
||||
You may also want to diff the Debug ROM in another terminal with
|
||||
|
||||
```sh
|
||||
./diff.py -mwo3 Math3D_CylTriVsIntersect
|
||||
```
|
||||
The `-v` flag tells `diff.py` to compare between `build/ntsc-1.2` and
|
||||
`expected/build/ntsc-1.2`, and to use `make VERSION=ntsc-1.2` when rebuilding.
|
||||
|
||||
You may also want to diff versions `gc-eu-mq` and/or `gc-eu-mq-dbg` in another terminal
|
||||
to ensure any changes still match there.
|
||||
|
||||
### Permuter and decomp.me
|
||||
|
||||
Disassembly for individual functions is written to
|
||||
`expected/build/gc-eu-mq/functions`, so to get a [decomp.me](https://decomp.me/) scratch you can run
|
||||
`expected/build/ntsc-1.2/functions`, so to get a [decomp.me](https://decomp.me/) scratch you can run
|
||||
e.g.
|
||||
|
||||
```sh
|
||||
decomp-permuter/import.py \
|
||||
src/code/sys_math3d.c \
|
||||
expected/build/gc-eu-mq/functions/src/code/sys_math3d/Math3D_CylTriVsIntersect.s \
|
||||
VERSION=gc-eu-mq --decompme
|
||||
expected/build/ntsc-1.2/functions/src/code/sys_math3d/Math3D_CylTriVsIntersect.s \
|
||||
VERSION=ntsc-1.2 --decompme
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue