New build system

This commit is contained in:
Seeky 2022-07-01 12:01:23 +01:00
parent 7ee53514fd
commit 9a91c42d74
179 changed files with 14121 additions and 3587 deletions

12
.gitignore vendored
View File

@ -1,4 +1,10 @@
__pycache__
.vscode
*.s
*.o
*.py
build
expected
out
*.dol
*.rel
*.exe
*.dll
build.ninja

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "tools/ppcdis"]
path = tools/ppcdis
url = https://github.com/SeekyCt/ppcdis.git

83
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,83 @@
# Contact
If you're interested in contributing, it's recommended you reach out to us in the #reverse-engineering channel of the [SPM Speedrunning Discord](https://discord.gg/dbd733H) first. Here you can ask for any help you might need and discuss what you plan to decompile to prevent any duplicated work.
# ppcdis
This project is build around the [ppcdis](https://github.com/SeekyCt/ppcdis) tools. These handle generation of assembly code (**you should never edit the assembly output manually**) and helpers for allowing partially-decompiled C files to match.
## YMLs
### Overrides
Overrides allow hints to be given to the analysis / disassembly to improve accuracy or work around issues. Generally you won't need to change anything about analysis (`config/analysis_overrides.yml`), though changing the disassembly is more common (`config/analysis_overrides.yml`).
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#analyser-overrides).
### Slices
`config/dol_slices.yml` / `config/rel_slices.yml` control how the disassembly is split around the decompiled C code for the dol / rel.
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#slice-yml-format)
**You must re-run configure.py after changing this file**
### Symbols
`config/symbols.yml` controls the naming of functions and data in disassembly.
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#symbol-map)
## Generated includes
These can be generated by adding the include statement to a C file and re-running configure.py.
### Orderstrings
`#include orderstrings/XXXXXXXX_YYYYYYYY.inc` will generate a workaround for the ordering of strings in a file, with strings starting at address XXXXXXXX (inclusive) and ending at address YYYYYYYY (exclusive).
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#orderstrings)
### Orderfloats
`#include orderfloats/XXXXXXXX_YYYYYYYY.inc` will generate a workaround for the ordering of floats in a file, with floats starting at address XXXXXXXX (inclusive) and ending at address YYYYYYYY (exclusive).
`#include orderfloatsm/XXXXXXXX_YYYYYYYY.inc` will generate a 'manual' version of that (see documentation below).
`#include orderdoubles/XXXXXXXX_YYYYYYYY.inc` will generate a version of that for doubles. 'Manual' doubles are not needed for this project.
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#orderfloats)
### Jumptable
`#include jumptable/XXXXXXXX.inc` will generate a workaround for an undecompiled jumptable at address XXXXXXXX.
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#c-jumptable-generation)
### Asm
`#include asm/XXXXXXXX.s` will generate inline assembly for an undecompiled function.
See also the [ppcdis documentation of this](https://github.com/SeekyCt/ppcdis/blob/master/TOOLS.md#inline-function-generation)
# diff.py
A setup for [asm-differ](https://github.com/simonlindholm/asm-differ/blob/main/diff.py) is included. To use it:
- First get a matching build and run expected.py
- If you use the `-o` flag (see below), this will need to be re-ran whenever you add new source files
- You can now run `diff.py symbolName` to diff a function
- It's recommended to run it with the flags `-mwo`, see `-h` for details on these and the other flags available
- If you want to diff a function in the rel, you'll need to add the `-r` flag
# Project-Specific Tools
## decompme.py
Generates a scratch on [decomp.me](https://decomp.me/) for a function. This gives a web-based UI for editing & diffing a function, and the ability to share it with other people. Usage is `decompme.py XXXXXXXX` to upload the function at XXXXXXXX.
By default, an M2C decompiler compatible context is made, which strips definitions and macros that you have wanted included. You can replace this with a context from makectx.py (see below) after the decompiler runs if you'd like.
## getfunction.py
Gets the assembly of a single function. Usage is `getfunction.py XXXXXXXX` to get the function at XXXXXXXX.
## makectx(_m2c).py
Creates a context of all header files in the project concatenated and prints it to stdout. If using makectx_m2c, this will have the C preprocessor ran on it.

View File

@ -1,25 +1,27 @@
# spm-decomp
Decompilation of Super Paper Mario (PAL revision 0). Doesn't produce a dol, asm is just checked by compiling with -S (the scripts for automating this are messy and fairly hard-coded to my computer so I don't plan on releasing them, but if you're interested in contributing then let me know and I'll put something together).
Decompilation of Super Paper Mario PAL revision 0. This will never be a decompilitation of the full game, just specific parts that are useful or interesting, and it certainly won't lead to ports to any other platform. The repo is currently not shiftable (i.e. making changes to the code that causes functions or data to change size or move won't create a working output) but is intended to be at some point. The SDK, NW4R and MSL libraries are out of scope for this project and will not be decompiled (though partial headers will be needed for them to allow other code to be decompiled).
See also https://github.com/SeekyCt/spm-docs for other documentation
See also https://github.com/SeekyCt/spm-docs for other documentation.
## Address Notes
- Addresses of global functions and variables are commented in headers, static ones are commented at their c file definitions
- PAL revision 1's addresses are identical to revision 0's, so information from the decomp is accurate there too
- Rel addresses are given for the rel loaded in its default position for PAL revisions 0 & 1 (80c45820)
## Building
- Dump a copy of the game and extract the main.dol & relF.bin files
- Extract relF.bin to relF.rel with a tool like [nlzss](https://github.com/magical/nlzss)
- Place main.dol and relF.rel in the orig folder
- Place Codewarrior EPPC Version 4.1 Build 60831 in tools/4199_60831
- Install DevkitPPC, Ninja and Python
- DevkitPPC r38 and r41 are known to work, other versions probably do too
- Python 3.8+ is supported, earlier versions may work
- If you didn't use `--recursive` when cloning, run `git submodule update --init --recursive`
- Install the modules from requirements.txt (`pip install -r requirements.txt`)
- Run configure.py
- Run ninja
## Compiler Notes
### Flags
The compiler flags probably aren't fully accurate yet, and it's likely that some parts of the game will use different flags.
### Version
The project currently uses Codewarrior Version 4.1 build 60831, it's not known if this is the correct version.
## Matching Notes
- Data sections generally won't match in incomplete files
- To match string pools in incomplete files (since they affect asm), functions with strings that haven't been decompiled have temporary replacements that call a fake __dummy_string function to place these strings in the pool
- To match float pools in incomplete rel files, __dummy_float is used
## Contributing
See [CONTRIBUTING.md](TODO)
## Credits
- Various members of the TTYD community for their [documentation](https://github.com/PistonMiner/ttyd-tools) and for porting the demo symbol map to the final game
- The [PM64 decomp](https://github.com/ethteck/papermario) team for decompiling many of the same functions, which are useful to check against
- PistonMiner, Zephiles, Jdaster64, Jasper, NWPlayer123, Malleo, SolidifiedGaming and Diagamma for their TTYD documentation
- All contributors to the [PM64 decomp](https://github.com/ethteck/papermario)
- All contributors to [asm-differ](https://github.com/simonlindholm/asm-differ)
- All contributors to [ppcdis](https://github.com/SeekyCt/ppcdis/)

View File

@ -1,21 +0,0 @@
set dolflags=-O4 -proc gekko -lang C99 -S -w all -use_lmw_stmw on -fp hard -str pool -rostr -I- -i include -enc SJIS -inline all -sdata2 4
mwcceppc %dolflags% src/evtmgr.c
mwcceppc %dolflags% -ipa file src/evtmgr_cmd.c
mwcceppc %dolflags% src/filemgr.c
mwcceppc %dolflags% src/main.c
mwcceppc %dolflags% src/mario_pouch.c
mwcceppc %dolflags% src/memory.c
mwcceppc %dolflags% src/nandmgr.c
mwcceppc %dolflags% src/relmgr.c
mwcceppc %dolflags% src/seqdef.c
mwcceppc %dolflags% src/seqdrv.c
mwcceppc %dolflags% src/spmario.c
mwcceppc %dolflags% src/swdrv.c
mwcceppc %dolflags% src/system.c
mwcceppc %dolflags% src/windowdrv.c
mwcceppc %dolflags% src/wpadmgr.c
set relflags=-O4 -proc gekko -lang C99 -S -w all -use_lmw_stmw on -fp hard -str pool -rostr -I- -i include -enc SJIS -inline all -sdata 0 -sdata2 0 -pool off -ordered-fp-compares
mwcceppc %relflags% rel/dan.c

View File

@ -1,2 +0,0 @@
del *.s
del *.o

222
common.py Normal file
View File

@ -0,0 +1,222 @@
"""
Common functions & definitions
"""
from enum import Enum
from hashlib import sha1
import json
import os
from subprocess import PIPE, Popen
from sys import executable as PYTHON, platform
from typing import Tuple, Union
#############
# Functions #
#############
def get_file_sha1(path: str) -> bytes:
"""Gets the SHA1 hash of a file"""
with open(path, 'rb') as f:
return sha1(f.read()).digest()
def get_cmd_stdout(cmd: str, text=True) -> str:
"""Run a command and get the stdout output as a string"""
proc = Popen(cmd.split(), stdout=PIPE, text=text)
ret = proc.stdout.read()
proc.wait()
assert proc.returncode == 0, f"Command '{cmd}' returned {proc.returncode}"
return ret
class Binary(Enum):
DOL = 1
REL = 2
# ppcdis source output
SourceDesc = Union[str, Tuple[str, int, int]]
def get_containing_slice(addr: int) -> Tuple[Binary, SourceDesc]:
"""Finds the binary containing an address and its source file
Source file is empty string if not decompiled"""
dol_raw = get_cmd_stdout(f"{SLICES} {DOL} {DOL_SLICES} -p {DOL_SRCDIR}/ --containing {addr:x}")
containing = json.loads(dol_raw)
if containing is None:
rel_raw = get_cmd_stdout(
f"{SLICES} {REL} {REL_SLICES} {PPCDIS_REL_FLAGS} -p {REL_SRCDIR}/ --containing {addr:x}"
)
containing = json.loads(rel_raw)
assert containing is not None, f"Unknown address {addr:x}"
return (Binary.REL, containing)
else:
return (Binary.DOL, containing)
################
# Project dirs #
################
# Directory for decompiled dol code
DOL_SRCDIR = "src"
# Directory for decompiled rel code
REL_SRCDIR = "rel"
# Include directory
INCDIR = "include"
# Build artifacts directory
BUILDDIR = "build"
# Output binaries directory
OUTDIR = "out"
# Original binaries directory
ORIG = "orig"
# Tools directory
TOOLS = "tools"
# Config directory
CONFIG = "config"
#########
# Tools #
#########
# ppcdis
PPCDIS = "tools/ppcdis"
ANALYSER = f"{PYTHON} {PPCDIS}/analyser.py"
DISASSEMBLER = f"{PYTHON} {PPCDIS}/disassembler.py"
ORDERSTRINGS = f"{PYTHON} {PPCDIS}/orderstrings.py"
ORDERFLOATS = f"{PYTHON} {PPCDIS}/orderfloats.py"
FORCEACTIVE = f"{PYTHON} {PPCDIS}/forceactive.py"
ELF2DOL = f"{PYTHON} {PPCDIS}/elf2dol.py"
ELF2REL = f"{PYTHON} {PPCDIS}/elf2rel.py"
SLICES = f"{PYTHON} {PPCDIS}/slices.py"
# Codewarrior
TOOLS = "tools"
CODEWARRIOR = os.path.join(TOOLS, "4199_60831")
CC = os.path.join(CODEWARRIOR, "mwcceppc")
LD = os.path.join(CODEWARRIOR, "mwldeppc")
if platform != "win32":
CC = f"wine {CC}"
LD = f"wine {LD}"
# DevkitPPC
DEVKITPPC = os.environ.get("DEVKITPPC")
AS = os.path.join(DEVKITPPC, "bin", "powerpc-eabi-as")
OBJDUMP = os.path.join(DEVKITPPC, "bin", "powerpc-eabi-objdump")
ICONV = f"{PYTHON} tools/sjis.py" # TODO: get actual iconv working(?)
#########
# Files #
#########
# Slices
DOL_SLICES = f"{CONFIG}/dol_slices.yml"
REL_SLICES = f"{CONFIG}/rel_slices.yml"
# Overrides (TODO: do these need to be separate for rel?)
ANALYSIS_OVERRIDES = f"{CONFIG}/analysis_overrides.yml"
DISASM_OVERRIDES = f"{CONFIG}/disasm_overrides.yml"
# Binaries
DOL = f"{ORIG}/main.dol" # read in python code
REL = f"{ORIG}/relF.rel" # read in python code
REL_ADDR = "80c45820"
REL_BSS = "80f64340"
DOL_SHA = f"{ORIG}/main.dol.sha1"
REL_SHA = f"{ORIG}/relF.rel.sha1"
# Symbols
SYMBOLS = f"{CONFIG}/symbols.yml"
# Analysis outputs
DOL_LABELS = f"{BUILDDIR}/labels.pickle"
DOL_RELOCS = f"{BUILDDIR}/relocs.pickle"
REL_LABELS = f"{BUILDDIR}/rel_labels.pickle"
REL_RELOCS = f"{BUILDDIR}/rel_relocs.pickle"
# Linker
DOL_LCF = f"{CONFIG}/dol.lcf"
REL_LCF = f"{CONFIG}/rel.lcf"
# Outputs
DOL_ELF = f"{BUILDDIR}/main.elf"
REL_PLF = f"{BUILDDIR}/relF.plf"
DOL_OUT = f"{OUTDIR}/main.dol"
REL_OUT = f"{OUTDIR}/relF.rel"
DOL_MAP = f"{OUTDIR}/main.map"
REL_MAP = f"{OUTDIR}/relF.map"
##############
# Tool Flags #
##############
SDA = "805b5f00 805b7260" #r13 r2
ASFLAGS = ' '.join([
"-m gekko"
])
CFLAGS = [
"-nostdinc",
"-align powerpc",
"-enc SJIS",
"-proc gekko",
"-lang c99",
"-W all",
"-fp hard",
"-Cpp_exceptions off",
"-O4",
"-use_lmw_stmw on",
"-str pool",
"-rostr",
"-maxerrors 1",
"-sym on",
"-ipa file"
]
DOL_CFLAGS = ' '.join(CFLAGS + [
"-inline all",
"-sdata 4",
"-sdata2 4"
])
REL_CFLAGS = ' '.join(CFLAGS + [
"-sdata 0",
"-sdata2 0",
"-pool off",
"-ordered-fp-compares"
])
LDFLAGS = ' '.join([
"-fp hard",
"-linkmode moreram",
"-maxerrors 1",
"-mapunused"
])
PPCDIS_REL_FLAGS = ' '.join([
f"-a {REL_ADDR}",
f"-b {REL_BSS}",
f"-d {DOL}"
])
PPCDIS_ANALYSIS_FLAGS = ' '.join([
f"-o {ANALYSIS_OVERRIDES}"
])
PPCDIS_DISASM_FLAGS = ' '.join([
f"-m {SYMBOLS}",
f"-o {DISASM_OVERRIDES}"
])
####################
# diff.py Expected #
####################
EXPECTED = "expected"
DOL_EXPECTED = f"{EXPECTED}/build/main.elf"
REL_EXPECTED = f"{EXPECTED}/build/relF.plf"

View File

@ -0,0 +1,47 @@
blocked_pointer_ranges:
# LZ compressed data is a common source of false positives
- [0x8034fcc8, 0x8036eb04] # wiimario_snd, ag2tg, cookingText, treasureMapText, pitText
- [0x8032c1b8, 0x8032db20] # unkTpl1
- [0x8032fc20, 0x8032fd53] # unkTpl2
- [0x8036f530, 0x80373c7b] # holdSidewaysTpl
- [0x80344490, 0x803494e7] # saveImagesTpl
- [0x80349830, 0x8034a07f] # homeButtonNotAllowedTpl
- [0x80373d70, 0x80375da6] # creditsText
# Health and safety tpls
- [0x80375da8, 0x8037f864]
- [0x8037f868, 0x8038abc3]
- [0x8038abc8, 0x80394283]
- [0x80394288, 0x8039f18e]
- [0x8039f190, 0x803a8ea3]
- [0x803a8ea8, 0x803b445b]
- [0x803b4460, 0x803bda07]
- [0x803bda08, 0x803c8815]
- [0x803c8818, 0x803d240f]
- [0x803d2410, 0x803dd883]
- [0x803dd888, 0x803e6cf0]
- [0x803e6cf0, 0x803f199e]
# Most of extab shouldn't point to anything
- [0x800064E0, 0x8000EFC0]
- [0x8000F8D8, 0x8000FAC0]
# Some WPAD binary blobs
- [0x80504A98, 0x80505DC0]
- [0x805062C4, 0x80506380]
# Some VI data
- [0x804F8F40, 0x804F94D0]
sdata_sizes:
# windowdrv.c RGBA constants
- [0x805af7e0, 4]
- [0x805af7e8, 4]
- [0x805af820, 4]
- [0x805af82c, 4]
- [0x805af830, 4]
- [0x805af83c, 4]
- [0x805af860, 4]
- [0x805af86c, 4]
# spmario.c RGBA constant
- [0x805b3d24, 4]

View File

@ -0,0 +1,5 @@
manual_sdata2_ranges:
# spmario.c has a struct in the middle of the floats
- [0x805b3d20, 0x805b3d50]
# windowdrv.c has many structs in the middle of the floats
- [0x805af7e0, 0x805af870]

38
config/dol.lcf Normal file
View File

@ -0,0 +1,38 @@
ENTRY(__start)
MEMORY {
text : origin = 0x80004000
forcestrip : origin = 0
}
SECTIONS {
GROUP:{
.init ALIGN(0x20):{}
extab_ ALIGN(0x20):{}
extabindex_ ALIGN(0x20):{}
.text ALIGN(0x20):{}
.ctors ALIGN(0x20):{}
.dtors ALIGN(0x20):{}
.rodata ALIGN(0x20):{}
.data ALIGN(0x20):{}
.bss ALIGN(0x80):{}
.sdata ALIGN(0x20):{}
.sbss ALIGN(0x20):{}
.sdata2 ALIGN(0x20):{}
.sbss2 ALIGN(0x20):{}
.stack ALIGN(0x100):{}
} > text
GROUP:{
forcestrip ALIGN(0x20):{}
} > forcestrip
_stack_addr = (_f_sbss2 + SIZEOF(.sbss2) + 65536 + 0x7) & ~0x7;
_stack_end = _f_sbss2 + SIZEOF(.sbss2);
_db_stack_addr = (_stack_addr + 0x2000);
_db_stack_end = _stack_addr;
__ArenaLo = (_db_stack_addr + 0x1f) & ~0x1f;
__ArenaHi = 0x81700000;
_eti_init_info_ = 0x80007290;
}
__dummy_str = 0;
__dummy_float = 0;
__dummy_double = 0;
__dummy_pointer = 0;

110
config/dol_slices.yml Normal file
View File

@ -0,0 +1,110 @@
#########################################################
# You must re-run configure.py after changing this file #
#########################################################
# Paths relative to src/
extab.s:
extab_: [0x800064e0, 0x8000fac0]
extabindex_: [0x8000fac0, 0x8001da60]
main.c:
.text: [0x8001da60, 0x8001da88]
swdrv.c:
.text: [0x80037eac, 0x800388b4]
.rodata: [0x80325cb8, 0x80326360]
.bss: [0x8050a118, 0x8050a120]
.sdata: [0x805adf40, 0x805adf48]
windowdrv.c:
.text: [0x800388b4, 0x8003b26c]
.rodata: [0x80326360, 0x80326378]
.data: [0x80406c98, 0x80406d28]
.sbss: [0x805ae790, 0x805ae7a0]
.sdata2: [0x805af7e0, 0x805af870]
evtmgr.c:
.text: [0x800d87e4, 0x800da0b0]
.rodata: [0x8032eb60, 0x8032eca0]
.bss: [0x8050c990, 0x8050ce30]
.sdata: [0x805ae018, 0x805ae020]
.sbss: [0x805ae8d8, 0x805ae8e8]
.sdata2: [0x805b1d48, 0x805b1d50]
evtmgr_cmd.c:
.text: [0x800da0b0, 0x800df9a8]
.rodata: [0x8032eca0, 0x8032efe8]
.data: [0x80410608, 0x804107e8]
.bss: [0x8050ce30, 0x8050cf30]
.sdata2: [0x805b1d50, 0x805b1d68]
mario_pouch.c:
.text: [0x8014c088, 0x801501c4]
.rodata: [0x80334908, 0x80334bd0]
.bss: [0x80511a28, 0x805120e8]
.sdata: [0x805ae060, 0x805ae068]
.sdata2: [0x805b28a0, 0x805b28a8]
seqdef.c:
.data: [0x804287a8, 0x804287f0]
seqdrv.c:
.text: [0x8017bf2c, 0x8017c0a0]
.bss: [0x80512360, 0x80512388]
.sdata: [0x805ae0b8, 0x805ae0c8]
.sbss: [0x805ae918, 0x805ae920]
system.c:
.text: [0x8019c500, 0x8019e044]
.rodata: [0x803376d0, 0x803377a8]
.data: [0x8042a160, 0x8042a308]
.bss: [0x80513e48, 0x80516f60]
.sdata: [0x805ae118, 0x805ae120]
.sbss: [0x805ae968, 0x805ae988]
.sdata2: [0x805b3c38, 0x805b3c88]
filemgr.c:
.text: [0x8019e478, 0x8019ffb8]
.rodata: [0x80337848, 0x80337a68]
.data: [0x8042a308, 0x8042a368]
.bss: [0x80516f88, 0x805173a0]
.sdata: [0x805ae130, 0x805ae138]
memory.c:
.text: [0x801a5dcc, 0x801a6e9c]
.rodata: [0x80337b18, 0x80337cc0]
.data: [0x8042a408, 0x8042a450]
.bss: [0x805173e0, 0x80525468]
.sdata: [0x805ae168, 0x805ae170]
.sbss: [0x805ae9a8, 0x805ae9b8]
spmario.c:
.text: [0x801a7ddc, 0x801a9098]
.rodata: [0x803387f0, 0x80338838]
.bss: [0x80525550, 0x805283a0]
.sdata: [0x805ae178, 0x805ae180]
.sbss: [0x805ae9b8, 0x805ae9d0]
.data: [0x8042a898, 0x8042a908] # TODO: GXRenderModeOBJs from 8042a550
.sdata2: [0x805b3d20, 0x805b3d50]
wpadmgr.c:
.text: [0x8023697c, 0x80237a10]
.rodata: [0x80343e98, 0x80343ea0]
.bss: [0x80528f48, 0x80532d10]
.sdata: [0x805ae198, 0x805ae1a0]
.sdata2: [0x805b61f8, 0x805b6230]
relmgr.c:
.text: [0x8023e434, 0x8023e60c]
.rodata: [0x80344468, 0x80344490]
.bss: [0x80534f98, 0x80534fa8]
.sdata: [0x805ae1a0, 0x805ae1b0]
nandmgr.c:
.text: [0x8023e60c, 0x802406a0]
.rodata: [0x803494e8, 0x80349538]
.data: [0x804e5008, 0x804e50a8] # TODO: more strings
.bss: [0x80534fa8, 0x80535168]
.sdata: [0x805ae1b0, 0x805ae1b8]
.sdata2: [0x805b62a8, 0x805b62b0]

21
config/rel.lcf Normal file
View File

@ -0,0 +1,21 @@
SECTIONS {
GROUP:{
.init ALIGN(0x4):{}
.text ALIGN(0x4):{}
.ctors ALIGN(0x4):{}
.dtors ALIGN(0x4):{}
.rodata ALIGN(0x4):{}
.data ALIGN(0x20):{}
.bss ALIGN(0x8):{}
// Removed by elf2rel
forcestrip ALIGN(0x4):{}
relsymdef ALIGN(0x4):{}
}
}
FORCEFILES {
}
__dummy_str = 0;
__dummy_float = 0;
__dummy_double = 0;

15
config/rel_slices.yml Normal file
View File

@ -0,0 +1,15 @@
###########################################################################
# You must re-run configure.py after adding/removing sources in this file #
###########################################################################
# Paths relative to rel/
ctors_dtors.s:
.ctors: [0x80ca9ad8, 0x80ca9adc]
.dtors: [0x80ca9adc, 0x80ca9ae8]
dan.c:
.text: [0x80c81eb0, 0x80c83fd4]
.rodata: [0x80cef8e8, 0x80cf0600]
.data: [0x80e4fef8, 0x80e55858]
.bss: [0x80f65888, 0x80f65890]

2238
config/symbols.yml Normal file

File diff suppressed because it is too large Load Diff

556
configure.py Normal file
View File

@ -0,0 +1,556 @@
"""
Creates a build script for ninja
"""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from io import StringIO
import json
import os
import re
from typing import List, Tuple
from ninja_syntax import Writer
import common as c
####################
# Setup Validation #
####################
# Check CW was added
assert os.path.exists("tools/4199_60831/mwcceppc.exe") and \
os.path.exists("tools/4199_60831/mwldeppc.exe"), \
"Error: Codewarrior not found in tools/4199_60831"
# Check binaries were added
assert os.path.exists(c.DOL) and os.path.exists(c.REL), \
"Error: Base binaries not found"
# Check binaries are correct
dol_hash = c.get_file_sha1(c.DOL)
assert dol_hash == bytes.fromhex("3fd3d9815528d1c04bc433d67d273b1e3301e976"), \
"Error: Base dol hash isn't correct."
rel_hash = c.get_file_sha1(c.REL)
if rel_hash == bytes.fromhex("29c78007559996dee6b615005fa3369d4cc1f5e3"):
assert 0, "Error: Base rel is from PAL revision 1, the decomp currently requires revision 0"
else:
assert rel_hash == bytes.fromhex("9b9b92c370b1aab68cf6ff5a3eb824fdab6a55ff")
# Check submodules added
assert os.path.exists(c.PPCDIS), \
"Error: Git submodules not initialised"
###############
# Ninja Setup #
###############
outbuf = StringIO()
n = Writer(outbuf)
n.variable("ninja_required_version", "1.3")
n.newline()
################
# Project Dirs #
################
n.variable("builddir", c.BUILDDIR)
n.variable("outdir", c.OUTDIR)
n.variable("orig", c.ORIG)
n.variable("tools", c.TOOLS)
n.variable("config", c.CONFIG)
n.newline()
#########
# Tools #
#########
n.variable("python", c.PYTHON)
n.variable("ppcdis", c.PPCDIS)
n.variable("analyser", c.ANALYSER)
n.variable("disassembler", c.DISASSEMBLER)
n.variable("orderstrings", c.ORDERSTRINGS)
n.variable("orderfloats", c.ORDERFLOATS)
n.variable("elf2dol", c.ELF2DOL)
n.variable("elf2rel", c.ELF2REL)
n.variable("codewarrior", c.CODEWARRIOR)
n.variable("cc", c.CC)
n.variable("ld", c.LD)
n.variable("devkitppc", c.DEVKITPPC)
n.variable("as", c.AS)
n.variable("iconv", c.ICONV)
n.newline()
##############
# Tool flags #
##############
n.variable("sda", c.SDA)
n.variable("asflags", c.ASFLAGS)
n.variable("ldflags", c.LDFLAGS)
n.variable("ppcdis_rel_flags", c.PPCDIS_REL_FLAGS)
n.variable("ppcdis_analysis_flags", c.PPCDIS_ANALYSIS_FLAGS)
n.variable("ppcdis_disasm_flags", c.PPCDIS_DISASM_FLAGS)
n.newline()
#########
# Rules #
#########
# Windows can't use && without this
ALLOW_CHAIN = "cmd /c " if os.name == "nt" else ""
n.rule(
"analyse",
command = "$analyser $in $sda $out $analysisflags",
description = "ppcdis analysis $in",
pool="console"
)
n.rule(
"disasm_slice",
command = "$disassembler $in $sda $out -q $disasmflags -s $slice",
description = "ppcdis disassembly $out",
)
n.rule(
"disasm_single",
command = "$disassembler $in $sda $out -f $addr -i -q $disasmflags",
description = "ppcdis function disassembly $addr"
)
n.rule(
"jumptable",
command = "$disassembler $in $sda $out -j $addr -q $disasmflags",
description = "Jumptable $addr"
)
n.rule(
"orderstrings",
command = "$orderstrings $in $addrs $out $flags --enc shift-jis",
description = "Order strings $in $addrs"
)
n.rule(
"orderfloats",
command = "$orderfloats $in $addrs $out $flags",
description = "Order floats $in $addrs"
)
n.rule(
"elf2dol",
command = "$elf2dol $in -o $out",
description = "elf2dol $in"
)
n.rule(
"elf2rel",
command = "$elf2rel $in -o $out $flags",
description = "elf2rel $in"
)
n.rule(
"sha1sum",
command = ALLOW_CHAIN + "sha1sum -c $in && touch $out",
description = "Verify $in",
pool="console"
)
n.rule(
"as",
command = f"$as $asflags -I {c.INCDIR} -I $ppcdis/include -c $in -o $out -I orig",
description = "AS $in"
)
# Due to CW dumbness with .d output location, $outstem must be defined without the .o
n.rule(
"cc",
command = f"$cc $cflags -I- -i {c.INCDIR} -i $ppcdis/include -i $builddir/include -MD -gccdep -c $in -o $out",
description = "CC $in",
deps = "gcc",
depfile = "$outstem.d"
)
n.rule(
"ccs",
command = f"$cc $cflags -I- -i {c.INCDIR} -i $builddir/include -MD -gccdep -c $in -o $out -S",
description = "CC -S $in",
deps = "gcc",
depfile = "$outstem.d"
)
n.rule(
"ld",
command = "$ld $ldflags -map $map -lcf $lcf $in -o $out",
description = "LD $out",
)
n.rule(
"iconv",
command = "$iconv $in $out",
description = "iconv $in",
)
###########
# Sources #
###########
@dataclass
class SourceContext:
srcdir: str
cflags: str
binary: str
labels: str
relocs: str
slices: str
sdata2_threshold: int
binflags: str = ""
class GeneratedInclude(ABC):
def __init__(self, source_name: str, path: str):
self.source_name = source_name
self.path = path
@abstractmethod
def build(self, ctx: SourceContext):
raise NotImplementedError
def find(source_name: str, txt: str) -> List["GeneratedInclude"]:
return [
cl(source_name, match)
for cl in (
AsmInclude,
JumptableInclude,
StringInclude,
FloatInclude,
DoubleInclude
)
for match in re.findall(cl.REGEX, txt)
]
class AsmInclude(GeneratedInclude):
REGEX = r'#include "asm\/([0-9a-f]{8})\.s"'
def __init__(self, source_name: str, match: str):
self.addr = match
super().__init__(source_name, f"$builddir/include/asm/{self.addr}.s")
def build(self, ctx: SourceContext):
n.build(
self.path,
rule="disasm_single",
inputs=[ctx.binary, ctx.labels, ctx.relocs],
implicit=[c.SYMBOLS, c.DISASM_OVERRIDES],
variables={
"disasmflags" : f"$ppcdis_disasm_flags {ctx.binflags} -n {self.source_name}",
"addr" : self.addr
}
)
def __repr__(self):
return f"AsmInclude({self.addr})"
class JumptableInclude(GeneratedInclude):
REGEX = r'#include "jumptable\/([0-9a-f]{8})\.inc"'
def __init__(self, source_name: str, match: str):
self.addr = match
super().__init__(source_name, f"$builddir/include/jumptable/{self.addr}.inc")
def build(self, ctx: SourceContext):
n.build(
self.path,
rule="jumptable",
inputs=[ctx.binary, ctx.labels, ctx.relocs],
implicit=[c.SYMBOLS, c.DISASM_OVERRIDES],
variables={
"disasmflags" : f"$ppcdis_disasm_flags {ctx.binflags} -n {self.source_name}",
"addr" : self.addr
}
)
def __repr__(self):
return f"JumptableInclude({self.addr})"
class StringInclude(GeneratedInclude):
REGEX = r'#include "orderstrings\/([0-9a-f]{8})_([0-9a-f]{8})\.inc"'
def __init__(self, source_name: str, match: Tuple[str]):
self.start, self.end = match
super().__init__(source_name, f"$builddir/include/orderstrings/{self.start}_{self.end}.inc")
def build(self, ctx: SourceContext):
n.build(
self.path,
rule="orderstrings",
inputs=ctx.binary,
variables={
"addrs" : f"{self.start} {self.end}",
"flags" : ctx.binflags
}
)
def __repr__(self):
return f"StringInclude({self.start}, {self.end})"
class FloatInclude(GeneratedInclude):
REGEX = r'#include "(orderfloats(m?))\/([0-9a-f]{8})_([0-9a-f]{8})\.inc"'
def __init__(self, source_name: str, match: Tuple[str]):
folder, manual, self.start, self.end = match
self.manual = manual != ''
super().__init__(source_name, f"$builddir/include/{folder}/{self.start}_{self.end}.inc")
def build(self, ctx: SourceContext):
sda = "--sda " if ctx.sdata2_threshold >= 4 else ""
asm = "" if self.manual else "--asm"
n.build(
self.path,
rule="orderfloats",
inputs=ctx.binary,
variables={
"addrs" : f"{self.start} {self.end}",
"flags" : f"{ctx.binflags} {sda} {asm}"
}
)
def __repr__(self):
return f"FloatInclude({self.start}, {self.end})"
class DoubleInclude(GeneratedInclude):
REGEX = r'#include "orderdoubles\/([0-9a-f]{8})_([0-9a-f]{8})\.inc"'
def __init__(self, source_name: str, match: Tuple[str]):
self.start, self.end = match
super().__init__(source_name, f"$builddir/include/orderdoubles/{self.start}_{self.end}.inc")
def build(self, ctx: SourceContext):
n.build(
self.path,
rule="orderfloats",
inputs=ctx.binary,
variables={
"addrs" : f"{self.start} {self.end}",
"flags" : f"{ctx.binflags} --double"
}
)
def __repr__(self):
return f"DoubleInclude({self.start}, {self.end})"
class Source(ABC):
def __init__(self, decompiled: bool, src_path: str, o_path: str,
gen_includes: List[GeneratedInclude] = []):
self.decompiled = decompiled
self.src_path = src_path
self.o_path = o_path
self.o_stem = o_path[:-2]
self.gen_includes = gen_includes
def build(self):
raise NotImplementedError
def make(ctx: SourceContext, source: c.SourceDesc):
if isinstance(source, str):
ext = source.split('.')[-1].lower()
if ext in ("c", "cpp", "cxx", "cc"):
return CSource(ctx, source)
elif ext == "s":
return AsmSource(ctx, source)
else:
assert 0, f"Unknown source type .{ext}"
else:
return GenAsmSource(ctx, *source)
class GenAsmSource(Source):
def __init__(self, ctx: SourceContext, section: str, start: int, end: int):
self.start = start
self.end = end
self.ctx = ctx
src_path = f"$builddir/asm/{section}_{start:x}_{end:x}.s"
super().__init__(False, src_path, src_path + ".o")
def build(self):
n.build(
self.src_path,
rule = "disasm_slice",
inputs = [self.ctx.binary, self.ctx.labels, self.ctx.relocs],
implicit = [c.SYMBOLS, c.DISASM_OVERRIDES],
variables = {
"slice" : f"{self.start:x} {self.end:x}",
"disasmflags" : f"$ppcdis_disasm_flags {self.ctx.binflags}"
}
)
n.build(
self.o_path,
rule="as",
inputs=self.src_path
)
class AsmSource(Source):
def __init__(self, ctx: SourceContext, path: str):
super().__init__(True, path, f"$builddir/{path}.o")
def build(self):
n.build(
self.o_path,
rule = "as",
inputs = self.src_path
)
class CSource(Source):
def __init__(self, ctx: SourceContext, path: str):
self.cflags = ctx.cflags
self.iconv_path = f"$builddir/iconv/{path}"
# Find generated includes
with open(path, encoding="utf-8") as f:
gen_includes = GeneratedInclude.find(path, f.read())
self.s_path = f"$builddir/{path}.s"
super().__init__(True, path, f"$builddir/{path}.o", gen_includes)
def build(self):
n.build(
self.iconv_path,
rule="iconv",
inputs=self.src_path
)
n.build(
self.o_path,
rule = "cc",
inputs = self.iconv_path,
implicit = [inc.path for inc in self.gen_includes],
variables = {
"cflags" : self.cflags,
"outstem" : self.o_stem
}
)
# Optional manual debug target
n.build(
self.s_path,
rule = "ccs",
inputs = self.iconv_path,
implicit = [inc.path for inc in self.gen_includes],
variables = {
"cflags" : self.cflags,
"outstem" : self.o_stem
}
)
def load_sources(ctx: SourceContext):
raw = c.get_cmd_stdout(
f"{c.SLICES} {ctx.binary} {ctx.slices} {ctx.binflags} -o -p {ctx.srcdir}/"
)
return [Source.make(ctx, s) for s in json.loads(raw)]
dol_ctx = SourceContext(c.DOL_SRCDIR, c.DOL_CFLAGS, c.DOL, c.DOL_LABELS,
c.DOL_RELOCS, c.DOL_SLICES, 4)
rel_ctx = SourceContext(c.REL_SRCDIR, c.REL_CFLAGS, c.REL, c.REL_LABELS,
c.REL_RELOCS, c.REL_SLICES, 0, c.PPCDIS_REL_FLAGS)
dol_sources = load_sources(dol_ctx)
dol_c_sources = [source for source in dol_sources if isinstance(source, CSource)]
dol_gen_includes = [inc for source in dol_c_sources for inc in source.gen_includes]
rel_sources = load_sources(rel_ctx)
rel_c_sources = [source for source in rel_sources if isinstance(source, CSource)]
rel_gen_includes = [inc for source in rel_c_sources for inc in source.gen_includes]
##########
# Builds #
##########
n.build(
[c.REL_LABELS, c.REL_RELOCS],
rule = "analyse",
inputs = c.REL,
implicit = c.ANALYSIS_OVERRIDES,
variables = {
"analysisflags" : "$ppcdis_rel_flags $ppcdis_analysis_flags"
}
)
n.build(
[c.DOL_LABELS, c.DOL_RELOCS],
rule = "analyse",
inputs = c.DOL,
implicit = [c.ANALYSIS_OVERRIDES, c.REL_LABELS],
variables = {
"analysisflags" : f"$ppcdis_analysis_flags -l {c.REL_LABELS}"
}
)
for inc in dol_gen_includes:
inc.build(dol_ctx)
for inc in rel_gen_includes:
inc.build(rel_ctx)
for source in dol_sources + rel_sources:
source.build()
n.build(
c.DOL_ELF,
rule="ld",
inputs=[s.o_path for s in dol_sources],
implicit=c.DOL_LCF,
implicit_outputs=c.DOL_MAP,
variables={
"map" : c.DOL_MAP,
"lcf" : c.DOL_LCF
}
)
n.build(
c.DOL_OUT,
rule="elf2dol",
inputs=c.DOL_ELF,
)
n.build(
"$builddir/main.dol.ok",
rule = "sha1sum",
inputs = c.DOL_SHA,
implicit = c.DOL_OUT,
)
n.default("$builddir/main.dol.ok")
n.build(
c.REL_PLF,
rule="ld",
inputs=[s.o_path for s in rel_sources],
implicit=c.REL_LCF,
implicit_outputs=c.REL_MAP,
variables={
"map" : c.REL_MAP,
"lcf" : c.REL_LCF,
"ldflags" : c.LDFLAGS + " -r1"
}
)
n.build(
c.REL_OUT,
rule="elf2rel",
inputs=[c.REL_PLF, c.DOL_ELF],
variables={
"flags" : f"-n 18 -r {c.REL} -a {c.REL_ADDR} -b {c.REL_BSS}"
}
)
n.build(
"$builddir/relF.rel.ok",
rule = "sha1sum",
inputs = c.REL_SHA,
implicit = c.REL_OUT,
)
n.default("$builddir/relF.rel.ok")
##########
# Ouptut #
##########
with open("build.ninja", 'w') as f:
f.write(outbuf.getvalue())
n.close()

56
decompme.py Normal file
View File

@ -0,0 +1,56 @@
"""
Creates a decomp.me scratch for a function
"""
from argparse import ArgumentParser
import requests
import common as c
from getfunction import get_function
# Get arguments
parser = ArgumentParser()
hex_int = lambda s: int(s, 16)
parser.add_argument("addr", type=hex_int)
parser.add_argument("--host", default="https://decomp.me")
args = parser.parse_args()
# Find containing binary
binary, source = c.get_containing_slice(args.addr)
base_flags = "-lang c99 -enc SJIS -fp hard -O4 -use_lmw_stmw on -str pool -rostr -ipa file -cpp_exceptions off -sym on -W all"
# Get flags for binary (keep in sync with decomp.me templates)
if binary == c.Binary.DOL:
preset = "Super Paper Mario (DOL)"
flags = base_flags + " -inline all -sdata 4 -sdata2 4"
else:
preset = "Super Paper Mario (REL)"
flags = base_flags + " -sdata 0 -sdata2 0 -pool off -ordered-fp-compares"
# Disassemble function
srcflag = f"-n {source}" if isinstance(source, str) else ""
asm = get_function(binary, srcflag, args.addr)
# Get diff_label
lines = asm.splitlines()
assert lines[0].startswith(".global "), "Address doesn't appear to be a function"
diff_label = lines[0][len(".global "):]
# Get context
ctx = c.get_cmd_stdout(f"{c.PYTHON} makectx_m2c.py")
# Send request
req = {
"target_asm" : asm,
"context" : ctx,
"platform" : "gc_wii",
"compiler" : "mwcc_41_60831",
"compiler_flags" : flags,
"preset" : preset,
"diff_label" : diff_label
}
r = requests.post(args.host + "/api/scratch", json=req)
assert r.status_code == 201, f"Bad status code {r.status_code}"
print(args.host + r.json()["html_url"])

3103
diff.py Normal file

File diff suppressed because it is too large Load Diff

25
diff_settings.py Normal file
View File

@ -0,0 +1,25 @@
from argparse import ArgumentParser, Namespace
import common as c
def apply(config, args: Namespace):
if args.rel:
config["mapfile"] = c.REL_MAP
config["myimg"] = c.REL_PLF
config["baseimg"] = c.REL_EXPECTED
config["source_directories"] = [c.REL_SRCDIR, c.INCDIR]
else:
config["mapfile"] = c.DOL_MAP
config["myimg"] = c.DOL_ELF
config["baseimg"] = c.DOL_EXPECTED
config["source_directories"] = [c.DOL_SRCDIR, c.INCDIR]
config["make_command"] = ["ninja"]
config["makeflags"] = []
config["arch"] = "ppc"
config["map_format"] = "mw"
config["mw_build_dir"] = c.BUILDDIR
config["objdump_executable"] = c.OBJDUMP
config["objdump_flags"] = ["-mpowerpc", "-Mbroadway"]
config["show_line_numbers_default"] = True
def add_custom_arguments(parser: ArgumentParser):
parser.add_argument("-r", "--rel", action="store_true", help="(SPM) Diff a function in relF.rel")

18
expected.py Normal file
View File

@ -0,0 +1,18 @@
"""
Creates the expected folder for diff.py
"""
from shutil import copytree, rmtree
import common as c
# Remove it if already existing
try:
rmtree(c.EXPECTED)
except FileNotFoundError:
pass
# Copy in builddir and outdir
copytree(c.BUILDDIR, f"{c.EXPECTED}/build")
copytree(c.OUTDIR, f"{c.EXPECTED}/out")

50
getfunction.py Normal file
View File

@ -0,0 +1,50 @@
"""
Disassembles a single function
"""
from argparse import ArgumentParser
from os import system, unlink
from tempfile import NamedTemporaryFile
import common as c
def get_function(binary: c.Binary, srcflag: str, addr: int) -> str:
# Get flags for binary
if binary == c.Binary.DOL:
binary = c.DOL
binflags = ""
anlflags = f"{c.DOL_LABELS} {c.DOL_RELOCS}"
else:
binary = c.REL
binflags = c.PPCDIS_REL_FLAGS
anlflags = f"{c.REL_LABELS} {c.REL_RELOCS}"
# Disassemble function
with NamedTemporaryFile(suffix=".c", delete=False) as tmp:
try:
tmp.close()
ret = system(
f"{c.DISASSEMBLER} {binary} {anlflags} {c.SDA} {tmp.name} -f {addr:x} "
f"-m {c.SYMBOLS} {binflags} {srcflag} -q"
)
assert ret == 0, f"Disassembly error code {ret}"
with open(tmp.name) as f:
asm = f.read()
finally:
unlink(tmp.name)
return asm
if __name__=="__main__":
parser = ArgumentParser()
hex_int = lambda s: int(s, 16)
parser.add_argument("addr", type=hex_int)
args = parser.parse_args()
# Find containing binary
binary, source = c.get_containing_slice(args.addr)
# Get source file name flag
srcflag = f"-n {source}" if isinstance(source, str) else ""
print(get_function(binary, srcflag, args.addr))

View File

@ -1,9 +0,0 @@
#ifndef DEMOINIT_H
#define DEMOINIT_H
#include <common.h>
void DEMOBeforeRender(); // 801a94c8
void DEMODoneRender(); // 801a9590
#endif

View File

@ -1,8 +0,0 @@
#ifndef ANIMDRV_H
#define ANIMDRV_H
typedef void (AnimPoseDisplayCb)(void * param, int animGroupIdx, int param_3);
void animPoseSetDispCallback(int animPoseId, AnimPoseDisplayCb * cb, void * param); // 8004d52c
#endif

View File

@ -1,20 +1,20 @@
/*
Common definitions
*/
#ifndef COMMON_H
#define COMMON_H
#pragma once
#include <stdbool.h>
#include <ppcdis.h>
#define NULL ((void*)0)
#ifdef __INTELLISENSE__
#define asm
#endif
// Basic types
typedef unsigned long long u64;
typedef unsigned int u32;
typedef unsigned long u32;
typedef unsigned short u16;
typedef unsigned char u8;
typedef long long s64;
typedef int s32;
typedef long s32;
typedef short s16;
typedef char s8;
@ -23,22 +23,19 @@ typedef double f64;
typedef u32 size_t;
#define NULL 0
typedef s32 BOOL;
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
typedef u16 wchar_t;
typedef struct
{
float x;
float y;
} Vec2;
typedef struct
{
float x;
float y;
float z;
} Vec3;
// Used in un-implemented functions to make string/float pools match when asm is affected
void __dummy_string(const char *); void __dummy_float(float);
#endif
#define SDA2_BASE 0x805b7260

View File

@ -1,11 +0,0 @@
#ifndef DISPDRV_H
#define DISPDRV_H
#include <common.h>
typedef void (DispCallback)(s8 cameraId, void * param);
void dispEntry(s8 cameraId, u8 renderMode, float z, DispCallback * cb, void * cbParam); // 8005af04
#endif

View File

@ -1,8 +0,0 @@
#ifndef DVD_H
#define DVD_H
#include <common.h>
s32 DVDConvertPathToEntrynum(const char * path); // 8027b910
#endif

View File

@ -1,13 +0,0 @@
#ifndef DVDDMGR_H
#define DVDMGR_H
#include <common.h>
typedef struct
{
u8 unknown_0x0[0x7c - 0x0];
void * unknown_0x7c;
u8 unknown_0x80[0x9c - 0x80];
} DVDEntry;
#endif

298
include/evt_cmd.h Normal file
View File

@ -0,0 +1,298 @@
#pragma once
#include <spm/evtmgr.h>
#include <spm/evtmgr_cmd.h>
#define EVT_DECLARE_USER_FUNC(symbol, argCount) \
s32 symbol(EvtEntry * script, bool isFirstCall);
#define EVT_UNKNOWN_USER_FUNC(symbol) \
s32 symbol(EvtEntry * script, bool isFirstCall);
#define EVT_DECLARE(symbol) \
extern EvtScriptCode symbol[];
#define EVT_CMD_(opcode) \
(0 << 16) | opcode
#define EVT_CMD(opcode, ...) \
((sizeof((EvtScriptCode[]){__VA_ARGS__})/sizeof(EvtScriptCode)) << 16) | (opcode), \
__VA_ARGS__
#define PTR(addr) \
((s32)(addr))
#define EVT_BEGIN(symbol) \
EvtScriptCode symbol[] = {
#define EVT_END() \
EVT_CMD_(EVT_OPC_END_SCRIPT) \
};
/*
Instructions
*/
#define RETURN() \
EVT_CMD_(EVT_OPC_END_EVT),
#define LBL(id) \
EVT_CMD(EVT_OPC_LBL, id),
#define GOTO(id) \
EVT_CMD(EVT_OPC_GOTO, id),
#define DO(n) \
EVT_CMD(EVT_OPC_DO, n),
#define WHILE() \
EVT_CMD_(EVT_OPC_WHILE),
#define DO_BREAK() \
EVT_CMD_(EVT_OPC_DO_BREAK),
#define DO_CONTINUE() \
EVT_CMD_(EVT_OPC_DO_CONTINUE),
#define WAIT_FRM(frames) \
EVT_CMD(EVT_OPC_WAIT_FRM, frames),
#define WAIT_MSEC(msecs) \
EVT_CMD(EVT_OPC_WAIT_MSEC, msecs),
#define HALT(condition) \
EVT_CMD(EVT_OPC_HALT, condition),
#define IF_STR_EQUAL(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_EQUAL, s1, s2),
#define IF_STR_NOT_EQUAL(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_NOT_EQUAL, s1, s2),
#define IF_STR_SMALL(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_SMALL, s1, s2),
#define IF_STR_LARGE(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_LARGE, s1, s2),
#define IF_STR_SMALL_EQUAL(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_SMALL_EQUAL, s1, s2),
#define IF_STR_LARGE_EQUAL(s1, s2) \
EVT_CMD(EVT_OPC_IF_STR_LARGE_EQUAL, s1, s2),
#define IFF_EQUAL(f1, f2) \
EVT_CMD(EVT_OPC_IFF_EQUAL, f1, f2),
#define IFF_NOT_EQUAL(f1, f2) \
EVT_CMD(EVT_OPC_IFF_NOT_EQUAL, f1, f2),
#define IFF_SMALL(f1, f2) \
EVT_CMD(EVT_OPC_IFF_SMALL, f1, f2),
#define IFF_LARGE(f1, f2) \
EVT_CMD(EVT_OPC_IFF_LARGE, f1, f2),
#define IFF_SMALL_EQUAL(f1, f2) \
EVT_CMD(EVT_OPC_IFF_SMALL_EQUAL, f1, f2),
#define IFF_LARGE_EQUAL(f1, f2) \
EVT_CMD(EVT_OPC_IFF_LARGE_EQUAL, f1, f2),
#define IF_EQUAL(v1, v2) \
EVT_CMD(EVT_OPC_IF_EQUAL, v1, v2),
#define IF_NOT_EQUAL(v1, v2) \
EVT_CMD(EVT_OPC_IF_NOT_EQUAL, v1, v2),
#define IF_SMALL(v1, v2) \
EVT_CMD(EVT_OPC_IF_SMALL, v1, v2),
#define IF_LARGE(v1, v2) \
EVT_CMD(EVT_OPC_IF_LARGE, v1, v2),
#define IF_SMALL_EQUAL(v1, v2) \
EVT_CMD(EVT_OPC_IF_SMALL_EQUAL, v1, v2),
#define IF_LARGE_EQUAL(v1, v2) \
EVT_CMD(EVT_OPC_IF_LARGE_EQUAL, v1, v2),
#define IF_FLAG(value, mask) \
EVT_CMD(EVT_OPC_IF_FLAG, value, mask),
#define IF_NOT_FLAG(value, mask) \
EVT_CMD(EVT_OPC_IF_NOT_FLAG, value, mask),
#define ELSE() \
EVT_CMD_(EVT_OPC_ELSE),
#define END_IF() \
EVT_CMD_(EVT_OPC_END_IF),
#define SWITCH(value) \
EVT_CMD(EVT_OPC_SWITCH, value),
#define SWITCHI(value) \
EVT_CMD(EVT_OPC_SWITCHI, value),
#define CASE_EQUAL(value) \
EVT_CMD(EVT_OPC_CASE_EQUAL, value),
#define CASE_NOT_EQUAL(value) \
EVT_CMD(EVT_OPC_CASE_NOT_EQUAL, value),
#define CASE_SMALL(value) \
EVT_CMD(EVT_OPC_CASE_SMALL, value),
#define CASE_LARGE(value) \
EVT_CMD(EVT_OPC_CASE_LARGE, value),
#define CASE_SMALL_EQUAL(value) \
EVT_CMD(EVT_OPC_CASE_SMALL_EQUAL, value),
#define CASE_LARGE_EQUAL(value) \
EVT_CMD(EVT_OPC_CASE_LARGE_EQUAL, value),
#define CASE_ETC() \
EVT_CMD_(EVT_OPC_CASE_ETC),
#define CASE_OR(value) \
EVT_CMD(EVT_OPC_CASE_OR, value),
#define CASE_AND(value) \
EVT_CMD(EVT_OPC_CASE_AND, value),
#define CASE_FLAG(value) \
EVT_CMD(EVT_OPC_CASE_FLAG, value),
#define CASE_END() \
EVT_CMD_(EVT_OPC_CASE_END),
#define EVT_CASE_BETWEEN(min, max) \
EVT_CMD(EVT_OPC_CASE_BETWEEN, min, max),
#define SWITCH_BREAK() \
EVT_CMD_(EVT_OPC_SWITCH_BREAK),
#define END_SWITCH() \
EVT_CMD_(EVT_OPC_END_SWITCH),
#define SET(var, value) \
EVT_CMD(EVT_OPC_SET, var, value),
#define SETI(var, value) \
EVT_CMD(EVT_OPC_SETI, var, value),
#define SETF(var, value) \
EVT_CMD(EVT_OPC_SETF, var, value),
#define ADD(var, value) \
EVT_CMD(EVT_OPC_ADD, var, value),
#define SUB(var, value) \
EVT_CMD(EVT_OPC_SUB, var, value),
#define MUL(var, value) \
EVT_CMD(EVT_OPC_MUL, var, value),
#define DIV(var, value) \
EVT_CMD(EVT_OPC_DIV, var, value),
#define MOD(var, value) \
EVT_CMD(EVT_OPC_MOD, var, value),
#define ADDF(var, value) \
EVT_CMD(EVT_OPC_ADDF, var, value),
#define SUBF(var, value) \
EVT_CMD(EVT_OPC_SUBF, var, value),
#define MULF(var, value) \
EVT_CMD(EVT_OPC_MULF, var, value),
#define DIVF(var, value) \
EVT_CMD(EVT_OPC_DIVF, var, value),
#define SET_READ(addr) \
EVT_CMD(EVT_OPC_SET_READ, addr),
#define READ(dest) \
EVT_CMD(EVT_OPC_READ, dest),
#define READ2(dest1, dest2) \
EVT_CMD(EVT_OPC_READ2, dest1, dest2),
#define READ3(dest1, dest2, dest3) \
EVT_CMD(EVT_OPC_READ3, dest1, dest2, dest3),
#define READ4(dest1, dest2, dest3, dest4) \
EVT_CMD(EVT_OPC_READ4, dest1, dest2, dest3, dest4),
#define READ_N(dest, idx) \
EVT_CMD(EVT_OPC_READ_N, dest, idx),
#define SET_READF(addr) \
EVT_CMD(EVT_OPC_SET_READF, addr),
#define READF(dest) \
EVT_CMD(EVT_OPC_READF, dest),
#define READF2(dest1, dest2) \
EVT_CMD(EVT_OPC_READF2, dest1, dest2),
#define READF3(dest1, dest2, dest3) \
EVT_CMD(EVT_OPC_READF3, dest1, dest2, dest3),
#define READF4(dest1, dest2, dest3, dest4) \
EVT_CMD(EVT_OPC_READF4, dest1, dest2, dest3, dest4),
#define READF_N(dest, idx) \
EVT_CMD(EVT_OPC_READF_N, dest, idx),
#define CLAMP_INT(var, min, max) \
EVT_CMD(EVT_OPC_CLAMP_INT, var, min, max),
#define SET_USER_WRK(addr) \
EVT_CMD(EVT_OPC_SET_USER_WRK, addr),
#define SET_USER_FLG(addr) \
EVT_CMD(EVT_OPC_SET_USER_FLG, addr),
#define ALLOC_USER_WRK(count) \
EVT_CMD(EVT_OPC_ALLOC_USER_WRK, count),
#define AND(dest, mask) \
EVT_CMD(EVT_OPC_AND, dest, mask),
#define ANDI(dest, mask) \
EVT_CMD(EVT_OPC_ANDI, dest, mask),
#define OR(dest, mask) \
EVT_CMD(EVT_OPC_OR, dest, mask),
#define ORI(dest, mask) \
EVT_CMD(EVT_OPC_ORI, dest, mask),
#define SET_FRAME_FROM_MSEC(dest, msecs) \
EVT_CMD(EVT_OPC_SET_FRAME_FROM_MSEC, dest, msecs),
#define SET_MSEC_FROM_FRAMES(dest, frames) \
EVT_CMD(EVT_OPC_SET_MSEC_FROM_FRAME, dest, frames),
#define SET_RAM(value, addr) \
EVT_CMD(EVT_OPC_SET_RAM, value, addr),
#define SET_RAMF(value, addr) \
EVT_CMD(EVT_OPC_SET_RAMF, value, addr),
#define GET_RAM(dest, addr) \
EVT_CMD(EVT_OPC_GET_RAM, dest, addr),
#define GET_RAMF(dese, addr) \
EVT_CMD(EVT_OPC_GET_RAMF, dest, addr),
#define SETR(dest, value) \
EVT_CMD(EVT_OPC_SETR, dest, value),
#define SETRF(dest, value) \
EVT_CMD(EVT_OPC_SETRF, dest, value),
#define GETR(value, dest) \
EVT_CMD(EVT_OPC_GETR, value, dest),
#define GETRF(value, dest) \
EVT_CMD(EVT_OPC_GETRF, value, dest),
#define USER_FUNC(...) \
EVT_CMD(EVT_OPC_USER_FUNC, (s32) __VA_ARGS__),
#define RUN_EVT(evt) \
EVT_CMD(EVT_OPC_RUN_EVT, evt),
#define RUN_EVT_ID(evt, dest) \
EVT_CMD(EVT_OPC_RUN_EVT_ID, evt, dest),
#define RUN_CHILD_EVT(evt) \
EVT_CMD(EVT_OPC_RUN_CHILD_EVT, evt),
#define DELETE_EVT(id) \
EVT_CMD(EVT_OPC_DELETE_EVT, id),
#define RESTART_EVT(id) \
EVT_CMD(EVT_OPC_RESTART_EVT, id),
#define SET_PRI(pri) \
EVT_CMD(EVT_OPC_SET_PRI, pri),
#define SET_SPD(spd) \
EVT_CMD(EVT_OPC_SET_SPD, spd),
#define SET_TYPE(type) \
EVT_CMD(EVT_OPC_SET_TYPE, type),
#define STOP_ALL(type) \
EVT_CMD(EVT_OPC_STOP_ALL, type),
#define START_ALL(type) \
EVT_CMD(EVT_OPC_START_ALL, type),
#define STOP_OTHER(type) \
EVT_CMD(EVT_OPC_STOP_OTHER, type),
#define START_OTHER(type) \
EVT_CMD(EVT_OPC_START_OTHER, type),
#define STOP_ID(id) \
EVT_CMD(EVT_OPC_STOP_ID, id),
#define START_ID(id) \
EVT_CMD(EVT_OPC_START_ID, id),
#define CHK_EVT(id, dest) \
EVT_CMD(EVT_OPC_CHK_EVT, id, dest),
#define INLINE_EVT() \
EVT_CMD_(EVT_OPC_INLINE_EVT),
#define INLINE_EVT_ID(dest) \
EVT_CMD(EVT_OPC_INLINE_EVT_ID, dest),
#define END_INLINE() \
EVT_CMD_(EVT_OPC_END_INLINE),
#define BROTHER_EVT() \
EVT_CMD_(EVT_OPC_BROTHER_EVT),
#define BROTHER_EVT_ID(dest) \
EVT_CMD(EVT_OPC_BROTHER_EVT_ID, dest),
#define END_BROTHER() \
EVT_CMD_(EVT_OPC_END_BROTHER),
#define DEBUG_PUT_MSG(msg) \
EVT_CMD(EVT_OPC_DEBUG_PUT_MSG, msg),
#define DEBUG_MSG_CLEAR() \
EVT_CMD(EVT_OPC_DEBUG_MSG_CLEAR),
#define DEBUG_PUT_REG(reg) \
EVT_CMD(EVT_OPC_DEBUG_PUT_REG, reg),
#define DEBUG_NAME(name) \
EVT_CMD(EVT_OPC_DEBUG_NAME, name),
#define DEBUG_REM() \
EVT_CMD_(EVT_OPC_DEBUG_REM),
#define DEBUG_BP() \
EVT_CMD_(EVT_OPC_DEBUG_BP),

View File

@ -1,29 +0,0 @@
#ifndef EVT_DOOR_H
#define EVT_DOOR_H
typedef struct
{
u32 flags;
const char * name_l;
const char * name_r;
const char * hitName2d;
const char * hitName3d;
const char * destMapName;
const char * unknown_0x18;
int unknown_0x1c;
} MapDoorDesc;
typedef struct
{
int scriptNumber;
u16 flags;
u16 _pad_6;
const char * name;
const char * mapName;
const char * hitName2d;
const char * hitName3d;
const char * destMapName;
const char * unknown_0x1c;
} DokanDesc;
#endif

View File

@ -1,8 +0,0 @@
#ifndef EVT_MSG_H
#define EVT_MSG_H
#include <common.h>
void evt_msg_init(); // 800fb27c
#endif

View File

@ -1,203 +0,0 @@
/*
Functions to manage execution of the game's evt bytecode scripts
*/
#ifndef EVTMGR_H
#define EVTMGR_H
#include <common.h>
#define EVT_max 0x78
#define EVT_ENTRY_MAX 0x80
#define MAX_EVT_JMPTBL 16
struct _EvtEntry;
typedef s32 (user_func)(struct _EvtEntry * entry, bool firstRun);
typedef s32 EvtScriptCode;
#define EVT_FLAG_IN_USE (1 << 0)
#define EVT_FLAG_PAUSED (1 << 1)
typedef struct _EvtEntry
{
s64 lifetime;
u8 flags; // bit flags, see defines above
u8 curDataLength; // number of pieces of data (4 bytes each) belonging to the current instruction
u8 curOpcode; // see evtmgr_cmd.h for opcodes
u8 priority;
u8 type;
s8 blocked;
s8 dowhileDepth; // number of do-while loops the current instruction is nested into
s8 switchDepth; // number of switches the current instruction is nested into
EvtScriptCode * pCurInstruction;
EvtScriptCode * pCurData;
s8 labelIds[MAX_EVT_JMPTBL]; // each correspond to an address in the jump table
void * jumptable[MAX_EVT_JMPTBL]; // addresses for each label
struct _EvtEntry * parent;
struct _EvtEntry * childEntry;
struct _EvtEntry * brotherEntry;
union {
s32 tempS[3];
u32 tempU[3];
};
u8 unknown_0x80[0x94 - 0x80];
user_func * userFunc; // Function set & called by the user_func opcode
s32 lw[16];
u32 lf[3];
void * dowhileStartPtrs[8]; // pointer to do opcodes
s32 dowhileCounters[8];
s8 switchStates[8];
s32 switchValues[8];
union
{
s32 * readAddr;
float * readfAddr;
};
s32 * uw;
u32 * uf;
s32 id;
float speed;
float unknown_0x160;
s32 casedrvId;
void * ownerNPC;
void * ownerMOBJ;
s32 unknown_0x170;
s32 msgWindowId;
s32 unknown_0x178;
f32 unknown_0x17c;
f32 unknown_0x180;
f32 unknown_0x184;
s32 msgPri;
u8 unknown_0x18c[0x198 - 0x18c];
EvtScriptCode * scriptStart;
char * name; // debug thing, unused?
void * pPrevInstruction;
u8 unknown_0x1a4[0x1a8 - 0x1a4];
} EvtEntry;
typedef struct
{
s32 entryCount;
s32 gw[32];
u32 gf[3];
EvtEntry * entries;
u8 unknown_0x94[0x98 - 0x94];
s64 time;
} EvtWork;
extern s32 evtMax; // 805ae8d8
/*
Returns pointer to the EvtWork struct
*/
EvtWork * evtGetWork(); // 800d87e4
/*
Allocates memories for entries and zeros global evt variables
*/
void evtmgrInit(); // 800d8a88
/*
Zeros all entries
*/
void evtmgrReInit(); // 800d8b2c
/*
Starts execution of a script
*/
EvtEntry * evtEntry(EvtScriptCode * script, u32 priority, u8 flags); // 800d8b88
EvtEntry * evtEntryType(EvtScriptCode * script, u32 priority, u8 flags, u8 type); // 800d8df4
EvtEntry * evtChildEntry(EvtEntry * entry, EvtScriptCode * script, u8 flags); // 800d9060
EvtEntry * evtBrotherEntry(EvtEntry * entry, EvtScriptCode * script, u8 flags); // 800d9370
/*
Restarts a entry
*/
EvtEntry * evtRestart(EvtEntry * entry); // 800d9634
/*
Sets up entry executions, called every frame
*/
void evtmgrMain(); // 800d9764
/*
Terminates a entry and all its children & brothers
*/
void evtDelete(EvtEntry * entry); // 800d9944
/*
Terminates a entry by id and all its children & brothers
*/
void evtDeleteID(s32 id); // 800d9b00
/*
Checks if a entry is running by id
*/
bool evtCheckID(s32 id); // 800d9b88
/*
Sets the execution priority of a entry
*/
void evtSetPri(EvtEntry * entry, u32 pri); // 800d9bd4
/*
Sets the execution speed of a entry
*/
void evtSetSpeed(EvtEntry * entry, f32 multiplier); // 800d9bdc
/*
Sets the type mask of a entry
*/
void evtSetType(EvtEntry * entry, u32 type); // 800d9bec
/*
Pauses execution a entry and all its children & brothers with types included in the mask
*/
void evtStop(EvtEntry * entry, u32 mask); // 800d9bf4
/*
Resumes execution of a entry and all its children & brothers with types included in the mask
*/
void evtStart(EvtEntry * entry, u32 mask); // 800d9c98
/*
Pauses execution of a entry by id and all its children & brothers
*/
void evtStopID(s32 id); // 800d9d3c
/*
Resumes execution of a entry by id and all its children & brothers
*/
void evtStartID(s32 id); // 800d9dc8
/*
Pauses execution of all entries with types included in the mask
*/
void evtStopAll(u32 mask); // 800d9e54
/*
Resumes execution of all entries with types included in the mask
*/
void evtStartAll(u32 mask); // 800d9ed4
/*
Pauses execution of all entries with types included in the mask other than one specific entry
*/
void evtStopOther(EvtEntry * entry, u32 mask); // 800d9f54
/*
Resumes execution of all entries with types included in the mask other than one specific entry
*/
void evtStartOther(EvtEntry * entry, u32 mask); // 800d9fc8
/*
Gets an entry by its index into the array of entries
*/
EvtEntry * evtGetPtr(s32 index); // 800da03c
/*
Gets an entry by its id
*/
EvtEntry * evtGetPtrID(s32 id); // 800da064
#endif

View File

@ -1,386 +0,0 @@
/*
Functions to execute interpreted evt script code and handle evt variables
*/
#ifndef EVTMGR_CMD_H
#define EVTMGR_CMD_H
#include <common.h>
#include <evtmgr.h>
// Data types
#define EVTDAT_ADDR_MAX -290000000
#define EVTDAT_FLOAT_MAX -220000000
#define EVTDAT_UF_MAX -200000000
#define EVTDAT_UW_MAX -180000000
#define EVTDAT_GSW_MAX -160000000
#define EVTDAT_LSW_MAX -140000000
#define EVTDAT_GSWF_MAX -120000000
#define EVTDAT_LSWF_MAX -100000000
#define EVTDAT_GF_MAX -80000000
#define EVTDAT_LF_MAX -60000000
#define EVTDAT_GW_MAX -40000000
#define EVTDAT_LW_MAX -20000000
#define EVTDAT_FLOAT_BASE 240000000
#define EVTDAT_UF_BASE 210000000
#define EVTDAT_UW_BASE 190000000
#define EVTDAT_GSW_BASE 170000000
#define EVTDAT_LSW_BASE 150000000
#define EVTDAT_GSWF_BASE 130000000
#define EVTDAT_LSWF_BASE 110000000
#define EVTDAT_GF_BASE 90000000
#define EVTDAT_LF_BASE 70000000
#define EVTDAT_GW_BASE 50000000
#define EVTDAT_LW_BASE 30000000
#define UF(id) ((id) - EVTDAT_UF_BASE)
#define UW(id) ((id) - EVTDAT_UW_BASE)
#define GSW(id) ((id) - EVTDAT_GSW_BASE)
#define LSW(id) ((id) - EVTDAT_LSW_BASE)
#define GSWF(id) ((id) - EVTDAT_GSWF_BASE)
#define LSWF(id) ((id) - EVTDAT_LSWF_BASE)
#define GF(id) ((id) - EVTDAT_GF_BASE)
#define LF(id) ((id) - EVTDAT_LF_BASE)
#define GW(id) ((id) - EVTDAT_GW_BASE)
#define LW(id) ((id) - EVTDAT_LW_BASE)
/*
Return values
*/
// Stop execution of all scripts this frame
#define EVT_END_FRAME -1
// Keep re-executing current instruction, continue next frame if too much time passed
#define EVT_BLOCK_WEAK 0
// Move to next instruction, continue next frame if too much time passed
#define EVT_CONTINUE_WEAK 1
// Move to next instruction
#define EVT_CONTINUE 2
// Keep re-executing current instruction (unused?)
#define EVT_BLOCK 3
// Stop running current script
#define EVT_END 0xff
/*
Opcodes
*/
enum EvtOpcode
{
EVT_OPC_NEXT,
EVT_OPC_END_SCRIPT,
EVT_OPC_END_EVT,
EVT_OPC_LBL,
EVT_OPC_GOTO,
EVT_OPC_DO,
EVT_OPC_WHILE,
EVT_OPC_DO_BREAK,
EVT_OPC_DO_CONTINUE,
EVT_OPC_WAIT_FRM,
EVT_OPC_WAIT_MSEC,
EVT_OPC_HALT,
EVT_OPC_IF_STR_EQUAL,
EVT_OPC_IF_STR_NOT_EQUAL,
EVT_OPC_IF_STR_SMALL,
EVT_OPC_IF_STR_LARGE,
EVT_OPC_IF_STR_SMALL_EQUAL,
EVT_OPC_IF_STR_LARGE_EQUAL,
EVT_OPC_IFF_EQUAL,
EVT_OPC_IFF_NOT_EQUAL,
EVT_OPC_IFF_SMALL,
EVT_OPC_IFF_LARGE,
EVT_OPC_IFF_SMALL_EQUAL,
EVT_OPC_IFF_LARGE_EQUAL,
EVT_OPC_IF_EQUAL,
EVT_OPC_IF_NOT_EQUAL,
EVT_OPC_IF_SMALL,
EVT_OPC_IF_LARGE,
EVT_OPC_IF_SMALL_EQUAL,
EVT_OPC_IF_LARGE_EQUAL,
EVT_OPC_IF_FLAG,
EVT_OPC_IF_NOT_FLAG,
EVT_OPC_ELSE,
EVT_OPC_END_IF,
EVT_OPC_SWITCH,
EVT_OPC_SWITCHI,
EVT_OPC_CASE_EQUAL,
EVT_OPC_CASE_NOT_EQUAL,
EVT_OPC_CASE_SMALL,
EVT_OPC_CASE_LARGE,
EVT_OPC_CASE_SMALL_EQUAL,
EVT_OPC_CASE_LARGE_EQUAL,
EVT_OPC_CASE_ETC,
EVT_OPC_CASE_OR,
EVT_OPC_CASE_AND,
EVT_OPC_CASE_FLAG,
EVT_OPC_CASE_END,
EVT_OPC_CASE_BETWEEN,
EVT_OPC_SWITCH_BREAK,
EVT_OPC_END_SWITCH,
EVT_OPC_SET,
EVT_OPC_SETI,
EVT_OPC_SETF,
EVT_OPC_ADD,
EVT_OPC_SUB,
EVT_OPC_MUL,
EVT_OPC_DIV,
EVT_OPC_MOD,
EVT_OPC_ADDF,
EVT_OPC_SUBF,
EVT_OPC_MULF,
EVT_OPC_DIVF,
EVT_OPC_SET_READ,
EVT_OPC_READ,
EVT_OPC_READ2,
EVT_OPC_READ3,
EVT_OPC_READ4,
EVT_OPC_READ_N,
EVT_OPC_SET_READF,
EVT_OPC_READF,
EVT_OPC_READF2,
EVT_OPC_READF3,
EVT_OPC_READF4,
EVT_OPC_READF_N,
EVT_OPC_CLAMP_INT,
EVT_OPC_SET_USER_WRK,
EVT_OPC_SET_USER_FLG,
EVT_OPC_ALLOC_USER_WRK,
EVT_OPC_AND,
EVT_OPC_ANDI,
EVT_OPC_OR,
EVT_OPC_ORI,
EVT_OPC_SET_FRAME_FROM_MSEC,
EVT_OPC_SET_MSEC_FROM_FRAME,
EVT_OPC_SET_RAM,
EVT_OPC_SET_RAMF,
EVT_OPC_GET_RAM,
EVT_OPC_GET_RAMF,
EVT_OPC_SETR,
EVT_OPC_SETRF,
EVT_OPC_GETR,
EVT_OPC_GETRF,
EVT_OPC_USER_FUNC,
EVT_OPC_RUN_EVT,
EVT_OPC_RUN_EVT_ID,
EVT_OPC_RUN_CHILD_EVT,
EVT_OPC_DELETE_EVT,
EVT_OPC_RESTART_EVT,
EVT_OPC_SET_PRI,
EVT_OPC_SET_SPD,
EVT_OPC_SET_TYPE,
EVT_OPC_STOP_ALL,
EVT_OPC_START_ALL,
EVT_OPC_STOP_OTHER,
EVT_OPC_START_OTHER,
EVT_OPC_STOP_ID,
EVT_OPC_START_ID,
EVT_OPC_CHK_EVT,
EVT_OPC_INLINE_EVT,
EVT_OPC_INLINE_EVT_ID,
EVT_OPC_END_INLINE,
EVT_OPC_BROTHER_EVT,
EVT_OPC_BROTHER_EVT_ID,
EVT_OPC_END_BROTHER,
EVT_OPC_DEBUG_PUT_MSG,
EVT_OPC_DEBUG_MSG_CLEAR,
EVT_OPC_DEBUG_PUT_REG,
EVT_OPC_DEBUG_NAME,
EVT_OPC_DEBUG_REM,
EVT_OPC_DEBUG_BP
};
// Script instruction functions, 800da0b0 - 800ddd5b
int evt_end_evt(EvtEntry * entry);
int evt_lbl(EvtEntry * entry);
int evt_goto(EvtEntry * entry);
int evt_do(EvtEntry * entry);
int evt_while(EvtEntry * entry);
int evt_do_break(EvtEntry * entry);
int evt_do_continue(EvtEntry * entry);
int evt_wait_frm(EvtEntry * entry);
int evt_wait_msec(EvtEntry * entry);
int evt_halt(EvtEntry * entry);
int evt_if_str_equal(EvtEntry * entry);
int evt_if_str_not_equal(EvtEntry * entry);
int evt_if_str_small(EvtEntry * entry);
int evt_if_str_large(EvtEntry * entry);
int evt_if_str_small_equal(EvtEntry * entry);
int evt_if_str_large_equal(EvtEntry * entry);
int evt_iff_equal(EvtEntry * entry);
int evt_iff_not_equal(EvtEntry * entry);
int evt_iff_small(EvtEntry * entry);
int evt_iff_large(EvtEntry * entry);
int evt_iff_small_equal(EvtEntry * entry);
int evt_iff_large_equal(EvtEntry * entry);
int evt_if_equal(EvtEntry * entry);
int evt_if_not_equal(EvtEntry * entry);
int evt_if_small(EvtEntry * entry);
int evt_if_large(EvtEntry * entry);
int evt_if_small_equal(EvtEntry * entry);
int evt_if_large_equal(EvtEntry * entry);
int evt_if_flag(EvtEntry * entry);
int evt_if_not_flag(EvtEntry * entry);
int evt_else(EvtEntry * entry);
int evt_end_if(EvtEntry * entry);
int evt_switch(EvtEntry * entry);
int evt_switchi(EvtEntry * entry);
int evt_case_equal(EvtEntry * entry);
int evt_case_not_equal(EvtEntry * entry);
int evt_case_small(EvtEntry * entry);
int evt_case_small_equal(EvtEntry * entry);
int evt_case_large(EvtEntry * entry);
int evt_case_large_equal(EvtEntry * entry);
int evt_case_between(EvtEntry * entry);
int evt_case_etc(EvtEntry * entry);
int evt_case_flag(EvtEntry * entry);
int evt_case_or(EvtEntry * entry);
int evt_case_and(EvtEntry * entry);
int evt_case_end(EvtEntry * entry);
int evt_switch_break(EvtEntry * entry);
int evt_end_switch(EvtEntry * entry);
int evt_set(EvtEntry * entry);
int evt_seti(EvtEntry * entry);
int evt_setf(EvtEntry * entry);
int evt_add(EvtEntry * entry);
int evt_sub(EvtEntry * entry);
int evt_mul(EvtEntry * entry);
int evt_div(EvtEntry * entry);
int evt_mod(EvtEntry * entry);
int evt_addf(EvtEntry * entry);
int evt_subf(EvtEntry * entry);
int evt_mulf(EvtEntry * entry);
int evt_divf(EvtEntry * entry);
int evt_set_read(EvtEntry * entry);
int evt_set_readf(EvtEntry * entry);
int evt_read(EvtEntry * entry);
int evt_read2(EvtEntry * entry);
int evt_read3(EvtEntry * entry);
int evt_read4(EvtEntry * entry);
int evt_read_n(EvtEntry * entry);
int evt_readf(EvtEntry * entry);
int evt_readf2(EvtEntry * entry);
int evt_readf3(EvtEntry * entry);
int evt_readf4(EvtEntry * entry);
int evt_readf_n(EvtEntry * entry);
int evt_clamp_int(EvtEntry * entry);
int evt_set_user_wrk(EvtEntry * entry);
int evt_set_user_flg(EvtEntry * entry);
int evt_alloc_user_wrk(EvtEntry * entry);
int evt_and(EvtEntry * entry);
int evt_andi(EvtEntry * entry);
int evt_or(EvtEntry * entry);
int evt_ori(EvtEntry * entry);
int evt_set_frame_from_msec(EvtEntry * entry);
int evt_set_msec_from_frame(EvtEntry * entry);
int evt_set_ram(EvtEntry * entry);
int evt_set_ramf(EvtEntry * entry);
int evt_get_ram(EvtEntry * entry);
int evt_get_ramf(EvtEntry * entry);
int evt_setr(EvtEntry * entry);
int evt_setrf(EvtEntry * entry);
int evt_getr(EvtEntry * entry);
int evt_getrf(EvtEntry * entry);
int evt_user_func(EvtEntry * entry);
int evt_run_evt(EvtEntry * entry);
int evt_run_evt_id(EvtEntry * entry);
int evt_run_child_evt(EvtEntry * entry);
int evt_restart_evt(EvtEntry * entry);
int evt_delete_evt(EvtEntry * entry);
int evt_set_pri(EvtEntry * entry);
int evt_set_spd(EvtEntry * entry);
int evt_set_type(EvtEntry * entry);
int evt_stop_all(EvtEntry * entry);
int evt_start_all(EvtEntry * entry);
int evt_stop_other(EvtEntry * entry);
int evt_start_other(EvtEntry * entry);
int evt_stop_id(EvtEntry * entry);
int evt_start_id(EvtEntry * entry);
int evt_chk_evt(EvtEntry * entry);
int evt_inline_evt(EvtEntry * entry);
int evt_inline_evt_id(EvtEntry * entry);
int evt_end_inline(EvtEntry * entry);
int evt_brother_evt(EvtEntry * entry);
int evt_brother_evt_id(EvtEntry * entry);
int evt_end_brother(EvtEntry * entry);
int evt_debug_put_msg(EvtEntry * entry);
int evt_debug_msg_clear(EvtEntry * entry);
int evt_debug_put_reg(EvtEntry * entry);
int evt_debug_name(EvtEntry * entry);
int evt_debug_rem(EvtEntry * entry);
int evt_debug_bp(EvtEntry * entry);
/*
Executes an entry's script until it pauses or finishes
*/
s32 evtmgrCmd(EvtEntry * entry); // 800ddd5c
/*
Gets the value of an evt variable
*/
s32 evtGetValue(EvtEntry * entry, s32 variable); // 800de594
// evtGetNumber (inlined / unused)
/*
Sets the value of an evt variable
*/
s32 evtSetValue(EvtEntry * entry, s32 variable, s32 value); // 800de9b8
/*
Gets the value of a float evt variable
*/
f32 evtGetFloat(EvtEntry * entry, s32 variable); // 800dedb8
/*
Sets the value of a float evt variable
*/
f32 evtSetFloat(EvtEntry * entry, s32 variable, f32 value); // 800df1fc
/*
Returns a pointer to the instruction after the specified label
in an entry's script
*/
EvtScriptCode * evtSearchLabel(EvtEntry * entry, int id); // inlined
/*
Returns a pointer to the instruction after the next else on the
current if else depth in an entry's script
*/
EvtScriptCode * evtSearchElse(EvtEntry * entry); // 800df55c
/*
Returns a pointer to the instruction after the next end if on the
current if else depth in an entry's script
*/
EvtScriptCode * evtSearchEndIf(EvtEntry * entry); // 800df620
/*
Returns a pointer to the the next end switch on the current switch
depth in an entry's script
*/
EvtScriptCode * evtSearchEndSwitch(EvtEntry * entry); // 800df6d8
/*
Returns a pointer to the next case or end switch on the current
switch depth in an entry's script
*/
EvtScriptCode * evtSearchCase(EvtEntry * entry); // 800df780
/*
Returns a pointer to the instruction after the next while on the
current do while depth in an entry's script
*/
EvtScriptCode * evtSearchWhile(EvtEntry * entry); // 800df84c
/*
Returns a pointer to the next while instruction on the current do
while depth in an entry's script
*/
EvtScriptCode * evtSearchJustBeforeWhile(EvtEntry * entry); // 800df8f8
#endif

View File

@ -1,10 +0,0 @@
/*
Revolution SDK GX Library
*/
#ifndef GX_H
#define GX_H
void GXInitTexObjData(void * texObj, void * image); // 802918f8
#endif

View File

@ -1,10 +0,0 @@
#ifndef HUD_H
#define HUD_H
#include <common.h>
typedef void (CountdownDoneCb)();
void hudStartCountdown(u32 length, CountdownDoneCb * cb); // 80199cc4
#endif

View File

@ -1,8 +0,0 @@
#ifndef LZ_TEXTS_H
#define LZ_TEXTS_H
#include <common.h>
extern u8 pitText[]; // 8036afc0
#endif

View File

@ -1,8 +0,0 @@
#ifndef MAIN_H
#define MAIN_H
#include <common.h>
int main(int argc, char ** argv); // 8001da60
#endif

View File

@ -1,134 +0,0 @@
#ifndef MARIO_POUCH_H
#define MARIO_POUCH_H
#include <common.h>
#define ITEM_ID_KEY_START 16
#define ITEM_ID_KEY_MAX 65
#define ITEM_ID_USE_START 65
#define ITEM_ID_USE_MAX 216
#define ITEM_ID_COOK_START 120
#define ITEM_ID_COOK_MAX 216
#define ITEM_ID_CHAR_START 216
#define ITEM_ID_CHAR_MAX 220
#define ITEM_ID_FAIRY_START 220
#define ITEM_ID_FAIRY_MAX 232
#define ITEM_ID_MAP_START 234
#define ITEM_ID_MAP_MAX 282
#define ITEM_ID_CARD_START 282
#define ITEM_ID_CARD_MAX 538
typedef struct
{
bool selectable;
bool selected;
s16 id;
} PouchCharOrPixlInfo;
typedef struct
{
int characterId;
int score;
u8 unknown_0x8[0x18 - 0x8];
} PouchMinigameScore;
typedef struct
{
u8 unknown_0x0[0x4 - 0x0]; // unused?
int level;
int attack;
int hp;
int maxHp;
int flipTimer;
int xp;
int coins;
s16 keyItem[32];
s16 useItem[10];
s16 shopItem[32];
PouchCharOrPixlInfo characters[4];
PouchCharOrPixlInfo pixls[16];
int shopPoints;
u32 shopPointRewardsCollected; // bit mask, index 1 << i
s8 catchCards[256]; // value is count, index is id - first card id
u8 unknown_0x20c[256];
u32 ownedMaps[2]; // [id / 32] & 1 << (id % 32)
u32 foundMaps[2]; // [id / 32] & 1 << (id % 32)
u32 knownRecipes[3]; // [id / 32] & 1 << (id % 32)
u32 knownCards[8]; // [id / 32] & 1 << (id % 32)
int charmsRemaining;
int killsBeforeNextCharm;
u8 unknown_0x350[0x368 - 0x350];
PouchMinigameScore minigameScores[4][5];
u8 unknown_0x548[0x688 - 0x548];
int arcadeTokens;
int totalCoinsCollected;
int maxJumpCombo;
int maxStylishCombo;
int enemiesDefeated;
u8 unknown_0x69c[0x6a0 - 0x69c]; // unused?
} MarioPouchWork;
MarioPouchWork * pouchGetPtr(); // 8014c088
void pouchInit(); // 8014c094
void pouchReInit(); // 8014c728
void pouchMain(); // 8014cd90
// func_8014d184
void pouchSetLevel(int level); // 8014d1bc
int pouchGetLevel(); // 8014d1f0
int pouchGetNextLevelXp(); // 8014d200
void pouchSetAttack(int attack); // 8014d394
int pouchGetAttack(); // 8014d3c8
void pouchAddAttack(int increase); // 8014d3d8
void pouchSetHp(int attack); // 8014d414
int pouchGetHp(); // 8014d458
void pouchAddHp(int increase); // 8014d468
void pouchSetMaxHp(int maxHp); // 8014d4b4
int pouchGetMaxHp(); // 8014d4e8
int pouchGetXp(); // 8014d4f8
void pouchAddXp(int increase); // 8014d508
void pouchSetCoin(int coins); // 8014d548
int pouchGetCoin(); // 8014d57c
void pouchAddTotalCoin(int increase); // inlined
void pouchAddCoin(int increase); // 8014d58c
bool pouchAddItem(short itemId); // 8014d5f8
bool pouchCheckHaveItem(int itemId); // 8014dbf4
void pouchRemoveItem(int itemId); // 8014df4c
// pouchRemoveItemIdx 8014e6d0
// pouchAddShopItem 8014ea38
// pouchRemoveShopItem 8014eb68
// pouchRemoveShopItemIdx 8014edb8
// pouchGetCharInfo 8014ef98
// pouchMakeCharSelectable 8014efb0
// pouchMakeCharNotSelectable 8014f018
// pouchGetPixlInfo 8014f080
// pouchMakePixlSelectable 8014f098
// pouchMakePixlNotSelectable 8014f154
// pouchCheckPixlSelected 8014f210
// pouchGetCurPixl 8014f31c
// pouchSetPixlSelected 8014f408
// pouchRegisterMapFound 8014f594
void pouchRegisterRecipeKnown(int itemId); // 8014f64c
// pouchCheckRecipeKnown 8014f704
// pouchGetCardCount 8014f7c8
// pouchCheckCardKnown 8014f84c
// pouchRegisterJumpCombo 8014f910
// pouchRegisterStylishCombo 8014f944
// pouchSetEnemiesDefeated 8014f978
// pouchGetTotalCoinsCollected 8014f99c
// pouchGetMaxJumpCombo 8014f9ac
// pouchGetMaxStylishCombo 8014f9bc
// pouchGetEnemiesDefeated 8014f9cc
// pouchGetArcadeTokens 8014f9dc
// pouchSetArcadeTokens 8014f9ec
// pouchCountUseItems 8014fa20
// pouchCountKeyItems 8014fad0
// pouchCountShopItems 8014fb78
// pouchCountChars 8014fc20
// pouchCountPixls 8014fc70
// pouchCountPixlsNotSelected 8014fd18
// pouchCheckFreeUseItem 8014fdb0
// pouchCountMapsOwned 8014fe88
// pouchCountRecipesKnown 8014ff9c
// pouchCountCardsKnown 801500b0
#endif

View File

@ -1,6 +0,0 @@
#ifndef MATH_H
#define MATH_H
double fmod(double numer, double denom);
#endif

View File

@ -1,91 +0,0 @@
/*
Revolution SDK OS Library
*/
#ifndef OS_H
#define OS_H
#include <common.h>
#define OSClockSpeed ((*(u32 *) 0x800000F8) / 4)
#define OSTicksToMilliseconds(ticks) ((ticks) / (OSClockSpeed / 1000))
void OSPanic(char * filename, s32 line, char * msg, ...); // 8019e33c
void * OSGetMEM1ArenaHi(); // 8026fac8
void * OSGetMEM2ArenaHi(); // 8026fad0
void * OSGetArenaHi(); // 8026fad8
void * OSGetMEM1ArenaLo(); // 8026fae0
void * OSGetMEM2ArenaLo(); // 8026fae8
void * OSGetArenaLo(); // 8026faf0
void OSSetMEM1ArenaHi(void * arenaHi); // 8026faf8
void OSSetMEM2ArenaHi(void * arenaHi); // 8026fb00
void OSSetArenaHi(void * arenaHi); // 8026fb08
void OSSetMEM1ArenaLo(void * arenaLo); // 8026fb10
void OSSetMEM2ArenaLo(void * arenaLo); // 8026fb18
void OSSetArenaLo(void * arenaLo); // 8026fb20
void * DCFlushRange(void * ptr, size_t length); // 80270050
typedef void (RelExportFunc)();
// Unions are offsets in file then pointers after OSLink
struct _RelHeader;
typedef struct _RelHeader {
u32 id;
struct _RelHeader * next;
struct _RelHeader * prev;
u32 numSections;
union {
u32 sectionInfoOffset;
void * sectionInfo;
};
union {
u32 nameOffset;
void * name;
};
u32 nameSize;
u32 version;
u32 bssSize;
union {
u32 relOffset;
void * relocationTable;
};
union {
u32 impOffset;
void * impTable;
};
u32 impSize;
u8 prologSection;
u8 epilogSection;
u8 unresolvedSection;
u8 bssSection;
union {
u32 prologOffset;
RelExportFunc * prolog;
};
union {
u32 epilogOffset;
RelExportFunc * epilog;
};
union {
u32 unresolvedOffset;
RelExportFunc * unresolved;
};
u32 align;
u32 bssAlign;
u32 fixSize;
} RelHeader;
typedef struct
{
u8 unknown_0x0[0x318 - 0x0];
} OSThread;
bool OSLink(RelHeader * relFile, void * bss); // 80274c0c
void OSYieldThread(); // 802776c0
s64 OSGetTime(); // 80278370
#endif

View File

@ -1,21 +0,0 @@
#ifndef PARSE_H
#define PARSE_H
enum ParseValueType
{
PARSE_VALUE_TYPE_STRING = 0,
PARSE_VALUE_TYPE_1 = 1,
PARSE_VALUE_TYPE_INT = 2,
PARSE_VALUE_TYPE_FLOAT = 3,
PARSE_VALUE_TYPE_VEC3 = 4
};
void parseInit(const char * text, u32 length); // 801a6e9c
// getTag 801a6ebc
bool parsePush(const char * tag); // 801a6f40
void parsePop(); // 801a70f4
void parsePopNext(); // 801a710c
bool parseGet1Next(int type, void * ret); // 801a7140
bool parseTagGet1(const char * tag, int type, void * ret); // 801a7488
#endif

View File

@ -1,11 +0,0 @@
#ifndef SEQ_GAME_H
#define SEQ_GAME_H
#include <common.h>
#include <seqdrv.h>
void seq_gameInit(SeqWork * work); // 8017ce44
void seq_gameMain(SeqWork * work); // 8017cf08
void seq_gameExit(SeqWork * work); // 8017d004
#endif

View File

@ -1,11 +0,0 @@
#ifndef SEQ_GAMEOVER_H
#define SEQ_GAMEOVER_H
#include <common.h>
#include <seqdrv.h>
void seq_gameOverInit(SeqWork * work); // 801789f4
void seq_gameOverMain(SeqWork * work); // 80178b68
void seq_gameOverExit(SeqWork * work); // 80178af4
#endif

View File

@ -1,11 +0,0 @@
#ifndef SEQ_LOAD_H
#define SEQ_LOAD_H
#include <common.h>
#include <seqdrv.h>
void seq_loadInit(SeqWork * work); // 8017c10c
void seq_loadMain(SeqWork * work); // 8017c13c
void seq_loadExit(SeqWork * work); // 8017c138
#endif

View File

@ -1,11 +0,0 @@
#ifndef SEQ_LOGO_H
#define SEQ_LOGO_H
#include <common.h>
#include <seqdrv.h>
void seq_logoInit(SeqWork * work); // 80178fd0
void seq_logoMain(SeqWork * work); // 80179140
void seq_logoExit(SeqWork * work); // 801790f8
#endif

View File

@ -1,11 +0,0 @@
#ifndef SEQ_MAPCHANGE_H
#define SEQ_MAPCHANGE_H
#include <common.h>
#include <seqdrv.h>
void seq_mapChangeInit(SeqWork * work); // 8017a33c
void seq_mapChangeExit(SeqWork * work); // 8017a460
void seq_mapChangeMain(SeqWork * work); // 8017a464
#endif

View File

@ -1,16 +0,0 @@
#ifndef SEQ_TITLE_H
#define SEQ_TITLE_H
#include <common.h>
#include <seqdrv.h>
void seq_titleInit(SeqWork * work); // 8017b130
void seq_titleMain(SeqWork * work); // 8017b250
void seq_titleExit(SeqWork * work); // 8017b410
// more
// No idea why this is in this file of all places, but it is
const char * getNextDanMapname(int dungeonNo); // 8017bc4c
#endif

View File

@ -1,14 +0,0 @@
/*
Unknown functions and data from unknown files
*/
#ifndef SOMEWHERE_H
#define SOMEWHERE_H
#include <common.h>
// referenced in dan.c
void func_800b426c(float, float, float, int, int);
void func_800cd554(float, float, float, float, float, float, int, int);
#endif

9
include/spm/DEMOInit.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#include <common.h>
extern s32 DemoUseMEMHeap;
void DEMOInit();
void DEMOBeforeRender();
void DEMODoneRender();

6
include/spm/acdrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void acInit();
void acMain();

17
include/spm/animdrv.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <common.h>
typedef struct {
u8 unknown_0x0[0x110 - 0x0];
} AnimWork; // Uncertain size;
AnimWork * animGetPtr();
void animInit();
void animMain();
typedef void (AnimPoseDisplayCb)(void * param, s32 animGroupIdx, s32 param_3);
void animPoseSetDispCallback(s32 animPoseId, AnimPoseDisplayCb * cb, void * param);
s32 animPoseGetGroupIdx(s32 id, const char * name);

View File

@ -1,7 +1,9 @@
#ifndef BGDRV_H
#define BGDRV_H
#pragma once
#include <common.h>
void bgInit();
void bgMain();
void func_8004f5c8(const char *);
void func_8004f5f0(const char *);
#endif

34
include/spm/camdrv.h Normal file
View File

@ -0,0 +1,34 @@
#pragma once
#include <common.h>
#include <wii/types.h>
typedef struct
{
u32 flag;
u8 unknown_0x4[0x54 - 0x4];
Mtx34 viewMtx;
u8 unknown_0x84[0x94 - 0x84];
Mtx44 projMtx;
u8 unknown_0xd4[0xf0 - 0xd4];
f32 top;
f32 bottom;
f32 left;
f32 right;
u8 unknown_0x100[0x158 - 0x100];
s32 isOrtho;
Vec3 pos;
Vec3 target;
u8 unknown_0x174[0x18c - 0x174];
f32 aspect;
u8 unknown_0x190[0x2f0 - 0x174];
} CamEntry;
void camInit();
void camMain();
void camDraw();
bool camCheck3d(s32 camId);
CamEntry * camGetPtr(s32 camId);
CamEntry * camGetCurPtr();

6
include/spm/casedrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void caseInit();
void caseMain();

5
include/spm/debug.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <common.h>
void debugInit();

15
include/spm/dispdrv.h Normal file
View File

@ -0,0 +1,15 @@
#pragma once
#include <common.h>
typedef void (DispCallback)(s32 cameraId, void * param);
typedef struct {
u8 unknown_0x0[0x10 - 0x0];
} DispEntry;
void dispInit();
void dispEntry(s8 cameraId, u8 renderMode, float z, DispCallback * cb, void * cbParam);
DispEntry * dispGetCurWork();

22
include/spm/dvdmgr.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include <common.h>
typedef void (DVDMgrCallback)(s32 result, void * fileInfo);
typedef struct
{
u8 unknown_0x0[0x7c - 0x0];
void * unknown_0x7c;
u8 unknown_0x80[0x9c - 0x80];
} DVDEntry;
void DVDMgrInit();
void DVDMgrDelete();
DVDEntry * DVDMgrOpen(const char * path, s32 param_2, s32 param_3);
s32 DVDMgrRead(DVDEntry * entry, void * dest, size_t length, u32 offset);
s32 DVDMgrReadAsync(DVDEntry * entry, void * dest, size_t length, u32 offset, DVDMgrCallback * callback);
void DVDMgrClose(DVDEntry * entry);
size_t DVDMgrGetLength(DVDEntry * entry);

View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
UNKNOWN_FUNCTION(func_800c1838);
UNKNOWN_FUNCTION(func_800c1938);

8
include/spm/effdrv.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <common.h>
void effInit();
void effMain();
UNKNOWN_FUNCTION(effGetTexObj);

6
include/spm/envdrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void envInit();
void envMain();

12
include/spm/evt_cam.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(evt_cam_shake)
EVT_UNKNOWN_USER_FUNC(evt_cam3d_evt_zoom_in)
EVT_UNKNOWN_USER_FUNC(func_800e01f8)
EVT_UNKNOWN_USER_FUNC(func_800e0430)
EVT_UNKNOWN_USER_FUNC(func_800e04fc)
EVT_DECLARE(lbl_80439f10)

50
include/spm/evt_door.h Normal file
View File

@ -0,0 +1,50 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
typedef struct
{
u32 flags;
const char * name_l;
const char * name_r;
const char * hitName2d;
const char * hitName3d;
const char * destMapName;
const char * unknown_0x18;
s32 unknown_0x1c;
} MapDoorDesc;
typedef struct
{
s32 scriptNumber;
u16 flags;
u16 _pad_6;
const char * name;
const char * mapName;
const char * hitName2d;
const char * hitName3d;
const char * destMapName;
const char * unknown_0x1c;
} DokanDesc;
EVT_UNKNOWN_USER_FUNC(evt_door_wait_flag)
// evt_door_set_door_descs(DoorDesc * descs, s32 count)
EVT_DECLARE_USER_FUNC(evt_door_set_door_descs, 1)
// evt_door_set_dokan_descs(DokanDesc * descs, s32 count)
EVT_DECLARE_USER_FUNC(evt_door_set_dokan_descs, 1)
// evt_door_enable_disable_dokan_desc(bool enabled, const char * name)
EVT_DECLARE_USER_FUNC(evt_door_enable_disable_dokan_desc, 2)
// evt_door_set_map_door_descs(MapDoorDesc * descs, s32 count)
EVT_DECLARE_USER_FUNC(evt_door_set_map_door_descs, 1)
// evt_door_enable_disable_map_door_desc(bool enabled, const char * name)
EVT_DECLARE_USER_FUNC(evt_door_enable_disable_map_door_desc, 2)
EVT_DECLARE(lbl_80417e10)
EVT_DECLARE(door_init_evt)

11
include/spm/evt_eff.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_800e57bc)
// evt_eff_softdelete(const char * name)
EVT_DECLARE_USER_FUNC(evt_eff_softdelete, 1)
EVT_UNKNOWN_USER_FUNC(func_800e6250)

14
include/spm/evt_fairy.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
// evt_fairy_set_pos(s32 id, float x, float y, float z)
EVT_DECLARE_USER_FUNC(evt_fairy_set_pos, 4)
// evt_fairy_reset()
EVT_DECLARE_USER_FUNC(evt_fairy_reset, 0)
EVT_UNKNOWN_USER_FUNC(func_800e8518)
EVT_UNKNOWN_USER_FUNC(func_800e8824)

10
include/spm/evt_frame.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_800e88d0)
EVT_UNKNOWN_USER_FUNC(func_800e8ab4)
EVT_UNKNOWN_USER_FUNC(func_800e8854)
EVT_UNKNOWN_USER_FUNC(func_800e89d4)
EVT_UNKNOWN_USER_FUNC(func_800e8a58)

6
include/spm/evt_guide.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_800eaa88)

13
include/spm/evt_hit.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
// evt_hitobj_onoff(const char * name, bool group, bool on)
EVT_DECLARE_USER_FUNC(evt_hitobj_onoff, 4)
// evt_hit_bind_mapobj(const char * hit_name, const char * map_name)
EVT_DECLARE_USER_FUNC(evt_hit_bind_mapobj, 2)
// evt_hit_bind_update(const char * hit_name)
EVT_DECLARE_USER_FUNC(evt_hit_bind_update, 1)
// evt_hitobj_attr_onoff(bool group, bool on, const char * name, u32 mask)
EVT_DECLARE_USER_FUNC(evt_hitobj_attr_onoff, 4)

12
include/spm/evt_img.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_800ec2c8)
EVT_UNKNOWN_USER_FUNC(func_800ec3ac)
EVT_UNKNOWN_USER_FUNC(func_800ec458)
EVT_UNKNOWN_USER_FUNC(func_800ec4ec)
EVT_UNKNOWN_USER_FUNC(func_800ec7e0)
EVT_UNKNOWN_USER_FUNC(func_800ec8c4)
EVT_UNKNOWN_USER_FUNC(func_800ec920)

10
include/spm/evt_item.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(evt_item_entry)
EVT_UNKNOWN_USER_FUNC(func_800ecda0)
EVT_UNKNOWN_USER_FUNC(func_800ece50)
EVT_UNKNOWN_USER_FUNC(evt_item_flag_onoff)
EVT_UNKNOWN_USER_FUNC(evt_item_wait_collected)

18
include/spm/evt_map.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include <evt_cmd.h>
// evt_mapobj_flag_onoff(bool group, bool on, const char * name, u32 mask)
EVT_DECLARE_USER_FUNC(evt_mapobj_flag_onoff, 4)
// evt_mapobj_flag4_onoff(bool group, bool on, const char * name, u32 mask)
EVT_DECLARE_USER_FUNC(evt_mapobj_flag4_onoff, 4)
// evt_mapobj_trans(const char * name, s32 x, s32 y, s32 z)
EVT_DECLARE_USER_FUNC(evt_mapobj_trans, 4)
// evt_mapobj_color(bool group, const char * name, u8 r, u8 g, u8 b, u8 a)
EVT_DECLARE_USER_FUNC(evt_mapobj_color, 6)
// evt_mapobj_get_position(const char * name, float& x, float& y, float& z)
EVT_DECLARE_USER_FUNC(evt_mapobj_get_position, 4)

41
include/spm/evt_mario.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(evt_mario_key_on)
EVT_UNKNOWN_USER_FUNC(evt_mario_key_off)
// evt_mario_get_pos(float& x, float& y, float& z)
EVT_DECLARE_USER_FUNC(evt_mario_get_pos, 3)
// evt_mario_get_pos(float x, float y, float z)
EVT_DECLARE_USER_FUNC(evt_mario_set_pos, 3)
EVT_UNKNOWN_USER_FUNC(func_800efce0)
EVT_UNKNOWN_USER_FUNC(func_800efd88)
EVT_UNKNOWN_USER_FUNC(func_800f1684)
// evt_mario_set_pose(const char * name, s16 time)
EVT_DECLARE_USER_FUNC(evt_mario_set_pose, 2)
EVT_DECLARE_USER_FUNC(evt_mario_wait_anim, 0)
EVT_UNKNOWN_USER_FUNC(func_800f23e4)
EVT_UNKNOWN_USER_FUNC(func_800f240c)
EVT_UNKNOWN_USER_FUNC(func_800f2450)
// evt_mario_flag8_onoff(bool onOff, u32 mask)
EVT_DECLARE_USER_FUNC(evt_mario_flag8_onoff, 2)
EVT_UNKNOWN_USER_FUNC(func_800f09c4)
// evt_mario_get_character(s32& ret)
EVT_DECLARE_USER_FUNC(evt_mario_get_character, 1)
// evt_mario_set_anim_change_handler(MarioAnimChangeHandler * handler)
EVT_DECLARE_USER_FUNC(evt_mario_set_anim_change_handler, 1)
// evt_mario_face_npc(const char * name)
EVT_DECLARE_USER_FUNC(evt_mario_face_npc, 1)
EVT_UNKNOWN_USER_FUNC(func_800f0074)

38
include/spm/evt_mobj.h Normal file
View File

@ -0,0 +1,38 @@
#pragma once
#include <evt_cmd.h>
// Script to save the game
EVT_DECLARE(mobj_save_blk_sysevt)
EVT_UNKNOWN_USER_FUNC(evt_mobj_exec_cancel)
// evt_mobj_flag_onoff(bool on, bool flag4, const char * name, u32 mask)
EVT_DECLARE_USER_FUNC(evt_mobj_flag_onoff, 4)
// evt_mobj_zyo(const char * name, s32 lockItemId, float x, float y, float z, float yRotation,
// EvtScriptCode * interactScript, EvtScriptCode * openScript, EvtVar collectedVar)
EVT_DECLARE_USER_FUNC(evt_mobj_zyo, 9)
// evt_mobj_thako(s32 type, const char * name, float x, float y, float z, EvtScriptCode * interactScript,
// EvtScriptCode * openScript, UNK arg8, UNK arg9)
EVT_DECLARE_USER_FUNC(evt_mobj_thako, 9)
// evt_mobj_kan(bool rotation, const char * name, float x, float y, float z, EvtScriptCode * interactScript,
// UNK arg7)
EVT_DECLARE_USER_FUNC(evt_mobj_kan, 7)
// evt_mobj_arrow(const char * name, float x, float y, float z, UNK arg5)
EVT_DECLARE_USER_FUNC(evt_mobj_arrow, 5)
// evt_mobj_wait_animation_end(const char * name, UNUSED)
EVT_DECLARE_USER_FUNC(evt_mobj_wait_animation_end, 2)
// evt_mobj_get_position(const char * name, float& x, float& y, float& z)
EVT_DECLARE_USER_FUNC(evt_mobj_get_position, 4)
// evt_mobj_set_position(const char * name, float x, float y, float z)
EVT_DECLARE_USER_FUNC(evt_mobj_set_position, 4)
// evt_mobj_hit_onoff(bool on, const char * name)
EVT_DECLARE_USER_FUNC(evt_mobj_hit_onoff, 2)

12
include/spm/evt_msg.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
void evt_msg_init();
// evt_msg_print(u32 flags, const char * msg, s32, const char * speaker)
EVT_DECLARE_USER_FUNC(evt_msg_print, 4)
// evt_msg_continue()
EVT_DECLARE_USER_FUNC(evt_msg_continue, 0)

79
include/spm/evt_npc.h Normal file
View File

@ -0,0 +1,79 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
// evt_npc_set_position(const char * instanceName, float x, float y, float z)
EVT_DECLARE_USER_FUNC(evt_npc_set_position, 4)
// evt_npc_entry(const char * instanceName, const char * animPoseName, s32 instanceId)
EVT_DECLARE_USER_FUNC(evt_npc_entry, 3)
EVT_DECLARE_USER_FUNC(func_80103054, 1)
EVT_DECLARE_USER_FUNC(evt_npc_set_anim, 3)
EVT_DECLARE_USER_FUNC(func_80104694, 2)
// evt_npc_flag8_onoff(const char * instanceName, bool on, u32 mask)
EVT_DECLARE_USER_FUNC(evt_npc_flag8_onoff, 3)
// evt_npc_animflag_onoff(const char * instanceName, bool on, u32 mask)
EVT_DECLARE_USER_FUNC(evt_npc_animflag_onoff, 3)
// evt_npc_set_property(const char * instanceName, s32 propertyId, s32 value)
EVT_DECLARE_USER_FUNC(evt_npc_set_property, 3)
// evt_npc_set_property(const char * instanceName, s32 partId, s32 propertyId, s32 value)
// partId -1 updates all parts
EVT_DECLARE_USER_FUNC(evt_npc_modify_part, 4)
EVT_DECLARE_USER_FUNC(func_801059d0, 2)
// evt_npc_entry_from_template(s32 instanceIdOverride, s32 templateId, s32 x, s32 y,
// s32 z, &s32 instanceId, &char * instanceName)
EVT_DECLARE_USER_FUNC(evt_npc_entry_from_template, 7)
EVT_DECLARE_USER_FUNC(func_80107cfc, 0)
EVT_DECLARE_USER_FUNC(func_80107d20, 0)
EVT_DECLARE_USER_FUNC(func_80108194, 2)
// evt_npc_teleport_effect(bool appearDisappear, const char * instanceName)
// Found by JohnP55
EVT_DECLARE_USER_FUNC(evt_npc_teleport_effect, 2)
EVT_UNKNOWN_USER_FUNC(func_80105b94)
// evt_npc_get_position(const char * name, float& x, float& y, float& z)
EVT_DECLARE_USER_FUNC(evt_npc_get_position, 4)
// evt_npc_jump_to(const char * name, float destX, float destY, float destZ, float height, s32 length)
EVT_DECLARE_USER_FUNC(evt_npc_jump_to, 6)
EVT_UNKNOWN_USER_FUNC(evt_npc_glide_to)
// evt_npc_get_axis_movement_unit(const char * name, float& ret)
EVT_DECLARE_USER_FUNC(evt_npc_get_axis_movement_unit, 2)
// evt_npc_set_camid(const char * name, s32 camId)
EVT_DECLARE_USER_FUNC(evt_npc_set_camid, 2)
EVT_UNKNOWN_USER_FUNC(func_800fef30)
EVT_UNKNOWN_USER_FUNC(func_80103410)
// evt_npc_tribe_agb_async(s32 tribeId)
EVT_DECLARE_USER_FUNC(evt_npc_tribe_agb_async, 1)
// evt_npc_delete(const char * name)
EVT_DECLARE_USER_FUNC(evt_npc_delete, 1)
EVT_UNKNOWN_USER_FUNC(func_80107c38)
EVT_UNKNOWN_USER_FUNC(func_80105708)
EVT_UNKNOWN_USER_FUNC(func_801055a4)
EVT_UNKNOWN_USER_FUNC(func_800ff8f8)
EVT_UNKNOWN_USER_FUNC(func_80105768)
EVT_UNKNOWN_USER_FUNC(func_80105550)
EVT_UNKNOWN_USER_FUNC(func_80102bf8)
EVT_UNKNOWN_USER_FUNC(func_801086fc)
EVT_UNKNOWN_USER_FUNC(func_801049ec)
// evt_npc_set_unitwork(const char * name, s32 idx, s32 val)
EVT_DECLARE_USER_FUNC(evt_npc_set_unitwork, 3)

View File

@ -0,0 +1,9 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_8010c4a4)
EVT_UNKNOWN_USER_FUNC(func_8010c4d4)
EVT_UNKNOWN_USER_FUNC(func_8010c600)
EVT_UNKNOWN_USER_FUNC(func_8010c660)

13
include/spm/evt_pouch.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
// evt_pouch_check_have_item(s32 id, bool& ret)
EVT_DECLARE_USER_FUNC(evt_pouch_check_have_item, 2)
// evt_pouch_add_item(s32 id)
EVT_DECLARE_USER_FUNC(evt_pouch_add_item, 1)
// evt_pouch_set_pixl_selected(s32 id)
EVT_DECLARE_USER_FUNC(evt_pouch_set_pixl_selected, 1)

16
include/spm/evt_shop.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
typedef struct
{
s32 type;
const char * npcName;
s32 * items; // [itemId, price, arg] repeated then [-1]
const char * case1Name;
const char * case2Name;
} EvtShopDef;
// evt_shop_set_defs(EvtShopDef * defs, s32 count)
EVT_DECLARE_USER_FUNC(evt_shop_set_defs, 2)

51
include/spm/evt_snd.h Normal file
View File

@ -0,0 +1,51 @@
#pragma once
#include <evt_cmd.h>
// evt_snd_bgmon(s32 param_1, const char * name)
EVT_DECLARE_USER_FUNC(evt_snd_bgmon, 2)
EVT_DECLARE_USER_FUNC(func_800d36f4, 1)
// evt_snd_set_sfx_reverb_mode(s32 mode)
EVT_DECLARE_USER_FUNC(evt_snd_set_sfx_reverb_mode, 1)
EVT_UNKNOWN_USER_FUNC(evt_snd_bgmoff_f_d)
EVT_UNKNOWN_USER_FUNC(func_800d2294)
// evt_snd_sfxon_3d_player_character(const char * marioName, const char * peach,
// const char * bowserName, const char * luigiName)
EVT_DECLARE_USER_FUNC(evt_snd_sfxon_3d_player_character, 4)
// evt_snd_sfxon_3d_player(const char * name)
EVT_DECLARE_USER_FUNC(evt_snd_sfxon_3d_player, 1)
EVT_UNKNOWN_USER_FUNC(func_800d2268)
EVT_UNKNOWN_USER_FUNC(func_800d35d8)
EVT_UNKNOWN_USER_FUNC(func_800d3144)
// evt_snd_get_bgm_wait_time(s32 bgmPlayerId, s32& ret)
EVT_DECLARE_USER_FUNC(evt_snd_get_bgm_wait_time, 2)
EVT_UNKNOWN_USER_FUNC(func_800d3644)
EVT_UNKNOWN_USER_FUNC(func_800d31a0)
EVT_UNKNOWN_USER_FUNC(func_800d22d8)
EVT_UNKNOWN_USER_FUNC(evt_snd_bgmon_f_d)
// evt_snd_sfxon_3d(const char * name, float x, float y, float z)
EVT_DECLARE_USER_FUNC(evt_snd_sfxon_3d, 4)
// evt_snd_sfxon(const char * name)
EVT_DECLARE_USER_FUNC(evt_snd_sfxon, 1)
// evt_snd_get_last_sfx_id(s32& ret)
EVT_DECLARE_USER_FUNC(evt_snd_get_last_sfx_id, 1)
// evt_snd_sfxoff(s32 id)
EVT_DECLARE_USER_FUNC(evt_snd_sfxoff, 1)
// evt_snd_bgmoff(s32 bgmPlayerId)
EVT_DECLARE_USER_FUNC(evt_snd_bgmoff, 1)
// evt_snd_sfxon_npc(const char * sfxName, const char * npcName)
EVT_DECLARE_USER_FUNC(evt_snd_sfxon_npc, 2)

17
include/spm/evt_sub.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <common.h>
#include <evt_cmd.h>
EVT_UNKNOWN_USER_FUNC(func_800d4de4)
EVT_UNKNOWN_USER_FUNC(func_800d74a0)
EVT_UNKNOWN_USER_FUNC(func_800d7930)
EVT_UNKNOWN_USER_FUNC(evt_sub_intpl_msec_init)
EVT_UNKNOWN_USER_FUNC(evt_sub_intpl_msec_get_value)
// evt_sub_random(s32 max, s32& ret)
EVT_DECLARE_USER_FUNC(evt_sub_random, 2)
// evt_sub_animgroup_async(const char * name)
EVT_DECLARE_USER_FUNC(evt_sub_animgroup_async, 1)

224
include/spm/evtmgr.h Normal file
View File

@ -0,0 +1,224 @@
/*
Functions to manage execution of the game's evt bytecode scripts
*/
#pragma once
#include <common.h>
#include <wii/os.h>
/*
Defines from asserts
*/
#define EVT_max 0x78
#define EVT_ENTRY_MAX 0x80
#define MAX_EVT_JMPTBL 16
/*
EvtEntry.flags values
*/
// Entry is being used to run a script
#define EVT_FLAG_IN_USE 0x1
// Entry's script is temporarily stopped
#define EVT_FLAG_PAUSED 0x2
// Entry's lifetime doesn't increase
#define EVT_FLAG_STOP_TIME 0x4
// Entry's script is temporarily stopped until its child script finishes
#define EVT_FLAG_WAIT_CHILD 0x10
// Entry should still execute this frame if created while evtmgrMain is running
#define EVT_FLAG_START_IMMEDIATE 0x20
// Same effect as EVT_FLAG_PAUSED?
#define EVT_FLAG_80 0x80
struct _EvtEntry;
typedef s32 (UserFunc)(struct _EvtEntry * entry, bool firstRun);
typedef s32 EvtScriptCode;
typedef struct _EvtEntry
{
OSTime lifetime; // Time this script has been running & not paused
u8 flags; // Bit flags, see defines above
u8 curDataLength; // Number of pieces of data (4 bytes each) belonging to the current instruction
u8 curOpcode; // Opcode of the current instruction, see evtmgr_cmd.h for opcodes
u8 priority; // Priority for script to run (higher value -> earlier)
u8 type; // Type mask for stopping/starting
s8 blocked; // Keep re-exucuting the current instruction if true (decomp doesn't match as bool)
s8 doWhileDepth; // Number of do-while loops the current instruction is nested into
s8 switchDepth; // Number of switches the current instruction is nested into
EvtScriptCode * pCurInstruction; // Current instruction being executed
EvtScriptCode * pCurData; // Args for the current instruction being executed
s8 labelIds[MAX_EVT_JMPTBL]; // Each correspond to an address in the jump table
void * jumptable[MAX_EVT_JMPTBL]; // Addresses for each label
struct _EvtEntry * parent; // Script that started this one as a child
struct _EvtEntry * childEntry; // Script started by this one, pausing this until it's finished
struct _EvtEntry * brotherEntry; // Script started by this one which will be stopped if this one is
union
{
s32 tempS[3];
u32 tempU[3];
}; // Temp values with meanings varying by instruction / user func
u8 unknown_0x80[0x94 - 0x80];
UserFunc * userFunc; // Function set & called by the user_func opcode
s32 lw[16]; // Local Work variables
u32 lf[3]; // Local Flag variables
void * doWhileStartPtrs[8]; // Pointer to do opcodes for active while loops
s32 doWhileCounters[8]; // Counters for active while loops
s8 switchStates[8]; // Sates of active switch statements
s32 switchValues[8]; // Values passed into active switch statements
union
{
s32 * readAddr;
float * readfAddr;
}; // Current addr for read/readf instructions
s32 * uw; // User Work variables pointer
u32 * uf; // User Flag variables pointer
s32 id; // Script id
float speed; // timeToRun given per frame
float timeToRun; // Number of instructions to execute this frame
s32 casedrvId;
void * ownerNPC;
void * ownerMOBJ;
s32 unknown_0x170;
s32 msgWindowId;
s32 unknown_0x178;
f32 unknown_0x17c;
f32 unknown_0x180;
f32 unknown_0x184;
s32 msgPri;
u8 unknown_0x18c[0x198 - 0x18c];
EvtScriptCode * scriptStart; // Pointer to the start of this script
char * name; // debug thing, unused?
void * pPrevInstruction; // Pointer to last instruction executed
u8 unknown_0x1a4[0x1a8 - 0x1a4];
} EvtEntry;
typedef struct
{
s32 entryCount; // Number of EvtEntry structs in the entries array
s32 gw[32]; // Global Work variables
u32 gf[3]; // Global Flag variables
EvtEntry * entries; // Entry array
u8 unknown_0x94[0x98 - 0x94];
OSTime time; // Time evtmgrMain last ran
} EvtWork;
extern s32 evtMax;
/*
Returns pointer to the EvtWork struct
*/
EvtWork * evtGetWork();
/*
Allocates memories for entries and zeros global evt variables
*/
void evtmgrInit();
/*
Zeros all entries
*/
void evtmgrReInit();
/*
Starts execution of a script
*/
EvtEntry * evtEntry(EvtScriptCode * script, u32 priority, u8 flags);
EvtEntry * evtEntryType(EvtScriptCode * script, u32 priority, u8 flags, u8 type);
EvtEntry * evtChildEntry(EvtEntry * entry, EvtScriptCode * script, u8 flags);
EvtEntry * evtBrotherEntry(EvtEntry * entry, EvtScriptCode * script, u8 flags);
/*
Restarts a entry
*/
EvtEntry * evtRestart(EvtEntry * entry);
/*
Sets up entry executions, called every frame
*/
void evtmgrMain();
/*
Terminates a entry and all its children & brothers
*/
void evtDelete(EvtEntry * entry);
/*
Terminates a entry by id and all its children & brothers
*/
void evtDeleteID(s32 id);
/*
Checks if a entry is running by id
*/
bool evtCheckID(s32 id);
/*
Sets the execution priority of a entry
*/
void evtSetPri(EvtEntry * entry, u32 pri);
/*
Sets the execution speed of a entry
*/
void evtSetSpeed(EvtEntry * entry, f32 multiplier);
/*
Sets the type mask of a entry
*/
void evtSetType(EvtEntry * entry, u32 type);
/*
Pauses execution a entry and all its children & brothers with types included in the mask
*/
void evtStop(EvtEntry * entry, u32 mask);
/*
Resumes execution of a entry and all its children & brothers with types included in the mask
*/
void evtStart(EvtEntry * entry, u32 mask);
/*
Pauses execution of a entry by id and all its children & brothers
*/
void evtStopID(s32 id);
/*
Resumes execution of a entry by id and all its children & brothers
*/
void evtStartID(s32 id);
/*
Pauses execution of all entries with types included in the mask
*/
void evtStopAll(u32 mask);
/*
Resumes execution of all entries with types included in the mask
*/
void evtStartAll(u32 mask);
/*
Pauses execution of all entries with types included in the mask other than one specific entry
*/
void evtStopOther(EvtEntry * entry, u32 mask);
/*
Resumes execution of all entries with types included in the mask other than one specific entry
*/
void evtStartOther(EvtEntry * entry, u32 mask);
/*
Gets an entry by its index into the array of entries
*/
EvtEntry * evtGetPtr(s32 index);
/*
Gets an entry by its id
*/
EvtEntry * evtGetPtrID(s32 id);

395
include/spm/evtmgr_cmd.h Normal file
View File

@ -0,0 +1,395 @@
/*
Functions to execute interpreted evt script code and handle evt variables
*/
#pragma once
#include <common.h>
#include <spm/evtmgr.h>
// Data types
#define EVTDAT_ADDR_MAX -290000000
#define EVTDAT_FLOAT_MAX -220000000
#define EVTDAT_UF_MAX -200000000
#define EVTDAT_UW_MAX -180000000
#define EVTDAT_GSW_MAX -160000000
#define EVTDAT_LSW_MAX -140000000
#define EVTDAT_GSWF_MAX -120000000
#define EVTDAT_LSWF_MAX -100000000
#define EVTDAT_GF_MAX -80000000
#define EVTDAT_LF_MAX -60000000
#define EVTDAT_GW_MAX -40000000
#define EVTDAT_LW_MAX -20000000
#define EVTDAT_ADDR_BASE 270000000
#define EVTDAT_FLOAT_BASE 240000000
#define EVTDAT_UF_BASE 210000000
#define EVTDAT_UW_BASE 190000000
#define EVTDAT_GSW_BASE 170000000
#define EVTDAT_LSW_BASE 150000000
#define EVTDAT_GSWF_BASE 130000000
#define EVTDAT_LSWF_BASE 110000000
#define EVTDAT_GF_BASE 90000000
#define EVTDAT_LF_BASE 70000000
#define EVTDAT_GW_BASE 50000000
#define EVTDAT_LW_BASE 30000000
#define UF(id) ((id) - EVTDAT_UF_BASE)
#define UW(id) ((id) - EVTDAT_UW_BASE)
#define GSW(id) ((id) - EVTDAT_GSW_BASE)
#define LSW(id) ((id) - EVTDAT_LSW_BASE)
#define GSWF(id) ((id) - EVTDAT_GSWF_BASE)
#define LSWF(id) ((id) - EVTDAT_LSWF_BASE)
#define GF(id) ((id) - EVTDAT_GF_BASE)
#define LF(id) ((id) - EVTDAT_LF_BASE)
#define GW(id) ((id) - EVTDAT_GW_BASE)
#define LW(id) ((id) - EVTDAT_LW_BASE)
#define FLOAT(value) (((s32) ((value) * 1024.f)) - EVTDAT_FLOAT_BASE)
#define EVT_NULLPTR (-EVTDAT_ADDR_BASE)
/*
Instruction / User Func Return values
*/
// Stop execution of all scripts this frame
#define EVT_RET_END_FRAME -1
// Keep re-executing current instruction, continue next frame if too much time passed
#define EVT_RET_BLOCK_WEAK 0
// Move to next instruction, continue next frame if too much time passed
#define EVT_RET_CONTINUE_WEAK 1
// Move to next instruction
#define EVT_RET_CONTINUE 2
// Keep re-executing current instruction
#define EVT_RET_BLOCK 3
// Stop running current script
#define EVT_RET_END 0xff
/*
evtmgrCmd return values
*/
#define EVTCMD_RET_END -1
#define EVTCMD_RET_CONTINUE 0
#define EVTCMD_RET_END_ALL 1
/*
Opcodes
*/
enum EvtOpcode
{
EVT_OPC_NEXT,
EVT_OPC_END_SCRIPT,
EVT_OPC_END_EVT,
EVT_OPC_LBL,
EVT_OPC_GOTO,
EVT_OPC_DO,
EVT_OPC_WHILE,
EVT_OPC_DO_BREAK,
EVT_OPC_DO_CONTINUE,
EVT_OPC_WAIT_FRM,
EVT_OPC_WAIT_MSEC,
EVT_OPC_HALT,
EVT_OPC_IF_STR_EQUAL,
EVT_OPC_IF_STR_NOT_EQUAL,
EVT_OPC_IF_STR_SMALL,
EVT_OPC_IF_STR_LARGE,
EVT_OPC_IF_STR_SMALL_EQUAL,
EVT_OPC_IF_STR_LARGE_EQUAL,
EVT_OPC_IFF_EQUAL,
EVT_OPC_IFF_NOT_EQUAL,
EVT_OPC_IFF_SMALL,
EVT_OPC_IFF_LARGE,
EVT_OPC_IFF_SMALL_EQUAL,
EVT_OPC_IFF_LARGE_EQUAL,
EVT_OPC_IF_EQUAL,
EVT_OPC_IF_NOT_EQUAL,
EVT_OPC_IF_SMALL,
EVT_OPC_IF_LARGE,
EVT_OPC_IF_SMALL_EQUAL,
EVT_OPC_IF_LARGE_EQUAL,
EVT_OPC_IF_FLAG,
EVT_OPC_IF_NOT_FLAG,
EVT_OPC_ELSE,
EVT_OPC_END_IF,
EVT_OPC_SWITCH,
EVT_OPC_SWITCHI,
EVT_OPC_CASE_EQUAL,
EVT_OPC_CASE_NOT_EQUAL,
EVT_OPC_CASE_SMALL,
EVT_OPC_CASE_LARGE,
EVT_OPC_CASE_SMALL_EQUAL,
EVT_OPC_CASE_LARGE_EQUAL,
EVT_OPC_CASE_ETC,
EVT_OPC_CASE_OR,
EVT_OPC_CASE_AND,
EVT_OPC_CASE_FLAG,
EVT_OPC_CASE_END,
EVT_OPC_CASE_BETWEEN,
EVT_OPC_SWITCH_BREAK,
EVT_OPC_END_SWITCH,
EVT_OPC_SET,
EVT_OPC_SETI,
EVT_OPC_SETF,
EVT_OPC_ADD,
EVT_OPC_SUB,
EVT_OPC_MUL,
EVT_OPC_DIV,
EVT_OPC_MOD,
EVT_OPC_ADDF,
EVT_OPC_SUBF,
EVT_OPC_MULF,
EVT_OPC_DIVF,
EVT_OPC_SET_READ,
EVT_OPC_READ,
EVT_OPC_READ2,
EVT_OPC_READ3,
EVT_OPC_READ4,
EVT_OPC_READ_N,
EVT_OPC_SET_READF,
EVT_OPC_READF,
EVT_OPC_READF2,
EVT_OPC_READF3,
EVT_OPC_READF4,
EVT_OPC_READF_N,
EVT_OPC_CLAMP_INT,
EVT_OPC_SET_USER_WRK,
EVT_OPC_SET_USER_FLG,
EVT_OPC_ALLOC_USER_WRK,
EVT_OPC_AND,
EVT_OPC_ANDI,
EVT_OPC_OR,
EVT_OPC_ORI,
EVT_OPC_SET_FRAME_FROM_MSEC,
EVT_OPC_SET_MSEC_FROM_FRAME,
EVT_OPC_SET_RAM,
EVT_OPC_SET_RAMF,
EVT_OPC_GET_RAM,
EVT_OPC_GET_RAMF,
EVT_OPC_SETR,
EVT_OPC_SETRF,
EVT_OPC_GETR,
EVT_OPC_GETRF,
EVT_OPC_USER_FUNC,
EVT_OPC_RUN_EVT,
EVT_OPC_RUN_EVT_ID,
EVT_OPC_RUN_CHILD_EVT,
EVT_OPC_DELETE_EVT,
EVT_OPC_RESTART_EVT,
EVT_OPC_SET_PRI,
EVT_OPC_SET_SPD,
EVT_OPC_SET_TYPE,
EVT_OPC_STOP_ALL,
EVT_OPC_START_ALL,
EVT_OPC_STOP_OTHER,
EVT_OPC_START_OTHER,
EVT_OPC_STOP_ID,
EVT_OPC_START_ID,
EVT_OPC_CHK_EVT,
EVT_OPC_INLINE_EVT,
EVT_OPC_INLINE_EVT_ID,
EVT_OPC_END_INLINE,
EVT_OPC_BROTHER_EVT,
EVT_OPC_BROTHER_EVT_ID,
EVT_OPC_END_BROTHER,
EVT_OPC_DEBUG_PUT_MSG,
EVT_OPC_DEBUG_MSG_CLEAR,
EVT_OPC_DEBUG_PUT_REG,
EVT_OPC_DEBUG_NAME,
EVT_OPC_DEBUG_REM,
EVT_OPC_DEBUG_BP
};
// Script instruction functions, 800da0b0 - 800ddd5b
s32 evt_end_evt(EvtEntry * entry);
s32 evt_lbl(EvtEntry * entry);
s32 evt_goto(EvtEntry * entry);
s32 evt_do(EvtEntry * entry);
s32 evt_while(EvtEntry * entry);
s32 evt_do_break(EvtEntry * entry);
s32 evt_do_continue(EvtEntry * entry);
s32 evt_wait_frm(EvtEntry * entry);
s32 evt_wait_msec(EvtEntry * entry);
s32 evt_halt(EvtEntry * entry);
s32 evt_if_str_equal(EvtEntry * entry);
s32 evt_if_str_not_equal(EvtEntry * entry);
s32 evt_if_str_small(EvtEntry * entry);
s32 evt_if_str_large(EvtEntry * entry);
s32 evt_if_str_small_equal(EvtEntry * entry);
s32 evt_if_str_large_equal(EvtEntry * entry);
s32 evt_iff_equal(EvtEntry * entry);
s32 evt_iff_not_equal(EvtEntry * entry);
s32 evt_iff_small(EvtEntry * entry);
s32 evt_iff_large(EvtEntry * entry);
s32 evt_iff_small_equal(EvtEntry * entry);
s32 evt_iff_large_equal(EvtEntry * entry);
s32 evt_if_equal(EvtEntry * entry);
s32 evt_if_not_equal(EvtEntry * entry);
s32 evt_if_small(EvtEntry * entry);
s32 evt_if_large(EvtEntry * entry);
s32 evt_if_small_equal(EvtEntry * entry);
s32 evt_if_large_equal(EvtEntry * entry);
s32 evt_if_flag(EvtEntry * entry);
s32 evt_if_not_flag(EvtEntry * entry);
s32 evt_else(EvtEntry * entry);
s32 evt_end_if(EvtEntry * entry);
s32 evt_switch(EvtEntry * entry);
s32 evt_switchi(EvtEntry * entry);
s32 evt_case_equal(EvtEntry * entry);
s32 evt_case_not_equal(EvtEntry * entry);
s32 evt_case_small(EvtEntry * entry);
s32 evt_case_small_equal(EvtEntry * entry);
s32 evt_case_large(EvtEntry * entry);
s32 evt_case_large_equal(EvtEntry * entry);
s32 evt_case_between(EvtEntry * entry);
s32 evt_case_etc(EvtEntry * entry);
s32 evt_case_flag(EvtEntry * entry);
s32 evt_case_or(EvtEntry * entry);
s32 evt_case_and(EvtEntry * entry);
s32 evt_case_end(EvtEntry * entry);
s32 evt_switch_break(EvtEntry * entry);
s32 evt_end_switch(EvtEntry * entry);
s32 evt_set(EvtEntry * entry);
s32 evt_seti(EvtEntry * entry);
s32 evt_setf(EvtEntry * entry);
s32 evt_add(EvtEntry * entry);
s32 evt_sub(EvtEntry * entry);
s32 evt_mul(EvtEntry * entry);
s32 evt_div(EvtEntry * entry);
s32 evt_mod(EvtEntry * entry);
s32 evt_addf(EvtEntry * entry);
s32 evt_subf(EvtEntry * entry);
s32 evt_mulf(EvtEntry * entry);
s32 evt_divf(EvtEntry * entry);
s32 evt_set_read(EvtEntry * entry);
s32 evt_set_readf(EvtEntry * entry);
s32 evt_read(EvtEntry * entry);
s32 evt_read2(EvtEntry * entry);
s32 evt_read3(EvtEntry * entry);
s32 evt_read4(EvtEntry * entry);
s32 evt_read_n(EvtEntry * entry);
s32 evt_readf(EvtEntry * entry);
s32 evt_readf2(EvtEntry * entry);
s32 evt_readf3(EvtEntry * entry);
s32 evt_readf4(EvtEntry * entry);
s32 evt_readf_n(EvtEntry * entry);
s32 evt_clamp_int(EvtEntry * entry);
s32 evt_set_user_wrk(EvtEntry * entry);
s32 evt_set_user_flg(EvtEntry * entry);
s32 evt_alloc_user_wrk(EvtEntry * entry);
s32 evt_and(EvtEntry * entry);
s32 evt_andi(EvtEntry * entry);
s32 evt_or(EvtEntry * entry);
s32 evt_ori(EvtEntry * entry);
s32 evt_set_frame_from_msec(EvtEntry * entry);
s32 evt_set_msec_from_frame(EvtEntry * entry);
s32 evt_set_ram(EvtEntry * entry);
s32 evt_set_ramf(EvtEntry * entry);
s32 evt_get_ram(EvtEntry * entry);
s32 evt_get_ramf(EvtEntry * entry);
s32 evt_setr(EvtEntry * entry);
s32 evt_setrf(EvtEntry * entry);
s32 evt_getr(EvtEntry * entry);
s32 evt_getrf(EvtEntry * entry);
s32 evt_user_func(EvtEntry * entry);
s32 evt_run_evt(EvtEntry * entry);
s32 evt_run_evt_id(EvtEntry * entry);
s32 evt_run_child_evt(EvtEntry * entry);
s32 evt_restart_evt(EvtEntry * entry);
s32 evt_delete_evt(EvtEntry * entry);
s32 evt_set_pri(EvtEntry * entry);
s32 evt_set_spd(EvtEntry * entry);
s32 evt_set_type(EvtEntry * entry);
s32 evt_stop_all(EvtEntry * entry);
s32 evt_start_all(EvtEntry * entry);
s32 evt_stop_other(EvtEntry * entry);
s32 evt_start_other(EvtEntry * entry);
s32 evt_stop_id(EvtEntry * entry);
s32 evt_start_id(EvtEntry * entry);
s32 evt_chk_evt(EvtEntry * entry);
s32 evt_inline_evt(EvtEntry * entry);
s32 evt_inline_evt_id(EvtEntry * entry);
s32 evt_end_inline(EvtEntry * entry);
s32 evt_brother_evt(EvtEntry * entry);
s32 evt_brother_evt_id(EvtEntry * entry);
s32 evt_end_brother(EvtEntry * entry);
s32 evt_debug_put_msg(EvtEntry * entry);
s32 evt_debug_msg_clear(EvtEntry * entry);
s32 evt_debug_put_reg(EvtEntry * entry);
s32 evt_debug_name(EvtEntry * entry);
s32 evt_debug_rem(EvtEntry * entry);
s32 evt_debug_bp(EvtEntry * entry);
/*
Executes an entry's script until it pauses or finishes
*/
s32 evtmgrCmd(EvtEntry * entry);
/*
Gets the value of an evt variable
*/
s32 evtGetValue(EvtEntry * entry, s32 variable);
// evtGetNumber (inlined / unused)
/*
Sets the value of an evt variable
*/
s32 evtSetValue(EvtEntry * entry, s32 variable, s32 value);
/*
Gets the value of a float evt variable
*/
f32 evtGetFloat(EvtEntry * entry, s32 variable);
/*
Sets the value of a float evt variable
*/
f32 evtSetFloat(EvtEntry * entry, s32 variable, f32 value);
/*
Returns a pointer to the instruction after the specified label
in an entry's script
*/
EvtScriptCode * evtSearchLabel(EvtEntry * entry, s32 id); // inlined
/*
Returns a pointer to the instruction after the next else on the
current if else depth in an entry's script
*/
EvtScriptCode * evtSearchElse(EvtEntry * entry);
/*
Returns a pointer to the instruction after the next end if on the
current if else depth in an entry's script
*/
EvtScriptCode * evtSearchEndIf(EvtEntry * entry);
/*
Returns a pointer to the the next end switch on the current switch
depth in an entry's script
*/
EvtScriptCode * evtSearchEndSwitch(EvtEntry * entry);
/*
Returns a pointer to the next case or end switch on the current
switch depth in an entry's script
*/
EvtScriptCode * evtSearchCase(EvtEntry * entry);
/*
Returns a pointer to the instruction after the next while on the
current do while depth in an entry's script
*/
EvtScriptCode * evtSearchWhile(EvtEntry * entry);
/*
Returns a pointer to the next while instruction on the current do
while depth in an entry's script
*/
EvtScriptCode * evtSearchJustBeforeWhile(EvtEntry * entry);

6
include/spm/extdrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void extInit();
void extMain();

8
include/spm/fadedrv.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <common.h>
void fadeInit();
void fadeMain();
bool fadeIsFinish();

View File

@ -2,12 +2,11 @@
Functions to access files on the game's disc
*/
#ifndef FILEMGR_H
#define FILEMGR_H
#pragma once
#include <common.h>
#include <dvdmgr.h>
#include <tpl.h>
#include <spm/dvdmgr.h>
#include <wii/tpl.h>
#define FILE_ENTRY_MAX 1024
@ -51,40 +50,38 @@ typedef struct
/*
Initialise entries
*/
void fileInit(); // 8017e288
void fileInit();
/*
Takes a TPL file and converts all offsets in it to pointers
*/
void UnpackTexPalette(TPLHeader * palette); // 8019e5a4
void UnpackTexPalette(TPLHeader * palette);
/*
Takes a TPL file and converts all pointers in it back to offsets
*/
void PackTexPalette(TPLHeader * palette); // 8019e6c0
void PackTexPalette(TPLHeader * palette);
/*
Converts self-pointers in file data to offsets to allow safe moving
*/
void fileGarbageDataAdrClear(FileEntry * entry); // 8019e7e0
void fileGarbageDataAdrClear(FileEntry * entry);
/*
Converts offsets in file data back to self-pointers
*/
void fileGarbageDataAdrSet(void * data, s32 fileType); // 8019ee2c
void fileGarbageDataAdrSet(void * data, s32 fileType);
/*
Safely moves memory containing file data, preserving any self-pointers
*/
void fileGarbageMoveMem(void * dest, FileEntry * sourceEntry); // 8019f498
void fileGarbageMoveMem(void * dest, FileEntry * sourceEntry);
void _fileGarbage(s32); // 8019f560
FileEntry * fileAllocf(s32 fileType, const char * format, ...); // 8019f724
FileEntry * fileAlloc(const char * path, s32 fileType); // 8019f7dc
FileEntry * _fileAlloc(const char * path, s32 fileType, s32 p3); // 8019f7e4
void fileFree(FileEntry * entry); // 8019fa8c
void _fileGarbage(s32);
FileEntry * fileAllocf(s32 fileType, const char * format, ...);
FileEntry * fileAlloc(const char * path, s32 fileType);
FileEntry * _fileAlloc(const char * path, s32 fileType, s32 p3);
void fileFree(FileEntry * entry);
// dvdReadDoneCallback 8019fb38
FileEntry * fileAsyncf(s32 fileType, s32 p2, const char * format, ...); // 8019fc5c
FileEntry * fileAsync(const char * path, s32 fileType, s32 p3); // 8019fd24
#endif
FileEntry * fileAsyncf(s32 fileType, s32 p2, const char * format, ...);
FileEntry * fileAsync(const char * path, s32 fileType, s32 p3);

5
include/spm/fontmgr.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <common.h>
void fontmgrInit();

6
include/spm/framedrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void frameInit();
void frameMain();

View File

@ -1,5 +1,6 @@
#ifndef GUIDE_H
#define GUIDE_H
#pragma once
#include <common.h>
typedef struct
{
@ -8,6 +9,4 @@ typedef struct
u8 unknown_0x3[0xb4 - 0x3];
} GuideWork;
GuideWork * guideGetWork(); // 8011fa2c
#endif
GuideWork * guideGetWork();

23
include/spm/gxsub.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <common.h>
#include <spm/camdrv.h>
#include <wii/tpl.h>
void gxsubInit_Tpl(TPLHeader * tpl);
void gxsubDrawTextureMtx(u32 texId, Mtx34 * mtx, RGBA * colour);
void gxsubDrawTexture(u32 texId, f32 x, f32 y, f32 width, f32 height, RGBA * colour);
f32 gxsubGetTexWidth(u32 texId);
f32 gxsubGetTexHeight(u32 texId);
void gxsubEnableTexAlpha();
void gxsubInit();
void gxsubInit_Cam(CamEntry * camera);
void gxsubInit_Colour();
void gxsubDrawQuad(f32 x, f32 y, f32 width, f32 height, RGBA * colour);
void gxsubDrawQuadMtx(Mtx34 * mtx, f32 width, f32 height, RGBA * colour);
void gxsubDrawQuadGradient(f32 x, f32 y, f32 width, f32 height, RGBA * startColour, RGBA * endColour);
void gxsubDrawLineSquare(f32 x, f32 y, f32 width, f32 height, u32 thickness, RGBA * colour);
void gxsubDrawLineSquareMtx(Mtx34 * mtx, f32 width, f32 height, u32 thickness, RGBA * colour);
void gxsubDrawDottedLine(Mtx34 * mtx, f32 width, f32 height, u32 thickness, RGBA * colour);
void gxsubDrawLine(Mtx34 * mtx, f32 width, f32 height, u32 thickness, RGBA * colour);
void gxsubDrawSphere(Mtx34 * mtx, RGBA * colour);

View File

@ -1,15 +1,18 @@
#ifndef HITDRV_H
#define HITDRV_H
#pragma once
#include <common.h>
#include <wii/types.h>
#define HITOBJ_FLAG_DISABLE 1
void hitGrpFlagOn(bool allowSubname, const char * name, u32 mask); // 8006c4b4
void hitGrpFlagOff(bool allowSubname, const char * name, u32 mask); // 8006c6ac
void hitGetMapEntryBbox(int mapEntryIdx, Vec3 * min, Vec3 * max); // 800703b0
void hitObjGetPos(const char * name, Vec3 * ret); // 8006ffe4
bool hitCheckFilter(float, float, float, float, float, float, void *, float *, float *,
float *, float *, float *, float *, float *); // 8006ee2c
#endif
void hitInit();
void hitMain();
void hitRecalcMatrices();
void hitGrpFlagOn(bool allowSubname, const char * name, u32 mask);
void hitGrpFlagOff(bool allowSubname, const char * name, u32 mask);
void hitGetMapEntryBbox(s32 mapEntryIdx, Vec3 * min, Vec3 * max);
void hitObjGetPos(const char * name, Vec3 * ret);
bool hitCheckFilter(float, float, float, float, float, float, void *, float *, float *,
float *, float *, float *, float *, float *);

View File

@ -0,0 +1,7 @@
#pragma once
#include <common.h>
void homebuttonInit();
void homebuttonMain();
bool func_80242198();

12
include/spm/hud.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <common.h>
void hudInit();
void hudMain();
typedef void (CountdownDoneCb)();
void hudStartCountdown(u32 length, CountdownDoneCb * cb);
void func_8019af88();
void hudTurnOffFlipTimeBox(s32 idx);

6
include/spm/icondrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void iconInit();
void iconMain();

6
include/spm/imgdrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void imgInit();
void imgMain();

View File

@ -1,7 +1,7 @@
#ifndef ITEMDRV_H
#define ITEMDRV_H
#pragma once
#include <common.h>
#include <wii/types.h>
#define URA_DAN_KEY 44
#define DAN_KEY 48
@ -18,15 +18,15 @@ typedef struct
typedef struct
{
int num;
s32 num;
ItemEntry * entries;
u8 unknown_0x8[0x80 - 0x8];
} ItemWork;
ItemWork * itemGetWork(); // 80077660
ItemEntry * itemEntry(float x, float y, float z, const char * instanceName, int itemId,
int behaviour, void * pickupScript, int switchNumber); // 80078b3c
int itemTypeNameToId(const char * itemName); // 8007bccc
bool itemCheckForId(int itemId); // 8007d8b4
#endif
ItemWork * itemGetWork();
void itemInit();
void itemMain();
ItemEntry * itemEntry(float x, float y, float z, const char * instanceName, s32 itemId,
s32 behaviour, void * pickupScript, s32 switchNumber);
s32 itemTypeNameToId(const char * itemName);
bool itemCheckForId(s32 itemId);

6
include/spm/lightdrv.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <common.h>
void lightInit();
void lightMain();

5
include/spm/lz_texts.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <common.h>
extern u8 pitText[];

5
include/spm/main.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include <common.h>
int main(int argc, char ** argv);

View File

@ -1,15 +1,18 @@
#ifndef MAPDRV_H
#define MAPDRV_H
#pragma once
#include <common.h>
#define MAPOBJ_FLAG_HIDE 1
void mapGrpFlagOn(bool allowSubname, const char * name, u32 mask); // 8008cf30
void mapGrpFlagOff(bool allowSubname, const char * name, u32 mask); // 8008d2fc
void mapGrpFlag4On(bool allowSubname, const char * name, u32 mask); // 8008e11c
extern BOOL __mapdrv_make_dl;
void mapInit();
void mapMain();
void mapDisp();
void mapGrpFlagOn(bool allowSubname, const char * name, u32 mask);
void mapGrpFlagOff(bool allowSubname, const char * name, u32 mask);
void mapGrpFlag4On(bool allowSubname, const char * name, u32 mask);
void func_8008f2a4(const char *);
void func_8008f324(const char *);
#endif

View File

@ -1,7 +1,7 @@
#ifndef MARIO_H
#define MARIO_H
#pragma once
#include <common.h>
#include <wii/types.h>
enum PlayerCharacter
{
@ -11,7 +11,8 @@ enum PlayerCharacter
PLAYER_LUIGI
};
typedef struct {
typedef struct
{
u32 flag0;
u32 flag4;
u32 flag8;
@ -22,6 +23,12 @@ typedef struct {
u8 unknown_0x68[0x156c - 0x68];
} MarioWork;
MarioWork * marioGetPtr(); // 80121f48
#endif
void marioInit();
void marioMain();
MarioWork * marioGetPtr();
s32 marioTakeDamage(Vec3 * pos, u32 flags, s32 damage);
bool marioCtrlOffChk();
bool marioKeyOffChk();
bool func_8012dab0();

136
include/spm/mario_pouch.h Normal file
View File

@ -0,0 +1,136 @@
#pragma once
#include <common.h>
#define ITEM_ID_KEY_START 16
#define ITEM_ID_KEY_MAX 65
#define ITEM_ID_USE_START 65
#define ITEM_ID_USE_MAX 216
#define ITEM_ID_COOK_START 120
#define ITEM_ID_COOK_MAX 216
#define ITEM_ID_CHAR_START 216
#define ITEM_ID_CHAR_MAX 220
#define ITEM_ID_FAIRY_START 220
#define ITEM_ID_FAIRY_MAX 232
#define ITEM_ID_MAP_START 234
#define ITEM_ID_MAP_MAX 282
#define ITEM_ID_CARD_START 282
#define ITEM_ID_CARD_MAX 538
typedef struct
{
bool selectable;
bool selected;
s16 id;
} PouchCharOrPixlInfo;
typedef struct
{
s32 characterId;
s32 score;
u8 unknown_0x8[0x18 - 0x8];
} PouchMinigameScore;
typedef struct
{
u8 unknown_0x0[0x4 - 0x0]; // unused?
s32 level;
s32 attack;
s32 hp;
s32 maxHp;
s32 flipTimer;
s32 xp;
s32 coins;
s16 keyItem[32];
s16 useItem[10];
s16 shopItem[32];
PouchCharOrPixlInfo characters[4];
PouchCharOrPixlInfo pixls[16];
s32 shopPoints;
u32 shopPointRewardsCollected; // bit mask, index 1 << i
s8 catchCards[256]; // value is count, index is id - first card id
u8 unknown_0x20c[256];
u32 ownedMaps[2]; // [id / 32] & 1 << (id % 32)
u32 foundMaps[2]; // [id / 32] & 1 << (id % 32)
u32 knownRecipes[3]; // [id / 32] & 1 << (id % 32)
u32 knownCards[8]; // [id / 32] & 1 << (id % 32)
s32 charmsRemaining;
s32 killsBeforeNextCharm;
u8 unknown_0x350[0x368 - 0x350];
PouchMinigameScore minigameScores[4][5];
u8 unknown_0x548[0x688 - 0x548];
s32 arcadeTokens;
s32 totalCoinsCollected;
s32 maxJumpCombo;
s32 maxStylishCombo;
s32 enemiesDefeated;
u8 unknown_0x69c[0x6a0 - 0x69c]; // unused?
} MarioPouchWork;
typedef struct
{
u8 unknown_0x0[0x20 - 0x0];
} MarioPouchWork2;
MarioPouchWork * pouchGetPtr();
void pouchInit();
void pouchReInit();
void pouchMain();
void pouchResetFlip();
void pouchSetLevel(s32 level);
s32 pouchGetLevel();
s32 pouchGetNextLevelXp();
void pouchSetAttack(s32 attack);
s32 pouchGetAttack();
void pouchAddAttack(s32 increase);
void pouchSetHp(s32 hp);
s32 pouchGetHp();
void pouchAddHp(s32 increase);
void pouchSetMaxHp(s32 maxHp);
s32 pouchGetMaxHp();
s32 pouchGetXp();
void pouchAddXp(s32 increase);
void pouchSetCoin(s32 coins);
s32 pouchGetCoin();
void pouchAddTotalCoin(s32 increase); // inlined
void pouchAddCoin(s32 increase);
bool pouchAddItem(s16 itemId);
bool pouchCheckHaveItem(s16 itemId);
void pouchRemoveItem(s16 itemId);
void pouchRemoveItemIdx(s16 itemId, s32 idx);
bool pouchAddShopItem(s16 itemId);
void pouchRemoveShopItem(s16 itemId);
void pouchRemoveShopItemIdx(s16 itemId, s32 idx);
PouchCharOrPixlInfo * pouchGetCharInfo(s32 slot);
void pouchMakeCharSelectable(s16 itemId);
void pouchMakeCharNotSelectable(s16 itemId);
PouchCharOrPixlInfo * pouchGetPixlInfo(s32 slot);
void pouchMakePixlSelectable(s16 itemId);
void pouchMakePixlNotSelectable(s16 itemId);
bool pouchCheckPixlSelected(s16 itemId);
s16 pouchGetCurPixl();
void pouchSetPixlSelected(s16 itemId);
void pouchRegisterMapFound(s16 itemId);
void pouchRegisterRecipeKnown(s16 itemId);
bool pouchCheckRecipeKnown(s16 itemId);
s32 pouchGetCardCount(s16 itemId);
bool pouchCheckCardKnown(s16 itemId);
void pouchRegisterJumpCombo(s32 length);
void pouchRegisterStylishCombo(s32 length);
void pouchSetEnemiesDefeated(s32 count);
void pouchGetTotalCoinsCollected(s32 count);
s32 pouchGetMaxJumpCombo();
s32 pouchGetMaxStylishCombo();
s32 pouchGetEnemiesDefeated();
s32 pouchGetArcadeTokens();
void pouchSetArcadeTokens(s32 tokens);
s32 pouchCountUseItems();
s32 pouchCountKeyItems();
s32 pouchCountShopItems();
s32 pouchCountChars();
s32 pouchCountPixls();
s32 pouchCountPixlsNotSelected();
bool pouchCheckFreeUseItem();
s32 pouchCountMapsOwned();
s32 pouchCountRecipesKnown();
s32 pouchCountCardsKnown();

View File

@ -5,11 +5,10 @@
by structs instead of direct pointers, since the data location can change.
*/
#ifndef MEMORY_H
#define MEMORY_H
#pragma once
#include <common.h>
#include <mem.h>
#include <wii/mem.h>
#define MEM1_HEAP_COUNT 3
#define MEM2_HEAP_COUNT 6
@ -61,68 +60,73 @@ typedef struct
s32 size;
} HeapSize;
extern s32 g_bFirstSmartAlloc; // 805ae9ac
extern s32 g_bFirstSmartAlloc;
/*
Initialise heaps
*/
void memInit(); // 801a5dcc
void memInit();
/*
Clear the contents of a heap
*/
void memClear(s32 heapId); // 801a61e4
void memClear(s32 heapId);
/*
Allocate a block of memory from a heap
*/
void * __memAlloc(s32 heapId, size_t size); // 801a626c
void * __memAlloc(s32 heapId, size_t size);
/*
Free a block of memory back to a heap
*/
void __memFree(s32 heapId, void * ptr); // 801a62f0
void __memFree(s32 heapId, void * ptr);
/*
Initialise the smart heap (requires memInit to have ran)
*/
void smartInit(); // 801a6300
void smartInit();
/*
Frees all allocations of a certain type
Freeing type 3 also frees type 4
*/
void smartAutoFree(s32 type); // 801a64f4
void smartAutoFree(s32 type);
/*
Frees a smart allocation back to the smart heap
*/
void smartFree(SmartAllocation * lp); // 801a6598
void smartFree(SmartAllocation * lp);
/*
Allocates memory from the smart heap of a certain type
*/
SmartAllocation * smartAlloc(size_t size, u8 type); // 801a6794
SmartAllocation * smartAlloc(size_t size, u8 type);
/*
Moves allocations forwards in the heap where possible to collect empty space
into a larger block at the end
*/
void smartGarbage(); // 801a6b60
void smartGarbage();
/*
Sets up a GXTexObj with an image stored behind a smart allocation
*/
void * smartTexObj(void * texObj, SmartAllocation * imageAllocation); // 801a6cf0
void * smartTexObj(void * texObj, SmartAllocation * imageAllocation);
// New to SPM:
// 801a6d4c
// __dl__FPv 801a6e34
/*
C++ operator new
*/
void * __nw__FUl(size_t size);
/*
Frees a block of memory baack to heap 0
C++ operator delete
*/
void freeToHeap0(void * ptr); // 801a6e8c
void __dl__FPv(void * ptr);
#endif
/*
Frees a block of memory back to heap 0
*/
void __sys_free(void * ptr);

View File

@ -1,7 +1,7 @@
#ifndef MOBJDRV_H
#define MOBJDRV_H
#pragma once
#include <common.h>
#include <wii/types.h>
typedef struct
{
@ -10,6 +10,12 @@ typedef struct
u8 unknown_0x24[0x2a8 - 0x24];
} MOBJEntry;
MOBJEntry * mobjNameToPtr(const char * name); // 8002c834
void mobjInit();
#endif
// ...
void mobjMain();
// ...
MOBJEntry * mobjNameToPtr(const char * name);

Some files were not shown because too many files have changed in this diff Show More