From f579cdc89c04f084a14025d4a4ca7ea534702cef Mon Sep 17 00:00:00 2001 From: armstrca Date: Fri, 24 Apr 2026 18:08:07 -0500 Subject: [PATCH 1/2] reset commit history --- .clang-format | 236 +++ .github/workflows/build.yaml | 67 + .gitignore | 20 + .gitmodules | 9 + Dockerfile | 49 + Makefile | 74 + README.md | 69 + bin/cc1-psx-26.gz.sha256 | 1 + bin/cc1-psx-272.gz.sha256 | 1 + config/permuter_settings.toml | 7 + config/sym_battle_import.us.txt | 20 + config/sym_extern.us.txt | 49 + config/sym_ovl_export.us.txt | 2310 +++++++++++++++++++++++++++ config/symbols.batini.txt | 0 config/symbols.battle.txt | 18 + config/symbols.bginmenu.us.txt | 0 config/symbols.brom.us.txt | 0 config/symbols.cnfgmenu.us.txt | 5 + config/symbols.dschange.us.txt | 0 config/symbols.ending.us.txt | 1 + config/symbols.field.us.txt | 75 + config/symbols.magic-barrier.us.txt | 2 + config/symbols.main.us.txt | 449 ++++++ config/symbols.savemenu.us.txt | 6 + config/symbols.world.txt | 1 + config/us.yaml | 193 +++ diff_settings.py | 71 + expected/report/build | 1 + go.work | 3 + go.work.sum | 4 + include/common.h | 39 + include/game.h | 469 ++++++ include/gte.inc | 93 ++ include/macro.inc | 19 + include/psxsdk/kernel.h | 114 ++ include/psxsdk/libapi.h | 96 ++ include/psxsdk/libc.h | 18 + include/psxsdk/libcard.h | 7 + include/psxsdk/libcd.h | 169 ++ include/psxsdk/libetc.h | 70 + include/psxsdk/libgpu.h | 647 ++++++++ include/psxsdk/libgs.h | 48 + include/psxsdk/libgte.h | 160 ++ include/psxsdk/libpress.h | 1 + include/psxsdk/libsn.h | 8 + include/psxsdk/libsnd.h | 180 +++ include/psxsdk/libspu.h | 102 ++ include/psxsdk/romio.h | 35 + include/psxsdk/types.h | 36 + mako.sh | 2 + requirements.txt | 12 + src/battle/batini.c | 276 ++++ src/battle/battle.c | 1095 +++++++++++++ src/battle/battle.h | 366 +++++ src/battle/battle1.c | 1053 ++++++++++++ src/battle/battle2.c | 1233 ++++++++++++++ src/battle/battle3.c | 620 +++++++ src/battle/battle_private.h | 387 +++++ src/brom/brom.c | 15 + src/dschange/dschange.c | 5 + src/ending/ending.c | 125 ++ src/field/field.c | 1263 +++++++++++++++ src/magic/barrier.c | 253 +++ src/main/1255C.c | 408 +++++ src/main/18B8.c | 1295 +++++++++++++++ src/main/akao.c | 892 +++++++++++ src/main/main_private.h | 118 ++ src/main/ovl.c | 28 + src/main/psxsdk.c | 1178 ++++++++++++++ src/menu/bginmenu.c | 165 ++ src/menu/cnfgmenu.c | 267 ++++ src/menu/savemenu.c | 703 ++++++++ src/menu/savemenu.h | 91 ++ src/menu/title.c | 625 ++++++++ src/world/world.c | 1293 +++++++++++++++ src/world/world.h | 1 + src/world/world2.c | 41 + tools/asm-differ | 1 + tools/builder/builder/build.go | 90 ++ tools/builder/builder/clean.go | 37 + tools/builder/builder/config.go | 46 + tools/builder/builder/objdiff.go | 143 ++ tools/builder/builder/report.go | 39 + tools/builder/builder/splat.go | 125 ++ tools/builder/builder/version.go | 11 + tools/builder/cmd/build.go | 24 + tools/builder/cmd/clean.go | 24 + tools/builder/cmd/decompile.go | 30 + tools/builder/cmd/format.go | 22 + tools/builder/cmd/rank.go | 23 + tools/builder/cmd/report.go | 23 + tools/builder/cmd/root.go | 16 + tools/builder/cmd/symbols.go | 18 + tools/builder/cmd/symbolsadd.go | 57 + tools/builder/cmd/symbolssort.go | 21 + tools/builder/deps/certs.go | 25 + tools/builder/deps/exec.go | 122 ++ tools/builder/deps/exec_unix.go | 14 + tools/builder/deps/exec_windows.go | 14 + tools/builder/deps/setup.go | 140 ++ tools/builder/format/format.go | 95 ++ tools/builder/go.mod | 14 + tools/builder/go.sum | 14 + tools/builder/main.go | 15 + tools/builder/rank/rank.go | 201 +++ tools/builder/symbols/add.go | 23 + tools/builder/symbols/sort.go | 83 + tools/builder/utils/utils.go | 22 + tools/decompile.py | 247 +++ tools/docker-build.sh | 14 + tools/fix_structs.py | 150 ++ tools/import_data.py | 128 ++ tools/m2c | 1 + tools/m2ctx.py | 87 + tools/maspsx | 1 + tools/ninja/gen.py | 410 +++++ tools/ninja/ninja_syntax.py | 199 +++ tools/str.c | 212 +++ tools/symbols.py | 83 + 119 files changed, 22926 insertions(+) create mode 100644 .clang-format create mode 100644 .github/workflows/build.yaml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 bin/cc1-psx-26.gz.sha256 create mode 100644 bin/cc1-psx-272.gz.sha256 create mode 100644 config/permuter_settings.toml create mode 100644 config/sym_battle_import.us.txt create mode 100644 config/sym_extern.us.txt create mode 100644 config/sym_ovl_export.us.txt create mode 100644 config/symbols.batini.txt create mode 100644 config/symbols.battle.txt create mode 100644 config/symbols.bginmenu.us.txt create mode 100644 config/symbols.brom.us.txt create mode 100644 config/symbols.cnfgmenu.us.txt create mode 100644 config/symbols.dschange.us.txt create mode 100644 config/symbols.ending.us.txt create mode 100644 config/symbols.field.us.txt create mode 100644 config/symbols.magic-barrier.us.txt create mode 100644 config/symbols.main.us.txt create mode 100644 config/symbols.savemenu.us.txt create mode 100644 config/symbols.world.txt create mode 100644 config/us.yaml create mode 100644 diff_settings.py create mode 120000 expected/report/build create mode 100644 go.work create mode 100644 go.work.sum create mode 100644 include/common.h create mode 100644 include/game.h create mode 100644 include/gte.inc create mode 100644 include/macro.inc create mode 100644 include/psxsdk/kernel.h create mode 100644 include/psxsdk/libapi.h create mode 100644 include/psxsdk/libc.h create mode 100644 include/psxsdk/libcard.h create mode 100644 include/psxsdk/libcd.h create mode 100644 include/psxsdk/libetc.h create mode 100644 include/psxsdk/libgpu.h create mode 100644 include/psxsdk/libgs.h create mode 100644 include/psxsdk/libgte.h create mode 100644 include/psxsdk/libpress.h create mode 100644 include/psxsdk/libsn.h create mode 100644 include/psxsdk/libsnd.h create mode 100644 include/psxsdk/libspu.h create mode 100644 include/psxsdk/romio.h create mode 100644 include/psxsdk/types.h create mode 100755 mako.sh create mode 100644 requirements.txt create mode 100644 src/battle/batini.c create mode 100644 src/battle/battle.c create mode 100644 src/battle/battle.h create mode 100644 src/battle/battle1.c create mode 100644 src/battle/battle2.c create mode 100644 src/battle/battle3.c create mode 100644 src/battle/battle_private.h create mode 100644 src/brom/brom.c create mode 100644 src/dschange/dschange.c create mode 100644 src/ending/ending.c create mode 100644 src/field/field.c create mode 100644 src/magic/barrier.c create mode 100644 src/main/1255C.c create mode 100644 src/main/18B8.c create mode 100644 src/main/akao.c create mode 100644 src/main/main_private.h create mode 100644 src/main/ovl.c create mode 100644 src/main/psxsdk.c create mode 100644 src/menu/bginmenu.c create mode 100644 src/menu/cnfgmenu.c create mode 100644 src/menu/savemenu.c create mode 100644 src/menu/savemenu.h create mode 100644 src/menu/title.c create mode 100644 src/world/world.c create mode 100644 src/world/world.h create mode 100644 src/world/world2.c create mode 160000 tools/asm-differ create mode 100644 tools/builder/builder/build.go create mode 100644 tools/builder/builder/clean.go create mode 100644 tools/builder/builder/config.go create mode 100644 tools/builder/builder/objdiff.go create mode 100644 tools/builder/builder/report.go create mode 100644 tools/builder/builder/splat.go create mode 100644 tools/builder/builder/version.go create mode 100644 tools/builder/cmd/build.go create mode 100644 tools/builder/cmd/clean.go create mode 100644 tools/builder/cmd/decompile.go create mode 100644 tools/builder/cmd/format.go create mode 100644 tools/builder/cmd/rank.go create mode 100644 tools/builder/cmd/report.go create mode 100644 tools/builder/cmd/root.go create mode 100644 tools/builder/cmd/symbols.go create mode 100644 tools/builder/cmd/symbolsadd.go create mode 100644 tools/builder/cmd/symbolssort.go create mode 100644 tools/builder/deps/certs.go create mode 100644 tools/builder/deps/exec.go create mode 100644 tools/builder/deps/exec_unix.go create mode 100644 tools/builder/deps/exec_windows.go create mode 100644 tools/builder/deps/setup.go create mode 100644 tools/builder/format/format.go create mode 100644 tools/builder/go.mod create mode 100644 tools/builder/go.sum create mode 100644 tools/builder/main.go create mode 100644 tools/builder/rank/rank.go create mode 100644 tools/builder/symbols/add.go create mode 100644 tools/builder/symbols/sort.go create mode 100644 tools/builder/utils/utils.go create mode 100755 tools/decompile.py create mode 100755 tools/docker-build.sh create mode 100644 tools/fix_structs.py create mode 100755 tools/import_data.py create mode 160000 tools/m2c create mode 100644 tools/m2ctx.py create mode 160000 tools/maspsx create mode 100644 tools/ninja/gen.py create mode 100644 tools/ninja/ninja_syntax.py create mode 100644 tools/str.c create mode 100755 tools/symbols.py diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ba466f4 --- /dev/null +++ b/.clang-format @@ -0,0 +1,236 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: true + AcrossComments: true + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: Always +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakAfterAttributes: Leave +BreakArrays: true +BreakBeforeInlineASMColon: OnlyMultiline +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Left +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +PackConstructorInitializers: NextLine +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +IndentRequiresClause: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: true +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 1 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PenaltyIndentedWhitespace: 1 +PointerAlignment: Left +PPIndentWidth: -1 +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: ReturnStatement +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: Never +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceAroundPointerQualifiers: Before +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: 1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +BitFieldColonSpacing: Both +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..c15d101 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,67 @@ +name: build +on: + push: + pull_request_target: + workflow_dispatch: +permissions: + contents: read +jobs: + build: + # Building and testing cannot work if the repository owner is not Xeeynamo + # due to the missing secrets to clone the CI dependencies + if: github.repository == 'Xeeynamo/ff7-decomp' + runs-on: ubuntu-latest + steps: + - run: sudo apt-get install -y ninja-build 7zip + # Ubuntu 24.04 uses binutils 2.42, which ships a version of mipsel-linux-gnu-ld that does not match the game. + # Ubuntu 24.10 (binutils 2.42.90) and later fixes the issue + - run: | + echo "deb http://archive.ubuntu.com/ubuntu/ questing main universe multiverse restricted" | sudo tee /etc/apt/sources.list.d/questing.list + sudo apt-get update + sudo apt-get install -y -t questing binutils-mipsel-linux-gnu gcc-mipsel-linux-gnu + sudo rm /etc/apt/sources.list.d/questing.list + sudo apt-get clean + sudo rm -rf /var/lib/apt/lists/* + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + - if: github.event_name != 'pull_request_target' + uses: actions/checkout@v5 + with: + ref: ${{ github.ref }} + submodules: true + - if: github.event_name == 'pull_request_target' + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.sha }} + submodules: true + - uses: actions/setup-go@v6 + with: + go-version-file: 'go.work' + cache: true + cache-dependency-path: "**/*.sum" + - run: make requirements + - name: Check if code is formatted + run: | + make format + git diff --exit-code + - uses: actions/checkout@v5 + with: + repository: xeeynamo/ff7-decomp-dependencies + token: ${{ secrets.FF7_DECOMP_DEPENDENCIES_TOKEN }} + path: tmp + - run: | + cat tmp/x* > tmp/ff7.7z + 7z x -sdel tmp/ff7.7z -odisks/ + rm tmp/* + ls -la disks/ + - run: make build + - name: Generate progress report + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: make report + - name: Upload progress report + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + uses: actions/upload-artifact@v4 + with: + name: us_report + path: build/report.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..523511d --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +__pycache__/ +.idea/ +.venv/ +.vscode/ +asm/ +assets/ +bin/ +build/ +config/sym_export_battle.us.txt +disks/ +report/ +sym_export.*.txt +undefined_funcs_auto.*.txt +undefined_syms_auto.*.txt +.ninja_log +.ninja_lock +.ninja_deps +build.ninja +objdiff.json +/permute* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..60280c0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "tools/maspsx"] + path = tools/maspsx + url = https://github.com/mkst/maspsx.git +[submodule "tools/asm-differ"] + path = tools/asm-differ + url = https://github.com/simonlindholm/asm-differ.git +[submodule "tools/m2c"] + path = tools/m2c + url = https://github.com/matt-kempster/m2c.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..228d4fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,49 @@ +# HOW TO USE THIS DOCKERFILE +# +# 1. Build image (one time): +# docker build --platform=linux/amd64 --tag ff7-build:latest . +# +# 2. Run builds using the wrapper script (recommended): +# ./tools/docker-build.sh "make build" +# ./tools/docker-build.sh "make format" +# ./tools/docker-build.sh bash # interactive shell +# +# 3. Or run interactively and reuse the container: +# docker run --name ff7-work -it --platform=linux/amd64 \ +# -v $(pwd):/ff7 -v ff7_venv:/ff7/.venv -v ff7_build:/ff7/build \ +# -v go_cache:/gocache ff7-build +# # Then reattach with: docker start -ai ff7-work + +FROM ubuntu:noble + +RUN apt-get update && \ + apt-get install -y build-essential binutils make git python3 python3-venv ninja-build 7zip bchunk && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* +RUN echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ questing main universe multiverse restricted" > /etc/apt/sources.list.d/questing.list && \ + apt-get update && \ + apt-get install -y -t questing binutils-mipsel-linux-gnu gcc-mipsel-linux-gnu && \ + rm /etc/apt/sources.list.d/questing.list && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=golang:1.25-bookworm /usr/local/go/ /usr/local/go/ +ENV PATH="${PATH}:/usr/local/go/bin" +ENV GOMODCACHE=/gocache/mod +ENV GOCACHE=/gocache/build + +RUN mkdir -p /gocache/mod /gocache/build && chmod -R 777 /gocache + +USER ubuntu +WORKDIR /ff7 +COPY requirements.txt requirements.txt +RUN chown ubuntu:ubuntu /ff7 && \ + mkdir -p /ff7/.venv /ff7/build && \ + mkdir -p ~/go/bin && \ + ln -s /usr/local/go/bin/go ~/go/bin/go && \ + git config --global --add safe.directory /ff7 && \ + python3 -m venv .venv && \ + . .venv/bin/activate && \ + pip3 install -r requirements.txt + +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..03534c4 --- /dev/null +++ b/Makefile @@ -0,0 +1,74 @@ +OVL_US += BATTLE/BATINI.X +OVL_US += BATTLE/BATRES.X +OVL_US += BATTLE/BATTLE.X +OVL_US += BATTLE/BROM.X +OVL_US += FIELD/FIELD.BIN +OVL_US += MINI/CHOCOBO.BIN +OVL_US += WORLD/WORLD.BIN + +.PHONY: all +all: disks build + +.PHONY: build +build: bin/cc1-psx-26 bin/cc1-psx-272 bin/str disks/us/FIELD/FIELD.BIN.dec + @./mako.sh build + +disks/us/FIELD/FIELD.BIN.dec: + @for f in $(OVL_US); do \ + tail --bytes=+9 "disks/us/$$f" | gzip -cd > "disks/us/$$f.dec"; \ + done + +.PHONY: disks +disks: disks/us + +disks/%.iso: + bchunk "disks/$*.bin" "disks/$*.cue" "$@" + mv "disks/$*.iso01.iso" "$@" +disks/us: disks/Final\ Fantasy\ VII\ (USA)\ (Disc\ 1).iso + 7z x "$<" -o$@ +disks/betaus: disks/Final\ Fantasy\ VII\ (USA)\ (Interactive\ Sampler\ CD).iso + 7z x "$<" -o$@ + +.PHONY: clean +clean: + @./mako.sh clean + +.PHONY: format +format: + @./mako.sh format + +.PHONY: rebuild +rebuild: + @./mako.sh clean + @./mako.sh build + +.PHONY: submit +submit: + @./mako.sh clean + @./mako.sh build + @./mako.sh format + @git add config/ include/ src/ + +.PHONY: report +report: build + @./mako.sh report us build/report.json + +.PHONY: requirements +requirements: + python3 -m venv .venv + .venv/bin/pip3 install -r requirements.txt + +build/us/%.o: % + ninja $@ + +bin/str: tools/str.c + gcc -s -o $@ -O2 $< + chmod +x $@ + +bin/%: bin/%.gz + sha256sum --check $<.sha256 + gzip -kcd $< > $@ + touch $@ + chmod +x $@ +bin/%.gz: bin/%.gz.sha256 + wget -O $@ https://github.com/Xeeynamo/ff7-decomp/releases/download/init/$*.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf27921 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Final Fantasy VII decomp (PS1) + +## Contribute + +This project is open to contributors! +Decompiling a video game is a collaborative effort made possible by passionate people. + +* If you’d like to know more about how to contribute, feel free to reach out to me on Discord. +* New pull requests are always welcome! + +## Set-up + +Clone the repository: + +```shell +git clone git@github.com:Xeeynamo/ff7-decomp.git --recursive &&\ +cd ff7-decomp +``` + +Install the necessary dependencies: + +```shell +make requirements + +# Debian/Ubuntu +sudo add-apt-repository ppa:longsleep/golang-backports +sudo apt update +sudo apt install golang-go ninja-build 7zip bchunk binutils-mipsel-linux-gnu gcc-mipsel-linux-gnu + +# Arch Linux +sudo pacman -S go ninja 7zip bchunk +yay mipsel-linux-gnu-binutils mipsel-linux-gnu-gcc +``` + +Place the required disk images: + +```shell +'disks/Final Fantasy VII (USA) (Disc 1).bin' +'disks/Final Fantasy VII (USA) (Disc 1).cue' +'disks/Final Fantasy VII (USA) (Interactive Sampler CD).bin' # OPTIONAL! +'disks/Final Fantasy VII (USA) (Interactive Sampler CD).cue' # OPTIONAL! +``` + +## Tooling + +* `make build`: build project +* `make clean`: remove generated files from build +* `make format`: format codebase +* `./mako.sh rank `: find remaning functions to decompile sorted from easier to hardest +* `./mako.sh dec `: decompile function +* `./mako.sh symbols add [size]`: add or rename symbol + +## Game strings + +The game uses a custom character encoding instead of standard ASCII. +In this codebase, such strings are represented as `_S("Hello FF7!")`. + +To decode a FF7-style string into readable ASCII, use the included tool: + +```shell +# compile it at least once +make bin/str + +# specify an overlay and an offset in hex +bin/str disks/us/MENU/SAVEMENU.MNU 12DF8 + +# The program will print the decoded string to your terminal: +Saving. Do not remove Memory card. +``` diff --git a/bin/cc1-psx-26.gz.sha256 b/bin/cc1-psx-26.gz.sha256 new file mode 100644 index 0000000..ec6c7be --- /dev/null +++ b/bin/cc1-psx-26.gz.sha256 @@ -0,0 +1 @@ +dcb51631ec45b14c0a3afcafae6073c3ed5280910b7cce09631fc2fe1e037d90 bin/cc1-psx-26.gz diff --git a/bin/cc1-psx-272.gz.sha256 b/bin/cc1-psx-272.gz.sha256 new file mode 100644 index 0000000..0fa0411 --- /dev/null +++ b/bin/cc1-psx-272.gz.sha256 @@ -0,0 +1 @@ +1959ced957d8780489874de30d9af79a9154174624b8a00976f4a7f3fad87ac6 bin/cc1-psx-272.gz diff --git a/config/permuter_settings.toml b/config/permuter_settings.toml new file mode 100644 index 0000000..67d6df9 --- /dev/null +++ b/config/permuter_settings.toml @@ -0,0 +1,7 @@ +build_system = "ninja" +compiler_type = "gcc" + +[preserve_macros] +"g[DS]P.*" = "void" +"gDma.*" = "void" +"_SHIFTL" = "unsigned int" diff --git a/config/sym_battle_import.us.txt b/config/sym_battle_import.us.txt new file mode 100644 index 0000000..14f855b --- /dev/null +++ b/config/sym_battle_import.us.txt @@ -0,0 +1,20 @@ +func_801B0000 = 0x801B0000; +func_801B000C = 0x801B000C; +func_801B0038 = 0x801B0038; +func_801B0040 = 0x801B0040; +func_801B0050 = 0x801B0050; +func_801B0054 = 0x801B0054; +func_801B0060 = 0x801B0060; +func_801B0084 = 0x801B0084; +func_801B00B0 = 0x801B00B0; +func_801B00B4 = 0x801B00B4; +func_801B00D0 = 0x801B00D0; +func_801B00E8 = 0x801B00E8; +func_801B00F0 = 0x801B00F0; +func_801B0110 = 0x801B0110; +func_801B0130 = 0x801B0130; +func_801B0150 = 0x801B0150; +func_801B0170 = 0x801B0170; +func_801B037C = 0x801B037C; +func_801B0498 = 0x801B0498; +func_801B04C0 = 0x801B04C0; \ No newline at end of file diff --git a/config/sym_extern.us.txt b/config/sym_extern.us.txt new file mode 100644 index 0000000..6cb8c0c --- /dev/null +++ b/config/sym_extern.us.txt @@ -0,0 +1,49 @@ +D_800730CC = 0x800730CC; +D_8009A000 = 0x8009A000; +D_8009A004 = 0x8009A004; +D_8009A008 = 0x8009A008; +Savemap = 0x8009C6E4; +func_800A0000 = 0x800A0000; +func_800A0030 = 0x800A0030; +func_800A00BC = 0x800A00BC; +func_800A00D0 = 0x800A00D0; +func_800A02D0 = 0x800A02D0; +func_800A0390 = 0x800A0390; +func_800A0448 = 0x800A0448; +func_800A0450 = 0x800A0450; +func_800A04C4 = 0x800A04C4; +func_800A0C58 = 0x800A0C58; +func_800A16CC = 0x800A16CC; +func_800A3278 = 0x800A3278; +func_800A460C = 0x800A460C; +func_800A5E0C = 0x800A5E0C; +func_800A5F90 = 0x800A5F90; +func_800B6B58 = 0x800B6B58; +func_800B6D6C = 0x800B6D6C; +func_800CF60C = 0x800CF60C; +func_800D8D78 = 0x800D8D78; +func_801D131C = 0x801D131C; +func_801D1A6C = 0x801D1A6C; +func_801D4118 = 0x801D4118; +func_801D2D74 = 0x801D2D74; +func_801D2E84 = 0x801D2E84; +func_801D2F00 = 0x801D2F00; +func_801D3138 = 0x801D3138; +func_801D3018 = 0x801D3018; +func_801D3228 = 0x801D3228; +func_801D11A8 = 0x801D11A8; +func_800B1C7C = 0x800B1C7C; +func_800B2A00 = 0x800B2A00; +func_800B0EDC = 0x800B0EDC; +func_800B0618 = 0x800B0618; +func_800B2DD4 = 0x800B2DD4; +func_800B5260 = 0x800B5260; +func_800B480C = 0x800B480C; +func_800B4B04 = 0x800B4B04; +func_800B4EAC = 0x800B4EAC; +func_800B62C4 = 0x800B62C4; +func_800B6AE4 = 0x800B6AE4; +func_800B86D8 = 0x800B86D8; +func_800B6B4C = 0x800B6B4C; +func_800B9B0C = 0x800B9B0C; +func_801B0000_2 = 0x801B0000; \ No newline at end of file diff --git a/config/sym_ovl_export.us.txt b/config/sym_ovl_export.us.txt new file mode 100644 index 0000000..a0ca1ab --- /dev/null +++ b/config/sym_ovl_export.us.txt @@ -0,0 +1,2310 @@ +func_801B0050 = 0x801b0050; +func_801B0490 = 0x801b0490; +func_801B0668 = 0x801b0668; +func_801B085C = 0x801b085c; +func_801B08C0 = 0x801b08c0; +func_801B0F08 = 0x801b0f08; +func_801B1120 = 0x801b1120; +func_801B11BC = 0x801b11bc; +func_801B137C = 0x801b137c; +func_801B13DC = 0x801b13dc; +func_801B14E8 = 0x801b14e8; +func_801B1530 = 0x801b1530; +func_801B1598 = 0x801b1598; +func_801B1734 = 0x801b1734; +func_801B18F8 = 0x801b18f8; +func_801B19AC = 0x801b19ac; +func_801B1CB0 = 0x801b1cb0; +func_801B1E0C = 0x801b1e0c; +func_801B2308 = 0x801b2308; +func_801B2738 = 0x801b2738; +func_801B2770 = 0x801b2770; +BATTLE_EnqueueClearImage = 0x800d25c0; +BATTLE_EnqueueLoadImage = 0x800d2538; +BATTLE_EnqueueMoveImage = 0x800d2590; +BATTLE_EnqueueStoreImage = 0x800d2564; +BATTLE_FlushImageQueue = 0x800d25e8; +BATTLE_ResetImageQueue = 0x800d26f8; +D_800F38AC = 0x800f38ac; +D_800F3944 = 0x800f3944; +D_800F3948 = 0x800f3948; +D_800F394C = 0x800f394c; +D_800F3950 = 0x800f3950; +D_800F3954 = 0x800f3954; +D_800F3958 = 0x800f3958; +D_800F39D8 = 0x800f39d8; +D_800F39DC = 0x800f39dc; +D_800F39E0 = 0x800f39e0; +D_800F39E4 = 0x800f39e4; +D_800F39E8 = 0x800f39e8; +D_800F39EC = 0x800f39ec; +D_800F39F0 = 0x800f39f0; +D_800F39F1 = 0x800f39f1; +D_800F39F2 = 0x800f39f2; +D_800F39F5 = 0x800f39f5; +D_800F3A04 = 0x800f3a04; +D_800F3A05 = 0x800f3a05; +D_800F3A06 = 0x800f3a06; +D_800F3A07 = 0x800f3a07; +D_800F3A08 = 0x800f3a08; +D_800F3A09 = 0x800f3a09; +D_800F3A18 = 0x800f3a18; +D_800F3A1C = 0x800f3a1c; +D_800F3A20 = 0x800f3a20; +D_800F3A40 = 0x800f3a40; +D_800F3A42 = 0x800f3a42; +D_800F3A80 = 0x800f3a80; +D_800F4280 = 0x800f4280; +D_800F4300 = 0x800f4300; +D_800F4304 = 0x800f4304; +D_800F4308 = 0x800f4308; +D_800F4908 = 0x800f4908; +D_800F4914 = 0x800f4914; +D_800F4920 = 0x800f4920; +D_800F4924 = 0x800f4924; +D_800F4938 = 0x800f4938; +D_800F494C = 0x800f494c; +D_800F4958 = 0x800f4958; +D_800F495C = 0x800f495c; +D_800F499C = 0x800f499c; +D_800F49A0 = 0x800f49a0; +D_800F49A8 = 0x800f49a8; +D_800F49F8 = 0x800f49f8; +D_800F4A48 = 0x800f4a48; +D_800F4A70 = 0x800f4a70; +D_800F4A98 = 0x800f4a98; +D_800F4AC0 = 0x800f4ac0; +D_800F4AC4 = 0x800f4ac4; +D_800F4AC8 = 0x800f4ac8; +D_800F4ACC = 0x800f4acc; +D_800F4AD0 = 0x800f4ad0; +D_800F4AD4 = 0x800f4ad4; +D_800F4AD8 = 0x800f4ad8; +D_800F4AF4 = 0x800f4af4; +D_800F4AF8 = 0x800f4af8; +D_800F4B00 = 0x800f4b00; +D_800F4B04 = 0x800f4b04; +D_800F4B08 = 0x800f4b08; +D_800F4B0C = 0x800f4b0c; +D_800F4B10 = 0x800f4b10; +D_800F4B12 = 0x800f4b12; +D_800F4B14 = 0x800f4b14; +D_800F4B1C = 0x800f4b1c; +D_800F4B24 = 0x800f4b24; +D_800F4B26 = 0x800f4b26; +D_800F4B28 = 0x800f4b28; +D_800F4B2A = 0x800f4b2a; +D_800F4B2C = 0x800f4b2c; +D_800F4B6C = 0x800f4b6c; +D_800F4BAC = 0x800f4bac; +D_800F4CEC = 0x800f4cec; +D_800F4D2C = 0x800f4d2c; +D_800F4E6C = 0x800f4e6c; +D_800F4E70 = 0x800f4e70; +D_800F4E74 = 0x800f4e74; +D_800F4E78 = 0x800f4e78; +D_800F4E8C = 0x800f4e8c; +D_800F508C = 0x800f508c; +D_800F50AC = 0x800f50ac; +D_800F512C = 0x800f512c; +D_800F512F = 0x800f512f; +D_800F5133 = 0x800f5133; +D_800F514C = 0x800f514c; +D_800F514D = 0x800f514d; +D_800F514E = 0x800f514e; +D_800F514F = 0x800f514f; +D_800F5150 = 0x800f5150; +D_800F5151 = 0x800f5151; +D_800F5152 = 0x800f5152; +D_800F5153 = 0x800f5153; +D_800F5155 = 0x800f5155; +D_800F515F = 0x800f515f; +D_800F5160 = 0x800f5160; +D_800F5161 = 0x800f5161; +D_800F5164 = 0x800f5164; +D_800F5166 = 0x800f5166; +D_800F5167 = 0x800f5167; +D_800F5168 = 0x800f5168; +D_800F516C = 0x800f516c; +D_800F516F = 0x800f516f; +D_800F5173 = 0x800f5173; +D_800F5174 = 0x800f5174; +D_800F5176 = 0x800f5176; +D_800F5178 = 0x800f5178; +D_800F5179 = 0x800f5179; +D_800F517A = 0x800f517a; +D_800F517C = 0x800f517c; +D_800F517E = 0x800f517e; +D_800F5194 = 0x800f5194; +D_800F5197 = 0x800f5197; +D_800F519B = 0x800f519b; +D_800F519C = 0x800f519c; +D_800F519E = 0x800f519e; +D_800F51A0 = 0x800f51a0; +D_800F51A1 = 0x800f51a1; +D_800F51A4 = 0x800f51a4; +D_800F51A6 = 0x800f51a6; +D_800F51B0 = 0x800f51b0; +D_800F51B2 = 0x800f51b2; +D_800F51B4 = 0x800f51b4; +D_800F51B5 = 0x800f51b5; +D_800F51B8 = 0x800f51b8; +D_800F51BA = 0x800f51ba; +D_800F5234 = 0x800f5234; +D_800F5237 = 0x800f5237; +D_800F523B = 0x800f523b; +D_800F523C = 0x800f523c; +D_800F523E = 0x800f523e; +D_800F5240 = 0x800f5240; +D_800F5241 = 0x800f5241; +D_800F5244 = 0x800f5244; +D_800F5246 = 0x800f5246; +D_800F525C = 0x800f525c; +D_800F525F = 0x800f525f; +D_800F5263 = 0x800f5263; +D_800F526C = 0x800f526c; +D_800F526F = 0x800f526f; +D_800F5273 = 0x800f5273; +D_800F527C = 0x800f527c; +D_800F527F = 0x800f527f; +D_800F5283 = 0x800f5283; +D_800F528C = 0x800f528c; +D_800F528F = 0x800f528f; +D_800F5293 = 0x800f5293; +D_800F52AC = 0x800f52ac; +D_800F52AF = 0x800f52af; +D_800F52B3 = 0x800f52b3; +D_800F531C = 0x800f531c; +D_800F539C = 0x800f539c; +D_800F541C = 0x800f541c; +D_800F549C = 0x800f549c; +D_800F551C = 0x800f551c; +D_800F5522 = 0x800f5522; +D_800F5530 = 0x800f5530; +D_800F5533 = 0x800f5533; +D_800F5534 = 0x800f5534; +D_800F55D4 = 0x800f55d4; +D_800F55D8 = 0x800f55d8; +D_800F5628 = 0x800f5628; +D_800F562C = 0x800f562c; +D_800F5630 = 0x800f5630; +D_800F5634 = 0x800f5634; +D_800F5638 = 0x800f5638; +D_800F563C = 0x800f563c; +D_800F5740 = 0x800f5740; +D_800F5760 = 0x800f5760; +D_800F5764 = 0x800f5764; +D_800F5768 = 0x800f5768; +D_800F576C = 0x800f576c; +D_800F576D = 0x800f576d; +D_800F576E = 0x800f576e; +D_800F5770 = 0x800f5770; +D_800F5771 = 0x800f5771; +D_800F5774 = 0x800f5774; +D_800F5778 = 0x800f5778; +D_800F577B = 0x800f577b; +D_800F57CC = 0x800f57cc; +D_800F57D0 = 0x800f57d0; +D_800F57D4 = 0x800f57d4; +D_800F57D8 = 0x800f57d8; +D_800F57DC = 0x800f57dc; +D_800F57DE = 0x800f57de; +D_800F57EC = 0x800f57ec; +D_800F57EF = 0x800f57ef; +D_800F57F0 = 0x800f57f0; +D_800F5B70 = 0x800f5b70; +D_800F5B71 = 0x800f5b71; +D_800F5B72 = 0x800f5b72; +D_800F5B73 = 0x800f5b73; +D_800F5B74 = 0x800f5b74; +D_800F5BB8 = 0x800f5bb8; +D_800F5C84 = 0x800f5c84; +D_800F5E60 = 0x800f5e60; +D_800F5EFC = 0x800f5efc; +D_800F5F01 = 0x800f5f01; +D_800F5F44 = 0x800f5f44; +D_800F7DCC = 0x800f7dcc; +D_800F7DCE = 0x800f7dce; +D_800F7DD0 = 0x800f7dd0; +D_800F7DD2 = 0x800f7dd2; +D_800F7DD8 = 0x800f7dd8; +D_800F7DDA = 0x800f7dda; +D_800F7DDE = 0x800f7dde; +D_800F7DE0 = 0x800f7de0; +D_800F7DE2 = 0x800f7de2; +D_800F7DE4 = 0x800f7de4; +D_800F7DE8 = 0x800f7de8; +D_800F7DEC = 0x800f7dec; +D_800F7DF4 = 0x800f7df4; +D_800F7DF8 = 0x800f7df8; +D_800F7DFC = 0x800f7dfc; +D_800F7E00 = 0x800f7e00; +D_800F7E04 = 0x800f7e04; +D_800F7E08 = 0x800f7e08; +D_800F7E0A = 0x800f7e0a; +D_800F7E0C = 0x800f7e0c; +D_800F7E0E = 0x800f7e0e; +D_800F7E10 = 0x800f7e10; +D_800F7ED4 = 0x800f7ed4; +D_800F7ED8 = 0x800f7ed8; +D_800F7EDA = 0x800f7eda; +D_800F7EDC = 0x800f7edc; +D_800F7EDE = 0x800f7ede; +D_800F7EE0 = 0x800f7ee0; +D_800F7EE2 = 0x800f7ee2; +D_800F7EE4 = 0x800f7ee4; +D_800F7EE6 = 0x800f7ee6; +D_800F7EE8 = 0x800f7ee8; +D_800F7EF0 = 0x800f7ef0; +D_800F8158 = 0x800f8158; +D_800F8178 = 0x800f8178; +D_800F8180 = 0x800f8180; +D_800F8182 = 0x800f8182; +D_800F8184 = 0x800f8184; +D_800F818C = 0x800f818c; +D_800F81AC = 0x800f81ac; +D_800F81B0 = 0x800f81b0; +D_800F81B6 = 0x800f81b6; +D_800F81E2 = 0x800f81e2; +D_800F81E4 = 0x800f81e4; +D_800F81EA = 0x800f81ea; +D_800F81EC = 0x800f81ec; +D_800F8214 = 0x800f8214; +D_800F8216 = 0x800f8216; +D_800F8218 = 0x800f8218; +D_800F821E = 0x800f821e; +D_800F8220 = 0x800f8220; +D_800F8248 = 0x800f8248; +D_800F8252 = 0x800f8252; +D_800F8254 = 0x800f8254; +D_800F8288 = 0x800f8288; +D_800F82BC = 0x800f82bc; +D_800F82F0 = 0x800f82f0; +D_800F8324 = 0x800f8324; +D_800F8360 = 0x800f8360; +D_800F8364 = 0x800f8364; +D_800F8368 = 0x800f8368; +D_800F836C = 0x800f836c; +D_800F8370 = 0x800f8370; +D_800F8374 = 0x800f8374; +D_800F8378 = 0x800f8378; +D_800F837C = 0x800f837c; +D_800F8380 = 0x800f8380; +D_800F8384 = 0x800f8384; +D_800F8390 = 0x800f8390; +D_800F8394 = 0x800f8394; +D_800F8398 = 0x800f8398; +D_800F839C = 0x800f839c; +D_800F83A4 = 0x800f83a4; +D_800F83A5 = 0x800f83a5; +D_800F83A6 = 0x800f83a6; +D_800F83AB = 0x800f83ab; +D_800F83AE = 0x800f83ae; +D_800F83B0 = 0x800f83b0; +D_800F83B2 = 0x800f83b2; +D_800F83B4 = 0x800f83b4; +D_800F83B6 = 0x800f83b6; +D_800F83B8 = 0x800f83b8; +D_800F83BA = 0x800f83ba; +D_800F83BC = 0x800f83bc; +D_800F83BE = 0x800f83be; +D_800F83C0 = 0x800f83c0; +D_800F83C6 = 0x800f83c6; +D_800F83C8 = 0x800f83c8; +D_800F83CC = 0x800f83cc; +D_800F83CE = 0x800f83ce; +D_800F83D0 = 0x800f83d0; +D_800F83D8 = 0x800f83d8; +D_800F83DC = 0x800f83dc; +D_800F83E0 = 0x800f83e0; +D_800F8518 = 0x800f8518; +D_800F8584 = 0x800f8584; +D_800F87F0 = 0x800f87f0; +D_800F87F4 = 0x800f87f4; +D_800F8CF0 = 0x800f8cf0; +D_800F8CF4 = 0x800f8cf4; +D_800F8E74 = 0x800f8e74; +D_800F90B4 = 0x800f90b4; +D_800F90BE = 0x800f90be; +D_800F90BF = 0x800f90bf; +D_800F90C6 = 0x800f90c6; +D_800F90C8 = 0x800f90c8; +D_800F90D1 = 0x800f90d1; +D_800F90D8 = 0x800f90d8; +D_800F90DA = 0x800f90da; +D_800F90E2 = 0x800f90e2; +D_800F90E3 = 0x800f90e3; +D_800F90EA = 0x800f90ea; +D_800F90EC = 0x800f90ec; +D_800F90F4 = 0x800f90f4; +D_800F90F5 = 0x800f90f5; +D_800F90FC = 0x800f90fc; +D_800F90FE = 0x800f90fe; +D_800F9100 = 0x800f9100; +D_800F9102 = 0x800f9102; +D_800F9104 = 0x800f9104; +D_800F9106 = 0x800f9106; +D_800F9107 = 0x800f9107; +D_800F9108 = 0x800f9108; +D_800F9109 = 0x800f9109; +D_800F910A = 0x800f910a; +D_800F910B = 0x800f910b; +D_800F910C = 0x800f910c; +D_800F910D = 0x800f910d; +D_800F910E = 0x800f910e; +D_800F9119 = 0x800f9119; +D_800F912B = 0x800f912b; +D_800F9132 = 0x800f9132; +D_800F913C = 0x800f913c; +D_800F9144 = 0x800f9144; +D_800F914E = 0x800f914e; +D_800F92E2 = 0x800f92e2; +D_800F92E4 = 0x800f92e4; +D_800F92E6 = 0x800f92e6; +D_800F92E8 = 0x800f92e8; +D_800F92EA = 0x800f92ea; +D_800F92EC = 0x800f92ec; +D_800F92ED = 0x800f92ed; +D_800F92EE = 0x800f92ee; +D_800F92EF = 0x800f92ef; +D_800F92F0 = 0x800f92f0; +D_800F92F1 = 0x800f92f1; +D_800F92F2 = 0x800f92f2; +D_800F92F3 = 0x800f92f3; +D_800F9774 = 0x800f9774; +D_800F977C = 0x800f977c; +D_800F9780 = 0x800f9780; +D_800F9980 = 0x800f9980; +D_800F9984 = 0x800f9984; +D_800F99E4 = 0x800f99e4; +D_800F99E8 = 0x800f99e8; +D_800F99EC = 0x800f99ec; +D_800F99EE = 0x800f99ee; +D_800F99F0 = 0x800f99f0; +D_800F99F2 = 0x800f99f2; +D_800F99F4 = 0x800f99f4; +D_800F99F6 = 0x800f99f6; +D_800F9D94 = 0x800f9d94; +D_800F9D98 = 0x800f9d98; +D_800F9D9C = 0x800f9d9c; +D_800F9DA0 = 0x800f9da0; +D_800F9DA4 = 0x800f9da4; +D_800F9DA8 = 0x800f9da8; +D_800F9DAA = 0x800f9daa; +D_800F9DAC = 0x800f9dac; +D_800F9DAD = 0x800f9dad; +D_800F9F28 = 0x800f9f28; +D_800F9F30 = 0x800f9f30; +D_800F9F34 = 0x800f9f34; +D_800F9F3C = 0x800f9f3c; +D_800F9F3E = 0x800f9f3e; +D_800F9F40 = 0x800f9f40; +D_800F9F42 = 0x800f9f42; +D_800F9F44 = 0x800f9f44; +D_800F9F46 = 0x800f9f46; +D_800F9F48 = 0x800f9f48; +D_800F9F4C = 0x800f9f4c; +D_800F9F4E = 0x800f9f4e; +D_800F9F54 = 0x800f9f54; +D_800F9F56 = 0x800f9f56; +D_800F9F5A = 0x800f9f5a; +D_800F9F5C = 0x800f9f5c; +D_800F9F62 = 0x800f9f62; +D_800F9F64 = 0x800f9f64; +D_800F9F68 = 0x800f9f68; +D_800F9F6A = 0x800f9f6a; +D_800F9F70 = 0x800f9f70; +D_800F9F72 = 0x800f9f72; +D_800F9F76 = 0x800f9f76; +D_800F9F78 = 0x800f9f78; +D_800F9F7E = 0x800f9f7e; +D_800F9F80 = 0x800f9f80; +D_800FA63C = 0x800fa63c; +D_800FA674 = 0x800fa674; +D_800FA676 = 0x800fa676; +D_800FA678 = 0x800fa678; +D_800FA67A = 0x800fa67a; +D_800FA67C = 0x800fa67c; +D_800FA67E = 0x800fa67e; +D_800FA680 = 0x800fa680; +D_800FA682 = 0x800fa682; +D_800FA684 = 0x800fa684; +D_800FA686 = 0x800fa686; +D_800FA688 = 0x800fa688; +D_800FA68A = 0x800fa68a; +D_800FA69C = 0x800fa69c; +D_800FA6A0 = 0x800fa6a0; +D_800FA6B8 = 0x800fa6b8; +D_800FA6D0 = 0x800fa6d0; +D_800FA6D4 = 0x800fa6d4; +D_800FA6D8 = 0x800fa6d8; +D_800FA780 = 0x800fa780; +D_800FA958 = 0x800fa958; +D_800FA978 = 0x800fa978; +D_800FA9B8 = 0x800fa9b8; +D_800FA9BC = 0x800fa9bc; +D_800FA9C0 = 0x800fa9c0; +D_800FA9C4 = 0x800fa9c4; +D_800FA9C6 = 0x800fa9c6; +D_800FA9C8 = 0x800fa9c8; +D_800FA9CA = 0x800fa9ca; +D_800FA9CC = 0x800fa9cc; +D_800FA9CE = 0x800fa9ce; +D_800FA9D0 = 0x800fa9d0; +D_800FA9D1 = 0x800fa9d1; +D_800FA9D2 = 0x800fa9d2; +D_800FA9D3 = 0x800fa9d3; +D_800FA9D4 = 0x800fa9d4; +D_800FA9D8 = 0x800fa9d8; +D_800FA9DC = 0x800fa9dc; +D_800FA9E8 = 0x800fa9e8; +D_800FA9EA = 0x800fa9ea; +D_800FA9EB = 0x800fa9eb; +D_800FA9EC = 0x800fa9ec; +D_800FA9F4 = 0x800fa9f4; +D_800FAA00 = 0x800faa00; +D_800FAA02 = 0x800faa02; +D_800FAA03 = 0x800faa03; +D_800FAA04 = 0x800faa04; +D_800FAA0C = 0x800faa0c; +D_800FAA18 = 0x800faa18; +D_800FAA1A = 0x800faa1a; +D_800FAA1B = 0x800faa1b; +D_800FAA1C = 0x800faa1c; +D_800FAA24 = 0x800faa24; +D_800FAA30 = 0x800faa30; +D_800FAA32 = 0x800faa32; +D_800FAA33 = 0x800faa33; +D_800FAA34 = 0x800faa34; +D_800FAA3C = 0x800faa3c; +D_800FAA48 = 0x800faa48; +D_800FAA4A = 0x800faa4a; +D_800FAA4B = 0x800faa4b; +D_800FAA4C = 0x800faa4c; +D_800FAA54 = 0x800faa54; +D_800FAFD4 = 0x800fafd4; +D_800FAFD8 = 0x800fafd8; +D_800FAFDC = 0x800fafdc; +D_800FAFE0 = 0x800fafe0; +D_800FAFE4 = 0x800fafe4; +D_800FAFE8 = 0x800fafe8; +D_800FAFEC = 0x800fafec; +D_800FAFF0 = 0x800faff0; +D_800FAFF4 = 0x800faff4; +D_800FAFFA = 0x800faffa; +D_800FB00A = 0x800fb00a; +D_800FB00B = 0x800fb00b; +D_800FB00C = 0x800fb00c; +D_800FB00D = 0x800fb00d; +D_800FB00E = 0x800fb00e; +D_800FB00F = 0x800fb00f; +D_800FB064 = 0x800fb064; +D_800FF060 = 0x800ff060; +D_800FF064 = 0x800ff064; +D_800FF068 = 0x800ff068; +D_800FF06C = 0x800ff06c; +D_800FF070 = 0x800ff070; +D_800FF074 = 0x800ff074; +D_800FF094 = 0x800ff094; +D_800FF098 = 0x800ff098; +D_800FF0D4 = 0x800ff0d4; +D_800FF0D8 = 0x800ff0d8; +D_800FF0DC = 0x800ff0dc; +D_800FF0E0 = 0x800ff0e0; +D_800FF0EA = 0x800ff0ea; +D_800FF0EE = 0x800ff0ee; +D_800FF0FE = 0x800ff0fe; +D_800FF0FF = 0x800ff0ff; +D_800FF100 = 0x800ff100; +D_800FF101 = 0x800ff101; +D_800FF102 = 0x800ff102; +D_800FF103 = 0x800ff103; +D_800FF813 = 0x800ff813; +D_800FF8AC = 0x800ff8ac; +D_800FF8E9 = 0x800ff8e9; +D_80103154 = 0x80103154; +D_80103158 = 0x80103158; +D_80103160 = 0x80103160; +D_80103188 = 0x80103188; +D_801031CC = 0x801031cc; +D_801031D4 = 0x801031d4; +D_801031E0 = 0x801031e0; +D_801031E4 = 0x801031e4; +D_801031E8 = 0x801031e8; +D_801031EA = 0x801031ea; +D_801031EC = 0x801031ec; +D_801031F0 = 0x801031f0; +D_801031F4 = 0x801031f4; +D_80103200 = 0x80103200; +D_80130200 = 0x80130200; +D_80132580 = 0x80132580; +D_80151200 = 0x80151200; +D_8015135C = 0x8015135c; +D_80151360 = 0x80151360; +D_80151362 = 0x80151362; +D_80151364 = 0x80151364; +D_80151366 = 0x80151366; +D_8015138A = 0x8015138a; +D_8015138C = 0x8015138c; +D_8015138F = 0x8015138f; +D_801513DC = 0x801513dc; +D_80151688 = 0x80151688; +D_80151694 = 0x80151694; +D_80151698 = 0x80151698; +D_8015169C = 0x8015169c; +D_801516A0 = 0x801516a0; +D_801516A4 = 0x801516a4; +D_801516CC = 0x801516cc; +D_801516F4 = 0x801516f4; +D_801516F8 = 0x801516f8; +D_801516FC = 0x801516fc; +D_801516FE = 0x801516fe; +D_80151700 = 0x80151700; +D_80151702 = 0x80151702; +D_8015174C = 0x8015174c; +D_80151774 = 0x80151774; +D_80151778 = 0x80151778; +D_8015177A = 0x8015177a; +D_8015177C = 0x8015177c; +D_80151780 = 0x80151780; +D_8015178C = 0x8015178c; +D_801517B4 = 0x801517b4; +D_801517B8 = 0x801517b8; +D_801517BC = 0x801517bc; +D_801517C0 = 0x801517c0; +D_801517C4 = 0x801517c4; +D_801517C8 = 0x801517c8; +D_801517F0 = 0x801517f0; +D_80151840 = 0x80151840; +D_80151844 = 0x80151844; +D_80151846 = 0x80151846; +D_80151848 = 0x80151848; +D_8015184C = 0x8015184c; +D_8015184E = 0x8015184e; +D_80151850 = 0x80151850; +D_80151851 = 0x80151851; +D_8015185A = 0x8015185a; +D_80151868 = 0x80151868; +D_8015186E = 0x8015186e; +D_80151870 = 0x80151870; +D_80151872 = 0x80151872; +D_80151876 = 0x80151876; +D_8015187C = 0x8015187c; +D_801518A4 = 0x801518a4; +D_801518A6 = 0x801518a6; +D_801518A8 = 0x801518a8; +D_801518AC = 0x801518ac; +D_801518AE = 0x801518ae; +D_801518B0 = 0x801518b0; +D_801518BA = 0x801518ba; +D_801518C8 = 0x801518c8; +D_801518CE = 0x801518ce; +D_801518D0 = 0x801518d0; +D_801518D2 = 0x801518d2; +D_801518D6 = 0x801518d6; +D_801518DC = 0x801518dc; +D_801518E0 = 0x801518e0; +D_801518E4 = 0x801518e4; +D_80156A28 = 0x80156a28; +D_80156A3E = 0x80156a3e; +D_801575DA = 0x801575da; +D_80158176 = 0x80158176; +D_80158CFC = 0x80158cfc; +D_80158D00 = 0x80158d00; +D_80158D02 = 0x80158d02; +D_80158D04 = 0x80158d04; +D_80158D08 = 0x80158d08; +D_80158D0C = 0x80158d0c; +D_801590CC = 0x801590cc; +D_801590D0 = 0x801590d0; +D_801590D4 = 0x801590d4; +D_801590D8 = 0x801590d8; +D_801590DC = 0x801590dc; +D_801590E0 = 0x801590e0; +D_801590E4 = 0x801590e4; +D_801590E8 = 0x801590e8; +D_801590EC = 0x801590ec; +D_8015E1E8 = 0x8015e1e8; +D_80161DE8 = 0x80161de8; +D_80161EEC = 0x80161eec; +D_80161EF0 = 0x80161ef0; +D_80162080 = 0x80162080; +D_80162084 = 0x80162084; +D_80162088 = 0x80162088; +D_8016208C = 0x8016208c; +D_80162090 = 0x80162090; +D_80162094 = 0x80162094; +D_80162098 = 0x80162098; +D_8016209C = 0x8016209c; +D_801620A0 = 0x801620a0; +D_801620A4 = 0x801620a4; +D_801620AC = 0x801620ac; +D_801621EC = 0x801621ec; +D_801621F0 = 0x801621f0; +D_80162970 = 0x80162970; +D_80162974 = 0x80162974; +D_80162978 = 0x80162978; +D_801635F8 = 0x801635f8; +D_801635FC = 0x801635fc; +D_80163600 = 0x80163600; +D_80163604 = 0x80163604; +D_80163608 = 0x80163608; +D_8016360C = 0x8016360c; +D_801636B8 = 0x801636b8; +D_80163758 = 0x80163758; +D_8016375A = 0x8016375a; +D_8016375C = 0x8016375c; +D_8016375E = 0x8016375e; +D_80163762 = 0x80163762; +D_80163766 = 0x80163766; +D_80163768 = 0x80163768; +D_8016376A = 0x8016376a; +D_8016376C = 0x8016376c; +D_8016376E = 0x8016376e; +D_80163770 = 0x80163770; +D_80163772 = 0x80163772; +D_80163774 = 0x80163774; +D_80163777 = 0x80163777; +D_80163778 = 0x80163778; +D_80163780 = 0x80163780; +D_80163784 = 0x80163784; +D_80163787 = 0x80163787; +D_80163788 = 0x80163788; +D_8016378C = 0x8016378c; +D_80163790 = 0x80163790; +D_80163798 = 0x80163798; +D_80163A98 = 0x80163a98; +D_80163ABC = 0x80163abc; +D_80163ABE = 0x80163abe; +D_80163AC0 = 0x80163ac0; +D_80163AC4 = 0x80163ac4; +D_80163AC6 = 0x80163ac6; +D_80163AC8 = 0x80163ac8; +D_80163ACC = 0x80163acc; +D_80163B38 = 0x80163b38; +D_80163B3C = 0x80163b3c; +D_80163B44 = 0x80163b44; +D_80163B46 = 0x80163b46; +D_80163B48 = 0x80163b48; +D_80163B70 = 0x80163b70; +D_80163B7C = 0x80163b7c; +D_80163B80 = 0x80163b80; +D_80163B84 = 0x80163b84; +D_80163C74 = 0x80163c74; +D_80163C78 = 0x80163c78; +D_80163C7C = 0x80163c7c; +D_80163C80 = 0x80163c80; +D_80163C8C = 0x80163c8c; +D_80163C9C = 0x80163c9c; +D_80163CC0 = 0x80163cc0; +D_80163CC2 = 0x80163cc2; +D_80163CC4 = 0x80163cc4; +func_800A1158 = 0x800a1158; +func_800A1798 = 0x800a1798; +func_800A22C0 = 0x800a22c0; +func_800A23BC = 0x800a23bc; +func_800A23E0 = 0x800a23e0; +func_800A283C = 0x800a283c; +func_800A2894 = 0x800a2894; +func_800A2974 = 0x800a2974; +func_800A2B28 = 0x800a2b28; +func_800A2BF4 = 0x800a2bf4; +func_800A2CC4 = 0x800a2cc4; +func_800A2D0C = 0x800a2d0c; +func_800A2D68 = 0x800a2d68; +func_800A2DB0 = 0x800a2db0; +func_800A2EFC = 0x800a2efc; +func_800A2F24 = 0x800a2f24; +func_800A2F4C = 0x800a2f4c; +func_800A2FD0 = 0x800a2fd0; +func_800A304C = 0x800a304c; +func_800A311C = 0x800a311c; +func_800A317C = 0x800a317c; +func_800A31A0 = 0x800a31a0; +func_800A3208 = 0x800a3208; +func_800A3240 = 0x800a3240; +func_800A329C = 0x800a329c; +func_800A32C0 = 0x800a32c0; +func_800A3354 = 0x800a3354; +func_800A345C = 0x800a345c; +func_800A3488 = 0x800a3488; +func_800A34CC = 0x800a34cc; +func_800A3534 = 0x800a3534; +func_800A35F8 = 0x800a35f8; +func_800A37F8 = 0x800a37f8; +func_800A3828 = 0x800a3828; +func_800A38FC = 0x800a38fc; +func_800A3D4C = 0x800a3d4c; +func_800A3E98 = 0x800a3e98; +func_800A3ED0 = 0x800a3ed0; +func_800A4350 = 0x800a4350; +func_800A4480 = 0x800a4480; +func_800A44D8 = 0x800a44d8; +func_800A4540 = 0x800a4540; +func_800A4844 = 0x800a4844; +func_800A4860 = 0x800a4860; +func_800A4954 = 0x800a4954; +func_800A4A80 = 0x800a4a80; +func_800A4ACC = 0x800a4acc; +func_800A4AF4 = 0x800a4af4; +func_800A4B3C = 0x800a4b3c; +func_800A4B9C = 0x800a4b9c; +func_800A4BA4 = 0x800a4ba4; +func_800A4CA8 = 0x800a4ca8; +func_800A4CC8 = 0x800a4cc8; +func_800A4D2C = 0x800a4d2c; +func_800A4D88 = 0x800a4d88; +func_800A4E00 = 0x800a4e00; +func_800A4E40 = 0x800a4e40; +func_800A4E80 = 0x800a4e80; +func_800A4F14 = 0x800a4f14; +func_800A4F60 = 0x800a4f60; +func_800A50E0 = 0x800a50e0; +func_800A5250 = 0x800a5250; +func_800A555C = 0x800a555c; +func_800A55BC = 0x800a55bc; +func_800A55F4 = 0x800a55f4; +func_800A5660 = 0x800a5660; +func_800A56B0 = 0x800a56b0; +func_800A5750 = 0x800a5750; +func_800A5990 = 0x800a5990; +func_800A5A5C = 0x800a5a5c; +func_800A5A88 = 0x800a5a88; +func_800A5AA8 = 0x800a5aa8; +func_800A5AC8 = 0x800a5ac8; +func_800A5BC8 = 0x800a5bc8; +func_800A5EB0 = 0x800a5eb0; +func_800A5FB0 = 0x800a5fb0; +func_800A6000 = 0x800a6000; +func_800A61D4 = 0x800a61d4; +func_800A6278 = 0x800a6278; +func_800A64A0 = 0x800a64a0; +func_800A64B4 = 0x800a64b4; +func_800A653C = 0x800a653c; +func_800A6590 = 0x800a6590; +func_800A65B0 = 0x800a65b0; +func_800A661C = 0x800a661c; +func_800A66A4 = 0x800a66a4; +func_800A6720 = 0x800a6720; +func_800A6748 = 0x800a6748; +func_800A6798 = 0x800a6798; +func_800A67B8 = 0x800a67b8; +func_800A6834 = 0x800a6834; +func_800A6858 = 0x800a6858; +func_800A68FC = 0x800a68fc; +func_800A6A3C = 0x800a6a3c; +func_800A6A70 = 0x800a6a70; +func_800A6AC4 = 0x800a6ac4; +func_800A6B1C = 0x800a6b1c; +func_800A6B88 = 0x800a6b88; +func_800A6BFC = 0x800a6bfc; +func_800A6C04 = 0x800a6c04; +func_800A6C5C = 0x800a6c5c; +func_800A6CC0 = 0x800a6cc0; +func_800A6D10 = 0x800a6d10; +func_800A6D3C = 0x800a6d3c; +func_800A6D88 = 0x800a6d88; +func_800A6DFC = 0x800a6dfc; +func_800A6E04 = 0x800a6e04; +func_800A6E0C = 0x800a6e0c; +func_800A6E6C = 0x800a6e6c; +func_800A6E9C = 0x800a6e9c; +func_800A7034 = 0x800a7034; +func_800A7060 = 0x800a7060; +func_800A7090 = 0x800a7090; +func_800A70C4 = 0x800a70c4; +func_800A7130 = 0x800a7130; +func_800A71E0 = 0x800a71e0; +func_800A71E8 = 0x800a71e8; +func_800A71F4 = 0x800a71f4; +func_800A7254 = 0x800a7254; +func_800A72C8 = 0x800a72c8; +func_800A73C0 = 0x800a73c0; +func_800A73D8 = 0x800a73d8; +func_800A73F8 = 0x800a73f8; +func_800A7458 = 0x800a7458; +func_800A7560 = 0x800a7560; +func_800A76AC = 0x800a76ac; +func_800A76CC = 0x800a76cc; +func_800A7784 = 0x800a7784; +func_800A778C = 0x800a778c; +func_800A784C = 0x800a784c; +func_800A7940 = 0x800a7940; +func_800A795C = 0x800a795c; +func_800A7988 = 0x800a7988; +func_800A79A8 = 0x800a79a8; +func_800A79CC = 0x800a79cc; +func_800A80DC = 0x800a80dc; +func_800A81B8 = 0x800a81b8; +func_800A8424 = 0x800a8424; +func_800A8528 = 0x800a8528; +func_800A853C = 0x800a853c; +func_800A85A0 = 0x800a85a0; +func_800A85B4 = 0x800a85b4; +func_800A85FC = 0x800a85fc; +func_800A866C = 0x800a866c; +func_800A8A6C = 0x800a8a6c; +func_800A8C94 = 0x800a8c94; +func_800A8CC8 = 0x800a8cc8; +func_800A8D04 = 0x800a8d04; +func_800A8D18 = 0x800a8d18; +func_800A8D60 = 0x800a8d60; +func_800A8DCC = 0x800a8dcc; +func_800A8E34 = 0x800a8e34; +func_800A8E54 = 0x800a8e54; +func_800A8E84 = 0x800a8e84; +func_800A9DA0 = 0x800a9da0; +func_800AA1C8 = 0x800aa1c8; +func_800AA574 = 0x800aa574; +func_800AA688 = 0x800aa688; +func_800AA6E8 = 0x800aa6e8; +func_800AA738 = 0x800aa738; +func_800AA950 = 0x800aa950; +func_800AABBC = 0x800aabbc; +func_800AB308 = 0x800ab308; +func_800AB480 = 0x800ab480; +func_800AB674 = 0x800ab674; +func_800AB788 = 0x800ab788; +func_800AB830 = 0x800ab830; +func_800AB9C4 = 0x800ab9c4; +func_800ABA68 = 0x800aba68; +func_800ABB0C = 0x800abb0c; +func_800AC6B4 = 0x800ac6b4; +func_800AC73C = 0x800ac73c; +func_800ACA24 = 0x800aca24; +func_800ACA4C = 0x800aca4c; +func_800ACB98 = 0x800acb98; +func_800ACD88 = 0x800acd88; +func_800ACE14 = 0x800ace14; +func_800ACE88 = 0x800ace88; +func_800AD088 = 0x800ad088; +func_800AD0FC = 0x800ad0fc; +func_800AD324 = 0x800ad324; +func_800AD420 = 0x800ad420; +func_800AD480 = 0x800ad480; +func_800AD4EC = 0x800ad4ec; +func_800AD5E8 = 0x800ad5e8; +func_800AD73C = 0x800ad73c; +func_800AD804 = 0x800ad804; +func_800AD890 = 0x800ad890; +func_800AD8DC = 0x800ad8dc; +func_800AD924 = 0x800ad924; +func_800AD944 = 0x800ad944; +func_800ADBBC = 0x800adbbc; +func_800ADC70 = 0x800adc70; +func_800ADD2C = 0x800add2c; +func_800ADDE8 = 0x800adde8; +func_800ADE5C = 0x800ade5c; +func_800ADE84 = 0x800ade84; +func_800ADED8 = 0x800aded8; +func_800ADF04 = 0x800adf04; +func_800ADF38 = 0x800adf38; +func_800ADFC0 = 0x800adfc0; +func_800ADFF4 = 0x800adff4; +func_800AE050 = 0x800ae050; +func_800AE058 = 0x800ae058; +func_800AE060 = 0x800ae060; +func_800AE068 = 0x800ae068; +func_800AE070 = 0x800ae070; +func_800AE078 = 0x800ae078; +func_800AE080 = 0x800ae080; +func_800AE234 = 0x800ae234; +func_800AE25C = 0x800ae25c; +func_800AE2A0 = 0x800ae2a0; +func_800AE318 = 0x800ae318; +func_800AE378 = 0x800ae378; +func_800AE42C = 0x800ae42c; +func_800AE6C0 = 0x800ae6c0; +func_800AE764 = 0x800ae764; +func_800AE82C = 0x800ae82c; +func_800AE954 = 0x800ae954; +func_800AEB20 = 0x800aeb20; +func_800AEB80 = 0x800aeb80; +func_800AEBF0 = 0x800aebf0; +func_800AEC10 = 0x800aec10; +func_800AEF68 = 0x800aef68; +func_800AF0C4 = 0x800af0c4; +func_800AF1A8 = 0x800af1a8; +func_800AF1D4 = 0x800af1d4; +func_800AF264 = 0x800af264; +func_800AF320 = 0x800af320; +func_800AF380 = 0x800af380; +func_800AF3AC = 0x800af3ac; +func_800AF470 = 0x800af470; +func_800AF494 = 0x800af494; +func_800AF594 = 0x800af594; +func_800AF63C = 0x800af63c; +func_800AF65C = 0x800af65c; +func_800AF834 = 0x800af834; +func_800AF874 = 0x800af874; +func_800AF9C8 = 0x800af9c8; +func_800AFE98 = 0x800afe98; +func_800AFECC = 0x800afecc; +func_800B0170 = 0x800b0170; +func_800B0234 = 0x800b0234; +func_800B0378 = 0x800b0378; +func_800B062C = 0x800b062c; +func_800B079C = 0x800b079c; +func_800B089C = 0x800b089c; +func_800B0910 = 0x800b0910; +func_800B0B8C = 0x800b0b8c; +func_800B0B94 = 0x800b0b94; +func_800B0C14 = 0x800b0c14; +func_800B0DF8 = 0x800b0df8; +func_800B0E5C = 0x800b0e5c; +func_800B0EB4 = 0x800b0eb4; +func_800B0F04 = 0x800b0f04; +func_800B0FFC = 0x800b0ffc; +func_800B1060 = 0x800b1060; +func_800B108C = 0x800b108c; +func_800B10B4 = 0x800b10b4; +func_800B10F0 = 0x800b10f0; +func_800B11B4 = 0x800b11b4; +func_800B1218 = 0x800b1218; +func_800B1268 = 0x800b1268; +func_800B12DC = 0x800b12dc; +func_800B1304 = 0x800b1304; +func_800B1368 = 0x800b1368; +func_800B13B0 = 0x800b13b0; +func_800B141C = 0x800b141c; +func_800B153C = 0x800b153c; +func_800B1624 = 0x800b1624; +func_800B16D0 = 0x800b16d0; +func_800B17F0 = 0x800b17f0; +func_800B18A8 = 0x800b18a8; +func_800B1A5C = 0x800b1a5c; +func_800B1AA0 = 0x800b1aa0; +func_800B1B64 = 0x800b1b64; +func_800B1C1C = 0x800b1c1c; +func_800B1C94 = 0x800b1c94; +func_800B1D48 = 0x800b1d48; +func_800B2A2C = 0x800b2a2c; +func_800B2B5C = 0x800b2b5c; +func_800B2C60 = 0x800b2c60; +func_800B2CFC = 0x800b2cfc; +func_800B2EBC = 0x800b2ebc; +func_800B2F30 = 0x800b2f30; +func_800B2F50 = 0x800b2f50; +func_800B2F70 = 0x800b2f70; +func_800B3030 = 0x800b3030; +func_800B30E4 = 0x800b30e4; +func_800B33A4 = 0x800b33a4; +func_800B36B4 = 0x800b36b4; +func_800B37A0 = 0x800b37a0; +func_800B383C = 0x800b383c; +func_800B38E0 = 0x800b38e0; +func_800B3968 = 0x800b3968; +func_800B3A04 = 0x800b3a04; +func_800B3AB8 = 0x800b3ab8; +func_800B3B84 = 0x800b3b84; +func_800B3C50 = 0x800b3c50; +func_800B3E2C = 0x800b3e2c; +func_800B3FAC = 0x800b3fac; +func_800B3FFC = 0x800b3ffc; +func_800B430C = 0x800b430c; +func_800B45F0 = 0x800b45f0; +func_800B46B4 = 0x800b46b4; +func_800B4794 = 0x800b4794; +func_800B4E30 = 0x800b4e30; +func_800B5138 = 0x800b5138; +func_800B54B8 = 0x800b54b8; +func_800B588C = 0x800b588c; +func_800B5AAC = 0x800b5aac; +func_800B5C1C = 0x800b5c1c; +func_800B5CD4 = 0x800b5cd4; +func_800B5D38 = 0x800b5d38; +func_800B5E64 = 0x800b5e64; +func_800B5FC4 = 0x800b5fc4; +func_800B5FE8 = 0x800b5fe8; +func_800B60E0 = 0x800b60e0; +func_800B64CC = 0x800b64cc; +func_800B677C = 0x800b677c; +func_800B6B98 = 0x800b6b98; +func_800B7764 = 0x800b7764; +func_800B798C = 0x800b798c; +func_800B79F0 = 0x800b79f0; +func_800B7DB4 = 0x800b7db4; +func_800B7FB4 = 0x800b7fb4; +func_800B8234 = 0x800b8234; +func_800B8360 = 0x800b8360; +func_800B8438 = 0x800b8438; +func_800B888C = 0x800b888c; +func_800B88CC = 0x800b88cc; +func_800B8944 = 0x800b8944; +func_800B8A34 = 0x800b8a34; +func_800B8B48 = 0x800b8b48; +func_800B8E48 = 0x800b8e48; +func_800B8EE4 = 0x800b8ee4; +func_800B8FCC = 0x800b8fcc; +func_800B905C = 0x800b905c; +func_800B91CC = 0x800b91cc; +func_800B950C = 0x800b950c; +func_800B9568 = 0x800b9568; +func_800BA11C = 0x800ba11c; +func_800BA24C = 0x800ba24c; +func_800BA2BC = 0x800ba2bc; +func_800BA360 = 0x800ba360; +func_800BA598 = 0x800ba598; +func_800BACEC = 0x800bacec; +func_800BB2A8 = 0x800bb2a8; +func_800BB430 = 0x800bb430; +func_800BB4F8 = 0x800bb4f8; +func_800BB538 = 0x800bb538; +func_800BB67C = 0x800bb67c; +func_800BB684 = 0x800bb684; +func_800BB90C = 0x800bb90c; +func_800BB978 = 0x800bb978; +func_800BB9B8 = 0x800bb9b8; +func_800BB9FC = 0x800bb9fc; +func_800BBA40 = 0x800bba40; +func_800BBA84 = 0x800bba84; +func_800BBB20 = 0x800bbb20; +func_800BBEAC = 0x800bbeac; +func_800BBF7C = 0x800bbf7c; +func_800BC04C = 0x800bc04c; +func_800BC11C = 0x800bc11c; +func_800BC1E0 = 0x800bc1e0; +func_800BC2F0 = 0x800bc2f0; +func_800BC348 = 0x800bc348; +func_800BC440 = 0x800bc440; +func_800BC538 = 0x800bc538; +func_800BC630 = 0x800bc630; +func_800BC754 = 0x800bc754; +func_800BC81C = 0x800bc81c; +func_800BC8B0 = 0x800bc8b0; +func_800BCA58 = 0x800bca58; +func_800BCB1C = 0x800bcb1c; +func_800BE49C = 0x800be49c; +func_800BE69C = 0x800be69c; +func_800BE86C = 0x800be86c; +func_800BEA38 = 0x800bea38; +func_800BFA98 = 0x800bfa98; +func_800BFB10 = 0x800bfb10; +func_800BFB88 = 0x800bfb88; +func_800BFDA0 = 0x800bfda0; +func_800BFF88 = 0x800bff88; +func_800C0088 = 0x800c0088; +func_800C018C = 0x800c018c; +func_800C0254 = 0x800c0254; +func_800C0314 = 0x800c0314; +func_800C03B8 = 0x800c03b8; +func_800C03FC = 0x800c03fc; +func_800C0410 = 0x800c0410; +func_800C0480 = 0x800c0480; +func_800C0630 = 0x800c0630; +func_800C0900 = 0x800c0900; +func_800C0970 = 0x800c0970; +func_800C0B20 = 0x800c0b20; +func_800C0DD8 = 0x800c0dd8; +func_800C1104 = 0x800c1104; +func_800C1304 = 0x800c1304; +func_800C1394 = 0x800c1394; +func_800C14C0 = 0x800c14c0; +func_800C1D8C = 0x800c1d8c; +func_800C2000 = 0x800c2000; +func_800C20E8 = 0x800c20e8; +func_800C2150 = 0x800c2150; +func_800C223C = 0x800c223c; +func_800C2704 = 0x800c2704; +func_800C2864 = 0x800c2864; +func_800C2928 = 0x800c2928; +func_800C2C1C = 0x800c2c1c; +func_800C2F20 = 0x800c2f20; +func_800C2FD4 = 0x800c2fd4; +func_800C3068 = 0x800c3068; +func_800C328C = 0x800c328c; +func_800C33F0 = 0x800c33f0; +func_800C3578 = 0x800c3578; +func_800C36B4 = 0x800c36b4; +func_800C3950 = 0x800c3950; +func_800C3AA0 = 0x800c3aa0; +func_800C3CA8 = 0x800c3ca8; +func_800C3DE4 = 0x800c3de4; +func_800C3F44 = 0x800c3f44; +func_800C40F4 = 0x800c40f4; +func_800C428C = 0x800c428c; +func_800C44B4 = 0x800c44b4; +func_800C45EC = 0x800c45ec; +func_800C4814 = 0x800c4814; +func_800C494C = 0x800c494c; +func_800C4DC8 = 0x800c4dc8; +func_800C4FC8 = 0x800c4fc8; +func_800C5004 = 0x800c5004; +func_800C5170 = 0x800c5170; +func_800C5694 = 0x800c5694; +func_800C57B0 = 0x800c57b0; +func_800C5864 = 0x800c5864; +func_800C59B8 = 0x800c59b8; +func_800C5ADC = 0x800c5adc; +func_800C5BEC = 0x800c5bec; +func_800C5C18 = 0x800c5c18; +func_800C5CC0 = 0x800c5cc0; +func_800C5E94 = 0x800c5e94; +func_800C60F4 = 0x800c60f4; +func_800C614C = 0x800c614c; +func_800C61C0 = 0x800c61c0; +func_800C627C = 0x800c627c; +func_800C62F4 = 0x800c62f4; +func_800C64AC = 0x800c64ac; +func_800C64D4 = 0x800c64d4; +func_800C6628 = 0x800c6628; +func_800C679C = 0x800c679c; +func_800C6CB8 = 0x800c6cb8; +func_800C70AC = 0x800c70ac; +func_800C7220 = 0x800c7220; +func_800C7340 = 0x800c7340; +func_800C74E4 = 0x800c74e4; +func_800C76C8 = 0x800c76c8; +func_800C7924 = 0x800c7924; +func_800C7C4C = 0x800c7c4c; +func_800CD400 = 0x800cd400; +func_800CD558 = 0x800cd558; +func_800CD5E4 = 0x800cd5e4; +func_800CD860 = 0x800cd860; +func_800CDDA4 = 0x800cdda4; +func_800CDF6C = 0x800cdf6c; +func_800CE970 = 0x800ce970; +func_800CEB48 = 0x800ceb48; +func_800CF5BC = 0x800cf5bc; +func_800CF8C0 = 0x800cf8c0; +func_800CFB14 = 0x800cfb14; +func_800CFCB0 = 0x800cfcb0; +func_800CFE60 = 0x800cfe60; +func_800D01C0 = 0x800d01c0; +func_800D0578 = 0x800d0578; +func_800D061C = 0x800d061c; +func_800D06B8 = 0x800d06b8; +func_800D0760 = 0x800d0760; +func_800D088C = 0x800d088c; +func_800D08B8 = 0x800d08b8; +func_800D0958 = 0x800d0958; +func_800D09D0 = 0x800d09d0; +func_800D0A44 = 0x800d0a44; +func_800D0A4C = 0x800d0a4c; +func_800D0B4C = 0x800d0b4c; +func_800D0C80 = 0x800d0c80; +func_800D1110 = 0x800d1110; +func_800D1530 = 0x800d1530; +func_800D2710 = 0x800d2710; +func_800D2828 = 0x800d2828; +func_800D2980 = 0x800d2980; +func_800D29D4 = 0x800d29d4; +func_800D32B4 = 0x800d32b4; +func_800D3354 = 0x800d3354; +func_800D3418 = 0x800d3418; +func_800D3474 = 0x800d3474; +func_800D34C8 = 0x800d34c8; +func_800D3520 = 0x800d3520; +func_800D3548 = 0x800d3548; +func_800D35D8 = 0x800d35d8; +func_800D3658 = 0x800d3658; +func_800D376C = 0x800d376c; +func_800D3994 = 0x800d3994; +func_800D3A6C = 0x800d3a6c; +func_800D3AF0 = 0x800d3af0; +func_800D3BF0 = 0x800d3bf0; +func_800D3D88 = 0x800d3d88; +func_800D3E8C = 0x800d3e8c; +func_800D3F0C = 0x800d3f0c; +func_800D3F8C = 0x800d3f8c; +func_800D415C = 0x800d415c; +func_800D41FC = 0x800d41fc; +func_800D4284 = 0x800d4284; +func_800D4368 = 0x800d4368; +func_800D44E8 = 0x800d44e8; +func_800D461C = 0x800d461c; +func_800D4710 = 0x800d4710; +func_800D491C = 0x800d491c; +func_800D4A64 = 0x800d4a64; +func_800D4C08 = 0x800d4c08; +func_800D4CBC = 0x800d4cbc; +func_800D4D90 = 0x800d4d90; +func_800D4FA8 = 0x800d4fa8; +func_800D4FF0 = 0x800d4ff0; +func_800D508C = 0x800d508c; +func_800D5138 = 0x800d5138; +func_800D51D4 = 0x800d51d4; +func_800D5230 = 0x800d5230; +func_800D52A0 = 0x800d52a0; +func_800D5350 = 0x800d5350; +func_800D5444 = 0x800d5444; +func_800D54BC = 0x800d54bc; +func_800D54EC = 0x800d54ec; +func_800D55A4 = 0x800d55a4; +func_800D55F4 = 0x800d55f4; +func_800D56A8 = 0x800d56a8; +func_800D574C = 0x800d574c; +func_800D5774 = 0x800d5774; +func_800D57C0 = 0x800d57c0; +func_800D58D0 = 0x800d58d0; +func_800D5938 = 0x800d5938; +func_800D5AC0 = 0x800d5ac0; +func_800D5B6C = 0x800d5b6c; +func_800D5D28 = 0x800d5d28; +func_800D61AC = 0x800d61ac; +func_800D6260 = 0x800d6260; +func_800D6394 = 0x800d6394; +func_800D650C = 0x800d650c; +func_800D6734 = 0x800d6734; +func_800D6814 = 0x800d6814; +func_800D6840 = 0x800d6840; +func_800D6998 = 0x800d6998; +func_800D6ACC = 0x800d6acc; +func_800D6C20 = 0x800d6c20; +func_800D6D8C = 0x800d6d8c; +func_800D6F78 = 0x800d6f78; +func_800D70C0 = 0x800d70c0; +func_800D7178 = 0x800d7178; +func_800D72B4 = 0x800d72b4; +func_800D7368 = 0x800d7368; +func_800D751C = 0x800d751c; +func_800D76B8 = 0x800d76b8; +func_800D7724 = 0x800d7724; +func_800D7888 = 0x800d7888; +func_800D7A88 = 0x800d7a88; +func_800D7B1C = 0x800d7b1c; +func_800D7BA4 = 0x800d7ba4; +func_800D7C2C = 0x800d7c2c; +func_800D7D3C = 0x800d7d3c; +func_800D8304 = 0x800d8304; +func_800D83A4 = 0x800d83a4; +func_800D8468 = 0x800d8468; +func_800D84F8 = 0x800d84f8; +func_800D85B0 = 0x800d85b0; +func_800D87EC = 0x800d87ec; +func_800D8A04 = 0x800d8a04; +func_800D8A0C = 0x800d8a0c; +func_800D8A24 = 0x800d8a24; +func_800D8A2C = 0x800d8a2c; +func_800D8A70 = 0x800d8a70; +func_800D8A78 = 0x800d8a78; +func_800D8A88 = 0x800d8a88; +func_800D8B2C = 0x800d8b2c; +func_800D8B60 = 0x800d8b60; +func_800D91DC = 0x800d91dc; +func_800D93DC = 0x800d93dc; +func_800D93E4 = 0x800d93e4; +func_800D9BF4 = 0x800d9bf4; +func_800D9DEC = 0x800d9dec; +func_800D9E0C = 0x800d9e0c; +func_800D9FA4 = 0x800d9fa4; +func_800DA380 = 0x800da380; +func_800DB818 = 0x800db818; +func_800DBC18 = 0x800dbc18; +func_800DBEC8 = 0x800dbec8; +func_800DBF8C = 0x800dbf8c; +func_800DC0CC = 0x800dc0cc; +func_800DCF58 = 0x800dcf58; +func_800DCF60 = 0x800dcf60; +func_800DCF94 = 0x800dcf94; +func_800DCFD4 = 0x800dcfd4; +func_800DD85C = 0x800dd85c; +func_800DDAD8 = 0x800ddad8; +func_800DDC34 = 0x800ddc34; +func_800DDCE8 = 0x800ddce8; +func_800DDE90 = 0x800dde90; +func_800DDFEC = 0x800ddfec; +func_800DE2B4 = 0x800de2b4; +func_800DE3CC = 0x800de3cc; +func_800DE46C = 0x800de46c; +func_800DE5D8 = 0x800de5d8; +func_800DE5E0 = 0x800de5e0; +func_800DE5E8 = 0x800de5e8; +func_800DE5F0 = 0x800de5f0; +func_800DE5F8 = 0x800de5f8; +func_800DE600 = 0x800de600; +func_800DE608 = 0x800de608; +func_800DE610 = 0x800de610; +func_800DE618 = 0x800de618; +func_800DE910 = 0x800de910; +func_800DE918 = 0x800de918; +func_800DE94C = 0x800de94c; +func_800DEB10 = 0x800deb10; +func_800DEB18 = 0x800deb18; +func_800DEC10 = 0x800dec10; +func_800DF244 = 0x800df244; +func_800DF24C = 0x800df24c; +func_800DF2CC = 0x800df2cc; +func_800DF528 = 0x800df528; +func_800DF530 = 0x800df530; +func_800DF5C8 = 0x800df5c8; +func_800DF7BC = 0x800df7bc; +func_800DF7C4 = 0x800df7c4; +func_800DF7CC = 0x800df7cc; +func_800DF8F0 = 0x800df8f0; +func_800DF8F8 = 0x800df8f8; +func_800DF900 = 0x800df900; +func_800DF9F0 = 0x800df9f0; +func_800DF9F8 = 0x800df9f8; +func_800DFA94 = 0x800dfa94; +func_800DFC38 = 0x800dfc38; +func_800DFC40 = 0x800dfc40; +func_800DFE34 = 0x800dfe34; +func_800DFFDC = 0x800dffdc; +func_800DFFE4 = 0x800dffe4; +func_800E010C = 0x800e010c; +func_800E026C = 0x800e026c; +func_800E0274 = 0x800e0274; +func_800E0294 = 0x800e0294; +func_800E03C8 = 0x800e03c8; +func_800E03D0 = 0x800e03d0; +func_800E03F0 = 0x800e03f0; +func_800E0528 = 0x800e0528; +func_800E0530 = 0x800e0530; +func_800E05E4 = 0x800e05e4; +func_800E078C = 0x800e078c; +func_800E0794 = 0x800e0794; +func_800E084C = 0x800e084c; +func_800E08C4 = 0x800e08c4; +func_800E0BE0 = 0x800e0be0; +func_800E0E34 = 0x800e0e34; +func_800E15D8 = 0x800e15d8; +func_800E16B8 = 0x800e16b8; +func_800E1A2C = 0x800e1a2c; +func_800E1AC0 = 0x800e1ac0; +func_800E1C40 = 0x800e1c40; +func_800E2054 = 0x800e2054; +func_800E2098 = 0x800e2098; +func_800E2C6C = 0x800e2c6c; +func_800E3088 = 0x800e3088; +func_800E33A0 = 0x800e33a0; +func_800E368C = 0x800e368c; +func_800E3B64 = 0x800e3b64; +func_800E3E10 = 0x800e3e10; +func_800E3FB4 = 0x800e3fb4; +func_800E4180 = 0x800e4180; +func_800E4394 = 0x800e4394; +func_800E4A64 = 0x800e4a64; +func_800E4C08 = 0x800e4c08; +func_800E53C8 = 0x800e53c8; +func_800E54EC = 0x800e54ec; +func_800E5530 = 0x800e5530; +func_800E5814 = 0x800e5814; +func_800E58B0 = 0x800e58b0; +func_800E58CC = 0x800e58cc; +func_800E5960 = 0x800e5960; +func_800E5978 = 0x800e5978; +func_800E5FB4 = 0x800e5fb4; +func_800E6018 = 0x800e6018; +func_800E60F8 = 0x800e60f8; +func_800E6820 = 0x800e6820; +func_800E68B4 = 0x800e68b4; +func_800E6904 = 0x800e6904; +func_800E6B94 = 0x800e6b94; +func_800E6DCC = 0x800e6dcc; +func_800E7170 = 0x800e7170; +func_800A00CC = 0x800a00cc; +func_800A015C = 0x800a015c; +func_800A01A0 = 0x800a01a0; +func_800A0514 = 0x800a0514; +func_800A0534 = 0x800a0534; +func_800A05D4 = 0x800a05d4; +func_800A09DC = 0x800a09dc; +func_800A0AB8 = 0x800a0ab8; +func_800A0BA8 = 0x800a0ba8; +func_800A0CAC = 0x800a0cac; +func_800A0E68 = 0x800a0e68; +func_800A0F90 = 0x800a0f90; +func_800A11B4 = 0x800a11b4; +func_800A12F0 = 0x800a12f0; +func_800A139C = 0x800a139c; +func_800A14BC = 0x800a14bc; +func_800A16E4 = 0x800a16e4; +func_800A17C0 = 0x800a17c0; +func_800A19A4 = 0x800a19a4; +func_800A1E20 = 0x800a1e20; +func_800A1ED4 = 0x800a1ed4; +func_800A1EE4 = 0x800a1ee4; +func_800A1EEC = 0x800a1eec; +func_800A1F48 = 0x800a1f48; +func_800A1FA4 = 0x800a1fa4; +func_800A1FC8 = 0x800a1fc8; +func_800A2014 = 0x800a2014; +func_800A208C = 0x800a208c; +func_800A20D4 = 0x800a20d4; +func_800A20F8 = 0x800a20f8; +func_800A2190 = 0x800a2190; +func_800A21CC = 0x800a21cc; +func_800A2248 = 0x800a2248; +func_800A2274 = 0x800a2274; +func_800A22A4 = 0x800a22a4; +func_800A22D4 = 0x800a22d4; +func_800A22E4 = 0x800a22e4; +func_800A2328 = 0x800a2328; +func_800A2380 = 0x800a2380; +func_800A23F8 = 0x800a23f8; +func_800A2420 = 0x800a2420; +func_800A2458 = 0x800a2458; +func_800A24A8 = 0x800a24a8; +func_800A2504 = 0x800a2504; +func_800A273C = 0x800a273c; +func_800A2888 = 0x800a2888; +func_800A2934 = 0x800a2934; +func_800A2974 = 0x800a2974; +func_800A2A2C = 0x800a2a2c; +func_800A2C68 = 0x800a2c68; +func_800A2E80 = 0x800a2e80; +func_800A2F1C = 0x800a2f1c; +func_800A2FB8 = 0x800a2fb8; +func_800A310C = 0x800a310c; +func_800A3178 = 0x800a3178; +func_800A3210 = 0x800a3210; +func_800A32D8 = 0x800a32d8; +func_800A32F0 = 0x800a32f0; +func_800A32FC = 0x800a32fc; +func_800A3308 = 0x800a3308; +func_800A3314 = 0x800a3314; +func_800A3368 = 0x800a3368; +func_800A343C = 0x800a343c; +func_800A34C4 = 0x800a34c4; +func_800A358C = 0x800a358c; +func_800A379C = 0x800a379c; +func_800A1368 = 0x800a1368; +func_800A1498 = 0x800a1498; +func_800A14D8 = 0x800a14d8; +func_800A2314 = 0x800a2314; +func_800A2D5C = 0x800a2d5c; +func_800A2F78 = 0x800a2f78; +func_800A3020 = 0x800a3020; +func_800A364C = 0x800a364c; +func_800A4094 = 0x800a4094; +func_800A4134 = 0x800a4134; +func_800A424C = 0x800a424c; +func_800A4430 = 0x800a4430; +func_800A45D4 = 0x800a45d4; +func_800A47F8 = 0x800a47f8; +func_800A48B8 = 0x800a48b8; +func_800A496C = 0x800a496c; +func_800A4BEC = 0x800a4bec; +func_800A5FB4 = 0x800a5fb4; +func_800A635C = 0x800a635c; +func_800A6418 = 0x800a6418; +func_800A65A4 = 0x800a65a4; +func_800A82A0 = 0x800a82a0; +func_800A8304 = 0x800a8304; +func_800A8600 = 0x800a8600; +func_800A8620 = 0x800a8620; +func_800A8640 = 0x800a8640; +func_800A8858 = 0x800a8858; +func_800A8968 = 0x800a8968; +func_800A8E34 = 0x800a8e34; +func_800A8F88 = 0x800a8f88; +func_800A9B64 = 0x800a9b64; +func_800A9CE8 = 0x800a9ce8; +func_800A9EEC = 0x800a9eec; +func_800AA180 = 0x800aa180; +func_800AA348 = 0x800aa348; +func_800AA514 = 0x800aa514; +func_800AA5E4 = 0x800aa5e4; +func_800AA870 = 0x800aa870; +func_800AA930 = 0x800aa930; +func_800AAB24 = 0x800aab24; +func_800AB2AC = 0x800ab2ac; +func_800AB2B4 = 0x800ab2b4; +func_800AB310 = 0x800ab310; +func_800AB4AC = 0x800ab4ac; +func_800AB5E8 = 0x800ab5e8; +func_800AB728 = 0x800ab728; +func_800AB9C8 = 0x800ab9c8; +func_800ABA34 = 0x800aba34; +func_800ABA70 = 0x800aba70; +func_800ABF0C = 0x800abf0c; +func_800ABFE8 = 0x800abfe8; +func_800AC35C = 0x800ac35c; +func_800ACBA0 = 0x800acba0; +func_800ACC5C = 0x800acc5c; +func_800AD7B8 = 0x800ad7b8; +func_800AD858 = 0x800ad858; +func_800ADAA4 = 0x800adaa4; +func_800ADC90 = 0x800adc90; +func_800ADD70 = 0x800add70; +func_800AE23C = 0x800ae23c; +func_800AE4DC = 0x800ae4dc; +func_800AEE24 = 0x800aee24; +func_800AF6EC = 0x800af6ec; +func_800AF96C = 0x800af96c; +func_800AFAC4 = 0x800afac4; +func_800AFDE4 = 0x800afde4; +func_800AFE1C = 0x800afe1c; +func_800B0A48 = 0x800b0a48; +func_800B0FB0 = 0x800b0fb0; +func_800B1E40 = 0x800b1e40; +func_800B2598 = 0x800b2598; +func_800B2F40 = 0x800b2f40; +func_800B5504 = 0x800b5504; +func_800B69C0 = 0x800b69c0; +func_800B79B8 = 0x800b79b8; +func_800B8CF0 = 0x800b8cf0; +func_800BA534 = 0x800ba534; +func_800BA65C = 0x800ba65c; +func_800BA7C4 = 0x800ba7c4; +func_800BAF54 = 0x800baf54; +func_800BB1B4 = 0x800bb1b4; +func_800BB3A8 = 0x800bb3a8; +func_800BBBCC = 0x800bbbcc; +func_800BBF74 = 0x800bbf74; +func_800BC338 = 0x800bc338; +func_800BC438 = 0x800bc438; +func_800BC4D4 = 0x800bc4d4; +func_800BC9FC = 0x800bc9fc; +func_800BEAD4 = 0x800bead4; +func_800BEE10 = 0x800bee10; +func_800BF3AC = 0x800bf3ac; +func_800BF908 = 0x800bf908; +func_800C0248 = 0x800c0248; +func_800C0B54 = 0x800c0b54; +func_800C0BE8 = 0x800c0be8; +func_800C0C18 = 0x800c0c18; +func_800C0DE0 = 0x800c0de0; +func_800C0E5C = 0x800c0e5c; +func_800C0EDC = 0x800c0edc; +func_800C0F58 = 0x800c0f58; +func_800C0FD8 = 0x800c0fd8; +func_800C107C = 0x800c107c; +func_800C1214 = 0x800c1214; +func_800C13B0 = 0x800c13b0; +func_800C1674 = 0x800c1674; +func_800C1714 = 0x800c1714; +func_800C17B8 = 0x800c17b8; +func_800C1858 = 0x800c1858; +func_800C1AB4 = 0x800c1ab4; +func_800C1BF4 = 0x800c1bf4; +func_800C1D24 = 0x800c1d24; +func_800C1DE4 = 0x800c1de4; +func_800C1EEC = 0x800c1eec; +func_800C2000 = 0x800c2000; +func_800C228C = 0x800c228c; +func_800C2394 = 0x800c2394; +func_800C24A8 = 0x800c24a8; +func_800C2754 = 0x800c2754; +func_800C285C = 0x800c285c; +func_800C2970 = 0x800c2970; +func_800C2BFC = 0x800c2bfc; +func_800C2CA8 = 0x800c2ca8; +func_800C2D54 = 0x800c2d54; +func_800C2E00 = 0x800c2e00; +func_800C2F7C = 0x800c2f7c; +func_800C2FFC = 0x800c2ffc; +func_800C307C = 0x800c307c; +func_800C30FC = 0x800c30fc; +func_800C31E4 = 0x800c31e4; +func_800C32CC = 0x800c32cc; +func_800C33B4 = 0x800c33b4; +func_800C3A20 = 0x800c3a20; +func_800C3C34 = 0x800c3c34; +func_800C3EA0 = 0x800c3ea0; +func_800C3F1C = 0x800c3f1c; +func_800C3FA0 = 0x800c3fa0; +func_800C401C = 0x800c401c; +func_800C40A4 = 0x800c40a4; +func_800C42B0 = 0x800c42b0; +func_800C4350 = 0x800c4350; +func_800C43C4 = 0x800c43c4; +func_800C45AC = 0x800c45ac; +func_800C46A4 = 0x800c46a4; +func_800C46D0 = 0x800c46d0; +func_800C4804 = 0x800c4804; +func_800C493C = 0x800c493c; +func_800C49EC = 0x800c49ec; +func_800C4A40 = 0x800c4a40; +func_800C4A94 = 0x800c4a94; +func_800C4AE8 = 0x800c4ae8; +func_800C4BCC = 0x800c4bcc; +func_800C4C9C = 0x800c4c9c; +func_800C4CE8 = 0x800c4ce8; +func_800C4DE8 = 0x800c4de8; +func_800C4EE8 = 0x800c4ee8; +func_800C506C = 0x800c506c; +func_800C50EC = 0x800c50ec; +func_800C5194 = 0x800c5194; +func_800C523C = 0x800c523c; +func_800C532C = 0x800c532c; +func_800C5414 = 0x800c5414; +func_800C54BC = 0x800c54bc; +func_800C5564 = 0x800c5564; +func_800C560C = 0x800c560c; +func_800C5668 = 0x800c5668; +func_800C5740 = 0x800c5740; +func_800C5898 = 0x800c5898; +func_800C5A2C = 0x800c5a2c; +func_800C5B38 = 0x800c5b38; +func_800C5CE8 = 0x800c5ce8; +func_800C5E80 = 0x800c5e80; +func_800C5FF4 = 0x800c5ff4; +func_800C63CC = 0x800c63cc; +func_800C6748 = 0x800c6748; +func_800C684C = 0x800c684c; +func_800C6924 = 0x800c6924; +func_800C6D64 = 0x800c6d64; +func_800C6FD8 = 0x800c6fd8; +func_800C728C = 0x800c728c; +func_800C7354 = 0x800c7354; +func_800C75F0 = 0x800c75f0; +func_800C7C3C = 0x800c7c3c; +func_800C7CE8 = 0x800c7ce8; +func_800C7D5C = 0x800c7d5c; +func_800C814C = 0x800c814c; +func_800C81C0 = 0x800c81c0; +func_800C826C = 0x800c826c; +func_800C8514 = 0x800c8514; +func_800C8588 = 0x800c8588; +func_800C8634 = 0x800c8634; +func_800C8B98 = 0x800c8b98; +func_800C8F64 = 0x800c8f64; +func_800C9080 = 0x800c9080; +func_800C91D8 = 0x800c91d8; +func_800C955C = 0x800c955c; +func_800C9A20 = 0x800c9a20; +func_800C9B88 = 0x800c9b88; +func_800C9C84 = 0x800c9c84; +func_800C9D80 = 0x800c9d80; +func_800C9E7C = 0x800c9e7c; +func_800C9F78 = 0x800c9f78; +func_800CA074 = 0x800ca074; +func_800CA158 = 0x800ca158; +func_800CA254 = 0x800ca254; +func_800CA394 = 0x800ca394; +func_800CA490 = 0x800ca490; +func_800CA5D4 = 0x800ca5d4; +func_800CA77C = 0x800ca77c; +func_800CA95C = 0x800ca95c; +func_800CAA24 = 0x800caa24; +func_800CAAEC = 0x800caaec; +func_800CAC98 = 0x800cac98; +func_800CADFC = 0x800cadfc; +func_800CAF60 = 0x800caf60; +func_800CB01C = 0x800cb01c; +func_800CB0B8 = 0x800cb0b8; +func_800CB1CC = 0x800cb1cc; +func_800CB28C = 0x800cb28c; +func_800CB354 = 0x800cb354; +func_800CB450 = 0x800cb450; +func_800CB4F8 = 0x800cb4f8; +func_800CB5C0 = 0x800cb5c0; +func_800CB660 = 0x800cb660; +func_800CB718 = 0x800cb718; +func_800CB7C0 = 0x800cb7c0; +func_800CB858 = 0x800cb858; +func_800CB8F4 = 0x800cb8f4; +func_800CB98C = 0x800cb98c; +func_800CBA28 = 0x800cba28; +func_800CBAC0 = 0x800cbac0; +func_800CBB5C = 0x800cbb5c; +func_800CBBF4 = 0x800cbbf4; +func_800CBCA4 = 0x800cbca4; +func_800CBD40 = 0x800cbd40; +func_800CBDFC = 0x800cbdfc; +func_800CBE94 = 0x800cbe94; +func_800CBF40 = 0x800cbf40; +func_800CBFDC = 0x800cbfdc; +func_800CC098 = 0x800cc098; +func_800CC134 = 0x800cc134; +func_800CC1D4 = 0x800cc1d4; +func_800CC284 = 0x800cc284; +func_800CC358 = 0x800cc358; +func_800CC404 = 0x800cc404; +func_800CC4D8 = 0x800cc4d8; +func_800CC558 = 0x800cc558; +func_800CC5EC = 0x800cc5ec; +func_800CC670 = 0x800cc670; +func_800CC70C = 0x800cc70c; +func_800CC78C = 0x800cc78c; +func_800CC824 = 0x800cc824; +func_800CC8A8 = 0x800cc8a8; +func_800CC944 = 0x800cc944; +func_800CC9EC = 0x800cc9ec; +func_800CCA68 = 0x800cca68; +func_800CCB10 = 0x800ccb10; +func_800CCBBC = 0x800ccbbc; +func_800CCC3C = 0x800ccc3c; +func_800CCCC8 = 0x800cccc8; +func_800CCD54 = 0x800ccd54; +func_800CCE94 = 0x800cce94; +func_800CCFE8 = 0x800ccfe8; +func_800CD0C4 = 0x800cd0c4; +func_800CD16C = 0x800cd16c; +func_800CD214 = 0x800cd214; +func_800CD2E8 = 0x800cd2e8; +func_800CD3F0 = 0x800cd3f0; +func_800CD554 = 0x800cd554; +func_800CD5F0 = 0x800cd5f0; +func_800CD6B0 = 0x800cd6b0; +func_800CD770 = 0x800cd770; +func_800CD834 = 0x800cd834; +func_800CD91C = 0x800cd91c; +func_800CDA24 = 0x800cda24; +func_800CDB0C = 0x800cdb0c; +func_800CDC28 = 0x800cdc28; +func_800CDD40 = 0x800cdd40; +func_800CDE8C = 0x800cde8c; +func_800CE054 = 0x800ce054; +func_800CE214 = 0x800ce214; +func_800CE480 = 0x800ce480; +func_800CE6F4 = 0x800ce6f4; +func_800CE904 = 0x800ce904; +func_800CEB20 = 0x800ceb20; +func_800CEB94 = 0x800ceb94; +func_800CEE44 = 0x800cee44; +func_800CF028 = 0x800cf028; +func_800CF140 = 0x800cf140; +func_800CF200 = 0x800cf200; +func_800CF2BC = 0x800cf2bc; +func_800CF368 = 0x800cf368; +func_800CF4CC = 0x800cf4cc; +func_800CF66C = 0x800cf66c; +func_800CF6C0 = 0x800cf6c0; +func_800CF718 = 0x800cf718; +func_800CF874 = 0x800cf874; +func_800CF9B8 = 0x800cf9b8; +func_800CFAF0 = 0x800cfaf0; +func_800CFB84 = 0x800cfb84; +func_800CFC1C = 0x800cfc1c; +func_800CFCE4 = 0x800cfce4; +func_800CFE78 = 0x800cfe78; +func_800D0180 = 0x800d0180; +func_800D0518 = 0x800d0518; +func_800D0938 = 0x800d0938; +func_800D0B4C = 0x800d0b4c; +func_800D1200 = 0x800d1200; +func_800D1350 = 0x800d1350; +func_800D152C = 0x800d152c; +func_800D1654 = 0x800d1654; +func_800D184C = 0x800d184c; +func_800D195C = 0x800d195c; +func_800D1A80 = 0x800d1a80; +func_800D1B94 = 0x800d1b94; +func_800D1C68 = 0x800d1c68; +func_800D1D3C = 0x800d1d3c; +func_800D1DB8 = 0x800d1db8; +func_800D1F20 = 0x800d1f20; +func_800D1FDC = 0x800d1fdc; +func_800D2098 = 0x800d2098; +func_800D2164 = 0x800d2164; +func_800D2794 = 0x800d2794; +func_800D28A8 = 0x800d28a8; +func_800D298C = 0x800d298c; +func_800D2A70 = 0x800d2a70; +func_800D2B60 = 0x800d2b60; +func_800D2C60 = 0x800d2c60; +func_800D2E94 = 0x800d2e94; +func_800D2F3C = 0x800d2f3c; +func_800D3004 = 0x800d3004; +func_800D3124 = 0x800d3124; +func_800D3264 = 0x800d3264; +func_800D3330 = 0x800d3330; +func_800D33FC = 0x800d33fc; +func_800D348C = 0x800d348c; +func_800D3548 = 0x800d3548; +func_800D368C = 0x800d368c; +func_800D3728 = 0x800d3728; +func_800D3840 = 0x800d3840; +func_800D3958 = 0x800d3958; +func_800D3A70 = 0x800d3a70; +func_800D3B88 = 0x800d3b88; +func_800D3C18 = 0x800d3c18; +func_800D3CA8 = 0x800d3ca8; +func_800D3D40 = 0x800d3d40; +func_800D3DCC = 0x800d3dcc; +func_800D3E64 = 0x800d3e64; +func_800D3F30 = 0x800d3f30; +func_800D4038 = 0x800d4038; +func_800D4160 = 0x800d4160; +func_800D4214 = 0x800d4214; +func_800D4300 = 0x800d4300; +func_800D4378 = 0x800d4378; +func_800D4420 = 0x800d4420; +func_800D44E8 = 0x800d44e8; +func_800D4780 = 0x800d4780; +func_800D48C0 = 0x800d48c0; +func_800D493C = 0x800d493c; +func_800D4B28 = 0x800d4b28; +func_800D4BC0 = 0x800d4bc0; +func_800D4BFC = 0x800d4bfc; +func_800D4C68 = 0x800d4c68; +func_800D4E24 = 0x800d4e24; +func_800D4E88 = 0x800d4e88; +func_800D4EB4 = 0x800d4eb4; +func_800D5228 = 0x800d5228; +func_800D579C = 0x800d579c; +func_800D5A60 = 0x800d5a60; +func_800D5C9C = 0x800d5c9c; +func_800D6D44 = 0x800d6d44; +func_800D6E0C = 0x800d6e0c; +func_800D6F6C = 0x800d6f6c; +func_800D707C = 0x800d707c; +func_800D726C = 0x800d726c; +func_800D775C = 0x800d775c; +func_800D785C = 0x800d785c; +func_800D7970 = 0x800d7970; +func_800D7A58 = 0x800d7a58; +func_800D7C98 = 0x800d7c98; +func_800D7D6C = 0x800d7d6c; +func_800D8194 = 0x800d8194; +func_800D828C = 0x800d828c; +func_800D8334 = 0x800d8334; +func_800D83A8 = 0x800d83a8; +func_800D8420 = 0x800d8420; +func_800D8498 = 0x800d8498; +func_800D84CC = 0x800d84cc; +func_800D85FC = 0x800d85fc; +func_800D8710 = 0x800d8710; +func_800D9C04 = 0x800d9c04; +func_800D9F00 = 0x800d9f00; +func_800D9FFC = 0x800d9ffc; +func_800DA124 = 0x800da124; +func_800DA194 = 0x800da194; +func_800DA1D4 = 0x800da1d4; +func_800DA214 = 0x800da214; +func_800DA28C = 0x800da28c; +func_800DA2CC = 0x800da2cc; +func_800DA4FC = 0x800da4fc; +func_801D0000 = 0x801d0000; +func_801D00C4 = 0x801d00c4; +func_801D01C4 = 0x801d01c4; +func_801D027C = 0x801d027c; +func_801D0324 = 0x801d0324; +func_801D0408 = 0x801d0408; +func_801D0500 = 0x801d0500; +func_801D05C4 = 0x801d05c4; +func_801D0704 = 0x801d0704; +func_801D069C = 0x801d069c; +func_801D080C = 0x801d080c; +unused = 0x801d2514; +func_801D05C0 = 0x801d05c0; +func_801D06B0 = 0x801d06b0; +func_801D1774 = 0x801d1774; +func_801D1950 = 0x801d1950; +func_801D19C4 = 0x801d19c4; +func_801D1BA4 = 0x801d1ba4; +func_801D1C2C = 0x801d1c2c; +func_801D1D1C = 0x801d1d1c; +func_801D1D40 = 0x801d1d40; +func_801D1F40 = 0x801d1f40; +func_801D2184 = 0x801d2184; +func_801D21F0 = 0x801d21f0; +func_801D224C = 0x801d224c; +func_801D2408 = 0x801d2408; +func_801D2DA8 = 0x801d2da8; +func_801D3478 = 0x801d3478; +func_801D3668 = 0x801d3668; +func_801D3698 = 0x801d3698; +func_801D370C = 0x801d370c; +func_801D4CC0 = 0x801d4cc0; +g_MenuStartMode = 0x801e2cf8; +menus = 0x801e379c; +func_800A0B48 = 0x800a0b48; +func_800A0BE4 = 0x800a0be4; +func_800A0C54 = 0x800a0c54; +func_800A0D2C = 0x800a0d2c; +func_800A12AC = 0x800a12ac; +func_800A1370 = 0x800a1370; +func_800A141C = 0x800a141c; +func_800A16E0 = 0x800a16e0; +func_800A1710 = 0x800a1710; +func_800A19FC = 0x800a19fc; +func_800A1D14 = 0x800a1d14; +func_800A1D38 = 0x800a1d38; +func_800A1D54 = 0x800a1d54; +func_800A1DF0 = 0x800a1df0; +func_800A1FAC = 0x800a1fac; +func_800A2040 = 0x800a2040; +func_800A2088 = 0x800a2088; +func_800A2108 = 0x800a2108; +func_800A21A4 = 0x800a21a4; +func_800A21B4 = 0x800a21b4; +func_800A31C0 = 0x800a31c0; +func_800A31E8 = 0x800a31e8; +func_800A31F8 = 0x800a31f8; +func_800A32F4 = 0x800a32f4; +func_800A3304 = 0x800a3304; +func_800A368C = 0x800a368c; +func_800A36AC = 0x800a36ac; +func_800A38C8 = 0x800a38c8; +func_800A3908 = 0x800a3908; +func_800A3964 = 0x800a3964; +func_800A3C74 = 0x800a3c74; +func_800A3DFC = 0x800a3dfc; +func_800A3E4C = 0x800a3e4c; +func_800A3E9C = 0x800a3e9c; +func_800A3EC8 = 0x800a3ec8; +func_800A3F4C = 0x800a3f4c; +func_800A4008 = 0x800a4008; +func_800A4080 = 0x800a4080; +func_800A40B8 = 0x800a40b8; +func_800A40F0 = 0x800a40f0; +func_800A4138 = 0x800a4138; +func_800A41E8 = 0x800a41e8; +func_800A4268 = 0x800a4268; +func_800A4494 = 0x800a4494; +func_800A44A4 = 0x800a44a4; +func_800A44B4 = 0x800a44b4; +func_800A44C4 = 0x800a44c4; +func_800A45C4 = 0x800a45c4; +func_800A45D4 = 0x800a45d4; +func_800A45E4 = 0x800a45e4; +func_800A45F4 = 0x800a45f4; +func_800A4DDC = 0x800a4ddc; +func_800A4F08 = 0x800a4f08; +func_800A4F78 = 0x800a4f78; +func_800A5208 = 0x800a5208; +func_800A52A4 = 0x800a52a4; +func_800A5348 = 0x800a5348; +func_800A53A8 = 0x800a53a8; +func_800A54F0 = 0x800a54f0; +func_800A57C8 = 0x800a57c8; +func_800A5924 = 0x800a5924; +func_800A5970 = 0x800a5970; +func_800A59A0 = 0x800a59a0; +func_800A5A20 = 0x800a5a20; +func_800A5A94 = 0x800a5a94; +func_800A5AD8 = 0x800a5ad8; +func_800A5B88 = 0x800a5b88; +func_800A5C08 = 0x800a5c08; +func_800A5D00 = 0x800a5d00; +func_800A5E28 = 0x800a5e28; +func_800A5FB4 = 0x800a5fb4; +func_800A60D8 = 0x800a60d8; +func_800A6168 = 0x800a6168; +func_800A63FC = 0x800a63fc; +func_800A64AC = 0x800a64ac; +func_800A67A8 = 0x800a67a8; +func_800A6884 = 0x800a6884; +func_800A692C = 0x800a692c; +func_800A6994 = 0x800a6994; +func_800A6B8C = 0x800a6b8c; +func_800A6BCC = 0x800a6bcc; +func_800A6C00 = 0x800a6c00; +func_800A6C3C = 0x800a6c3c; +func_800A6FC0 = 0x800a6fc0; +func_800A71E8 = 0x800a71e8; +func_800A7EA4 = 0x800a7ea4; +func_800A7F18 = 0x800a7f18; +func_800A7F38 = 0x800a7f38; +func_800A806C = 0x800a806c; +func_800A82F0 = 0x800a82f0; +func_800A8300 = 0x800a8300; +func_800A835C = 0x800a835c; +func_800A86C4 = 0x800a86c4; +func_800A886C = 0x800a886c; +func_800A8888 = 0x800a8888; +func_800A8898 = 0x800a8898; +func_800A891C = 0x800a891c; +func_800A8A1C = 0x800a8a1c; +func_800A8A88 = 0x800a8a88; +func_800A8ABC = 0x800a8abc; +func_800A8AF4 = 0x800a8af4; +func_800A8B30 = 0x800a8b30; +func_800A8C70 = 0x800a8c70; +func_800A8CA4 = 0x800a8ca4; +func_800A8CE4 = 0x800a8ce4; +func_800A8D58 = 0x800a8d58; +func_800A8E50 = 0x800a8e50; +func_800A8F48 = 0x800a8f48; +func_800A8F74 = 0x800a8f74; +func_800A8FA0 = 0x800a8fa0; +func_800A8FCC = 0x800a8fcc; +func_800A9018 = 0x800a9018; +func_800A9064 = 0x800a9064; +func_800A90EC = 0x800a90ec; +func_800A9110 = 0x800a9110; +func_800A9134 = 0x800a9134; +func_800A9154 = 0x800a9154; +func_800A9174 = 0x800a9174; +func_800A9194 = 0x800a9194; +func_800A91A4 = 0x800a91a4; +func_800A91E0 = 0x800a91e0; +func_800A921C = 0x800a921c; +func_800A9240 = 0x800a9240; +func_800A929C = 0x800a929c; +func_800A92F8 = 0x800a92f8; +func_800A9334 = 0x800a9334; +func_800A9480 = 0x800a9480; +func_800A94A8 = 0x800a94a8; +func_800A94D0 = 0x800a94d0; +func_800A94F4 = 0x800a94f4; +func_800A9520 = 0x800a9520; +func_800A9678 = 0x800a9678; +func_800A96A4 = 0x800a96a4; +func_800A96D0 = 0x800a96d0; +func_800A97A8 = 0x800a97a8; +func_800A97E4 = 0x800a97e4; +func_800A9820 = 0x800a9820; +func_800A984C = 0x800a984c; +func_800A9878 = 0x800a9878; +func_800A98A4 = 0x800a98a4; +func_800A98E4 = 0x800a98e4; +func_800A9910 = 0x800a9910; +func_800A993C = 0x800a993c; +func_800A9988 = 0x800a9988; +func_800A99BC = 0x800a99bc; +func_800A9A04 = 0x800a9a04; +func_800A9A24 = 0x800a9a24; +func_800A9A44 = 0x800a9a44; +func_800A9A70 = 0x800a9a70; +func_800A9AA4 = 0x800a9aa4; +func_800A9AD0 = 0x800a9ad0; +func_800A9B04 = 0x800a9b04; +func_800A9C64 = 0x800a9c64; +func_800A9D5C = 0x800a9d5c; +func_800A9D88 = 0x800a9d88; +func_800A9DB4 = 0x800a9db4; +func_800A9E14 = 0x800a9e14; +func_800AA04C = 0x800aa04c; +func_800AA098 = 0x800aa098; +func_800AA0E0 = 0x800aa0e0; +func_800AA128 = 0x800aa128; +func_800AA170 = 0x800aa170; +func_800AA1B8 = 0x800aa1b8; +func_800AA238 = 0x800aa238; +func_800AA2B8 = 0x800aa2b8; +func_800AA304 = 0x800aa304; +func_800AA580 = 0x800aa580; +func_800AA640 = 0x800aa640; +func_800AA684 = 0x800aa684; +func_800AA6A4 = 0x800aa6a4; +func_800AA6D0 = 0x800aa6d0; +func_800AA7DC = 0x800aa7dc; +func_800AA8D8 = 0x800aa8d8; +func_800AA8F8 = 0x800aa8f8; +func_800AAA00 = 0x800aaa00; +func_800AAB18 = 0x800aab18; +func_800AB36C = 0x800ab36c; +func_800AB398 = 0x800ab398; +func_800AB48C = 0x800ab48c; +func_800AB4F4 = 0x800ab4f4; +func_800AB570 = 0x800ab570; +func_800AB5E4 = 0x800ab5e4; +func_800AB6E4 = 0x800ab6e4; +func_800AB8EC = 0x800ab8ec; +func_800AB92C = 0x800ab92c; +func_800AB988 = 0x800ab988; +func_800ABA18 = 0x800aba18; +func_800ABA78 = 0x800aba78; +func_800ABB24 = 0x800abb24; +func_800ABE58 = 0x800abe58; +func_800ABFC0 = 0x800abfc0; +func_800AC3C0 = 0x800ac3c0; +func_800AC484 = 0x800ac484; +func_800AC700 = 0x800ac700; +func_800AD63C = 0x800ad63c; +func_800AD788 = 0x800ad788; +func_800AD804 = 0x800ad804; +func_800AD928 = 0x800ad928; +func_800AD970 = 0x800ad970; +func_800ADA08 = 0x800ada08; +func_800ADA64 = 0x800ada64; +func_800ADB30 = 0x800adb30; +func_800ADC3C = 0x800adc3c; +func_800ADC70 = 0x800adc70; +func_800ADC80 = 0x800adc80; +func_800ADD4C = 0x800add4c; +func_800ADE30 = 0x800ade30; +func_800ADEA8 = 0x800adea8; +func_800ADFC0 = 0x800adfc0; +func_800AE024 = 0x800ae024; +func_800AE0BC = 0x800ae0bc; +func_800AE180 = 0x800ae180; +func_800AE47C = 0x800ae47c; +func_800AE4B8 = 0x800ae4b8; +func_800AE5B8 = 0x800ae5b8; +func_800AE5F0 = 0x800ae5f0; +func_800AE628 = 0x800ae628; +func_800AE638 = 0x800ae638; +func_800AE8AC = 0x800ae8ac; +func_800AEA48 = 0x800aea48; +func_800AF0A0 = 0x800af0a0; +func_800AF0B0 = 0x800af0b0; +func_800AF110 = 0x800af110; +func_800AF1A8 = 0x800af1a8; +func_800AF1E8 = 0x800af1e8; +func_800AF24C = 0x800af24c; +func_800AF2A4 = 0x800af2a4; +func_800AF324 = 0x800af324; +func_800AF364 = 0x800af364; +func_800AF3A4 = 0x800af3a4; +func_800AF96C = 0x800af96c; +func_800AF9A0 = 0x800af9a0; +func_800AF9DC = 0x800af9dc; +func_800AFCC8 = 0x800afcc8; +func_800AFFBC = 0x800affbc; +func_800B0098 = 0x800b0098; +func_800B017C = 0x800b017c; +func_800B01C4 = 0x800b01c4; +func_800B0200 = 0x800b0200; +func_800B0240 = 0x800b0240; +func_800B0250 = 0x800b0250; +func_800B0334 = 0x800b0334; +func_800B04AC = 0x800b04ac; +func_800B0670 = 0x800b0670; +func_800B075C = 0x800b075c; +func_800B0794 = 0x800b0794; +func_800B0810 = 0x800b0810; +func_800B0BF4 = 0x800b0bf4; +func_800B0D98 = 0x800b0d98; +func_800B0E84 = 0x800b0e84; +func_800B104C = 0x800b104c; +func_800B10AC = 0x800b10ac; +func_800B11C4 = 0x800b11c4; +func_800B1650 = 0x800b1650; +func_800B190C = 0x800b190c; +func_800B1C80 = 0x800b1c80; +func_800B21E4 = 0x800b21e4; +func_800B2304 = 0x800b2304; +func_800B2638 = 0x800b2638; +func_800B271C = 0x800b271c; +func_800B28CC = 0x800b28cc; +func_800B29CC = 0x800b29cc; +func_800B2E90 = 0x800b2e90; +func_800B2FA4 = 0x800b2fa4; +func_800B2FD0 = 0x800b2fd0; +func_800B3018 = 0x800b3018; +func_800B3044 = 0x800b3044; +func_800B307C = 0x800b307c; +func_800B3300 = 0x800b3300; +func_800B3350 = 0x800b3350; +func_800B338C = 0x800b338c; +func_800B3418 = 0x800b3418; +func_800B37E0 = 0x800b37e0; +func_800B3828 = 0x800b3828; +func_800B392C = 0x800b392c; +func_800B39B4 = 0x800b39b4; +func_800B3C40 = 0x800b3c40; +func_800B40B4 = 0x800b40b4; +func_800B4244 = 0x800b4244; +func_800B45DC = 0x800b45dc; +func_800B5274 = 0x800b5274; +func_800B5314 = 0x800b5314; +func_800B579C = 0x800b579c; +func_800B57C0 = 0x800b57c0; +func_800B57DC = 0x800b57dc; +func_800B58F8 = 0x800b58f8; +func_800B59F4 = 0x800b59f4; +func_800B5C7C = 0x800b5c7c; +func_800B5DD8 = 0x800b5dd8; +func_800B5E28 = 0x800b5e28; +func_800B624C = 0x800b624c; +func_800B6348 = 0x800b6348; +func_800B63F0 = 0x800b63f0; +func_800B64A0 = 0x800b64a0; +func_800B64D8 = 0x800b64d8; +func_800B650C = 0x800b650c; +func_800B6570 = 0x800b6570; +func_800B65A4 = 0x800b65a4; +func_800B65E0 = 0x800b65e0; +func_800B667C = 0x800b667c; +func_800B6724 = 0x800b6724; +func_800B69A4 = 0x800b69a4; +func_800B6A4C = 0x800b6a4c; +func_800B6AEC = 0x800b6aec; +func_800B6B28 = 0x800b6b28; +func_800B6C84 = 0x800b6c84; +func_800B6D10 = 0x800b6d10; +func_800B6DCC = 0x800b6dcc; +func_800B6E08 = 0x800b6e08; +func_800B6E78 = 0x800b6e78; +func_800B6EFC = 0x800b6efc; +func_800B7104 = 0x800b7104; +func_800B7134 = 0x800b7134; +func_800B717C = 0x800b717c; +func_800B7200 = 0x800b7200; +func_800B7228 = 0x800b7228; +func_800B7480 = 0x800b7480; +func_800B7620 = 0x800b7620; +func_800B76A8 = 0x800b76a8; +func_800B7714 = 0x800b7714; +func_800B77A8 = 0x800b77a8; +func_800B77F4 = 0x800b77f4; +func_800B7820 = 0x800b7820; +func_800B7838 = 0x800b7838; +func_800B785C = 0x800b785c; +func_800B786C = 0x800b786c; +func_800B787C = 0x800b787c; +func_800B79B8 = 0x800b79b8; +func_800B7A40 = 0x800b7a40; +func_800B7AC0 = 0x800b7ac0; +func_800B7B1C = 0x800b7b1c; +func_800B7B3C = 0x800b7b3c; +func_800B7B54 = 0x800b7b54; +func_800B7B78 = 0x800b7b78; +func_800B7BA0 = 0x800b7ba0; +func_800B7BC0 = 0x800b7bc0; +func_800B7BD8 = 0x800b7bd8; +func_800B7C1C = 0x800b7c1c; +func_800B7C7C = 0x800b7c7c; +func_800B832C = 0x800b832c; +func_800B8488 = 0x800b8488; +func_800B84D8 = 0x800b84d8; +func_800B851C = 0x800b851c; +func_800B858C = 0x800b858c; +func_800B85D4 = 0x800b85d4; +func_800B86C4 = 0x800b86c4; +func_800B86E8 = 0x800b86e8; +func_800B8720 = 0x800b8720; +func_800B8760 = 0x800b8760; +func_800B87D8 = 0x800b87d8; +func_800B89C4 = 0x800b89c4; +func_800B8A5C = 0x800b8a5c; +func_800B8A98 = 0x800b8a98; +func_800B8B00 = 0x800b8b00; +func_800B8CBC = 0x800b8cbc; +func_800B8D20 = 0x800b8d20; +func_800B8D4C = 0x800b8d4c; +func_800B90C0 = 0x800b90c0; +func_800B95E8 = 0x800b95e8; +func_800B962C = 0x800b962c; +func_800B98F0 = 0x800b98f0; +func_800B9B2C = 0x800b9b2c; +func_800BA938 = 0x800ba938; +func_800BAA00 = 0x800baa00; +func_800BAB60 = 0x800bab60; +func_800BAC70 = 0x800bac70; +func_800BAE60 = 0x800bae60; +func_800BB350 = 0x800bb350; +func_800BB450 = 0x800bb450; +func_800BB568 = 0x800bb568; +func_800BB650 = 0x800bb650; +func_800BB7DC = 0x800bb7dc; +func_800BB8B0 = 0x800bb8b0; +func_800BB8E8 = 0x800bb8e8; +func_800BB9A0 = 0x800bb9a0; +func_800BB9D0 = 0x800bb9d0; +func_800BBA0C = 0x800bba0c; +func_800BBA44 = 0x800bba44; +func_800BBBB0 = 0x800bbbb0; +func_800BBC4C = 0x800bbc4c; +func_800BBD20 = 0x800bbd20; +func_800BC1CC = 0x800bc1cc; +func_800BC420 = 0x800bc420; +func_800BC9E8 = 0x800bc9e8; +func_800BCA38 = 0x800bca38; +func_800BCA48 = 0x800bca48; +func_800BCA78 = 0x800bca78; +func_800BCB2C = 0x800bcb2c; +func_800BCBE8 = 0x800bcbe8; +func_800BCECC = 0x800bcecc; +func_800BD124 = 0x800bd124; +func_800BFBF0 = 0x800bfbf0; +func_800BFCAC = 0x800bfcac; +func_800C02F4 = 0x800c02f4; +func_800C0808 = 0x800c0808; +func_800C08A8 = 0x800c08a8; +func_800C0B48 = 0x800c0b48; +func_800C1490 = 0x800c1490; +func_800C1D58 = 0x800c1d58; +func_800C1FD8 = 0x800c1fd8; +func_800C2130 = 0x800c2130; +func_800C2450 = 0x800c2450; +func_800C2524 = 0x800c2524; +func_800C31F0 = 0x800c31f0; +func_800C3948 = 0x800c3948; +func_800C3DB0 = 0x800c3db0; +func_800C4148 = 0x800c4148; +func_800C4FB4 = 0x800c4fb4; +func_800C5CD4 = 0x800c5cd4; +func_800C6104 = 0x800c6104; +func_800C6598 = 0x800c6598; +world_unk_s = 0x800c80c0; +D_801B0CC0 = 0x801b0cc0; +D_801B0CC4 = 0x801b0cc4; +D_801D0CC4 = 0x801d0cc4; +func_801B0000 = 0x801b0000; diff --git a/config/symbols.batini.txt b/config/symbols.batini.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/symbols.battle.txt b/config/symbols.battle.txt new file mode 100644 index 0000000..8f38f91 --- /dev/null +++ b/config/symbols.battle.txt @@ -0,0 +1,18 @@ +BATTLE_EnqueueLoadImage = 0x800D2538; +BATTLE_FlushImageQueue = 0x800D25E8; +D_800F5BB8 = 0x800F5BB8; // size:0xCC +D_800F5E60 = 0x800F5E60; // size:0x9C +D_800F5F44 = 0x800F5F44; // size:0x1E88 +D_800F83E0 = 0x800F83E0; // size:0x138 +D_800FA63C = 0x800FA63C; // size:0x38 +D_800FA6D8 = 0x800FA6D8; // size:0xA8 +D_800FA958 = 0x800FA958; // size:0x20 +D_80151200 = 0x80151200; // size:0x15C +D_801518E4 = 0x801518E4; // size:0x5144 +D_801620AC = 0x801620AC; // size:0x140 +D_801621F0 = 0x801621F0; // size:0x780 +D_80162978 = 0x80162978; // size:0xC80 +D_8016360C = 0x8016360C; // size:0xAC +D_801636B8 = 0x801636B8; // size:0xA0 +D_80163798 = 0x80163798; // size:0x300 +D_80163C80 = 0x80163C80; // size:0xC diff --git a/config/symbols.bginmenu.us.txt b/config/symbols.bginmenu.us.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/symbols.brom.us.txt b/config/symbols.brom.us.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/symbols.cnfgmenu.us.txt b/config/symbols.cnfgmenu.us.txt new file mode 100644 index 0000000..ce054a2 --- /dev/null +++ b/config/symbols.cnfgmenu.us.txt @@ -0,0 +1,5 @@ +D_8009D7C0 = 0x8009D7C0; // size:0x10 +D_801D2478 = 0x801D2478; // size:0x14 +D_801D24A0 = 0x801D24A0; // size:0x10 +D_801D24B8 = 0x801D24B8; // size:0x8 +D_801D24CC = 0x801D24CC; // size:0x48 diff --git a/config/symbols.dschange.us.txt b/config/symbols.dschange.us.txt new file mode 100644 index 0000000..e69de29 diff --git a/config/symbols.ending.us.txt b/config/symbols.ending.us.txt new file mode 100644 index 0000000..aa0bd95 --- /dev/null +++ b/config/symbols.ending.us.txt @@ -0,0 +1 @@ +func_8003A08C = 0x8003A08C; // ignore:true diff --git a/config/symbols.field.us.txt b/config/symbols.field.us.txt new file mode 100644 index 0000000..b44f173 --- /dev/null +++ b/config/symbols.field.us.txt @@ -0,0 +1,75 @@ +D_800A0238 = 0x800A0238; // force_migration:True +D_800A023C = 0x800A023C; // force_migration:True +D_800A0240 = 0x800A0240; // force_migration:True +D_800A0244 = 0x800A0244; // force_migration:True +D_800A0248 = 0x800A0248; // force_migration:True +D_800A024C = 0x800A024C; // force_migration:True +D_800A0250 = 0x800A0250; // force_migration:True +D_800A0254 = 0x800A0254; // force_migration:True +D_800A0258 = 0x800A0258; // force_migration:True +D_800A025C = 0x800A025C; // force_migration:True +D_800A0260 = 0x800A0260; // force_migration:True +D_800A0264 = 0x800A0264; // force_migration:True +D_800A0268 = 0x800A0268; // force_migration:True +D_800A026C = 0x800A026C; // force_migration:True +D_800A0270 = 0x800A0270; // force_migration:True +D_800A0274 = 0x800A0274; // force_migration:True +D_800A0278 = 0x800A0278; // force_migration:True +D_800A027C = 0x800A027C; // force_migration:True +D_800A0288 = 0x800A0288; // force_migration:True +D_800A028C = 0x800A028C; // force_migration:True +D_800A0290 = 0x800A0290; // force_migration:True +D_800A029C = 0x800A029C; // force_migration:True +D_800A02A8 = 0x800A02A8; // force_migration:True +D_800A02B4 = 0x800A02B4; // force_migration:True +D_800A02B8 = 0x800A02B8; // force_migration:True +D_800A02BC = 0x800A02BC; // force_migration:True +D_800A02C0 = 0x800A02C0; // force_migration:True +D_800A02C4 = 0x800A02C4; // force_migration:True +D_800A02C8 = 0x800A02C8; // force_migration:True +D_800A02CC = 0x800A02CC; // force_migration:True +D_800A02D0 = 0x800A02D0; // force_migration:True +D_800A02D4 = 0x800A02D4; // force_migration:True +D_800A02D8 = 0x800A02D8; // force_migration:True +D_800A02DC = 0x800A02DC; // force_migration:True +D_800A02E0 = 0x800A02E0; // force_migration:True +D_800A02E4 = 0x800A02E4; // force_migration:True +D_800A02E8 = 0x800A02E8; // force_migration:True +D_800A02EC = 0x800A02EC; // force_migration:True +D_800A02F0 = 0x800A02F0; // force_migration:True +D_800A02F4 = 0x800A02F4; // force_migration:True +D_800A0300 = 0x800A0300; // type:asciz force_migration:True +D_800A0308 = 0x800A0308; // type:asciz force_migration:True +D_800A0310 = 0x800A0310; // type:asciz force_migration:True +D_800A0318 = 0x800A0318; // type:asciz force_migration:True +D_800A0320 = 0x800A0320; // type:asciz force_migration:True +D_800A032C = 0x800A032C; // type:asciz force_migration:True +D_800A0394 = 0x800A0394; // type:asciz force_migration:True +D_800A039C = 0x800A039C; // type:asciz force_migration:True +D_800A03A4 = 0x800A03A4; // type:asciz force_migration:True +D_800A03AC = 0x800A03AC; // type:asciz force_migration:True +D_800A0674 = 0x800A0674; // type:asciz force_migration:True +D_800A06B0 = 0x800A06B0; // type:asciz force_migration:True +D_800A06B4 = 0x800A06B4; // type:asciz force_migration:True +D_800A06C0 = 0x800A06C0; // type:asciz force_migration:True +D_800A06CC = 0x800A06CC; // type:asciz force_migration:True +D_800A06D4 = 0x800A06D4; // type:asciz force_migration:True +D_800A06E0 = 0x800A06E0; // type:asciz force_migration:True +D_800A07EC = 0x800A07EC; // type:asciz force_migration:True +D_800A07F8 = 0x800A07F8; // type:asciz force_migration:True +D_800A0810 = 0x800A0810; // type:asciz force_migration:True +D_800A0848 = 0x800A0848; // type:asciz force_migration:True +D_800A0854 = 0x800A0854; // type:asciz force_migration:True +D_800A08B0 = 0x800A08B0; // type:asciz force_migration:True +D_800A08D0 = 0x800A08D0; // type:asciz force_migration:True +D_800A0BE0 = 0x800A0BE0; // type:asciz force_migration:True +D_800A0C68 = 0x800A0C68; // type:asciz force_migration:True +D_800A0C70 = 0x800A0C70; // type:asciz force_migration:True +D_800A0C78 = 0x800A0C78; // type:asciz force_migration:True +D_800A0C80 = 0x800A0C80; // type:asciz force_migration:True +D_800A0F38 = 0x800A0F38; // type:asciz force_migration:True +D_800A103C = 0x800A103C; // type:asciz force_migration:True +D_800A104C = 0x800A104C; // type:asciz force_migration:True +D_800A10DC = 0x800A10DC; // type:asciz force_migration:True +D_800A10EC = 0x800A10EC; // type:asciz force_migration:True +D_800E4DF0 = 0x800E4DF0; // size:0x2F138 diff --git a/config/symbols.magic-barrier.us.txt b/config/symbols.magic-barrier.us.txt new file mode 100644 index 0000000..c803477 --- /dev/null +++ b/config/symbols.magic-barrier.us.txt @@ -0,0 +1,2 @@ +D_801B0C98 = 0x801B0C98; // size:0x8 +D_801B0CB0 = 0x801B0CB0; // size:0x8 diff --git a/config/symbols.main.us.txt b/config/symbols.main.us.txt new file mode 100644 index 0000000..1fe7c0e --- /dev/null +++ b/config/symbols.main.us.txt @@ -0,0 +1,449 @@ +__main = 0x800110B8; +__SN_ENTRY_POINT = 0x800110C0; +main = 0x80011C1C; +SetupGamepad = 0x8001C434; +SYS_gil = 0x80025B7C; +func_80026A0C = 0x80026A0C; +SetReverbMode = 0x80029AF0; +DS_read = 0x80033E74; +ChangeClearSIO = 0x80034CE8; +_SpuInit = 0x800362B8; +SpuStart = 0x800363B0; +_spu_init = 0x8003642C; +_spu_writeByIO = 0x800366C0; +_spu_FiDMA = 0x8003688C; +_spu_r_ = 0x8003695C; +_spu_t = 0x80036A18; +_spu_write = 0x80036CA8; +_spu_read = 0x80036D30; +_spu_FsetRXX = 0x80036D98; +_spu_FsetRXXa = 0x80036DE0; +_spu_FgetRXXa = 0x80036E84; +_spu_FsetPCR = 0x80036EC0; +_spu_FsetDelayW = 0x80036F20; +_spu_FsetDelayR = 0x80036F4C; +_spu_FwaitFs = 0x80036F78; +_SpuDataCallback = 0x80036FD8; +SpuInitMalloc = 0x80036FFC; +_SpuMallocSeparateTo3 = 0x80037050; +SpuMallocWithStartAddr = 0x800373AC; +_spu_gcSPU = 0x80037664; +SpuSetNoiseVoice = 0x80037964; +_SpuSetAnyVoice = 0x80037988; +SpuSetNoiseClock = 0x80037B90; +SpuRead = 0x80037BE0; +SpuSetReverb = 0x80037C40; +_SpuIsInAllocateArea = 0x80037D10; +_SpuIsInAllocateArea_ = 0x80037D90; +SpuSetReverbModeParam = 0x80037E1C; +_spu_setReverbAttr = 0x8003832C; +SpuGetReverbModeParam = 0x800387FC; +SpuSetReverbDepth = 0x8003884C; +SpuSetReverbVoice = 0x800388C4; +SpuClearReverbWorkArea = 0x800388E8; +SpuSetIRQ = 0x80038A84; +SpuSetIRQAddr = 0x80038BC4; +SpuSetIRQCallback = 0x80038C04; +_SpuCallback = 0x80038C48; +SpuSetKey = 0x80038C6C; +SpuGetKeyStatus = 0x80038E70; +SpuSetTransferStartAddr = 0x80038F64; +SpuSetTransferMode = 0x80038FB8; +SpuSetTransferCallback = 0x80038FEC; +SpuSetPitchLFOVoice = 0x80039010; +SpuSetCommonAttr = 0x80039034; +SpuSetVoiceVolume = 0x800393C8; +SpuSetVoiceVolumeAttr = 0x80039450; +SpuSetVoicePitch = 0x800395C8; +SpuSetVoiceStartAddr = 0x80039644; +SpuSetVoiceLoopStartAddr = 0x800396C0; +SpuSetVoiceDR = 0x8003973C; +SpuSetVoiceSL = 0x800397C8; +SpuSetVoiceARAttr = 0x80039850; +SpuSetVoiceSRAttr = 0x800398EC; +SpuSetVoiceRRAttr = 0x800399D0; +rsin = 0x80039A74; +sin_1 = 0x80039AB0; +rcos = 0x80039B40; +SetFogNearFar = 0x80039BE0; +csqrt_1 = 0x80039CEC; +csqrt = 0x80039E40; +InitGeom = 0x80039EDC; +SquareRoot0 = 0x80039F5C; +InvSquareRoot = 0x80039FEC; +VectorNormalS = 0x8003A078; +VectorNormal = 0x8003A08C; +VectorNormalSS = 0x8003A0B8; +MatrixNormal = 0x8003A1A4; +gteMIMefunc = 0x8003A28C; +LoadAverage12 = 0x8003A30C; +LoadAverage0 = 0x8003A35C; +LoadAverageShort12 = 0x8003A3AC; +LoadAverageShort0 = 0x8003A434; +LoadAverageByte = 0x8003A4BC; +LoadAverageCol = 0x8003A51C; +SquareRoot12 = 0x8003A59C; +CompMatrix = 0x8003A63C; +MulMatrix0 = 0x8003A79C; +MulRotMatrix0 = 0x8003A8A8; +MulRotMatrix = 0x8003A98C; +SetMulMatrix = 0x8003AA74; +ApplyMatrixLV = 0x8003AB84; +ApplyRotMatrix = 0x8003ACE4; +ScaleMatrixL = 0x8003AD14; +PushMatrix = 0x8003AE38; +PopMatrix = 0x8003AED8; +ReadRotMatrix = 0x8003AF78; +ReadLightMatrix = 0x8003AFC0; +ReadColorMatrix = 0x8003B008; +MulMatrix = 0x8003B05C; +MulMatrix2 = 0x8003B16C; +ApplyMatrix = 0x8003B27C; +ApplyMatrixSV = 0x8003B2CC; +TransMatrix = 0x8003B32C; +ScaleMatrix = 0x8003B35C; +SetRotMatrix = 0x8003B48C; +SetLightMatrix = 0x8003B4BC; +SetColorMatrix = 0x8003B4EC; +SetTransMatrix = 0x8003B51C; +SetVertex0 = 0x8003B53C; +SetVertex1 = 0x8003B54C; +SetVertex2 = 0x8003B55C; +SetVertexTri = 0x8003B56C; +SetRGBfifo = 0x8003B58C; +SetIR123 = 0x8003B5A0; +SetIR0 = 0x8003B5B4; +SetSZfifo3 = 0x8003B5C0; +SetSZfifo4 = 0x8003B5D4; +SetSXSYfifo = 0x8003B5EC; +SetRii = 0x8003B600; +SetMAC123 = 0x8003B614; +SetData32 = 0x8003B628; +SetDQA = 0x8003B634; +SetDQB = 0x8003B640; +ReadGeomOffset = 0x8003B64C; +ReadGeomScreen = 0x8003B66C; +SetBackColor = 0x8003B67C; +SetFarColor = 0x8003B69C; +SetGeomOffset = 0x8003B6BC; +SetGeomScreen = 0x8003B6DC; +LocalLight = 0x8003B6EC; +DpqColor = 0x8003B710; +NormalColor = 0x8003B72C; +NormalColor3 = 0x8003B748; +NormalColorDpq = 0x8003B784; +NormalColorDpq3 = 0x8003B7A8; +NormalColorCol = 0x8003B7F0; +NormalColorCol3 = 0x8003B810; +ColorDpq = 0x8003B854; +ColorCol = 0x8003B87C; +AverageSZ3 = 0x8003B8A0; +AverageSZ4 = 0x8003B8B0; +ReadOTZ = 0x8003B8B4; +LightColor = 0x8003B8CC; +DpqColorLight = 0x8003B8F4; +DpqColor3 = 0x8003B91C; +Intpl = 0x8003B958; +Square12 = 0x8003B97C; +Square0 = 0x8003B9A4; +AverageZ3 = 0x8003B9CC; +AverageZ4 = 0x8003B9EC; +OuterProduct12 = 0x8003BA10; +OuterProduct0 = 0x8003BA68; +Lzc = 0x8003BAC0; +ReadLZC = 0x8003BACC; +RotTransSV = 0x8003BADC; +SquareSS12 = 0x8003BB0C; +SquareSS0 = 0x8003BB44; +SquareSL12 = 0x8003BB7C; +SquareSL0 = 0x8003BBAC; +RotTransPers = 0x8003BBDC; +RotTransPers3 = 0x8003BC0C; +RotTrans = 0x8003BC6C; +RotTransPers4 = 0x8003BC9C; +RotAverage3 = 0x8003BD1C; +RotAverage4 = 0x8003BD7C; +RotAverageNclip3 = 0x8003BDFC; +RotAverageNclip4 = 0x8003BE8C; +TransposeMatrix = 0x8003BF3C; +RotMatrix = 0x8003BF8C; +RotMatrixYXZ = 0x8003C21C; +RotMatrixZYX = 0x8003C4AC; +RotMatrixX = 0x8003C73C; +RotMatrixY = 0x8003C8DC; +RotMatrixZ = 0x8003CA7C; +ratan2 = 0x8003CC1C; +_patch_gte = 0x8003CD9C; +PadInit = 0x8003CE3C; +PadRead = 0x8003CE8C; +PadStop = 0x8003CEBC; +VSync = 0x8003CEDC; +v_wait = 0x8003D024; +ResetCallback = 0x8003D0C0; +InterruptCallback = 0x8003D0F0; +DMACallback = 0x8003D120; +VSyncCallback = 0x8003D150; +VSyncCallbacks = 0x8003D184; +StopCallback = 0x8003D1B4; +RestartCallback = 0x8003D1E4; +CheckCallback = 0x8003D214; +GetIntrMask = 0x8003D224; +SetIntrMask = 0x8003D23C; +startIntr = 0x8003D258; +trapIntr = 0x8003D334; +setIntr = 0x8003D51C; +stopIntr = 0x8003D670; +restartIntr = 0x8003D71C; +memclr = 0x8003D7A4; +startIntrVSync = 0x8003D7D0; +trapIntrVSync = 0x8003D828; +setIntrVSync = 0x8003D8A0; +DMA_memclr = 0x8003D8CC; +startIntrDMA = 0x8003D8F8; +trapIntrDMA = 0x8003D948; +setIntrDMA = 0x8003DACC; +VSync_memclr = 0x8003DB74; +StSetRing = 0x8003DBA0; +CdInit = 0x8003DBD0; +def_cbsync = 0x8003DC60; +def_cbready = 0x8003DC88; +def_cbread = 0x8003DCB0; +CdLastPos = 0x8003DD08; +CdReset = 0x8003DD18; +CdControl = 0x8003DE9C; +CdControlF = 0x8003DFD4; +CdControlB = 0x8003E100; +CdMix = 0x8003E244; +CdGetSector = 0x8003E268; +CdIntToPos = 0x8003E2D0; +CdPosToInt = 0x8003E3D4; +getintr = 0x8003E454; +CD_sync = 0x8003E9DC; +CD_ready = 0x8003EC60; +CD_vol = 0x8003F398; +CD_flush = 0x8003F420; +CD_initvol = 0x8003F500; +CD_initintr = 0x8003F5F4; +CD_init = 0x8003F644; +CD_datasync = 0x8003F830; +CD_getsector = 0x8003F99C; +callback = 0x8003FAAC; +CdSearchFile = 0x8003FB8C; +_cmp = 0x8003FE74; +CD_newmedia = 0x8003FE98; +CD_searchdir = 0x8004018C; +CD_cachefile = 0x80040238; +cd_read = 0x800404F4; +CD_memcpy = 0x80040560; +CdRead2 = 0x80040594; +StCdInterrupt2 = 0x80040628; +CdDiskReady = 0x80040648; +CdGetDiskType = 0x8004076C; +StClearRing = 0x80040898; +StUnSetRing = 0x800408F8; +data_ready_callback = 0x80040950; +StGetBackloc = 0x800409E0; +StSetStream = 0x80040A40; +StFreeRing = 0x80040AC8; +init_ring_status = 0x80040B84; +StGetNext = 0x80040BC4; +StSetMask = 0x80040C88; +StRingStatus = 0x80041810; +DecDCTReset = 0x80041F14; +DecDCTGetEnv = 0x80041F4C; +DecDCTPutEnv = 0x80041FD8; +DecDCTBufSize = 0x80042038; +DecDCTin = 0x80042044; +DecDCTout = 0x800420C0; +DecDCTinSync = 0x800420E0; +DecDCToutSync = 0x80042100; +DecDCTinCallback = 0x80042120; +DecDCToutCallback = 0x80042144; +MDEC_reset = 0x80042168; +MDEC_in = 0x80042270; +MDEC_out = 0x80042304; +MDEC_in_sync = 0x80042394; +MDEC_out_sync = 0x8004242C; +timeout = 0x800424C4; +DecDCTvlcSize = 0x800425FC; +DecDCTvlc = 0x8004262C; +InitHeap = 0x80042990; +FlushCache = 0x800429A0; +_bu_init = 0x800429B0; +_96_remove = 0x800429C0; +SetMem = 0x800429D0; +SystemError = 0x800429E0; +DeliverEvent = 0x800429F0; +OpenEvent = 0x80042A00; +CloseEvent = 0x80042A10; +WaitEvent = 0x80042A20; +TestEvent = 0x80042A30; +EnableEvent = 0x80042A40; +DisableEvent = 0x80042A50; +InitPAD = 0x80042A60; +StartPAD = 0x80042A70; +StopPAD = 0x80042A80; +PAD_init = 0x80042A90; +PAD_dr = 0x80042AA0; +ReturnFromException = 0x80042AB0; +ResetEntryInt = 0x80042AC0; +HookEntryInt = 0x80042AD0; +UnDeliverEvent = 0x80042AE0; +EnterCriticalSection = 0x80042AF0; +ExitCriticalSection = 0x80042B00; +SetSp = 0x80042B10; +open = 0x80042B20; +read = 0x80042B30; +write = 0x80042B40; +close = 0x80042B50; +format = 0x80042B60; +firstfile = 0x80042B70; +nextfile = 0x80042B80; +delete = 0x80042B90; +ChangeClearPAD = 0x80042BA0; +ChangeClearRCnt = 0x80042BB0; +SetRCnt = 0x80042BC0; +GetRCnt = 0x80042C60; +StartRCnt = 0x80042C98; +StopRCnt = 0x80042CCC; +ResetRCnt = 0x80042D00; +exit = 0x80042D38; +puts = 0x80042D48; +setjmp = 0x80042D58; +strcmp = 0x80042D68; +strncmp = 0x80042D78; +bcopy = 0x80042D88; +memcpy = 0x80042D98; +rand = 0x80042DA8; +srand = 0x80042DB8; +printf = 0x80042DC8; +sprintf = 0x80042DD8; +strlen = 0x80043634; +memchr = 0x80043644; +memmove = 0x80043654; +LoadTPage = 0x800436C0; +LoadClut = 0x800437AC; +SetDefDrawEnv = 0x80043814; +SetDefDispEnv = 0x800438D4; +SetVideoMode = 0x80043910; +GetVideoMode = 0x80043928; +ResetGraph = 0x80043938; +SetGraphReverse = 0x80043A94; +SetGraphDebug = 0x80043BA8; +SetGraphQueue = 0x80043C14; +GetGraphType = 0x80043CC0; +GetGraphDebug = 0x80043CD0; +DrawSyncCallback = 0x80043CE0; +SetDispMask = 0x80043D3C; +DrawSync = 0x80043DD8; +checkRECT = 0x80043E44; +ClearImage = 0x80043F6C; +LoadImage = 0x80044000; +StoreImage = 0x80044064; +MoveImage = 0x800440C8; +ClearOTag = 0x8004418C; +ClearOTagR = 0x80044244; +DrawPrim = 0x800442DC; +DrawOTag = 0x8004433C; +PutDrawEnv = 0x800443B0; +GetDrawEnv = 0x80044474; +PutDispEnv = 0x800444AC; +GetDispEnv = 0x800448D0; +GetODE = 0x80044908; +SetTexWindow = 0x8004493C; +SetDrawArea = 0x80044978; +SetDrawOffset = 0x800449FC; +SetPriority = 0x80044A40; +SetDrawMode = 0x80044A68; +SetDrawEnv = 0x80044AC0; +get_mode = 0x80044D64; +get_cs = 0x80044DC0; +get_ce = 0x80044E8C; +get_ofs = 0x80044F58; +get_tw = 0x80044FA0; +get_dx = 0x80045024; +_status = 0x800450E0; +_otc = 0x800450F8; +_clr = 0x800451E0; +_dws = 0x80045400; +_drs = 0x80045654; +_ctl = 0x800458F0; +_getctl = 0x8004591C; +_cwb = 0x80045934; +_cwc = 0x80045984; +_param = 0x800459D0; +_addque = 0x80045A00; +_addque2 = 0x80045A24; +_exeque = 0x80045D18; +_reset = 0x8004602C; +_sync = 0x80046168; +set_alarm = 0x800462B0; +get_alarm = 0x800462E4; +_version = 0x80046450; +GPU_memset = 0x80046530; +GPU_cw = 0x8004655C; +GetTPage = 0x8004656C; +GetClut = 0x80046634; +DumpTPage = 0x8004664C; +DumpClut = 0x8004671C; +NextPrim = 0x8004675C; +IsEndPrim = 0x80046778; +AddPrim = 0x80046794; +AddPrims = 0x800467D0; +CatPrim = 0x8004680C; +TermPrim = 0x80046830; +SetSemiTrans = 0x80046848; +SetShadeTex = 0x80046870; +SetPolyF3 = 0x80046898; +SetPolyFT3 = 0x800468AC; +SetPolyG3 = 0x800468C0; +SetPolyGT3 = 0x800468D4; +SetPolyF4 = 0x800468E8; +SetPolyFT4 = 0x800468FC; +SetPolyG4 = 0x80046910; +SetPolyGT4 = 0x80046924; +SetSprt8 = 0x80046938; +SetSprt16 = 0x8004694C; +SetSprt = 0x80046960; +SetTile1 = 0x80046974; +SetTile8 = 0x80046988; +SetTile16 = 0x8004699C; +SetTile = 0x800469B0; +SetLineF2 = 0x800469C4; +SetLineG2 = 0x800469D8; +SetLineF3 = 0x800469EC; +SetLineG3 = 0x80046A0C; +SetLineF4 = 0x80046A2C; +SetLineG4 = 0x80046A4C; +SetBlockFill = 0x80046A6C; +SetDrawMove = 0x80046A80; +MargePrim = 0x80046A9C; +DumpDrawEnv = 0x80046AD0; +DumpDispEnv = 0x80046C50; +OpenTIM = 0x80046CFC; +ReadTIM = 0x80046D0C; +OpenTMD = 0x80046D74; +ReadTMD = 0x80046DB4; +get_tim_addr = 0x80047060; +get_tmd_addr = 0x80047180; +unpack_packet = 0x80047318; +memset = 0x80048498; +_card_info = 0x80048968; +_card_load = 0x80048978; +_card_auto = 0x80048988; +_card_clear = 0x80048998; +_card_write = 0x800489D0; +_new_card = 0x800489E0; +InitCARD = 0x800489F0; +StartCARD = 0x80048A44; +SsInitHot = 0x80048A7C; +InitCARD2 = 0x80048AAC; +StartCARD2 = 0x80048ABC; +StopCARD2 = 0x80048ACC; +_patch_card = 0x80048B34; +_patch_card2 = 0x80048BEC; +_ExitCard = 0x80048C7C; +g_bPadsInitialized = 0x80062D70; +D_800696AC = 0x800696AC; +g_ReverbMode = 0x8009A140; +g_ReverbAttr = 0x8009C564; // type:SpuReverbAttr size:0x14 diff --git a/config/symbols.savemenu.us.txt b/config/symbols.savemenu.us.txt new file mode 100644 index 0000000..804e9f7 --- /dev/null +++ b/config/symbols.savemenu.us.txt @@ -0,0 +1,6 @@ +func_801D1774 = 0x801D1774; +func_801D1BAC = 0x801D1BAC; +g_MenuStartMode = 0x801E2CF8; +D_801E2E64 = 0x801E2E64; +menus = 0x801E379C; // size:0x90 +D_801E3D80 = 0x801E3D80; // size:0x24 diff --git a/config/symbols.world.txt b/config/symbols.world.txt new file mode 100644 index 0000000..d565a6e --- /dev/null +++ b/config/symbols.world.txt @@ -0,0 +1 @@ +func_800BD124 = 0x800BD124; diff --git a/config/us.yaml b/config/us.yaml new file mode 100644 index 0000000..47159ef --- /dev/null +++ b/config/us.yaml @@ -0,0 +1,193 @@ +version: us +build_path: build/us +asm_path: asm/us +asset_path: assets/us +src_path: src +ld_script_path: build/us +generated_sym_path: build/us +align: 4 +overlays: + - name: main + disk_path: disks/us/SCUS_941.63 + sha1: a95e8b16b97071203b953bb81a33980509262f30 + base_path: main + symbol_addrs_path: + - config/symbols.main.us.txt + - config/sym_extern.us.txt + migrate_rodata_to_functions: true + vram_start: 0x80010000 + gp_value: 0x80062D44 + segments: + - [0x800, rodata] + - [0xA9C, .rodata, 18B8] # D_8001029C + - [0xAB4, rodata] + - [0xB94, rodata] + - [0x18B8, c, 18B8] + - [0x1255C, c, 1255C] + - [0x19BD0, c, akao] + - [0x24370, c, psxsdk] + - [0x394E0, data] + - [0x39BA8, .data, ovl] + - [0x39C50, data] + - [0x5354C, .sdata, 18B8] + - [0x536BC, .sdata, 1255C] + - [0x536C4, bss] + - name: batini + disk_path: disks/us/BATTLE/BATINI.X.dec + sha1: 2771b06f7249d34ed8a4f8c94e6047f70278e17c + base_path: battle + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.batini.txt + - config/sym_export_battle.us.txt + migrate_rodata_to_functions: true + vram_start: 0x801B0000 + segments: + - [0, .rodata, batini] + - [0x50, c, batini] + - name: battle + disk_path: disks/us/BATTLE/BATTLE.X.dec + sha1: c82690f814b18664c3b2d024f4edeea5743995d9 + base_path: battle + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.battle.txt + - config/sym_battle_import.us.txt + migrate_rodata_to_functions: true + vram_start: 0x800A0000 + bss_size: 0x70684 + segments: + - [0x0, .rodata, battle] + - [0x5BC, .rodata, battle1] + - [0x888, .rodata, battle2] + - [0xDD4, .rodata, battle3] + - [0x1158, c, battle] + - [0x130E4, c, battle1] + - [0x27B60, c, battle2] + - [0x38A04, c, battle3] + - [0x47A38, data] + - [0x538AC, bss] + - name: brom + disk_path: disks/us/BATTLE/BROM.X.dec + sha1: ebc7a6559f677d1caef8c5db5fd884fd9e0ab156 + base_path: brom + symbol_addrs_path: + - config/symbols.brom.us.txt + - config/sym_export.us.txt + migrate_rodata_to_functions: false + vram_start: 0x800A0000 + segments: + - [0x0, c, brom] + - [0x6B4, data] + - name: dschange + disk_path: disks/us/FIELD/DSCHANGE.X + sha1: e884441c5ceacdeb94e16a603b73ca53706078e8 + base_path: dschange + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.dschange.us.txt + vram_start: 0x800A0000 + segments: + - [0x0, c, dschange] + - [0x1580, data] + - [0x15E0, bss] + - name: ending + disk_path: disks/us/FIELD/ENDING.X + sha1: 1b3fbf999913024209b23a1bb8a6874a66fc19ba + base_path: ending + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.ending.us.txt + vram_start: 0x800A0000 + segments: + - [0x0, rodata] + - [0x30, c, ending] + - [0x3934, data] + - [0x6524, bss] + - name: field + disk_path: disks/us/FIELD/FIELD.BIN.dec + sha1: 9d4dc1688526f48a5e0706228e6a751d01871396 + base_path: field + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.field.us.txt + migrate_rodata_to_functions: true + vram_start: 0x800A0000 + segments: + - [0x0, .rodata, field] + - [0x1368, c, field] + - [0x3A5B8, data] + - name: bginmenu + disk_path: disks/us/MENU/BGINMENU.MNU + sha1: af17d71fa4738e53ec50df5d15d992a355500223 + base_path: menu + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.bginmenu.us.txt + vram_start: 0x801D0000 + segments: + - [0x0, c, bginmenu] + - [0x7F0, data] + - [0x860, bss] + - name: cnfgmenu + disk_path: disks/us/MENU/CNFGMENU.MNU + sha1: 20450f6e53a204f0f3b251a3864f125bc7b27bb6 + base_path: menu + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.cnfgmenu.us.txt + migrate_rodata_to_functions: true + vram_start: 0x801D0000 + segments: + - [0x0, .rodata, cnfgmenu] + - [0x40, c, cnfgmenu] + - [0x1AA8, .data, cnfgmenu] + - [0x24CC, .bss, cnfgmenu] + - name: savemenu + disk_path: disks/us/MENU/SAVEMENU.MNU + sha1: 430d54dbe01d9a0c670b1d2d2b5c642bdd1b3199 + base_path: menu + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.savemenu.us.txt + migrate_rodata_to_functions: true + vram_start: 0x801D0000 + segments: + - [0x0, .rodata, savemenu] + - [0x3B8, .rodata, title] + - [0x408, c, savemenu] + - [0x2B58, c, title] + - [0x4EC4, data] + - [0x12C78, .data, savemenu] + - [0x13650, data] + - [0x13698, bss] + - name: world + disk_path: disks/us/WORLD/WORLD.BIN.dec + sha1: a6b26b066e6fb8b5985c928d76faeb6f5f29ce2c + base_path: world + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.world.txt + migrate_rodata_to_functions: true + vram_start: 0x800A0000 + bss_size: 0x1D978 + segments: + - [0x0, .rodata, world] + - [0xB40, c, world] + - [0x1D124, asm, world_unk] + - [0x1FBF0, c, world2] + - [0x265EC, data, world] + - name: barrier + disk_path: disks/us/MAGIC/BARRIER.BIN + sha1: e93c458117a937879f1a6d8c956dfbdacd6286e0 + base_path: magic + vram_start: 0x801B0000 + bss_size: 0x20008 + symbol_addrs_path: + - config/sym_export.us.txt + - config/symbols.magic-barrier.us.txt + - config/sym_export_battle.us.txt + segments: + - [0, c, barrier] + - [0xB68, .data, barrier] + - [0xCC0, .bss, barrier] diff --git a/diff_settings.py b/diff_settings.py new file mode 100644 index 0000000..9ee718b --- /dev/null +++ b/diff_settings.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import sys + + +def add_custom_arguments(parser): + # Peek at argv: if the value after --overlay is a function name (not a real + # overlay), register it as a flag so argparse doesn't consume the function name. + # this allows aliases with --overlay burned into it to always work: + # differ='.venv/bin/python3 tools/asm-differ/diff.py -mows --overlay' + # allowed: differ main func_8002B958 + # allowed: differ func_8002B958 + + overlay_as_flag = False + if "--overlay" in sys.argv: + idx = sys.argv.index("--overlay") + next_val = sys.argv[idx + 1] if idx + 1 < len(sys.argv) else None + if next_val is None or not os.path.isfile(f"build/us/{next_val}.map"): + overlay_as_flag = True + if overlay_as_flag: + parser.add_argument( + "--overlay", + action="store_const", + const=None, + default=None, + dest="overlay", + ) + else: + parser.add_argument( + "--overlay", + default=None, + dest="overlay", + ) + + +def estimate_overlay_from_func_name(func_name: str) -> str | None: + # match symbol definitions but not imports (imports have "= 0x..." after the name) + matches = [] + pattern = re.compile( + r"^\s+0x[0-9a-f]+\s+" + re.escape(func_name) + r"\s*$", re.MULTILINE + ) + for map_path in glob.glob("build/us/*.map"): + with open(map_path) as f: + if pattern.search(f.read()): + ovl = map_path.rsplit("/", 1)[-1].removesuffix(".map") + matches.append(ovl) + if len(matches) == 1: + return matches[0] + return None + + +def apply(config, args): + overlay = args.overlay + if overlay is None: + func_name = next((a for a in sys.argv[1:] if not a.startswith("-")), None) + if func_name: + overlay = estimate_overlay_from_func_name(func_name) + if overlay is None: + overlay = "main" + config["baseimg"] = "disks/us/SCUS_941.63" + config["myimg"] = f"build/us/{overlay}.bin" + config["mapfile"] = f"build/us/{overlay}.map" + config["source_directories"] = [f"src/{overlay}"] + config["build_dir"] = "build/" + config["expected_dir"] = "expected/" + config["objdump_executable"] = "mipsel-linux-gnu-objdump" + config["arch"] = "mipsel" + config["makeflags"] = [] diff --git a/expected/report/build b/expected/report/build new file mode 120000 index 0000000..81dd3ba --- /dev/null +++ b/expected/report/build @@ -0,0 +1 @@ +/home/xeeynamo/repo/ff7/expected/build \ No newline at end of file diff --git a/go.work b/go.work new file mode 100644 index 0000000..3ba81a6 --- /dev/null +++ b/go.work @@ -0,0 +1,3 @@ +go 1.25.3 + +use ./tools/builder diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..24eb666 --- /dev/null +++ b/go.work.sum @@ -0,0 +1,4 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/include/common.h b/include/common.h new file mode 100644 index 0000000..7327d96 --- /dev/null +++ b/include/common.h @@ -0,0 +1,39 @@ +#ifndef COMMON_H +#define COMMON_H + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef SKIP_ASM +#undef USE_INCLUDE_ASM +#endif + +#ifdef USE_INCLUDE_ASM +__asm__(".include \"macro.inc\"\n"); +#define INCLUDE_ASM(FOLDER, NAME) \ + void __maspsx_include_asm_hack_##NAME() { \ + __asm__(".text # maspsx-keep \n" \ + "\t.align\t2 # maspsx-keep\n" \ + "\t.set noreorder # maspsx-keep\n" \ + "\t.set noat # maspsx-keep\n" \ + ".include \"" FOLDER "/" #NAME ".s\" # maspsx-keep\n" \ + "\t.set reorder # maspsx-keep\n" \ + "\t.set at # maspsx-keep\n"); \ + } +#else +#define INCLUDE_ASM(FOLDER, NAME) +#endif + +typedef signed char s8; +typedef unsigned char u8; +typedef signed short s16; +typedef unsigned short u16; +typedef signed int s32; +typedef unsigned int u32; +typedef u8 unk_data; +typedef unsigned int* unk_ptr; + +#define LEN(x) ((s32)(sizeof(x) / sizeof(*(x)))) + +#endif diff --git a/include/game.h b/include/game.h new file mode 100644 index 0000000..fb7aac4 --- /dev/null +++ b/include/game.h @@ -0,0 +1,469 @@ +#ifndef GAME_H +#define GAME_H + +#include "psxsdk/libgpu.h" +#include +#include +#include + +#ifndef FF7_STR +#define _S(x) x // check the usage of 'bin/str' to see how this works +#define _SL(len, x) x // same as _S, but for fixed-length strings with padding +#endif + +#define MAX_PARTY_COUNT 9 +#define MAX_INVENTORY_COUNT 320 +#define MAX_MATERIA_COUNT 200 + +typedef unsigned char ff7s[]; + +typedef enum { + LABEL_TIME, + LABEL_GIL, +} Labels; + +typedef enum { + INIT_YAMADA, + INIT_WINDOW, + INIT_KERNEL, + BATTLE_BROM, + BATTLE_TITLE, + BATTLE_BATTLE, + BATTLE_BATINI, + BATTLE_SCENE, + BATTLE_BATRES, + BATTLE_CO, + YAMADA_FILE_NUM, +} YamadaFile; + +typedef struct { + s32 loc; // disk sector where the file can be found + s32 len; // file size in bytes +} Yamada; + +typedef enum { + LBA_INIT_YAMADA = 614, + LBA_ENEMY6_SEFFECT = 30046, + LBA_ENEMY6_OVER2 = 30694, + LBA_ENEMY6_FAN2 = 30695, +} Lba; + +typedef struct { + s16 unk0; + s16 unk2; // current page + s16 unk4; + s16 unk6; // total item count + s16 unk8; + s8 unkA; + s8 unkB; // selected element + s8 unkC; + s8 unkD; // elements per page + s8 unkE; + s8 unkF; + s8 unk10; + s8 unk11; // scroll type: 0=no wrap, 1/2:wrap, 3>:infinite +} Unk80026448; // size: 0x12 + +typedef union { + void* poly; + POLY_FT4* ft4; + SPRT* sprt; + TILE* tile; + TILE_1* tile1; + BLK_FILL* blk_fill; + LINE_F2* linef2; +} Gpu; + +typedef struct { + u32 checksum; + u8 leader_level; + u8 leader_portrait; + u8 portrait2; + u8 portrait3; + s8 leader_name[0x10]; + u16 leader_hp; + u16 leader_hp_max; + u16 leader_mp; + u16 leader_mp_max; + s32 gil; + s32 time; + s8 place_name[0x20]; + s32 menu_color[3]; +} SaveHeader; // size: 0x54 + +// partially inspired by Q-Gears 'VI. The Save game format' +typedef struct { + u8 unk0; + u8 level; + u8 strength; + u8 vitality; + u8 magic; + u8 spirit; + u8 dexterity; + u8 luck; + u8 strength_bonus; + u8 vitality_bonus; + u8 magic_bonus; + u8 spirit_bonus; + u8 dexterity_bonus; + u8 luck_bonus; + u8 limit_level; + u8 limit_charge; + u8 name[12]; + u8 weapon; + u8 armor; + u8 accessory; + u8 unk1F; + u8 unk20; + u8 unk21; + u16 limit_learn; + u16 kill_count; + u16 limit_lv1_count; + u16 limit_lv2_count; + u16 limit_lv3_count; + u16 hp_cur; + u16 hp_base; + u16 mp_cur; + u16 mp_base; + u32 unk34; + u16 hp_max; + u16 mp_max; + u32 exp; + u8 materia_weapon[8]; + u8 materia_armor[8]; + u8 unk50[0x34]; +} SavePartyMember; // size:0x84 +typedef struct { + SaveHeader header; + /* 0x54 */ SavePartyMember party[MAX_PARTY_COUNT]; + /* 0x4F8 */ u8 partyID[4]; + /* 0x4FC */ u16 inventory[MAX_INVENTORY_COUNT]; + /* 0x77C */ s32 materia[MAX_MATERIA_COUNT]; + /* 0xA9C */ s32 yuffie_stolen_materia[48]; + /* 0xB5C */ u8 unk_b5c[32]; + /* 0xB7C */ s32 gil; + /* 0xB80 */ s32 time; + /* 0xB84 */ s32 countdown_timer_seconds; + /* 0xB88 */ s32 game_timer_fraction; + /* 0xB8C */ s32 countdown_timer_fraction; + /* 0xB90 */ s32 worldmap_exit_action; + /* 0xB94 */ u16 current_module; + /* 0xB96 */ u16 current_location_id; + /* 0xB98 */ u16 padding2; + /* 0xB9A */ s16 field_x; + /* 0xB9C */ s16 field_y; + /* 0xB9E */ u16 field_triangle; + /* 0xBA0 */ u8 field_direction; + /* 0xBA1 */ u8 step_id; + /* 0xBA2 */ u8 step_offset; + /* 0xBA3 */ u8 padding3; + /* 0xBA4 */ u8 memory_bank_1[256]; + /* 0xCA4 */ u8 memory_bank_2[256]; + /* 0xDA4 */ u8 memory_bank_3[256]; + /* 0xEA4 */ u8 memory_bank_4[256]; + /* 0xFA4 */ u8 memory_bank_5[256]; + /* 0x10A4 */ u16 phs_locking_mask; + /* 0x10A6 */ u16 phs_visibility_mask; + /* 0x10A8 */ u8 unk_10a8[48]; + /* 0x10D8 */ u8 battle_speed; + /* 0x10D9 */ u8 battle_msg_speed; + /* 0x10DA */ u16 config; + /* 0x10DC */ u8 button_config[16]; + /* 0x10EC */ u8 field_msg_speed; + /* 0x10ED */ u8 D_8009D7D1; // ?? + /* 0x10EE */ u16 D_8009D7D2; // ?? + /* 0x10F0 */ u32 D_8009D7D4; +} SaveWork; // size: 0x10F4 + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; + u8 unk34[4]; // character spacing array + s32 unk38; + s32 unk3C; + s32 unk40; + s32 unk44; + s32 unk48; + s32 unk4C; + s32 unk50; + s32 unk54; + s32 unk58; + s32 unk5C; + s32 unk60; + s32 unk64; + s32 unk68; + s32 unk6C; + s32 unk70; + s32 unk74; + s32 unk78; + s32 unk7C; + s32 unk80; + s32 unk84; + s32 unk88; + s32 unk8C; + s32 unk90; + s32 unk94; + s32 unk98; + s32 unk9C; + s32 unkA0; + s32 unkA4; + s32 unkA8; + s32 unkAC; + s32 unkB0; + s32 unkB4; + s32 unkB8; + s32 unkBC; + s32 unkC0; + s32 unkC4; + s32 unkC8; + s32 unkCC; + u8 unkD0[8]; + s32 unkD8; + s32 unkDC; + s32 unkE0; + s32 unkE4; + s32 unkE8; + s32 unkEC; + s32 unkF0; + s32 unkF4; + s32 unkF8; + s32 unkFC; + s32 unk100[0x40]; + s32 unk200; + s32 unk204; + s32 unk208; + s32 unk20C; + s32 unk210; + s32 unk214; + s32 unk218; + s32 unk21C; + s32 unk220; + s32 unk224; + s32 unk228; + s32 unk22C; + s32 unk230; + s32 unk234; + s32 unk238; + s32 unk23C; + s32 unk240; + s32 unk244; + s32 unk248; + s32 unk24C; + s32 unk250; + s32 unk254; + s32 unk258; + s32 unk25C; +} Unk800A8D04; // size: ??? + +// seems to be related to a party member during battle +typedef struct { + s32 unk0; + s16 unk4; + s8 unk6; + s8 unk7; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + s16 unk10; + s16 unk12; + s16 unk14; + s16 unk16; + s32 unk18; + s32 unk1C; + s8 unk20; + s8 unk21; + s8 unk22; + s8 unk23; + u8 unk24[0x28]; + u8 un4C[4][6]; + u8 un64[0x48]; + u8 unAC[4]; + u8 unB0[0x390]; +} Unk8009D84C; // size: 0x440 + +typedef struct { + /* 00 */ u16 unk0; + /* 02 */ u16 unk2; + /* 04 */ u16 unk4[6]; + /* 10 */ u8 unk10; + /* 11 */ u8 unk11; + /* 12 */ u16 unk12; +} Unk800730CC; + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u32 unk4; +} Unk80062F7C; + +typedef struct { + /* 0x00 */ u16 unk0; + /* 0x02 */ u16 unk2; + /* 0x04 */ u16 unk4; + /* 0x06 */ u16 unk6; + /* 0x08 */ u16 unk8; + /* 0x0A */ u16 unkA; + /* 0x0C */ u16 unkC; + /* 0x0E */ u16 unkE; + /* 0x10 */ u16 unk10; + /* 0x12 */ u16 unk12; + /* 0x14 */ u8 unk14; + /* 0x15 */ u8 unk15; + /* 0x16 */ u8 unk16; + /* 0x17 */ u8 unk17; +} Unk8007E7AC; // size:0x18 + +typedef struct { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; + /* 0x14 */ s32 unk14; + /* 0x18 */ s32 unk18; + /* 0x1C */ s8 unk1C[0x68]; +} Unk80074EA4; // size:0x84 + +typedef struct { + u8 unk0[0x28]; + u16 unk28; // n_actor ? + u16 unk2A; + u16 unk2C; // main actor anim ? + u16 unk2E; + u8 unk30[0x38]; + s16 unk68; // input related + s16 unk6A; // input related + s16 unk6C; // input related + s16 unk6E; // input related + u16 unk70; // input related + u16 unk72; // input related + u16 unk74; // input related + u16 unk76; // input related + s32 unk78; + s32 unk7C; + u16 unk80; + u16 unk82; +} Unk8009C6E0; // size:??? + +extern u8 D_80049208[12]; // window colors maybe?? +extern u8 D_800492F0[][12]; // see Labels enum +extern u16 D_80062D78; // pressed button? +extern u16 D_80062D7C; // pressed button? +extern u16 D_80062D7E; // pressed button? +extern u16 D_80062D80; // tapped button +extern u16 D_80062D82; // repeated button +extern u8 D_80062D98; +extern u8 D_80062D99; +extern s32 D_80062DCC; +extern u8 D_80062F1A; +extern u8 D_80062F1B; +extern Gpu D_80062F24; +extern u16 D_80062F3C; +extern s32 D_80062F58; +extern u_long* D_80062FC4; +extern Unk800A8D04* D_80063014; +extern DRAWENV D_800706A4[2]; +extern u8 D_80070788; +extern u16 D_800707BE; +extern s16 D_80071A5C; +extern s8 D_80071C08; +extern u8 D_80071E24; +extern u8 D_80071E2C; +extern MATRIX* D_80071E40; +extern u8 D_80071E34; +extern u8 D_800722C4; +extern Unk800730CC D_800730CC[]; +extern u8 D_800730DD[][0x14]; +extern Unk80074EA4 D_80074EA4[2]; +extern s32 D_800756F8[]; +extern int D_80075DEC; // buffer index, either 0 or 1 +extern u8 D_80075E24[]; +extern s8 D_80077F64[2][0x3400]; // polygon buffer +extern Unk8007E7AC D_8007E7AC[]; +extern DRAWENV D_8007EAAC[2]; +extern DISPENV D_8007EB68[2]; +extern s8 D_8007EBCC; +extern s8 D_8007EBDC; +extern u8 D_8007EBE0; // field debug mode +extern u8 D_80083184[0x40]; +extern u16 D_800831FC[]; +extern s32 D_80083274; +extern s16 D_800832A0; +extern s32 D_80083338; +extern s8 D_80095DCC; +extern volatile u16 D_80095DD4; +extern s16 D_800965E0; +extern s16 D_800965E8; +extern volatile s16 D_800965EC; +extern u8 D_80099FFC; +extern s16 D_8009A000[1]; +extern s32 D_8009A004[1]; +extern s32 D_8009A008[1]; +extern s32 D_8009A024[8]; +extern u8 D_8009A058; +extern u8* D_8009C6DC; +extern Unk8009C6E0* D_8009C6E0; // points to 0x8009abf4 +extern SaveWork Savemap; // 0x8009C6E4 +extern u8 D_8009CBDC[]; +extern s16 D_8009D288[]; +extern u8 D_8009D2E7; +extern u8 D_8009D391[1]; // part of a struct? +extern u8 D_8009D40D; +extern u8 D_8009D684; +extern u8 D_8009D685; +extern u8 D_8009D686; +extern u8 D_8009D820; // field debug related +extern u8 D_8009D8F8[]; +extern u32 D_8009D260; +extern volatile s32 D_8009D268[]; +extern Unk8009D84C D_8009D84C[3]; +extern s8 D_8009FE8C; + +// PSXSDK funcs +SVECTOR* ApplyMatrixSV(MATRIX* m, SVECTOR* v0, SVECTOR* v1); +MATRIX* RotMatrixYXZ(SVECTOR* r, MATRIX* m); +void SystemError(char c, long n); + +s32 func_80014B70(void); +s32 func_80014BA8(s32 arg0); +s32 func_8001521C(s32); +const char* func_80015248(s32 arg0, s32 arg1, s32 arg2); +void func_800155A4(s32); +void func_8001726C(s16, u16); +void func_80021044(DRAWENV* draw_env, DISPENV* disp_env); +void func_80026448(Unk80026448* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, + s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, s32 arg10, + s32 arg11, s32 arg12, u16 arg13); +void func_800269C0(void* poly); +s32 func_80026B70(unsigned char* str); +void func_80026F44(s32 x, s32 y, const char*, s32 color); // print FF7 string +void func_8002DA7C(); + +int func_80033DAC(int sector_no, void (*cb)()); +int func_80033DE4(int sector_no); +int func_80033E34(int sector_no, size_t size, u_long* dst, void (*cb)()); +int DS_read(int sector_no, size_t size, u_long* dst, void (*cb)()); +int func_80033EDC(int sector_no, void (*cb)()); +int func_80033F40(int sector_no, size_t size, u_long* dst, void (*cb)()); +int func_80033FC4(int sector_no, size_t size, u_long* dst, void (*cb)()); +u32 func_80034B44(void); + +// from overlays +extern s32 D_8019DAA0; +extern u_long* D_8019D5E8; // otag array + +#endif diff --git a/include/gte.inc b/include/gte.inc new file mode 100644 index 0000000..94d5840 --- /dev/null +++ b/include/gte.inc @@ -0,0 +1,93 @@ +.ifndef .L_GTE_INC +.L_GTE_INC: +# GTE macros + +.macro RTPS + .word 0x4A180001 +.endm + +.macro RTPT + .word 0x4A280030 +.endm + +.macro DPCL + .word 0x4A680029 +.endm + +.macro DPCS + .word 0x4A780010 +.endm + +.macro DPCT + .word 0x4AF8002A +.endm + +.macro INTPL + .word 0x4A980011 +.endm + +.macro NCS + .word 0x4AC8041E +.endm + +.macro NCT + .word 0x4AD80420 +.endm + +.macro NCDS + .word 0x4AE80413 +.endm + +.macro NCDT + .word 0x4AF80416 +.endm + +.macro NCCS + .word 0x4B08041B +.endm + +.macro NCCT + .word 0x4B18043F +.endm + +.macro CDP + .word 0x4B280414 +.endm + +.macro CC + .word 0x4B38041C +.endm + +.macro NCLIP + .word 0x4B400006 +.endm + +.macro AVSZ3 + .word 0x4B58002D +.endm + +.macro AVSZ4 + .word 0x4B68002E +.endm + +.macro MVMVA sf, mx, v, cv, lm + .word 0x4A400012|\sf<<19|\mx<<17|\v<<15|\cv<<13|\lm<<10 +.endm + +.macro SQR sf + .word 0x4AA00428|\sf<<19 +.endm + +.macro OP sf + .word 0x4B70000C|\sf<<19 +.endm + +.macro GPF sf + .word 0x4B90003D|\sf<<19 +.endm + +.macro GPL sf + .word 0x4BA0003E|\sf<<19 +.endm + +.endif diff --git a/include/macro.inc b/include/macro.inc new file mode 100644 index 0000000..3078253 --- /dev/null +++ b/include/macro.inc @@ -0,0 +1,19 @@ +.ifndef .L_MACRO_INC +.L_MACRO_INC: + +.macro jlabel label + glabel \label +.endm + +.macro glabel label + .global \label + \label: +.endm + +.macro .def # +.endm + + +.include "gte.inc" + +.endif diff --git a/include/psxsdk/kernel.h b/include/psxsdk/kernel.h new file mode 100644 index 0000000..cd442af --- /dev/null +++ b/include/psxsdk/kernel.h @@ -0,0 +1,114 @@ +#ifndef KERNEL_H +#define KERNEL_H + +#define DescMask 0xff000000 +#define DescTH DescMask +#define DescHW 0xf0000000 +#define DescEV 0xf1000000 +#define DescRC 0xf2000000 +#define DescUEV 0xf3000000 /* User event */ +#define DescSW 0xf4000000 /* BIOS */ + +#define HwVBLANK (DescHW | 0x01) /* VBLANK */ +#define HwGPU (DescHW | 0x02) /* GPU */ +#define HwCdRom (DescHW | 0x03) /* CDROM Decorder */ +#define HwDMAC (DescHW | 0x04) /* DMA controller */ +#define HwRTC0 (DescHW | 0x05) /* RTC0 */ +#define HwRTC1 (DescHW | 0x06) /* RTC1 */ +#define HwRTC2 (DescHW | 0x07) /* RTC2 */ +#define HwCNTL (DescHW | 0x08) /* Controller */ +#define HwSPU (DescHW | 0x09) /* SPU */ +#define HwPIO (DescHW | 0x0a) /* PIO */ +#define HwSIO (DescHW | 0x0b) /* SIO */ + +#define HwCPU (DescHW | 0x10) /* Exception */ +#define HwCARD (DescHW | 0x11) /* memory card */ +#define HwCARD_0 (DescHW | 0x12) /* memory card */ +#define HwCARD_1 (DescHW | 0x13) /* memory card */ +#define SwCARD (DescSW | 0x01) /* memory card */ +#define SwMATH (DescSW | 0x02) /* libmath */ + +#define RCntCNT0 (DescRC | 0x00) /* �\���s�N�Z�� */ +#define RCntCNT1 (DescRC | 0x01) /* �������� */ +#define RCntCNT2 (DescRC | 0x02) /* �V�X�e���N���b�N�W���� */ +#define RCntCNT3 (DescRC | 0x03) /* �������� �^�[�Q�b�g�l�͂P�ɌŒ� */ + +#define RCntMdINTR 0x1000 +#define RCntMdNOINTR 0x2000 +#define RCntMdSC 0x0001 +#define RCntMdSP 0x0000 +#define RCntMdFR 0x0000 +#define RCntMdGATE 0x0010 + +#define EvSpCZ 0x0001 /* counter becomes zero */ +#define EvSpINT 0x0002 /* interrupted */ +#define EvSpIOE 0x0004 /* end of i/o */ +#define EvSpCLOSE 0x0008 /* file was closed */ +#define EvSpACK 0x0010 /* command acknowledged */ +#define EvSpCOMP 0x0020 /* command completed */ +#define EvSpDR 0x0040 /* data ready */ +#define EvSpDE 0x0080 /* data end */ +#define EvSpTIMOUT 0x0100 /* time out */ +#define EvSpUNKNOWN 0x0200 /* unknown command */ +#define EvSpIOER 0x0400 /* end of read buffer */ +#define EvSpIOEW 0x0800 /* end of write buffer */ +#define EvSpTRAP 0x1000 /* general interrupt */ +#define EvSpNEW 0x2000 /* new device */ +#define EvSpSYSCALL 0x4000 /* system call instruction */ +#define EvSpERROR 0x8000 /* error happned */ +#define EvSpPERROR 0x8001 /* previous write error happned */ +#define EvSpEDOM 0x0301 /* domain error in libmath */ +#define EvSpERANGE 0x0302 /* range error in libmath */ + +#define EvMdINTR 0x1000 +#define EvMdNOINTR 0x2000 + +#define EvStUNUSED 0x0000 +#define EvStWAIT 0x1000 +#define EvStACTIVE 0x2000 +#define EvStALREADY 0x4000 + +#define TcbMdRT 0x1000 /* reserved by system */ +#define TcbMdPRI 0x2000 /* reserved by system */ + +#define TcbStUNUSED 0x1000 +#define TcbStACTIVE 0x4000 + +struct EvCB { + unsigned long desc; + long status; + long spec; + long mode; + long (*FHandler)(); + long system[2]; /* reserved by system */ +}; + +typedef struct DIRENTRY_RESERVED* PDIRENTRY_RESERVED; +struct DIRENTRY { + /* 0x00 */ char name[20]; + /* 0x14 */ long attr; + /* 0x18 */ long size; + /* 0x1C */ struct DIRENTRY* next; + /* 0x20*/ long head; + /* 0x24 */ char system[4]; +}; // size = 0x28 + +void EnterCriticalSection(void); +void ExitCriticalSection(void); + +void InitCARD(long val); +long StartCARD(void); +long StopCARD(void); +void _bu_init(void); +long _card_info(long chan); +long _card_clear(long chan); +long _card_load(long chan); +long _card_auto(long val); +void _new_card(void); +long _card_status(long drv); +long _card_wait(long drv); +unsigned long _card_chan(void); +long _card_write(long chan, long block, unsigned char* buf); +long _card_read(long chan, long block, unsigned char* buf); + +#endif diff --git a/include/psxsdk/libapi.h b/include/psxsdk/libapi.h new file mode 100644 index 0000000..bf24b26 --- /dev/null +++ b/include/psxsdk/libapi.h @@ -0,0 +1,96 @@ +#ifndef LIBAPI_H +#define LIBAPI_H + +struct EXEC { + unsigned long pc0; + unsigned long gp0; + unsigned long t_addr; + unsigned long t_size; + unsigned long d_addr; + unsigned long d_size; + unsigned long b_addr; + unsigned long b_size; + unsigned long s_addr; + unsigned long s_size; + unsigned long sp, fp, gp, ret, base; +}; + +extern void InitCARD(long val); +extern long StartCARD(void); +extern long StopCARD(void); +extern void _bu_init(void); +extern long _card_info(long chan); +extern long _card_clear(long chan); +extern long _card_load(long chan); +extern long _card_auto(long val); +extern void _new_card(void); +extern long _card_status(long drv); +extern long _card_wait(long drv); +extern unsigned long _card_chan(void); +extern long _card_write(long chan, long block, unsigned char* buf); +extern long _card_read(long chan, long block, unsigned char* buf); + +extern void InitHeap(unsigned long*, unsigned long); +extern long Load(char*, struct EXEC*); +extern long Exec(struct EXEC*, long, char**); +// GPU_cw +extern void _bu_init(void); + +/* + * Opens a device for low-level input/output and returns + * the descriptor. Returns -1 on failure. + */ +int open(const char* __file, int __oflag); + +extern long lseek(long, long, long); + +/* + * Reads n bytes from the descriptor + * fd to the are specified by buf. + * Returns the actual number of bytes + * read into the are. An error returns -1 + */ +extern long read(long fd, // File descriptor + void* buf, // Pointer to read buffer address + long n // Number of bytes to read +); +extern long write(long, void*, long); + +/* + * Close releases the file descriptor. + * fd is returned when successful, and -1 in all other cases. + */ +extern int close(int fd // File descriptor +); + +/* + * Initializes the file system + * Returns 1 if successful, 0 in all other cases. + */ +extern long format(char* fs // File system name +); + +extern struct DIRENTRY* firstfile(char*, struct DIRENTRY*); +extern struct DIRENTRY* nextfile(struct DIRENTRY*); +extern long erase(char*); +extern long Krom2RawAdd(unsigned long); +extern void ChangeClearPAD(long); +extern void StopPAD(void); +extern void FlushCache(void); +extern void DeliverEvent(unsigned long, unsigned long); + +extern long OpenEvent(unsigned long, long, long, long (*func)()); +extern long CloseEvent(long); +extern long WaitEvent(long); +extern long TestEvent(long); +extern long EnableEvent(long); +extern long DisableEvent(long); +extern void DeliverEvent(unsigned long, unsigned long); +extern void UnDeliverEvent(unsigned long, unsigned long); + +// ChangeClearRCnt +extern void _96_remove(void); +extern long SetRCnt(unsigned long, unsigned short, long); +extern long StartRCnt(unsigned long); + +#endif diff --git a/include/psxsdk/libc.h b/include/psxsdk/libc.h new file mode 100644 index 0000000..8552daa --- /dev/null +++ b/include/psxsdk/libc.h @@ -0,0 +1,18 @@ +extern void exit(); +extern void puts(char*); +// setjmp +extern char* strcat(char*, char*); +extern char* strcpy(char*, char*); +extern int strlen(char*); +extern void* memcpy(unsigned char*, unsigned char*, int); +extern void* memset(unsigned char*, unsigned char, int); + +/* + * Returns a pseudo-random number from 0 to RAND_MAX (0x7FFF=32767). + */ +extern int rand(void); +extern void srand(unsigned int); +extern void* malloc(size_t // Size of memory block to be allocated +); +extern void free(void*); +int printf(char*, ...); diff --git a/include/psxsdk/libcard.h b/include/psxsdk/libcard.h new file mode 100644 index 0000000..86c5534 --- /dev/null +++ b/include/psxsdk/libcard.h @@ -0,0 +1,7 @@ +// _card_info +// _card_load +extern void InitCARD(long val); +extern long StartCARD(void); +// _card_clear +// _card_write +// _new_card diff --git a/include/psxsdk/libcd.h b/include/psxsdk/libcd.h new file mode 100644 index 0000000..ec4728c --- /dev/null +++ b/include/psxsdk/libcd.h @@ -0,0 +1,169 @@ +#include + +/* Location */ +typedef struct { + u_char minute; + u_char second; + u_char sector; + u_char track; +} CdlLOC; + +/* Attenuator */ +typedef struct { + u_char val0; /* volume for CD(L) -> SPU (L) */ + u_char val1; /* volume for CD(L) -> SPU (R) */ + u_char val2; /* volume for CD(R) -> SPU (L) */ + u_char val3; /* volume for CD(R) -> SPU (R) */ +} CdlATV; + +typedef struct { + u_short id; + u_short type; + u_short secCount; + u_short nSectors; + u_long frameCount; + u_long frameSize; + + u_short width; + u_short height; + u_long dummy1; + u_long dummy2; + CdlLOC loc; +} StHEADER; + +/* Low Level File System for CdSearchFile() */ +#define CdlMAXFILE 64 /* max number of files in a directory */ +#define CdlMAXDIR 128 /* max number of total directories */ +#define CdlMAXLEVEL 8 /* max levels of directories */ + +/* + * CD-ROM Primitive Commands + */ +#define CdlNop 0x01 +#define CdlSetloc 0x02 +#define CdlPlay 0x03 +#define CdlForward 0x04 +#define CdlBackward 0x05 +#define CdlReadN 0x06 +#define CdlStandby 0x07 +#define CdlStop 0x08 +#define CdlPause 0x09 +#define CdlMute 0x0b +#define CdlDemute 0x0c +#define CdlSetfilter 0x0d +#define CdlSetmode 0x0e +#define CdlGetparam 0x0f +#define CdlGetlocL 0x10 +#define CdlGetlocP 0x11 +#define CdlGetTN 0x13 +#define CdlGetTD 0x14 +#define CdlSeekL 0x15 +#define CdlSeekP 0x16 +#define CdlReadS 0x1B + +/* + * CD-ROM Mode (used int CdlSetmode) + */ +// Normal Streaming +#define CdlModeStream 0x100 +// SUB HEADER information includes +#define CdlModeStream2 0x120 +// normal speed 1: double speed +#define CdlModeSpeed 0x80 +// 0: ADPCM off 1: ADPCM on +#define CdlModeRT 0x40 +// 2048 byte 1: 2340byte +#define CdlModeSize1 0x20 +// 0: - 1: 2328byte +#define CdlModeSize0 0x10 +// 0: Channel off 1: Channel on +#define CdlModeSF 0x08 +// 0: Report off 1: Report on +#define CdlModeRept 0x04 +// AutoPause off 1: AutoPause on +#define CdlModeAP 0x02 +// 0: CD-DA off 1: CD-DA on +#define CdlModeDA 0x01 + +#define CdlModeSpeedNormal 0 +#define CdlModeSpeedDouble 1 + +/* + * Status Contents + */ +#define CdlStatPlay 0x80 /* playing CD-DA */ +#define CdlStatSeek 0x40 /* seeking */ +#define CdlStatRead 0x20 /* reading data sectors */ +#define CdlStatShellOpen 0x10 /* once shell open */ +#define CdlStatSeekError 0x04 /* seek error detected */ +#define CdlStatStandby 0x02 /* spindle motor rotating */ +#define CdlStatError 0x01 /* command error detected */ + +/* + * Interrupts + */ +#define CdlNoIntr 0x00 /* No interrupt */ +#define CdlDataReady 0x01 /* Data Ready */ +#define CdlComplete 0x02 /* Command Complete */ +#define CdlAcknowledge 0x03 /* Acknowledge (reserved) */ +#define CdlDataEnd 0x04 /* End of Data Detected */ +#define CdlDiskError 0x05 /* Error Detected */ + +typedef struct { + CdlLOC pos; /* file location */ + u_long size; /* file size */ + char name[16]; /* file name (body) */ +} CdlFILE; + +typedef void (*CdlCB)(u_char, u_char*); + +void def_cbsync(u_char intr, u_char* result); +void def_cbready(u_char intr, u_char* result); +void def_cbread(u_char intr, u_char* result); + +int CdInit(void); +int CdStatus(void); +int CdMode(void); +int CdLastCom(void); +int CdReset(int mode); +void CdFlush(void); +int CdSetDebug(int level); +char* CdComstr(u_char com); +char* CdIntstr(u_char intr); +int CdSync(int mode, u_char* result); +int CdReady(int mode, u_char* result); +CdlCB CdSyncCallback(CdlCB func); +CdlCB CdReadyCallback(CdlCB func); + +// Issues direct primitive commands to the CD-ROM subsystem +int CdControl(u_char com, u_char* param, u_char* result); +int CdControlB(u_char com, u_char* param, u_char* result); +int CdControlF(u_char com, u_char* param); + +/* + * Sets the audio volume for CD audio (CD-DA, ADPCM). + * Return value: 1 + */ +int CdMix(CdlATV* vol // Pointer to attenuator volume +); + +int CdGetSector(void* madr, int size); +void(*CdDataCallback(void (*func)())); +CdlLOC* CdIntToPos(int i, CdlLOC* p); +int CdPosToInt(CdlLOC* p); +CdlFILE* CdSearchFile(CdlFILE* fp, char* name); +int CdRead(int sectors, u_long* buf, int mode); +int CdReadSync(int mode, u_char* result); +CdlCB CdReadCallback(CdlCB func); +int CdRead2(long mode); + +void StClearRing(void); +void StSetStream(u_long mode, u_long start_frame, u_long end_frame, + void (*func1)(), void (*func2)()); + +void StSetMask(u_long mask, u_long start, u_long end); +u_long StGetNext(u_long** addr, u_long** header); +u_long StFreeRing(u_long* base); +int StGetBackloc(CdlLOC* loc); +void StSetRing(u_long* ring_addr, u_long ring_size1); +void StUnSetRing(void); diff --git a/include/psxsdk/libetc.h b/include/psxsdk/libetc.h new file mode 100644 index 0000000..cfade93 --- /dev/null +++ b/include/psxsdk/libetc.h @@ -0,0 +1,70 @@ +#ifndef LIBETC_H +#define LIBETC_H + +#include + +extern int PadIdentifier; +/* + * PAD I/O (SIO Pad) + */ +#define PADLup (1 << 12) +#define PADLdown (1 << 14) +#define PADLleft (1 << 15) +#define PADLright (1 << 13) +#define PADRup (1 << 4) +#define PADRdown (1 << 6) +#define PADRleft (1 << 7) +#define PADRright (1 << 5) +#define PADi (1 << 9) +#define PADj (1 << 10) +#define PADk (1 << 8) +#define PADl (1 << 3) +#define PADm (1 << 1) +#define PADn (1 << 2) +#define PADo (1 << 0) +#define PADh (1 << 11) +#define PADL1 PADn +#define PADL2 PADo +#define PADR1 PADl +#define PADR2 PADm +#define PADstart PADh +#define PADselect PADk + +#define _PAD(x, y) ((y) << ((x) << 4)) + +#define MOUSEleft (1 << 3) +#define MOUSEright (1 << 2) + +#define MODE_NTSC 0 +#define MODE_PAL 1 + +struct Callbacks { + void (*unk0)(void); + void* (*DMACallback)(int dma, void (*func)()); + void (*unk8)(void); + int (*ResetCallback)(void); + int (*StopCallback)(void); + int (*VSyncCallbacks)(int ch, void (*f)()); + int (*RestartCallback)(void); +}; + +extern u16 D_8002C2BA; +extern struct Callbacks* D_8002D340; + +int VSync(int mode); +int VSyncCallback(void (*f)()); +int VSyncCallbacks(int ch, void (*f)()); + +void* DMACallback(int dma, void (*func)()); +int ResetCallback(void); +int StopCallback(void); +int RestartCallback(void); +u16 CheckCallback(void); +long GetVideoMode(void); +long SetVideoMode(long mode); + +void PadInit(int mode); +u_long PadRead(int id); +void PadStop(void); + +#endif diff --git a/include/psxsdk/libgpu.h b/include/psxsdk/libgpu.h new file mode 100644 index 0000000..23746c2 --- /dev/null +++ b/include/psxsdk/libgpu.h @@ -0,0 +1,647 @@ +#ifndef LIBGPU_H +#define LIBGPU_H +#include + +extern int (*GPU_printf)(); /* printf() object */ + +#define limitRange(x, l, h) ((x) = ((x) < (l) ? (l) : (x) > (h) ? (h) : (x))) + +#define setRECT(r, _x, _y, _w, _h) \ + (r)->x = (_x), (r)->y = (_y), (r)->w = (_w), (r)->h = (_h) + +/* + * Set Primitive Attributes + */ +#define setTPage(p, tp, abr, x, y) ((p)->tpage = getTPage(tp, abr, x, y)) + +#define setClut(p, x, y) ((p)->clut = getClut(x, y)) + +/* + * Set Primitive Colors + */ +#define setRGB0(p, _r0, _g0, _b0) (p)->r0 = _r0, (p)->g0 = _g0, (p)->b0 = _b0 + +#define setRGB1(p, _r1, _g1, _b1) (p)->r1 = _r1, (p)->g1 = _g1, (p)->b1 = _b1 + +#define setRGB2(p, _r2, _g2, _b2) (p)->r2 = _r2, (p)->g2 = _g2, (p)->b2 = _b2 + +#define setRGB3(p, _r3, _g3, _b3) (p)->r3 = _r3, (p)->g3 = _g3, (p)->b3 = _b3 + +/* + * Set Primitive Screen Points + */ +#define setXY0(p, _x0, _y0) (p)->x0 = (_x0), (p)->y0 = (_y0) + +#define setXY2(p, _x0, _y0, _x1, _y1) \ + (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1) + +#define setXY3(p, _x0, _y0, _x1, _y1, _x2, _y2) \ + (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), \ + (p)->x2 = (_x2), (p)->y2 = (_y2) + +#define setXY4(p, _x0, _y0, _x1, _y1, _x2, _y2, _x3, _y3) \ + (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x1), (p)->y1 = (_y1), \ + (p)->x2 = (_x2), (p)->y2 = (_y2), (p)->x3 = (_x3), (p)->y3 = (_y3) + +#define setXYWH(p, _x0, _y0, _w, _h) \ + (p)->x0 = (_x0), (p)->y0 = (_y0), (p)->x1 = (_x0) + (_w), (p)->y1 = (_y0), \ + (p)->x2 = (_x0), (p)->y2 = (_y0) + (_h), (p)->x3 = (_x0) + (_w), \ + (p)->y3 = (_y0) + (_h) + +/* + * Set Primitive Width/Height + */ +#define setWH(p, _w, _h) (p)->w = _w, (p)->h = _h + +/* + * Set Primitive Texture Points + */ +#define setUV0(p, _u0, _v0) (p)->u0 = (_u0), (p)->v0 = (_v0) + +#define setUV3(p, _u0, _v0, _u1, _v1, _u2, _v2) \ + (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), \ + (p)->u2 = (_u2), (p)->v2 = (_v2) + +#define setUV4(p, _u0, _v0, _u1, _v1, _u2, _v2, _u3, _v3) \ + (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u1), (p)->v1 = (_v1), \ + (p)->u2 = (_u2), (p)->v2 = (_v2), (p)->u3 = (_u3), (p)->v3 = (_v3) + +#define setUVWH(p, _u0, _v0, _w, _h) \ + (p)->u0 = (_u0), (p)->v0 = (_v0), (p)->u1 = (_u0) + (_w), (p)->v1 = (_v0), \ + (p)->u2 = (_u0), (p)->v2 = (_v0) + (_h), (p)->u3 = (_u0) + (_w), \ + (p)->v3 = (_v0) + (_h) + +/* + * Primitive Handling Macros + */ +#define setlen(p, _len) (((P_TAG*)(p))->len = (u_char)(_len)) +#define setaddr(p, _addr) (((P_TAG*)(p))->addr = (u_long)(_addr)) +#define setcode(p, _code) (((P_TAG*)(p))->code = (u_char)(_code)) + +#define getlen(p) (u_char)(((P_TAG*)(p))->len) +#define getcode(p) (u_char)(((P_TAG*)(p))->code) +#define getaddr(p) (u_long)(((P_TAG*)(p))->addr) + +#define nextPrim(p) (void*)((((P_TAG*)(p))->addr) | 0x80000000) +#ifdef __psyz +#undef nextPrim +#define nextPrim(p) (void*)(((P_TAG*)(p))->addr) +#endif + +#define isendprim(p) ((((P_TAG*)(p))->addr) == 0xffffff) + +#define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p) +#define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)), setaddr(ot, p0) + +#define catPrim(p0, p1) setaddr(p0, p1) +#define termPrim(p) setaddr(p, 0xffffff) + +#define _get_mode(dfe, dtd, tpage) \ + ((0xe1000000) | ((dtd) ? 0x0200 : 0) | ((dfe) ? 0x0400 : 0) | \ + ((tpage) & 0x9ff)) +#define setDrawTPage(p, dfe, dtd, tpage) \ + setlen(p, 1), ((u_long*)(p))[1] = _get_mode(dfe, dtd, tpage) + +#define setPolyF3(p) setlen(p, 4), setcode(p, 0x20) +#define setPolyFT3(p) setlen(p, 7), setcode(p, 0x24) +#define setPolyF4(p) setlen(p, 5), setcode(p, 0x28) +#define setPolyFT4(p) setlen(p, 9), setcode(p, 0x2c) +#define setPolyG3(p) setlen(p, 6), setcode(p, 0x30) +#define setPolyGT3(p) setlen(p, 9), setcode(p, 0x34) +#define setPolyG4(p) setlen(p, 8), setcode(p, 0x38) +#define setPolyGT4(p) setlen(p, 12), setcode(p, 0x3c) +#define setLineF2(p) setlen(p, 3), setcode(p, 0x40) +#define setLineF3(p) setlen(p, 5), setcode(p, 0x48), (p)->pad = 0x55555555 +#define setLineF4(p) setlen(p, 6), setcode(p, 0x4c), (p)->pad = 0x55555555 +#define setLineG2(p) setlen(p, 4), setcode(p, 0x50) +#define setLineG3(p) \ + setlen(p, 7), setcode(p, 0x58), (p)->pad = 0x55555555, (p)->p2 = 0 +#define setLineG4(p) \ + setlen(p, 9), setcode(p, 0x5c), \ + (p)->pad = 0x55555555, (p)->p2 = 0, (p)->p3 = 0 +#define setTile(p) setlen(p, 3), setcode(p, 0x60) +#define setSprt(p) setlen(p, 4), setcode(p, 0x64) +#define setTile1(p) setlen(p, 2), setcode(p, 0x68) +#define setTile8(p) setlen(p, 2), setcode(p, 0x70) +#define setSprt8(p) setlen(p, 3), setcode(p, 0x74) +#define setTile16(p) setlen(p, 2), setcode(p, 0x78) +#define setSprt16(p) setlen(p, 3), setcode(p, 0x7c) + +#define setSemiTrans(p, abe) \ + ((abe) ? setcode(p, getcode(p) | 0x02) : setcode(p, getcode(p) & ~0x02)) + +#define setShadeTex(p, tge) \ + ((tge) ? setcode(p, getcode(p) | 0x01) : setcode(p, getcode(p) & ~0x01)) + +#define getTPage(tp, abr, x, y) \ + ((((tp) & 0x3) << 7) | (((abr) & 0x3) << 5) | (((y) & 0x100) >> 4) | \ + (((x) & 0x3ff) >> 6) | (((y) & 0x200) << 2)) + +#define getClut(x, y) ((y << 6) | ((x >> 4) & 0x3f)) + +typedef struct { + /* 0x0 */ short x; + /* 0x2 */ short y; /* offset point on VRAM */ + /* 0x4 */ short w; /* width */ + /* 0x6 */ short h; /* height */ +} RECT; /* size = 0x8 */ + +#ifdef __psyz +#define O_TAG \ + u_long tag; \ + u_long len +typedef struct { + O_TAG; +} OT_TYPE; +#else +#define O_TAG u_long tag +#define OT_TYPE u_long +#endif + +typedef struct { +#ifndef __psyz + unsigned addr : 24; + unsigned len : 8; +#else + u_long addr; + u_long len; +#endif + u_char r0, g0, b0, code; +} P_TAG; + +typedef struct { + u_char r0, g0, b0, code; +} P_CODE; + +typedef struct { + /* 0x00 */ O_TAG; + /* 0x4 */ u_long code[15]; +} DR_ENV; /* Packed Drawing Environment, size = 0x40 */ + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short x1, y1; + short x2, y2; +} POLY_F3; // 0x20 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char u0, v0; + u_short clut; + short x1, y1; + u_char u1, v1; + u_short tpage; + short x2, y2; + u_char u2, v2; + u_short pad1; +} POLY_FT3; // 0x24 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short x1, y1; + short x2, y2; + short x3, y3; +} POLY_F4; // 0x28 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char u0, v0; + u_short clut; + short x1, y1; + u_char u1, v1; + u_short tpage; + short x2, y2; + u_char u2, v2; + u_short pad1; + short x3, y3; + u_char u3, v3; + u_short pad2; +} POLY_FT4; // 0x2C + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char r1, g1, b1, pad1; + short x1, y1; + u_char r2, g2, b2, pad2; + short x2, y2; +} POLY_G3; // 0x30 + +typedef struct { + O_TAG; + u_char r0; + u_char g0; + u_char b0; + u_char code; + short x0; + short y0; + u_char u0; + u_char v0; + u_short clut; + u_char r1; + u_char g1; + u_char b1; + u_char p1; + short x1; + short y1; + u_char u1; + u_char v1; + u_short tpage; + u_char r2; + u_char g2; + u_char b2; + u_char p2; + short x2; + short y2; + u_char u2; + u_char v2; + u_short pad2; +} POLY_GT3; // 0x34 + +typedef struct { + O_TAG; + u_char r0; + u_char g0; + u_char b0; + u_char code; + short x0; + short y0; + u_char r1; + u_char g1; + u_char b1; + u_char pad1; + short x1; + short y1; + u_char r2; + u_char g2; + u_char b2; + u_char pad2; + short x2; + short y2; + u_char r3; + u_char g3; + u_char b3; + u_char pad3; + short x3; + short y3; +} POLY_G4; // 0x38 + +typedef struct { + O_TAG; + u_char r0; + u_char g0; + u_char b0; + u_char code; + short x0; + short y0; + u_char u0; + u_char v0; + u_short clut; + u_char r1; + u_char g1; + u_char b1; + u_char p1; + short x1; + short y1; + u_char u1; + u_char v1; + u_short tpage; + u_char r2; + u_char g2; + u_char b2; + u_char p2; + short x2; + short y2; + u_char u2; + u_char v2; + u_short pad2; + u_char r3; + u_char g3; + u_char b3; + u_char p3; + short x3; + short y3; + u_char u3; + u_char v3; + u_short pad3; +} POLY_GT4; // 0x3C + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short x1, y1; +} LINE_F2; // 0x40 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short x1, y1; + short x2, y2; + u_long pad; +} LINE_F3; // 0x48 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short x1, y1; + short x2, y2; + short x3, y3; + u_long pad; +} LINE_F4; // 0x4C + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char r1, g1, b1, p1; + short x1, y1; +} LINE_G2; // 0x50 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char r1, g1, b1, p1; + short x1, y1; + u_char r2, g2, b2, p2; + short x2, y2; + u_long pad; +} LINE_G3; // 0x58 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char r1, g1, b1, p1; + short x1, y1; + u_char r2, g2, b2, p2; + short x2, y2; + u_char r3, g3, b3, p3; + short x3, y3; + u_long pad; +} LINE_G4; // 0x5C + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short w, h; +} TILE; // 0x60 + +typedef struct { + O_TAG; + u_char r0; + u_char g0; + u_char b0; + u_char code; + short x0; + short y0; + u_char u0; + u_char v0; + u_short clut; + short w; + short h; +} SPRT; // 0x64 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; +} TILE_1; // 0x68 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; +} TILE_8; // 0x70 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + u_char u0, v0; + u_short clut; +} SPRT_8; // 0x74 + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; +} TILE_16; // 0x78 + +typedef struct { + O_TAG; + u_char r0; + u_char g0; + u_char b0; + u_char code; + short x0; + short y0; + u_char u0; + u_char v0; + u_short clut; +} SPRT_16; // 0x7C + +typedef struct { + O_TAG; + u_char r0, g0, b0, code; + short x0, y0; + short w, h; +} BLK_FILL; + +/* + * Special Primitive Definitions + */ +typedef struct { + O_TAG; + u_long code[2]; +} DR_MODE; /* Drawing Mode */ + +typedef struct { + O_TAG; + u_long code[2]; +} DR_TWIN; /* Texture Window */ + +typedef struct { + O_TAG; + u_long code[2]; +} DR_AREA; /* Drawing Area */ + +typedef struct { + O_TAG; + u_long code[2]; +} DR_OFFSET; /* Drawing Offset */ + +typedef struct { /* MoveImage */ + O_TAG; + u_long code[5]; +} DR_MOVE; + +typedef struct { /* LoadImage */ + O_TAG; + u_long code[3]; + u_long p[13]; +} DR_LOAD; + +typedef struct { + O_TAG; + u_long code[1]; +} DR_TPAGE; /* Drawing TPage */ + +/* + * Font Stream Parameters + */ +#define FNT_MAX_ID 8 /* max number of stream ID */ +#define FNT_MAX_SPRT 1024 /* max number of sprites in all streams */ + +typedef struct { + /* 0x00 */ RECT clip; /* clip area */ + /* 0x08 */ short ofs[2]; /* drawing offset */ + /* 0x0C */ RECT tw; /* texture window */ + /* 0x14 */ u_short tpage; /* texture page */ + /* 0x16 */ u_char dtd; /* dither flag (0:off, 1:on) */ + /* 0x17 */ u_char dfe; /* flag to draw on display area (0:off 1:on) */ + /* 0x18 */ u_char isbg; /* enable to auto-clear */ + /* 0x19 */ u_char r0, g0, b0; /* initital background color */ + /* 0x1C */ DR_ENV dr_env; /* reserved */ +} DRAWENV; /* size = 0x58 */ + +typedef struct { + /* 0x00 */ RECT disp; /* display area */ + /* 0x08 */ RECT screen; /* display start point */ + /* 0x10 */ u_char isinter; /* interlace 0: off 1: on */ + /* 0x11 */ u_char isrgb24; /* RGB24 bit mode */ + /* 0x12 */ u_char pad0; /* reserved */ + /* 0x13 */ u_char pad1; /* reserved */ +} DISPENV; /* size = 0x14 */ + +/* + * Multi-purpose TIM image + */ +typedef struct { + u_long mode; /* pixel mode */ + RECT* crect; /* CLUT rectangle on frame buffer */ + u_long* caddr; /* CLUT address on main memory */ + RECT* prect; /* texture image rectangle on frame buffer */ + u_long* paddr; /* texture image address on main memory */ +} TIM_IMAGE; + +/* + * Loads a texture pattern from the memory area starting at the address pix into + * the frame buffer area starting at the address (x, y), and calculates the + * texture page ID for the loaded texture pattern. The texture pattern size w + * represents the number of pixels, not the actual size of the transfer area in + * the frame buffer. + */ +extern u_short LoadTPage( + u_long* pix, // Pointer to texture pattern start address + int tp, // Bit depth (0 = 4-bit; 1 = 8-bit; 2 = 16-bit) + int abr, // Semitransparency rate + int x, int y, // Destination frame buffer address + int w, int h // Texture pattern size +); + +extern u_short LoadClut(u_long* clut, int x, int y); +extern u_short LoadClut2(u_long* clut, int x, int y); + +/** + * Calculates and returns the texture CLUT ID. + * The CLUT address is limited to multiples of 16 in the x direction + */ +u_short GetClut(int x, // Horizontal frame buffer address of CLUT + int y // Vertical frame buffer address of CLUT +); + +u_short GetTPage(int tp, int abr, int x, int y); +extern void* NextPrim(void* p); +extern void AddPrim(void* ot, void* p); +extern void AddPrims(void* ot, void* p0, void* p1); +extern void CatPrim(void* p0, void* p1); +extern void DrawOTag(OT_TYPE* p); +extern void DrawOTagIO(OT_TYPE* p); +extern void DrawOTagEnv(OT_TYPE* p, DRAWENV* env); +extern void DrawPrim(void* p); +extern void DumpClut(u_short clut); +extern void DumpDispEnv(DISPENV* env); +extern void DumpDrawEnv(DRAWENV* env); +extern void DumpOTag(OT_TYPE* p); +extern void DumpTPage(u_short tpage); +extern void FntLoad(int tx, int ty); +extern void SetDispMask(int mask); +extern void SetDrawArea(DR_AREA* p, RECT* r); +extern void SetDrawEnv(DR_ENV* dr_env, DRAWENV* env); +extern void SetDrawLoad(DR_LOAD* p, RECT* rect); +extern void SetDrawMode(DR_MODE* p, int dfe, int dtd, int tpage, RECT* tw); +extern void SetDrawTPage(DR_TPAGE* p, int dfe, int dtd, int tpage); +extern void SetDrawMove(DR_MOVE* p, RECT* rect, int x, int y); +extern void SetDrawOffset(DR_OFFSET* p, u_short* ofs); +extern void SetDumpFnt(int id); +extern void SetLineF2(LINE_F2* p); +extern void SetLineF3(LINE_F3* p); +extern void SetLineF4(LINE_F4* p); +extern void SetLineG2(LINE_G2* p); +extern void SetLineG3(LINE_G3* p); +extern void SetLineG4(LINE_G4* p); +extern void SetPolyF3(POLY_F3* p); +extern void SetPolyF4(POLY_F4* p); +extern void SetPolyFT3(POLY_FT3* p); +extern void SetPolyFT4(POLY_FT4* p); +extern void SetPolyG3(POLY_G3* p); +extern void SetPolyG4(POLY_G4* p); +extern void SetPolyGT3(POLY_GT3* p); +extern void SetPolyGT4(POLY_GT4* p); +extern void SetSemiTrans(void* p, int abe); +extern void SetShadeTex(void* p, int tge); +extern void SetSprt(SPRT* p); +extern void SetSprt16(SPRT_16* p); +extern void SetSprt8(SPRT_8* p); +extern void SetTexWindow(DR_TWIN* p, RECT* tw); +extern void SetTile(TILE* p); +extern void SetTile1(TILE_1* p); +extern void SetTile16(TILE_16* p); +extern void SetTile8(TILE_8* p); +extern void TermPrim(void* p); +extern int ResetGraph(int mode); +int SetGraphDebug(int level); +extern int SetGraphReverse(int mode); +extern int SetGraphQueue(int mode); +extern u_long DrawSyncCallback(void (*func)()); +extern void FntLoad(int tx, int ty); +int FntPrint(const char* fmt, ...); +extern void SetDispMask(int mask); +extern void SetDrawMode(DR_MODE* p, int dfe, int dtd, int tpage, RECT* tw); +extern void SetDumpFnt(int id); +extern int CheckPrim(char* s, OT_TYPE* p); +extern int ClearImage(RECT* rect, u_char r, u_char g, u_char b); +extern int DrawSync(int mode); +extern int FntOpen(int x, int y, int w, int h, int isbg, int n); +extern int GetGraphDebug(void); +extern u_long* FntFlush(int id); +extern int KanjiFntOpen(int x, int y, int w, int h, int dx, int dy, int cx, + int cy, int isbg, int n); +extern int LoadImage(RECT* rect, u_long* p); +extern int MargePrim(void* p0, void* p1); +extern int StoreImage(RECT* rect, u_long* p); +extern int MoveImage(RECT* rect, int x, int y); +extern int OpenTIM(u_long* addr); +extern OT_TYPE* ClearOTag(OT_TYPE* ot, int n); +extern OT_TYPE* ClearOTagR(OT_TYPE* ot, int n); +extern DRAWENV* PutDrawEnv(DRAWENV* env); +extern DISPENV* PutDispEnv(DISPENV* env); +extern DISPENV* SetDefDispEnv(DISPENV* env, int x, int y, int w, int h); +extern DRAWENV* SetDefDrawEnv(DRAWENV* env, int x, int y, int w, int h); +extern TIM_IMAGE* ReadTIM(TIM_IMAGE* timimg); + +#endif diff --git a/include/psxsdk/libgs.h b/include/psxsdk/libgs.h new file mode 100644 index 0000000..f1c9010 --- /dev/null +++ b/include/psxsdk/libgs.h @@ -0,0 +1,48 @@ +#ifndef LIBGS_H +#define LIBGS_H + +#include + +#define GsOFSGTE 0 +#define GsOFSGPU 4 +#define GsINTER 1 +#define GsNONINTER 0 +#define GsRESET0 0 +#define GsRESET3 (3 << 4) + +typedef unsigned char PACKET; + +typedef struct { +#ifndef __psyz + unsigned p : 24; + unsigned char num : 8; +#else + O_TAG; +#endif +} GsOT_TAG; + +typedef struct { + unsigned long length; + GsOT_TAG* org; + unsigned long offset; + unsigned long point; + GsOT_TAG* tag; +} GsOT; + +void GsClearVcount(void); +long GsGetVcount(); +void GsInitVcount(); +void GsClearOt(unsigned short offset, unsigned short point, GsOT* otp); +void GsInitGraph(unsigned short x, unsigned short y, unsigned short intmode, + unsigned short dith, unsigned short varmmode); +void GsDefDispBuff( + unsigned short x0, unsigned short y0, unsigned short x1, unsigned short y1); +int GsGetActiveBuff(void); +void GsSetWorkBase(PACKET* outpacketp); +void GsSwapDispBuff(void); +void GsSortClear(unsigned char, unsigned char, unsigned char, GsOT*); +void GsDrawOt(GsOT* ot); +void GsSetDrawBuffClip(void); +void GsSetDrawBuffOffset(void); + +#endif diff --git a/include/psxsdk/libgte.h b/include/psxsdk/libgte.h new file mode 100644 index 0000000..03ba161 --- /dev/null +++ b/include/psxsdk/libgte.h @@ -0,0 +1,160 @@ +#ifndef LIBGTE_H +#define LIBGTE_H +#include + +void InitGeom(); + +typedef struct { + short m[3][3]; // 3 x 3 matrix coefficient value + long t[3]; // Parallel transfer volume +} MATRIX; // size = 0x1E + +typedef struct { + long vx, vy, vz; // Vector coordinates + long pad; // System reserved +} VECTOR; // size = 0x10 + +typedef struct { + short vx, vy, vz; // Vector coordinates + short pad; // System reserved +} SVECTOR; // size = 0x8 + +typedef struct { + u_char r, g, b; // Color palette + u_char cd; // GPU code +} CVECTOR; + +MATRIX* RotMatrix(SVECTOR* r, MATRIX* m); +void SetGeomOffset(long ofx, long ofy); +long RotTransPers(SVECTOR*, long*, long*, long*); +void SetGeomScreen(long h); +void SetRotMatrix(MATRIX* m); +MATRIX* TransMatrix(MATRIX* m, VECTOR* v); +void SetTransMatrix(MATRIX* m); +long RotTransPers4( + SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, + SVECTOR* v3, // Pointers to vectors (input) + long* v10, long* v11, long* v12, + long* v13, // Pointers to screen coordinates + long* p, // Pointer to interpolated value for depth cueing + long* flag // Pointer to flag +); +long RotAverageNclip4( + SVECTOR* v0, SVECTOR* v1, SVECTOR* v2, + SVECTOR* v3, // Pointer to vectors (input) + long* sxy0, long* sxy1, long* sxy2, + long* sxy3, // Pointer to coordinates (output) + long* p, // Pointer to interpolation value (output) + long* otz, // Pointer to OTZ value (output) + long* flag // Pointer to flag (output) +); +void NormalColorCol(SVECTOR* v0, // Pointer to normal vector (input) + CVECTOR* v1, // Pointer to primary color vector (input) + CVECTOR* v2 // Pointer to color vector (output) +); +MATRIX* RotMatrixY(long r, // Rotation angle(input) + MATRIX* m // Pointer to rotation matrix (input/output) +); +MATRIX* MulMatrix2(MATRIX* m0, MATRIX* m1); +void RotTrans(SVECTOR* v0, VECTOR* v1, int* flag); +void SetBackColor(long rbk, long gbk, long bbk); +void SetColorMatrix(MATRIX* m); +void SetLightMatrix(MATRIX* m); +void SetTransMatrix(MATRIX* m); +void SetFarColor(long rfc, long gfc, long bfc); // Color values (input) +void SetFogNear(long a, long h); // Distance between visual point and screen + +extern long SquareRoot0(long a); +extern long SquareRoot12(long a); +extern int rcos(int a); +extern int rsin(int a); +extern long ratan2(long y, long x); + +#define gte_SetRotMatrix(r0) \ + __asm__ volatile( \ + "lw $12, 0( %0 );" \ + "lw $13, 4( %0 );" \ + "ctc2 $12, $0;" \ + "ctc2 $13, $1;" \ + "lw $12, 8( %0 );" \ + "lw $13, 12( %0 );" \ + "lw $14, 16( %0 );" \ + "ctc2 $12, $2;" \ + "ctc2 $13, $3;" \ + "ctc2 $14, $4" \ + : \ + : "r"(r0) \ + : "$12", "$13", "$14") + +#define gte_SetTransMatrix(r0) \ + __asm__ volatile( \ + "lw $12, 20( %0 );" \ + "lw $13, 24( %0 );" \ + "ctc2 $12, $5;" \ + "lw $14, 28( %0 );" \ + "ctc2 $13, $6;" \ + "ctc2 $14, $7" \ + : \ + : "r"(r0) \ + : "$12", "$13", "$14") +#define gte_ldv0(r0) \ + __asm__ volatile("lwc2 $0, 0( %0 );" \ + "lwc2 $1, 4( %0 )" \ + : \ + : "r"(r0)) + +// NOTE: These are not the official defines in the SDK. +// They were identified by looking at functions which used them. +#define gte_rtps() \ + __asm__ volatile("nop;" \ + "nop;" \ + ".word 0x4A180001") +#define gte_rtpt() \ + __asm__ volatile("nop;" \ + "nop;" \ + ".word 0x4A280030") +#define gte_nclip() \ + __asm__ volatile("nop;" \ + "nop;" \ + ".word 0x4B400006") + +#define gte_stsxy2(r0) \ + __asm__ volatile("swc2 $14, 0( %0 )" : : "r"(r0) : "memory") +#define gte_stszotz(r0) \ + __asm__ volatile( \ + "mfc2 $12, $19;" \ + "nop;" \ + "sra $12, $12, 2;" \ + "sw $12, 0( %0 )" \ + : \ + : "r"(r0) \ + : "$12", "memory") + +#define gte_ldv3(r0, r1, r2) \ + __asm__ volatile( \ + "lwc2 $0, 0( %0 );" \ + "lwc2 $1, 4( %0 );" \ + "lwc2 $2, 0( %1 );" \ + "lwc2 $3, 4( %1 );" \ + "lwc2 $4, 0( %2 );" \ + "lwc2 $5, 4( %2 )" \ + : \ + : "r"(r0), "r"(r1), "r"(r2)) + +#define gte_stopz(r0) \ + __asm__ volatile("swc2 $24, 0( %0 )" : : "r"(r0) : "memory") + +#define gte_stsxy3(r0, r1, r2) \ + __asm__ volatile( \ + "swc2 $12, 0( %0 );" \ + "swc2 $13, 0( %1 );" \ + "swc2 $14, 0( %2 )" \ + : \ + : "r"(r0), "r"(r1), "r"(r2) \ + : "memory") +#define gte_stsxy(r0) \ + __asm__ volatile("swc2 $14, 0( %0 )" : : "r"(r0) : "memory") + +#define gte_SetGeomScreen(r0) __asm__ volatile("ctc2 %0, $26" : : "r"(r0)) + +#endif diff --git a/include/psxsdk/libpress.h b/include/psxsdk/libpress.h new file mode 100644 index 0000000..6a8d66d --- /dev/null +++ b/include/psxsdk/libpress.h @@ -0,0 +1 @@ +extern void DecDCTReset(int mode); diff --git a/include/psxsdk/libsn.h b/include/psxsdk/libsn.h new file mode 100644 index 0000000..31b6696 --- /dev/null +++ b/include/psxsdk/libsn.h @@ -0,0 +1,8 @@ + +int PCinit(void); +int PCopen(char* name, int flags, int perms); +int PCcreat(char* name, int perms); +int PClseek(int fd, int offset, int mode); +int PCread(int fd, char* buff, int len); +int PCwrite(int fd, char* buff, int len); +int PCclose(int fd); diff --git a/include/psxsdk/libsnd.h b/include/psxsdk/libsnd.h new file mode 100644 index 0000000..b22fb68 --- /dev/null +++ b/include/psxsdk/libsnd.h @@ -0,0 +1,180 @@ +#ifndef LIBSND_H +#define LIBSND_H + +#define SS_SEQ_TABSIZ 176 + +#define SS_NOTICK 0x1000 +#define SS_NOTICK0 0 +#define SS_TICK60 1 +#define SS_TICK240 2 +#define SS_TICK120 3 +#define SS_TICK50 4 +#define SS_TICKVSYNC 5 +#define SS_TICKMODE_MAX 6 + +#define SS_IMEDIATE 0 +#define SS_IMMEDIATE 0 +#define SS_WAIT_COMPLETED 1 + +#define SS_REV_TYPE_OFF 0 +#define SS_REV_TYPE_ROOM 1 +#define SS_REV_TYPE_STUDIO_A 2 +#define SS_REV_TYPE_STUDIO_B 3 +#define SS_REV_TYPE_STUDIO_C 4 +#define SS_REV_TYPE_HALL 5 +#define SS_REV_TYPE_SPACE 6 +#define SS_REV_TYPE_ECHO 7 +#define SS_REV_TYPE_DELAY 8 +#define SS_REV_TYPE_PIPE 9 + +#define SS_SOFF 0 +#define SS_SON 1 +#define SS_MIX 0 +#define SS_REV 1 +#define SS_SERIAL_A 0 +#define SS_SERIAL_B 1 + +// Closes the SEQ data holding the seq_acces_num that is no longer necessary. +extern void SsSeqClose(short seq_access_num); + +/** + * Sets the main volume value in voll and volr respectively. + * Each can be set from 0 to 127. + * It is essential to set it before SEQ data is played. + */ +extern void SsSetMVol(short voll, short volr); + +// Carries out attribute setting relating to CD audio. +extern void SsSetSerialAttr(char s_num, char attr, char mode); +/** + * Sets the CD volume value in voll and volr. + * The volume value can be set from 0 to 127. + */ +extern void SsSetSerialVol(short s_num, short voll, short volr); + +/** + * Clears the area occupied by the reverb work + * area corresponding to the reverb mode. + * Returns 0 if successful. + */ +extern long SpuClearReverbWorkArea(long rev_mode // Reverb mode +); + +/** + * Initializes the sound system, without destroying data that has been + * transferred to the sound buffer. Using Exec()-related functions, when a child + * process wants to initialize the sound system with the sound buffer in its + * current state, it should call SsInitHot() instead of calling SsInit(). + */ +void SsInitHot(void); + +/** + * Declares the number of voices that the libsnd voice allocation management + * system has access to. Other voices can be keyed on in libspu or via + * SsUtKeyOnV(). Voice numbers are reserved from the lower end (from 0). + * For example, if voices = 20, then: + * (*) Voices 0-19 are used for allocation by libsnd. + * (*) Voices 20-23 are available for libspu. + * + * Returns the set voice count if successful. Returns -1 if unsuccessful + */ +char SsSetReservedVoice(char voices // Voice count +); + +/** + * Sets the resolution of a tick. Call this function only once before calling + * SsSeqOpen(), SsSepOpen() or SsStart() for the first time. When it is called + * multiple times, correct operation cannot be guaranteed. + */ +void SsSetTickMode(long tick_mode // Tick mode +); + +/** + * Starts the sound system.When SsSetTickMode() is used to set + * a mode that calls SsSeqCalledTbyT() automatically, this + * function causes SsSeqCalledTbyT() to be called each tick. + */ +void SsStart(void); + +/** + * Keys on the voice specified by the voice number (0-23), the VAB number, the + * program number (0-127), and the tone number (0-15) at the specified pitch and + * volume, and returns the allocated voice number. + */ +short SsUtKeyOnV( + short voice, // Voice number (0-23) + short vabId, // VAB number (0-31) returned by SsVabOpenHead() + short prog, // Program number (0-127) + short tone, // Tone number (0-15) + short note, // Pitch specification in semitones (note number) (0-127) + short fine, // Detailed pitch specification (100/127 cents) (0-127) + short voll, // Volume, left (0-127) + short volr // Volume, right (0-127) +); + +// Sets the left and right volumes of the specified voice, vc. Since libsnd uses +// an exponential volume calculation for sounds being keyed on, the input +// volumes voll and volr are modified as (vol * vol / 127). +// 0 if successful, -1 if unsuccessful. +short SsUtSetVVol(short vc, // Voice number (0-23) + short voll, // Volume left (0-127) + short volr // Volume right (0-127) +); + +void SpuGetAllKeysStatus(char* status); + +// Specify the area of a SEQ/SEP data attribute table +void SsSetTableSize( + char* table, // Pointer to SEQ/SEP data attribute table area variable + short s_max, // Maximum times to open SEQ/SEP data (up to 32) + short t_max // Number of SEQ included in SEP +); + +// Terminate SEQ data reading. +void SsSeqStop(short seq_access_num // SEQ access number +); + +// Sets the output to monaural mode. Forces all libsnd keyed-on voices to have +// equivalent left and right volumes.Stereo mode is the system default mode. +void SsSetMono(void); + +// Sets the output to stereo mode. The sound system default output is stereo. +void SsSetStereo(void); + +// Open a VAB header and specify transfer address in sound buffer. +s32 /*short*/ SsVabOpenHeadSticky( + u_char* addr, // Start address of VAB header (.VH) in main memory + u_long vabid, // Desired VAB ID or -1 + u_long sbaddr // Start address in sound buffer where VabBody is to be + // transferred +); + +// Starts transferring a VAB body in main memory, whose VAB header was opened +// with SsVabOpenHead(), to the sound buffer. +s32 /*short*/ SsVabTransBodyPartly( + u_char* addr, // Pointer to starting address of the segment transfer buffer + u_long bufsize, // Buffer size + u_long vabid // VAB ID +); + +// Determines whether data transfer to SPU local memory has terminated +s32 /*short*/ SsVabTransCompleted( + short immediateFlag // Transfer status recognition flag +); + +// Set reverb type +void SsUtSetReverbType(short type); + +// Turns on global Reverb at the type and depth set by SsUtSetReverbType() and +// SsUtSetReverbDepth(). +void SsUtReverbOn(void); + +// Set a reverb depth +void SsUtSetReverbDepth( + short ldepth, // Left channel depth. Value between 0 and 127 + short rdepth // Right channel depth. Value between 0 and 127 +); + +void SsUtSetReverbDelay(short delay); + +#endif diff --git a/include/psxsdk/libspu.h b/include/psxsdk/libspu.h new file mode 100644 index 0000000..ec53cfa --- /dev/null +++ b/include/psxsdk/libspu.h @@ -0,0 +1,102 @@ +#ifndef LIBSPU_H +#define LIBSPU_H + +#define SPU_VOICE_VOLL (0x01 << 0) // volume (left) +#define SPU_VOICE_VOLR (0x01 << 1) // volume (right) +#define SPU_VOICE_VOLMODEL (0x01 << 2) // volume mode (left) +#define SPU_VOICE_VOLMODER (0x01 << 3) // volume mode (right) +#define SPU_VOICE_PITCH (0x01 << 4) // tone (pitch setting) +#define SPU_VOICE_NOTE (0x01 << 5) // tone (note setting) +#define SPU_VOICE_SAMPLE_NOTE (0x01 << 6) // waveform data sample note +#define SPU_VOICE_WDSA (0x01 << 7) // waveform data start address +#define SPU_VOICE_ADSR_AMODE (0x01 << 8) // ADSR Attack rate mode +#define SPU_VOICE_ADSR_SMODE (0x01 << 9) // ADSR Sustain rate mode +#define SPU_VOICE_ADSR_RMODE (0x01 << 10) // ADSR Release rate mode +#define SPU_VOICE_ADSR_AR (0x01 << 11) // ADSR Attack rate +#define SPU_VOICE_ADSR_DR (0x01 << 12) // ADSR Decay rate +#define SPU_VOICE_ADSR_SR (0x01 << 13) // ADSR Sustain rate +#define SPU_VOICE_ADSR_RR (0x01 << 14) // ADSR Release rate +#define SPU_VOICE_ADSR_SL (0x01 << 15) // ADSR Sustain level +#define SPU_VOICE_LSAX (0x01 << 16) // start address for loop +#define SPU_VOICE_ADSR_ADSR1 (0x01 << 17) // ADSR adsr1 for `VagAtr' +#define SPU_VOICE_ADSR_ADSR2 (0x01 << 18) // ADSR adsr2 for `VagAtr' + +#define SPU_REV_MODE (0x01 << 0) // mode setting +#define SPU_REV_DEPTHL (0x01 << 1) // reverb depth (left) +#define SPU_REV_DEPTHR (0x01 << 2) // reverb depth (right) +#define SPU_REV_DELAYTIME (0x01 << 3) // Delay Time (ECHO, DELAY only) +#define SPU_REV_FEEDBACK (0x01 << 4) // Feedback (ECHO only) + +#define SPU_REV_MODE_CHECK (-1) +#define SPU_REV_MODE_OFF 0 +#define SPU_REV_MODE_ROOM 1 +#define SPU_REV_MODE_STUDIO_A 2 +#define SPU_REV_MODE_STUDIO_B 3 +#define SPU_REV_MODE_STUDIO_C 4 +#define SPU_REV_MODE_HALL 5 +#define SPU_REV_MODE_SPACE 6 +#define SPU_REV_MODE_ECHO 7 +#define SPU_REV_MODE_DELAY 8 +#define SPU_REV_MODE_PIPE 9 +#define SPU_REV_MODE_MAX 10 + +#define SPU_REV_MODE_CLEAR_WA 0x100 + +#define SPU_OFF 0 +#define SPU_ON 1 + +#ifndef __SPU_IRQCALLBACK_PROC +#define __SPU_IRQCALLBACK_PROC +typedef void (*SpuIRQCallbackProc)(void); +#endif + +typedef struct { + short left; // left channel + short right; // right channel +} SpuVolume; + +typedef struct { + /* 0x00 */ unsigned long voice; // each voice is a bit value + /* 0x04 */ unsigned long mask; // settings attribute bit (invalid with Get) + /* 0x08 */ SpuVolume volume; // volume + /* 0x0C */ SpuVolume volmode; // volume mode + /* 0x10 */ SpuVolume volumex; // current volume (invalid with Set) + /* 0x14 */ unsigned short pitch; // tone (pitch setting) + /* 0x16 */ unsigned short note; // tone (note setting) + /* 0x18 */ unsigned short sample_note; // tone (note setting) + /* 0x1A */ short envx; // current envelope value (invalid with Set) + /* 0x1C */ unsigned long addr; // waveform data start address + /* 0x20 */ unsigned long loop_addr; // loop start address + /* 0x24 */ long a_mode; // Attack rate mode + /* 0x28 */ long s_mode; // Sustain rate mode + /* 0x2C */ long r_mode; // Release rate mode + /* 0x30 */ unsigned short ar; // Attack rate + /* 0x32 */ unsigned short dr; // Decay rate + /* 0x34 */ unsigned short sr; // Sustain rate + /* 0x36 */ unsigned short rr; // Release rate + /* 0x38 */ unsigned short sl; // Sustain level + /* 0x3A */ unsigned short adsr1; // adsr1 for `VagAtr' + /* 0x3C */ unsigned short adsr2; // adsr2 for `VagAtr' +} SpuVoiceAttr; // size=0x3E + +typedef struct { + unsigned long mask; // settings mask + long mode; // reverb mode + SpuVolume depth; // reverb depth + long delay; // Delay Time (ECHO, DELAY only) + long feedback; // Feedback (ECHO only) +} SpuReverbAttr; + +extern long SpuSetTransferMode(long mode); +extern unsigned long SpuWrite(unsigned char* addr, unsigned long size); + +extern long SpuSetReverbModeParam(SpuReverbAttr* attr); + +extern void SpuSetVoiceAttr(SpuVoiceAttr* arg); +extern void SpuSetKey(long on_off, unsigned long voice_bit); + +extern long SpuMallocWithStartAddr(unsigned long addr, long size); + +extern SpuIRQCallbackProc SpuSetIRQCallback(SpuIRQCallbackProc); + +#endif diff --git a/include/psxsdk/romio.h b/include/psxsdk/romio.h new file mode 100644 index 0000000..be01d5e --- /dev/null +++ b/include/psxsdk/romio.h @@ -0,0 +1,35 @@ +#ifndef _ROMIO_H +#define _ROMIO_H + +#define FREAD 0x0001 /* readable */ +#define FWRITE 0x0002 /* writable */ +#define FNBLOCK 0x0004 /* non-blocking reads */ +#define FRLOCK 0x0010 /* read locked (non-shared) */ +#define FWLOCK 0x0020 /* write locked (non-shared) */ +#define FAPPEND 0x0100 /* append on each write */ +#define FCREAT 0x0200 /* create if nonexistant */ +#define FTRUNC 0x0400 /* truncate to zero length */ +#define FSCAN 0x1000 /* scan type */ +#define FRCOM 0x2000 /* remote command entry */ +#define FNBUF 0x4000 /* no ring buf. and console interrupt */ +#define FASYNC 0x8000 /* asyncronous i/o */ + +#define O_RDONLY FREAD +#define O_WRONLY FWRITE +#define O_RDWR FREAD | FWRITE +#define O_CREAT FCREAT /* open with file create */ +#define O_NOBUF FNBUF /* no device buffer and console interrupt */ +#define O_NBLOCK FNBLOCK /* non blocking mode */ +#define O_NOWAIT FASYNC /* asyncronous i/o */ + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#endif diff --git a/include/psxsdk/types.h b/include/psxsdk/types.h new file mode 100644 index 0000000..09307da --- /dev/null +++ b/include/psxsdk/types.h @@ -0,0 +1,36 @@ +#ifndef TYPES_H +#define TYPES_H + +#ifndef __psyz +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned long u_long; +typedef unsigned int size_t; +#else +#include +#endif + +#ifdef _MSC_VER +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned long long u_long; +#endif + +typedef signed char byte; +#ifndef __cplusplus +typedef enum { false, true } bool; +#endif + +#ifndef NULL +#define NULL (0) +#endif + +#endif diff --git a/mako.sh b/mako.sh new file mode 100755 index 0000000..3bd3afb --- /dev/null +++ b/mako.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +go run ./tools/builder "$@" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..03ea47d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +splat64==0.34.3 +spimdisasm==1.35.0 +rabbitizer +colorama +watchdog +levenshtein +cxxfilt +pygfxd +crunch64 +pyyaml +n64img +pycparser diff --git a/src/battle/batini.c b/src/battle/batini.c new file mode 100644 index 0000000..c0731da --- /dev/null +++ b/src/battle/batini.c @@ -0,0 +1,276 @@ +#include "battle.h" + +extern Unk801B2308 D_80163624; +extern u16 D_8016376C; +void func_800A3354(void); // battle callback for batini, move to battle.h +void func_801B2308(void); + +// entrypoint +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B0050); + +static void func_801B23E0(s32 sceneID, void (*cb)(void)); +void func_801B0490(s32 sceneID) { + s32 i; + s32 var_s1; + s8* temp; + + var_s1 = 4; + if (D_8016376C) { + var_s1 = 0; + func_800A7254(0, 0, 15, 0); + func_800A7254(0, 0, 14, 0); + } + for (i = 0; i < 0x40; i++) { + if (D_800F6936[i][0] >= var_s1) { + D_800F6936[i][0] = -1; + } + } + for (i = 0; i < 3; i++) { + D_800F5E60[i].unk6 = 0; + } + if (D_8016376C) { + func_801B0F08(); + } + func_801B23E0(sceneID, func_800A3354); + func_801B1E0C(); + D_800F83AE[0][0] = 0; + for (i = 0; i < 10; i++) { + func_800AE954(i); + temp = (s8*)&D_800F83AE[i][0x19]; + if (temp[8] != -1) { + D_800F83AE[0][0] |= 1 << i; + } + } + D_800F83CC = sceneID; + D_800F83A8 = D_80163624.unk2; + func_801B19AC(); + func_800A4540(); + func_801B2308(); + func_800A4540(); + for (i = 4; i < 10; i++) { + D_800F5BBC[i][0] = ((u8)func_80014BA8(0x40) + 0x80) << 8; + func_800B108C(i); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B0668); + +void func_801B085C(s32 arg0) { + D_800F5F44.D_800F7DA6 = 0x10000 / ((arg0 * 480 / 256 + 0x78) * 2); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B08C0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B0F08); + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1120); + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B11BC); + +void func_801B137C(s32 arg0) { + s32 i; + Unk8009D84C* unk; + + unk = &D_8009D84C[arg0]; + unk->unk21 = 1; + for (i = 1; i < 4; i++) { + unk->un4C[i][0] = 0xFF; + unk->un4C[i][1] = 0; + unk->un4C[i][2] = 0; + unk->un4C[i][3] = 3; + unk->un4C[i][4] = 0; + unk->un4C[i][5] = 0; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B13DC); + +s32 func_801B14E8(u32 arg0) { + u8 temp_v1; + s32 ret; + + temp_v1 = arg0; + ret = 0; + if (temp_v1 != 0xFF && (D_800730CC[temp_v1].unk11 & 0xF) == 7) { + ret = (arg0 >> 8) | 0x80000000; + } + return ret; +} + +s32 func_801B1530(u32* arg0) { + s32 ret; + s32 i; + + ret = 0; + for (i = 0; i < 8; i++) { + ret |= func_801B14E8(arg0[0x10 + i]); + ret |= func_801B14E8(arg0[0x18 + i]); + } + return ret; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1598); + +const s32 D_801B001C[] = {0x0000, 0x1000, 0x0008, 0x0800}; +const s32 D_801B002C[] = {0x0000, 0x000A, 0x0027, 0x000A}; +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1734); + +typedef struct { + s32 unk0; + s32 unk4; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + s16 unk10; + s16 unk12; + s16 unk14; + s16 unk16; + u8 unk18[0x1C]; +} Unk801B18F8; // size:0x34 +void func_801B18F8(Unk8009D84C* arg0, Unk801B18F8* arg1, Unk800F83E0* arg2) { + arg2->unk14 = arg0->unk6; + arg2->unk15 = arg0->unk7; + arg2->unk30 = arg0->unk12; + arg2->unk2A = arg0->unk16; + arg2->unkD = arg0->unk8; + arg2->unkE = arg0->unkC; + arg2->unk20 = arg0->unkA; + arg2->unk22 = arg0->unkE; + if (arg2->unkD == 0) { + arg2->unkD = 1; + } + arg1->unk12 = arg2->unk30; + arg1->unk10 = arg2->unk2A; + if (arg0->unk23 & 8) { + arg1->unk16 = 999; + arg1->unk14 = 9999; + } else { + arg1->unk16 = 9999; + arg1->unk14 = 999; + } +} + +const u8 D_801B003C[] = {0xFF, 0x32, 0x33, 0x34, 0x35, 0xFF, 0x48, 0x07}; +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B19AC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1CB0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/batini", func_801B1E0C); + +void func_801B2308(void) { + s32 i; + + for (i = 0; i < 6; i++) { + if (D_80163624.unk34[i].unk0 != -1) { + func_800A6000(i + 4, 0, 0); + } + }; + for (i = 0; i < 6; i++) { + D_80163624.unk34[i].unkC = D_800F83E0[4 + i].unk4; + D_80163624.unk94[4 + i][1] = D_800F83E0[4 + i].unk10; + D_800F83E0[4 + i].unk44[0] = D_800F83E0[4 + i].unk0; + } +} + +static const s8 D_801B0044[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x03, 0x03, 0x03, 0x05, 0x6E, 0x64, 0x62}; +static void func_801B23E0(s32 sceneID, void (*cb)(void)) { + u8 dummy[0x100]; + SceneContainer scene; + s32 chunkID; + s32 temp_s1; + s32 formationIndex; + s32 i; + u_long* var_s2; + s32* var_s5; + s32* var_s3_2; + + var_s5 = (s32*)0x801C0000; + chunkID = sceneID / 4; + temp_s1 = func_801B2738(chunkID); // sector modified based on the Chunk ID + func_80033E34( // load file from disk + func_800144D8(BATTLE_SCENE) + + temp_s1 * 4, // Disk sector where to load the file from + 0x800 * 4, // Size in bytes to copy + (u_long*)var_s5, // Destination + NULL); + formationIndex = chunkID - D_80083184[temp_s1]; + func_800145BC(cb); // wait until all data is read, keep executing the vsync + // callback until then + i = var_s5[formationIndex]; + var_s3_2 = &var_s5[i]; + var_s2 = (u_long*)&scene; + func_80017108( // gzip decompress + var_s3_2, // src + var_s2); // dst + formationIndex = sceneID - chunkID * 4; + func_80014A00(D_8016360C.enemyModelIDs, scene.enemyModelIDs, + sizeof(scene.enemyModelIDs)); + func_80014A00((s32*)&D_8016360C.setup, &scene.setup[formationIndex], + sizeof(BattleSetup)); + func_80014A00((s32*)&D_8016360C.camera, &scene.camera[formationIndex], + sizeof(CameraPlacement) * 4); + func_80014A00((s32*)&D_8016360C.formation, &scene.formation[formationIndex], + sizeof(FormationEntry) * 6); + func_80014A00((s32*)&D_800F5F44.enemy, &scene.enemy, sizeof(scene.enemy)); + func_80014A00( + (s32*)&D_800F5F44.attacks, &scene.attacks, sizeof(scene.attacks)); + func_80014A00( + (s32*)&D_800F5F44.attackIDs, scene.attackIDs, sizeof(scene.attackIDs)); + func_80014A00((s32*)&D_800F5F44.attackNames, &scene.attackNames, + sizeof(scene.attackNames)); + func_80014A00((s32*)&D_800F5F44._5, &scene.unkC80, sizeof(Unk800F5F44_5)); + func_80014A00( + (s32*)&D_800F5F44.script, &scene.script, sizeof(scene.script)); + if (D_8016376A & 4 && D_8016360C.setup.flags & SETUP_NO_PREEMPTIVE_STRIKE) { + if (D_8016360C.setup.type == SETUP_DEFAULT) { + D_8016360C.setup.type = SETUP_PREEMPTIVE; + } + } + D_800F5F44.D_800F7DC8 = (u8)D_801B0044[D_8016360C.setup.type]; + if (D_8016376A & EVENT_BATTLE_SQUARE) { + D_8016360C.setup.stageID = 37; + D_8016360C.setup.flags |= SETUP_CANNOT_ESCAPE; + D_8016360C.setup.cameraID = (func_80014B70() & 3) + 0x60; + D_8016360C.setup.escapeCounter = 1; + // enemy strength and magic is 25% higher at battle square + for (i = 0; i < 3; i++) { + D_800F5F44.enemy[i].unk90[5] *= 2; + D_800F5F44.enemy[i].strength = + func_801B2770(D_800F5F44.enemy[i].strength); + D_800F5F44.enemy[i].magic = + func_801B2770(D_800F5F44.enemy[i].magic); + } + } else if (D_8016376A & 8) { + D_8016360C.setup.flags &= ~SETUP_CANNOT_ESCAPE; + } + if (!(D_8016360C.setup.flags & SETUP_CANNOT_ESCAPE)) { + D_8016376A |= 8; + } + D_800F5F44.D_800F7DB2 = D_8016360C.setup.escapeCounter; + if (D_800F5F44.D_800F7DC8 == 1 || D_800F5F44.D_800F7DC8 == 3) { + D_800F5F44.D_800F7DB2 = 1; + } + D_800F5F44.D_800F7DB6 = D_800F5F44.D_800F7DB2; +} + +s32 func_801B2738(s32 arg0) { + u32 i; + + for (i = 1; i < LEN(D_80083184); i++) { + if (arg0 < D_80083184[i]) { + break; + } + } + return i - 1; +} + +// increase param by 25% +s32 func_801B2770(s32 arg0) { + arg0 = (arg0 * 125) / 100; + if (arg0 > 255) { + arg0 = 255; + } + return arg0; +} diff --git a/src/battle/battle.c b/src/battle/battle.c new file mode 100644 index 0000000..7c471a7 --- /dev/null +++ b/src/battle/battle.c @@ -0,0 +1,1095 @@ +#include "battle_private.h" + +const u8 D_800A0000 = 0; +const u8 D_800A0001 = 0; +const u16 D_800A0002 = 0; +const u8 D_800A0004[] = { + 0x14, 0x11, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, + 0x21, 0x37, 0x00, 0x00, 0x22, 0x00, 0x06, 0x00, 0x26, 0x00, 0x12, 0x04, + 0x21, 0x0A, 0x00, 0x00, 0x21, 0x09, 0x00, 0x00, 0x28, 0xB1, 0x00, 0x20, + 0x2A, 0x11, 0x00, 0x00, 0x2C, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x24, 0x11, 0x04, 0x00, 0x00, 0x11, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, + 0x1F, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x15, 0x11, 0x00, 0x00, + 0x16, 0x11, 0x00, 0x10, 0x1C, 0x11, 0x02, 0x00, 0x18, 0x11, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00}; +const u8 D_800A0098[] = { + 0x1F, 0x0E, 0x09, 0x1F, 0x00, 0x0C, 0x09, 0x1F, 0x01, 0x0C, 0x09, 0x1F, + 0x02, 0x0D, 0x09, 0x1F, 0x1E, 0x09, 0x1F, 0x0A, 0x16, 0x09, 0x1F, 0x1D, + 0x09, 0x1F, 0x19, 0x09, 0x1F, 0x0E, 0x1C, 0x09, 0x1F, 0x0E, 0x1B, 0x09, + 0x1F, 0x1A, 0x09, 0x1F, 0x17, 0x1F, 0x03, 0x0C, 0x09, 0x1F, 0x1F, 0x1F, + 0x1F, 0x0E, 0x09, 0x1F, 0x04, 0x0B, 0x0F, 0x1F, 0x05, 0x1F, 0x06, 0x0C, + 0x09, 0x1F, 0x00, 0x0C, 0x09, 0x1F, 0x01, 0x0C, 0x09, 0x1F, 0x02, 0x0D, + 0x09, 0x1F, 0x0E, 0x09, 0x1F, 0x12, 0x0E, 0x09, 0x1F, 0x0E, 0x18, 0x09, + 0x1F, 0x10, 0x0E, 0x09, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x07, 0x0C, 0x09, + 0x1F, 0x08, 0x1F, 0x11, 0x1F, 0x13, 0x09, 0x1F, 0x14, 0x1F, 0x15, 0x0F, + 0x1F, 0x00, 0x00, 0x00}; +const s32 D_800A0108 = 21; +const s32 D_800A010C[] = {2, 22, 3, 23, 4}; + +// entrypoint +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A1158); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A1798); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A22C0); + +void func_800A23BC(s32 arg0) { + if (D_800E7A38 == arg0) { + D_800E7A38 = -1; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A23E0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A283C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A2894); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A2974); + +void func_800A2B28(s32 arg0) { + if (arg0 & 1) { + D_80063014->unk90 |= 0x80; + } + if (arg0 & 2) { + D_80063014->unk90 |= 0x40; + } + if (arg0 & 8) { + D_80063014->unk90 |= 0x04; + } + if (arg0 & 0x10) { + D_80063014->unk90 |= 0x800; + } + if (arg0 & 0xE0) { + D_80063014->unkE8 = (arg0 >> 5) * 10; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A2BF4); + +void func_800B10F0(s32, s32, s32, s32, s32, s32, s32); +void func_800A2CC4(s32 arg0) { + func_800B10F0(D_80063014->unk0, arg0, D_80063014->unk28, D_80063014->unk24, + D_80063014->unk98, 0, 0); +} + +const u8 D_800A01A8[] = {0x05, 0x06, 0x07, 0x12, 0x0F, 0x00, 0x03, 0xA6}; +u8 func_800A2D0C(void) { + s32 temp_v1; + + if (D_80063014->unk208 >= 3) { + return D_800F83E0[D_80063014->unk208].unk11; + } + return D_800A01A8[D_80063014->unkCC]; +} + +void func_800A2D68(u8 arg0) { + s32 i; + + for (i = 0; i < 8; i++) { + if (D_80063014->unkD0[i] == 0xFF) { + D_80063014->unkD0[i] = arg0; + return; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A2DB0); + +void func_800A2EFC(void) { + D_800F3950 = D_800F3944; + D_800F3954 = D_800F3948; +} + +void func_800A2F24(void) { + D_800F3944 = D_800F3950; + D_800F3948 = D_800F3954; +} + +Unk800A2F4C* func_800A2F4C(void) { + Unk800A2F4C* unk = &D_80163798[D_800F3944]; + unk->unk3 = 0; + unk->unk2 = 0; + unk->unkA = D_800F3948; + if (D_800F3944 < LEN(D_80163798)) { + D_800F3944++; + } else { + func_800155A4(40); + } + return unk; +} + +s8* func_800A2FD0(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A2FD0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A304C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A311C); + +void func_800A317C(void) { + s8* ret = func_800A2FD0(); + *ret = -1; +} + +void func_800A31A0(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + Unk800A2F4C* unk = func_800A2F4C(); + unk->unk0 = arg0; + unk->unk1 = arg1; + unk->unk5 = arg2; + unk->unk6 = arg3; + unk->unk8 = -1; + unk->unkA = -1; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3208); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3240); + +void func_800A3278(void) { + D_800F3944 = 0; + D_800F3948 = 0; + D_80163798[0].unk0 = -1; +} + +void func_800A329C(void) { + if (D_800F3944) { + D_800F3944--; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A32C0); + +void func_800A3354(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3354); + +void func_800A345C(void) { + if (D_800F3944) { + func_800A3354(); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3488); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A34CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3534); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A35F8); + +s32 func_800A37F8(s32 arg0) { + if (arg0 >= 0) { + D_800F39E0 = arg0; + D_800F39E4 = 0; + return 0; + } + return D_800F39E0; +} + +s32 func_800A3828(void) { + s32 ret = 0; + if (D_800F39E0 == 3) { + D_800F39E4 += D_800F5F44.D_800F7DA6; + } + if (D_800F5F44.D_800F7DAA == 2) { + switch (D_800F3896) { + case 0: + case 4: + case 5: + case 6: + case 7: + case 8: + case 24: + case 26: + case 27: + ret = 1; + break; + } + } + ret |= func_800A4A80(); + ret |= (D_800F83D0 & 3) ? 1 : 0; + if (D_800F39E4 > 0x4000) { + ret = 1; + } + return ret; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A38FC); + +typedef struct { + s8 unk0; + s8 unk1; + s8 unk2; + s8 unk3; + s16 unk4; + s16 unk6; +} Unk800A3D4C; // size:8 +void func_800A3D4C(Unk800A3D4C*); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3D4C); + +void func_800A3E98(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + Unk800A3D4C sp; + + sp.unk2 = arg0; + sp.unk0 = arg1; + sp.unk3 = arg2; + sp.unk4 = arg3; + sp.unk6 = arg4; + func_800A3D4C(&sp); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A3ED0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4350); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4480); + +s32 func_800A44D8(s32 arg0); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A44D8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4540); + +void func_800A4844(s32 arg0) { + s32 var_v0 = arg0 ? 3 : 1; + D_800F39EC = var_v0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4860); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4954); + +s32 func_800A4A80(void) { + s32 ret; + + ret = 1; + if (D_80163C7C > 3 && D_80163C7C < 6 && !(D_800F9DA4 & 1)) { + if (D_800FAFDC) { + ret = 1; + } else { + ret = 0; + } + } + return ret; +} + +void func_800A4ACC(s16 arg0, u16 arg1) { func_8001726C(arg0, arg1); } + +void func_800B6D6C(); +void func_800A4AF4(void) { + while (D_800F9DA4 & 2) { + func_800B6D6C(); + } +} + +u8 func_800A4B3C(s32 index, s32 arg1) { + if (arg1 != -1) { + D_801518E4[index].D_8015190F = arg1; + } + return D_801518E4[index].D_8015190F; +} + +void func_800A4B9C(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4BA4); + +u8 func_800A4CA8(s32 arg0) { return D_800F39F0[arg0][0]; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4CC8); + +void func_800A4D2C(s32 arg0) { + u32 i; + + if (D_800F83C6) { + return; + } + for (i = 0; i < LEN(D_800E7A48); i++) { + if (D_800E7A48[i] == arg0) { + return; + } + if (D_800E7A48[i] == 0xFF) { + D_800E7A48[i] = arg0; + return; + } + } +} + +void func_800A4D88(s32 arg0) { + u32 i; + + for (i = 0; i < LEN(D_800E7A48); i++) { + if (D_800E7A48[i] == arg0) { + for (; i < LEN(D_800E7A48) - 1; i++) { + D_800E7A48[i] = D_800E7A48[i + 1]; + if (D_800E7A48[i] == 0xFF) { + break; + } + } + return; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4E00); + +void func_800A4E40(void) { + u8 temp_s0; + + temp_s0 = D_800E7A48[0]; + if (temp_s0 != 0xFF) { + func_800A4D88(temp_s0); + func_800A4D2C(temp_s0); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4E80); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4F14); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A4F60); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A50E0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5250); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A555C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A55BC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A55F4); + +void func_800A5660(s32, s16); +; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5660); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A56B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5750); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5990); + +const u8 D_800A0240[] = { + 0xA8, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, + 0x54, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, + 0xA8, 0x54, 0x0A, 0x80, 0x94, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, + 0xA8, 0x54, 0x0A, 0x80, 0xA8, 0x54, 0x0A, 0x80, 0x14, 0x54, 0x0A, 0x80, + 0x34, 0x54, 0x0A, 0x80, 0x74, 0x54, 0x0A, 0x80}; +const u8 D_800A0278[] = { + 0x05, 0x06, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x00, 0x5C, 0x5A, + 0x0A, 0x80, 0x88, 0x5A, 0x0A, 0x80, 0xA8, 0x5A, 0x0A, 0x80}; +u8 func_800A5A5C(void) { return D_800A0278[func_80014BA8(7)]; } + +s32 func_800A5A88(void) { return func_80014BA8(54); } + +s32 func_800A5AA8(void) { return func_80014BA8(16) + 56; } + +const u8 D_800A028C[] = {0x02, 0xFF, 0x01, 0x86}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5AC8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5BC8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5E0C); + +s32 func_800A5EB0(s32, s16*); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5EB0); + +s8* func_800A5F90(s32 arg0) { return &D_800F3A80[D_800F4280[arg0]]; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5FB0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6000); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A61D4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6278); + +void func_800A64A0(s32 arg0, s8 arg1) { D_800E7A58[arg0] = arg1; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A64B4); + +void func_800A653C(s32 arg0) { + s32 index = func_800A44D8(arg0); + D_800F5BB8[index].unk4 = 0; + D_800F5F44.D_800F7DC2 &= ~(1 << index); +} + +void func_800A6590(s32 arg0) { func_800A4D88(arg0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A65B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A661C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A66A4); + +void func_800A6720(s32 arg0, s16 arg1) { func_800A5660(10, arg1); } + +void func_800A6748(s32 arg0) { + func_800A653C(arg0); + func_800A4D88(arg0); + D_800F5F44.D_800F7DAC &= ~(1 << arg0); +} + +void func_800A6798(s32 arg0, s32 arg1) { func_800A37F8(arg1); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A67B8); + +void func_800A6834(s32 arg0) { D_800F5F44.D_800F7DC4 &= ~(1 << arg0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6858); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A68FC); + +void func_800A6A3C(s32 arg0, s32 arg1) { D_800F5BB8[arg0].unkE |= arg1; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6A70); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6AC4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6B1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6B88); + +void func_800A6BFC(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6C04); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6C5C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6CC0); + +void func_800A6D10(s32 arg0) { func_800A3E98(arg0, 3, 2, 54, 0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6D3C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6D88); + +void func_800A6DFC(void) {} + +void func_800A6E04(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6E0C); + +void func_800A7254(s32, s32, s32, s32); +void func_800A6E6C(s32 arg0, s32 arg1) { func_800A7254(0, arg0, 13, arg1); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6E9C); + +void func_800B0FFC(s32, s32, s32, s16*); +void func_800A7034(s32 arg0, s16 arg1) { + s16 out = arg1; + func_800B0FFC(arg0, 0x53, 1, &out); +} + +void func_800A7060(s32 arg0, s32 arg1) { func_800A7254(0, arg0, 12, arg1); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7090); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A70C4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7130); + +void func_800A71E0(void) {} + +s32 func_800A71E8(s32 arg0) { return (arg0 + 1) & 0x7F; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A71F4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7254); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A72C8); + +void func_800A73C0(void) { D_80063014->unk2C = D_80063014->unk10; } + +void func_800A73D8(void) { D_80063014->unk2C = D_80063014->unk10 + 56; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A73F8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7458); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7560); + +void func_800A76AC(void) { D_80063014->unk2C = D_80063014->unk10 + 72; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A76CC); + +void func_800A7784(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A778C); + +const s16 D_800A0290[] = {0, 56, 72, 96, 256}; +const s32 D_800A029C[] = { + 0x140D0302, 0x3D3CFFFF, 0x41403F3E, 0xFFFFFF42, 0xFFFFFFFF, + 0x43424140, 0x47464544, 0xFF444843, 0xFFFFFFFF}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A784C); + +void func_800A7940(void) { + D_80063014->unk80 = 0x400000; + D_80063014->unkE4 = 0x59; +} + +void func_800B1060(s32); +void func_800A795C(void) { func_800B1060(D_80063014->unk10); } + +void func_800AF9C8(); +void func_800A7988(void) { func_800AF9C8(); } + +void func_800A79A8(void) { + D_80063014->unk50 = 0; + D_80063014->unk18 = 1 << D_80063014->unk0; +} + +void func_800A79CC(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A79CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A80DC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A81B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8424); + +void func_800A8528(void) { D_80063014->unkB4 = 4; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A853C); + +void func_800A85A0(void) { D_80063014->unkB4 = 2; } + +void func_800A85B4(void) { + D_80063014->unk44 = 0x10; + D_80063014->unk48 = 1; + D_80063014->unk50 = 0; + if (!((D_80163758[1] >> D_80063014->unk0) & 1)) { + D_80063014->unk20 = -1; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A85FC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A866C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8A6C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8C94); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8CC8); + +void func_800A8D04(void) { D_80063014->unk48 = 2; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8D18); + +void func_800A8D60(s32 arg0) { + if (D_80063014->unk50 == 0xFF) { + D_80063014->unk50 = arg0; + } +} + +static void func_800A8D88(s32 arg0, s32 arg1) { + D_80063014->unkBC = -1; + if (arg0 != 0xFF) { + D_80063014->unkBC = arg0; + D_80063014->unkC0 = arg1; + func_800A8E84(2); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8DCC); + +void func_800A8E34(void) { func_800A79CC(); } + +void func_800A8E54(s32 arg0) { + D_80063014->unkF8 = arg0; + D_80063014->unkAC = arg0 + 3; + if (D_80063014->unkAC > 8) { + D_80063014->unkAC = 8; + } +} + +const s16 D_800A02C0[] = { + 0x04, 0x3C, 0x04, 0x20, 0x01, 0x24, 0x10, 0x10, 0x04, 0x02, 0x02, 0x02, + 0x02, 0x01, 0x20, 0x04, 0x24, 0x10, 0x10, 0x04, 0x20, 0x10, 0x10, 0x10, + 0x30, 0x10, 0x20, 0x10, 0x10, 0x14, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8E84); + +static void func_800A9C24(void) { + s32 temp_s0; + s32 var_a0; + s32 var_s0; + s32 i; + + i = 0; + var_a0 = 0; + while (i < 7) { + if (D_80163774[0] == D_800E7BA4[var_a0 + 0] && + D_80163774[1] == D_800E7BA4[var_a0 + 1] && + D_80163774[2] == D_800E7BA4[(var_s0 = var_a0) + 2]) { + break; + } + i++; + var_a0 += 3; + } + if (i) { + D_80063014->unk2C = i + 0x68; + } else { + var_s0 = 4; + for (i = 0; i < 4; i++) { + var_s0 += func_80014BA8(10) & 0xFF; + func_80014B54(); + } + var_s0 += D_80063014->unk4 / 21; + var_s0 /= 2; + var_s0 -= 4; + if (var_s0 < 0) { + var_s0 = 0; + } + if (var_s0 > 0xF) { + var_s0 = 0xF; + } + D_80063014->unk2C = var_s0 + 0x38; + D_80063014->unk28 = 3; + } + D_80063014->unk50 = 0xFF; + D_80063014->unk98 = D_80063014->unk2C; + temp_s0 = D_80063014->unk20; + func_800A8E34(); + D_80063014->unk20 = temp_s0; + D_80063014->unk38 = 0; +} + +const u8 D_800A0398[] = {0x64, 0x14, 0x14, 0x14, 0xEC, 0xCE, 0xCE, 0x00}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A9DA0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AA1C8); + +static void func_800AA468(void) { + s32 temp_s0; + s32 var_s1; + + var_s1 = D_80063014->unkC8; + if (func_800B10B4(D_80063014->unk0)) { + var_s1 |= 2; + } + temp_s0 = func_80014A58(var_s1 & 0x0400029A); + temp_s0 += func_80014A58(var_s1 & 0x202000) * 2; + D_80063014->unk214 *= temp_s0 + 1; +} + +static void func_800AA4FC(void) { + s32 var_s0; + + var_s0 = 1; + if (func_800B10B4(D_80063014->unk0) != 0) { + var_s0 = 2; + } + if (D_80063014->unkC8 & 0x200000) { + var_s0 *= 4; + } + D_80063014->unk214 *= var_s0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AA574); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AA688); + +s32 func_800AA6E8(s32 arg0, s32 arg1) { + arg0 = arg0 < 4 ? 1 : 0; + if (arg1 < 4) { + arg0++; + } + return arg0 & 1; +} + +static s32 func_800AA700(s32 arg0) { + s32 var_v0; + + var_v0 = 0xF; + if (arg0 < 4) { + var_v0 = 0x3F0; + } + return func_800B3030(*D_80163758 & var_v0) & 0xFFFF; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AA738); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AA950); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AABBC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB308); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB480); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB674); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB788); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB830); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AB9C4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ABA68); + +const s32 D_800A03A0[] = {0x200, 0x100, 0x010, 0x020}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ABB0C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AC6B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AC73C); + +void func_800ACA24(void) { + D_80063014->unk238 = 0; + D_80063014->unk23C = 0; + D_80063014->unk240 = 0; + D_80063014->unk244 = 0; + D_80063014->unk230 = 0; + D_80063014->unk214 = 0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ACA4C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ACB98); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ACD88); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ACE14); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ACE88); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD088); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD0FC); + +void func_800AD324(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + s32 temp_t0; + s32 var_a2; + + var_a2 = arg2; + temp_t0 = D_80063014->unk220 & 1; + if (arg3 & 1) { + if (arg1 == D_80063014->unk208) { + if (D_80063014->unk25C < var_a2) { + var_a2 = D_80063014->unk25C; + } + } + if (temp_t0) { + var_a2 = -var_a2; + } + D_800F5BB8[arg0].unk30 -= var_a2; + } + if (arg3 & 2) { + if (arg1 == D_80063014->unk208) { + if (D_80063014->unk258 < var_a2) { + var_a2 = D_80063014->unk258; + } + } + if (temp_t0) { + var_a2 = -var_a2; + } + D_800F5BB8[arg0].unk2C -= var_a2; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD420); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD480); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD4EC); + +const s8 D_800A04B0[] = { + 0x0A, 0x0B, 0x0C, 0x0D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x7F, 0x03, 0x34}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD5E8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD73C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD804); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD890); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD8DC); + +void func_800AD924(void) { D_80063014->unk218 |= 2; } + +void func_800AD944(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD944); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADBBC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADC70); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADD2C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADDE8); + +void func_800ADE5C(void) { D_80063014->unk214 = D_80063014->unk48 * 20; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADE84); + +void func_800ADED8(void) { + if (D_80063014->unk230 & 0x40) { + D_80063014->unk230 = 1; + } else { + D_80063014->unk230 = 0x80; + } +} + +void func_800ADF04(void) { + D_80063014->unk4C = D_80063014->unkD8 * 2; + func_800AD944(); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADF38); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADFC0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADFF4); + +void func_800AE050(void) {} + +void func_800AE058(void) {} + +void func_800AE060(void) {} + +void func_800AE068(void) {} + +void func_800AE070(void) {} + +void func_800AE078(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE080); + +void func_800AE234(void) { + D_80063014->unk214 = + Savemap.memory_bank_1[26] + Savemap.memory_bank_1[27] * 256; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE25C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE2A0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE318); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE378); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE42C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE6C0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE764); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE82C); + +void func_800AE954(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AE954); + +const s8 D_800A04BC[] = { + 0x1E, 0x14, 0x3C, 0x1E, 0x7F, 0x7F, 0x0A, 0x64, 0x7F, 0x7F, + 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x0D, 0x00, 0x00}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEB20); + +// this data belong to functions located above: +const s8 D_800A04D0[] = {0x0A, 0x19, 0x15, 0x0D, 0x10, 0x11, 0x03, 0x02, + 0x0F, 0x1B, 0x14, 0x18, 0xFF, 0xFF, 0xFF, 0xFF}; +int func_800B0378(); +int func_800B062C(); +int func_800B079C(); +int func_800B0B8C(); +int func_800B0910(); +int func_800B089C(); +int (* const D_800A04E0[])() = { + func_800B0378, func_800B062C, func_800B079C, func_800B0B8C, + func_800B0B8C, func_800B0B8C, func_800B0910, func_800B089C, +}; +// ___end + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEB80); + +void func_800AEBF0(void) { func_800AE954(); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEC10); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AEF68); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF0C4); + +void func_800A7254(s32, s32, s32, s32); +void func_800AF1A8(s32 arg0) { func_800A7254(0, arg0, 8, 0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF1D4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF264); + +void func_800AF320(s32 arg0, s32 arg1, s32 arg2) { + func_800AEBF0(); + func_800AEB80(arg0, arg1, arg2); + func_800AF0C4(arg0, arg1, arg2); +} + +void func_800AF380(s32 arg0) { func_800A7254(2, arg0, 0x15, 0xF); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF3AC); + +void func_800AF470(s32 arg0) { D_800F5BB8[arg0].unk28 = 3; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF494); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF594); + +void func_800B108C(s32 arg0); +void func_800AF63C(s32 arg0) { func_800B108C(arg0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF65C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF834); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF874); + +void func_800AF9C8(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AF9C8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AFE98); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AFECC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0170); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0234); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0378); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B062C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B079C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B089C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0910); + +int func_800B0B8C(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0B94); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0C14); + +void func_800B0DF8(void) { + if (D_80063014->unk234 & 2) { + D_800F83E0[D_80063014->unk208].unk4 ^= 0x80; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0E5C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0EB4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0F04); + +void func_800B0FFC(s32 arg0, s32 arg1, s32 arg2, s16* arg3) { + func_800A31A0( + arg0, 2, arg2, func_800A5EB0(func_8001521C(arg1), arg3) + 0x100); +} + +void func_800B1060(s32 arg0) { func_800A31A0(10, 2, 1, arg0); } + +void func_800B108C(s32 arg0) { func_800A31A0(arg0, 5, 0, 0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B10B4); + +void func_800B10F0(s32, s32, s32, s32, s32, s32, s32); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B10F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B11B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1218); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1268); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B12DC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1304); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1368); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B13B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B141C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B153C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1624); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B16D0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B17F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B18A8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1A5C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1AA0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1B64); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1C1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1C94); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B1D48); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2A2C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2B5C); + +u16* func_800B2EBC(); +s32 func_800B2C60(s32 arg0) { + s32 var_s0; + u16* ret; + + var_s0 = 0; + if (arg0 <= 0xFFFE) { + ret = func_800B2EBC(); + if (ret) { + var_s0 = ret[2]; + } + } + return var_s0; +} + +static void func_800B2CAC(s32 arg0, s32 arg1) { + switch (arg0) { + case 0: + D_800F83A6 = Savemap.memory_bank_1[arg1]; + return; + case 1: + Savemap.memory_bank_1[arg1] = D_800F83A6; + return; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2CFC); + +u16* func_800B2EBC(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2EBC); + +u8 func_800B2F30(void) { return func_80014B70(); } + +u16 func_800B2F50(void) { return func_80014BE4(); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2F70); + +static s32 func_800B2FC4(s32 arg0) { + return (arg0 * (func_800B2F30() + 0xF01)) >> 12; +} + +static s32 func_800B3000(u16 arg0) { + s32 count = 0; + + while (arg0 != 0) { + if (arg0 & 1) { + count++; + } + arg0 >>= 1; + } + return count; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B3030); diff --git a/src/battle/battle.h b/src/battle/battle.h new file mode 100644 index 0000000..e07ab3b --- /dev/null +++ b/src/battle/battle.h @@ -0,0 +1,366 @@ +#include + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/BattleFlags.cs#L4 +typedef enum { + SETUP_CANNOT_ESCAPE = 4, + SETUP_NO_VICTORY_POSE = 8, + SETUP_NO_PREEMPTIVE_STRIKE = 0x10, +} BattleSetupFlags; + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/BattleType.cs#L3 +typedef enum { + SETUP_DEFAULT, + SETUP_PREEMPTIVE, + SETUP_BACK_ATTACK, + SETUP_SIDE_ATTACK, + SETUP_PINCER, + SETUP_PINCER_2, + SETUP_SIDE_ATTACK_2, + SETUP_SIDE_ATTACK_3, + SETUP_FRONT_ROW_ONLY, + NUM_SETUP, +} BattleSetupType; + +typedef enum { + EVENT_BATTLE_SQUARE = 0x40, +} BattleEventType; + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; + s8 unkC; + u8 unkD; + s8 unkE; + s8 unkF; + s8 unk10; + s8 unk11; + s16 unk12; + s8 unk14; + s8 unk15; + s16 unk16; + s32 unk18; + s32 unk1C; + s16 unk20; + s16 unk22; + s32 unk24; + s16 unk28; + s16 unk2A; + s16 unk2C; + s16 unk2E; + s32 unk30; + u32 unk34[4]; + u32 unk44[9]; +} Unk800F83E0; // size:0x68 +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s16 unk8; + s16 unkA; + s32 unkC; +} UnkStruct; // size:0x10 +typedef struct { + s16 unk0; + u8 unk2; + u8 unk3; + /* 0x04 */ u8 unk4[0x30]; + /* 0x34 */ UnkStruct unk34[6]; + /* 0x94 */ u8 unk94[6][0x10]; +} Unk801B2308; + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/BattleSetupData.cs +typedef struct { + /* 0x00 0x80163614 */ u16 stageID; // load STAGE/ files + /* 0x02 0x80163616 */ s16 nextStageID; + /* 0x04 0x80163618 */ s16 escapeCounter; + /* 0x06 0x8016361A */ s16 D_8016361A; + /* 0x08 0x8016361C */ u16 D_8016361C[4]; + /* 0x10 0x80163624 */ u16 flags; // BattleSetupFlags + /* 0x12 0x80163626 */ u8 type; // BattleSetupType + /* 0x13 0x80163627 */ s8 cameraID; +} BattleSetup; // size:0x14 + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/CameraPlacementData.cs +typedef struct { + short x, y, z; +} CameraPos; +typedef struct { + CameraPos start; + CameraPos direction; +} CameraPlacement; // size:0xC + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/EnemyLocation.cs +typedef struct { + /* 0x00 */ u16 enemyID; + /* 0x02 */ u16 x, y, z; + /* 0x08 */ u16 row; + /* 0x0A */ u16 coverFlags; + /* 0x0C */ u32 flags; +} FormationEntry; // size:0x10 + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/SceneEditor/Enemy.cs +typedef struct { + /* 0x00 */ u8 name[0x20]; + /* 0x20 */ u8 level; + /* 0x21 */ u8 speed; + /* 0x22 */ u8 luck; + /* 0x23 */ u8 evade; + /* 0x24 */ u8 strength; + /* 0x25 */ u8 defense; + /* 0x26 */ u8 magic; + /* 0x27 */ u8 magicDef; + /* 0x28 */ u8 resist[8]; + /* 0x30 */ u8 elemResist[8]; + /* 0x38 */ u8 anim[16]; + /* 0x48 */ u8 attackID[16]; + /* 0x58 */ u8 cameraID[16]; + /* 0x68 */ u8 dropItem[4]; + /* 0x6C */ u16 dropItemCount[4]; + /* 0x74 */ u16 manipAttackID[4]; + /* 0x7C */ u16 mp; + /* 0x7E */ u16 ap; + /* 0x80 */ u16 morphItem; + /* 0x82 */ u8 backAttackMul; + /* 0x83 */ u8 unk83; + /* 0x84 */ s32 exp; + /* 0x88 */ s32 gil; + /* 0x8C */ s32 statusImmunities; + /* 0x90 */ u32 unk90[10]; +} SceneEnemy; // size:0xB8 + +// https://github.com/petfriendamy/ff7-scarlet/blob/main/src/Shared/DataParser.cs +typedef struct { + u8 accuracyRate; + u8 impactEffectID; + u8 impactAnimID; + u8 unk3; + u16 mpCost; + u16 impactSfxID; + u16 cameraSingleID; + u16 cameraMultiID; + u8 targetFlags; + u8 attackEffectID; + u8 damageCalcID; + u8 strength; + u8 conditionSubmenu; + u8 statusChange; + u8 additionalEffects; + u8 effectsModifier; + u32 statuses; + u16 elements; + u16 flags; +} AttackEntry; // size:0x1C + +typedef struct { + u8 unk0[0x200]; +} Unk800F5F44_5; // size:0x200 + +// an uncompressed chunk from SCENE.BIN +typedef struct { + /* 0x000 */ u16 enemyModelIDs[4]; + /* 0x008 */ BattleSetup setup[4]; + /* 0x058 */ CameraPlacement camera[4][4]; + /* 0x118 */ FormationEntry formation[4][6]; + /* 0x298 */ SceneEnemy enemy[3]; + /* 0x4C0 */ AttackEntry attacks[0x20]; + /* 0x840 */ u16 attackIDs[0x20]; + /* 0x880 */ char attackNames[0x20][0x20]; + /* 0xC80 */ Unk800F5F44_5 unkC80; + /* 0xE80 */ u8 script[0x1000]; +} SceneContainer; // 0x1E80 + +typedef struct { + /* 0x00 */ u16 enemyModelIDs[4]; + /* 0x08 */ BattleSetup setup; + /* 0x1C */ CameraPlacement camera[4]; + /* 0x4C */ FormationEntry formation[6]; +} Unk8016360C; // size:0xAC + +typedef struct { + /* 0x0000 */ SceneEnemy enemy[3]; + /* 0x0228 */ AttackEntry attacks[0x20]; + /* 0x05A8 */ u16 attackIDs[0x20]; + /* 0x05E8 */ char attackNames[0x20][0x20]; + /* 0x09E8 */ u8 unk9E8[0x278]; + /* 0x0C60 */ Unk800F5F44_5 _5; + /* 0x0E60 */ u8 script[0x1000]; + /* 0x1E60 */ u16 D_800F7DA4; + /* 0x1E62 */ u16 D_800F7DA6; + /* 0x1E64 */ u16 D_800F7DA8; + /* 0x1E66 */ u16 D_800F7DAA; + /* 0x1E68 */ u16 D_800F7DAC; + /* 0x1E6A */ u16 D_800F7DAE; + /* 0x1E6C */ u16 D_800F7DB0; + /* 0x1E6E */ u16 D_800F7DB2; + /* 0x1E70 */ u16 D_800F7DB4; + /* 0x1E72 */ u16 D_800F7DB6; + /* 0x1E74 */ u16 D_800F7DB8; + /* 0x1E76 */ u16 D_800F7DBA; + /* 0x1E78 */ u16 D_800F7DBC; + /* 0x1E7A */ u16 D_800F7DBE; + /* 0x1E7B */ u16 D_800F7DC0; + /* 0x1E7E */ u16 D_800F7DC2; + /* 0x1E80 */ u16 D_800F7DC4; + /* 0x1E72 */ u16 D_800F7DC6; + /* 0x1E84 */ u16 D_800F7DC8; + /* 0x1E84 */ u16 D_800F7DCA; +} Unk800F5F44; // size:0x1E88 + +#define BATTLE_SCENE 7 + +typedef struct { + MATRIX m; + SVECTOR sv1; + SVECTOR sv2; + MATRIX* pm; +} BattleModelSub; // size:0x34 + +typedef struct { + /* 0x000 */ s16 D_801518E4; + /* 0x002 */ s16 D_801518E6; + /* 0x004 */ s16 D_801518E8; + /* 0x006 */ s16 D_801518EA; + /* 0x008 */ u8 unk8[8]; + /* 0x010 */ s16 unk10; + /* 0x012 */ s16 unk12; + /* 0x014 */ u16 unk14[2]; + /* 0x018 */ s16 D_801518FC; + /* 0x01A */ s16 D_801518FE; + /* 0x01C */ s32 D_80151900; + /* 0x020 */ s16 D_80151904; + /* 0x022 */ u8 D_80151906; + /* 0x023 */ u8 D_80151907; + /* 0x024 */ u8 D_80151908; + /* 0x025 */ u8 D_80151909; + /* 0x026 */ u8 D_8015190A; + /* 0x027 */ u8 D_8015190B; + /* 0x028 */ u8 D_8015190C; + /* 0x029 */ u8 D_8015190D; + /* 0x02A */ u8 D_8015190E; + /* 0x02B */ u8 D_8015190F; + /* 0x02C */ s32 D_80151910; + /* 0x030 */ s32 D_80151914; + /* 0x034 */ s16 D_80151918; + /* 0x036 */ s16 D_8015191A; + /* 0x038 */ s16 D_8015191C; + /* 0x03A */ s8 D_8015191E; + /* 0x03B */ s8 D_8015191F; + /* 0x03C */ u8 D_80151920; + /* 0x03D */ s8 D_80151921; + /* 0x03E */ s8 D_80151922; + /* 0x03F */ s8 D_80151923; + /* 0x040 */ s32 D_80151924; + /* 0x044 */ s32 D_80151928; + /* 0x048 */ s32 D_8015192C; + /* 0x04C */ s32 D_80151930; + /* 0x050 */ s32 D_80151934; + /* 0x054 */ s32 D_80151938; + /* 0x058 */ s32 D_8015193C; + /* 0x05C */ s32 D_80151940; + /* 0x060 */ s32 D_80151944; + /* 0x064 */ s32 D_80151948; + /* 0x068 */ s32 D_8015194C; + /* 0x06C */ s32 D_80151950; + /* 0x070 */ s32 D_80151954; + /* 0x074 */ s32 D_80151958; + /* 0x078 */ u8 unk5C[0xC8]; + /* 0x140 */ MATRIX m; + /* 0x160 */ SVECTOR unk160; + /* 0x168 */ SVECTOR D_80151A4C; + /* 0x170 */ s32 D_80151A54; + /* 0x174 */ BattleModelSub D_80151A58[50]; +} BattleModel; // size:0xB9C + +typedef struct { + /* 0x0000 */ u_long* unk0[0x1C]; + /* 0x0070 */ u_long* unk70[0x1000]; + /* 0x4070 */ u_long* unk4070[2]; + /* 0x4078 */ u_long* unk4078[2]; + /* 0x4080 */ u_long* unk4080[9]; + /* 0x40A4 */ u_long* unk40A4[0x10]; + /* 0x40E4 */ u_long* unk40E4[2]; + /* 0x40EC */ u_long* unk40EC[2]; +} Unk801517C0; // size:0x40F4 + +typedef struct { + /* 0x00 */ MATRIX m; + /* 0x20 */ SVECTOR sv; + union { + /* 0x28 */ VECTOR v; + struct { + /* 0x28 */ SVECTOR sv2; + /* 0x30 */ s32 unk30; + /* 0x34 */ s8 unk34; + /* 0x35 */ s8 unk35; + /* 0x36 */ s16 unk36; + } sub; + } u; + +} Unk800BB75C; // size:0x38 + +typedef struct { + s32* unk0; + s32 unk4; + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; +} Unk801B0C98; + +typedef struct { + /* 0x00 */ SavePartyMember* partyMember; + /* 0x04 */ u16 unk4; + /* 0x06 */ u8 unk6; + /* 0x07 */ u8 unk7; + /* 0x08 */ u16 limitBar; + /* 0x0A */ u16 limitBarUI; + /* 0x0C */ u16 curMP; + /* 0x0E */ u16 curHP; + /* 0x10 */ u16 maxMP; + /* 0x12 */ u16 maxHP; + /* 0x14 */ u16 capMP; + /* 0x16 */ u16 capHP; + /* 0x18 */ u16 unk18; + /* 0x1A */ u16 unk1A; + /* 0x1C */ u16 unk1C; + /* 0x1E */ u16 unk1E; + /* 0x20 */ u16 unk20; + /* 0x22 */ u16 unk22; + /* 0x24 */ u16 unk24; + /* 0x26 */ u16 unk26; + /* 0x28 */ u16 unk28; + /* 0x2A */ u16 unk2A; + /* 0x2C */ u16 unk2C; + /* 0x2E */ u16 unk2E; + /* 0x30 */ u16 unk30; + /* 0x32 */ u16 unk32; +} Unk800F5E60; // size:0x34 + +extern u16 D_800F5BBC[10][0x22]; +extern Unk800F5E60 D_800F5E60[3]; +extern Unk800F5F44 D_800F5F44; +extern s8 D_800F6936[0x40][8]; +extern s16 D_800F83AE[10][0x34]; // overlaps with D_800F83E0, D_800F83A8 +#define D_800F83A8 (*((u8*)&D_800F83AE[0][0] - 6)) +extern s16 D_800F83CC; // overlaps with D_800F83AE, sceneID +extern Unk800F83E0 D_800F83E0[3]; +extern s8 D_800F90B4[][0x240]; +extern Unk800BB75C D_800FA63C; +extern Unk801517C0* D_801517C0; +extern short D_8015169C; +extern BattleModel D_801518E4[7]; // len might be 10, not 7 +extern short D_80162080; +extern Unk8016360C D_8016360C; +extern u16 D_8016376A; + +// battle.c +int func_800BBEAC(void (*func)(void)); + +// battle2.c +void* func_800D29D4(Unk801B0C98*, u_long**, int, void*); +void func_800D3994(s32 arg0, s32 arg1, void* arg2); +void func_800D5444(int, int, int, void (*func)(int)); +void func_800D55F4(int, int, int); +int func_800D574C(int); diff --git a/src/battle/battle1.c b/src/battle/battle1.c new file mode 100644 index 0000000..efcdc54 --- /dev/null +++ b/src/battle/battle1.c @@ -0,0 +1,1053 @@ +//! PSYQ=3.3 CC1=2.6.3 +#include "battle_private.h" +#include +#include + +static void func_800B37EC(void); +static void func_800B3D38(void); +static void func_800B3D88(void); +static void func_800B3DBC(void); +static void func_800B7FDC(void); +static void func_800B85E0(); +static void func_800BA4C8(void); +void func_800BA598(s16); +static void func_800BB030(s16); +static void func_800BB75C(Unk800BB75C* arg0, MATRIX* m, s16* arg2, s16* arg3); +static void func_800BB804(void); +static void func_800BB864(void); +static void func_800C4D10(void); +DR_MODE* func_800C4DC8(s16 x, s16 y, s16 w, s16 h, s32*); + +void func_800B30E4(void) { + s32 i; + + D_801517C0 = &D_800FAFF4; + D_801031E4 = 0; + D_800F8368 = 0; + D_80162084 = 0x200; + func_800B383C(); + func_800B430C(); + VSync(0); + SetDispMask(0); + D_800F9F34 = 0; + *(s8*)&D_800FA63C.u.sub.unk34 = 0; + D_800FA6A0 = 0; + func_800B37A0(); + func_800B3E2C(); + func_800BB684(); + func_800BC04C(func_800C4D10); + func_800B7FDC(); + func_800B7FDC(); + do { + } while (D_80095DD4); + func_800B37EC(); + SetDispMask(1); + while (1) { + switch (D_80163C7C) { + case 0: + D_801635FC = 0x3D; + func_800B38E0(); + func_800B7FDC(); + D_80163C7C = 1; + break; + case 1: + func_800B7FDC(); + if (D_800F7DF4 == (u8)D_80166F64 && D_801518DC == 0) { + func_800B3D38(); + func_800B5138(); + D_80163C7C = 6; + } + break; + case 6: + func_800B7FDC(); + func_800B3D88(); + for (i = 4; i < D_800F7E04[0] + 4; i++) { + D_801518E4[i].D_80151922 |= 4; + } + D_80163C7C = 2; + break; + case 2: + func_800B7FDC(); + if ((u8)D_80166F64 == 3 && D_801518DC == 0) { + func_800B3DBC(); + D_80163C7C = 3; + D_801518E4[0].D_80151922 |= 4; + D_801518E4[1].D_80151922 |= 4; + D_801518E4[2].D_80151922 |= 4; + } + break; + case 3: + func_800B7FDC(); + if (D_801635FC == 0) { + D_80163C7C = 4; + func_800C61C0(); + } + break; + default: + return; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B33A4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B36B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B37A0); + +static void func_800B37EC(void) { + D_80162094 = 4; + func_800D8A78(4); + func_800E15D8(); + func_800D9E0C(-1, -1, 0); + D_80095DD4 = 2; +} + +// Load stage files +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B383C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B38E0); + +static void func_800B3934(void) { + func_800B5D38(2); + func_800B5CD4(2); + D_80166F64 = 3; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3968); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3A04); + +void func_800B3AB8(void); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3AB8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3B84); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3C50); + +static void func_800B3CD0(void) { + Yamada* y; + u_long* dst; + + dst = (u_long*)0x801B0000; + func_800D2980(dst, 0, 0, 0); + y = &D_800E8068[D_800FA9C4]; + DS_read(y->loc, *&D_800E8068[D_800FA9C4].len, dst, func_800B3AB8); + func_800B7FB4(); +} + +static void func_800B3D38(void) { + func_800C5E94(); + D_800F839C = D_800EA50C; + DS_read(LBA_ENEMY6_SEFFECT, 0xA800, (u_long*)0x801B0000, func_800B3CD0); + func_800B7FB4(); +} + +static void func_800B3D88(void) { + func_800B588C(); + func_800B6B98(4, 10); + func_800B36B4(); +} + +static void func_800B3DBC(void) { + s32 i; + + func_800B4794(); + func_800B6B98(0, 3); + func_800B6B98(3, 3); + if (D_8016360C.setup.stageID == 57) { + for (i = 0; i < 10; i++) { + D_801518E4[i].D_80151909 |= 0x10; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3E2C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3FAC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3FFC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B430C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B45F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B46B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B4794); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B4E30); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5138); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B54B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B588C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5AAC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5C1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5CD4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5D38); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5E64); + +void func_800B60E0(s16); +void func_800B5FC4(s16 arg0) { func_800B60E0(arg0); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B5FE8); + +void func_800B60E0(s16); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B60E0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B64CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B677C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B6B98); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B6D6C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B7764); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B798C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B79F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B7DB4); + +static void func_800B7F6C(void) { + volatile s32 padding; + + while (D_80062D99) { + func_800B7FB4(); + } + D_80062D98 = 0; +} + +void func_800B7FB4(void) { D_801518DC = func_80034B44(); } + +static void func_800B7FDC(void) { + s32 i; + + func_800B7FB4(); + ClearOTagR((u_long*)D_801517C0->unk40A4, LEN(D_801517C0->unk40A4)); + ClearOTag((u_long*)D_801517C0->unk4070, LEN(D_801517C0->unk4070)); + ClearOTag((u_long*)D_801517C0->unk4078, LEN(D_801517C0->unk4078)); + ClearOTagR((u_long*)D_801517C0->unk70, LEN(D_801517C0->unk70)); + ClearOTagR((u_long*)D_801517C0->unk4080, LEN(D_801517C0->unk4080)); + ClearOTag((u_long*)D_801517C0->unk40E4, LEN(D_801517C0->unk40E4)); + ClearOTag((u_long*)D_801517C0->unk40EC, LEN(D_801517C0->unk40EC)); + D_80163C74 = D_800F8368 == 0 ? (DR_MODE*)0x80168000 : (DR_MODE*)0x80184000; + func_800B8360(1); + func_800C5CC0(); + func_800B8438(); + for (i = 0; i < 10; i++) { + if (D_801518E4[i].D_8015190A == 0) { + D_800F7DE4 = 0; + break; + } + if (D_80162080 == 0) { + D_800F7DE4 = 1; + } else { + D_800F7DE4 = 0; + } + } + func_800A3ED0(); + func_800B8360(2); + func_800DCFD4((u_long*)D_801517C0->unk40E4); + if (D_800F9D94 == 0) { + ResetGraph(1); + D_800F9D94 = 1; + } + if (D_8016376A & 2) { + func_800E16B8(D_801517C0->unk40E4, 0x10, 0x10, D_8009D268[0]); + } + D_800FA9B8 = VSync(1); + BATTLE_FlushImageQueue(); + func_800B7FB4(); + D_80158D08 = func_800D8A88(); + SetGeomScreen(D_80162084); + D_801516F4++; + func_800B7F6C(); + func_800B950C(); + D_801516A0 = D_800F198C; +} + +void func_800B8234(s32 arg0) { + if (arg0) { + func_800D0C80(D_801590CC); + D_801517BC = 0; + } +} + +static void func_800B8268(void) { + s32 i; + u8* var_a1; + s32 var_t1; + + i = 0; + var_t1 = 1; + var_a1 = D_80163784; + while (i < 10) { + *var_a1 = D_801636B8[i].D_801636B9; + if (!(D_80151200[i].D_8015120C & 8) && + D_801518E4[i].D_801518E6 != *var_a1 && + D_801518E4[i].D_8015190A == var_t1) { + D_801518E4[i].D_80151922 |= 1; + D_801518E4[i].D_801518E6 = *var_a1; + } + var_a1++; + i += 1; + } + D_80163787 = 0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8360); + +static void func_800B83C4() { + s32 i; + + for (i = 0; i < 3; i++) { + if (D_80151200[i].D_8015120C & 1) { + func_800BA4C8(); + func_800BA40C(); + return; + } + } + func_800BA40C(); + func_800BA4C8(); +} + +void func_800B8438(void) { + func_800B9568(); + if (D_801635FC) { + D_801635FC--; + } + switch (D_80163C7C) { + case 2: + func_800B905C(); + func_800BC440(); + func_800BA4C8(); + break; + case 0: + case 1: + case 6: + break; + case 3: + case 4: + case 5: + default: + func_800B8EE4(); + func_800B905C(); + func_800B8234(D_801517BC); + func_800BC440(); + func_800B7FB4(); + func_800B83C4(); + func_800B8B48(); + break; + } + func_800B7FB4(); + func_800B91CC(); + D_80151694 = D_80163758[1]; + func_800B85E0(); + func_800BC81C(D_800F8370, D_801518E4[D_801590CC].D_80151906); + func_800BC8B0(D_800F8370); + func_800B8268(); + SetFarColor(0, 0, 0); + func_800BC538(); + func_800BC348(); + func_800BB75C(&D_800FA63C, &D_800FA958, &D_80158D00, &D_801031E8); + func_800C627C(); +} + +static void func_800B85E0() { + s32 i; + + if (D_800F7ED4 != 100 && D_800FA6B8) { + func_800BB804(); + D_80163C7C = 5; + func_800D8B2C(); + D_800F7ED4 = 100; + D_80163798[D_801590E0].unk8 = -3; + func_800BB684(); + for (i = 0; i < 3; i++) { + D_801518E4[i].D_80151922 |= 0x20; + D_80151200[i].D_80151200 = D_801636B8[i].D_801636C0; + } + } + if (D_800F9D98 != 100 && (D_800707BE & 1)) { + D_80163C7C = 5; + func_800D8B2C(); + D_800F9D98 = 100; + D_80163798[D_801590E0].unk8 = -1; + func_800BB684(); + } + if (!D_801590D8 && D_80163B80) { + func_800BB864(); + D_801590D8 = 1; + } + if (D_800F9D9C != 100) { + i = 0; + if (D_800707BE & 8) { + for (; i < 3; i++) { + D_801518E4[i].D_80151922 |= 1; + D_801518E4[i].D_801518E6 = D_801636B8[i].D_801636B9; + D_801518E4[i].D_80151922 |= 0x20; + D_80151200[i].D_80151200 = D_801636B8[i].D_801636C0; + } + D_800F9D9C = 100; + D_80163C7C = 5; + func_800D8B2C(); + D_80163798[D_801590E0].unk8 = -1; + func_800BB684(); + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B888C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B88CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8944); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8A34); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8B48); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8E48); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8EE4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B8FCC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B905C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B91CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B950C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B9568); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BA11C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BA24C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BA2BC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BA360); + +static void func_800BA40C(void) { + s32 i; + u8 param; + + for (i = 0; i < 3; i++) { + if (!(D_801518E4[i].D_80151909 & 2)) { + param = i; + func_800C1908(param); + func_800BA598(i); + if (D_801518E4[i].D_8015190B & 0x80) { + func_800BB2A8(param); + func_800BB030(i); + } + } + } +} + +static void func_800BA4C8(void) { + s32 i; + + for (i = 4; i < D_800F7E04[0] + 4; i++) { + if (!(D_801518E4[i].D_80151909 & 0x80)) { + continue; + } + if (D_801518E4[i].D_80151909 & 2) { + continue; + } + func_800C1908(i); + func_800BA598(i); + if (D_801518E4[i].D_8015190B & 0x80) { + func_800BB030(i); + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BA598); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BACEC); + +static void func_800BAF34(BattleModelSub* modelSub) { + s32 flag; + + *(MATRIX**)0x1F800020 = modelSub->pm; + *(MATRIX*)0x1F800024 = **(MATRIX**)0x1F800020; + MulMatrix2((MATRIX*)0x1F800024, &modelSub->m); + SetRotMatrix((MATRIX*)0x1F800024); + SetTransMatrix((MATRIX*)0x1F800024); + RotTrans(&modelSub->sv2, (VECTOR*)modelSub->m.t, &flag); + SetRotMatrix(&modelSub->m); + SetTransMatrix(&modelSub->m); +} + +static void func_800BAFF8(MATRIX* m, VECTOR* v) { + ScaleMatrix(m, v); + SetRotMatrix(m); + SetTransMatrix(m); +} + +static void func_800BB030(s16 arg0) { + s32 i; + Unk801B0C98* unk; + + unk = (Unk801B0C98*)0x1F800020; + SetFarColor(D_801518E4[arg0].D_8015190C, D_801518E4[arg0].D_8015190D, + D_801518E4[arg0].D_8015190E); + SetRotMatrix(&D_801518E4[arg0].m); + SetTransMatrix(&D_801518E4[arg0].m); + for (i = 0; i < D_800FA6D8[arg0].unk3C; i++) { + RotMatrixYXZ( + &D_800FA6D8[arg0].unk8[i].sv1, &D_800FA6D8[arg0].unk8[i].m); + } + + for (i = 0; i < D_800FA6D8[arg0].unk3C; i++) { + func_800BAF34(&D_800FA6D8[arg0].unk8[i]); + if (!D_800FA6D8[arg0].unk4[i]) + continue; + unk->unk0 = D_800FA6D8[arg0].unk4[i]; + unk->unk4 = D_800FA6D8[arg0].unk3E[i] | 0x180; + unk->unk8 = 0; + unk->unkA = D_801518E4[arg0].unk14[0]; + unk->unkC = 0x20; + unk->unkE = D_801518E4[arg0].unk14[1]; + if (D_801518E4[arg0].D_80151909 & 4) { + continue; + } + D_80163C74 = func_800D29D4(unk, D_801517C0->unk70, 12, D_80163C74); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB2A8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB430); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB4F8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB538); + +void func_800BB67C(s32 arg0, Unk800BB67C* arg1) { arg1->unk30 = arg0; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB684); + +static void func_800BB75C(Unk800BB75C* arg0, MATRIX* m, s16* arg2, s16* arg3) { + int flag; + + func_800D85B0(m, arg2, arg3, &D_800E7D10); + RotMatrixYXZ(&arg0->sv, &arg0->m); + TransMatrix(&arg0->m, &arg0->u.v); + MulMatrix2(m, &arg0->m); + SetRotMatrix(m); + SetTransMatrix(m); + RotTrans(&arg0->u.sub.sv2, (VECTOR*)&arg0->m.t, &flag); + func_800BAFF8(&arg0->m, &D_800E7D20); +} + +static void func_800BB89C(void); +static void func_800BB804(void) { + if (!(D_8016376A & 0x20)) { + func_80033E34( + LBA_ENEMY6_FAN2, 0x1000, (u_long*)0x801D0000, func_800BB89C); + func_800B7FB4(); + return; + } + D_80163B80 = 0; + D_800FA6B8 = 0; +} + +static void func_800BB864(void) { + func_80033E34(LBA_ENEMY6_OVER2, 0x800, (u_long*)0x801D0000, func_800BB89C); + func_800B7FB4(); +} + +static void func_800BB89C(void) { + D_80163B80 = 0; + D_800FA6B8 = 0; + D_8009A000[0] = !(!(D_8016376A & 0x10) && !D_80083338) ? 0x10 : 0x14; + D_8009A004[0] = 0x801D0000; + func_8002DA7C(); +} + +void func_800BB90C(void) { + D_8009A000[0] = 0xA0; + D_8009A004[0] = 0x7F; + func_8002DA7C(); +} + +static void func_800BB944(void) { + func_800BB90C(); + D_8009A000[0] = 0xF1; + func_8002DA7C(); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB978); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB9B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB9FC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBA40); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBA84); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBB20); + +static void func_800BBDF8(void) { + if (D_800F8368 == 0) { + D_800F4AF4 = D_80163C74; + if ((u32)D_80163C74 > (u32)0x80184000) { + PadStop(); + ResetGraph(1); + StopCallback(); + SystemError('b', 0); + } + } else { + D_800F4AF8 = D_80163C74; + if ((u32)D_80163C74 > (u32)0x801A0000) { + PadStop(); + ResetGraph(1); + StopCallback(); + SystemError('b', 1); + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBEAC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBF7C); + +s32 func_800BC04C(void (*cb)(void)); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC04C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC11C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC1E0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC2F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC348); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC440); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC538); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC630); + +void func_800BCA58(s32); +void func_800C1104(); +static void func_800BC72C(void) { + func_800C1104(); + func_800BCA58(3); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC754); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC81C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BC8B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BCA58); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BCB1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BE49C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BE69C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BE86C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BEA38); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BFA98); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BFB10); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BFB88); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BFDA0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BFF88); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0088); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C018C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0254); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0314); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C03B8); + +s32 func_800C03FC(s32 arg0, s32 arg1) { return arg0 < 0 ? -arg1 : arg1; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0410); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0480); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0630); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0900); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0970); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0B20); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0DD8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C1104); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C1304); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C1394); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C14C0); + +static s32 func_800C169C(u8 arg0) { + D_801518E4[arg0].D_80151909 |= 8; + if (D_80151200[arg0].D_80151200 & 0x2000) { + return 10; + } + if (D_80151200[arg0].D_80151200 & 0x4000) { + return 5; + } + if (D_80151200[arg0].D_80151200 & 0x0008) { + return 1; + } + if (D_80151200[arg0].D_80151200 & 0x800000) { + return 3; + } + if (D_80151200[arg0].D_80151200 & 0x01000000) { + return 6; + } + if (D_80151200[arg0].D_80151200 & 0x04000000) { + return 8; + } + if (D_80151200[arg0].D_80151200 & 0x8000) { + return 9; + } + if (D_80151200[arg0].D_80151200 & 0x400000) { + return 7; + } + D_801518E4[arg0].D_80151909 &= ~8; + return 0; +} + +static void func_800C17A0(s32 arg0, s32 arg1) { + switch (D_800EA19C[arg1][0]) { + case 0: + D_801518E4[arg0].unk14[0] = 0; + break; + case 1: + D_801518E4[arg0].unk14[0] = 0x800; + break; + case 2: + D_801518E4[arg0].unk14[0] = 0xC00; + break; + } + D_801518E4[arg0].D_8015190C = D_800EA19C[arg1][1]; + D_801518E4[arg0].D_8015190D = D_800EA19C[arg1][2]; + D_801518E4[arg0].D_8015190E = D_800EA19C[arg1][3]; + D_801518E4[arg0].D_80151908 = 0; +} + +static void func_800C5468(u8 arg0); +void func_800C5170(u8); + +static void func_800C1908(u8 arg0) { + s32 temp_a1; + s16 var_a0; + u8 temp_s0; + + temp_s0 = arg0; + if (D_801518E4[temp_s0].D_80151922 & 0x20) { + if (temp_s0 < 4) { + D_800F9F28[temp_s0] = D_801636B8[temp_s0].D_801636C0; + } + func_800C5170(temp_s0); + func_800C5468(temp_s0); + func_800C17A0(temp_s0, func_800C169C(temp_s0)); + D_801518E4[temp_s0].D_80151922 &= 0xDF; + } + temp_a1 = arg0; + if (D_80151200[temp_a1].D_80151235 == 0) { + if (D_80151200[temp_a1].D_80151200 & 0x4000) { + D_80151200[temp_a1].D_80151233 = 3; + return; + } + D_80151200[temp_a1].D_80151233 = 0; + if (D_80151200[temp_a1].D_80151200 & 0x100) { + D_80151200[temp_a1].D_80151233 = 1; + } + if (D_80151200[temp_a1].D_80151200 & 0x200) { + D_80151200[temp_a1].D_80151233 = 2; + } + if (D_80151200[temp_a1].D_80151200 & 0x400) { + D_80151200[temp_a1].D_80151233 = 3; + } + if (D_80151200[temp_a1].D_80151200 & 0x02000000) { + D_80151200[temp_a1].D_80151233 = 3; + } + if (D_80151200[temp_a1].D_80151200 & 0x40) { + if (D_801518E4[temp_a1].D_801518E6 == D_80163784[temp_a1]) { + D_801518E4[temp_a1].unk160.vy += 0x100; + } + } + var_a0 = arg0; + if (D_80151200[var_a0].D_80151200 & 0x400000 && + D_801518E4[var_a0].D_801518E6 == D_80163784[var_a0]) { + if (D_801518E4[var_a0].D_801518FC == 0) { + D_801518E4[var_a0].unk160.vy = 0x800; + } else { + D_801518E4[var_a0].unk160.vy = 0; + } + } + var_a0 = arg0; + if (D_801518E4[var_a0].D_80151909 & 8) { + if (D_801518E4[var_a0].D_80151908 < 0x10) { + D_801518E4[var_a0].unk14[0] += 0x80; + } else { + D_801518E4[var_a0].unk14[0] -= 0x80; + } + D_801518E4[arg0].D_80151908--; + D_801518E4[arg0].D_80151908 &= 0x1F; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C1D8C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2000); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C20E8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2150); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C223C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2704); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2864); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2928); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2C1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2F20); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C2FD4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3068); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C328C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C33F0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3578); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C36B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3950); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3AA0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3CA8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3DE4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C3F44); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C40F4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C428C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C44B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C45EC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C4814); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C494C); + +static void func_800C4B60(s16 arg0) { + if (D_801621F0[arg0].D_801621F4 == 0) { + D_801621F0[arg0].D_801621F0 = -1; + return; + } + D_80163C74 = func_800C4DC8(0, D_801621F0[arg0].unkA, 320, 47, &D_800EA25C); + D_80163C74 = + func_800C4DC8(0, D_801621F0[arg0].unkA + 47, 320, 32, &D_800EA258); + D_80163C74 = func_800C4DC8(0, D_801621F0[arg0].unk8, 320, 32, &D_800EA260); + D_80163C74 = + func_800C4DC8(0, D_801621F0[arg0].unk8 + 32, 320, 47, &D_800EA25C); + D_801621F0[arg0].unk8 += 4; + D_801621F0[arg0].unkA -= 4; + D_801621F0[arg0].D_801621F4--; +} + +static void func_800C4D10(void) { + int arg0; + + arg0 = D_801590D4; + switch (D_801621F0[arg0].D_801621F2) { + case 0: + D_801621F0[arg0].D_801621F4 = 21; + D_801621F0[arg0].unk8 = 87; + D_801621F0[arg0].unkA = 8; + D_801621F0[arg0].D_801621F2++; + case 1: + func_800C4B60(arg0); + break; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C4DC8); + +static u_long* func_800C5040(u8 r, u8 g, u8 b, s32 tpage, u_long* ot); + +u_long* func_800C4FC8(u8 r, u8 g, u8 b) { + return func_800C5040(r, g, b, 1, (u_long*)&D_801517C0->unk4080[1]); +} + +u_long* func_800C5004(u8 r, u8 g, u8 b) { + return func_800C5040(r, g, b, 2, (u_long*)&D_801517C0->unk40EC); +} + +static u_long* func_800C5040(u8 r, u8 g, u8 b, s32 tpage, u_long* ot) { + DR_MODE* drMode; + POLY_F4* poly; + + drMode = D_80163C74; + SetDrawMode(drMode, 1, 0, (tpage & 3) << 5, NULL); + poly = (POLY_F4*)(drMode + 24); + SetPolyF4(poly); + SetSemiTrans(poly, 1); + poly->r0 = r; + poly->g0 = g; + poly->b0 = b; + poly->x0 = 0; + poly->y0 = 8; + poly->x1 = 320; + poly->y1 = 8; + poly->x2 = 0; + poly->y2 = 166; + poly->x3 = 320; + poly->y3 = 166; + addPrim(ot, poly); + addPrim(ot, drMode); + return (u_long*)(poly + 1); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5170); + +static void func_800C55B8(void); +static void func_800C5468(u8 arg0) { + s32 var_v0_2; + s32 var_v0; + u16 temp_a1; + + var_v0 = arg0; + if (D_80151200[var_v0].D_80151200 & 0x1000) { + temp_a1 = D_80151200[var_v0].D_8015120C; + if (!(temp_a1 & 0x80)) { + D_80151200[var_v0].D_8015120C |= 0x80; + var_v0_2 = func_800BC04C(func_800C55B8); + D_801621F0[var_v0_2].D_801621F6 = arg0; + D_801621F0[var_v0_2].D_801621F4 = 0x10; + D_801621F0[var_v0_2].D_801621F2 = -0x80; + } + } else { + temp_a1 = D_80151200[var_v0].D_8015120C; + if (temp_a1 & 0x80) { + D_80151200[var_v0].D_8015120C = temp_a1 & (~0x80); + var_v0_2 = func_800BC04C(func_800C55B8); + var_v0_2 = var_v0_2; + D_801621F0[var_v0_2].D_801621F6 = arg0; + D_801621F0[var_v0_2].D_801621F4 = 0x10; + D_801621F0[var_v0_2].D_801621F2 = 0x80; + } + } +} + +static void func_800C55B8(void) { + if (D_801621F0[D_801590D4].D_801621F4 == 0) { + D_801621F0[D_801590D4].D_801621F0 = -1; + return; + } + D_801518E4[D_801621F0[D_801590D4].D_801621F6].D_801518EA += + D_801621F0[D_801590D4].D_801621F2; + D_801621F0[D_801590D4].D_801621F4--; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5694); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C57B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5864); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C59B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5ADC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5BEC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5C18); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5CC0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5E94); + +s32 func_800C60F4(void) { return Savemap.battle_msg_speed / 4 + 4; } + +static void func_800C610C(void) { + while (D_801518DC) { + func_800B7FB4(); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C614C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C61C0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C627C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C62F4); + +void func_800C679C(void); + +void func_800C64AC(void) { func_800BBEAC(func_800C679C); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C64D4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C6628); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C679C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C6CB8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C70AC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C7220); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C7340); + +static void func_800C74A4(void) { + if (!(D_801518E4[3].D_80151909 & 2)) { + func_800C7C4C(3, D_800F57D0->unk8, D_800F57D0 + 1, D_800F57D0); + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C74E4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C76C8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C7924); diff --git a/src/battle/battle2.c b/src/battle/battle2.c new file mode 100644 index 0000000..3576e70 --- /dev/null +++ b/src/battle/battle2.c @@ -0,0 +1,1233 @@ +//! PSYQ=3.3 CC1=2.6.3 +#include "battle_private.h" + +static void func_800D67BC(s32 arg0); +static void func_800D67E8(s32 arg0); +void func_800D6814(s32 arg0); + +extern Yamada D_800EEBB8[]; // MAGIC/*.BIN overlay +extern s16 D_800EF5B0[]; +extern s16 D_800EF63C[]; +extern s16 D_800EF6A8[]; +extern s16 D_800EF6D8[]; +extern s16 D_800EF6FC[]; +extern s16 D_800EF838[]; +extern s16 D_800EF8D8[]; + +s32 func_800BBF7C(void (*f)(void)); +s32 func_800BC04C(void (*f)()); +void func_800C2928(); +void func_800C328C(); +void func_800C3578(); +void func_800C3950(); +void func_800C3CA8(); +void func_800C40F4(); +void func_800C44B4(); +void func_800C4814(); +void func_800CFB14(); +void func_800D1530(); +s32 func_800D376C(BattleModelSub* arg0, s32 arg1, s16 nItems, u8* arg3); +void func_800D3AF0(); +static void func_800D4D4C(s32 arg0, s32 arg1); + +// MAGIC/ entrypoints +void func_801B037C(s16, u8); +void func_801B0000(s16, u8); +void func_801B0000_2(s16, u8); +void func_801B000C(s16, u8); +void func_801B0040(s16, u8); +void func_801B0054(s16, u8); +void func_801B0084(s16, u8); + +static s32 func_800C7B60(s16 arg0, s16 nItems, u8* arg2) { + BattleModelSub* var_a0; + s32 var_a1; + s32 temp_s0; + s32 temp_v0; + + var_a0 = D_801518E4[arg0].D_80151A58; + var_a1 = D_801518E4[arg0].D_80151958; + D_801518E4[arg0].D_80151958 = func_800D376C(var_a0, var_a1, nItems, arg2); + return D_801518E4[arg0].D_80151958 == 0; +} + +static void func_800C7BE8(s16 arg0, s16 arg1, u8* arg2) { + D_800FA6D8[arg0].unk0 = + func_800D376C(D_800FA6D8[arg0].unk8, D_800FA6D8[arg0].unk0, arg1, arg2); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800C7C4C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800CD400); + +s16 func_800CD558(s16 arg0, u8* arg1) { + u32 val; + val = arg1[D_801518E4[arg0].D_80151920++]; + return (arg1[D_801518E4[arg0].D_80151920++] << 8) + val; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800CD5E4); + +static void func_800CD798(u8 arg0) { + D_801518E4[arg0].D_80151A4C.vx = D_80163C80[arg0].vx; + D_801518E4[arg0].D_80151A4C.vy = D_80163C80[arg0].vy; + D_801518E4[arg0].D_80151A4C.vz = D_80163C80[arg0].vz; +} + +static void func_800CD82C(void) { + D_801590DC = 1; + D_801621F0[D_801590D4].D_801621F0 = -1; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800CD860); + +static void func_800CDD44(s16 arg0) { + D_801518E4[arg0].D_8015191F = 1; + D_801518E4[arg0].D_80151920 = 0; + D_801518E4[arg0].D_80151921 = 0; +} + +void func_800CDDA4(void) { + if (D_80166F68) { + D_800F9DA4 = D_800F9DA4 | 1; + } else { + D_800F9DA4 = D_800F9DA4 & ~1; + } +} + +static void func_800CDDE8(void) { + func_800BBA84(D_801621F0[D_801590D4].D_801621F4, D_801590CC, 0); + func_800D7178(D_801590CC, D_801621F0[D_801590D4].D_801621F2); + D_801621F0[D_801590D4].D_801621F0 = -1; +} + +static void func_800CDE78(void) { + if (D_801516FC[D_801590CC][0] < + D_801516FC[D_801621F0[D_801590D4].unk8][0]) { + D_801621F0[D_801590D4].unk14 |= 0x100; + } + func_800D4D4C(D_801621F0[D_801590D4].unk8, D_801621F0[D_801590D4].unk14); + D_801621F0[D_801590D4].D_801621F0 = -1; +} + +void func_800CDF6C(s32 arg0, s16 arg1) { + func_800BBA84(0x14, arg1, 0); + func_800D58D0(arg0, 1, 1); + func_800D4D4C(D_800FA6D4, 0x2C); +} + +static void func_800CDFC4(void) { + if (!D_801621F0[D_801590D4].D_801621F4) { + D_80163C74 = (DR_MODE*)func_800C4FC8(0xFA, 0xFA, 0xFA); + D_801621F0[D_801590D4].D_801621F0 = -1; + return; + } + D_801621F0[D_801590D4].D_801621F4--; +} + +static void func_800CE058(s16 arg0) { + Unk80151200* dst = &D_80151200[arg0]; + dst->D_8015123C = 0x1000; + dst->D_8015123A = 0x1000; + D_80151200[arg0].D_80151238 = 0x1000; + D_80151200[arg0].D_8015120C |= 0x20; +} + +static void func_800CE0C8(s16 arg0, u8 arg1, u8 arg2) { + s32 ret; + + func_800CE058(arg0); + switch (arg1) { + case 0: + ret = func_800BBEAC(func_800C3578); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + case 8: + ret = func_800BBEAC(func_800C4814); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + case 1: + case 10: + ret = func_800BBF7C(func_800C3950); + D_801620AC[ret].D_801621B2 = arg2; + D_801620AC[ret].D_801621B4 = arg0; + D_801620AC[ret].D_801621B6 = 0xF8; + return; + case 2: + ret = func_800BBEAC(func_800C3CA8); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + case 3: + ret = func_800BBEAC(func_800C328C); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + case 17: + case 18: + ret = func_800BBEAC(func_800C40F4); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + case 7: + ret = func_800BBEAC(func_800C44B4); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg2; + break; + } +} + +static void func_800CE21C(s16 arg0, u8 arg1) { + s32 ret; + + func_800CE058(arg0); + switch (D_801636B8[arg0].D_801636BC) { + case 0: + ret = func_800BBEAC(func_800C3578); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + case 8: + ret = func_800BBEAC(func_800C4814); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + case 1: + case 10: + ret = func_800BBF7C(func_800C3950); + D_801620AC[ret].D_801621B2 = arg1; + D_801620AC[ret].D_801621B4 = arg0; + D_801620AC[ret].D_801621B6 = 0xF8; + break; + case 2: + ret = func_800BBEAC(func_800C3CA8); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + case 3: + ret = func_800BBEAC(func_800C328C); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + case 17: + case 18: + ret = func_800BBEAC(func_800C40F4); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + case 7: + ret = func_800BBEAC(func_800C44B4); + D_80162978[ret].D_80162980 = arg0; + D_80162978[ret].D_8016297E = arg1; + break; + } +} + +static void func_800CE384(void) { + u8* ptr; + u8 do_work; + u32 param; + u32 param_hi; + + if (D_80151200[D_801621F0[D_801590D4].D_801621F6].D_80151234 != + D_801621F0[D_801590D4].D_801621F2) { + D_801621F0[D_801590D4].D_801621F0 = -1; + return; + } + if (D_801621F0[D_801590D4].D_801621F4) { + D_801621F0[D_801590D4].D_801621F4--; + return; + } + do_work = 1; + while (do_work) { + ptr = D_801621F0[D_801590D4].unk10.ptr; + switch (ptr[D_801621F0[D_801590D4].unk18++]) { + case 0xFD: + param = ptr[D_801621F0[D_801590D4].unk18++]; + param_hi = ptr[D_801621F0[D_801590D4].unk18++]; + param_hi <<= 8; + param |= param_hi; + D_801621F0[D_801590D4].D_801621F4 = + ptr[D_801621F0[D_801590D4].unk18++]; + D_80151200[D_801621F0[D_801590D4].D_801621F6].D_8015122E = param; + do_work = 0; + break; + case 0xFE: + D_801621F0[D_801590D4].unk18 = 0; + break; + case 0xFF: + D_801621F0[D_801590D4].D_801621F0 = -1; + do_work = 0; + break; + default: + do_work = 0; + break; + } + } +} + +static void func_800CE638(void) { + switch (D_801621F0[D_801590D4].D_801621F2) { + case 0: + D_801621F0[D_801590D4].D_801621F4 = 3; + D_801621F0[D_801590D4].D_801621F2++; + case 1: + if (D_801621F0[D_801590D4].D_801621F4 == 0) { + D_801621F0[D_801590D4].D_801621F0 = -1; + func_800A3534( + D_801621F0[D_801590D4].unkA, D_801621F0[D_801590D4].unk8); + } + D_801621F0[D_801590D4].D_801621F4--; + break; + } +} + +static void func_800CE75C(void) { + if ((D_800FA69C >> D_80162978[D_8015169C].D_80162980) & 1) { + func_800D67E8(D_80162978[D_8015169C].D_80162980); + } else if ((D_80163608 >> D_80162978[D_8015169C].D_80162980) & 1) { + func_800D67BC(D_80162978[D_8015169C].D_80162980); + } +} + +static void func_800CE7E0(void) { + s32 dst; + + if (!D_80162978[D_8015169C].D_8016297C) { + if (D_80162978[D_8015169C].D_8016297E != -1) { + func_800CE75C(); + dst = func_800BC04C(func_800C2928); + D_801621F0[dst].unk14 = D_80162978[D_8015169C].unkA; + D_801621F0[dst].unkE = D_80162978[D_8015169C].D_80162982; + D_801621F0[dst].unk10.ptr = + (u8*)(u32)D_80162978[D_8015169C].D_80162980; + dst = func_800BC04C(func_800CE638); + D_801621F0[dst].unkA = D_80162978[D_8015169C].unk15; + D_801621F0[dst].unk8 = D_80162978[D_8015169C].D_8016297E; + } + D_80162978[D_8015169C].D_80162978 = -1; + return; + } else { + D_80162978[D_8015169C].D_8016297C--; + } +} + +void func_800CEB48(void); +void func_800CE970(void) { + s32 dst; + + if (!D_80162978[D_8015169C].D_8016297C) { + if (D_80162978[D_8015169C].unkA & 2) { + D_80163C74 = (DR_MODE*)func_800C4FC8(0xFA, 0xFA, 0xFA); + } + if (D_80162978[D_8015169C].D_8016297E != -1 && + D_80162978[D_8015169C].unk14 != 1) { + func_800CE75C(); + dst = func_800BC04C(func_800C2928); + D_801621F0[dst].unk14 = D_80162978[D_8015169C].unkA; + D_801621F0[dst].unkE = D_80162978[D_8015169C].D_80162982; + D_801621F0[dst].unk10.ptr = + (u8*)(u32)D_80162978[D_8015169C].D_80162980; + dst = func_800BC04C(func_800CE638); + D_801621F0[dst].unkA = D_80162978[D_8015169C].unk15; + D_801621F0[dst].unk8 = D_80162978[D_8015169C].D_8016297E; + } + func_800CEB48(); + return; + } else { + D_80162978[D_8015169C].D_8016297C--; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800CEB48); + +static void func_800CF2F0(void) { + s16 index; + + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + index = D_801620AC[D_801590D0].D_801621B4; + D_801518E4[index].D_80151A4C.vy += D_801620AC[D_801590D0].D_801621B6; + *(s32*)0x1F80000C = index; + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].D_801621B0 - 1; +} + +static void func_800CF3CC(void) { + s16 index; + + index = D_801620AC[D_801590D0].D_801621B4; + *(s32*)0x1F80000C = index; + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + D_801518E4[index].unk160.vy += D_801620AC[D_801590D0].unkA; + D_801620AC[D_801590D0].D_801621B0--; +} + +static void func_800CF4A8(void) { + s16 index; + + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + index = D_801620AC[D_801590D0].D_801621B4; + D_801518E4[index].D_80151A4C.vx += D_801620AC[D_801590D0].D_801621B6; + D_801518E4[index].D_80151A4C.vz += D_801620AC[D_801590D0].unk8; + *(s32*)0x1F80000C = index; + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].D_801621B0 - 1; +} + +void func_800CF5BC(void) { +#define MUL(a, b) (((a) * (b)) >> 12) +#define IDX1 *(s32*)0x1F80000C +#define IDX2 *(s32*)0x1F800008 + IDX1 = D_801620AC[D_801590D0].D_801621B4; + IDX2 = D_801620AC[D_801590D0].D_801621B6; + if (D_801620AC[D_801590D0].D_801621AE == 0) { + D_801620AC[D_801590D0].D_801621AE = 1; + if (IDX1 >= 4) { + if (D_801031F0 == 0) { + D_801620AC[D_801590D0].D_801621B2 = + (MUL(D_801518E4[IDX2].D_80151A4C.vy, + D_801518E4[IDX2].D_801518EA) - + MUL(D_801518E4[IDX1].D_80151A4C.vy, + D_801518E4[IDX1].D_801518EA)) / + D_801620AC[D_801590D0].D_801621B0; + } else { + D_801620AC[D_801590D0].D_801621B2 = 0; + } + } else { + D_801620AC[D_801590D0].D_801621B2 = 0; + } + } + if (!D_801620AC[D_801590D0].unk14) { + D_80166F58 = 0; + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + D_801518E4[IDX1].D_80151A4C.vx += D_801620AC[D_801590D0].unk8; + D_801518E4[IDX1].D_80151A4C.vz += D_801620AC[D_801590D0].unkA; + D_801518E4[IDX1].D_80151A4C.vy += D_801620AC[D_801590D0].D_801621B2; + D_801620AC[D_801590D0].D_801621B0--; + return; + } + D_801620AC[D_801590D0].unk14--; +#undef IDX2 +#undef IDX1 +#undef MUL +} + +void func_800CF8C0(s16 arg0, s16 arg1, u8 arg2) { + u8 dst; + + dst = func_800BBF7C(func_800CFB14); + D_801620AC[dst].D_801621B4 = arg0; + D_801620AC[dst].D_801621B0 = arg1; + D_801620AC[dst].D_801621B6 = D_800F99E8; + D_801620AC[dst].unk14 = arg2; + if (D_800F99E8 == arg0) { + D_801620AC[dst].unk8 = 0; + D_801620AC[dst].unkA = 0; + D_801620AC[dst].D_801621B2 = 0; + return; + } + D_801620AC[dst].unk8 = + (D_80163C80[arg0].vx - D_801518E4[arg0].D_80151A4C.vx) / arg1; + D_801620AC[dst].unkA = + (D_80163C80[arg0].vz - D_801518E4[arg0].D_80151A4C.vz) / arg1; + D_801620AC[dst].D_801621B2 = + (D_80163C80[arg0].vy - D_801518E4[arg0].D_80151A4C.vy) / arg1; +} + +void func_800CFB14(void) { + s16 dst; + + dst = D_801620AC[D_801590D0].D_801621B4; + *(s32*)0x1F80000C = dst; + *(s32*)0x1F800008 = D_801620AC[D_801590D0].D_801621B6; + if (D_801620AC[D_801590D0].unk14 == 0) { + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + D_801518E4[dst].D_80151A4C.vx += D_801620AC[D_801590D0].unk8; + D_801518E4[dst].D_80151A4C.vz += D_801620AC[D_801590D0].unkA; + D_801518E4[dst].D_80151A4C.vy += D_801620AC[D_801590D0].D_801621B2; + D_801620AC[D_801590D0].D_801621B0--; + return; + } + D_801620AC[D_801590D0].unk14--; +} + +void func_800CFCB0(void) { + s32 temp_a3; + s16 temp_a2; + s32 temp_a1; + + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + temp_a2 = D_801620AC[D_801590D0].D_801621B4; + temp_a3 = D_801620AC[D_801590D0].D_801621B6; + temp_a1 = D_801620AC[D_801590D0].unkC; + *((s32*)0x1F80000C) = temp_a2; + *((s32*)0x1F800008) = temp_a3; + *((s32*)0x1F800010) = temp_a1; + D_801518E4[temp_a2].D_80151A4C.vx += D_801620AC[D_801590D0].unk8; + D_801518E4[temp_a2].D_80151A4C.vz += D_801620AC[D_801590D0].unkA; + D_801518E4[temp_a2].D_80151A4C.vy += + D_800EEB28[temp_a1][D_801620AC[D_801590D0].unk14++]; + D_801620AC[D_801590D0].D_801621B0--; +} + +void func_800CFE60(void) { +#define MUL(a, b) (((a) * (b)) >> 12) +#define IDX1 *(s32*)0x1F80000C +#define IDX2 *(s32*)0x1F800008 + IDX1 = D_801620AC[D_801590D0].D_801621B4; + IDX2 = D_801620AC[D_801590D0].D_801621B6; + switch (D_801620AC[D_801590D0].D_801621AE) { + case 0: + D_801620AC[D_801590D0].D_801621AE = 1; + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].unk15; + break; + case 1: + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AE = 2; + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].unk16; + D_801620AC[D_801590D0].D_801621B2 = + MUL(D_801518E4[IDX1].D_80151A4C.vy - + D_801620AC[D_801590D0].unkC, + D_801518E4[IDX2].D_801518EA) / + D_801620AC[D_801590D0].unk16; + return; + } + D_801518E4[IDX1].D_80151A4C.vy += D_801620AC[D_801590D0].unk10; + D_801620AC[D_801590D0].D_801621B0--; + break; + case 2: + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + D_801518E4[IDX1].D_80151A4C.vx += D_801620AC[D_801590D0].unk8; + D_801518E4[IDX1].D_80151A4C.vz += D_801620AC[D_801590D0].unkA; + D_801518E4[IDX1].D_80151A4C.vy -= D_801620AC[D_801590D0].D_801621B2; + D_801620AC[D_801590D0].D_801621B0--; + break; + } +#undef IDX2 +#undef IDX1 +#undef MUL +} + +void func_800D01C0(void) { +#define MUL(a, b) (((a) * (b)) >> 12) +#define IDX1 *(s32*)0x1F80000C +#define IDX2 *(s32*)0x1F800008 + IDX2 = D_801620AC[D_801590D0].D_801621B6; + IDX1 = D_801620AC[D_801590D0].D_801621B4; + switch (D_801620AC[D_801590D0].D_801621AE) { + case 0: + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].unk16; + D_801620AC[D_801590D0].D_801621B2 = + (D_801620AC[D_801590D0].unk10 - D_801518E4[IDX1].D_80151A4C.vy) / + D_801620AC[D_801590D0].unk16; + D_801620AC[D_801590D0].D_801621AE = 1; + break; + case 1: + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621B0 = D_801620AC[D_801590D0].unk15; + D_801620AC[D_801590D0].D_801621B2 = + MUL(D_801620AC[D_801590D0].unk10 - D_801620AC[D_801590D0].unkC, + D_801518E4[D_801620AC[D_801590D0].D_801621B6].D_801518EA) / + D_801620AC[D_801590D0].unk15; + D_801620AC[D_801590D0].D_801621AE = 2; + return; + } + D_801518E4[IDX1].D_80151A4C.vx += D_801620AC[D_801590D0].unk8; + D_801518E4[IDX1].D_80151A4C.vz += D_801620AC[D_801590D0].unkA; + D_801518E4[IDX1].D_80151A4C.vy += D_801620AC[D_801590D0].D_801621B2; + D_801620AC[D_801590D0].D_801621B0--; + break; + case 2: + if (D_801620AC[D_801590D0].D_801621B0 == 0) { + D_801620AC[D_801590D0].D_801621AC = -1; + return; + } + D_801518E4[IDX1].D_80151A4C.vy -= D_801620AC[D_801590D0].D_801621B2; + D_801620AC[D_801590D0].D_801621B0--; + break; + } +#undef IDX2 +#undef IDX1 +#undef MUL +} + +void func_800D0578(void) { + if (D_801621F0[D_801590D4].D_801621F4 == 0) { + func_800D4D4C( + D_801621F0[D_801590D4].unk8, D_801621F0[D_801590D4].D_801621F6); + D_801621F0[D_801590D4].D_801621F0 = -1; + return; + } + D_801621F0[D_801590D4].D_801621F4--; +} + +void func_800D061C(void) { + if (D_801621F0[D_801590D4].D_801621F4 == 0) { + func_800BBA84(D_801621F0[D_801590D4].D_801621F6, D_801590CC, 0); + D_801621F0[D_801590D4].D_801621F0 = -1; + return; + } + D_801621F0[D_801590D4].D_801621F4--; +} + +void func_800D06B8(void) { + if (D_801621F0[D_801590D4].D_801621F4 == 0) { + if (D_801518DC == 0) { + func_800D0C80(D_801621F0[D_801590D4].D_801621F6); + D_801621F0[D_801590D4].D_801621F0 = -1; + } + } else { + D_801621F0[D_801590D4].D_801621F4--; + } +} + +void func_800D0760(void) { + if (D_80162978[D_8015169C].D_8016297E == 0) { + if (D_80162978[D_8015169C].D_8016297C == 0) { + D_80162978[D_8015169C].D_80162978 = -1; + return; + } + func_800DCF60(D_801518E4[D_801590CC].D_80151907, + D_80151200[D_801590CC].D_8015123E); + D_80162978[D_8015169C].D_8016297C--; + return; + } + D_80162978[D_8015169C].D_8016297E--; +} + +void func_800D088C(s32 loc, s32 len) { + func_80033E34(loc, len, (u_long*)0x801B0000, NULL); + func_800B7FB4(); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D08B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D0958); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D09D0); + +void func_800D0A44(void) {} + +static void func_800D0AD4(void); +void func_800D0A4C(void) { + s32 ret; + s32 i; + + for (i = 0; i < 3; i++) { + D_801518E4[i].D_80151909 |= 1; + } + func_801B0040(D_80151774, D_801590CC); + ret = func_800BC04C(func_800D0AD4); + *(s32*)0x1F800000 = ret; + D_801621F0[ret].D_801621F4 = 2; +} + +static void func_800D0AD4(void) { + if (!D_801621F0[D_801590D4].D_801621F4) { + D_801621F0[D_801590D4].D_801621F0 = -1; + func_800BB978(); + return; + } + D_801621F0[D_801590D4].D_801621F4--; +} + +void func_800D0B4C(u8 arg0) { + D_800F8CF0 = 0; + func_800D1530(); + switch (D_801518E4[arg0].D_80151907) { + case 4: + D_800EF9D8[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + break; + case 7: + func_801B037C(D_80151774, D_801590CC); + break; + case 8: + D_800EFFE0[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + break; + } +} + +void func_800D0C80(u8 arg0) { + D_800F8CF0 = 0; + func_800D1530(); + switch (D_801518E4[arg0].D_80151907) { + case 2: + if (D_801031F0 == 0) { + if (D_801518E4[arg0].D_80151906 == 25) { + D_801518E4[0].D_8015190A = 1; + D_801518E4[1].D_8015190A = 1; + D_801518E4[2].D_8015190A = 1; + } + D_800EFAF0[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + return; + } + switch (D_801518E4[arg0].D_80151906) { + case 41: + func_801B0000(D_80151774, D_801590CC); + break; + case 44: + func_801B0000_2(D_80151774, D_801590CC); + break; + case 35: + func_801B000C(D_80151774, D_801590CC); + break; + case 32: + func_801B0054(D_80151774, D_801590CC); + break; + case 29: + func_801B0084(D_80151774, D_801590CC); + break; + default: + D_800EFAF0[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + break; + } + break; + case 13: + D_800EFBC8[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + break; + case 20: + if (D_801518E4[arg0].D_80151906 == 2) { + if (D_801590CC == D_800FA9E8) { + D_80163A98 = 0; + } else { + D_80163A98 = 1; + } + } + *(s32*)0x1F800000 = + D_800EFEA0[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + switch (D_801518E4[arg0].D_80151906) { + case 0x2D: + case 0x2E: + case 0x2F: + case 0x30: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4F: + *(s32*)0x1F800000 = 0; + break; + } + func_800D08B8(arg0, *(s32*)0x1F800000); + break; + case 32: + D_800EFC28[D_801518E4[arg0].D_80151906](D_80151774, D_801590CC); + break; + case 3: + func_800C64AC(); + break; + } +} + +void func_800D1110(u8 arg0) { + s32 lba; + s32 var_a1; + s32 id; + + switch (D_801518E4[arg0].D_80151907) { + case 2: + if (D_801031F0 == 0) { + id = D_800EF63C[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + } else { + switch (D_801518E4[arg0].D_80151906) { + case 29: + func_800D088C(D_800EEBB8[77].loc, D_800EEBB8[77].len); + break; + case 41: + func_800D088C(D_800EEBB8[32].loc, D_800EEBB8[32].len); + break; + case 44: + func_800D088C(D_800EEBB8[26].loc, D_800EEBB8[26].len); + break; + case 32: + func_800D088C(D_800EEBB8[255].loc, D_800EEBB8[255].len); + break; + case 35: + func_800D088C(D_800EEBB8[6].loc, D_800EEBB8[6].len); + break; + default: + id = D_800EF63C[D_801518E4[arg0].D_80151906]; + lba = D_800EEBB8[id].loc; + var_a1 = D_800EEBB8[id].len; + func_800D088C(lba, var_a1); + break; + } + } + break; + case 7: + func_800D088C(D_800EEBB8[221].loc, D_800EEBB8[221].len); + break; + case 8: + id = D_800EF8D8[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + case 13: + id = D_800EF6A8[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + case 20: + id = D_800EF838[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + case 4: + id = D_800EF5B0[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + case 32: + id = D_800EF6FC[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + case 3: + id = D_800EF6D8[D_801518E4[arg0].D_80151906]; + func_800D088C(D_800EEBB8[id].loc, D_800EEBB8[id].len); + break; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D1530); + +void BATTLE_EnqueueLoadImage(RECT* rect, u_long* ptr) { + D_800F01DC->method = QUEUE_LOAD_IMAGE; + D_800F01DC->rect = rect; + D_800F01DC->ptr = ptr; + D_800F01DC++; +} + +void BATTLE_EnqueueStoreImage(RECT* rect, u_long* ptr) { + D_800F01DC->method = QUEUE_STORE_IMAGE; + D_800F01DC->rect = rect; + D_800F01DC->ptr = ptr; + D_800F01DC++; +} + +void BATTLE_EnqueueMoveImage(RECT* rect, s32 x, s32 y) { + D_800F01DC->method = QUEUE_MOVE_IMAGE; + D_800F01DC->rect = rect; + D_800F01DC->x = x; + D_800F01DC->y = y; + D_800F01DC++; +} + +void BATTLE_EnqueueClearImage(RECT* rect) { + D_800F01DC->method = QUEUE_CLEAR_IMAGE; + D_800F01DC->rect = rect; + D_800F01DC++; +} + +void BATTLE_FlushImageQueue(void) { + Unk800F01DC* item; + + for (item = D_800F4BAC; item < D_800F01DC; item++) { + switch (item->method) { + case QUEUE_LOAD_IMAGE: + LoadImage(item->rect, item->ptr); + break; + case QUEUE_STORE_IMAGE: + StoreImage(item->rect, item->ptr); + break; + case QUEUE_MOVE_IMAGE: + MoveImage(item->rect, item->x, item->y); + break; + case QUEUE_CLEAR_IMAGE: + ClearImage(item->rect, 0, 0, 0); + break; + } + } + D_800F01DC = D_800F4BAC; +} + +void BATTLE_ResetImageQueue(void) { D_800F01DC = D_800F4BAC; } + +void func_800D2710(u_long* addr, s16 x, s16 y) { + TIM_IMAGE tim; + + OpenTIM(addr); + ReadTIM(&tim); + if (tim.crect && tim.caddr) { + D_800F4B2C[D_800F01E0] = *tim.crect; + D_800F4B2C[D_800F01E0].x += x & ~15; + D_800F4B2C[D_800F01E0].y = + y + D_800F4B2C[D_800F01E0].y; // requires GCC 2.6.3 + BATTLE_EnqueueLoadImage(&D_800F4B2C[D_800F01E0], tim.caddr); + D_800F01E0 = (D_800F01E0 + 1) & 7; + } +} + +void func_800D2828(u_long* addr, s32 xy) { + TIM_IMAGE tim; + s32 temp_a1; + s32 temp_a3; + s32 temp_a2; + + OpenTIM(addr); + ReadTIM(&tim); + if (tim.prect && tim.paddr) { + D_800F4B6C[D_800F01E4] = *tim.prect; + temp_a1 = (tim.prect->y & 0x300) >> 4 | (tim.prect->x & 0x3FF) >> 6; + temp_a2 = temp_a1 + xy; + temp_a3 = (temp_a1 & 0x0F) * 0x40; + D_800F4B6C[D_800F01E4].x = + ((temp_a2 & 0x0F) * 0x40 + (D_800F4B6C[D_800F01E4].x - temp_a3)) & + 0x3FF; + temp_a3 = (temp_a1 & 0x30) * 0x10; + D_800F4B6C[D_800F01E4].y = + ((temp_a2 & 0x30) * 0x10 + (D_800F4B6C[D_800F01E4].y - temp_a3)) & + 0x1FF; + BATTLE_EnqueueLoadImage(&D_800F4B6C[D_800F01E4], tim.paddr); + D_800F01E4 = (D_800F01E4 + 1) & 7; + } +} + +void func_800D2980(u_long* addr, s16 imgXY, s16 clutX, s16 clutY) { + func_800D2710(addr, clutX, clutY); + func_800D2828(addr, imgXY); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D29D4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D32B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3354); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3418); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3474); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D34C8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3520); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3548); + +s32 func_800D35D8(u8* arg0, s32* arg1, s32 arg2) { + s32 bits; + s32 i; + + bits = 0; + for (i = 0; i < arg2; i++) { + bits <<= 1; + if ((arg0[*arg1 / 8] >> (7 - (*arg1 & 7))) & 1) { + bits++; + } + *arg1 = *arg1 + 1; + } + bits <<= 32 - arg2; + bits >>= 32 - arg2; + return bits; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3658); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D376C); + +void func_800D3994(s32 arg0, s32 arg1, void* arg2); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3994); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3A6C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3AF0); + +const s32 D_800A0D98[] = {0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00001000, 0x00000000, 0x00000000, 0x00000000}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3BF0); + +void func_800D3D88(void) { + Unk801621F0* temp_s0_2; + Unk801621F0* temp_s1; + s32 temp_s0; + u16 temp_s2; + + temp_s1 = &D_801621F0[D_801590D4]; + temp_s0 = temp_s1->D_801621F0; + temp_s2 = ((u8*)&D_801518E4[temp_s0].D_8015191A)[temp_s1->D_801621F2 & 1]; + temp_s0++; // !FAKE + temp_s0--; // !FAKE + if (temp_s2 != 0xFF) { + temp_s0_2 = &D_801621F0[func_800BC04C(func_800D3BF0)]; + func_800D3994(temp_s0, temp_s2, &temp_s0_2->D_801621F4); + temp_s0_2->D_801621F6 = 0; + temp_s0_2->unkE = temp_s1->unkE; + temp_s0_2->unk10.unk.unk0 = temp_s1->unk10.unk.unk0; + } + temp_s1->D_801621F2++; + if (temp_s1->D_801621F2 == 4) { + temp_s1->D_801621F0 = -1; + } +} + +void func_800D3E8C(s32 arg0) { + Unk801621F0* temp_v0; + + temp_v0 = &D_801621F0[func_800BC04C(func_800D3D88)]; + temp_v0->D_801621F0 = arg0; + temp_v0->unkE = *(s16*)& temp_v0->unk10 = D_801518E4[arg0].D_801518EA; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D3F0C); + +void func_800D3F8C(void) { + Unk801621F0* temp_s0; + Unk801621F0* temp_s1; + + temp_s1 = &D_801621F0[D_801590D4]; + if (D_80062D98 == 0) { + temp_s1->unkC--; + if (temp_s1->unkC == -1) { + temp_s0 = &D_801621F0[func_800BC04C(func_800D3AF0)]; + RotMatrixYXZ(&D_801518E4[temp_s1->unk10.unk.unk2].unk160, + (MATRIX*)0x1F800008); + ApplyMatrixSV((MATRIX*)0x1F800008, (SVECTOR*)&temp_s1->D_801621F4, + (SVECTOR*)0x1F800000); + temp_s0->D_801621F4 = + D_801518E4[temp_s1->unk10.unk.unk2].D_80151A4C.vx + + ((SVECTOR*)0x1F800000)->vx; + temp_s0->D_801621F6 = + D_801518E4[temp_s1->unk10.unk.unk2].D_80151A4C.vy + + ((SVECTOR*)0x1F800000)->vy; + temp_s0->unk8 = D_801518E4[temp_s1->unk10.unk.unk2].D_80151A4C.vz + + ((SVECTOR*)0x1F800000)->vz; + temp_s0->unkE = temp_s1->unkE; + temp_s0->unk10.unk.unk0 = temp_s1->unk10.unk.unk0; + temp_s1->D_801621F0 = -1; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D415C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D41FC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4284); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4368); + +static void func_800D4484(u_long* ot, u16 tpage) { + DR_MODE* dr_mode; + + dr_mode = D_80163C74; + SetDrawMode(dr_mode, 0, 1, tpage, NULL); + AddPrim(ot, (void*)dr_mode); + D_80163C74 = dr_mode + 1; +} + +const s32 D_800A0DB8[] = {0x00000000, 0xFFFFF000, 0x00000000, 0x00000000}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D44E8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D461C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4710); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D491C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4A64); + +static void func_800D4D6C(s32 arg0, s32 arg1, s32 arg2); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4C08); + +void func_800D4CBC(s32, s32, s32); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4CBC); + +static void func_800D4D4C(s32 arg0, s32 arg1) { + func_800D4CBC(arg0, arg1, 0x1000); +} + +static void func_800D4D6C(s32 arg0, s32 arg1, s32 arg2) { + func_800D4C08(arg0, arg1, 0x1000, arg2); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4D90); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4FA8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D4FF0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D508C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5138); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D51D4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5230); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D52A0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5350); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5444); + +s32 func_800D54BC(s32 arg0) { + s32 count; + s32 i; + + count = 0; + for (i = 0; i < 10; i++) { + if ((arg0 >> i) & 1) { + count++; + } + } + return count; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D54EC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D55A4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D55F4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D56A8); + +s32 func_800D574C(s32 arg0) { + s32 sp10; + + func_800D54EC(arg0, &sp10); + return func_800D56A8(&sp10); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5774); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D57C0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D58D0); + +void func_800D5938(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5938); + +static void func_800D5A68(s16 arg0, s16 arg1) { + Unk80162978* temp_v0; + + temp_v0 = &D_80162978[func_800BBEAC(func_800D5938)]; + temp_v0->D_80162978 = 0; + temp_v0->D_8016297E = arg1; + temp_v0->D_8016297C = arg0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5AC0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5B6C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5D28); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D61AC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6260); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6394); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D650C); + +extern u8 D_800F10EC[]; +extern u8 D_800F11E8[]; +extern u8 D_800F1304[]; +u8* const D_800A0DC8[] = {D_800F10EC, D_800F11E8, D_800F1304}; +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6734); + +void func_800D6734(s32, s32); +extern s32 D_800F14D4; + +static void func_800D67BC(s32 arg0) { + D_800F14D4 = 0x88; + func_800D6734(arg0, 0); +} + +static void func_800D67E8(s32 arg0) { + D_800F14D4 = 0xA8; + func_800D6734(arg0, 1); +} + +void func_800D6814(s32 arg0) { + D_800F14D4 = 0x88; + func_800D6734(arg0, 2); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6840); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6998); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6ACC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6C20); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6D8C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6F78); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D70C0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7178); + +void func_800D72B4(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D72B4); + +static void func_800D7340(void) { func_800BBEAC(func_800D72B4); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7368); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D751C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D76B8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7724); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7888); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7A88); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7B1C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7BA4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7C2C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7D3C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D8304); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D83A4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D8468); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D84F8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D85B0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D87EC); diff --git a/src/battle/battle3.c b/src/battle/battle3.c new file mode 100644 index 0000000..05ea587 --- /dev/null +++ b/src/battle/battle3.c @@ -0,0 +1,620 @@ +//! PSYQ=3.3 CC1=2.7.2 +#include "battle_private.h" + +static void func_800E5358(void); +static void func_800E4B88(void); +static s32 func_800E4BCC(void); + +void func_800D8A04(void) {} + +s32 func_800D8A0C(s32 arg0) { return arg0 < 0 ? -arg0 : arg0; } + +void func_800D8A24(void) {} + +void func_800D8A2C(void) { D_800F199C = 0; } + +static void func_800D8A3C(s32 arg0) { D_800F9780[D_800F199C++] = arg0; } + +void func_800D8A70(void) {} + +void func_800D8A78(s8 arg0) { D_800F19A4 = arg0; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D8A88); + +static void func_800D8AF0(u16 arg0) { + D_8009A000[0] = arg0; + D_8009A004[0] = arg0; + D_8009A008[0] = arg0; + func_8002DA7C(arg0); +} + +void func_800D8B2C(void) { + if (D_80062D99) { + func_800D8AF0(0x98); + } + D_80062D99 = 0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D8B60); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D8D78); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D91DC); + +void func_800D93DC(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D93E4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D9BF4); + +u8 func_800D9DEC(s16 arg0) { return D_800F514C[arg0]; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D9E0C); + +static void func_800D9F5C(s16 arg0) { D_800F514C[arg0] = 3; } + +static void func_800D9F80(void) { + D_800F311C = 0; + D_800FAFEC = -0x100; + D_800FAFF0 = -0x100; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800D9FA4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DA380); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DB818); + +const s32 D_800A0E48[] = {0, 0, 0}; +void func_800DBC18(s32, s16); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DBC18); + +static void func_800DBEA4(s32 arg0, s16 arg1) { func_800DBC18(arg0, arg1); } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DBEC8); + +static void func_800DBF54(void) { func_800269C0(D_80077F64); } + +static void func_800DBF7C(void) { D_800F3122 = 0; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DBF8C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DC0CC); + +void func_800DCF58(void) {} + +void func_800DCF60(s16 arg0, s16 arg1) { + D_800F3138 = 1; + D_800F313C = arg0; + D_800F3140 = arg1; +} + +void func_800DCF94(s16 arg0) { + if (arg0 == -1) { + D_800F1E4F = 0; + return; + } + D_800F1E4F = 1; + D_800F1E50 = arg0; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DCFD4); + +static void func_800E6848(void); +static void func_800DD690(s32 arg0, s16 arg1) { + s32 setupType; + s32 temp_v1; + + func_80026A00(); + switch (arg1) { + case 0: + func_800E2098(); + break; + case 1: + func_800E2C6C(&D_800F90B4[D_800F38A0]); + break; + case 5: + func_800E3088(); + break; + case 6: + func_800E3B64(); + break; + case 4: + func_800E3FB4(); + break; + case 7: + func_800E3E10(); + break; + case 2: + setupType = SETUP_SIDE_ATTACK_3; + temp_v1 = D_8016360C.setup.type; + if (temp_v1 < NUM_SETUP) { + setupType = -(temp_v1 <= SETUP_BACK_ATTACK) & 7; + } + func_80026F44(8, 7, func_80015248(5, 0x12, 8), setupType); + break; + case 3: + func_80026F44(9, 7, func_80015248(5, 0x13, 8), 7); + break; + case 24: + func_800E33A0(); + break; + case 20: + func_800E4180(); + break; + case 21: + func_800E4394(); + break; + case 19: + func_800E4A64(); + break; + case 26: + func_800E4C08(); + break; + case 27: + func_800E5530(); + break; + case 28: + func_800E5978(); + break; + case 9: + func_800E6848(); + break; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DD85C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DDAD8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DDC34); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DDCE8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DDE90); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DDFEC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DE2B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DE3CC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DE46C); + +void func_800DE5D8(void) {} + +void func_800DE5E0(void) {} + +void func_800DE5E8(void) {} + +void func_800DE5F0(void) {} + +void func_800DE5F8(void) {} + +void func_800DE600(void) {} + +void func_800DE608(void) {} + +void func_800DE610(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DE618); + +void func_800DE910(void) {} + +void func_800DE918(void) { + D_80151840 = D_8009D260; + if (D_8009D260 > 600000) { + D_80151840 = 600000; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DE94C); + +void func_800DEB10(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DEB18); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DEC10); + +void func_800DF244(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF24C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF2CC); + +void func_800DF528(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF530); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF5C8); + +void func_800DF7BC(void) {} + +void func_800DF7C4(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF7CC); + +void func_800DF8F0(void) {} + +void func_800DF8F8(void) {} + +void func_800DF900(void) { + u16* tapped; + + if (D_800F3896 == 3 && D_800F99E4 == 0) { + tapped = &D_80062D7E; + if (*tapped & 0x20) { + func_800BB9B8(1); + D_800F99E4 = 1; + D_800F3896 = -1; + func_800A4350(D_800F38A0, D_800F389C, D_800F389E, D_801516F8); + func_800D9F5C(3); + func_800D9F5C(1); + } else if (D_80062D7E & 0x8040) { + func_800BB9B8(4); + D_800F99E4 = 1; + D_800F3896 = 1; + func_800D9F5C(3); + } + } +} + +void func_800DF9F0(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DF9F8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DFA94); + +void func_800DFC38(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DFC40); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DFE34); + +void func_800DFFDC(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DFFE4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E010C); + +void func_800E026C(void) {} + +void func_800E53C8(); +void func_800E0274(void) { func_800E53C8(); } + +void func_800E0294(void) { + u8* temp_s0; + + temp_s0 = &D_8009D84C[D_800F38A1].unAC[0]; + if (D_800F3896 == 0x1B && D_800F99E4 == 0) { + if (D_80062D7E & 0x20) { + if (func_800E54EC() == 2) { + D_800F99E4 = 1; + func_800BB9B8(1); + D_800F38A2 = temp_s0[3]; + D_800F389E = temp_s0[0]; + D_800FAFD4 = 0; + func_800E6B94(); + func_800DDFEC(); + func_800E5814(); + func_800D9F5C(0x1B); + func_800D9F5C(1); + } + } else if ((D_80062D7E & 0x40) && (func_800E54EC() == 0)) { + func_800BB9B8(4); + D_800F99E4 = 1; + D_800F3896 = 1; + func_800D9F5C(0x1B); + } + } +} + +void func_800E03C8(void) {} + +void func_800E03D0(void) { func_800E4B88(); } + +void func_800E03F0(void) { + u8* temp_s0; + + temp_s0 = &D_8009D8F8[D_800F38A1 * 0x440]; + if ((D_800F3896 == 0x1A) && (D_800F99E4 == 0)) { + if (D_80062D7E & 0x20) { + D_800F99E4 = 1; + if (func_800E4BCC() == 2) { + func_800BB9B8(1); + D_800F38A2 = temp_s0[3]; + D_800F389E = temp_s0[0]; + D_800FAFD4 = 0; + func_800E6B94(); + func_800DDFEC(); + func_800E5358(); + func_800D9F5C(0x1A); + func_800D9F5C(1); + } + } else if ((D_80062D7E & 0x40) && (func_800E4BCC() == 0)) { + func_800BB9B8(4); + D_800F99E4 = 1; + D_800F3896 = 1; + func_800D9F5C(0x1A); + } + } +} + +void func_800E0528(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E0530); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E05E4); + +void func_800E078C(void) {} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E0794); + +void func_800E084C(void) { + if (D_800F3896 == 9) { + func_800264A8(&D_800F9144); + if (D_80062D7C & 0x20) { + if (D_800F914E == 0) { + func_800A4844(1); + } else { + func_800A4844(0); + } + func_800D9F5C(9); + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E08C4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E0BE0); + +static void func_800E0DF4(void) { + s16 i; + + for (i = 0; i < 0x20; i++) { + D_800F514C[i] = 0; + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E0E34); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E15D8); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E16B8); + +static void func_800E1938(s16 arg0, s16 arg1, s32 arg2) { + s32 temp_a2; + u32 var_a3; + s32 x; + s32 y; + + if (arg2 < 0x80) { + var_a3 = 0; + } else if (arg2 < 0x100) { + temp_a2 = arg2 - 0x80; + if (temp_a2 < 0x10) { + var_a3 = 1; + } else if (temp_a2 < 0x20) { + var_a3 = 3; + } else if (temp_a2 < 0x30) { + var_a3 = 2; + } else if (temp_a2 < 0x3E) { + var_a3 = 5; + } else if (temp_a2 < 0x49) { + var_a3 = 4; + } else if (temp_a2 < 0x57) { + var_a3 = 9; + } else if (temp_a2 < 0x65) { + var_a3 = 6; + } else if (temp_a2 < 0x72) { + var_a3 = 7; + } else { + var_a3 = 8; + } + } else if (arg2 < 0x120) { + var_a3 = 10; + } else { + var_a3 = 11; + } + x = ((var_a3 & 1) << 4) | 0x60; + y = ((var_a3 >> 1) << 4) + 0x70; + func_80028CA0(arg0, arg1, x, y, 0x10, 0x10, 1, 0); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E1A2C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E1AC0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E1C40); + +void func_800E2054(s32 arg0, s32 arg1) { + func_80027354(0xB0, arg0, &D_800F3184[arg1 * 10], 3); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E2098); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E2C6C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E3088); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E33A0); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E368C); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E3B64); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E3E10); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E3FB4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E4180); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E4394); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E4A64); + +static void func_800E4B88(void) { + s32 i; + + for (i = 0; i < 3; i++) { + D_800F33A0[i] = 0; + } + + D_800F5760 = 10; + D_800F33AA = 0; + D_800F5764 = 2; +} + +static s32 func_800E4BCC(void) { + if (D_800F33A0[0] == 0) { + return 0; + } + if (D_800F33AA == 3) { + return 2; + } + return 1; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E4C08); + +static void func_800E5358(void) { + s32 i; + s32 index; + + for (i = 0; i < 3; i++) { + index = (1 - ((D_800F338C[i] >> (D_800F5764 + 1)) & 0xF)) & 0xF; + D_80163774[i] = D_800F332C[i][index]; + } +} + +void func_800E53C8(); +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E53C8); + +s32 func_800E54EC(void) { + if (D_800F33A0[0] == 0) { + return 0; + } + if (D_800F33AA == D_800F5774) { + return 2; + } + return 1; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5530); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5814); + +void func_800E58B0(void) { + D_800F3468 = 0; + D_800F5760 = 10; +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E58CC); + +static u8 func_800E593C(void) { return D_800F381C[D_80163604]; } + +s32 func_800E5960(s32 arg0) { return arg0 < 0 ? -arg0 : arg0; } + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5978); + +// BUG: ret is not initialized +static s32 func_800E5F30() { + s32 i; + s32 ret; + + for (i = 0; i < 3; i++) { + if (D_8009CBDC[i] != 0xFF) { + ret = D_8009CBDC[i]; + } + } + return ret; +} + +// BUG: ret is not initialized +static s32 func_800E5F70(void) { + s32 i; + s32 ret; + + for (i = 0; i < 3; i++) { + if (D_8009CBDC[i] != 0xFF) { + ret = i; + } + } + + return ret; +} + +#ifndef NON_MATCHING +// might require a file split to match due to mis-aligned rodata +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5FB4); +#else +s32 func_800E5FB4(u32 arg0, s32 arg1) { + s32 ret; + + ret = 0; + switch (arg0) { + case 0: + if (arg1 == 4) { + ret = 1; + } + break; + case 1: + if (arg1 == 10) { + ret = 1; + } + break; + case 2: + if (arg1 == 5) { + ret = 1; + } + break; + case 3: + if (arg1 == 9) { + ret = 1; + } + break; + case 4: + if (arg1 == 8) { + ret = 1; + } + break; + case 5: + ret = 1; + break; + } + return ret; +} +#endif + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E6018); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E60F8); + +s32 func_800E6820(void) { return func_80026B70(D_800F384A); } + +static void func_800E6848(void) { + func_80026F44(0x10, 8, &D_800F3828[0], 7); + func_80026F44(0x2C, 0x1C, &D_800F3828[0x22], 7); + func_80026F44(func_800E6820() + 0x4C, 0x1C, &D_800F3828[0x44], 7); +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E68B4); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E6904); + +// BUG function can return undefined value +static s32 func_800E6B40(void) { + s32 i; + + for (i = 0; i < 3; i++) { + if ((1 << D_800F38A7) & D_801516F8 & D_8016376E[i]) { + return i; + } + } +} + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E6B94); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E6DCC); + +INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E7170); diff --git a/src/battle/battle_private.h b/src/battle/battle_private.h new file mode 100644 index 0000000..79f4429 --- /dev/null +++ b/src/battle/battle_private.h @@ -0,0 +1,387 @@ +// should be imported only by the BATTLE overlay, not BATINI or similar +#include "battle.h" + +enum QueueMethod { + QUEUE_LOAD_IMAGE, + QUEUE_STORE_IMAGE, + QUEUE_MOVE_IMAGE, + QUEUE_CLEAR_IMAGE, +}; + +typedef struct { + u8 unk[0x30]; + s32 unk30; +} Unk800BB67C; + +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + s32 unk8; + s16 unkC; + u8 unkE; + u8 unkF; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s8 unk28; + s8 unk29; + s16 unk2A; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s32 unk3C; + s32 unk40; +} Unk800AF470; // 0x44 + +typedef struct { + s8 unk0; + s8 unk1; + s8 unk2; + s8 unk3; + s8 unk4; + s8 unk5; + s16 unk6; + s16 unk8; + s16 unkA; +} Unk800A2F4C; // size: 0x12 + +typedef struct { + s16 D_801621AC; + s16 D_801621AE; + s16 D_801621B0; + s16 D_801621B2; + s16 D_801621B4; + s16 D_801621B6; + s16 unk8; + s16 unkA; + s32 unkC; + s32 unk10; + u8 unk14; + u8 unk15; + u8 unk16; + u8 unk17; + s16 unk18; + s16 unk1A; +} Unk801620AC; // size:0x20 + +typedef struct { + /* 0x00 */ s16 D_80162978; + /* 0x02 */ s16 D_8016297A; + /* 0x04 */ s16 D_8016297C; + /* 0x06 */ s16 D_8016297E; + /* 0x08 */ s16 D_80162980; + /* 0x0A */ s16 D_80162982; + /* 0x0C */ s16 unk8; + /* 0x0E */ s16 unkA; + /* 0x10 */ s16 unkC; + /* 0x12 */ s16 unkE; + /* 0x14 */ s16 unk10; + /* 0x16 */ s16 unk12; + /* 0x18 */ u8 unk14; + /* 0x19 */ u8 unk15; + /* 0x1A */ s16 unk16; + /* 0x1C */ s16 unk18; + /* 0x1E */ s16 unk1A; +} Unk80162978; // size:0x20 + +typedef struct { + u16 unk0; + s16 unk2; +} Unk80162200; +typedef union { + u8* ptr; + Unk80162200 unk; +} Union80162200; + +typedef struct { + s16 D_801621F0; + s16 D_801621F2; + s16 D_801621F4; + s16 D_801621F6; // player idx? 0, 1 or 2. See func_800D0C80 + s16 unk8; + s16 unkA; + s16 unkC; + s16 unkE; + Union80162200 unk10; + s32 unk14; + u8 unk18; + s8 unk19; + s16 unk1A; + s16 unk1C; + s16 unk1E; +} Unk801621F0; // size:0x20 + +typedef struct { + /* 0x00 */ s8 D_801636B8; + /* 0x01 */ u8 D_801636B9; + /* 0x02 */ s8 D_801636BA; + /* 0x03 */ s8 D_801636BB; + /* 0x04 */ u8 D_801636BC; + /* 0x05 */ s8 D_801636BD; + /* 0x06 */ s16 D_801636BE; + /* 0x08 */ s32 D_801636C0; + /* 0x0C */ s32 D_801636C4; +} Unk801636B8; // size:0x10 + +typedef struct { + s32 method; // enum QueueMethod + RECT* rect; + u_long* ptr; + s32 x; + s32 y; +} Unk800F01DC; // size:0x14 + +typedef struct { + /* 0x00 */ s32 unk0; // frame counter? + /* 0x04 */ s32* unk4[1]; + /* 0x08 */ BattleModelSub unk8[1]; + /* 0x3C */ s16 unk3C; + /* 0x3E */ u8 unk3E[1]; + /* 0x3F */ u8 unk3F; +} Unk800FA6D8; + +typedef struct { + short vx, vy, vz; +} ShortVectorXYZ; + +typedef struct { + /* 0x00 */ s32 D_80151200; + /* 0x04 */ s32 D_80151204; + /* 0x08 */ s32 D_80151208; + /* 0x0C */ s16 D_8015120C; + /* 0x0E */ s16 D_8015120E; + /* 0x10 */ s32 D_80151210; + /* 0x14 */ s32 D_80151214; + /* 0x18 */ s32 D_80151218; + /* 0x1C */ s32 D_8015121C; + /* 0x20 */ s32 D_80151220; + /* 0x24 */ s32 D_80151224; + /* 0x28 */ s32 D_80151228; + /* 0x2C */ s16 D_8015122C; + /* 0x2E */ s16 D_8015122E; + /* 0x30 */ u16 D_80151230; + /* 0x32 */ u8 D_80151232; + /* 0x33 */ u8 D_80151233; + /* 0x34 */ u8 D_80151234; + /* 0x35 */ u8 D_80151235; + /* 0x36 */ s16 D_80151236; + /* 0x38 */ s16 D_80151238; + /* 0x3A */ s16 D_8015123A; + /* 0x3C */ s16 D_8015123C; + /* 0x3E */ s16 D_8015123E; + /* 0x40 */ s32 D_80151240; + /* 0x44 */ s32 D_80151244; + /* 0x48 */ s32 D_80151248; + /* 0x4C */ s32 D_8015124C; + /* 0x50 */ s32 D_80151250; + /* 0x54 */ s32 D_80151254; + /* 0x58 */ s32 D_80151258; + /* 0x5C */ s32 D_8015125C; + /* 0x60 */ s32 D_80151260; + /* 0x64 */ s32 D_80151264; + /* 0x68 */ s32 D_80151268; + /* 0x6C */ s32 D_8015126C; + /* 0x70 */ s32 D_80151270; +} Unk80151200; // size:0x74 + +typedef struct { + s32 unk0; + s32 unk4; + s32 unk8; +} Unk800F57D0; + +typedef struct { + /* 0x00 */ s32 D_800F83E4; + /* 0x04 */ u8 unk4[0x64]; +} Unk800F83E4; // size:0x68 + +extern s32 D_800E7A38; +extern u8 D_800E7A48[0x10]; +extern s8 D_800E7A58[]; +extern u8 D_800E7BA4[3]; +extern VECTOR D_800E7D10; +extern VECTOR D_800E7D20; +extern Yamada D_800E8068[]; +extern u8 D_800EA19C[][4]; +extern s32 D_800EA258; +extern s32 D_800EA25C; +extern s32 D_800EA260; +extern s32 D_800EA50C[]; +extern short D_800EEB28[9][8]; +extern void (*D_800EF9D8[])(s16, u8); +extern void (*D_800EFFE0[])(s16, u8); +extern void (*D_800EFAF0[])(s16, u8); +extern void (*D_800EFBC8[])(s16, u8); +extern void (*D_800EFC28[])(s16, u8); +extern s32 (*D_800EFEA0[])(s16, u8); +extern Unk800F01DC* D_800F01DC; +extern s32 D_800F01E0; +extern s32 D_800F01E4; +extern u16 D_800F198C; +extern s32 D_800F199C; +extern u8 D_800F19A4; +extern s8 D_800F1E4F; +extern s16 D_800F1E50; +extern s32 D_800F311C; +extern s16 D_800F3122; // part of a struct? +extern s32 D_800F3138; +extern s32 D_800F313C; +extern s32 D_800F3140; +extern u8 D_800F3184[]; +extern u8 D_800F332C[3][0x10]; +extern s16 D_800F338C[]; +extern u8 D_800F33A0[3]; +extern u8 D_800F33AA; +extern s8 D_800F3468; +extern u8 D_800F381C[]; +extern u8 D_800F3828[]; +extern unsigned char D_800F384A[]; +extern u8 D_800F38A0; +extern u8 D_800F38A1; +extern s16 D_800F38A2; +extern u8 D_800F7E04[]; // part of a struct +extern u8 D_800F7ED4; +extern u8 D_800F38A7; +extern u8 D_800F389C; +extern s16 D_800F389E; +extern s16 D_800F3896; +extern s32 D_800F3944; +extern s32 D_800F3948; +extern s32 D_800F3950; +extern s32 D_800F3954; +extern s32 D_800F39E0; +extern s32 D_800F39E4; +extern s32 D_800F39EC; +extern u8 D_800F39F0[][6]; +extern s8 D_800F3A80[]; +extern u16 D_800F4280[]; +extern DR_MODE* D_800F4AF4; +extern DR_MODE* D_800F4AF8; +extern RECT D_800F4B2C[]; +extern RECT D_800F4B6C[]; +extern Unk800F01DC D_800F4BAC[]; +extern u8 D_800F514C[]; +extern s8 D_800F5760; +extern u8 D_800F5764; +extern u8 D_800F5774; +extern Unk800F57D0* D_800F57D0; +extern Unk800AF470 D_800F5BB8[]; +extern s8 D_800F7DE4; +extern u8 D_800F7DF4; +extern s32 D_800F8368; +extern s16 D_800F8370; +extern s32* D_800F839C; // CD offset? +extern u8 D_800F83A6; +extern u16 D_800F83C6; // part of struct? +extern u16 D_800F83D0; +extern Unk800F83E4 D_800F83E4[]; +extern s32 D_800F8408; +extern s8 D_800F8CF0; +extern s32 D_800F9144; +extern s8 D_800F914E; +extern s32 D_800F9F28[]; // size is either 4 or 5 +extern s8 D_800F9F34; +extern u8 D_800F99E8; +extern s32 D_800F99E4; +extern u8 D_800F9D94; +extern u8 D_800F9D98; +extern u8 D_800F9D9C; +extern u16 D_800F9DA4; +extern Unk800BB75C D_800FA63C; +extern s16 D_800FA69C; +extern s8 D_800FA6A0; +extern u16 D_800FA6B8; +extern u8 D_800FA6D4; +extern Unk800FA6D8 D_800FA6D8[]; +extern MATRIX D_800FA958; +extern s32 D_800FA9B8; +extern s16 D_800FA9C4; +extern s8 D_800FA9E8; +extern u8 D_800FAFDC; +extern s16 D_800FAFD4; +extern s32 D_800FAFEC; +extern s32 D_800FAFF0; +extern Unk801517C0 D_800FAFF4; +extern s32 D_801031E4; +extern s16 D_801031E8; +extern u8 D_801031F0; +extern Unk80151200 D_80151200[3]; +extern u16 D_80151694; +extern s16 D_8015169C; +extern u16 D_801516A0; +extern u8 D_801516F4; +extern u16 D_801516F8; +extern s16 D_801516FC[][4]; // most likely a struct +extern s16 D_80151774; +extern u8 D_801517BC; +extern s16 D_80158D00; +extern s32 D_80158D08; +extern u8 D_801518DC; +extern s32 D_800F9780[]; +extern u8 D_80153BDD; +extern u32 D_80151840; +extern u8 D_801590CC; +extern s16 D_801590D0; +extern s16 D_801590D4; +extern u8 D_801590D8; +extern s8 D_801590DC; +extern u8 D_801590E0; +extern s16 D_80162080; +extern s16 D_80162084; +extern s8 D_80162094; +extern Unk801620AC D_801620AC[10]; +extern Unk801621F0 D_801621F0[60]; +extern Unk80162978 D_80162978[100]; +extern u8 D_801635FC; +extern u8 D_80163604; +extern s16 D_80163608; +extern Unk801636B8 D_801636B8[5]; +extern u16 D_80163758[]; // part of a struct +extern u8 D_80163774[]; +extern u16 D_8016376E[]; +extern u8 D_80163784[3]; +extern s8 D_80163787; // suspicious, very likely part of a struct +extern Unk800A2F4C D_80163798[0x40]; +extern s8 D_80163A98; +extern u16 D_80163B80; +extern DR_MODE* D_80163C74; // TODO might be a generic u_long*, not DR_MODE* +extern u8 D_80163C7C; +extern ShortVectorXYZ D_80163C80[]; +extern s8 D_80166F58; +extern s8 D_80166F64; +extern u8 D_80166F68; + +void func_800A4350(u8, u8, s16, u16); +void func_800A8E84(s32); +s32 func_800B3030(s32); +void func_800B4794(void); +void func_800B5CD4(s32); +void func_800B5D38(s32); +void func_800B6B98(s32, s32); +void func_800B7FB4(void); +void func_800B8438(void); +static void func_800BA40C(); +static void func_800BB030(s16 arg0); +void func_800BB2A8(u8); +void func_800BB9B8(s32); +void func_800BBA84(u16 arg0, s32 arg1, s32 arg2); +static void func_800C1908(u8 arg0); +void func_800C5E94(void); +void func_800D088C(s32 loc, s32 len); +void func_800D0C80(u8 arg0); +void func_800D2980(u_long* addr, s16 imgXY, s16 clutX, s16 clutY); +void func_800D3BF0(); +void func_800D8A78(s8); +int func_800D8A88(void); +void func_800D9E0C(s32, s32, s32); +void func_800DCFD4(u_long*); +void func_800DDFEC(void); +void func_800E15D8(void); +void func_800E5814(void); +void func_800E6B94(void); diff --git a/src/brom/brom.c b/src/brom/brom.c new file mode 100644 index 0000000..d2c6206 --- /dev/null +++ b/src/brom/brom.c @@ -0,0 +1,15 @@ +#include "common.h" + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A0000); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A00CC); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A015C); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A01A0); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A0514); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A0534); + +INCLUDE_ASM("asm/us/brom/nonmatchings/brom", func_800A05D4); diff --git a/src/dschange/dschange.c b/src/dschange/dschange.c new file mode 100644 index 0000000..c6a07d3 --- /dev/null +++ b/src/dschange/dschange.c @@ -0,0 +1,5 @@ +#include "common.h" + +INCLUDE_ASM("asm/us/dschange/nonmatchings/dschange", func_800A0000); + +INCLUDE_ASM("asm/us/dschange/nonmatchings/dschange", func_800A0C58); diff --git a/src/ending/ending.c b/src/ending/ending.c new file mode 100644 index 0000000..003733a --- /dev/null +++ b/src/ending/ending.c @@ -0,0 +1,125 @@ +#include "common.h" + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0030); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A04C4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A09DC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0AB8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0BA8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0CAC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0E68); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0F90); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A11B4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A12F0); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A139C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A14BC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A16E4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A17C0); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A19A4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1E20); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1ED4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1EE4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1EEC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1F48); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1FA4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1FC8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2014); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A208C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A20D4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A20F8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2190); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A21CC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2248); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2274); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22A4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22D4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22E4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2328); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2380); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A23F8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2420); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2458); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A24A8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2504); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A273C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2888); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2934); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2974); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2A2C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2C68); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2E80); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2F1C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2FB8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A310C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A3178); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A3210); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A32D8); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A32F0); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A32FC); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A3308); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A3314); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A3368); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A343C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A34C4); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A358C); + +INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A379C); diff --git a/src/field/field.c b/src/field/field.c new file mode 100644 index 0000000..0280dd6 --- /dev/null +++ b/src/field/field.c @@ -0,0 +1,1263 @@ +//! PSYQ=3.3 CC1=2.6.3 +#include + +struct GpuBuf { + /* 0x00000 */ u_long ot[0x400]; + /* 0x01000 */ u8 unk1000[0x1689C]; + /* 0x3FFC used by DrawOTag */ + /* 0x418C used by DrawOTag */ + /* 0x4190 used by DrawOTag */ + /* 0x1748C */ u_long ot1748C[1]; + /* 0x17490 */ u8 unk17490[0xC]; + /* 0x1749C */ u8 unk1749C[0x400]; +}; // size:0x1789C + +const u32 D_800A0000[] = {0, 0x01D801E0}; +extern char D_800E0208[16]; // '0' to 'F' for hex digits +extern char D_800A0270[4]; +extern s8 D_800E0628; +extern s8 D_800E0630; +extern u16 D_800E1024; +extern s16 D_800E41B8; +extern s16 D_800E41C0; +extern s16 D_800E41BC; +extern s16 D_800E41C4; +extern u16 D_800E4210; +extern char D_800E4254[]; // debug text +extern char D_800E4288[]; // debug value transformed into text +extern struct GpuBuf D_800E4DF0[2]; +extern u8 D_80114498[]; + +void func_800A364C(struct GpuBuf* buf); +void func_800AA180(Unk80074EA4* arg0, Unk8007E7AC* arg1); +void func_800AAB24(struct GpuBuf* buf); +s32 func_800A9CE8(Unk8007E7AC*, u_long*, u_long*); +static void func_800D4840(const char* str); +static void func_800D4848(const char* errmsg); +void func_800D9F00(s32 val, const char* msg_out); +static void func_800DA334(char* dst, const char* src); +static void func_800DA368(char* arg0, char* arg1); +static void func_800DA424(s32 val, char* msg_out); +static void func_800DA444(s32 val, char* msg_out); +static void func_800DA480(s32 val, char* msg_out); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A1368); + +void func_800A1498(void) { + if (D_800965E8 == 1) { + func_8003408C(); + } + D_80071A5C = 0; + D_800965E8 = 0; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A14D8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A16CC); + +const u32 D_800A0024[] = {0x00000000, 0x000801E0}; +const u32 D_800A002C[] = {0x00E80000, 0x000801E0}; +const u32 D_800A0034[] = {0x01D00000, 0x000801E0}; +const u32 D_800A003C[] = {0x00000000, 0x00080140}; +const u32 D_800A0044[] = {0x00E80000, 0x00080140}; +const u32 D_800A004C[] = {0x01D00000, 0x00080140}; +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A2314); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A2D5C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A2F78); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A3020); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A364C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A4094); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A4134); + +static s32 func_800A41CC(SVECTOR* arg0, long* arg1) { + long sp10; + long sp14; + s32 ret; + + PushMatrix(); + SetRotMatrix(D_80071E40); + SetTransMatrix(D_80071E40); + SetGeomOffset(0, 0); + ret = RotTransPers(arg0, arg1, &sp10, &sp14); + PopMatrix(); + return ret; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A424C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A4430); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A45D4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A47F8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A48B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A496C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A4BEC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A5FB4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A635C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A6418); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A65A4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A82A0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8304); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8600); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8620); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8640); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8858); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8968); + +static void func_800A8DF4(s32* arg0, s16* arg1, s16* arg2) { + arg0[0] = arg1[0] - arg2[0]; + arg0[1] = arg1[1] - arg2[1]; + arg0[2] = arg1[2] - arg2[2]; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8E34); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A8F88); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A9B64); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A9CE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A9EEC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA180); + +static void func_800AA32C(Unk8007E7AC* arg0) { + s32 i; + + for (i = 0; i < 32; i++) { + arg0->unk15 = 0; + arg0++; + } +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA348); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA514); + +const u32 D_800A00BC[] = {0x00360000, 0x012A007A}; +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA5E4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA870); + +const u32 D_800A00DC[] = {0x00000000}; +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AA930); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AAB24); + +void func_800AB2AC(void) {} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB2B4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB310); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB4AC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB5E8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB728); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB9C8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ABA34); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ABA70); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ABF0C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ABFE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AC35C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ACBA0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ACC5C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AD7B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AD858); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ADAA4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ADC90); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800ADD70); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AE23C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AE4DC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AEE24); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AF6EC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AF96C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AFAC4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AFDE4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AFE1C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B0618); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B0A48); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B0EDC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B0FB0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B1C7C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B1E40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B2598); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B2A00); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B2DD4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B2F40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B480C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B4B04); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B4EAC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B5260); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B5504); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B62C4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B69C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B6AE4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B6B4C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B79B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B86D8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B8CF0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800B9B0C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BA534); + +static void func_800D7F9C(void); +void func_800BA65C(s32 arg0) { + if (D_8007EBE0) { + func_800D4BFC(); + func_800BC338(); + func_800D7D6C(); + func_800D7F9C(); + D_80095DCC = 0; + D_8009FE8C = 0; + D_8007EBE0 = 0; + if (D_8009C6DC[1] < 5) { + SystemError('K', 11); + } + if (D_8009C6DC[0] < 2) { + SystemError('K', 10); + } + if (D_8009C6DC[0] > 2 || D_8009C6DC[1] > 5) { + SystemError('K', 12); + } + } + if (D_80099FFC != 4) { + if (D_80099FFC != 5 || D_80070788 != 0) { + func_800BB3A8(); + } + } + if (D_80071E2C) { + func_8001F1BC(&D_80083274, 4, arg0, D_8009C6E0->unk0[0] ^ 1); + } + func_800BC438(arg0); +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BA7C4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BAF54); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BB1B4); + +const u32 D_800A013C[] = {0x00000000, 0x00000000}; +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BB3A8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BBBCC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BBF74); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BC338); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BC438); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BC4D4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BC9FC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BEAD4); + +static void func_800BECA4(const char* str, s32 val, s32 kind) { + if (!(D_80071E24 & 4) || D_80114498[D_800722C4]) { + func_800DA334(D_800E4254, str); + switch (kind) { + case 1: + func_800DA424(val, D_800E4288); // to single hex digit + break; + case 2: + func_800DA444(val, D_800E4288); // to double hex digit + break; + case 4: + func_800DA480(val, D_800E4288); // to four hex digits + break; + default: + func_800DA334(D_800E4288, D_800A0270); + break; + } + func_800DA368(D_800E4254, D_800E4288); + if (D_8009D820 & 1) { + func_800D9F00(2, D_800E4254); + } + if (D_8009D820 & 2) { + func_800D4840(D_800E4254); + } + } +} + +#ifndef NON_MATCHINGS +// OK; depends on func_800BF908 matching +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BEE10); +#else +s32 func_800BEE10(s16 arg0, s16 arg1) { + s32 indx; + s32 glov; + s32 var_v1; + + switch (arg0) { + case 1: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[1] >> 4; + break; + case 2: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[1] & 0xF; + break; + case 3: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[2] >> 4; + break; + case 4: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[2] & 0xF; + break; + case 5: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[3] >> 4; + break; + case 6: + var_v1 = (&D_8009C6DC[D_800831FC[D_800722C4]])[3] & 0xF; + break; + } + switch ((u8)var_v1) { + case 0: + glov = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1]; + if (D_8009D820 & 3) { + func_800BECA4("G cons=", glov, 2); + } + break; + case 1: + case 2: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1]; + glov = ((u8*)D_8009D288)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G glov=", glov, 2); + } + break; + case 3: + case 4: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1] | 0x100; + glov = ((u8*)D_8009D288)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G glov=", glov, 2); + } + break; + case 11: + case 12: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1] | 0x200; + glov = ((u8*)D_8009D288)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G glov=", glov, 2); + } + break; + case 13: + case 14: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1] | 0x300; + glov = ((u8*)D_8009D288)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G glov=", glov, 2); + } + break; + case 7: + case 15: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1] | 0x400; + glov = ((u8*)D_8009D288)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G glov=", glov, 2); + } + break; + case 5: + case 6: + indx = (&D_8009C6DC[D_800831FC[D_800722C4]])[arg1]; + glov = ((u8*)D_80075E24)[indx]; + if (D_8009D820 & 3) { + func_800BECA4("G indx=", indx, 4); + func_800BECA4("G mapv=", glov, 2); + } + break; + default: + if (D_8009D820 & 3) { + func_800BECA4("G data err=", (u8)var_v1, 2); + } + func_800D4848("Bad Event arg!"); + return 0; + } + return glov; +} +#endif + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BF3AC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800BF908); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0248); + +s32 func_800C0B54(void) { + if (D_8009D820 & 3) { + func_800DA444(D_8009A058, D_800E4288); + func_800DA368(D_800E4288, "???"); + func_800BEAD4(D_800E4288, 8); + func_800DA214(3, 0x7F, 0, 0); + } else { + func_800D4848("Bad Event code!"); + } + return 1; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0BE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0C18); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0DE0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0E5C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0EDC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0F58); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0FD8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C107C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1214); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C13B0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1674); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1714); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C17B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1858); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1AB4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1BF4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1D24); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1DE4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C1EEC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2000); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C228C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2394); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C24A8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2754); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C285C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2970); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2BFC); + +void func_800C2CA8(void) { + if (D_8009D820 & 3) { + func_800BEAD4("keyon", 3); + } + if (!((&D_8009C6DC[D_800831FC[D_800722C4]])[2] & 2)) { + func_800C2E00(D_8009C6E0->unk70); + } else { + func_800C2E00(D_8009C6E0->unk80); + } +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2D54); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2E00); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2F7C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C2FFC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C307C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C30FC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C31E4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C32CC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C33B4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C3A20); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C3C34); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C3EA0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C3F1C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C3FA0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C401C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C40A4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C42B0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4350); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C43C4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C45AC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C46A4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C46D0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4804); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C493C); + +void func_800C49EC(void) { + if (D_8009D820 & 3) { + func_800BEAD4("music", 1); + } + func_800C46A4(); + D_8009A000[0] = 0x10; + func_800C4BCC(); +} + +void func_800C4A40(void) { + if (D_8009D820 & 3) { + func_800BEAD4("musvt", 1); + } + func_800C46A4(); + D_8009A000[0] = 0x14; + func_800C4BCC(); +} + +void func_800C4A94(void) { + if (D_8009D820 & 3) { + func_800BEAD4("musvm", 1); + } + func_800C46A4(); + D_8009A000[0] = 0x15; + func_800C4BCC(); +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4AE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4BCC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4C9C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4CE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4DE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C4EE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C506C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C50EC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5194); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C523C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C532C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5414); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C54BC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5564); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C560C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5668); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5740); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5898); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5A2C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5B38); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5CE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5E80); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C5FF4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C63CC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C6748); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C684C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C6924); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C6D64); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C6FD8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C728C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C7354); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C75F0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C7C3C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C7CE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C7D5C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C814C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C81C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C826C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C8514); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C8588); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C8634); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C8B98); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C8F64); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9080); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C91D8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C955C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9A20); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9B88); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9C84); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9D80); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9E7C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C9F78); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA074); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA158); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA254); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA394); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA490); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA5D4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA77C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CA95C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CAA24); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CAAEC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CAC98); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CADFC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CAF60); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB01C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB0B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB1CC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB28C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB354); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB450); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB4F8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB5C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB660); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB718); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB7C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB858); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB8F4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CB98C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBA28); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBAC0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBB5C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBBF4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBCA4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBD40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBDFC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBE94); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBF40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CBFDC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC098); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC134); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC1D4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC284); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC358); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC404); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC4D8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC558); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC5EC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC670); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC70C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC78C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC824); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC8A8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC944); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CC9EC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCA68); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCB10); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCBBC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCC3C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCCC8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCD54); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCE94); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CCFE8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD0C4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD16C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD214); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD2E8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD3F0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD554); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD5F0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD6B0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD770); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD834); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CD91C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CDA24); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CDB0C); + +static void func_800CDC14(s16* arg0) { + arg0[0] = 0; + arg0[1] = 0; + arg0[2] = 0; + arg0[3] = 0; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CDC28); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CDD40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CDE8C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CE054); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CE214); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CE480); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CE6F4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CE904); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CEB20); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CEB94); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CEE44); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF028); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF140); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF200); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF2BC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF368); + +void func_800CF4CC(void*, void*, void*, void*); +void func_800CF66C(void*, void*); +void func_800CF6C0(void*, void*); +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF4CC); + +static void func_800CF5A0(void) { + s32 sp10[2]; + s32 sp18[2]; + + func_800CF4CC(D_8009CBDC, D_8009CBDC + 0x7B5, sp10, sp18); + func_800CF66C(D_8009CBDC, sp18); + func_800CF6C0(D_8009CBDC, sp10); + D_80071E34 = 1; +} + +static void func_800CF60C(void) { + s32 sp10[2]; + s32 sp18[2]; + + func_800CF4CC(D_8009D391, D_8009D391 - 0x7B5, sp10, sp18); + func_800CF66C(D_8009D391, sp18); + func_800CF6C0(D_8009D391, sp10); +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF66C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF6C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF718); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF874); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CF9B8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CFAF0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CFB84); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CFC1C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CFCE4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800CFE78); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D0180); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D0518); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D0938); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D0B4C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1200); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1350); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D152C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1654); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D184C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D195C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1A80); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1B94); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1C68); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1D3C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1DB8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1F20); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D1FDC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2098); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2164); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2794); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D28A8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D298C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2A70); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2B60); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2C60); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2E94); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D2F3C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3004); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3124); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3264); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3330); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D33FC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D348C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3548); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D368C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3728); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3840); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3958); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3A70); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3B88); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3C18); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3CA8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3D40); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3DCC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3E64); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D3F30); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4038); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4160); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4214); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4300); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4378); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4420); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D44E8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4780); + +static void func_800D4838(void) {} + +static void func_800D4840(const char* str) { + // used to print debug messages -- dummied out on release +} + +static void func_800D4848(const char* errmsg) { + func_800D828C(0, 100, 100, 150, 12); + func_800DA214(0, 0x7F, 0, 0); + func_800D9F00(0, errmsg); + D_80095DCC = 1; + D_80099FFC = 4; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D48C0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D493C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4B28); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4BC0); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4BFC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4C68); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4E24); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4E88); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D4EB4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D5228); + +static void func_800D5750(void) { + func_800C46A4(); + D_8009A000[0] = 0x30; + D_8009A004[0] = 1; + D_8009A008[0] = 0x40; + func_8002DA7C(); +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D579C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D5A60); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D5C9C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D6D44); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D6E0C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D6F6C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D707C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D726C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D775C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D785C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D7970); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D7A58); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D7C98); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D7D6C); + +static void func_800D7F9C(void) { + func_800D828C(5, 0x6C, 0, 0x6C, 0x52); + func_800DA334(D_800E4254, "Authr:"); + func_800DA368(D_800E4254, (s8*)(D_8009C6DC + 0x10)); + func_800D9F00(5, D_800E4254); + func_800DA334(D_800E4254, "Event:"); + func_800DA368(D_800E4254, (s8*)(D_8009C6DC + 0x18)); + func_800D9F00(5, D_800E4254); + func_800D9F00(5, " Go"); + func_800D9F00(5, " Stop"); + func_800D9F00(5, " Step"); + func_800DA124(5, 5, " Actor OFF"); + func_800DA124(5, 6, " Info OFF"); + func_800DA2CC(5); + func_800D828C(4, 0x6C, 0x52, 0x6C, 0x52); + func_800D9F00(4, &D_800E0628); + func_800DA2CC(4); + func_800D828C(3, 0x6C, 0xA4, 0x6C, 0x5C); + func_800D9F00(3, &D_800E0630); + func_800DA2CC(3); + func_800D828C(1, 0, 0, 0x6C, 0xCA); + func_800D9F00(1, &D_800E0628); + func_800DA2CC(1); + D_80099FFC = 3; + D_8007EBCC = 4; + D_8007EBDC = 8; + D_80071E24 = 0; + D_8009D820 = 0; + D_80070788 = 0; + D_80071C08 = 5; + func_800DA1D4(5, 4); +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D8194); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D828C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D8334); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D83A8); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D8420); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D8498); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D84CC); + +static void func_800D85C0(void) { + D_800E41B8 = 0; + D_800E41C0 = 0; + D_800E41BC = 0; + D_800E41C4 = 0; + D_800E1024 ^= 1; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D85FC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D8710); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D9C04); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D9F00); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800D9FFC); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA124); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA194); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA1D4); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA214); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA28C); + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA2CC); + +static void func_800DA310(void) { D_800E4210 = (D_800E4210 + 1) & 3; } + +static void func_800DA334(char* dst, const char* src) { + if (*src) { + do { + *dst++ = *src++; + } while (*src != '\0'); + } + *dst = '\0'; +} + +static void func_800DA368(char* arg0, char* arg1) { + if (*arg0 != '\0') { + while (*++arg0 != '\0') { + } + } + if (*arg1 != '\0') { + do { + *arg0++ = *arg1++; + } while (*arg1 != '\0'); + } + *arg0 = '\0'; +} + +static s32 func_800DA3C4(char* arg0) { + s32 len = 0; + + while (*arg0 != '\0') { + arg0++; + len++; + } + return len; +} + +static void func_800DA3F0(char* dst, char* src, s32 len) { + s32 i; + for (i = len - 1; i != -1; i--) { + *dst = *src; + src++; + dst++; + } +} + +static void func_800DA424(s32 val, char* msg_out) { + msg_out[1] = '\0'; + msg_out[0] = D_800E0208[val & 0xF]; +} + +static void func_800DA444(s32 val, char* msg_out) { + msg_out[2] = '\0'; + msg_out[0] = D_800E0208[(val & 0xF0) >> 4]; + msg_out[1] = D_800E0208[val & 0xF]; +} + +static void func_800DA480(s32 val, char* msg_out) { + msg_out[4] = '\0'; + msg_out[0] = D_800E0208[(val & 0xF000) >> 0xC]; + msg_out[1] = D_800E0208[(val & 0xF00) >> 8]; + msg_out[2] = D_800E0208[(val & 0xF0) >> 4]; + msg_out[3] = D_800E0208[val & 0xF]; +} + +INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800DA4FC); diff --git a/src/magic/barrier.c b/src/magic/barrier.c new file mode 100644 index 0000000..3762620 --- /dev/null +++ b/src/magic/barrier.c @@ -0,0 +1,253 @@ +//! PSYQ=3.3 CC1=2.6.3 + +#include "common.h" +#include "../battle/battle.h" + +typedef struct BarrierData { + s16 unk0; + s16 unk2; + s16 unk4; + s16 unk6; + SVECTOR pos; + SVECTOR rot; + u16 unk18; + char pad1[0x6]; +} BarrierData; + +extern BarrierData D_80162978[]; + +static s32 D_801B0B68[] = { // this seems to be a header+3D model + 0x00000030, 0xFE0C0000, 0x000001CA, 0x00000000, 0x0000FFD7, 0x0000FE0C, + 0x000002E5, 0xFFEDFE2F, 0x000002C2, 0xFE2AFFF2, 0x000001C2, 0xFFEDFFF2, + 0x00000000, 0x00200000, 0x00000000, 0x00000000, 0x00000006, 0x00280008, + 0x00180010, 0x38FFFFFF, 0x006A6A6A, 0x00C0C0C0, 0x006A6A6A, 0x00200000, + 0x00280008, 0x38C0C0C0, 0x006A6A6A, 0x00FFFFFF, 0x006A6A6A, 0x00180010, + 0x00200000, 0x38C0C0C0, 0x006A6A6A, 0x00C0C0C0, 0x006A6A6A, 0x00100008, + 0x00180028, 0x38FFFFFF, 0x00C0C0C0, 0x006A6A6A, 0x006A6A6A, 0x00080000, + 0x00280020, 0x38C0C0C0, 0x00FFFFFF, 0x006A6A6A, 0x006A6A6A, 0x00000010, + 0x00200018, 0x38C0C0C0, 0x00C0C0C0, 0x006A6A6A, 0x006A6A6A}; +static s32 D_801B0C3C[] = { // this seems to be a header+3D model + 0x00000018, 0xFFEDFE2F, 0x000002C2, 0xFE2AFFF2, 0x000001C2, 0xFFEDFFF2, + 0x00000000, 0x00200000, 0x00000000, 0x00000002, 0x00000008, 0x00000010, + 0x303F3F3F, 0x003F3F3F, 0x00D4D4D4, 0x00100008, 0x00000000, 0x303F3F3F, + 0x00D4D4D4, 0x003F3F3F, 0x00000000}; +static SVECTOR D_801B0C90 = {0, 0, -500}; +static Unk801B0C98 D_801B0C98 = {D_801B0B68, 0, 0, 0, 0x20}; +static SVECTOR D_801B0CA8 = {0, 0, -500}; +static Unk801B0C98 D_801B0CB0 = {D_801B0C3C, 0, 0, 0, 0x20}; +static int D_801B0CC0; +static char D_801B0CC4[0x20000]; +static void* D_801D0CC4; + +// barrier.c forward declarations +static void func_801B0AF0(int arg0, int arg1); + +void func_801B0000(int arg0, int arg1) { func_801B0AF0(arg0, arg1); } + +static void func_801B0020(void) { + MATRIX* matrix = (MATRIX*)0x1F800000; + VECTOR* scale = (VECTOR*)0x1F800020; + BarrierData* data = &D_80162978[D_8015169C]; + int temp_a0 = (data->unk2 + data->unk0) - 17; + int var_s4; + int var_s3; + + if (temp_a0 < 0) { + scale->vx = scale->vy = scale->vz = (D_801B0CC0 * 0xC00) >> 12; + var_s3 = data->unk18; + var_s4 = 0; + } else if (temp_a0 > 7) { + data->unk0 = -1; + return; + } else { + var_s3 = data->unk18 | 8; + var_s4 = temp_a0 << 9; + scale->vx = scale->vy = scale->vz = + (((temp_a0 * 0x180) + 0xC00) * D_801B0CC0) >> 12; + } + + SetFarColor(0, 0, 0); + RotMatrixYXZ(&data->rot, matrix); + ScaleMatrix(matrix, scale); + ApplyMatrix(matrix, &D_801B0C90, matrix->t); + + matrix->t[0] += data->pos.vx; + matrix->t[1] += data->pos.vy; + matrix->t[2] += data->pos.vz; + + CompMatrix(&D_800FA63C.m, matrix, matrix); + SetRotMatrix(matrix); + SetTransMatrix(matrix); + + D_801B0C98.unk4 = var_s3 | 0x80; + D_801B0C98.unkA = var_s4; + D_801D0CC4 = func_800D29D4(&D_801B0C98, D_801517C0->unk70, 12, D_801D0CC4); + + if (D_80062D98 == 0) { + data->unk2++; + } +} + +static void func_801B0220(void) { + MATRIX* matrix1 = (MATRIX*)0x1F800000; + MATRIX* matrix2 = (MATRIX*)0x1F800020; + VECTOR* scale1 = (VECTOR*)0x1F800040; + VECTOR* scale2 = (VECTOR*)0x1F800050; + BarrierData* data = &D_80162978[D_8015169C]; + int temp_a0 = data->unk2 + data->unk0 - 17; + int var_s5; + int var_s6; + + if (temp_a0 < 0) { + if (data->unk2 < 6) { + scale1->vx = scale1->vy = scale1->vz = + (data->unk2 * (D_801B0CC0 << 9)) >> 12; + } else { + scale1->vx = scale1->vy = scale1->vz = (D_801B0CC0 * 0xC00) >> 12; + } + + scale2->vx = scale2->vy = scale2->vz = (D_801B0CC0 * 0xC00) >> 12; + + var_s5 = data->unk18; + var_s6 = 0; + } else if (temp_a0 > 7) { + data->unk0 = -1; + return; + } else { + var_s5 = data->unk18 | 8; + var_s6 = temp_a0 << 9; + scale1->vx = scale1->vy = scale1->vz = scale2->vx = scale2->vy = + scale2->vz = (((temp_a0 * 0x180) + 0xC00) * D_801B0CC0) >> 12; + } + + SetFarColor(0, 0, 0); + RotMatrixYXZ(&data->rot, matrix1); + *matrix2 = *matrix1; + ScaleMatrix(matrix1, scale1); + ScaleMatrix(matrix2, scale2); + ApplyMatrix(matrix2, &D_801B0CA8, matrix1->t); + matrix1->t[0] += data->pos.vx; + matrix1->t[1] += data->pos.vy; + matrix1->t[2] += data->pos.vz; + CompMatrix(&D_800FA63C.m, matrix1, matrix1); + SetRotMatrix(matrix1); + SetTransMatrix(matrix1); + + D_801B0CB0.unk4 = var_s5 | 0x80; + D_801B0CB0.unkA = var_s6; + D_801D0CC4 = func_800D29D4(&D_801B0CB0, D_801517C0->unk70, 12, D_801D0CC4); + + if (D_80062D98 == 0) { + data->unk2++; + } +} + +static void func_801B04F4(void) { + BarrierData* data = &D_80162978[D_8015169C]; + BarrierData* next; + + if (D_80062D98 != 0) { + return; + } + + if (data->unk2 == 0) { + next = &D_80162978[func_800BBEAC(func_801B0020)]; + next->unk0 = data->unk2; + next->unk18 = 0; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 2) { + next = &D_80162978[func_800BBEAC(func_801B0020)]; + next->unk0 = data->unk2; + next->unk18 = 1; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 4) { + next = &D_80162978[func_800BBEAC(func_801B0020)]; + next->unk0 = data->unk2; + next->unk18 = 3; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 6) { + next = &D_80162978[func_800BBEAC(func_801B0020)]; + next->unk0 = data->unk2; + next->unk18 = 2; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 1) { + next = &D_80162978[func_800BBEAC(func_801B0220)]; + next->unk0 = data->unk2; + next->unk18 = 0; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 3) { + next = &D_80162978[func_800BBEAC(func_801B0220)]; + next->unk0 = data->unk2; + next->unk18 = 1; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 5) { + next = &D_80162978[func_800BBEAC(func_801B0220)]; + next->unk0 = data->unk2; + next->unk18 = 3; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 7) { + next = &D_80162978[func_800BBEAC(func_801B0220)]; + next->unk0 = data->unk2; + next->unk18 = 2; + next->rot = data->rot; + next->pos = data->pos; + } + + if (data->unk2 == 17) { + func_800D5774(data->unk4); + data->unk0 = -1; + } + + data->unk2++; +} + +static void func_801B092C(int arg0) { + BarrierData* data = &D_80162978[func_800BBEAC(func_801B04F4)]; + + func_800D3994(arg0, D_801518E4[arg0].D_8015190F, &data->pos); + data->pos.vx -= + (rsin(D_801518E4[arg0].unk160.vy) * D_801518E4[arg0].unk12) >> 12; + data->pos.vz -= + (rcos(D_801518E4[arg0].unk160.vy) * D_801518E4[arg0].unk12) >> 12; + data->rot = D_801518E4[arg0].unk160; + data->unk4 = arg0; +} + +static void func_801B0A90(void) { + BarrierData* data = &D_80162978[D_8015169C]; + + D_801D0CC4 = &D_801B0CC4[data->unk2 * 65536]; + data->unk2 ^= 1; + + if (D_80162080 < 2) { + data->unk0 = -1; + } +} + +static void func_801B0AF0(int arg0, int arg1) { + D_801B0CC0 = 0x3000; + func_800BBEAC(func_801B0A90); + func_800D5444(arg0, arg1, 4, func_801B092C); + func_800D55F4(32, func_800D574C(arg0), 94); +} diff --git a/src/main/1255C.c b/src/main/1255C.c new file mode 100644 index 0000000..f5ae9e2 --- /dev/null +++ b/src/main/1255C.c @@ -0,0 +1,408 @@ +//! PSYQ=3.3 CC1=2.7.2 G=8 +#include "main_private.h" + +s8 D_80062EBC = 0; +static s8 _D_80062EBD = 0; +static s8 _D_80062EBE = 0; +static s8 _D_80062EBF = 0; +s8 D_80062EC0 = 0; +static s8 _D_80062EC1 = 0; +static s8 _D_80062EC2 = 0; +static s8 _D_80062EC3 = 0; + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80021D5C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80021E70); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80021F58); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80022B5C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80022DE4); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80022FE0); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80023050); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_8002305C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800230C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_8002368C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80023788); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_8002382C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80023940); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80023AC4); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80023AD4); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80024A04); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80024A3C); + +void func_80024D88(s32 arg0) { + func_800211C4(0xD); + do { + } while (func_80034B44()); + VSync(30); + func_801D131C(arg0); +} + +void func_80024DD4(s32 arg0) { + func_800211C4(0xE); + do { + } while (func_80034B44()); + func_801D1A6C(arg0); +} + +void func_80024E18(s32 arg0) { + func_800211C4(0xF); + do { + } while (func_80034B44()); + func_801D4118(arg0); +} + +// This should be the title screen handler +void func_80024E5C(void) { + func_800211C4(0x10); // load title screen? + do { // wait until it's loaded? + } while (func_80034B44()); + func_801D4CC0(); // jump into title screen loop? +} + +void func_80024E94(void) { + func_800211C4(0xA); + do { + } while (func_80034B44()); + func_801D1774(); +} + +void func_80024ECC(void) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D2D74(); +} + +void func_80024F04(void) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D2E84(); +} + +void func_80024F3C(s32 arg0) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D2F00(arg0); +} + +void func_80024F80(s32 arg0) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D3138(arg0); +} + +void func_80024FC4(s32 arg0) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D3018(arg0); +} + +void func_80025008(void) { + func_800211C4(1); + do { + } while (func_80034B44()); + func_801D3228(); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025040); + +void func_800250B4(void) { + func_800211C4(0xC); + do { + } while (func_80034B44()); + func_801D027C(); +} + +void func_800250EC(s32 arg0) { + func_800211C4(0xC); + do { + } while (func_80034B44()); + func_801D05C4(arg0); +} + +void func_80025130(s32 arg0) { + func_800211C4(0xC); + do { + } while (func_80034B44()); + func_801D0704(arg0); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025174); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025288); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025310); + +void func_80025360() { func_8001FA28(0x19F); } + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025380); + +s32 func_8002542C(s32 arg0) { + s32 i; + for (i = 0; i < MAX_MATERIA_COUNT; i++) { + if (Savemap.materia[i] == -1) { + Savemap.materia[i] = arg0; + if (func_8002603C(arg0 & 0xFF) == 10) { + Savemap.memory_bank_1[75] |= 1; + } + if ((arg0 & 0xFF) == 44) { + Savemap.memory_bank_1[75] |= 2; + } + return -1; + } + } + return arg0; +} + +void func_800254D8() { D_80062EBC = 0; } + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800254E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025514); + +void func_80025648(void) {} + +void func_80025650(void) {} + +// get party leader (Cloud) level +s32 func_80025658() { return D_8009C738[0].level; } + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025668); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800256DC); + +s32* func_80025758(s32 arg0) { return &D_80071E44[arg0 * 9]; } + +s32* func_80025774(s32 arg0) { return &D_80071C24[arg0 * 4]; } + +Unk8009D84C* func_80025788(s32 arg0) { + if (Savemap.partyID[arg0] != 0xFF) { + return &D_8009D84C[arg0]; + } + // BUG undefined return +} + +void func_800257C4(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800257CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025800); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800258BC); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025988); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025A44); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025B10); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025B48); + +s32 SYS_gil(void) { return Savemap.gil; } + +void func_80025B8C(u_long* image) { + RECT rect; + rect.x = 0x340; + rect.y = 0x184; + rect.w = 0x30; + rect.h = 0x78; + StoreImage(&rect, image); +} + +void func_80025BD0(u_long* image) { + RECT rect; + rect.x = 0x340; + rect.y = 0x184; + rect.w = 0x30; + rect.h = 0x78; + LoadImage(&rect, image); +} + +void func_80025C14(u_long* image) { + RECT rect; + rect.x = 0x180; + rect.y = 0; + rect.w = 0x100; + rect.h = 9; + StoreImage(&rect, image); +} + +void func_80025C54(u_long* image) { + RECT rect; + rect.x = 0x180; + rect.y = 0; + rect.w = 0x100; + rect.h = 9; + LoadImage(&rect, image); +} + +void func_80025C94(u_long* image) { + RECT rect; + rect.x = 0x100; + rect.y = 0x1ED; + rect.w = 0x100; + rect.h = 3; + LoadImage(&rect, image); +} + +void func_80025CD4(u_long* image) { + RECT rect; + rect.x = 0x100; + rect.y = 0x1ED; + rect.w = 0x100; + rect.h = 3; + StoreImage(&rect, image); +} + +void func_80025D14(u_long* addr, s32 px, s32 py, s32 cx, s32 cy) { + TIM_IMAGE tim; + OpenTIM(addr); + while (ReadTIM(&tim)) { + if (tim.caddr) { + tim.crect->x = cx; + tim.crect->y = cy; + LoadImage(tim.crect, tim.caddr); + DrawSync(0); + } + if (tim.paddr) { + tim.prect->x = px; + tim.prect->y = py; + LoadImage(tim.prect, tim.paddr); + DrawSync(0); + } + } +} + +// this function seems to be responsible of loading the characters' portrait +void func_80025DF8(void) { + u8 dummy[8]; + u8 buf[0x1000]; + u_long* dst; + s32 i; + s32* sector_off; + s32* length; + s32 cx, cy; + + i = 0; + dst = (u_long*)buf; + sector_off = &D_80048FE8->sector_off; + length = &D_80048FE8->length; + for (; i < 9; i++) { + func_80033F40(sector_off[i * 2], length[i * 2], dst, 0); + cx = 0x340 + (i / 5) * 0x18; + cy = 0x100 + (i % 5) * 0x30; + func_80025D14(dst, cx, cy, 0x180, i); + DrawSync(0); + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80025ED4); + +void func_80026034(void) {} + +s32 func_8002603C(u8 arg0) { + return D_80049520[D_80049528[D_800730DC[arg0][1] & 0xF]]; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026090); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800260DC); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026258); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800262D8); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026408); + +void func_80026448(Unk80026448* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, + s32 arg5, s32 arg6, s32 arg7, s32 arg8, s32 arg9, s32 arg10, + s32 arg11, s32 arg12, u16 arg13) { + arg0->unkA = arg1; + arg0->unkB = arg2; + arg0->unkC = arg3; + arg0->unkD = arg4; + arg0->unk0 = arg5; + arg0->unk2 = arg6; + arg0->unk4 = arg7; + arg0->unk6 = arg8; + arg0->unkE = arg9; + arg0->unkF = arg10; + arg0->unk10 = arg11; + arg0->unk11 = arg12; + arg0->unk8 = arg13; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800264A8); + +void func_800269C0(void* arg0) { D_80062F24.poly = arg0; } + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800269D0); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800269E8); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026A00); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026A0C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026A20); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026A34); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026A94); + +void func_80026B5C(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026B64); + +// strlen but for FF7 strings +// FF7 string is 0x00: ' ', 0x10: '0', 0x21: 'A', 0xFF: terminator +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026B70); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026C5C); + +// print FF7 string +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80026F44); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_8002708C); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80027354); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80027408); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80027990); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80027B84); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80028030); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80028484); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_800285AC); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80028930); + +void func_80028CA0(s16, s16, s16, s16, s16, s16, s16, s16); +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80028CA0); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80028E00); + +INCLUDE_ASM("asm/us/main/nonmatchings/1255C", func_80029114); diff --git a/src/main/18B8.c b/src/main/18B8.c new file mode 100644 index 0000000..631cf50 --- /dev/null +++ b/src/main/18B8.c @@ -0,0 +1,1295 @@ +//! G=8 +#include "main_private.h" + +s32 D_80062D4C = 0x00000000; +s32 D_80062D50 = 0x000000FF; +s32 D_80062D54 = 0x00000000; +s32 D_80062D58 = 0x00000009; +s32 D_80062D5C = 0x00000006; +s16 D_80062D60 = 0x0000; +s16 D_80062D62 = 0x0000; +s16 D_80062D64 = 0x0000; +s16 D_80062D66 = 0x0000; +s16 D_80062D68 = 0x0000; +s16 D_80062D6A = 0x0000; +s16 D_80062D6C = 0x0000; +s16 D_80062D6E = 0x0000; +u8 g_bPadsInitialized = 0x00; +s8 D_80062D71 = 0x00; +s16 D_80062D72 = 0x0000; +s16 D_80062D74 = 0x0000; +s16 D_80062D76 = 0x0000; +u16 D_80062D78 = 0x0000; +s16 D_80062D7A = 0x0000; +u16 D_80062D7C = 0x0000; +u16 D_80062D7E = 0x0000; +u16 D_80062D80 = 0x0000; +u16 D_80062D82 = 0x0000; +s32 D_80062D84 = 0x00000000; +s16 D_80062D88 = 0x0000; +s16 D_80062D8A = 0x0000; +s32 D_80062D8C = 0x00000000; +s32 D_80062D90 = 0x00000000; +s32 D_80062D94 = 0x00000000; +u8 D_80062D98 = 0x00; +u8 D_80062D99 = 0x00; +static s16 D_80062D9A = 0x0000; +s32 D_80062D9C = 0x00000000; +s32 D_80062DA0 = 0x00140000; +s32 D_80062DA4 = 0x007800A0; +s32 D_80062DA8 = 0x00010002; +s32 D_80062DAC = 0x00060006; +s32 D_80062DB0 = 0x00010001; +s16 D_80062DB4 = 0x0007; +s16 D_80062DB6 = 0x0000; +s16 D_80062DB8 = 0x0000; +s16 D_80062DBA = 0x0000; +s16 D_80062DBC = 0x0000; +s16 D_80062DBE = 0x0000; +s32 D_80062DC0 = 0x00000000; +s32 D_80062DC4 = 0x00000000; +s32 D_80062DC8 = 0x00000000; +s32 D_80062DCC = 0x00000000; +s32 D_80062DD0 = 0x00000000; +s32 D_80062DD4 = 0x00000000; +s16 D_80062DD8 = 0x0000; +s8 D_80062DDA = 0x00; +u8 D_80062DDB = 0x00; +u8 D_80062DDC = 0x02; +static s8 _D_80062DDD = 0x00; +static s8 _D_80062DDE = 0x00; +static s8 _D_80062DDF = 0x00; +s32 D_80062DE0 = 0x00000000; +u8 D_80062DE4 = 0x00; +u8 D_80062DE5 = 0x00; +s16 D_80062DE6 = 0x00B4; +s16 D_80062DE8 = 0x0068; +s16 D_80062DEA = 0x0000; +s32 D_80062DEC = 0x801D0000; +s32 D_80062DF0 = 0x00000084; +s32 D_80062DF4 = 0xFFFFFFFF; +s32 D_80062DF8 = 0x00000001; +s8 D_80062DFC = 0x40; +static s8 _D_80062DFD = 0x00; +static s8 _D_80062DFE = 0x00; +static s8 _D_80062DFF = 0x00; +s32 D_80062E00 = 0x00000000; +s32 D_80062E04 = 0x00000000; +s16 D_80062E08 = 0x0000; +s16 D_80062E0A = 0x0000; +s32 D_80062E0C = 0; +s32 D_80062E10 = 0; // most likely a struct with D_80062E14 (see func_80014C44) +s32 D_80062E14 = 0; +s32 D_80062E18 = 0; +s32 D_80062E1C = 0; +s32 D_80062E20 = 0; +s32 D_80062E24 = 0x00000000; +s32 D_80062E28 = 0x00000000; +s32 D_80062E2C = 0x00000000; +s32 D_80062E30 = 0x00000000; +s32 D_80062E34 = 0x00000000; +s32 D_80062E38 = 0x00000000; +s32 D_80062E3C = 0x00000000; +s32 D_80062E40 = 0x00000000; +s32 D_80062E44 = 0x00000000; +s32 D_80062E48 = 0x00000000; +s32 D_80062E4C = 0x00000000; +s8 D_80062E50 = 0x00; +static s8 _D_80062E51 = 0x00; +static s8 _D_80062E52 = 0x00; +static s8 _D_80062E53 = 0x00; +s8 D_80062E54 = 0x00; +static s8 _D_80062E55 = 0x00; +static s8 _D_80062E56 = 0x00; +static s8 _D_80062E57 = 0x00; +s8 D_80062E58 = 0x00; +static s8 _D_80062E59 = 0x00; +static s8 _D_80062E5A = 0x00; +static s8 _D_80062E5B = 0x00; +s8 D_80062E5C = 0x00; +static s8 _D_80062E5D = 0x00; +static s8 _D_80062E5E = 0x00; +static s8 _D_80062E5F = 0x00; +s32 D_80062E60 = 0; +s8 D_80062E64 = 0x00; +static s8 _D_80062E65 = 0x00; +static s8 _D_80062E66 = 0x00; +static s8 _D_80062E67 = 0x00; +s8 D_80062E68 = 0x00; +static s8 _D_80062E69 = 0x00; +static s8 _D_80062E6A = 0x00; +static s8 _D_80062E6B = 0x00; +s32 D_80062E6C = 0x00000000; +s16 D_80062E70 = 0x0000; +s16 D_80062E72 = 0x0000; +s16 D_80062E74 = 0x0000; +s16 D_80062E76 = 0x0000; +s8 D_80062E78 = 0x00; +static s8 _D_80062E79 = 0x00; +static s8 _D_80062E7A = 0x00; +static s8 _D_80062E7B = 0x00; +s32 D_80062E7C = 0x00000000; +s32 D_80062E80 = 0x00000000; +s32 D_80062E84 = 0x00000000; +s16 D_80062E88 = 0x0000; +s16 D_80062E8A = 0x0000; +s8 D_80062E8C = 0x00; +static s8 _D_80062E8D = 0x00; +static s8 _D_80062E8E = 0x00; +static s8 _D_80062E8F = 0x00; +s8 D_80062E90 = 0x00; +static s8 _D_80062E91 = 0x00; +static s8 _D_80062E92 = 0x00; +static s8 _D_80062E93 = 0x00; +s32 D_80062E94 = 0x00000000; +s32 D_80062E98 = 0x00000000; +s32 D_80062E9C = 0x00000000; +s32 D_80062EA0 = 0x00000000; +s32 D_80062EA4 = 0x00000000; +s16 D_80062EA8 = 0x0000; +s16 D_80062EAA = 0x0000; +s16 D_80062EAC = 0x0000; +s16 D_80062EAE = 0x0000; +s16 D_80062EB0 = 0x0000; +s16 D_80062EB2 = 0x0000; +s8 D_80062EB4 = 0x00; +static s8 _D_80062EB5 = 0x00; +static s8 _D_80062EB6 = 0x00; +static s8 _D_80062EB7 = 0x00; +s32 D_80062EB8 = 0; + +void func_8001155C(void); +void func_80014A00(s32* dst, s32* src, s32 len); +u16* func_80014D9C(s32, s32, s32); +s32 func_800150E4(u16*, u16*); +u16* func_800151F4(s32); +void func_80015CA0(GzHeader* src, s32* dst); +s32 func_8001AC9C(u8, s32); +void func_8001B834(s32); +void func_8001BD50(u8, u8, u8); +u8 func_8001F6B4(); + +void __main(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", __SN_ENTRY_POINT); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001117C); + +void func_800111E4(void) { + D_8009A000[0] = 0xF4; + func_8002DA7C(); + if (!(D_8009D5E9 & 0x30)) { + func_8001117C(0x2B); + } + D_800707BC = D_8009ABF6; + D_800707BE = D_8009AC32; + D_800707BE = D_800716D0 | D_800707BE; + func_800146A4(); + D_800716D0 = 0; +} + +void func_80011274(void) { + func_80033E34(D_80048D1C, D_80048D20, (u_long*)0x800E0000, NULL); + + while (1) { + if (func_80034B44() == 0) { + break; + } + } + + func_80033E34(D_80048D14, D_80048D18, (u_long*)0x800A0000, NULL); + + while (1) { + if (func_80034B44() == 0) { + break; + } + } + + func_80029818((u32*)0x800A0000, (u32*)0x800E0000); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800112E8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001146C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001155C); + +void func_8001171C(void) { + StopCallback(); + ResetCallback(); + ResetGraph(0); + func_80036298(); + D_80095DD4 = 0; + VSyncCallback(&func_8001155C); + SetGraphDebug(0); + SetDispMask(0); + InitGeom(); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80011784); + +void func_800A16CC(); // field loop +void func_800CF60C(); // field load +extern s32 D_80048D24; // field.X sector +extern u32 D_80048D28; // field.X size + +void func_80011860(void) { + if (D_800965EC != 5 && D_800965EC != 13) { + if (D_800965EC != 2) { + func_80033E34(D_80048D24, D_80048D28, (u_long*)0x80180000, NULL); + while (1) { + if (func_80034B44() == 0) { + break; + } + } + func_80015CA0((GzHeader*)0x80180000, (s32*)0x800A0000); + } else { + while (1) { + if (func_80034B44() == 0) { + break; + } + } + func_80015CA0((GzHeader*)0x801C0000, (s32*)0x800A0000); + } + } + func_800CF60C(); + func_800A16CC(); +} + +void func_80011920(void) { + D_800965E8 = 0; + D_80071A5C = 0; +} + +void func_80011938(void) { + func_80033E34(D_80048CFC, D_80048D00, (u_long*)0x800F0000, NULL); + do { + } while (func_80034B44()); + func_80033E34(D_80048D04, D_80048D08, (u_long*)0x801B0000, NULL); + do { + } while (func_80034B44()); + func_80033E34(D_80048D0C, D_80048D10, (u_long*)0x801BC800, NULL); + do { + } while (func_80034B44()); + func_8002988C(0x800F0000, 0x801BC800); + func_80029998(0x801B0000); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800119E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80011AEC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80011BB4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", main); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80012840); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800128B8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800129D0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80012A8C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80012DB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800131B8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800134F4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80013564); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800135C0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80013624); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80013800); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800138EC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80013C9C); + +void func_800140A4(void) { + D_8019DAA0++; + if (!(D_8019DAA0 & 1)) { + DrawOTag(D_8019D5E8); + func_80013C9C(); + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800140F4); + +// obtain file sector from a YamadaFile +s32 func_800144D8(s32 file_no) { return D_80048D84[file_no].loc; } + +void func_800144F0(s32 file_no) { func_80033DAC(file_no, 0); } + +void func_80014510(s32 file_no) { func_800144F0(D_80048D84[file_no].loc); } + +// used to load WORLD/WORLD.BIN or FIELD/FIELD.BIN +void func_80014540(void) { + func_80033E34(D_80071744, D_80095DD8, D_800722C8, NULL); +} + +void func_80014578(s32 file_no, void* dst, void (*cb)(void)) { + func_80033E34(D_80048D84[file_no].loc, D_80048D84[file_no].len, dst, cb); +} + +void func_800145BC(void (*cb)(void)) { + while (func_80034B44()) { + if (cb) { + cb(); + } + } +} + +void func_80014608(void) {} + +// initialize LBA system +void func_80014610(void) { + u8 buf[2048]; + func_80033E34(LBA_INIT_YAMADA, sizeof(buf), (u_long*)&buf, NULL); + func_800145BC(0); + func_80014A00( + (s32*)D_80048D84, (s32*)&buf, sizeof(Yamada) * YAMADA_FILE_NUM); +} + +void func_80014658(s32 file_no, void (*cb)(void)) { + func_80014578(file_no, (void*)0x801B0000, 0); + func_800145BC(0); + func_80015CA0((GzHeader*)0x801B0000, (s32*)0x800A0000); + cb(); +} + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800146A4); +#else +void func_800146A4(void) { + s32 var_s0 = -1; + while (var_s0) { + switch (D_8009C560) { + case 4: + func_800145BC(0); + func_80014658(BATTLE_BROM, D_800A00CC); + break; + case 2: + func_800140F4(); + func_80014658(BATTLE_BATTLE, D_800A1158); + break; + default: + var_s0 = 0; + break; + } + } +} +#endif + +void func_80014750(void) { + s32 temp_a0; + s32 temp_s0; + + func_80015B44(0x801B0000); + while (1) { + temp_s0 = func_80015B50() & 0xFFFF; + if (temp_s0 == 0xFFFF) { + break; + } + temp_a0 = func_80015B88() & 0xFFFF; + if (temp_s0 == 9) { + func_80015BC0(func_80014C80(temp_a0)); + } else if (D_80048DD4[temp_s0]) { + func_80015BC0(D_80048DD4[temp_s0]); + } + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014804); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800148A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800148B4); + +void func_80014934(void) { + func_800148A0(); + func_80014578(INIT_KERNEL, (void*)0x801B0000, 0); + func_800145BC(0); + func_80015C3C(0x801B0000, D_8009C738, KERNEL_INIT); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014980); + +void func_800149E0(void) { DrawSync(0); } + +void func_80014A00(s32* dst, s32* src, s32 len) { + int i; + for (i = 0; i < len >> 2; i++) { + *dst++ = *src++; + } +} + +s32 func_80014A38(u32 arg0) { + s32 i; + for (i = 0;; i++) { + arg0 >>= 1; + if (!arg0) { + return i; + } + } +} + +s32 func_80014A58(u32 arg0) { + s32 i; + i = 0; + while (arg0) { + if (arg0 & 1) { + i++; + } + arg0 >>= 1; + } + return i; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014A84); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014B08); + +void func_80014B54(void) { D_80062E18 = (D_80062E18 + 1) & 7; } + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014B70); + +s32 func_80014BA8(s32 arg0) { + return (u8)(((func_80014B70() & 0xFF) * arg0) >> 8); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014BE4); + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014C44); +#else +// func_80014C44 needs to be in a different file than D_80062E10 +void func_80014C44(s32 arg0) { + s32 i; + for (i = 0; i < 8; i++) { + D_80062E10[i] = arg0; + arg0 >>= 1; + } + D_80062E18 = 0; +} +#endif + +void func_80014C70() { + D_80062E1C = 0; + D_80062E20 = 0; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014C80); + +s32 func_80014CBC(s32 arg0, s32 arg1) { + s32 var_a2; + u8 var_v1; + + var_v1 = 0xFF; + var_a2 = -1; + switch (arg0) { + case 0: + case 1: + case 2: + var_v1 = D_800708D4[(D_80010100[arg0] + arg1) * 0x1C]; + break; + case 4: + if (arg1 < 0x80) { + var_v1 = D_800722DC[arg1 * 0x1C]; + } + } + if (var_v1 != 0xFF) { + var_a2 = var_v1; + } + return var_a2; +} + +u8* func_80014D58(u8* arg0, u8* arg1, s32 arg2) { + u8 var_a3 = *arg1; + while (var_a3 != 0xFF) { + *arg0 = var_a3; + arg1++; + arg2--; + arg0++; + if (arg2 == -1) { + break; + } + var_a3 = *arg1; + } + return arg0; +} + +u16* func_80014D9C(s32 arg0, s32 arg1, s32 arg2) { + u8* temp_v1 = D_80063690 + D_80069490[arg0 + arg2]; + return (u16*)&temp_v1[*(u16*)&temp_v1[arg1 * 2]]; +} + +void func_80014DD0(s32 arg0, s32 arg1, u8* arg2) { + func_80014D58(arg2, (u8*)func_80014D9C(arg0, arg1, 0), -1); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014E0C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014E74); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800150E4); + +u16* func_800151F4(s32 arg0) { return func_80014D9C(0x10, arg0, 0); } + +s32 func_8001521C(s32 arg0) { + u16* temp_v0 = func_800151F4(arg0); + return func_800150E4(temp_v0, temp_v0); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015248); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800155A4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800155B0); + +void func_80015654(s32 arg0) { + D_80062E24 = 0; + D_80062E28 = 0; + D_80062E2C = arg0; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015668); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800159B0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015AFC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015B44); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015B50); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015B88); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015BC0); + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015C3C); +#else +// load kernel module by its ID +// https://wiki.ffrtt.ru/index.php/FF7/Kernel/Low_level_libraries#BIN-GZIP_Type_Archives +s32 func_80015C3C(u8* src, void* dst, s32 id) { + s32 len; + s32 cur_id; + s32 ret; + + ret = -1; + while (len = (src[0] | (src[1] << 8))) { + cur_id = src[4] | (src[5] << 8); + if (cur_id == id) { + ret = func_80017108(src + 6, dst); + break; + } + src += len + 6; + } + return ret; +} +#endif + +void func_80015CA0(GzHeader* src, s32* dst) { + s32 i; + s32* var_s1; + u32 len; + s32 unk4; + + unk4 = src->unk4; + len = src->len; + func_80017108(src + 1, dst); + var_s1 = &dst[len >> 2]; + unk4 = (u32)unk4 >> 2; + for (i = 0; i < unk4; i++) { + var_s1[i] = 0; + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015D14); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015D64); + +s32 func_80016320(s32* arg0) { + while (arg0) { + arg0 = (s32*)arg0[-1]; + } + return 0; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80016340); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800166C0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80016808); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800169B8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80016F90); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001708C); + +// gzip inflate +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80017108); + +void func_80017238(u32 arg0, u32* arg1, u8* arg2) { + *arg2 = arg0; + *arg1 = arg0 >> 8; + func_8001AC9C(*arg2, *arg1); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001726C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80017678); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001786C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80017E68); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80017F38); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018028); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018220); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800182FC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018390); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001840C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800184C0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800185A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018630); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018834); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018934); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018A04); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018AB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018B14); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018BB8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018C94); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018D4C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018E18); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018E90); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018ECC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80018FC0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019064); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800190E8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800191A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019254); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019338); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001937C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800193F4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019440); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800194BC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019544); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019608); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001964C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019690); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800197B8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019978); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019D1C); + +void func_80019D74(u8 arg0, u8 arg1) { + if (arg1 == 0xB) { + func_80019E4C(arg0); + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019DA0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019E4C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019E84); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80019F90); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A174); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A1C8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A280); + +// file cut between func_8001A384 to func_8001C0EC + +#ifndef NON_MATCHINGS +// needs BSS import for %gp regs +void func_8001A384(u8 arg0, s32 arg1); +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A384); +#else +extern s8 D_80062FFC = 0; +extern u8 D_80063020 = 0; +void func_8001A384(u8 arg0, s32 arg1) { + func_8001AC9C(arg0, arg1); + if (D_80063020) { + D_80062FFC = 11; + } +} +#endif + +#ifndef NON_MATCHINGS +// needs BSS import for %gp regs +void func_8001A3B8(s32 arg0, s32 arg1, s32 arg2); +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A3B8); +#else +extern s8 D_80062FFC = 0; +extern u8 D_80063020 = 0; +void func_8001A3B8(s32 arg0, s32 arg1, s32 arg2) { + u8 param; + s32 i; + s32 enabled; + s32 bits; + + if (D_80063020 == 0) { + bits = arg2 & 0xFFFFFF; + for (i = 0; i < 0x18; i++) { + enabled = bits & 1; + bits >>= 1; + if (enabled) { + param = i + 0x48; + func_8001BD50(i, param, param); + } + } + + func_8001B834(13); + return; + } + D_80062FFC = 8; +} +#endif + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A440); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A4A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A518); + +void func_8001A780(u8, s32); +void func_8001A874(u8, s32); +void func_8001A5B4(u8 arg0, u8 arg1, s32 arg2) { + u8 temp_s1; + u8 temp_a0; + + temp_s1 = arg1; + temp_a0 = func_8001AC9C(temp_s1, arg2); + switch (arg0) { + case 0: + func_8001A684(temp_s1, arg2); + break; + case 2: + func_8001A780(temp_s1, arg2); + break; + case 4: + func_8001A874(temp_s1, arg2); + break; + case 3: + func_80019D74(temp_a0, temp_s1); + break; + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A684); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A780); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A874); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A980); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001A9CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001AB1C); + +#ifndef NON_MATCHINGS +// matching with GCC 2.6.3 +s32 func_8001AC9C(u8, s32); +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001AC9C); +#else +extern Unk80062F7C* D_80062F7C = NULL; // %gp +extern s32 D_80062F10 = 0; // %gp +extern s32 D_80062FBC = 0; // %gp +extern u8 D_80063020 = 0; // %gp +s32 func_8001AC9C(u8 arg0, s32 arg1) { + s32 i; + s32 found; + u16 temp_a2; + Unk80062F7C* new_var; + + found = 1; + for (i = 3; i >= 0; i--) { + temp_a2 = D_800730CC[arg0].unk4[i]; + if (temp_a2 == 0xFFFF || arg1 < temp_a2 * 100) { + continue; + } + found = i + 2; + break; + } + D_80062FBC = 1; + for (i = 0; i < 4; i++) { + temp_a2 = D_800730CC[arg0].unk4[i]; + if (temp_a2 != 0xFFFF) { + D_80062FBC++; + } + } + if (D_80063020) { + temp_a2 = D_800730CC[arg0].unk4[found - 1]; + if (temp_a2 == 0xFFFF || found == D_80062FBC) { + D_80062F10 = 0; + } else { + D_80062F10 = temp_a2 * 100 - arg1; + } + new_var = D_80062F7C; + new_var->unk0 = found; + new_var->unk1 = *(u8*)&D_80062FBC; + new_var->unk4 = D_80062F10; + } + return found; +} +#endif + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001AE08); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001AEE4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B4A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B570); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B5E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B704); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B834); + +// ------------------------ ?? + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B8A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001B944); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BA54); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BB30); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BC18); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BCE8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BD50); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001BDB0); + +// file cut between func_8001A384 to func_8001C0EC +const u8 D_8001029C[] = { + 0x00, 0x01, 0x02, 0x03, 0x00, 0x02, 0x01, 0x03, 0x02, 0x00, 0x01, 0x03, + 0x01, 0x00, 0x02, 0x03, 0x01, 0x02, 0x00, 0x03, 0x02, 0x01, 0x00, 0x03}; +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C0EC); + +void func_8001C3C4(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C3CC); + +void SetupGamepad(void) { + if (g_bPadsInitialized == 0) { + g_bPadsInitialized = 1; + StartPAD(); + InitPAD(&D_800696AC.padABuffer, 4, &D_800696AC.padBBuffer, 4); + } + D_80062FA0 = 0; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C484); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C498); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C4E8); + +void func_8001C58C(void) { + if (!func_8001F6B4()) { + D_80062D71 = 0; + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C5BC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C788); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C808); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C8D4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C980); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001CB48); + +void func_8001CDA4(void) { + SetPolyFT4(D_80062F24.ft4); + SetShadeTex(D_80062F24.ft4, 1); + D_80062F24.ft4->x0 = 0; + D_80062F24.ft4->y0 = 5; + D_80062F24.ft4->x1 = 0x40; + D_80062F24.ft4->y1 = 5; + D_80062F24.ft4->x2 = 0; + D_80062F24.ft4->y2 = 0x45; + D_80062F24.ft4->x3 = 0x40; + D_80062F24.ft4->y3 = 0x45; + D_80062F24.ft4->u0 = 0; + D_80062F24.ft4->v0 = 0; + D_80062F24.ft4->u1 = 128; + D_80062F24.ft4->v1 = 0; + D_80062F24.ft4->u2 = 0; + D_80062F24.ft4->v2 = 128; + D_80062F24.ft4->u3 = 128; + D_80062F24.ft4->v3 = 128; + D_80062F24.ft4->clut = GetClut(0, 0x1FE); + D_80062F24.ft4->tpage = GetTPage(1, 0, 0x340, 0); + AddPrim(D_80062FC4, D_80062F24.ft4); + D_80062F24.ft4++; +} + +void func_8001CF3C(s16 x, s16 y, s16 w, s16 h, u16 tx, u16 ty, u16 tw, u16 th, + s16 clut, s32 tex) { + SetPolyFT4(D_80062F24.ft4); + SetShadeTex(D_80062F24.ft4, 1); + if (tex << 0x10) { + SetSemiTrans(D_80062F24.ft4, 1); + } + D_80062F24.ft4->x0 = x; + D_80062F24.ft4->y0 = y; + D_80062F24.ft4->x1 = x + w; + D_80062F24.ft4->y1 = y; + D_80062F24.ft4->x2 = x; + D_80062F24.ft4->y2 = y + h; + D_80062F24.ft4->x3 = x + w; + D_80062F24.ft4->y3 = y + h; + D_80062F24.ft4->u0 = tx; + D_80062F24.ft4->v0 = ty; + D_80062F24.ft4->u1 = tx + tw; + D_80062F24.ft4->v1 = ty; + D_80062F24.ft4->u2 = tx; + D_80062F24.ft4->v2 = ty + th; + D_80062F24.ft4->u3 = tx + tw; + D_80062F24.ft4->v3 = ty + th; + D_80062F24.ft4->clut = GetClut(0x100, (s16)clut + 0x1E0); + D_80062F24.ft4->tpage = GetTPage(1, 0, 0x3C0, 0x100); + AddPrim(D_80062FC4, D_80062F24.ft4); + D_80062F24.ft4++; +} + +void func_8001D180(s16 x, s16 y, s16 w, s16 h, u16 tx, u16 ty, u16 tw, u16 th, + s16 clut, s32 tex) { + SetPolyFT4(D_80062F24.ft4); + SetShadeTex(D_80062F24.ft4, 1); + if (tex << 0x10) { + SetSemiTrans(D_80062F24.ft4, 1); + } + D_80062F24.ft4->x0 = x; + D_80062F24.ft4->y0 = y; + D_80062F24.ft4->x1 = x + w; + D_80062F24.ft4->y1 = y; + D_80062F24.ft4->x2 = x; + D_80062F24.ft4->y2 = y + h; + D_80062F24.ft4->x3 = x + w; + D_80062F24.ft4->y3 = y + h; + D_80062F24.ft4->u0 = tx; + D_80062F24.ft4->v0 = ty; + D_80062F24.ft4->u1 = tx + tw; + D_80062F24.ft4->v1 = ty; + D_80062F24.ft4->u2 = tx; + D_80062F24.ft4->v2 = ty + th; + D_80062F24.ft4->u3 = tx + tw; + D_80062F24.ft4->v3 = ty + th; + D_80062F24.ft4->clut = GetClut(0x180, (s16)clut); + D_80062F24.ft4->tpage = GetTPage(1, 0, 0x340, 0x100); + AddPrim(D_80062FC4, D_80062F24.ft4); + D_80062F24.ft4++; +} + +void func_8001D3C0(s16 x, s16 y) { + SetTile1(D_80062F24.tile1); + D_80062F24.tile1->x0 = x; + D_80062F24.tile1->y0 = y; + D_80062F24.tile1->r0 = 0xFF; + D_80062F24.tile1->g0 = 0xFF; + D_80062F24.tile1->b0 = 0; + AddPrim(D_80062FC4, D_80062F24.tile1); + D_80062F24.tile1++; +} + +void func_8001D47C(s16 x0, s16 x1, s16 y, s32 color) { + SetLineF2(D_80062F24.linef2); + D_80062F24.linef2->r0 = color >> 16; + D_80062F24.linef2->g0 = color >> 8; + D_80062F24.linef2->b0 = color; + D_80062F24.linef2->x0 = x0; + D_80062F24.linef2->y0 = y; + D_80062F24.linef2->x1 = x1; + D_80062F24.linef2->y1 = y; + AddPrim(D_80062FC4, D_80062F24.linef2); + D_80062F24.linef2++; +} + +void func_8001D56C(s16 x0, s16 y0, s16 x1, s16 y1, s16 is_yellow) { + if (is_yellow) { + SetLineF2(D_80062F24.linef2); + D_80062F24.linef2->r0 = 0xFF; + D_80062F24.linef2->g0 = 0xFF; + D_80062F24.linef2->b0 = 0; + } else { + SetLineF2(D_80062F24.linef2); + D_80062F24.linef2->r0 = 0x80; + D_80062F24.linef2->g0 = 0x80; + D_80062F24.linef2->b0 = 0x80; + } + D_80062F24.linef2->x0 = x0; + D_80062F24.linef2->y0 = y0; + D_80062F24.linef2->x1 = x1; + D_80062F24.linef2->y1 = y1; + AddPrim(D_80062FC4, D_80062F24.linef2); + D_80062F24.linef2++; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001D6A8); + +void func_8001DE0C(Unk8001DE0C* arg0, s16 arg1, s16 arg2, s16 arg3, s32 arg4) { + arg0->unk0 = arg1; + arg0->unk2 = arg2; + arg0->unk4 = arg3; + arg0->unk6 = arg4; +} + +// translate window dialog +void func_8001DE24(Unk8001DE0C* arg0, s32 arg1, s32 arg2) { + arg0->unk0 = arg0->unk0 + arg1; + arg0->unk2 = arg0->unk2 + arg2; +} + +// set window dialog rect +void func_8001DE40(Unk8001DE0C* arg0, Unk8001DE0C* arg1) { + arg0->unk0 = arg1->unk0; + arg0->unk2 = arg1->unk2; + arg0->unk4 = arg1->unk4; + arg0->unk6 = arg1->unk6; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001DE70); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001DEB0); + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001DEF0); +#else +// only matches with --aspsx-version=2.21 +// sets the menu color with a quadruplet of RGB values +void func_8001DEF0(u8* menu_colors) { + s32 i; + for (i = 0; i < 12; i++) { + D_80049208[i] = *menu_colors++; + } +} +#endif + +void func_8001DF24(RECT* rect, u8 arg1, u8 arg2, u8 arg3) { + setTile(D_80062F24.tile); + SetShadeTex(D_80062F24.tile, 1); + D_80062F24.tile->x0 = rect->x; + D_80062F24.tile->y0 = rect->y; + D_80062F24.tile->w = rect->w; + D_80062F24.tile->h = rect->h; + D_80062F24.tile->r0 = arg1; + D_80062F24.tile->g0 = arg2; + D_80062F24.tile->b0 = arg3; + AddPrim(D_80062FC4, D_80062F24.tile++); +} + +// prints menu window +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001E040); + +// print menu cursor +void func_8001EB2C(s16 x, s16 y) { + RECT rect; + + setSprt(D_80062F24.sprt); + SetSemiTrans(D_80062F24.sprt, 1); + SetShadeTex(D_80062F24.sprt, 1); + D_80062F24.sprt->x0 = x; + D_80062F24.sprt->y0 = y; + D_80062F24.sprt->u0 = 224; + D_80062F24.sprt->v0 = 8; + D_80062F24.sprt->w = 24; + D_80062F24.sprt->h = 16; + D_80062F24.sprt->clut = GetClut(0x100, 0x1E1); + AddPrim(D_80062FC4, D_80062F24.sprt++); + rect.x = 0; + rect.y = 0; + rect.w = 0xFF; + rect.h = 0xFF; + func_80026A34(0, 1, (u16)GetTPage(0, 2, 0x3C0, 0x100), &rect); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001EC70); + +void func_8001EF84(s32 x, s32 y, s32 n, s32 len) { + RECT rect; + s32 i; + s32 uv; + + for (i = 0; i < 8; i++) { + uv = n / D_80049224[i]; + setSprt(D_80062F24.sprt); + SetShadeTex(D_80062F24.sprt, 1); + D_80062F24.sprt->x0 = x; + D_80062F24.sprt->y0 = y; + D_80062F24.sprt->u0 = (uv % 5) * 16 - 80; + D_80062F24.sprt->v0 = uv >= 5 ? 104 : 80; + D_80062F24.sprt->w = 16; + D_80062F24.sprt->h = 21; + D_80062F24.sprt->clut = GetClut(0x100, 0x1EC); + if (len >= 8 - i) { + x += 16; + AddPrim(D_80062FC4, D_80062F24.sprt++); + } + n %= D_80049224[i]; + } + rect.x = 0; + rect.y = 0; + rect.w = 255; + rect.h = 255; + func_80026A34(0, 1, (u16)GetTPage(0, 1, 0x3C0, 0x100), &rect); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001F1BC); + +void func_8001F6AC(void) {} + +u8 func_8001F6B4(void) { return D_80062DDB; } + +void func_8001F6C0(s32 arg0, s8 arg1) { + D_80062DDB = 1; + D_80062DDC = arg1; + D_80062DE0 = 0x28; + D_80062EB8 = arg0; + D_80062DE5 = 1; +} + +void func_8001F6E4(s16 arg0, s16 arg1, s16 arg2) { + D_80062DE4 = arg0; + if (arg0) { + D_80062DE6 = arg1; + D_80062DE8 = arg2; + } else { + D_80062DDB = 0; + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001F710); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FA28); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FA68); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FAAC); + +void func_8001FAF0(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FAF8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FBAC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FCDC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FE6C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FF50); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FF8C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FFD4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8002001C); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80020058); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800206E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80020B68); + +void func_80021044(DRAWENV* draw_env, DISPENV* disp_env) { + VSync(0); + SetDefDrawEnv(draw_env, 0, 0, 0x180, 0x1D8); + draw_env[0].dfe = 1; + draw_env[0].isbg = 1; + PutDrawEnv(draw_env); + VSync(0); + SetDefDrawEnv(draw_env, 0, 8, 0x180, 0xE0); + SetDefDrawEnv(&draw_env[1], 0, 0xF0, 0x180, 0xE0); + SetDefDispEnv(&disp_env[0], 0, 0xE8, 0x16C, 0xF0); + SetDefDispEnv(&disp_env[1], 0, 0, 0x16C, 0xF0); + draw_env[1].isbg = 1; + draw_env[0].isbg = 1; + draw_env[1].dfe = 1; + draw_env[0].dfe = 1; + draw_env[1].dtd = 1; + draw_env[0].dtd = 1; + draw_env[0].r0 = 0; + draw_env[0].g0 = 0; + draw_env[0].b0 = 0; + draw_env[1].r0 = 0; + draw_env[1].g0 = 0; + draw_env[1].b0 = 0; + draw_env[0].tpage = draw_env[1].tpage = + GetGraphType() != 1 && GetGraphType() != 2 ? 0x3F : 0xAF; + VSync(0); + PutDispEnv(disp_env); + PutDrawEnv(draw_env); + SetDispMask(1); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800211B8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800211C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8002120C); + +void func_80021258(s32 arg0) { func_80015248(13, arg0, 8); } + +void func_80021280(s32 arg0) { func_80015248(4, arg0, 8); } + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800212A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80021BAC); + +INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80021C4C); diff --git a/src/main/akao.c b/src/main/akao.c new file mode 100644 index 0000000..e2d2122 --- /dev/null +++ b/src/main/akao.c @@ -0,0 +1,892 @@ +//! PSYQ=3.3 CC1=2.6.3 + +#include "common.h" +#include "psxsdk/libspu.h" + +typedef struct { + s32 unk0; + s8 unk4; +} Unk8002C5A8; + +typedef struct { + u8* addr; + u8* loop_addr[4]; + u8* drum_addr; + u8 pad1[0xC]; + u32 overlay_voice; + s32 unk28; + s32 unk2C; + s32 unk30; + s32 unk34; + s32 unk38; + s8 unk3C[0x24]; + s16 unk60; + s16 unk62; + s16 unk64; + u16 unk66; + u32 unk68; + s16 unk6C; + s16 unk6E; + u8 unk70[0x20]; + s16 unk90; + s16 unk92; + s16 unk94; + s16 unk96; + s16 unk98; + s16 unk9A; + s16 unk9C; + s16 unk9E; + s16 unkA0; + s16 unkA2; + s16 unkA4; + s16 unkA6; + s16 unkA8; + s16 unkAA; + s16 unkAC; + s16 unkAE; + u8 unkB0[0x10]; + u8 unkC0[0x2]; + u16 unkC2; + u16 unkC4; + u8 unkC6[0x4]; + u16 unkCA; + s16 unkCC; + s16 unkCE; + s32 unkD0; + s16 unkD4; + s16 unkD6; + s16 unkD8; + s16 unkDA; + s32 unkDC; + s32 unkE0; +} AKAO_TRACK; + +typedef struct { + u8 unk0[0x48]; + u16 tempo_slide_length; + u16 song_id; + u16 last_condition; + u16 condition; + u16 reverb_depth_slide_length; + u16 noise_clock; + u16 field_54; + u16 beats_per_measure; + u16 beat; + u16 ticks_per_beat; + u16 tick; + u16 measure; +} AKAO_CONFIG; + +typedef struct { + /* 0x0 */ u8 unk0; + /* 0x1 */ u8 unk1; + /* 0x2 */ s16 unk2; + /* 0x4 */ s32 unk4; + /* 0x8 */ s32 unk8; + /* 0xC */ u16 unkC; + /* 0xE */ u16 unkE; + /* 0x10 */ s32 unk10; + /* 0x14 */ s32 unk14; + /* 0x18 */ s32 unk18; + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; +} Unk8002B7E0; // size:0x24 + +extern void (*D_80049548[])(Unk8002B7E0*); +extern u8 D_800499A8[]; // opcode lenghts +extern s16 D_80062F40; +extern s16 D_80062F48; +extern s32 D_80062F8C; +extern s32 D_80062FE4; +extern s32 D_80062FE8; +extern s32 D_80063010; // sound message queue count +extern s32 D_8007EC10; +extern s32 D_800804D0; +extern Unk8002B7E0 D_80081DC8[]; // sound messages queue +extern s32 D_80083334; +extern u16 D_8008337E; +extern s32 D_80083394; +extern u16 D_800833DE; +extern s32 D_80096608; +extern s32 D_80099788; +extern s32 D_80099998; +extern u16 D_8009A14E; +extern u8 D_80099BA8[]; +extern s32 D_80099DB8; +extern s32 D_8009A104; + +extern u32 g_ReverbMode; +extern SpuReverbAttr g_ReverbAttr; + +#define READ_S8(addr) ((s8)(*(addr)++)) +#define READ_S16(addr) ((s16)(*(addr)++ | (*(addr)++ << 8))) + +void func_8002CF98(Unk8002B7E0* arg0); +void func_8002B1F8(Unk8002B7E0* arg0); +void func_8002B2F8(Unk8002B7E0* arg0); +void func_8002B3B4(Unk8002B7E0* arg0); +void func_8002B5A8(Unk8002B7E0* arg0); +void func_8002B608(Unk8002B7E0* arg0); +void func_8002B904(Unk8002B7E0* arg0); +void func_8002B6AC(Unk8002B7E0* arg0); +void func_8002B730(Unk8002B7E0* arg0); +void func_8002B7E0(Unk8002B7E0* arg0); +void func_8002B958(Unk8002B7E0* arg0); +void func_8002B9AC(Unk8002B7E0* arg0); +void func_8002BA08(Unk8002B7E0* arg0); +void func_8002B8B4(Unk8002B7E0* arg0); +void func_8002B668(Unk8002B7E0* arg0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800293D0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800293F4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029424); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029464); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800294A4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800294BC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800297A4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029818); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002988C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029998); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800299C8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029A50); + +void SetReverbMode(s32 in_ReverbMode) { + func_80029A50(); + SpuGetReverbModeParam(&g_ReverbAttr); + if (g_ReverbAttr.mode != in_ReverbMode) { + g_ReverbMode = in_ReverbMode; + SpuSetReverb(SPU_OFF); + g_ReverbAttr.mode = in_ReverbMode | SPU_REV_MODE_CLEAR_WA; + g_ReverbAttr.mask = SPU_REV_MODE; + SpuSetReverbModeParam(&g_ReverbAttr); + SpuSetReverb(SPU_ON); + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029B78); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029BAC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029C48); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029E98); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80029F44); + +void func_8002A094(u16 arg0, s32 arg1, s32 arg2, s32 arg3); +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A094); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A28C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A43C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A510); + +void func_8002A6C4(s32* arg0, s32* arg1, u16 arg2); +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A6C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A748); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A798); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A7E8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002A958); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002AABC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002AFB8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002B1A8); + +void func_8002B1F8(Unk8002B7E0* arg0) { + func_80029B78(arg0->unk4, arg0->unk8); + if (D_8009A14E == 0xE) { + func_8002A7E8(); + func_8002B1A8(&D_80096608, &D_800804D0, &D_8009A104, &D_80083394); + } + func_80029E98(); + if (D_8008337E && D_8008337E == arg0->unkC) { + func_8002AABC(0); + } else if (D_800833DE && D_800833DE == arg0->unkC) { + func_8002AABC(1); + } else { + func_80029C48(); + } + D_8009A14E = arg0->unkC; +} + +void func_8002B2F8(Unk8002B7E0* arg0) { + s32* var_a2; + + func_80029B78(arg0->unk4, arg0->unk8); + func_8002A7E8(); + var_a2 = &D_8009A104; + if (D_8009A14E) { + if (D_8009A14E == 0xE) { + func_8002B1A8(&D_80096608, &D_800804D0, var_a2, &D_80083394); + } else { + func_8002B1A8(&D_80096608, &D_8007EC10, var_a2, &D_80083334); + } + } + func_80029E98(); + func_80029C48(); + D_8009A14E = arg0->unkC; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002B3B4); + +extern u16 D_80062FC8; + +void func_8002B5A8(Unk8002B7E0* arg0) { + if (D_8009A14E) { + D_80062FC8 = arg0->unk10 ? arg0->unk10 : 0x10; + func_8002AFB8(); + } + func_8002B1F8(arg0); +} + +void func_8002B608(Unk8002B7E0* arg0) { + if (D_8009A14E) { + D_80062FC8 = arg0->unk10 ? arg0->unk10 : 0x10; + func_8002AFB8(); + } + func_8002B2F8(arg0); +} + +void func_8002B668(Unk8002B7E0* arg0) { + func_8002A510(4, 1); + func_8002A094(0x40, 0x34, arg0->unk4, arg0->unk8); +} + +void func_8002B6AC(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(4, 2); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x32, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unkC); + func_8002A094(arg0->unk4, 0x34, sp10, sp14); +} + +void func_8002B730(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(4, 3); + func_80029A50(); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x30, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unkC); + func_8002A094(arg0->unk4, 0x32, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unk10); + func_8002A094(arg0->unk4, 0x34, sp10, sp14); +} + +void func_8002B7E0(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(6, 4); + func_80029A50(); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x30, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unkC); + func_8002A094(arg0->unk4, 0x32, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unk10); + func_8002A094(arg0->unk4, 0x34, sp10, sp14); + func_8002A6C4(&sp10, &sp14, arg0->unk14); + func_8002A094(arg0->unk4, 0x36, sp10, sp14); +} + +void func_8002B8B4(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(6, 1); + func_8002A6C4(&sp10, &sp14, arg0->unk4); + func_8002A28C(sp10, sp14); +} + +void func_8002B904(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(4, 1); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x34, sp10, sp14); +} + +void func_8002B958(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(2, 1); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x32, sp10, sp14); +} + +void func_8002B9AC(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(0, 1); + func_80029A50(); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x30, sp10, sp14); +} + +void func_8002BA08(Unk8002B7E0* arg0) { + s32 sp10, sp14; + + func_8002A510(6, 1); + func_8002A6C4(&sp10, &sp14, arg0->unk8); + func_8002A094(arg0->unk4, 0x36, sp10, sp14); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BA5C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BA98); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BB20); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BBB4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BBEC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BC58); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BCCC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BD04); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BDCC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BE2C); + +void func_8002BE8C(s32 arg0) { func_8002BCCC(arg0, D_80099BA8); } + +void func_8002BEB4(s32 arg0) { func_8002BD04(arg0, D_80099BA8); } + +void func_8002BEDC(s32 arg0) { func_8002BCCC(arg0, &D_80099998); } + +void func_8002BF04(s32 arg0) { func_8002BD04(arg0, &D_80099998); } + +void func_8002BF2C(s32 arg0) { func_8002BCCC(arg0, &D_80099788); } + +void func_8002BF54(s32 arg0) { func_8002BD04(arg0, &D_80099788); } + +void func_8002BF7C(s32 arg0) { func_8002BCCC(arg0, &D_80099DB8); } + +void func_8002BFA4(s32 arg0) { func_8002BD04(arg0, &D_80099DB8); } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002BFCC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C004); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C0CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C12C); + +void func_8002C18C(s32 arg0) { func_8002BFCC(arg0, D_80099BA8); } + +void func_8002C1B4(s32 arg0) { func_8002C004(arg0, D_80099BA8); } + +void func_8002C1DC(s32 arg0) { func_8002BFCC(arg0, &D_80099998); } + +void func_8002C204(s32 arg0) { func_8002C004(arg0, &D_80099998); } + +void func_8002C22C(s32 arg0) { func_8002BFCC(arg0, &D_80099788); } + +void func_8002C254(s32 arg0) { func_8002C004(arg0, &D_80099788); } + +void func_8002C27C(s32 arg0) { func_8002BFCC(arg0, &D_80099DB8); } + +void func_8002C2A4(s32 arg0) { func_8002C004(arg0, &D_80099DB8); } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C2CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C300); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C3A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C408); + +void func_8002C468(s32 arg0) { func_8002C2CC(arg0, D_80099BA8); } + +void func_8002C490(s32 arg0) { func_8002C300(arg0, D_80099BA8); } + +void func_8002C4B8(s32 arg0) { func_8002C2CC(arg0, &D_80099998); } + +void func_8002C4E0(s32 arg0) { func_8002C300(arg0, &D_80099998); } + +void func_8002C508(s32 arg0) { func_8002C2CC(arg0, &D_80099788); } + +void func_8002C530(s32 arg0) { func_8002C300(arg0, &D_80099788); } + +void func_8002C558(s32 arg0) { func_8002C2CC(arg0, &D_80099DB8); } + +void func_8002C580(s32 arg0) { func_8002C300(arg0, &D_80099DB8); } + +void func_8002C5A8(Unk8002C5A8* arg0) { + s32 n = arg0->unk4; + D_80062F48 = 0; + D_80062FE8 = n << 0x10; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C5C8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C634); + +void func_8002C6A8(Unk8002C5A8* arg0) { + s32 n = arg0->unk4; + D_80062F40 = 0; + D_80062FE4 = n << 0x10; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C6C8); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C734); + +void func_8002C7A8(void) { func_80029F44(); } + +void func_8002C7C8(void) { func_8002A43C(); } + +void func_8002C7E8(void) { + D_8009A104 = 1; + func_8002A748(); + func_8002A798(); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C81C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C850); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C884); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C8C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C8DC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002C9E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CA84); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CB78); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CC18); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CC44); + +void func_8002CCBC(void) { D_8008337E = 0; } + +void func_8002CCCC(void) { D_800833DE = 0; } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CCDC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CDD0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CEC0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CF1C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CF78); + +void func_8002CF98(Unk8002B7E0* arg0) {} + +void func_8002CFA0() { SpuSetTransferCallback(0); } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002CFC0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D1E4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D2D4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D410); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D4A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D530); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D668); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D7A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002D8E8); + +void func_8002DA30(Unk8002B7E0** out_msg) { + *out_msg = D_80081DC8; + *out_msg = &D_80081DC8[D_80063010]; + D_80063010++; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002DA7C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002DF88); + +void func_8002E1A8(void) { + Unk8002B7E0* msg; + + if (D_80062F8C == 0) { + for (msg = D_80081DC8; D_80063010; D_80063010--, msg++) { + D_80049548[msg->unk0](msg); + } + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002E23C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002E428); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002E478); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002E954); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002ED34); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002F24C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002F738); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002F848); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002FDA0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002FE48); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002FF4C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80030038); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80030148); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80030234); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80030380); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800308D4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80030E7C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031820); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800318BC); + +u8 func_80031A70(u8** arg0) { + u8 expected; + u8 len; + u8 opcode; + u8* data; + + data = *arg0; + expected = 0xCA; + do { + opcode = *data; + len = D_800499A8[opcode]; + data += len; + } while (len); + return opcode == expected ? 0xCA : 0xA0; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031AB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031AFC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031BA0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031BE4); + +void func_80031C88(AKAO_TRACK* track) { + track->unk2C = *track->addr++; + track->unkE0 |= 3; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031CB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031CE0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031D6C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031E98); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031EEC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80031F30); + +void func_80031FC0(AKAO_TRACK* track) { + track->unk60 = *track->addr++ << 8; + track->unk62 = 0; + track->unkE0 |= 3; +} + +void func_80031FF0(AKAO_TRACK* track) { + u8 ch; + u16 var_a0; + + track->unk62 = *track->addr++; + if (track->unk62 == 0) { + track->unk62 = 0x100; + } + ch = *track->addr++; + track->unk60 &= 0xFF00; + var_a0 = track->unk60; + track->unkCA = ((ch << 8) - var_a0) / (u16)track->unk62; +} + +void func_80032078(AKAO_TRACK* track) { track->unk66 = *track->addr++; } + +void func_80032094(AKAO_TRACK* track) { + track->unk66 = (track->unk66 + 1) & 0xF; +} + +void func_800320AC(AKAO_TRACK* track) { + track->unk66 = (track->unk66 + 0xFFFF) & 0xF; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800320C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032274); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800323CC); + +void func_800324D8(AKAO_TRACK* track) { track->unkCC = (s8)*track->addr++; } + +void func_80032500(AKAO_TRACK* track) { + track->unkCC = (s8)*track->addr++ + track->unkCC; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8003252C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8003257C); + +void func_800325B8(AKAO_TRACK* track) { track->unk6C = 0; } + +void func_800325C0(AKAO_TRACK* track) { track->unkCE = (s8)*track->addr++; } + +void func_800325E8(AKAO_TRACK* track) { + track->unkCE = (s8)*track->addr++ + track->unkCE; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032614); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032718); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032770); + +void func_800327E0(AKAO_TRACK* track) { + track->unkD6 = 0; + track->unk38 &= ~1; + track->unkE0 |= 0x10; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032804); + +void func_800328D4(AKAO_TRACK* track) { track->unk90 = *track->addr++ << 8; } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800328F8); + +void func_80032968(AKAO_TRACK* track) { + track->unkD8 = 0; + track->unk38 &= ~2; + track->unkE0 |= 3; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8003298C); + +void func_80032A04(AKAO_TRACK* track) { track->unk9E = *track->addr++ << 7; } + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032A28); + +void func_80032A98(AKAO_TRACK* track) { + track->unkDA = 0; + track->unk38 &= ~4; + track->unkE0 |= 3; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032ABC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032B30); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032BB4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032C20); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032C8C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032CE8); + +void func_80032D44(AKAO_TRACK* track) { track->unk6E = 1; } + +void func_80032D50(void) {} + +void func_80032D58(AKAO_TRACK* track) { track->unk6E = 4; } + +void func_80032D64(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032D6C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032E08); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032E6C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032ED0); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032F34); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032F98); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80032FFC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033060); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800330C4); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033128); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800331CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033224); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033264); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800332EC); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8003337C); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033420); + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8003345C); + +void func_80033488(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + short delta = READ_S8(track->addr); + if (delta != 0) { + delta += track->unkC2; + if (delta < 1) { + delta = 1; + } else if (delta > 255) { + delta = 255; + } + } + track->unkC4 = delta; +} + +void func_800334EC(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->drum_addr = track->addr + READ_S16(track->addr); + track->unk38 |= 0x8; +} + +void func_80033534(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 &= ~0x8; +} + +void func_80033548(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + config->ticks_per_beat = *track->addr++; + config->beats_per_measure = *track->addr++; + config->tick = 0; + config->beat = 0; +} + +void func_80033588(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + config->measure = *track->addr++; + config->measure |= *track->addr++ << 8; +} + +void func_800335CC(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + config->field_54 = 1; +} + +void func_800335D8(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + func_80032E6C(track, config, mask); + func_80032ED0(track, config, mask); +} + +void func_80033628(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + int delay = *track->addr++; + if (delay == 0) { + track->unkA4 = 257; + } else { + track->unkA4 = delay + 1; + } + func_80032ABC(track, config, mask); +} + +void func_8003366C(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + s16 var_v0 = *track->addr++; + if (var_v0 == 0) { + var_v0 = 257; + } else { + var_v0++; + } + track->unkA4 = var_v0; +} + +void func_80033698(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + int delay = *track->addr++; + if (delay == 0) { + track->unkA6 = 257; + } else { + track->unkA6 = delay + 1; + } + func_80032BB4(track, config, mask); +} + +void func_800336DC(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + s16 var_v0 = *track->addr++; + if (var_v0 == 0) { + var_v0 = 257; + } else { + var_v0++; + } + track->unkA6 = var_v0; +} + +void func_80033708(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 &= ~0x37; + func_80032B30(track, config, mask); + func_80032C20(track, config, mask); + func_80032CE8(track, config, mask); + track->unk6E &= ~0x5; +} + +void func_80033788(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 |= 0x10; +} + +void func_8003379C(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 &= ~0x10; +} + +void func_800337B0(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 |= 0x20; +} + +void func_800337C4(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->unk38 &= ~0x20; +} + +void func_800337D8(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + track->addr += READ_S16(track->addr); +} + +void func_80033818(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + int cond = *track->addr++; + if (config->condition != 0 && cond <= config->condition) { + track->addr += READ_S16(track->addr); + config->last_condition = cond; + } else { + track->addr += 2; + } +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033894); + +void func_80033A70(AKAO_TRACK* track, AKAO_CONFIG* config, u32 mask) { + func_80033894(track, config, mask); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_80033A90); diff --git a/src/main/main_private.h b/src/main/main_private.h new file mode 100644 index 0000000..7270d37 --- /dev/null +++ b/src/main/main_private.h @@ -0,0 +1,118 @@ +#include + +typedef enum { + KERNEL_COMMAND, + KERNEL_ATTACK, + KERNEL_GROWTH, + KERNEL_INIT, + KERNEL_ITEM, + KERNEL_WEAPON, + KERNEL_ARMOR, + KERNEL_ACCESSORY, + KERNEL_MATERIA, + KERNEL_DESC_COMMAND, + KERNEL_DESC_MAGIC, + KERNEL_DESC_ITEM, + KERNEL_DESC_WEAPON, + KERNEL_DESC_ARMOR, + KERNEL_DESC_ACCESSORY, + KERNEL_DESC_MATERIA, + KERNEL_DESC_KEY_ITEM, + KERNEL_NAME_COMMAND, + KERNEL_NAME_MAGIC, + KERNEL_NAME_ITEM, + KERNEL_NAME_WEAPON, + KERNEL_NAME_ARMOR, + KERNEL_NAME_ACCESSORY, + KERNEL_NAME_MATERIA, + KERNEL_NAME_KEY_ITEM, + KERNEL_TEXT_BATTLE, + KERNEL_NAME_SUMMON, +} KernelID; + +typedef enum { + SUBSYSTEM_FIELD = 1, + SUBSYSTEM_BATTLE = 2, + SUBSYSTEM_WORLD = 3, // also used for snowfield + SUBSYSTEM_UNK = 4, // similar to battle? + SUBSYSTEM_MENU = 5, + SUBSYSTEM_BIKE = 6, + SUBSYSTEM_RACE = 7, + SUBSYSTEM_SNOWBOARD = 8, + SUBSYSTEM_FORTCONDOR = 9, + SUBSYSTEM_SUBMARIME = 10, + SUBSYSTEM_SHOOTING = 11, + SUBSYSTEM_CHANGE_DISK, + SUBSYSTEM_SNOWBOARD_GOLDSAURCER = 14, +} Subsystem; + +typedef struct { + s32 len; // decompressed length + s32 unk4; +} GzHeader; + +typedef struct { + u16 unk0; + u16 unk2; + u16 unk4; + u16 unk6; +} Unk8001DE0C; + +typedef struct { + u8 padABuffer; + u8 unk1; + u8 unk2; + u8 unk3[31]; + u8 padBBuffer; + u8 unk23; + u8 unk24; + u8 unk25[31]; +} Unk800696AC; + +typedef struct { + s32 sector_off; + s32 length; +} PortraitEntry; + +extern s32 D_80010100[]; +extern s32 D_80048CFC; +extern s32 D_80048D00; +extern s32 D_80048D04; +extern s32 D_80048D08; +extern s32 D_80048D0C; +extern s32 D_80048D10; +extern s32 D_80048D14; +extern s32 D_80048D18; +extern s32 D_80048D1C; +extern s32 D_80048D20; +extern Yamada D_80048D84[]; +extern s32 D_80048DD4[]; +extern PortraitEntry D_80048FE8[15]; +extern u8 D_80049208[12]; // menu color RGB-quadruplet +extern s32 D_80049224[8]; +extern u8 D_80049520[]; +extern u8 D_80049528[]; +extern u8 D_80063690[]; +extern Unk800696AC D_800696AC; +extern u32 D_80062FA0; // Some sort of pad state +extern u16 D_80069490[]; +extern u16 D_800707BC; +extern u16 D_800707BE; +extern u8 D_800708D4[]; +extern u8 D_800716D0; +extern s32 D_80071744; // LBA loc for func_80014540 +extern s16 D_80071A5C; +extern s32 D_80071C24[]; // accessory data? +extern s32 D_80071E44[]; // armor data? +extern u_long* D_800722C8; // LBA dst for func_80014540 +extern u8 D_800722DC[]; +extern u8 D_800730DC[][0x14]; +extern s32 D_80095DD8; // LBA len for func_80014540 +extern s16 D_800965E8; +extern u16 D_8009C560; // refer to Subsystem enum +extern SavePartyMember D_8009C738[8]; +extern u16 D_8009ABF6; +extern u16 D_8009AC32; +extern u8 D_8009D5E9; +extern void (*D_800A00CC)(void); // battle/brom entrypoint +extern void (*D_800A1158)(void); // battle/battle entrypoint diff --git a/src/main/ovl.c b/src/main/ovl.c new file mode 100644 index 0000000..252abda --- /dev/null +++ b/src/main/ovl.c @@ -0,0 +1,28 @@ +#include + +void func_8002368C(); +void func_801D0000(); +void func_801D069C(); +void func_801D05C0(); +void* D_800493A8[] = { + func_8002368C, (void*)0x801D0BA0, (void*)0x801D0164, (void*)0x801D3CB0, + (void*)0x801D0574, (void*)0x801D0040, func_801D0000, (void*)0x801D006C, + func_801D069C, (void*)0x801D0C1C, func_801D05C0, (void*)0x801D0198, + func_801D0000, (void*)0x801D006C, (void*)0x801D0BA0, (void*)0x801D0574, + (void*)0x801D0BA0, (void*)0x801D0BA0, (void*)0x801D0BA0, (void*)0x801D0BA0, + (void*)0x801D0BA0, +}; + +void func_80023AD4(); +void func_801D00C4(); +void func_801D080C(); +void func_801D06B0(); +void func_801D00C4(); +void* D_800493FC[] = { + func_80023AD4, (void*)0x801D0E80, (void*)0x801D0490, (void*)0x801D6C2C, + (void*)0x801D0BD0, (void*)0x801D167C, func_801D00C4, (void*)0x801D042C, + func_801D080C, (void*)0x801D0E94, func_801D06B0, (void*)0x801D0250, + func_801D00C4, (void*)0x801D0E80, (void*)0x801D0E80, (void*)0x801D0BD0, + (void*)0x801D0E80, (void*)0x801D0E80, (void*)0x801D0E80, (void*)0x801D0E80, + (void*)0x801D0E80, +}; diff --git a/src/main/psxsdk.c b/src/main/psxsdk.c new file mode 100644 index 0000000..bbcf448 --- /dev/null +++ b/src/main/psxsdk.c @@ -0,0 +1,1178 @@ +//! PSYQ=3.3 +#include +#include +#include + +typedef enum { + CDOP_0, + CDOP_1, + CDOP_3 = 3, + CDOP_11 = 11, + CDOP_19 = 0x13, + CDOP_20 = 0x14, +} CdOp; + +extern void (*D_8004A634[21])(void); +extern int D_800698E8; // sector_no +extern int D_800698F0; +extern int D_8006E0F0; +extern int D_8006E0F4; +extern CdOp D_80071A60; // some kind of operation? +extern int D_80071A64; // +extern CdlLOC D_80071A68; // cd sector +extern size_t D_80071A6C; // amount of sectors to read +extern u_long* D_80071A80; // read content destination +extern void (*D_80071A84)(); // callback +void func_80033B70(void) { + while (!CdInit()) { + } + D_80071A60 = CDOP_0; + func_8003DDA4(0); + func_80034F3C(); + CdControlB(CdlSetmode, (u8*)0x80, NULL); + VSync(3); + D_80071A64 = func_80034350(); + func_80034F5C(); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80033BE0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80033C20); + +void func_80033CB8(int op, int sector, size_t len, u_long* dst, void (*cb)()); +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80033CB8); + +int func_80033DAC(int sector_no, void (*cb)()) { + func_80033CB8(CDOP_1, sector_no, 0, NULL, cb); + return 0; +} + +int func_80033DE4(int sector_no) { + func_80033CB8(CDOP_0, sector_no, 0, NULL, NULL); + do { + + } while (CdControl(CdlSetloc, (u_char*)&D_80071A68, NULL) == 0); + return 0; +} + +int func_80033E34(int sector_no, size_t size, u_long* dst, void (*cb)()) { + func_80033CB8(CDOP_3, sector_no, size, dst, cb); + return 0; +} + +int DS_read(int sector_no, size_t size, u_long* dst, void (*cb)()) { + func_80033CB8(CDOP_11, sector_no, size, dst, cb); + D_800698E8 = sector_no; + func_80034D2C(&D_800698F0, dst); + return 0; +} + +int func_80033EDC(int sector_no, void (*cb)()) { + while (func_80033DAC(sector_no, cb)) { + } + while (func_80034B44()) { + VSync(0); + } + return 0; +} + +int func_80033F40(int sector_no, size_t size, u_long* dst, void (*cb)()) { + while (func_80033E34(sector_no, size, dst, cb)) { + } + while (func_80034B44()) { + VSync(0); + } + return 0; +} + +int func_80033FC4(int sector_no, size_t size, u_long* dst, void (*cb)()) { + while (DS_read(sector_no, size, dst, cb)) { + } + while (func_80034B44()) { + VSync(0); + } + return 0; +} + +void func_80034048(void) { + D_80071A6C = 0; + D_80071A80 = NULL; + D_80071A84 = NULL; + D_80071A60 = CDOP_19; + func_80034B44(); +} + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003408C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034104); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034150); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034350); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800343F0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034410); + +void func_80034420(void) {} + +void func_80034428(void) {} + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034430); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034444); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003447C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800344C0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800345BC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034600); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800346F8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034754); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800347B4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800347F8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800348F4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034974); + +void func_80034A58(void) { + CdControlF(CdlPause, NULL); + D_80071A60 = CDOP_20; + D_8006E0F4 = 0; +} + +void func_80034A90(void) { + s32 temp_v0; + s32* var_a1; + + switch (func_8003DE2C(1, 0)) { + case 2: + func_80034444(); + return; + case 5: + D_80071A60 = CDOP_19; + return; + default: + temp_v0 = VSync(-1); + var_a1 = &D_8006E0F0; + if (*var_a1 != temp_v0) { + *var_a1 = temp_v0; + D_8006E0F4++; + if (D_8006E0F4 == 3600) { + D_80071A60 = CDOP_19; + func_80034CAC(3); + } + } + return; + } +} + +u32 func_80034B44(void) { + u32* op; + if (D_80071A60 >= LEN(D_8004A634)) { + while (1) { + } + } + op = &D_80071A60; + D_8004A634[*op](); + return *op; +} + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034BB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034CAC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ChangeClearSIO); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034D18); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034D2C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034D5C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034DB0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034E00); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034F3C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034F5C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80034FC8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035430); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800354CC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035658); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035744); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035CF0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035D64); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035DC8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80035F14); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80036038); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80036100); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80036190); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80036244); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80036298); + +// NOTE: please do not decompile any of these functions. +// Please refer to psyz/decomp for decompiled PSX SDK functions: +// https://github.com/Xeeynamo/psyz/tree/main/decomp + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuInit); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuStart); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_init); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_writeByIO); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FiDMA); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_r_); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_t); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_write); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_read); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FsetRXX); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FsetRXXa); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FgetRXXa); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FsetPCR); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FsetDelayW); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FsetDelayR); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_FwaitFs); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuDataCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuInitMalloc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuMallocSeparateTo3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuMallocWithStartAddr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_gcSPU); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetNoiseVoice); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuSetAnyVoice); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetNoiseClock); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuRead); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetReverb); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuIsInAllocateArea); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuIsInAllocateArea_); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetReverbModeParam); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _spu_setReverbAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuGetReverbModeParam); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetReverbDepth); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetReverbVoice); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuClearReverbWorkArea); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetIRQ); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetIRQAddr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetIRQCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _SpuCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetKey); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuGetKeyStatus); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80038F04); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetTransferStartAddr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetTransferMode); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetTransferCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetPitchLFOVoice); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetCommonAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceVolume); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceVolumeAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoicePitch); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceStartAddr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceLoopStartAddr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceDR); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceSL); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceARAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceSRAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SpuSetVoiceRRAttr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", rsin); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", sin_1); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", rcos); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetFogNearFar); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", csqrt_1); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", csqrt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InitGeom); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareRoot0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InvSquareRoot); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VectorNormalS); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VectorNormal); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VectorNormalSS); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003A0E8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MatrixNormal); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", gteMIMefunc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverage12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverage0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverageShort12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverageShort0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverageByte); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadAverageCol); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareRoot12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CompMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MulMatrix0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MulRotMatrix0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MulRotMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetMulMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ApplyMatrixLV); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ApplyRotMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ScaleMatrixL); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PushMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PopMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadRotMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadLightMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadColorMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MulMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MulMatrix2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ApplyMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ApplyMatrixSV); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", TransMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ScaleMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetRotMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLightMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetColorMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTransMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetVertex0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetVertex1); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetVertex2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetVertexTri); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetRGBfifo); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetIR123); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetIR0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSZfifo3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSZfifo4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSXSYfifo); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetRii); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetMAC123); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetData32); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDQA); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDQB); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadGeomOffset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadGeomScreen); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetBackColor); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetFarColor); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetGeomOffset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetGeomScreen); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LocalLight); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DpqColor); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColor); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColor3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColorDpq); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColorDpq3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColorCol); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NormalColorCol3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ColorDpq); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ColorCol); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AverageSZ3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AverageSZ4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadOTZ); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LightColor); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DpqColorLight); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DpqColor3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", Intpl); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", Square12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", Square0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AverageZ3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AverageZ4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", OuterProduct12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", OuterProduct0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", Lzc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadLZC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotTransSV); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareSS12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareSS0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareSL12); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SquareSL0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotTransPers); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotTransPers3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotTrans); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotTransPers4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotAverage3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotAverage4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotAverageNclip3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotAverageNclip4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", TransposeMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrixYXZ); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrixZYX); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrixX); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrixY); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RotMatrixZ); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ratan2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _patch_gte); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003CE0C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PadInit); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PadRead); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PadStop); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", v_wait); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ResetCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InterruptCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DMACallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VSyncCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VSyncCallbacks); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StopCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", RestartCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CheckCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetIntrMask); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetIntrMask); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", startIntr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", trapIntr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", setIntr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", stopIntr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", restartIntr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", memclr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", startIntrVSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", trapIntrVSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", setIntrVSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DMA_memclr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", startIntrDMA); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", trapIntrDMA); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", setIntrDMA); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", VSync_memclr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StSetRing); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdInit); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", def_cbsync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", def_cbready); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", def_cbread); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DCD8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DCE8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DCF8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdLastPos); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdReset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DD84); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DDA4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DDBC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DDF4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DE2C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DE4C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DE6C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003DE84); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdControl); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdControlF); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdControlB); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdMix); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdGetSector); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003E28C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003E2B0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdIntToPos); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdPosToInt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", getintr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_sync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_ready); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003EF30); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_vol); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_flush); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_initvol); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_initintr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_init); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_datasync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_getsector); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_8003FA9C); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", callback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdSearchFile); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _cmp); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_newmedia); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_searchdir); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_cachefile); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", cd_read); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CD_memcpy); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdRead2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StCdInterrupt2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdDiskReady); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CdGetDiskType); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StClearRing); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StUnSetRing); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", data_ready_callback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StGetBackloc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StSetStream); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StFreeRing); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", init_ring_status); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StGetNext); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StSetMask); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80040CA8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041620); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041654); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StRingStatus); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800418D8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041AFC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041CD4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041D28); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041E30); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80041EFC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTReset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTGetEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTPutEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTBufSize); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTin); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTout); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTinSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCToutSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTinCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCToutCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MDEC_reset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MDEC_in); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MDEC_out); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MDEC_in_sync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MDEC_out_sync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", timeout); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800425F8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTvlcSize); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DecDCTvlc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InitHeap); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", FlushCache); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _bu_init); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _96_remove); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetMem); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SystemError); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DeliverEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", OpenEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CloseEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", WaitEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", TestEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", EnableEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DisableEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InitPAD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StartPAD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StopPAD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PAD_init); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PAD_dr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReturnFromException); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ResetEntryInt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", HookEntryInt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", UnDeliverEvent); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", EnterCriticalSection); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ExitCriticalSection); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSp); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", open); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", read); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", write); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", close); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", format); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", firstfile); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", nextfile); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", delete); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ChangeClearPAD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ChangeClearRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StartRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StopRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ResetRCnt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", exit); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", puts); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", setjmp); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", strcmp); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", strncmp); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", bcopy); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", memcpy); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", rand); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", srand); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", printf); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", sprintf); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", strlen); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", memchr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", memmove); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadTPage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadClut); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDefDrawEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDefDispEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetVideoMode); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetVideoMode); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ResetGraph); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetGraphReverse); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetGraphDebug); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetGraphQueue); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetGraphType); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetGraphDebug); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DrawSyncCallback); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDispMask); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DrawSync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", checkRECT); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ClearImage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", LoadImage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StoreImage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MoveImage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ClearOTag); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ClearOTagR); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DrawPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DrawOTag); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PutDrawEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetDrawEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", PutDispEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetDispEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetODE); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTexWindow); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDrawArea); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDrawOffset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPriority); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDrawMode); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDrawEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_mode); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_cs); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_ce); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_ofs); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_tw); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_dx); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _status); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _otc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _clr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _dws); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _drs); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _ctl); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _getctl); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _cwb); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _cwc); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _param); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _addque); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _addque2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _exeque); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _reset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _sync); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", set_alarm); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_alarm); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _version); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GPU_memset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GPU_cw); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetTPage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", GetClut); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DumpTPage); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DumpClut); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", NextPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", IsEndPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AddPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", AddPrims); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", CatPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", TermPrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSemiTrans); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetShadeTex); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyF3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyFT3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyG3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyGT3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyF4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyFT4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyG4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetPolyGT4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSprt8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSprt16); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetSprt); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTile1); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTile8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTile16); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetTile); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineF2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineG2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineF3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineG3); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineF4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetLineG4); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetBlockFill); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SetDrawMove); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", MargePrim); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DumpDrawEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", DumpDispEnv); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", OpenTIM); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadTIM); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", OpenTMD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", ReadTMD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_tim_addr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", get_tmd_addr); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", unpack_packet); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", memset); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800484A8); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80048540); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800485A0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_800487F0); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _card_info); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _card_load); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _card_auto); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _card_clear); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _card_write); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _new_card); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InitCARD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StartCARD); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", SsInitHot); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", InitCARD2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StartCARD2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", StopCARD2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _patch_card); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80048BBC); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _patch_card2); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", func_80048C58); + +INCLUDE_ASM("asm/us/main/nonmatchings/psxsdk", _ExitCard); diff --git a/src/menu/bginmenu.c b/src/menu/bginmenu.c new file mode 100644 index 0000000..5c6d513 --- /dev/null +++ b/src/menu/bginmenu.c @@ -0,0 +1,165 @@ +//! PSYQ=3.3 CC1=2.7.2 +#include + +typedef struct { + u8 unk0; + u8 unk1; +} Unk801D026C; +typedef struct { + u8 unk0[8]; +} Unk8001E040; + +extern s32 D_801D07F0; +extern Unk8001E040 D_801D07F4[2]; +extern s16 D_801D07FE; +extern u8 D_801D0804[]; +extern u8 D_801D082C[21]; +extern u8 D_801D0844[16]; +extern u8 D_801D0854[7]; +extern u8 D_801D085C[2]; +extern Unk80026448 D_801D0860[]; +extern s8 D_801D086B; + +void func_801D0000(void) { + volatile s32 padding; + func_80026448(&D_801D0860[0], 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 0, 1, 0); + func_80026448(&D_801D0860[1], 0, 0, 1, 3, 0, 0, 1, 9, 0, 0, 0, 0, 0); + D_801D07F0 = 0; +} + +void func_801D00C4(void) { + volatile s32 padding[4]; + s32 i; + + func_800230C4(D_80062F58); + if (D_801D07F0 == 0) { + func_8001EB2C(0, D_801D07FE + (D_801D086B << 6) + 0x20); + } + func_80026F44(0x10, 0xB, D_801D0804, 7); + for (i = 0; i < 2; i++) { + func_8001E040(&D_801D07F4[i]); + } + func_800264A8(&D_801D0860[D_801D07F0]); + if (D_80062D7E & 0x40) { + func_8002305C(5, 0); + func_8002120C(0); + } +} + +static void func_801D01BC(void) {} + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D01C4); +#else +// -O1 +extern u8 D_8009C778[]; // Savemap.party +extern u8 D_8009C798[]; // Savemap.party +s32 func_801D01C4(s32 arg0) { + s32 var_a1; + s32 var_a2; + s32 var_a3; + s32* var_v1; + + var_a1 = 0; + var_a2 = 0; + var_a3 = -1; + var_v1 = (s32*)&D_8009C778[arg0 * 0x84]; + for (; var_a1 < 8; var_a1++) { + if (*var_v1 != var_a3) { + var_a2++; + } + var_v1++; + } + var_a1 = 0; + var_a3 = -1; + var_v1 = (s32*)&D_8009C798[arg0 * 0x84]; + for (; var_a1 < 8; var_a1++) { + if (*var_v1 != var_a3) { + var_a2++; + } + var_v1++; + } + return var_a2; +} +#endif + +static s32 func_801D0258(Unk801D026C* arg0) { + return arg0->unk0 | (arg0->unk1 << 8); +} + +static void func_801D026C(Unk801D026C* arg0, u16 arg1) { + arg0->unk0 = arg1; + arg0->unk1 = arg1 >> 8; +} + +INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D027C); + +INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D0324); + +INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D0408); + +INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D0500); + +void func_801D05C4(s32 arg0) { + s32 i; + + Savemap.memory_bank_5[111] = 0; + switch (arg0) { + case 0: + for (i = 0; i < 21; i++) { + if (!func_801D0408(D_801D082C[i])) { + return; + } + } + break; + case 1: + for (i = 0; i < 16; i++) { + if (!func_801D0408(D_801D0844[i])) { + return; + } + } + break; + case 2: + for (i = 0; i < 7; i++) { + if (!func_801D0408(D_801D0854[i])) { + return; + } + } + break; + case 3: + for (i = 0; i < 2; i++) { + if (!func_801D0500(D_801D085C[i])) { + return; + } + } + break; + } + Savemap.memory_bank_5[111] = 1; +} + +void func_801D0704(s32 arg0) { + s32 i; + switch (arg0) { + case 0: + for (i = 0; i < 21; i++) { + func_801D0324(D_801D082C[i]); + } + func_8002542C(0x49); + break; + case 1: + for (i = 0; i < 16; i++) { + func_801D0324(D_801D0844[i]); + } + func_8002542C(0x5A); + break; + case 2: + for (i = 0; i < 7; i++) { + func_801D0324(D_801D0854[i]); + } + func_8002542C(0x30); + break; + case 3: + func_8002542C(0x58); + break; + } +} diff --git a/src/menu/cnfgmenu.c b/src/menu/cnfgmenu.c new file mode 100644 index 0000000..f3118ec --- /dev/null +++ b/src/menu/cnfgmenu.c @@ -0,0 +1,267 @@ +//! PSYQ=3.3 CC1=2.7.2 +#include + +static s32 D_801D1AA8 = -1; +static u8 D_801D1AAC[] = { + 0x07, 0x07, 0x05, 0x07, 0x06, 0x07, 0x04, 0x07, 0x03, 0x0A, 0x00, 0x0A, + 0x01, 0x0A, 0x02, 0x0A, 0x08, 0x07, 0x00, 0x00, 0x00, 0x00, 0x09, 0x07, + 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; +static u8 D_801D1ADB = 8; +static u8 D_801D1ADC[] = { + 0x05, 0x06, 0x04, 0x07, 0x02, 0x03, 0x00, 0x01, 0x08, 0x0B, 0x00, 0x00}; +static unsigned char D_801D1AE8[][0x30] = { + _S("Window color"), // 0 + _S("Sound"), // 1 + _S("Controller"), // 2 + _S("Cursor"), // 3 + _S("ATB"), // 4 + _S("Battle speed"), // 5 + _S("Battle message"), // 6 + _S("Field message"), // 7 + _S("Camera angle"), // 8 + _S("Select"), // 9 + _S("Cancel"), // 10 + _S("Menu"), // 11 + _S("Window OFF"), // 12 + _S("Pause"), // 13 + _S("Battle help"), // 14 + _S("Mono"), // 15 + _S("Stereo"), // 16 + _S("Wide"), // 17 +}; +static unsigned char D_801D1E48[][0x30] = { + _S("Normal"), + _S("Customize"), +}; +static unsigned char D_801D1EA8[][0x30] = { + _S("Initial"), + _S("Memory"), +}; +static unsigned char D_801D1F08[][0x30] = { + _S("Active"), // 0 + _S("Recommended"), // 1 + _S("Wait"), // 2 + _S("Auto"), // 3 + _S("Fix"), // 4 + _S(""), // 5 + _S("Slow"), // 6 + _S("Fast"), // 7 + _S("RED"), // 8 + _S("GREEN"), // 9 + _S("BLUE"), // 10 + _S("Magic order"), // 11 + _S("restore"), // 12 + _S("attack"), // 13 + _S("indirect"), // 14 + _S("forbidden"), // 15 + _S("No."), // 16 +}; +static unsigned char D_801D2238[][0x30] = { + _S("Left2"), // 0 + _S("Right2"), // 1 + _S("Left1"), // 2 + _S("Right1"), // 3 + _S("Menu"), // 4 + _S("Select"), // 5 + _S("Cancel"), // 6 + _S("EXT"), // 7 + _S("Help"), // 8 +}; +static unsigned char D_801D23E8[][0x30] = { + {0x30, 0x52, 0x45, 0x53, 0x53, 0x00, 0xB2, 0x33, 0x34, 0x21, 0x32, 0x34, + 0xB3, 0x00, 0x54, 0x4F, 0x00, 0x43, 0x55, 0x53, 0x54, 0x4F, 0x4D, 0x49, + 0x5A, 0x45, 0x0E, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, +}; +static unsigned char D_801D2418[][0x30] = { + _S("Press Directional button Left or Right to end."), + _S("Pause"), +}; +static u8 D_801D2478[][6] = { + {0xC5, 0xB8, 0xB7, 0xFF, 0x00, 0x00}, // RED + {0xBA, 0xC5, 0xB8, 0xB8, 0xC1, 0xFF}, // BLUE + {0xB5, 0xBF, 0xC8, 0xB8, 0xFF, 0x00}, // GREEN +}; +static u8 D_801D248C[] = { + 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, +}; +static RECT D_801D24A0[2] = { + {0, 5, 364, 24}, + {0, 29, 364, 195}, +}; +static u8 D_801D24B0[] = { + // maybe this is an unused string? + 0x53, 0x69, 0x17, 0x61, 0xA1, 0x69, 0xFF, +}; +struct Pad { + u16 press; + u16 prev; +}; +static struct Pad D_801D24B8 = {0, 0}; +static u16 D_801D24BC = 0; +static u8 D_801D24C0[] = {4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0}; + +// from now on this is the BSS section; this can be moved up if necessary +static Unk80026448 D_801D24CC[4]; +static s32 unused[5]; +static s32 D_801D2528; +static u8 D_801D252C[LEN(D_80049208)]; + +static void func_801D0040(u16 arg0) { + D_8009A000[0] = 0x30; + D_8009A004[0] = arg0; + D_8009A008[0] = arg0; + func_8002DA7C(arg0); +} + +static void func_801D0080(s32 arg0) { + switch (arg0) { + case 0: + D_8009A000[0] = 0x81; + D_8009A004[0] = 0x81; + D_8009A008[0] = 0x81; + break; + case 1: + D_8009A000[0] = 0x80; + D_8009A004[0] = 0x80; + D_8009A008[0] = 0x80; + break; + case 2: + D_8009A000[0] = 0x82; + D_8009A004[0] = 0x82; + D_8009A008[0] = 0x82; + break; + } + func_8002DA7C(); +} + +static u8 func_801D0118(u16 arg0) { + s32 i; + for (i = 0; i < 12; i++) { + if ((arg0 >> i) & 1) { + return i; + } + } + return 0xFF; +} + +static void func_801D014C(s16 x, s16 y, s32 value) { + u8 uv = D_801D1AAC[value * 2 + 0]; + u8 page = D_801D1AAC[value * 2 + 1]; + func_80028CA0( + x, y, (uv & 3) * 16 + 96, (uv >> 2) * 16 + 64, 16, 16, page, 0); +} + +static void func_801D01C8(void) { + RECT rect; + s32 temp_s4; + s32 y; + s32 x; + s32 var_s2; + s32 i; + s32 _setting; + u8* setting; + + y = D_801D24A0[1].y + 33; + func_80026F44(40, D_801D24A0[1].y + 14, D_801D1AE8[0], 5); + for (i = 1; i < 9; i++) { + func_80026F44(40, y + (i - 1) * 18, D_801D1AE8[i], 5); + } + func_80026F44(40, y + (i - 1) * 18, D_801D1AE8[33], 5); + for (i = 0; i < 2; i++) { + func_80026F44(165 + i * 65, y, D_801D1AE8[15 + i], + -((Savemap.config & 3) == i) & 7); + } + for (i = 0; i < 2; i++) { + func_80026F44(165 + i * 65, y + 18, D_801D1E48[i], + -(((Savemap.config >> 2) & 3) == i) & 7); + } + for (i = 0; i < 2; i++) { + func_80026F44(165 + i * 65, y + 0x24, D_801D1EA8[i], + -(((Savemap.config >> 4) & 3) == i) & 7); + } + temp_s4 = y + 54; + func_80026F44( + 165, temp_s4, D_801D1F08[0], -(((Savemap.config >> 6) & 3) == 0) & 7); + x = func_80026B70(D_801D1F08[0]); + func_80026F44(x + 175, temp_s4, D_801D1F08[1], + -(((Savemap.config >> 6) & 3) == 1) & 7); + func_80026F44(x + func_80026B70(D_801D1F08[1]) + 185, temp_s4, + D_801D1F08[2], -(((Savemap.config >> 6) & 3) == 2) & 7); + for (i = 0; i < 2; i++) { + func_80026F44(165 + i * 65, y + 126, D_801D1F08[3 + i], + -(((Savemap.config >> 8) & 3) == i) & 7); + } + for (i = 0; i < 3; i++) { + _setting = D_801D248C[((Savemap.config >> 10) & 7) * 3 + i]; + setting = &D_801D248C[((Savemap.config >> 10) & 7) * 3]; + func_80026F44(189 + i * 52, y + 0x90, D_801D1F08[12 + setting[i]], 7); + } + func_80026F44(149, y + 0x90, D_801D1F08[16], 7); + + // battle speed value + rect.y = y + 72; + rect.w = 8; + rect.h = 11; + rect.x = (Savemap.battle_speed >> 1) + 184; + func_80028030(&rect); + + // battle message speed value + rect.y = y + 0x5A; + rect.w = 8; + rect.h = 11; + rect.x = (Savemap.battle_msg_speed >> 1) + 184; + func_80028030(&rect); + + // field message speed value + rect.y = y + 108; + rect.w = 8; + rect.h = 11; + rect.x = (Savemap.field_msg_speed >> 1) + 184; + func_80028030(&rect); + + // speed values + for (i = 0; i < 3; i++) { + func_80026F44(157, y + 72 + i * 18 + 2, D_801D1F08[7], 7); + func_80026F44(324, y + 72 + i * 18 + 2, D_801D1F08[6], 7); + } + + // speed bars + for (i = 0; i < 3; i++) { + rect.x = 184; + rect.y = y + 72 + i * 18; + rect.w = 136; + rect.h = 11; + func_80027B84(&rect); + } + + // magic order ID + func_80029114(173, y + 146, ((Savemap.config >> 0xA) & 7) + 1, 1, 7); + + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x1F, &rect); +} + +// exported, see 800493C8 +void func_801D069C(void) { + volatile s32 dummy; + s32 i; + func_80026448(&D_801D24CC[0], 0, 0, 1, 10, 0, 0, 1, 10, 0, 0, 0, 1, 0); + func_80026448(&D_801D24CC[1], 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 1, 1, 0); + func_80026448(&D_801D24CC[2], 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 0, 1, 0); + func_80026448(&D_801D24CC[3], 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0); + D_801D1AA8 = 0; + for (i = 0; i < LEN(D_80049208); i++) { + D_801D252C[i] = D_80049208[i]; + } +} + +// exported, see 8004941C +INCLUDE_ASM("asm/us/menu/nonmatchings/cnfgmenu", func_801D080C); + +static void func_801D1AA0(void) {} diff --git a/src/menu/savemenu.c b/src/menu/savemenu.c new file mode 100644 index 0000000..d6299ee --- /dev/null +++ b/src/menu/savemenu.c @@ -0,0 +1,703 @@ +//! PSYQ=3.3 CC1=2.7.2 +#include +#include +#include + +#include "savemenu.h" + +static void func_801D0408(u16 arg0) { + D_8009A000[0] = 0x30; + D_8009A004[0] = arg0; + D_8009A008[0] = arg0; + func_8002DA7C(arg0); +} + +static s32 func_801D0448(s32 arg0) { + RECT rect; + + setTile(D_80062F24.tile); + SetSemiTrans(D_80062F24.tile, 1); + D_80062F24.tile->x0 = 0; + D_80062F24.tile->y0 = 0; + D_80062F24.tile->w = 0x180; + D_80062F24.tile->h = 0xE8; + D_80062F24.tile->r0 = D_801D4EC4; + D_80062F24.tile->g0 = D_801D4EC4; + D_80062F24.tile->b0 = D_801D4EC4; + AddPrim(D_80062FC4, D_80062F24.tile++); + rect.x = 0; + rect.y = 0; + rect.w = 255; + rect.h = 255; + func_80026A34(0, 1, 0x5F, &rect); + D_801D4EC4 += arg0; + if (D_801D4EC4 < 0) { + D_801D4EC4 = 0; + } + if (D_801D4EC4 >= 0x100) { + D_801D4EC4 = 0xFF; + } + return D_801D4EC4; +} + +void func_801D05C0(u8 arg0) { + D_801E3860 = 0xF0; + D_801E36B8 = arg0; + D_801E3850 = 0; + func_80026448(menus.D_801E379C, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 0, 1, 0); + func_80025B8C(&D_801E8F44); + func_80025C14(&D_801E4538); + func_80025DF8(); + func_801D19C4(); +} + +static void func_801D0670(void) { + func_80025BD0(D_801E8F44); + func_80025C54(D_801E4538); + func_801D1BA4(); +} + +int func_801D06B0(s32 arg0) { + RECT sp38; + RECT rect; + s32 temp_s1; + s32 temp_s2; + s32 temp_v1; + s32 var_s0; + s32 var_s1; + s32 var_s2; + s32 var_s3; + s32 var_v0_6; + s8 temp_s0_2; + + if (D_801E36B8 == 0) { + func_800230C4(D_80062F58); + } else if (D_801E36B0 == 0) { + if (func_801D0448(-15) == 0) { + D_801E36B0 = 1; + } + } else if (D_801E36B0 == 2) { + if (func_801D0448(15) == 0xFF) { + D_801E36B0 = -1; + } + } + if (!func_80023050() || (D_801E36B8 && D_801E36B0 == 1)) { + if (!(u8)func_8001F6B4()) { + if (D_801E3850 >= 0 && D_801E3850 < 2) { + func_801D3668(arg0); + } + if (D_801E3860) { + D_801E3860--; + } + } + } + func_80026B5C(0x80); + switch (D_801E3850) { + case 0: + func_8001EB2C(D_801D4EC8.x - 18, + D_801D4EC8.y + 6 + (menus.D_801E379C[0].unkB * 12)); + func_80026F44(0xA, 0xB, D_801E2CFC[1], 7); + func_80026F44(D_801D4EC8.x + 12, D_801D4EC8.y + 5, D_801E2CFC[3], + -(D_801E8F38[0][0] != 0) & 7); + func_80026F44(D_801D4EC8.x + 12, D_801D4EC8.y + 17, D_801E2CFC[4], + -(D_801E8F3B != 0) & 7); + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + func_8001E040(&D_801D4EC8); + break; + case 7: + func_8001EB2C(D_801D4ED0.x + 0x16, + 0x15 + D_801D4ED0.y + menus.D_801E3808[1].unkB * 0xC); + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + func_80026F44(D_801D4ED0.x + 0xA, D_801D4ED0.y + 6, D_801E2CFC[33], 7); + func_80026F44(D_801D4ED0.x + 48, D_801D4ED0.y + 19, D_801E2CFC[34], 7); + func_80026F44(D_801D4ED0.x + 48, D_801D4ED0.y + 31, D_801E2CFC[35], 7); + func_8001E040(&D_801D4ED0); + /* fallthrough */ + case 1: + if (!D_801E8F38[menus.D_801E379C[0].unkB][0]) { + D_801E3850 = 0; + } else { + func_800269D0(); + if (D_801E36B8 == 0) { + func_800269C0(D_80062F58 * 0x5000 + D_801D4EDC); + } else { + func_800269C0(D_801E36B4 * 0x5000 + D_801D4EDC); + } + if (D_801E3850 != 7 || (arg0 & 2)) { + func_8001EB2C(8, (menus.D_801E379C[1].unkB << 6) | 0x38); + } + var_s3 = !menus.D_801E379C[1].unk8 ? 3 : 4; + for (var_s0 = 0; var_s0 < var_s3; var_s0++) { + if ((D_80062F3C >> (var_s0 + menus.D_801E379C[1].unk2)) & 1) { + func_8001DE70(); + func_801D370C( + 0, var_s0 * 64 + 29 + menus.D_801E379C[1].unkF * 8, + var_s0 + menus.D_801E379C[1].unk2); + func_8001DEB0(); + } else { + func_80026F44( + 0x32, var_s0 * 64 + 55 + menus.D_801E379C[1].unkF * 8, + D_801E2CFC[8], 6); + func_8001DE40(&sp38, &D_801DEEF4); + func_8001DE24( + &sp38, 0, + var_s0 * 64 + 29 + menus.D_801E379C[1].unkF * 8); + func_8001E040(&sp38); + } + } + func_80026B5C(0x80); + rect.y = 29; + rect.w = 364; + rect.x = 0; + rect.h = 195; + if (D_801E36B8 == 0) { + func_80026A94(&D_800706A4[D_80062F58], &rect); + } else { + func_80026A94(&D_801E36BC[D_801E36B4], &rect); + } + func_80026F44(10, 11, D_801E2CFC[2], 7); + func_80026F44(206, 11, D_801E2CFC[9], 6); + func_80026F44( + func_80026B70(D_801E2CFC[9]) + 208, 11, + ((13 + menus.D_801E379C[1].unkB + menus.D_801E379C[1].unk2) * + 36) + + D_801E2CFC[0], + 7); + func_8001DE0C(&sp38, 200, 5, 78, 24); + func_8001E040(&sp38); + func_800269E8(); + } + break; + case 2: + case 3: + if (D_801E3850 == 2) { + var_s2 = 64; + var_s1 = 32; + var_s0 = 160; + } else { + var_s2 = 224; + var_s1 = 128; + var_s0 = 0; + } + func_80026F44(10, 11, D_801E2CFC[12], 7); + if (D_801E36A8 == 0) { + func_800285AC( + 122, 117, (D_801E36AC + 1) * 8, 8, var_s2, var_s1, var_s0); + rect.x = 0; + rect.y = 0; + rect.w = 0xFF; + rect.h = 0xFF; + func_80026A34(0, 1, 0x3F, &rect); + } + func_8001DE0C(&sp38, 0x70, 0x6D, 0x8C, 0x18); + func_8001E040(&sp38); + break; + case 4: + temp_s1 = func_80026B70(D_801E2CFC[7]) + 0x10; + func_80026F44(190 - temp_s1 / 2, 115, D_801E2CFC[7], 7); + func_8001DE0C(&sp38, 182 - temp_s1 / 2, 109, temp_s1, 24); + func_8001E040(&sp38); + break; + case 6: + if (arg0 & 2) { + func_8001EB2C(D_801D4EC8.x - 18, + D_801D4EC8.y + 6 + menus.D_801E379C[0].unkB * 0xC); + } + func_80026F44(D_801D4EC8.x + 12, D_801D4EC8.y + 5, D_801E2CFC[3], + -(D_801E8F38[0][0] != 0) & 7); + func_80026F44(D_801D4EC8.x + 12, D_801D4EC8.y + 0x11, D_801E2CFC[4], + -(D_801E8F38[1][0] != 0) & 7); + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + func_8001E040(&D_801D4EC8); + func_80026F44(10, 11, D_801E3260[4], 7); + temp_s2 = func_80026B70(D_801E3260[5]) + 0x10; + func_80026F44(190 - temp_s2 / 2, D_801D4EC8.h + 99, D_801E3260[5], 7); + func_80026F44(228 - temp_s2 / 2, D_801D4EC8.h + 112, D_801E2CFC[34], 7); + func_80026F44(228 - temp_s2 / 2, D_801D4EC8.h + 124, D_801E2CFC[35], 7); + func_8001EB2C(200 - temp_s2 / 2, + 115 + (menus.D_801E3808[0].unkB * 12) + D_801D4EC8.h); + func_8001DE0C( + &sp38, 182 - temp_s2 / 2, D_801D4EC8.h + 93, temp_s2, 0x30); + func_8001E040(&sp38); + break; + } + if (D_801E36B8 != 0) { + func_80026B5C(0x80); + func_80026F44(294, 11, &D_801DEEDC, 7); + func_8001E040(&D_801DEEFC); + } + func_8001DE0C(&sp38, 0, 5, 364, 24); + func_8001E040(&sp38); + if (!(D_801E36B8 == 0 && !func_80023050()) && + (D_801E36B8 == 0 || D_801E36B0 != 1)) { + return; + } + if (func_8001F6B4() & 0xFF) { + return; + } + switch (D_801E3850) { + case 0: + if (D_80062D7C & 0x20) { + if (D_801E8F38[menus.D_801E379C[0].unkB][0]) { + func_801D0408(1); + if (D_801E8F38[menus.D_801E379C[0].unkB][2]) { + D_801E3850 = 6; + func_80026448(&menus.D_801E3808[0], 0, 1, 1, 2, 0, 0, 1, 2, + 0, 0, 0, 1, 0); + } else { + D_801E3850 = 2; + D_801E36AC = 0; + D_801E36A0 = 0; + D_80062F3C = 0; + D_801E36A8 = 1; + D_801E36A4 = 0x3C; + func_80026448(&menus.D_801E379C[1], 0, 0, 1, 3, 0, 0, 1, 15, + 0, 0, 0, 0, 0); + } + } else { + func_801D0408(3); + func_8001F6C0(!D_801E3860 ? D_801E33B0[0] : D_801E3260[6], 7); + } + } else { + func_800264A8(&menus.D_801E379C[0]); + if (D_801E36B8 != 0) { + if (D_80062D7C & 0x40) { + func_801D0408(4); + D_801E36B0 = 2; + } + } else if (D_80062D7C & 0x40) { + func_801D0408(4); + func_801D0670(); + func_8002305C(5, 0); + func_8002120C(0); + } + } + break; + case 1: + var_s0 = menus.D_801E379C[1].unkF; + func_801D2DA8(&menus.D_801E379C[1]); + if ((menus.D_801E379C[1].unkF == 0) && (var_s0 == 0)) { + if (D_80062D7C & 0x20) { + D_801E3850 = 7; + func_80026448(&menus.D_801E3808[1], 0, 0, 1, 2, 0, 0, 1, 2, 0, + 0, 0, 1, 0); + func_801D0408(1); + } else if (D_80062D7C & 0x40) { + func_801D0408(4); + D_801E3850 = 0; + } + } + break; + case 2: + if (D_801E36A4 == 0) { + if (D_801E36A8) { + D_801E36A4 = 0; + D_801E36A8 = 0; + D_80062F3C = func_801D1C2C(menus.D_801E379C[0].unkB); + } else { + var_s0 = 0; + if ((D_80062F3C >> D_801E36AC) & 1) { + var_s0 = + func_801D3698(menus.D_801E379C[0].unkB, D_801E36AC); + } + D_801E36AC++; + if (var_s0) { + D_801E3850 = 0; + func_8001F6C0(D_801E33B0[8], 2); + } + if (D_801E36AC == 0xF) { + D_801E36AC = 0xE; + D_801E3850 = 3; + D_801E36A4 = 0xA; + func_801D0408(2); + } + } + } else { + D_801E36A4--; + } + break; + case 3: + if (D_801E36A4 == 0) { + D_801E3850 = 1; + } + D_801E36A4--; + break; + case 4: + if (D_801E36A4 != 0) { + D_801E36A4--; + return; + } + D_801E3850 = 1; + var_v0_6 = menus.D_801E379C[1].unkB + menus.D_801E379C[1].unk2; + if (menus.D_801E379C[0].unkB != 0) { + var_v0_6 |= 0x10; + } + if (!func_801D2A34(var_v0_6)) { + func_801D0408(0xD0); + func_8001F6C0(D_801E2CFC[28], 7); + D_80062F3C |= + 1 << (menus.D_801E379C[1].unkB + menus.D_801E379C[1].unk2); + } else { + func_801D0408(3); + func_8001F6C0(D_801E33B0[3], 7); + } + break; + case 6: + func_800264A8(&menus.D_801E3808[0]); + if (D_80062D7C & 0x20) { + if (menus.D_801E3808[0].unkB) { + D_801E3850 = 0; + func_801D0408(4); + } else { + if (menus.D_801E379C[0].unkB) { + temp_v1 = format("bu10:"); + } else { + temp_v1 = format("bu00:"); + } + D_801E3850 = 0; + if (temp_v1 == 1) { + D_801E8F38[menus.D_801E379C[0].unkB][2] = 0; + func_8001F6C0(D_801E2CFC[41], 7); + func_801D0408(0xD0); + } else { + func_8001F6C0(D_801E3260[3], 7); + func_801D0408(3); + } + } + } else if (D_80062D7C & 0x40) { + D_801E3850 = 0; + func_801D0408(4); + } + break; + case 7: + if (D_80062D7C & 0x20) { + temp_s0_2 = menus.D_801E3808[1].unkB; + switch (menus.D_801E3808[1].unkB) { + case 0: + func_801D0408(1); + D_801E3850 = 4; + D_801E36A4 = 0xA; + break; + case 1: + func_801D0408(4); + D_801E3850 = temp_s0_2; + break; + } + } else if (D_80062D7C & 0x40) { + D_801E3850 = 1; + func_801D0408(4); + } else { + func_800264A8(&menus.D_801E3808[1]); + } + break; + } +} + +static const char* D_801E2C78[] = { + "BASCUS-94163FF7-S01", "BASCUS-94163FF7-S02", "BASCUS-94163FF7-S03", + "BASCUS-94163FF7-S04", "BASCUS-94163FF7-S05", "BASCUS-94163FF7-S06", + "BASCUS-94163FF7-S07", "BASCUS-94163FF7-S08", "BASCUS-94163FF7-S09", + "BASCUS-94163FF7-S10", "BASCUS-94163FF7-S11", "BASCUS-94163FF7-S12", + "BASCUS-94163FF7-S13", "BASCUS-94163FF7-S14", "BASCUS-94163FF7-S15", +}; +static s32 D_801E2CB4 = 0; + +s32 func_801D1774(void) { + s32 ret; + s32 i; + + func_80021044(D_801E36BC, D_801E3774); + i = 0; + D_801E36B0 = 0; + func_801D05C0(1); + D_801E36B4 = 0; + while (1) { + func_8001CB48(); + func_800269C0(D_80077F64[D_801E36B4]); + D_801E3854 = (u_long*)D_801E3858[D_801E36B4]; + ClearOTag(D_801E3854, 1); + func_80026A00(D_801E3854); + func_8001F710(); + ret = func_801D06B0(i); + if (D_801E36B0 == -1) { + break; + } + DrawSync(0); + VSync(0); + PutDispEnv(&D_801E3774[D_801E36B4]); + PutDrawEnv(&D_801E36BC[D_801E36B4]); + DrawOTag(D_801E3854); + D_801E36B4 ^= 1; + i++; + } + func_801D0670(); + VSync(0); + PutDispEnv(&D_801E3774[0]); + PutDrawEnv(&D_801E36BC[0]); + VSync(0); + PutDispEnv(&D_801E3774[1]); + PutDrawEnv(&D_801E36BC[1]); + return ret; +} + +u16 func_801D1950(u16 len, u8* data) { + u16 i, j; + s32 sum = 0xFFFF; + for (i = 0; i < len; i++) { + sum ^= *(data + i) << 8; + for (j = 0; j < 8; j++) { + if (sum & 0x8000) { + sum = (sum * 2) ^ 0x1021; + } else { + sum *= 2; + } + } + } + return ~sum; +} + +void func_801D19C4(void) { + s32 i; + + if (D_80062DCC == 0) { + EnterCriticalSection(); + D_8009A024[0] = OpenEvent(SwCARD, EvSpIOE, EvMdNOINTR, NULL); + D_8009A024[1] = OpenEvent(SwCARD, EvSpERROR, EvMdNOINTR, NULL); + D_8009A024[2] = OpenEvent(SwCARD, EvSpTIMOUT, EvMdNOINTR, NULL); + D_8009A024[3] = OpenEvent(SwCARD, EvSpNEW, EvMdNOINTR, NULL); + D_8009A024[4] = OpenEvent(HwCARD, EvSpIOE, EvMdNOINTR, NULL); + D_8009A024[5] = OpenEvent(HwCARD, EvSpERROR, EvMdNOINTR, NULL); + D_8009A024[6] = OpenEvent(HwCARD, EvSpTIMOUT, EvMdNOINTR, NULL); + D_8009A024[7] = OpenEvent(HwCARD, EvSpNEW, EvMdNOINTR, NULL); + InitCARD(1); + StartCARD(); + ChangeClearPAD(0); + _bu_init(); + _card_auto(0); + for (i = 0; i < 8; i++) { + EnableEvent(D_8009A024[i]); + } + ExitCriticalSection(); + D_80062DCC = 1; + } + for (i = 0; i < 2; i++) { + D_801E8F38[i][0] = 0; + D_801E8F38[i][1] = 0; + D_801E8F38[i][2] = 0; + } +} + +void func_801D1BA4(void) {} + +static void func_801D1BAC(s32 arg0, s32 arg1) { TestEvent(D_8009A024[arg1]); } + +// strcmp? +static s32 func_801D1BE0(u8* arg0, u8* arg1) { + while (1) { + if (*arg0++ != *arg1++) { + return 0; + } + if (!*arg0 && !*arg1) { + return 1; + } + } +} + +#ifndef NON_MATCHINGS +INCLUDE_ASM("asm/us/menu/nonmatchings/savemenu", func_801D1C2C); +#else +u16 func_801D1C2C(s32 arg0) { + DIRENTRY sp10; + const char* memcard; + s32 i; + DIRENTRY* entry; + u16 var_s3; + + var_s3 = 0; + i = 0; + while (1) { + memcard = &D_801D0184; + if (arg0) { + memcard = &D_801D017C; + } + entry = firstfile2(memcard, &sp10); + if (entry) { + break; + } + i++; + if (i >= 100) { + var_s3 = 0; + goto end; + } + } + while (entry) { + for (i = 0; i < 15; i++) { + if (func_801D1BE0(entry->name, D_801E2C78[i]) != 0) { + var_s3 |= 1 << i; + } + } + entry = nextfile(entry); + } +end: + return var_s3; +} +#endif + +const char D_801D018C[] = "bu10:%s"; +const char D_801D0194[] = "bu00:%s"; + +SaveHeader* func_801D1D1C(s32 arg0) { return &D_801E3864[arg0]; } + +INCLUDE_ASM("asm/us/menu/nonmatchings/savemenu", func_801D1D40); + +INCLUDE_ASM("asm/us/menu/nonmatchings/savemenu", func_801D1F40); + +static s32 func_801D2150(s8 arg0) { + if (arg0 > -0x68 && arg0 < -0x60 || arg0 > -32 && arg0 < -3) { + return 1; + } + return 0; +} + +s32 func_801D2184(s8 arg0) { + if (arg0 > -0x80 && arg0 < -0x60 || arg0 > -33 && arg0 < -3) { + return 1; + } + return 0; +} + +static void func_801D21B8(u8* arg0, u8* arg1) { + s32 i; + for (i = 0; i < 0x40; i++) { + *arg0++ = *arg1++; + } +} + +static void func_801D21E0(s32 arg0) { D_801E2CB4 = arg0; } + +void func_801D21F0(u8* arg0, u8* arg1) { + s32 i; + for (i = 0; i < D_801E2CB4; i++) { + *arg0++ = *arg1; + if (*arg1 == 0xFF) { + break; + } + arg1++; + } +} + +INCLUDE_ASM("asm/us/menu/nonmatchings/savemenu", func_801D224C); + +INCLUDE_ASM("asm/us/menu/nonmatchings/savemenu", func_801D2408); + +const char* D_801E2CB8[] = { + "FF7/SAVE01/00:00", "FF7/SAVE02/00:00", + "FF7/SAVE03/00:00", "FF7/SAVE04/00:00", + "FF7/SAVE05/00:00", "FF7/SAVE06/00:00", + "FF7/SAVE07/00:00", "FF7/SAVE08/00:00", + "FF7/SAVE09/00:00", "FF7/SAVE10/11:11", + "FF7/SAVE11/11:11", "FF7/SAVE12/11:11", + "FF7/SAVE13/11:11", "FF7/SAVE14/11:11", + "FF7/SAVE15/11:11", +}; + +static s16 func_801D2A34(s32 save_id) { + char path[0x40]; + s32 ret; + s32 slot; + + if (save_id & 0x10) { + sprintf(path, D_801D018C, D_801E2C78[save_id & 15]); + } else { + sprintf(path, D_801D0194, D_801E2C78[save_id & 15]); + } + slot = save_id & 15; + D_801E3D50 = slot; + ret = func_801D2408(path, D_801E2CB8[slot]); + if (!(s16)ret) { + memcpy(&D_801E3864[slot], &Savemap.header, sizeof(SaveHeader)); + } + return ret; +} + +s32 D_801E2CF4 = 0xFF; // used by title.c +StartMenuMode g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; // used by title.c + +unsigned char D_801E2CFC[][0x24] = { + _S("Load"), + _S("Select a slot."), + _S("Select a file."), + _S("SLOT 1"), + _S("SLOT 2"), + _S("Are you sure?"), + _S("Loading. Do not remove Memory card."), + _S("Saving. Do not remove Memory card."), + _S("EMPTY"), + _S("FILE"), + _S("Continue?"), + _S("/15"), + _S("Checking Memory card."), + _S("01"), + _S("02"), + _S("03"), + _S("04"), + _S("05"), + _S("06"), + _S("07"), + _S("08"), + _S("09"), + _S("10"), + _S("11"), + _S("12"), + _S("13"), + _S("14"), + _S("15"), + _S("Saved."), + _S("Could not save."), + _S("Could not load."), + _S("File is ruined."), + _S("NEW GAME"), + _S("Are you sure you want to save?"), + _S("Yes"), + _S("No"), + _S(""), + _S("Completed."), +}; +static u32 _padding[] = {0, 0, 0}; +unsigned char D_801E3260[][0x30] = { + _S(""), + _S(""), + _S("Formatted."), + _S("Could not format."), + _S("Not formatted."), + _S("Want to format it now?"), + _S("No Memory card."), +}; +unsigned char D_801E33B0[][0x30] = { + _S("No Memory card."), + _S("This Memory card is damaged and cannot be used."), + _S("Please insert another Memory card."), + _S("No enough memory left on Memory card."), + _S("Use another Memory card,"), + _S("or erase 1 block of saved data."), + _S(""), + _S(""), + _S("Couldn't read it."), + _S("Still want to begin the game?"), + _S("‘’"), + _S("‘’"), + _S("‘’"), + _S(""), +}; diff --git a/src/menu/savemenu.h b/src/menu/savemenu.h new file mode 100644 index 0000000..1de647b --- /dev/null +++ b/src/menu/savemenu.h @@ -0,0 +1,91 @@ +#include + +typedef enum { + START_MENU_MODE_SELECT_SLOT = 0, + START_MENU_MODE_SELECT_FILE = 1, + START_MENU_MODE_CHECKING_FILES = 2, + START_MENU_MODE_CHECKING_WAIT = 3, + START_MENU_MODE_LOADING = 4, + START_MENU_MODE_FORMAT_PROMPT = 6, + START_MENU_MODE_TITLE = 7, +} StartMenuMode; + +typedef struct { + // this whole thing might be a D_801E379C[6] + /* 0x00 */ Unk80026448 D_801E379C[2]; + /* 0x24 */ u8 unk24[0x40]; + /* 0x64 */ s32 D_801E3800; + /* 0x68 */ s32 D_801E3804; + /* 0x6C */ Unk80026448 D_801E3808[2]; +} Menus; // size: 0x90 + +extern const char D_801D018C[]; +extern const char D_801D0194[]; +extern s32 D_801D4EC4; +extern RECT D_801D4EC8; +extern RECT D_801D4ED0; +extern u8 D_801D4EDC[]; +extern u8 D_801E2DF8; +extern u8 D_801E2E1C; +extern u8 D_801DEEDC; +extern s32 D_801DEEF4; +extern RECT D_801DEEFC; +extern u8 D_801E2EAC[]; +extern const char* D_801E2CB8[]; +extern StartMenuMode g_MenuStartMode; +extern s32 D_801E3440; +extern s32 D_801E3530; +extern RECT D_801E3650[3]; +extern s32 D_801E36A0; +extern s32 D_801E36A4; +extern s32 D_801E36A8; +extern s32 D_801E36AC; +extern s32 D_801E368C[]; +extern u8 D_801E3684[]; // "Level" label +extern s32 D_801E3698; +extern s32 D_801E36B0; +extern s32 D_801E36B8; +extern s32 D_801E36B4; +extern DRAWENV D_801E36BC[2]; +extern DISPENV D_801E3774[2]; +extern Menus menus; +extern u_long* D_801E3854; // otag pointer +extern u_long* D_801E3858[2][1]; +extern SaveHeader D_801E3864[]; +extern s32 D_801E3D50; +extern s32 D_801E3D54; +extern s32 D_801E3D58; // backbuffer id? +extern u_long* D_801E3D5C; // otag pointer +extern u_long* D_801E3D60[2][4]; +extern Unk80026448 D_801E3DFE[2]; +extern DRAWENV D_801E3E34[2]; +extern DISPENV D_801E3EEC[2]; +extern s32 D_801E3F2C[]; +extern s32 D_801E4538[]; +extern u8 D_801E8F38[2][3]; +extern s32 D_801E3850; +extern s32 D_801E3860; +extern u8 D_801E8F3B; +extern s32 D_801E8F44[]; +extern u8 D_801E2E88; +extern u8 D_801E3158; +extern RECT D_801E3668; +extern s16 D_801E366A; +extern s16 D_801E366E; +extern Unk80026448 D_801E3D80[2]; +extern s32 D_801E3F14; +extern s32 D_801E3F18; +extern s32 D_801E3F1C; +extern s32 D_801E3F20; +extern s32 D_801E3660; + +extern unsigned char D_801E2CFC[][0x24]; +extern unsigned char D_801E3260[][0x30]; +extern unsigned char D_801E33B0[][0x30]; + +void func_801D19C4(void); +void func_801D1BA4(void); +SaveHeader* func_801D1D1C(s32 arg0); +static s16 func_801D2A34(s32 save_id); +void func_801D3668(s32 arg0); +void func_801D370C(s32 x, s32 y, s32 slot_no); diff --git a/src/menu/title.c b/src/menu/title.c new file mode 100644 index 0000000..f48b621 --- /dev/null +++ b/src/menu/title.c @@ -0,0 +1,625 @@ +//! PSYQ=3.3 CC1=2.7.2 +#include +#include "savemenu.h" + +extern s32 D_801E2CF4; +extern Unk80026448 D_801E3DEC[2]; + +static void func_801D2B58(u16 arg0) { + D_8009A000[0] = 0x30; + D_8009A004[0] = arg0; + D_8009A008[0] = arg0; + func_8002DA7C(); +} + +static s32 func_801D2B98(s32 arg0) { + RECT rect; + + setTile(D_80062F24.tile); + SetSemiTrans(D_80062F24.tile, 1); + D_80062F24.tile->x0 = 0; + D_80062F24.tile->y0 = 0; + D_80062F24.tile->w = 0x180; + D_80062F24.tile->h = 0xE8; + D_80062F24.tile->r0 = (u8)D_801E2CF4; + D_80062F24.tile->g0 = (u8)D_801E2CF4; + D_80062F24.tile->b0 = (u8)D_801E2CF4; + AddPrim(D_80062FC4, D_80062F24.tile++); + rect.x = 0; + rect.y = 0; + rect.w = 255; + rect.h = 255; + func_80026A34(0, 1, 0x5F, &rect); + D_801E2CF4 += arg0; + if (D_801E2CF4 < 0) { + D_801E2CF4 = 0; + } + if (D_801E2CF4 >= 0x100) { + D_801E2CF4 = 0xFF; + } + return D_801E2CF4; +} + +static void func_801D2D10(s32 arg0) { + switch (arg0) { + case 0: + D_8009A000[0] = 0x81; + D_8009A004[0] = 0x81; + D_8009A008[0] = 0x81; + break; + case 1: + D_8009A000[0] = 0x80; + D_8009A004[0] = 0x80; + D_8009A008[0] = 0x80; + break; + case 2: + D_8009A000[0] = 0x82; + D_8009A004[0] = 0x82; + D_8009A008[0] = 0x82; + break; + } + func_8002DA7C(); +} + +INCLUDE_ASM("asm/us/menu/nonmatchings/title", func_801D2DA8); + +static void func_801D32C0(void) { + TestEvent(D_8009A024[0]); + TestEvent(D_8009A024[1]); + TestEvent(D_8009A024[2]); + TestEvent(D_8009A024[3]); +} + +static void func_801D3318(void) { + TestEvent(D_8009A024[4]); + TestEvent(D_8009A024[5]); + TestEvent(D_8009A024[6]); + TestEvent(D_8009A024[7]); +} + +static s32 func_801D3370(void) { + while (1) { + if (TestEvent(D_8009A024[0]) == 1) { + return 0; + } + if (TestEvent(D_8009A024[1]) == 1) { + return 1; + } + if (TestEvent(D_8009A024[2]) == 1) { + return 2; + } + if (TestEvent(D_8009A024[3]) == 1) { + return 3; + } + } +} + +static s32 func_801D33F4(void) { + while (1) { + if (TestEvent(D_8009A024[4]) == 1) { + return 0; + } + if (TestEvent(D_8009A024[5]) == 1) { + return 1; + } + if (TestEvent(D_8009A024[6]) == 1) { + return 2; + } + if (TestEvent(D_8009A024[7]) == 1) { + return 3; + } + } +} + +INCLUDE_ASM("asm/us/menu/nonmatchings/title", func_801D3478); + +void func_801D3668(s32 arg0) { + if (!(arg0 & 0x3F)) { + func_801D3478(0); + func_801D3478(1); + } +} + +s32 func_801D3698(s32 arg0, s32 arg1) { + s32 var_a0; + s32 i; + s32 ret; + + for (i = 0; i < 0x14; i++) { + var_a0 = arg1; + if (arg0) { + var_a0 |= 0x10; + } + if (func_801D1D40(var_a0) == 0) { + ret = 0; + break; + } + ret = 1; + } + return ret; +} + +void func_801D370C(s32 x, s32 y, s32 slot_no) { + RECT sp28; + RECT rect; + s32 i; + s32 j; + SaveHeader* save; + u8* data; + + save = func_801D1D1C(slot_no); + data = (u8*)save; + func_80026F44(192, y + 46, save->place_name, 7); + for (i = 0; i < 3; i++) { + if (data[i + 5] != 0xFF) { + func_8001D180( + 22 + i * 52, y + 6, 48, 48, (data[i + 5] >= 5) ? 48 : 0, + (data[i + 5] % 5) * 48, 48, 48, data[i + 5], 0); + } + } + + rect.x = 0; + rect.y = 0; + rect.w = 0xFF; + rect.h = 0xFF; + func_80026A34(0, 1, 127, &rect); + func_80028E00( + func_80026B70(D_801E3684) + 194, y + 28, save->leader_level, 2, 7); + func_8002708C(338, y + 12, 213, 7); // prints the ':' symbol maybe? + func_80029114(324, y + 11, func_80023788(save->time), 2, 7); + func_80029114(345, y + 11, func_8002382C(save->time), 2, 7); + func_80028E00(309, y + 25, save->gil, 7, 7); + + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 127, &rect); + func_80026F44(189, y + 26, D_801E3684, 5); + func_80026F44(184, y + 8, save->leader_name, 7); + func_80026F44(284, y + 9, D_800492F0[LABEL_TIME], 7); + func_80026F44(284, y + 23, D_800492F0[LABEL_GIL], 7); + func_8001DEF0(save->menu_color); + + for (j = 0; j < 3; j++) { + func_8001DE40(&sp28, &D_801E3650[j]); + func_8001DE24(&sp28, 0, y); + func_8001E040(&sp28); + } +} + +static void func_801D39C4(void) { + D_801E3698 = 0; + g_MenuStartMode = START_MENU_MODE_TITLE; + func_8001DEF0(D_801E368C); + func_80025D14(D_801D4EDC, 0x380, 0, 0, 0x1E0); + DrawSync(0); + func_80026448(D_801E3DFE, 0, 1, 1, 2, 0, 0, 1, 2, 0, 0, 0, 1, 0); + func_80025CD4(D_801E3F2C); + func_80025B8C(D_801E8F44); + func_80025C14(D_801E4538); + func_80025DF8(); + func_801D19C4(); +} + +// title screen handler +static s32 func_801D3AB0(s32 arg0) { + RECT sp38; + RECT rect; + s32 temp_v1_2; + s32 var_a0_3; + s32 var_s0; + s32 var_s0_2; + s32 temp_s1; + s32 var_s1; + s32 var_s2; + s32 temp_s2; + s32 var_s3; + + if ((g_MenuStartMode < START_MENU_MODE_CHECKING_FILES || + g_MenuStartMode == START_MENU_MODE_TITLE) && + D_801E3D54 != 2 && D_801E3D54 != 0) { + func_801D3668(arg0); + } + func_80026B5C(0x80); + if (D_801E3D54 == 0) { + if (func_801D2B98(-15) == 0) { + D_801E3D54 = 1; + } + } else if (D_801E3D54 == 2) { + if (func_801D2B98(15) == 0xFF) { + D_801E3D54 = -1; + } + } + func_8001F6B4(); + switch (g_MenuStartMode) { + case START_MENU_MODE_SELECT_SLOT: + func_8001EB2C( + D_801E3668.x - 18, D_801E3668.y + 6 + D_801E3D80[0].unkB * 12); + func_80026F44(10, 11, D_801E2CFC[1], 7); + func_80026F44(D_801E3668.x + 12, D_801E3668.y + 5, D_801E2CFC[3], + -(D_801E8F38[0][0] != 0) & 7); + func_80026F44(D_801E3668.x + 12, D_801E3668.y + 0x11, D_801E2CFC[4], + -(D_801E8F3B != 0) & 7); + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + func_8001E040(&D_801E3668); + break; + case START_MENU_MODE_SELECT_FILE: + if (!D_801E8F38[D_801E3D80[0].unkB][0]) { + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + } else { + func_800269D0(); + func_800269C0(D_801E3D58 * 0x5000 + D_801D4EDC); + func_8001EB2C(8, (D_801E3D80[1].unkB * 64) | 0x38); + var_s3 = !D_801E3D80[1].unk8 ? 3 : 4; + for (var_s0 = 0; var_s0 < var_s3; var_s0++) { + if ((D_80062F3C >> (var_s0 + D_801E3D80[1].unk2)) & 1) { + func_8001DE70(); + func_801D370C( + 0, var_s0 * 64 + 0x1D + D_801E3D80[1].unkF * 8, + var_s0 + D_801E3D80[1].unk2); + func_8001DEB0(); + } else { + func_80026F44( + 0x32, var_s0 * 64 + 55 + D_801E3D80[1].unkF * 8, + D_801E2CFC[8], 6); + func_8001DE40(&sp38, &D_801E3660); + func_8001DE24( + &sp38, 0, var_s0 * 64 + 0x1D + D_801E3D80[1].unkF * 8); + func_8001E040(&sp38); + } + } + func_80026B5C(0x80); + rect.y = 0x1D; + rect.w = 0x16C; + rect.h = 0xC3; + rect.x = 0; + func_80026A94(&D_801E3E34[D_801E3D58], &rect); + func_80026F44(10, 11, D_801E2CFC[2], 7); + func_80026F44(0xCE, 11, D_801E2CFC[9], 6); + func_80026F44( + func_80026B70(D_801E2CFC[9]) + 0xD0, 11, + ((13 + D_801E3D80[1].unkB + D_801E3D80[1].unk2) * 36) + + (D_801E2CFC[0]), + 7); + func_8001DE0C(&sp38, 200, 5, 0x4E, 0x18); + func_8001E040(&sp38); + func_800269E8(); + } + break; + case START_MENU_MODE_CHECKING_FILES: + case START_MENU_MODE_CHECKING_WAIT: + if (g_MenuStartMode == START_MENU_MODE_CHECKING_FILES) { + var_s2 = 0x40; + var_s1 = 0x20; + var_s0_2 = 0xA0; + } else { + var_s2 = 0xE0; + var_s1 = 0x80; + var_s0_2 = 0; + } + func_80026F44(10, 11, D_801E2CFC[12], 7); + if (D_801E3F1C == 0) { + func_800285AC( + 122, 117, (D_801E3F20 + 1) * 8, 8, var_s2, var_s1, var_s0_2); + rect.x = 0; + rect.y = 0; + rect.w = 0xFF; + rect.h = 0xFF; + func_80026A34(0, 1, 0x3F, &rect); + } + func_8001DE0C(&sp38, 112, 0x6D, 0x8C, 0x18); + func_8001E040(&sp38); + break; + case START_MENU_MODE_LOADING: + if (D_801E3D54 != 2) { + temp_s1 = func_80026B70(D_801E2CFC[6]) + 0x10; + func_80026F44(190 - temp_s1 / 2, 0x73, D_801E2CFC[6], 7); + func_8001DE0C(&sp38, 0xB6 - temp_s1 / 2, 0x6D, temp_s1, 24); + func_8001E040(&sp38); + } + break; + case START_MENU_MODE_FORMAT_PROMPT: + if (arg0 & 2) { + func_8001EB2C(D_801E3668.x - 0x12, + D_801E3668.y + 6 + D_801E3D80[0].unkB * 12); + } + func_80026F44(D_801E3668.x + 12, D_801E3668.y + 5, D_801E2CFC[3], + -(D_801E8F38[0][0] != 0) & 7); + func_80026F44(D_801E3668.x + 12, D_801E3668.y + 0x11, D_801E2CFC[4], + -(D_801E8F3B != 0) & 7); + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + func_8001E040(&D_801E3668.x); + func_80026F44(10, 11, D_801E3260[4], 7); + temp_s2 = func_80026B70(D_801E3260[5]) + 0x10; + func_80026F44(190 - temp_s2 / 2, D_801E3668.h + 99, D_801E3260[5], 7); + func_80026F44(228 - temp_s2 / 2, D_801E3668.h + 112, D_801E2CFC[34], 7); + func_80026F44(228 - temp_s2 / 2, D_801E3668.h + 124, D_801E2CFC[35], 7); + func_8001EB2C( + 200 - temp_s2 / 2, 0x73 + D_801E3DEC[0].unkB * 12 + D_801E3668.h); + func_8001DE0C( + &sp38, 0xB6 - temp_s2 / 2, D_801E3668.h + 0x5D, temp_s2, 0x30); + func_8001E040(&sp38); + break; + case START_MENU_MODE_TITLE: + func_8001EB2C( + D_801E3668.x - 0x12, D_801E3668.y + 6 + D_801E3DEC[1].unkB * 12); + func_80026F44( + D_801E3668.x + 8, D_801E3668.y + 6, D_801E2CFC[32], 7); // new game + func_80026F44( + D_801E3668.x + 8, D_801E3668.y + 18, D_801E2CFC[10], + D_801E8F38[0][0] || D_801E8F38[1][0] ? 7 : 0); // continue? + rect.x = 0; + rect.y = 0; + rect.w = 0x100; + rect.h = 0x100; + func_80026A34(0, 1, 0x7F, &rect); + SetPolyFT4(D_80062F24.ft4); + D_80062F24.ft4->r0 = 0x60; + D_80062F24.ft4->g0 = 0x60; + D_80062F24.ft4->b0 = 0x60; + D_80062F24.ft4->x0 = 0x6F; + D_80062F24.ft4->y0 = 0x54; + D_80062F24.ft4->x1 = 0x119; + D_80062F24.ft4->y1 = 0x54; + D_80062F24.ft4->x2 = 0x6F; + D_80062F24.ft4->y2 = 0xEA; + D_80062F24.ft4->x3 = 0x119; + D_80062F24.ft4->y3 = 0xEA; + D_80062F24.ft4->u0 = 0; + D_80062F24.ft4->v0 = 0; + D_80062F24.ft4->u1 = 0x96; + D_80062F24.ft4->v1 = 0; + D_80062F24.ft4->u2 = 0; + D_80062F24.ft4->v2 = 0x96; + D_80062F24.ft4->u3 = 0x96; + D_80062F24.ft4->v3 = 0x96; + D_80062F24.ft4->clut = GetClut(0, 0x1E0); + D_80062F24.ft4->tpage = GetTPage(1, 0, 0x380, 0); + AddPrim(D_80062FC4, D_80062F24.ft4); + D_80062F24.ft4++; + break; + } + if (g_MenuStartMode != START_MENU_MODE_TITLE) { + func_80026F44(0x126, 11, D_801E2CFC[0], 7); + func_8001DE0C(&sp38, 0x116, 5, 0x56, 0x18); + func_8001E040(&sp38); + func_8001DE0C(&sp38, 0, 5, 0x16C, 0x18); + func_8001E040(&sp38); + } + if (!(func_8001F6B4() & 0xFF) && D_801E3D54 == 1) { + switch (g_MenuStartMode) { + case START_MENU_MODE_SELECT_SLOT: + if (D_80062D7C & 0x20) { + temp_v1_2 = D_801E3D80[0].unkB; + if (temp_v1_2 >= 2) { + break; + } + if (temp_v1_2 < 0) { + break; + } + if (D_801E8F38[temp_v1_2][0]) { + func_801D2B58(1); + if (D_801E8F38[D_801E3D80[0].unkB][2]) { + g_MenuStartMode = START_MENU_MODE_FORMAT_PROMPT; + func_80026448(&D_801E3D80[6], 0, 1, 1, 2, 0, 0, 1, 2, 0, + 0, 0, 1, 0); + } else { + D_801E3F18 = 10; + g_MenuStartMode = START_MENU_MODE_CHECKING_FILES; + D_801E3F20 = 0; + D_801E3F14 = 0; + D_80062F3C = 0; + D_801E3F1C = 1; + func_80026448(&D_801E3D80[1], 0, 0, 1, 3, 0, 0, 1, 15, + 0, 0, 0, 0, 0); + } + } else { + func_801D2B58(3); + func_8001F6C0(D_801E33B0, 7); + } + } else if (D_80062D7C & 0x40) { + func_801D2B58(4); + g_MenuStartMode = START_MENU_MODE_TITLE; + } else { + func_800264A8(&D_801E3D80[0]); + } + break; + case START_MENU_MODE_SELECT_FILE: + var_s1 = D_801E3D80[1].unkF; + func_801D2DA8(&D_801E3D80[1]); + if (!D_801E3D80[1].unkF && !var_s1) { + if ((u16)D_80062D7C & 0x20) { + if (((s32)D_80062F3C >> + (D_801E3D80[1].unkB + D_801E3D80[1].unk2)) & + 1) { + func_801D2B58(1); + g_MenuStartMode = START_MENU_MODE_LOADING; + D_801E3F18 = 10; + } else { + func_801D2B58(3); + } + } else if ((u16)D_80062D7C & 0x40) { + func_801D2B58(4); + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + } + } + break; + case START_MENU_MODE_CHECKING_FILES: + if (D_801E3F18 == 0) { + if (D_801E3F1C) { + D_801E3F18 = 0; + D_801E3F1C = 0; + D_80062F3C = func_801D1C2C(D_801E3D80[0].unkB); + } else { + var_s1 = 0; + if ((D_80062F3C >> D_801E3F20) & 1) { + var_s1 = func_801D3698(D_801E3D80[0].unkB, D_801E3F20); + } + D_801E3F20++; + if (var_s1) { + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + func_8001F6C0(D_801E33B0[8], 2); + func_801D2B58(3); + } + if (D_801E3F20 == 0xF) { + D_801E3F20 = 0xE; + g_MenuStartMode = START_MENU_MODE_CHECKING_WAIT; + D_801E3F18 = 10; + func_801D2B58(2); + } + } + } else { + D_801E3F18--; + } + break; + case START_MENU_MODE_CHECKING_WAIT: + if (D_801E3F18 == 0) { + g_MenuStartMode = START_MENU_MODE_SELECT_FILE; + } + D_801E3F18--; + break; + case START_MENU_MODE_LOADING: + if (D_801E3F18 != 0) { + D_801E3F18--; + break; + } + D_80062D99 = 1; + var_a0_3 = D_801E3D80[1].unkB + D_801E3D80[1].unk2; + if (D_801E3D80[0].unkB) { + var_a0_3 |= 0x10; + } + var_s1 = (s16)func_801D1F40(var_a0_3); + if (var_s1 == 0) { + if (Savemap.header.checksum != + (u16)func_801D1950( + sizeof(SaveWork) - 4, &Savemap.header.leader_level)) { + g_MenuStartMode = START_MENU_MODE_SELECT_FILE; + func_801D2B58(3); + func_8001F6C0(D_801E2CFC[31], 0); + } else { + func_801D2B58(0xD0); + D_801E3D54 = 2; + func_801D2D10(Savemap.config & 3); + } + } else { + g_MenuStartMode = START_MENU_MODE_SELECT_FILE; + func_801D2B58(3); + func_8001F6C0(D_801E2CFC[11], var_s1); + } + D_80062D99 = 0; + break; + case START_MENU_MODE_FORMAT_PROMPT: + func_800264A8(&D_801E3DEC[0]); + if (D_80062D7C & 0x20) { + if (D_801E3DEC[0].unkB == 0) { + if (D_801E3D80[0].unkB) { + temp_v1_2 = format("bu10:"); + } else { + temp_v1_2 = format("bu00:"); + } + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + if (temp_v1_2 == 1) { + D_801E8F38[D_801E3D80[0].unkB][2] = 0; + func_8001F6C0(D_801E2CFC[41], 7); + func_801D2B58(0xD0); + } else { + func_8001F6C0(D_801E3260[3], 7); + func_801D2B58(3); + } + } else { + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + func_801D2B58(4); + } + } else if (D_80062D7C & 0x40) { + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + func_801D2B58(4); + } + break; + case START_MENU_MODE_TITLE: + if (D_80062D7C & 0x20) { + switch (D_801E3D80[7].unkB) { + case 0: + func_801D2B58(0xD0); + D_801E3698 = 1; + D_801E3D54 = 2; + break; + case 1: + if (D_801E8F38[0][0] || D_801E8F3B) { + func_801D2B58(1); + func_80026448(&D_801E3D80[0], 0, 0, 1, 2, 0, 0, 1, 2, 0, + 0, 0, 1, 0); + g_MenuStartMode = START_MENU_MODE_SELECT_SLOT; + } else { + func_801D2B58(3); + } + break; + } + } else { + func_800264A8(D_801E3DFE); + } + break; + } + } + return D_801E3698; +} + +static void func_801D4C38(void) { + func_80025ED4(); + func_80025CD4(D_800756F8); + func_80025C94(D_801E3F2C); + func_80025BD0(D_801E8F44); + func_80025C54(D_801E4538); + func_801D1BA4(); + PutDispEnv(D_801E3EEC); + PutDrawEnv(D_801E3E34); +} + +// title screen loop +s32 func_801D4CC0(void) { + s32 i; + s32 ret; + + func_80021044(D_801E3E34, D_801E3EEC); + D_801E3D54 = 0; + func_801D39C4(); + D_801E3D58 = 0; + for (i = 0;; i++) { + func_8001CB48(); + func_800269C0(D_80077F64[D_801E3D58]); + D_801E3D5C = (u_long*)D_801E3D60[D_801E3D58]; + ClearOTag(D_801E3D5C, 1); + func_80026A00(D_801E3D5C); + func_8001F710(); + ret = func_801D3AB0(i); + if (D_801E3D54 == -1) { + break; + } + DrawSync(0); + VSync(0); + PutDispEnv(&D_801E3EEC[D_801E3D58]); + PutDrawEnv(&D_801E3E34[D_801E3D58]); + DrawOTag(D_801E3D5C); + D_801E3D58 ^= 1; // flip back buffer ID? + } + func_801D4C38(); + VSync(0); + PutDispEnv(&D_801E3EEC[1]); + PutDrawEnv(&D_801E3E34[1]); + for (i = 0; i < 3; i++) { + if (Savemap.partyID[i] != 0xFF) { + func_80020058(i); + func_8001786C((u8)i); + } + } + func_80017678(); + return ret; +} diff --git a/src/world/world.c b/src/world/world.c new file mode 100644 index 0000000..dff8f3b --- /dev/null +++ b/src/world/world.c @@ -0,0 +1,1293 @@ +//! PSYQ=3.3 CC1=2.6.3 +#include "world.h" + +typedef struct { + /* 0x00 */ s32 unk0; // aligns with Unk8010AD3C->unkC + /* 0x04 */ s32 unk4; // aligns with Unk8010AD3C->unk10 + /* 0x08 */ s32 unk8; // aligns with Unk8010AD3C->unk14 + /* 0x0C */ s32 unkC; // aligns with Unk8010AD3C->unk18 +} Unk800AA098; + +typedef struct { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; + /* 0x14 */ s32 unk14; + /* 0x18 */ s32 unk18; + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; + /* 0x24 */ s32 unk24; + /* 0x28 */ s32 unk28; + /* 0x2C */ s32 unk2C; + /* 0x30 */ s32 unk30; + /* 0x34 */ s32 unk34; + /* 0x38 */ s32 unk38; + /* 0x3C */ s32 unk3C; + /* 0x40 */ s32 unk40; + /* 0x44 */ s32 unk44; + /* 0x48 */ s16 unk48; + /* 0x4A */ s16 unk4A; + /* 0x4C */ s16 unk4C; + /* 0x4E */ s16 unk4E; + /* 0x50 */ s32 unk50; + /* 0x54 */ s32 unk54; + /* 0x58 */ s32 unk58; + /* 0x5C */ s8 unk5C; + /* 0x5D */ s8 unk5D; +} Unk8010AD3C; // size:??? + +typedef struct { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; + /* 0x14 */ s32 unk14; + /* 0x18 */ s32 unk18; + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; + /* 0x24 */ s32 unk24; + /* 0x28 */ s32 unk28; + /* 0x2C */ s32 unk2C; + /* 0x30 */ s32 unk30; + /* 0x34 */ s32 unk34; + /* 0x38 */ s32 unk38; + /* 0x3C */ s32 unk3C; + /* 0x40 */ s32 unk40; + /* 0x44 */ s32 unk44; + /* 0x48 */ s16 unk48; + /* 0x4A */ s16 unk4A; + /* 0x4C */ s16 unk4C; + /* 0x4E */ s16 unk4E; + /* 0x50 */ s8 unk50; +} Unk8010AD40; // size:??? + +typedef struct { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ s32 unkC; + /* 0x10 */ s32 unk10; + /* 0x14 */ s32 unk14; + /* 0x18 */ s32 unk18; + /* 0x1C */ s32 unk1C; + /* 0x20 */ s32 unk20; +} Unk8010B3B8; // size:??? + +void func_800A31C0(s16); +void func_800A368C(s32); +void func_800A6994(s32*, s32); +void func_800A8CE4(); +void func_800A8F74(); +void func_800A8FCC(); +void func_800A9110(); +s32 func_800A9154(); +s32 func_800A9174(); +s32 func_800A929C(); +s16 func_800A97A8(void); +void func_800A98A4(s32); +s32 func_800A98E4(void); +s32 func_800A99BC(); +s32 func_800A9A44(void); +void func_800AB8EC(s32); +void func_800ABA18(s32); +void func_800B5274(); +void func_800B63F0(s32); +void func_800B65E0(s32); +s32 func_800B7200(); +void func_800BB9A0(u8); +static void func_800BBA5C(void); +s32 func_800BBBB0(void); + +extern s32 D_800D05E8; +extern s32 D_800E5608; +extern s32 D_800E560C; +extern s32 D_800E5618; +extern s32 D_800E5628; +extern s32 D_800E5630; +extern s32 D_800E5634; +extern s32 D_800E5648; +extern s32 D_800E5654; +extern s32 D_800E5678; +extern MATRIX D_800E5698; +extern MATRIX D_800E56B8; +extern s32 D_800E5828; +extern s32 D_800E55EC; +extern s32 D_800E55FC; +extern s32 D_800E561C; +extern s32 D_800E5620; +extern s32 D_800E5624; +extern s32 D_800E5638; +extern s32 D_800E563C; +extern s32 D_800E5644; +extern s32 D_800E5658; +extern s32 D_800E566C; +extern s32 D_800E5674; +extern s16 D_800E56D8; +extern s32 D_800E56F4; +extern s32 D_800E5824; +extern s32 D_80109D58; +extern s32 D_8010C808; +extern s32 D_8010CAF0; +extern s16 D_8010CAFC; +extern s32 D_80109D54; +extern s32 D_80109D6C; +extern Unk8010AD3C* D_8010AD3C; +extern Unk8010AD40* D_8010AD40; +extern s32 D_8010AE54; +extern s32 D_8010B080; +extern s32 D_8010B174; +extern Unk8010B3B8* D_8010B3B8; +extern s32 D_8010B47C; +extern s32 D_80115A68; +extern s32 D_801159DC; +extern s32 D_801159E0; +extern s32 D_80115A60; +extern s32 D_8011626C; +extern s32 D_80116270; +extern s32 D_80116278; +extern s32 D_8011627C; +extern s32 D_80116280; +extern s32 D_80116284; +extern s8 D_801163E0; +extern s8* D_801163E8; +extern s32 D_801163D4; +extern s32 D_801163EC; +extern s16 D_801164F8; + +const char D_800A0000[] = "NEW "; +static const char D_800A0008[] = "OLD "; +static const char D_800A0010[] = "JUMP "; +static const char D_800A0018[] = "FROM "; +static const char D_800A0020[] = "SCR-H"; + +static void func_800A0B40(void) {} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0B48); + +static s32 func_800A0BD4(void) { return D_800D05E8; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0BE4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0C54); + +static void func_800A0D1C(void) { D_800E55EC = 0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0D2C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A12AC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1370); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A141C); + +static void func_800A16D0(s32 arg0) { D_800E5630 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A16E0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1710); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A19FC); + +static s32 func_800A1D04(void) { return D_800E5648; } + +s32 func_800A1D14(void) { return D_800E560C & 0xFFF; } + +static void func_800A1D24(s32 arg0) { D_800E5608 = arg0 & 0xFFF; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1D38); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1D54); + +static s32 func_800A1DB0(void) { return D_800E5618; } + +static s32 func_800A1DC0(void) { return D_800E5654; } + +static void func_800A1DD0(s32 arg0) { D_800E5654 = arg0; } + +static s32 func_800A1DE0(void) { return D_800E5634; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1DF0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1FAC); + +void func_800A2040(void) { + SetRotMatrix(&D_800E5698); + SetTransMatrix(&D_800E56B8); +} + +static s16 func_800A2078(void) { return D_800E56D8; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A2088); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A2108); + +s32 func_800A21A4(void) { return D_800E55FC; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A21B4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A31C0); + +s32 func_800A31E8(void) { return !D_800E5628; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A31F8); + +s32 func_800A32F4(void) { return D_800E5678; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3304); + +void func_800A368C(s32 arg0) { D_800E5658 = arg0; } + +static s32 func_800A369C(void) { return D_800E5658; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A36AC); + +void func_800A38C8(void) { + if (D_80071E34 == 1) { + func_800260DC(); + func_80026090(); + D_80071E34 = 0; + } +} + +void func_800A3908(void) { + s32 ret; + + do { + ret = func_800484A8(); + if (ret == -1) { + VSync(0); + } + } while (ret == -1); + if (ret) { + do { + } while (func_80048540(1)); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3964); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3C74); + +void func_800A3DFC(void) { + D_800E566C = 5; + D_800E5644 = 0x14; + func_800B7714(0); + func_800A2108(0, 0); + func_800B0098(0x10, 1); +} + +void func_800A3E4C(void) { + D_800E566C = 4; + D_800E5644 = -0x14; + func_800B7714(0); + func_800A2108(0, 0); + func_800B0098(0x10, 1); +} + +void func_800A3E9C(s32 arg0) { + func_800B7714(arg0); + D_800E566C = 8; +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3EC8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3F4C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4008); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4080); + +void func_800A40B8(s32 arg0) { + func_800A2088(arg0 & 3); + func_800BC9E8((arg0 >> 2) & 3); +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A40F0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4138); + +void func_800A41E8(s32 arg0) { + switch (arg0) { + case 1: + func_800A2108(0, 4); + func_800B0098(4, 1); + break; + case 4: + func_800A2108(1, 4); + func_800AFFBC(0x10, 1); + arg0 = 0; + break; + } + D_800E56F4 = arg0; +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4268); + +void func_800A4494(s32 arg0) { D_800E561C = arg0; } + +void func_800A44A4(s32 arg0) { D_800E5620 = arg0; } + +void func_800A44B4(s32 arg0) { D_800E5624 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A44C4); + +void func_800A45C4(s32 arg0) { D_800E5638 = arg0; } + +void func_800A45D4(s32 arg0) { D_800E563C = arg0; } + +void func_800A45E4(s32 arg0) { D_800E5674 = arg0; } + +s32 func_800A45F4(void) { return D_800E5674; } + +static void func_800A4604(void) {} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A460C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4DDC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4F08); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4F78); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5208); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A52A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5348); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A53A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A54F0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A57C8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5924); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5970); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A59A0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5A20); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5A94); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5AD8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5B88); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5C08); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5D00); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5E28); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A5FB4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A60D8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6168); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A63FC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A64AC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A67A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6884); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A692C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6994); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6B8C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6BCC); + +void func_800A6C00(s32 arg0) { + if (func_800A1DB0() != 2) { + func_800A1FAC(arg0); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6C3C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A6FC0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A71E8); + +static s32 func_800A7E7C(void) { return D_80109D6C; } + +static void func_800A7E8C(s32 arg0) { D_80109D6C = arg0; } + +static void func_800A7E9C(void) {} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A7EA4); + +void func_800A7F18(void) { func_800A7F38(); } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A7F38); + +static void func_800A8048(void) { D_800E5828 = 1; } + +static s32 func_800A805C(void) { return D_800E5828; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A806C); + +static void func_800A82DC(void) { D_80109D54 = 1; } + +s32 func_800A82F0(void) { return D_80109D58; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8300); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A835C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A86C4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A886C); + +void func_800A8888(s32 arg0) { D_800E5824 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8898); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A891C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8A1C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8A88); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8ABC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8AF4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8B30); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8C70); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8CA4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8CE4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8D58); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8E50); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8F48); + +void func_800A8F74(void) { + if (D_8010AD40) { + func_800A8AF4(D_8010AD40); + } +} + +void func_800A8FA0(void) { + if (D_8010AD3C) { + func_800A8AF4(D_8010AD3C); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8FCC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9018); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9064); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A90EC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9110); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9134); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9154); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9174); + +Unk8010AD3C* func_800A9194(void) { return D_8010AD3C; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A91A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A91E0); + +s32 func_800A921C(s32 arg0, u8 arg1) { + if (arg1 >= 0x20) { + return 0; + } + return (arg0 >> arg1) & 1; +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9240); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A929C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A92F8); + +static const s32 D_800A01D8[] = {0, 0xF000}; +static const s32 D_800A01E0[] = {0, 0}; +static const s32 D_800A01E8[] = {0, 0, 0, 0}; + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9334); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9480); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A94A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A94D0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A94F4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9520); + +void func_800A9678(s16 arg0) { func_800A9520(D_8010AD3C, arg0); } + +void func_800A96A4(s16 arg0) { func_800A9520(D_8010AD40, arg0); } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A96D0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A97A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A97E4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9820); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A984C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9878); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A98A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A98E4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9910); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A993C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9988); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A99BC); + +void func_800A9A04(s8 arg0) { + if (D_8010AD40) { + D_8010AD40->unk50 = arg0; + } +} + +void func_800A9A24(s16 arg0) { + if (D_8010AD40) { + D_8010AD40->unk4A = arg0; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9A44); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9A70); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9AA4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9AD0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9B04); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9C64); + +void func_800A9D5C(s32 arg0) { func_800A9C64(D_8010AD3C, arg0); } + +void func_800A9D88(s32 arg0) { func_800A9C64(D_8010AD40, arg0); } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9DB4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9E14); + +static void func_800AA02C(s32 arg0) { + if (D_8010AD40) { + D_8010AD40->unk10 = arg0; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA04C); + +static void func_800AA078(s16 arg0) { + if (D_8010AD40) { + D_8010AD40->unk4E = arg0; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA098); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA0E0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA128); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA170); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA1B8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA238); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA2B8); + +static void func_800AA2E4(s8 arg0) { + if (D_8010AD3C) { + D_8010AD3C->unk5D = arg0; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA304); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA580); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA640); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA684); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA6A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA6D0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA7DC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8D8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8F8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AAA00); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AAB18); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB36C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB398); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB48C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB4F4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB570); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB5E4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB6E4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB8EC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB92C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB988); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ABA18); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ABA78); + +static const s32 D_800A0260[] = {0, 0}; + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ABB24); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ABE58); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ABFC0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AC3C0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AC484); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AC700); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD63C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD788); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD804); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD928); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD970); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADA08); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADA64); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADB30); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADC3C); + +void func_800ADC70(void) { D_8010AE54 = 0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADC80); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADD4C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADE30); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADEA8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800ADFC0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE024); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE0BC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE180); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE47C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE4B8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE5B8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE5F0); + +s32 func_800AE628(void) { return D_8010B080; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE638); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AE8AC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AEA48); + +void func_800AF0A0(s32 arg0) { D_8010B174 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF0B0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF110); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF1A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF1E8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF24C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF2A4); + +static void func_800AF2E4(s32 arg0) { + if (D_8010B3B8) { + D_8010B3B8->unk1C = arg0; + } +} + +static void func_800AF304(s32 arg0) { + if (D_8010B3B8) { + D_8010B3B8->unk20 = arg0; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF324); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF364); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF3A4); + +s32 func_800AF96C(s32 arg0) { + if (D_8010B3B8) { + return func_800AE024(arg0, D_8010B3B8); + } + return 0; +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF9A0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF9DC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AFCC8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AFFBC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0098); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B017C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B01C4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0200); + +s32 func_800B0240(void) { return !D_8010B47C; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0250); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0334); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B04AC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0670); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B075C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0794); + +static s32 func_800B0800(void) { return D_8010C808; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0810); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0BF4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0D98); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0E84); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B104C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B10AC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B11C4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B1650); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B190C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B1C80); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B21E4); + +static void func_800B22E4(void) { func_800B190C(); } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2304); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2638); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B271C); + +static void func_800BBD0C(void); +void func_800B28CC(s32 arg0) { + s32 param; + + if (D_8010CAF0 != 3) { + if (arg0 != 1) { + param = 0x26; + if (arg0 == 2) { + param = 0x2A; + } + } else { + param = 0x29; + } + } else { + param = 4; + } + func_800A993C(param, arg0); + switch (D_8010CAF0) { + case 3: + func_800A8FA0(); + D_8010CAF0 = 0; + break; + case 1: + if (func_800A8F48() != 0) { + func_800A9110(); + func_800BBD0C(); + } else { + + func_800AB988(func_800A9154(), 5); + } + break; + case 2: + func_800A9018(); + func_800A8FA0(); + break; + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B29CC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2E90); + +static void func_800B2F94(s32 arg0) { D_8010CAF0 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2FA4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2FD0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3018); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3044); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B307C); + +static s16 func_800B32F0(void) { return D_8010CAFC; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3300); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3350); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B338C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3418); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B37E0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3828); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B392C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B39B4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3C40); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B40B4); + +static const s32 D_800A0768[] = {0, 0x28}; + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B4244); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B45DC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5274); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5314); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B579C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B57C0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B57DC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B58F8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B59F4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5C7C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5DD8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B5E28); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B624C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6348); + +static void func_800B63E0(s32 arg0) { D_801159DC = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B63F0); + +void func_800B64A0(void) { func_800B63F0(D_801159E0); } + +static s32 func_800B64C8(void) { return D_801159E0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B64D8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B650C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6570); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B65A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B65E0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B667C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6724); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B69A4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6A4C); + +void func_800B6AEC(void) { + if (D_80115A60 != 0) { + D_80115A60 = 0; + func_800ADD4C(2); + func_800B6A4C(); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6B28); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6C84); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6D10); + +void func_800B6DCC(void) { + if (D_80115A60 != 0) { + D_80115A60 = 0; + func_800ADD4C(2); + func_800B6D10(); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6E08); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6E78); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6EFC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7104); + +void func_800B7134(void) { + func_8003408C(); + D_80115A60 = 0; +} + +static void func_800B715C(s32 arg0) { D_80115A68 = arg0; } + +static s32 func_800B716C(void) { return D_80115A68; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B717C); + +s32 func_800B7200(void) { + if (D_8009D288[0] >= 0x3E8 && D_8009D288[0] < 0x4B0) { + return 1; + } + return 0; +} + +static u8 func_800B7218(void) { return D_8009D686; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7228); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7480); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7620); + +void func_800B76A8(void) { + u32 var_a0; + + var_a0 = D_8009D685; + if (var_a0 >= 3) { + if (var_a0 >= 0x2B) { + func_800A993C(0x13); + func_800BBA5C(); + var_a0 = 3; + } + func_800A993C(var_a0); + func_800BBA5C(); + func_800A31C0(func_800A97A8()); + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7714); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B77A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B77F4); + +void func_800B7820(void) { + D_80116278 = 0; + D_8009D2E7 = 0; +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7838); + +s32 func_800B785C(void) { return D_8011626C; } + +s32 func_800B786C(void) { return D_80116270; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B787C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B79B8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7A40); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7AC0); + +void func_800B7B1C(u8 arg0) { D_8009D684 = arg0; } + +static u8 func_800B7B2C(void) { return D_8009D684; } + +u16 func_800B7B3C(void) { return (D_800707BE >> 3) & 1; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7B54); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7B78); + +u8 func_800B7BA0(void) { return D_80062F1B >> 7; } + +static u8 func_800B7BB0(void) { return D_80062F1A; } + +u8 func_800B7BC0(void) { return D_8009D40D & 1; } + +static s32 func_800B7BD0(void) { return 1; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7BD8); + +static s32 func_800B7C14(void) { return 1; } + +static void func_800B7C44(void); + +void func_800B7C1C(void) { + D_80116284 = 0; + func_800B7C44(); +} + +static void func_800B7C44(void) { D_8011627C = -0x8C; } + +static void func_800B7C58(void) { D_8011627C = -0x1E; } + +static void func_800B7C6C(s32 arg0) { D_80116280 = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7C7C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B832C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8488); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B84D8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B851C); + +static s32 func_800B857C(void) { return D_800832A0 != 0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B858C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B85D4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B86C4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B86E8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8720); + +static void func_800B8750(void) {} + +static void func_800B8758(void) {} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8760); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B87D8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B89C4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8A5C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8A98); + +static const char D_800A090C[] = "win limit x="; +static const char D_800A091C[] = "win limit y="; + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8B00); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8CBC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8D20); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8D4C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B90C0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B95E8); + +static const char D_800A09AC[] = "No mes data!"; +static const char D_800A09BC[] = "mes busy="; + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B962C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B98F0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B9B2C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BA938); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BAA00); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BAB60); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BAC70); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BAE60); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB350); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB450); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB568); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB650); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB7DC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB8B0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB8E8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB9A0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB9D0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BBA0C); + +static void func_800BBA34(s8 arg0) { D_801163E0 = arg0; } + +s32 func_800BBA44(void) { return (u32)&D_801163E0 < (u32)D_801163E8; } + +static void func_800BBA5C(void) { + s32 sp10[3]; + s32 var_a1; + s32 var_s0; + + if (func_800A9174() == 5 && D_801163EC) { + func_800A98A4(1); + func_800A368C(1); + return; + } + if (func_800A99BC()) { + func_800AA098(sp10); + func_800A6994(sp10, func_800A9154() == 3 ? -1 : 1); + func_800BB9A0(func_800A9174()); + if (func_800A929C()) { + func_800A8CE4(); + func_800B63F0(2); + return; + } + func_800A8FCC(); + func_800A8F74(); + func_800A9110(); + switch (func_800A9174()) { + case 3: + func_800A98A4(1); + func_800A368C(1); + func_800B5274(); + if (func_800B64C8() < 6) { + func_800B63F0(func_800B7200() ? 1 : 3); + } + break; + case 6: + func_800B65E0(0x1EC); + break; + } + } +} + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BBBB0); + +void func_800BBC4C(void) { + s32 temp_s0; + + temp_s0 = func_800A9174(); + if (D_801163D4 == 0) { + if (func_800BBBB0() != 0) { + if ((temp_s0 == 3) || ((temp_s0 == 5) && (func_800A98E4() != 0))) { + func_800A368C(-1); + } else { + func_800A2108(0, 2); + } + D_801163D4 = 1; + if ((u32)(temp_s0 - 3) < 2U) { + func_800AB8EC(1); + } + } + if (func_800A9A44() == 0x1B) { + func_800ABA18(9); + } + } +} + +static void func_800BBD0C(void) { D_801163D4 = 1; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BBD20); + +static s32 func_800BC1AC(void) { return D_801163D4; } + +static void func_800BC1BC(s32 arg0) { D_801163EC = arg0; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BC1CC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BC420); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BC9E8); + +s16 func_800BCA38(void) { return D_801164F8; } + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BCA48); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BCA78); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BCB2C); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BCBE8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BCECC); diff --git a/src/world/world.h b/src/world/world.h new file mode 100644 index 0000000..9a6bcf5 --- /dev/null +++ b/src/world/world.h @@ -0,0 +1 @@ +#include diff --git a/src/world/world2.c b/src/world/world2.c new file mode 100644 index 0000000..60f230b --- /dev/null +++ b/src/world/world2.c @@ -0,0 +1,41 @@ +#include "world.h" + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800BFBF0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800BFCAC); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C02F4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C0808); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C08A8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C0B48); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C1490); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C1D58); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C1FD8); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C2130); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C2450); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C2524); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C31F0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C3948); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C3DB0); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C4148); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C4FB4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C5CD4); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C6104); + +INCLUDE_ASM("asm/us/world/nonmatchings/world2", func_800C6598); diff --git a/tools/asm-differ b/tools/asm-differ new file mode 160000 index 0000000..4eb23bc --- /dev/null +++ b/tools/asm-differ @@ -0,0 +1 @@ +Subproject commit 4eb23bcd4bbeab81c16535c6318389e0c55584f7 diff --git a/tools/builder/builder/build.go b/tools/builder/builder/build.go new file mode 100644 index 0000000..9c677a4 --- /dev/null +++ b/tools/builder/builder/build.go @@ -0,0 +1,90 @@ +package builder + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/goccy/go-yaml" + "github.com/xeeynamo/ff7-decomp/tools/builder/deps" +) + +func Build(version string) error { + data, _ := os.ReadFile(ConfigPath(version)) + var b BuildConfig + if err := yaml.Unmarshal(data, &b); err != nil { + panic(err) + } + if err := writeObjdiffConfig(b); err != nil { + return err + } + if err := os.MkdirAll(b.BuildPath, 0755); err != nil { + return err + } + if err := writeSplatConfigs(b); err != nil { + return err + } + if err := writeSha1Check(b); err != nil { + return err + } + if err := deps.GenNinja(b.BuildPath); err != nil { + return err + } + if err := deps.Ninja(); err != nil { + return err + } + if err := generateExpected(); err != nil { + return err + } + return nil +} + +func writeSplatConfigs(b BuildConfig) error { + for _, o := range b.Overlays { + expectedFingerprint := o.Fingerprint() + actualFingerprint, _ := os.ReadFile(fmt.Sprintf("%s/%s.fingerprint", b.BuildPath, o.Name)) + if actualFingerprint != nil && bytes.Equal(expectedFingerprint, actualFingerprint) { + continue + } + splatConfig, err := makeSplatConfig(b, o) + if err != nil { + return err + } + data, err := yaml.Marshal(&splatConfig) + if err != nil { + return err + } + if err := os.WriteFile(fmt.Sprintf("%s/%s.yaml", b.BuildPath, o.Name), data, 0644); err != nil { + return err + } + if err := os.WriteFile(fmt.Sprintf("%s/%s.fingerprint", b.BuildPath, o.Name), expectedFingerprint, 0644); err != nil { + return err + } + } + return nil +} + +func writeSha1Check(b BuildConfig) error { + var sb strings.Builder + for _, o := range b.Overlays { + sb.WriteString(fmt.Sprintf("%s %s\n", o.Sha1, filepath.Join(b.BuildPath, o.Name+".exe"))) + } + return os.WriteFile(filepath.Join(b.BuildPath, "check.sha1"), []byte(sb.String()), 0644) +} + +func generateExpected() error { + if err := os.MkdirAll("expected/build", 0o755); err != nil { + return fmt.Errorf("mkdir: %w", err) + } + if err := os.RemoveAll("expected/build"); err != nil { + return fmt.Errorf("remove: %w", err) + } + cmd := exec.Command("cp", "-r", "build", "expected/") + if err := cmd.Run(); err != nil { + return fmt.Errorf("%s: %w", strings.Join(cmd.Args, " "), err) + } + return nil +} diff --git a/tools/builder/builder/clean.go b/tools/builder/builder/clean.go new file mode 100644 index 0000000..fe94769 --- /dev/null +++ b/tools/builder/builder/clean.go @@ -0,0 +1,37 @@ +package builder + +import ( + "os" + "path/filepath" + + "github.com/xeeynamo/ff7-decomp/tools/builder/deps" + "golang.org/x/sync/errgroup" +) + +func Clean(version string) error { + if version == "" { + version = Version() + } + var eg errgroup.Group + eg.Go(func() error { + return deps.Git( + "clean", "-Xfd", + filepath.Join("asm", version), + filepath.Join("build", version), + "config") + }) + eg.Go(func() error { + for _, path := range []string{ + ".ninja_deps", + ".ninja_log", + "build.ninja", + "objdiff.json", + } { + if err := os.RemoveAll(path); err != nil { + return err + } + } + return nil + }) + return eg.Wait() +} diff --git a/tools/builder/builder/config.go b/tools/builder/builder/config.go new file mode 100644 index 0000000..97e57af --- /dev/null +++ b/tools/builder/builder/config.go @@ -0,0 +1,46 @@ +package builder + +import ( + "crypto/md5" + "fmt" + "path/filepath" +) + +type Overlay struct { + Name string `yaml:"name"` + DiskPath string `yaml:"disk_path"` + Compression string `yaml:"compression"` + Sha1 string `yaml:"sha1"` + Sha1Decompressed string `yaml:"sha1_decompressed"` + BasePath string `yaml:"base_path"` + SymbolAddrsPath []string `yaml:"symbol_addrs_path"` + MigrateRodataToFunctions bool `yaml:"migrate_rodata_to_functions"` + VramStart int64 `yaml:"vram_start"` + GPValue int64 `yaml:"gp_value"` + BssSize int64 `yaml:"bss_size"` + Segments [][]any `yaml:"segments"` +} + +type BuildConfig struct { + Version string `yaml:"version"` + BuildPath string `yaml:"build_path"` + AsmPath string `yaml:"asm_path"` + AssetPath string `yaml:"asset_path"` + SrcPath string `yaml:"src_path"` + LdScriptPath string `yaml:"ld_script_path"` + GeneratedSymPath string `yaml:"generated_sym_path"` + Align int `yaml:"align"` + Overlays []Overlay `yaml:"overlays"` +} + +func (o Overlay) Fingerprint() []byte { + sum := md5.Sum([]byte(fmt.Sprintf("%v", o))) + return sum[:] +} + +func ConfigPath(version string) string { + if version == "" { + version = Version() + } + return filepath.Join("config", version+".yaml") +} diff --git a/tools/builder/builder/objdiff.go b/tools/builder/builder/objdiff.go new file mode 100644 index 0000000..ac1a220 --- /dev/null +++ b/tools/builder/builder/objdiff.go @@ -0,0 +1,143 @@ +package builder + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "strconv" + "strings" +) + +// https://raw.githubusercontent.com/encounter/objdiff/refs/heads/main/config.schema.json + +type objdiffMetadata struct { + Complete bool `json:"complete"` + ReverseFnOrder bool `json:"reverse_fn_order"` + SourcePath string `json:"source_path,omitempty"` + ProgressCategories []string `json:"progress_categories,omitempty"` + AutoGenerated bool `json:"auto_generated"` +} + +type objdiffUnit struct { + Name string `json:"name,omitempty"` + Path string `json:"path,omitempty"` + TargetPath string `json:"target_path,omitempty"` + BasePath string `json:"base_path,omitempty"` + ReverseFnOrder bool `json:"reverse_fn_order"` + Complete bool `json:"complete"` + Metadata objdiffMetadata `json:"metadata"` +} + +type objdiffProgressCategory struct { + ID string `json:"id"` + Name string `json:"name,omitempty"` +} + +type objdiffConfig struct { + CustomMake string `json:"custom_make,omitempty"` + BaseDir string `json:"base_dir,omitempty"` + BuildBase bool `json:"build_base"` + TargetDir string `json:"target_dir,omitempty"` + BuildTarget bool `json:"build_target"` + WatchPatterns []string `json:"watch_patterns,omitempty"` + IgnorePatterns []string `json:"ignore_patterns,omitempty"` + Units []objdiffUnit `json:"units,omitempty"` + ProgressCategory []objdiffProgressCategory `json:"progress_categories,omitempty"` +} + +func makeObjdiffConfig(b BuildConfig) objdiffConfig { + var units []objdiffUnit + var categories []objdiffProgressCategory + for _, o := range b.Overlays { + srcDir := filepath.Join(b.SrcPath, o.BasePath) + asmDir := filepath.Join(b.AsmPath, o.BasePath) + categories = append(categories, objdiffProgressCategory{ + ID: o.Name, + }) + for _, src := range o.Segments { + if len(src) < 2 { + continue + } + cat, ok := src[1].(string) + if !ok { + continue + } + name := "" + if len(src) >= 3 { + if n, ok := src[2].(string); ok { + name = n + } + } + if name == "" { + if v, ok := src[0].(uint64); ok { + name = strconv.FormatInt(int64(v), 16) + name = strings.ToUpper(name) + } + } + if name == "" { + panic("bug") + } + switch cat { + case "c": + srcFile := filepath.Join(srcDir, name+".c") + objFile := filepath.Join(b.BuildPath, srcFile+".o") + units = append(units, objdiffUnit{ + Name: fmt.Sprintf("%s/%s", o.Name, name), + BasePath: objFile, + TargetPath: targetPath(objFile), + Metadata: objdiffMetadata{ + SourcePath: srcFile, + ProgressCategories: []string{o.Name}, + }, + }) + case "data": + fallthrough + case "sbss": + fallthrough + case "bss": + asmFile := filepath.Join(asmDir, "data", fmt.Sprintf("%s.%s.s", name, cat)) + objFile := filepath.Join(b.BuildPath, asmFile+".o") + units = append(units, objdiffUnit{ + Name: fmt.Sprintf("%s/%s_%s", o.Name, name, cat), + BasePath: objFile, + TargetPath: targetPath(objFile), + Metadata: objdiffMetadata{ + SourcePath: asmFile, + ProgressCategories: []string{o.Name}, + }, + }) + } + } + } + return objdiffConfig{ + CustomMake: "ninja", + BaseDir: b.BuildPath, + BuildBase: true, + TargetDir: targetPath(b.BuildPath), + BuildTarget: false, + WatchPatterns: []string{ + "include/**.h", + "src/**.c", + "src/**.h", + }, + IgnorePatterns: []string{ + "build/**/*", + }, + Units: units, + ProgressCategory: categories, + } +} + +func writeObjdiffConfig(b BuildConfig) error { + data, err := json.Marshal(makeObjdiffConfig(b)) + if err != nil { + return err + } + return os.WriteFile("objdiff.json", data, 0644) +} + +func targetPath(path string) string { + path = strings.Replace(path, "report/", "", 1) + return filepath.Join("expected", path) +} diff --git a/tools/builder/builder/report.go b/tools/builder/builder/report.go new file mode 100644 index 0000000..548361f --- /dev/null +++ b/tools/builder/builder/report.go @@ -0,0 +1,39 @@ +package builder + +import ( + "os" + "path/filepath" + + "github.com/goccy/go-yaml" + "github.com/xeeynamo/ff7-decomp/tools/builder/deps" +) + +func Report(version string, outputFile string) error { + data, _ := os.ReadFile(ConfigPath(version)) + var b BuildConfig + if err := yaml.Unmarshal(data, &b); err != nil { + panic(err) + } + b.BuildPath = filepath.Join("report", b.BuildPath) + if err := os.MkdirAll(b.BuildPath, 0755); err != nil { + return err + } + if err := writeObjdiffConfig(b); err != nil { + return err + } + if err := writeSplatConfigs(b); err != nil { + return err + } + if err := writeSha1Check(b); err != nil { + return err + } + _ = os.Setenv("FF7_PROGRESS_REPORT", "1") + if err := deps.GenNinja(b.BuildPath); err != nil { + return err + } + _ = os.Unsetenv("FF7_PROGRESS_REPORT") + if err := deps.Ninja(); err != nil { + return err + } + return deps.ObjdiffCLI("report", "generate", "-o", outputFile) +} diff --git a/tools/builder/builder/splat.go b/tools/builder/builder/splat.go new file mode 100644 index 0000000..6cd8840 --- /dev/null +++ b/tools/builder/builder/splat.go @@ -0,0 +1,125 @@ +package builder + +import ( + "fmt" + "os" + "path/filepath" + "strings" +) + +type SplatOptions struct { + Platform string `yaml:"platform"` + Basename string `yaml:"basename"` + BasePath string `yaml:"base_path"` + BuildPath string `yaml:"build_path"` + TargetPath string `yaml:"target_path"` + AsmPath string `yaml:"asm_path"` + AssetPath string `yaml:"asset_path"` + SrcPath string `yaml:"src_path"` + LdScriptPath string `yaml:"ld_script_path"` + Compiler string `yaml:"compiler"` + SymbolAddrsPath []string `yaml:"symbol_addrs_path"` + CreateUndefinedFuncsAuto bool `yaml:"create_undefined_funcs_auto"` + UndefinedFuncsAutoPath string `yaml:"undefined_funcs_auto_path"` + CreateUndefinedSymsAuto bool `yaml:"create_undefined_syms_auto"` + UndefinedSymsAutoPath string `yaml:"undefined_syms_auto_path"` + FindFileBoundaries bool `yaml:"find_file_boundaries"` + UseLegacyIncludeAsm bool `yaml:"use_legacy_include_asm"` + AsmJtblLabelMacro string `yaml:"asm_jtbl_label_macro,omitempty"` + MigrateRodataToFunctions bool `yaml:"migrate_rodata_to_functions"` + DisassembleAll bool `yaml:"disassemble_all"` + GlobalVramStart int64 `yaml:"global_vram_start"` + GPValue int64 `yaml:"gp_value,omitempty"` + SectionOrder []string `yaml:"section_order"` + LdGenerateSymbolPerDataSegment bool `yaml:"ld_generate_symbol_per_data_segment"` + LdBssIsNoLoad bool `yaml:"ld_bss_is_noload"` +} + +type SplatSegment struct { + Name string `yaml:"name"` + Type string `yaml:"type"` + Start int `yaml:"start"` + Vram int64 `yaml:"vram"` + BssSize int64 `yaml:"bss_size,omitempty"` + Align int `yaml:"align"` + Subalign int `yaml:"subalign"` + Subsegments [][]any `yaml:"subsegments"` +} + +type SplatConfig struct { + Options SplatOptions `yaml:"options"` + Sha1 string `yaml:"sha1"` + Segments []any `yaml:"segments"` +} + +func makeSplatConfig(b BuildConfig, o Overlay) (SplatConfig, error) { + getRootDir := func(path string) string { + if path == "" { + return "." + } + parts := strings.Split(filepath.Clean(path), string(filepath.Separator)) + var ups []string + for _, p := range parts { + if p != "" { + ups = append(ups, "..") + } + } + if len(ups) == 0 { + return "." + } + return filepath.Join(ups...) + } + stat, err := os.Stat(o.DiskPath) + if err != nil { + return SplatConfig{}, err + } + start := 0 + var segments []any + if o.Name == "main" { + start = 0x800 + header := []any{0x800, "header"} + segments = append(segments, header) + } + seg := SplatSegment{ + Name: o.Name, + Type: "code", + Start: start, + Vram: o.VramStart, + BssSize: o.BssSize, + Align: b.Align, + Subalign: b.Align, + Subsegments: o.Segments, + } + segments = append(segments, seg) + segments = append(segments, []int64{stat.Size()}) + return SplatConfig{ + Sha1: o.Sha1, + Options: SplatOptions{ + Platform: "psx", + Compiler: "GCC", + Basename: o.Name, + BasePath: getRootDir(b.BuildPath), + BuildPath: b.BuildPath, + TargetPath: o.DiskPath, + AsmPath: filepath.Join(b.AsmPath, o.BasePath), + AssetPath: filepath.Join(b.AssetPath, o.BasePath), + SrcPath: filepath.Join(b.SrcPath, o.BasePath), + LdScriptPath: filepath.Join(b.LdScriptPath, fmt.Sprintf("%s.ld", o.Name)), + SymbolAddrsPath: o.SymbolAddrsPath, + CreateUndefinedFuncsAuto: true, + UndefinedFuncsAutoPath: filepath.Join(b.GeneratedSymPath, fmt.Sprintf("undefined_funcs.%s.txt", o.Name)), + CreateUndefinedSymsAuto: true, + UndefinedSymsAutoPath: filepath.Join(b.GeneratedSymPath, fmt.Sprintf("undefined_syms.%s.txt", o.Name)), + FindFileBoundaries: false, + UseLegacyIncludeAsm: false, + MigrateRodataToFunctions: o.MigrateRodataToFunctions, + DisassembleAll: o.Name == "main", // for some reason, `main` doesn't build without + GlobalVramStart: o.VramStart, + GPValue: o.GPValue, + SectionOrder: []string{".rodata", ".text", ".data", ".sdata", ".bss"}, + LdGenerateSymbolPerDataSegment: true, + LdBssIsNoLoad: o.Name != "main" && o.BssSize > 0, + }, + Segments: segments, + }, nil +} diff --git a/tools/builder/builder/version.go b/tools/builder/builder/version.go new file mode 100644 index 0000000..f8772d5 --- /dev/null +++ b/tools/builder/builder/version.go @@ -0,0 +1,11 @@ +package builder + +import "os" + +func Version() string { + version := os.Getenv("VERSION") + if version == "" { + return "us" + } + return version +} diff --git a/tools/builder/cmd/build.go b/tools/builder/cmd/build.go new file mode 100644 index 0000000..a7e966a --- /dev/null +++ b/tools/builder/cmd/build.go @@ -0,0 +1,24 @@ +package cmd + +import "github.com/spf13/cobra" +import "github.com/xeeynamo/ff7-decomp/tools/builder/builder" + +var buildCmd = &cobra.Command{ + Use: "build [version]", + Short: "Builds the game binaries with the support of the original game files", + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + var version string + if len(args) > 0 { + version = args[0] + } + if err := builder.Build(version); err != nil { + return err + } + return nil + }, +} + +func init() { + rootCmd.AddCommand(buildCmd) +} diff --git a/tools/builder/cmd/clean.go b/tools/builder/cmd/clean.go new file mode 100644 index 0000000..e9962e6 --- /dev/null +++ b/tools/builder/cmd/clean.go @@ -0,0 +1,24 @@ +package cmd + +import "github.com/spf13/cobra" +import "github.com/xeeynamo/ff7-decomp/tools/builder/builder" + +var cleanCmd = &cobra.Command{ + Use: "clean [version]", + Short: "Clean all generated build files", + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + var version string + if len(args) > 0 { + version = args[0] + } + if err := builder.Clean(version); err != nil { + return err + } + return nil + }, +} + +func init() { + rootCmd.AddCommand(cleanCmd) +} diff --git a/tools/builder/cmd/decompile.go b/tools/builder/cmd/decompile.go new file mode 100644 index 0000000..2939db0 --- /dev/null +++ b/tools/builder/cmd/decompile.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/deps" +) + +var ( + fixStructs bool +) + +var decompileCmd = &cobra.Command{ + Use: "dec ", + Short: "Replaces INCLUDE_ASM with approximated decompiled function", + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + if fixStructs { + args = append(args, "--fix-structs") + } + if err := deps.Decompile(args...); err != nil { + return err + } + return nil + }, +} + +func init() { + decompileCmd.Flags().BoolVar(&fixStructs, "fix-structs", false, "Replace D_8009XXXX symbols with Savemap.field_name references") + rootCmd.AddCommand(decompileCmd) +} diff --git a/tools/builder/cmd/format.go b/tools/builder/cmd/format.go new file mode 100644 index 0000000..685bd09 --- /dev/null +++ b/tools/builder/cmd/format.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/format" +) + +var formatCmd = &cobra.Command{ + Use: "format", + Short: "Format all code base", + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + if err := format.Format(); err != nil { + return err + } + return nil + }, +} + +func init() { + rootCmd.AddCommand(formatCmd) +} diff --git a/tools/builder/cmd/rank.go b/tools/builder/cmd/rank.go new file mode 100644 index 0000000..cde821b --- /dev/null +++ b/tools/builder/cmd/rank.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/rank" +) + +var rankCmd = &cobra.Command{ + Use: "rank ", + Short: "Rank non-decompiled functions from easiest to hardest", + SilenceErrors: true, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + if err := rank.Rank(args[0], 0); err != nil { + return err + } + return nil + }, +} + +func init() { + rootCmd.AddCommand(rankCmd) +} diff --git a/tools/builder/cmd/report.go b/tools/builder/cmd/report.go new file mode 100644 index 0000000..c0f273a --- /dev/null +++ b/tools/builder/cmd/report.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/builder" +) + +var reportCmd = &cobra.Command{ + Use: "report ", + Short: "Generates a progress report", + SilenceErrors: true, + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + if err := builder.Report(args[0], args[1]); err != nil { + return err + } + return nil + }, +} + +func init() { + rootCmd.AddCommand(reportCmd) +} diff --git a/tools/builder/cmd/root.go b/tools/builder/cmd/root.go new file mode 100644 index 0000000..eb4b054 --- /dev/null +++ b/tools/builder/cmd/root.go @@ -0,0 +1,16 @@ +package cmd + +import "github.com/spf13/cobra" + +var rootCmd = &cobra.Command{ + Short: "FF7 Decomp orchestrator", + Long: "Wraps all the tooling with a clear and simple interface", +} + +func init() { + cobra.OnInitialize(func() {}) +} + +func Execute() error { + return rootCmd.Execute() +} diff --git a/tools/builder/cmd/symbols.go b/tools/builder/cmd/symbols.go new file mode 100644 index 0000000..56f4c6b --- /dev/null +++ b/tools/builder/cmd/symbols.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var symbolsCmd = &cobra.Command{ + Use: "symbols", + Short: "Manage project symbols", + SilenceErrors: true, + RunE: func(cmd *cobra.Command, args []string) error { + return nil + }, +} + +func init() { + rootCmd.AddCommand(symbolsCmd) +} diff --git a/tools/builder/cmd/symbolsadd.go b/tools/builder/cmd/symbolsadd.go new file mode 100644 index 0000000..628680b --- /dev/null +++ b/tools/builder/cmd/symbolsadd.go @@ -0,0 +1,57 @@ +package cmd + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/builder" + "github.com/xeeynamo/ff7-decomp/tools/builder/symbols" + "github.com/xeeynamo/ff7-decomp/tools/builder/utils" +) + +var ( + rebuild bool +) + +var symbolsAddCmd = &cobra.Command{ + Use: "add 0x [size]", + Short: "Add a new symbol", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 3 { + return fmt.Errorf("requires at least 3 arguments: 0x") + } + if !strings.HasPrefix(args[2], "0x") { + return fmt.Errorf("offset must be hexadecimal and start with 0x") + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + offset, err := utils.ParseDigit(args[2]) + if err != nil { + return err + } + size, err := utils.ParseDigit(args[3]) + if err != nil { + return err + } + if err := symbols.Add(args[0], args[1], uint32(offset), int(size)); err != nil { + return fmt.Errorf("failed adding symbol: %w", err) + } + if rebuild { + if err := builder.Clean(""); err != nil { + return fmt.Errorf("clean: %w", err) + } + if err := builder.Build(""); err != nil { + return fmt.Errorf("build: %w", err) + } + } + return nil + }, +} + +func init() { + symbolsAddCmd.Flags().BoolVar(&rebuild, "rebuild", false, + "Run build clean + build after adding symbol") + symbolsCmd.AddCommand(symbolsAddCmd) +} diff --git a/tools/builder/cmd/symbolssort.go b/tools/builder/cmd/symbolssort.go new file mode 100644 index 0000000..2e699f8 --- /dev/null +++ b/tools/builder/cmd/symbolssort.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/xeeynamo/ff7-decomp/tools/builder/symbols" +) + +var symbolsSortCmd = &cobra.Command{ + Use: "sort ", + Short: "Sort symbols", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + if err := symbols.Sort(args[0]); err != nil { + panic(err) + } + }, +} + +func init() { + symbolsCmd.AddCommand(symbolsAddCmd) +} diff --git a/tools/builder/deps/certs.go b/tools/builder/deps/certs.go new file mode 100644 index 0000000..303229f --- /dev/null +++ b/tools/builder/deps/certs.go @@ -0,0 +1,25 @@ +package deps + +import ( + "crypto/sha256" + "fmt" + "path/filepath" +) + +var certs = map[string]string{ + "clang-format.gz": "8d81075ea13dcfc5c1b1223cf141f4bc534fd52eb64c27d9c96aa7a85053a57c", + "objdiff-cli-linux-x86_64": "6317ffdc0145709955ebb2dff6beca1b54752d4598829418881b44b1666059a8", +} + +func verify(path string) error { + base := filepath.Base(path) + expectedSum, ok := certs[base] + if !ok { + return fmt.Errorf("verification failed for %s: %s", base, "not found") + } + actualSum := fmt.Sprintf("%x", sha256.Sum256([]byte(path))) + if actualSum != expectedSum { + return fmt.Errorf("checksum mismatch: %s", actualSum) + } + return nil +} diff --git a/tools/builder/deps/exec.go b/tools/builder/deps/exec.go new file mode 100644 index 0000000..52e34b0 --- /dev/null +++ b/tools/builder/deps/exec.go @@ -0,0 +1,122 @@ +package deps + +import ( + "bytes" + "fmt" + "os" + "os/exec" + "path/filepath" +) + +func ObjdiffCLI(args ...string) error { + binPath := "bin/objdiff-cli-linux-x86_64" + if err := downloadFromGithubIfNotExists("encounter/objdiff", "v3.3.1", filepath.Base(binPath), binPath); err != nil { + return err + } + return (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath}, args...), + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run() +} + +func ObjdiffGUI(args ...string) error { + binPath := "bin/objdiff-linux-x86_64" + if err := downloadFromGithubIfNotExists("encounter/objdiff", "v3.3.1", filepath.Base(binPath), binPath); err != nil { + return err + } + cmd := &exec.Cmd{ + Path: binPath, + Args: []string{binPath, "--project-dir", "."}, + } + cmdSetDetached(cmd) + return cmd.Start() +} + +func Git(args ...string) error { + binPath, err := exec.LookPath("git") + if err != nil { + return err + } + stderr := bytes.NewBuffer(nil) + if err := (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath}, args...), + Stderr: stderr, + }).Run(); err != nil { + return fmt.Errorf("git: %v\n%s", err, stderr.Bytes()) + } + return nil +} + +func Decompile(args ...string) error { + binPath, err := venvPython() + if err != nil { + return err + } + return (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath, "tools/decompile.py"}, args...), + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run() +} + +func GenNinja(args ...string) error { + binPath, err := venvPython() + if err != nil { + return err + } + return (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath, "tools/ninja/gen.py"}, args...), + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run() +} + +func Ninja(args ...string) error { + binPath, err := exec.LookPath("ninja") + if err != nil { + return err + } + return (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath}, args...), + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run() +} + +func Black(args ...string) error { + binPath, err := venvPython() + if err != nil { + return err + } + blackPath := filepath.Join(filepath.Dir(binPath), "black") + if _, err := os.Stat(blackPath); os.IsNotExist(err) { + if err := pip("install", "black"); err != nil { + return err + } + } + return (&exec.Cmd{ + Path: blackPath, + Args: append([]string{binPath, "tools/ninja/gen.py"}, args...), + }).Run() +} + +func ClangFormat(args ...string) error { + binPath := "bin/clang-format" + if err := downloadFromGithubIfNotExists("Xeeynamo/ff7-decomp", "init", filepath.Base(binPath)+".gz", binPath); err != nil { + return err + } + return (&exec.Cmd{ + Path: binPath, + Args: append([]string{binPath}, args...), + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run() +} diff --git a/tools/builder/deps/exec_unix.go b/tools/builder/deps/exec_unix.go new file mode 100644 index 0000000..02bb74b --- /dev/null +++ b/tools/builder/deps/exec_unix.go @@ -0,0 +1,14 @@ +//go:build !windows + +package deps + +import ( + "os/exec" + "syscall" +) + +func cmdSetDetached(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{ + Setsid: true, + } +} diff --git a/tools/builder/deps/exec_windows.go b/tools/builder/deps/exec_windows.go new file mode 100644 index 0000000..4c0b38d --- /dev/null +++ b/tools/builder/deps/exec_windows.go @@ -0,0 +1,14 @@ +package deps + +import ( + "os/exec" + "syscall" +) + +const DETACHED_PROCESS = 8 + +func cmdSetDetached(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{ + CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS, + } +} diff --git a/tools/builder/deps/setup.go b/tools/builder/deps/setup.go new file mode 100644 index 0000000..e1c068c --- /dev/null +++ b/tools/builder/deps/setup.go @@ -0,0 +1,140 @@ +package deps + +import ( + "compress/gzip" + "fmt" + "io" + "net/http" + "os" + "os/exec" + "path/filepath" + "strings" +) + +func downloadFromGithubIfNotExists(repo, tag, name, destination string) error { + tagPath := destination + ".tag" + if tagData, err := os.ReadFile(tagPath); err == nil && string(tagData) == tag { + if _, err := os.Stat(destination); !os.IsNotExist(err) { + return nil + } + } + _ = os.Remove(destination) + url := fmt.Sprintf("https://github.com/%s/releases/download/%s/%s", repo, tag, name) + downloadFileName := destination + if strings.HasSuffix(url, ".gz") { + downloadFileName += ".gz" + } + if err := downloadIfNotExists(url, downloadFileName); err != nil { + _ = os.Remove(downloadFileName) + return fmt.Errorf("failed to download at %s: %w", url, err) + } + if strings.HasSuffix(downloadFileName, ".gz") { + if err := ungz(destination, downloadFileName); err != nil { + return err + } + } + if err := os.Chmod(destination, 0755); err != nil { + return err + } + return os.WriteFile(tagPath, []byte(tag), 0o644) +} + +func ungz(dstPath, srcPath string) error { + f, err := os.Open(srcPath) + if err != nil { + return err + } + defer f.Close() + + gz, err := gzip.NewReader(f) + if err != nil { + return err + } + defer gz.Close() + + out, err := os.Create(dstPath) + if err != nil { + return err + } + defer out.Close() + + if _, err := io.Copy(out, gz); err != nil { + return err + } + return nil +} + +func downloadIfNotExists(url string, filename string) error { + if _, err := os.Stat(filename); os.IsNotExist(err) { + return download(url, filename) + } + return nil +} + +func download(url string, filename string) error { + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("unexpected HTTP status %d for %s", resp.StatusCode, url) + } + out, err := os.Create(filename) + if err != nil { + return err + } + if _, err := io.Copy(out, resp.Body); err != nil { + return err + } + if err := out.Close(); err != nil { + return err + } + if err := verify(filename); err != nil { + return err + } + if filepath.Dir(filename) == "bin" { + if err := os.Chmod(filename, 0755); err != nil { + return err + } + } + return nil +} + +func venvPython() (string, error) { + const bin = ".venv/bin/python3" + if _, err := os.Stat(bin); err != nil { + if !os.IsNotExist(err) { + return "", fmt.Errorf("fetch python venv: %w", err) + } + binPath, err := exec.LookPath("python3") + if err != nil { + return "", err + } + if err := (&exec.Cmd{ + Path: binPath, + Args: []string{binPath, "-m", "venv", ".venv"}, + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + }).Run(); err != nil { + return "", fmt.Errorf("init python venv: %w", err) + } + } + return bin, nil +} + +func pip(args ...string) error { + binPath, err := venvPython() + if err != nil { + return err + } + cmd := exec.Cmd{ + Path: binPath, + Args: append([]string{binPath, "-m", "pip"}, args...), + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + } + return cmd.Run() +} diff --git a/tools/builder/format/format.go b/tools/builder/format/format.go new file mode 100644 index 0000000..dcad629 --- /dev/null +++ b/tools/builder/format/format.go @@ -0,0 +1,95 @@ +package format + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/xeeynamo/ff7-decomp/tools/builder/deps" + "github.com/xeeynamo/ff7-decomp/tools/builder/symbols" + "golang.org/x/sync/errgroup" +) + +func Format() error { + var eg errgroup.Group + eg.Go(clangFormat) + eg.Go(symbolsFormat) + eg.Go(pythonFormat) + if err := eg.Wait(); err != nil { + return fmt.Errorf("format: %v", err) + } + return nil +} + +func clangFormat() error { + var paths []string + entries, err := os.ReadDir("include") + if err != nil { + return err + } + for _, entry := range entries { + if entry.IsDir() { + continue + } + if !strings.HasSuffix(entry.Name(), ".h") { + continue + } + paths = append(paths, filepath.Join("include", entry.Name())) + } + err = filepath.Walk("src", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.IsDir() { + return nil + } + ext := strings.ToLower(filepath.Ext(path)) + if ext != ".c" && ext != ".h" { + return nil + } + paths = append(paths, path) + return nil + }) + if err != nil { + return err + } + args := append([]string{"-i"}, paths...) + return deps.ClangFormat(args...) +} + +func symbolsFormat() error { + entries, err := os.ReadDir("config") + if err != nil { + return err + } + for _, entry := range entries { + if entry.IsDir() { + continue + } + if !strings.HasSuffix(entry.Name(), ".txt") { + continue + } + if !strings.HasPrefix(entry.Name(), "symbols.") { + continue + } + if err := symbols.Sort(filepath.Join("config", entry.Name())); err != nil { + return err + } + } + return nil +} + +func pythonFormat() error { + for _, path := range []string{ + "tools/decompile.py", + "tools/import_data.py", + "tools/symbols.py", + "tools/ninja/gen.py", + } { + if err := deps.Black(path); err != nil { + return err + } + } + return nil +} diff --git a/tools/builder/go.mod b/tools/builder/go.mod new file mode 100644 index 0000000..6042c22 --- /dev/null +++ b/tools/builder/go.mod @@ -0,0 +1,14 @@ +module github.com/xeeynamo/ff7-decomp/tools/builder + +go 1.25.3 + +require ( + github.com/goccy/go-yaml v1.18.0 + github.com/spf13/cobra v1.10.1 +) + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.9 // indirect + golang.org/x/sync v0.19.0 // indirect +) diff --git a/tools/builder/go.sum b/tools/builder/go.sum new file mode 100644 index 0000000..e1c24c2 --- /dev/null +++ b/tools/builder/go.sum @@ -0,0 +1,14 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= +github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= +github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tools/builder/main.go b/tools/builder/main.go new file mode 100644 index 0000000..a760dc8 --- /dev/null +++ b/tools/builder/main.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "os" + + "github.com/xeeynamo/ff7-decomp/tools/builder/cmd" +) + +func main() { + if err := cmd.Execute(); err != nil { + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} diff --git a/tools/builder/rank/rank.go b/tools/builder/rank/rank.go new file mode 100644 index 0000000..fe743fc --- /dev/null +++ b/tools/builder/rank/rank.go @@ -0,0 +1,201 @@ +package rank + +import ( + "bufio" + "fmt" + "math" + "os" + "path/filepath" + "regexp" + "sort" + "strings" + + "github.com/xeeynamo/ff7-decomp/tools/builder/builder" +) + +type entry struct { + score float32 + name string +} + +func Rank(path string, minThreshold float32) error { + path = strings.TrimPrefix(path, "src/") + path = strings.TrimSuffix(path, ".c") + if !strings.HasPrefix(path, "asm/") { + path = filepath.Join("asm", builder.Version(), path) + } + if _, err := os.Stat(path); os.IsNotExist(err) { + targetedPath := filepath.Join(filepath.Dir(path), "nonmatchings", filepath.Base(path)) + if _, err := os.Stat(targetedPath); !os.IsNotExist(err) { + path = targetedPath + } + } else { + targetedPath := filepath.Join(path, "nonmatchings") + if _, err := os.Stat(targetedPath); !os.IsNotExist(err) { + path = targetedPath + } + } + var entries []entry + if err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if !strings.Contains(path, "nonmatchings") { + return nil + } + if !strings.HasSuffix(path, ".s") { + return nil + } + score, err := rankFunction(path) + if err != nil { + return err + } + if score < minThreshold { + return nil + } + entries = append(entries, entry{score, filepath.Base(path)}) + return nil + }); err != nil { + return err + } + sort.Slice(entries, func(i, j int) bool { + return entries[i].score < entries[j].score + }) + for _, entry := range entries { + fmt.Printf("%.3f: %s\n", entry.score, entry.name) + } + return nil +} + +// NOTE: decompilationDifficultyScore and rankFunction are directly converted +// from https://github.com/cdlewis/snowboardkids2-decomp/blob/main/CLAUDE.md +// all rights reserved to the original author https://github.com/cdlewis +// Read more in this article from the same author: +// https://blog.chrislewis.au/the-unexpected-effectiveness-of-one-shot-decompilation-with-claude/ + +// decompilationDifficultyScore calculates the ML-based difficulty score +// Based on the Python implementation's logistic regression model +func decompilationDifficultyScore(instructions, branches, jumps, labels int) float32 { + // Standardization parameters (from training) + means := []float64{34.27065527065527, 1.6666666666666667, 3.1880341880341883, 1.98005698005698} + stds := []float64{24.763225638334454, 2.047860394102145, 3.200600790997309, 2.3803926026229827} + + // Model coefficients + coefficients := []float64{2.499706543629367, -0.46648920346754463, -1.61606926820365, 0.4911494991317799} + intercept := -0.5155412977000488 + + // Calculate score + features := []float64{float64(instructions), float64(branches), float64(jumps), float64(labels)} + + // Standardize features + logit := intercept + for i := 0; i < 4; i++ { + featuresScaled := (features[i] - means[i]) / stds[i] + logit += featuresScaled * coefficients[i] + } + + // Sigmoid function + difficulty := 1.0 / (1.0 + math.Exp(-logit)) + return float32(difficulty) +} + +func rankFunction(path string) (float32, error) { + // Extract function name from file + filename := filepath.Base(path) + funcName := strings.TrimSuffix(filename, ".s") + + // Skip non-code sections (data, bss, rodata, header) + if strings.HasPrefix(funcName, "jtbl_") || + strings.HasPrefix(funcName, "D_") || + strings.HasSuffix(funcName, ".data") || + strings.HasSuffix(funcName, ".bss") || + strings.HasSuffix(funcName, ".rodata") || + funcName == "header" { + return 0, nil + } + + // Open and read file + file, err := os.Open(path) + if err != nil { + return 0, err + } + defer file.Close() + + // Compile regex patterns + branchPattern := regexp.MustCompile(`\b(beq|bne|bnez|beqz|blez|bgtz|bltz|bgez|blt|bgt|ble|bge|bltzal|bgezal)\b`) + jumpJalPattern := regexp.MustCompile(`\bjal\b`) + jumpJPattern := regexp.MustCompile(`\bj\b`) + labelPattern := regexp.MustCompile(`^\s*\.L[0-9A-Fa-f_]+:`) + instructionPattern := regexp.MustCompile(`/\*\s*[0-9A-Fa-f]+\s+[0-9A-Fa-f]+\s+[0-9A-Fa-f]+\s*\*/`) + + instructionCount := 0 + branchCount := 0 + jumpCount := 0 + labelCount := 0 + + // Read file content to check for rodata-only files + scanner := bufio.NewScanner(file) + var content strings.Builder + for scanner.Scan() { + content.WriteString(scanner.Text()) + content.WriteString("\n") + } + if err := scanner.Err(); err != nil { + return 0, err + } + + contentStr := content.String() + + // Skip files that only contain rodata (no actual code) + if strings.Contains(contentStr, ".section .rodata") && !strings.Contains(contentStr, "glabel") { + return 0, nil + } + + // Parse line by line + scanner = bufio.NewScanner(strings.NewReader(contentStr)) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + + // Skip empty lines, glabel, endlabel, and comments + if line == "" || + strings.HasPrefix(line, "glabel") || + strings.HasPrefix(line, "endlabel") || + strings.HasPrefix(line, "nonmatching") { + continue + } + + // Count local labels + if labelPattern.MatchString(line) { + labelCount++ + continue + } + + // Count instructions + if instructionPattern.MatchString(line) { + instructionCount++ + + // Check for branches + if branchPattern.MatchString(line) { + branchCount++ + } + + // Check for jumps + if jumpJalPattern.MatchString(line) || jumpJPattern.MatchString(line) { + jumpCount++ + } + } + } + + if err := scanner.Err(); err != nil { + return 0, err + } + + // Skip functions with 0 instructions (data sections) + if instructionCount == 0 { + return 0, nil + } + + // Calculate difficulty score + score := decompilationDifficultyScore(instructionCount, branchCount, jumpCount, labelCount) + return score, nil +} diff --git a/tools/builder/symbols/add.go b/tools/builder/symbols/add.go new file mode 100644 index 0000000..02b8939 --- /dev/null +++ b/tools/builder/symbols/add.go @@ -0,0 +1,23 @@ +package symbols + +import ( + "fmt" + "os" +) + +func Add(path string, symbol string, offset uint32, size int) error { + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0644) + if err != nil { + return err + } + defer f.Close() + line := fmt.Sprintf("%s = %08X;", symbol, offset) + if size > 0 { + line += fmt.Sprintf("// size:0x%X", size) + } + if _, err := f.WriteString(line + "\n"); err != nil { + return err + } + _ = f.Close() + return Sort(path) +} diff --git a/tools/builder/symbols/sort.go b/tools/builder/symbols/sort.go new file mode 100644 index 0000000..52ac74b --- /dev/null +++ b/tools/builder/symbols/sort.go @@ -0,0 +1,83 @@ +package symbols + +import ( + "bufio" + "fmt" + "os" + "sort" + "strings" + + "github.com/xeeynamo/ff7-decomp/tools/builder/utils" +) + +type symbolEntry struct { + offset uint32 + name string + comment string +} + +func Sort(path string) error { + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + + scanner := bufio.NewScanner(f) + symbols := map[uint32]symbolEntry{} + for scanner.Scan() { + line := scanner.Text() + if line == "" { + continue + } + split := strings.SplitN(line, "=", 2) + if len(split) != 2 { + return fmt.Errorf("invalid symbol entry: %s", line) + } + split2 := strings.SplitN(split[1], ";", 2) + if len(split2) != 2 { + return fmt.Errorf("invalid symbol entry: %s", line) + } + offset, err := utils.ParseDigit(split2[0]) + if err != nil { + return fmt.Errorf("invalid symbol offset at %s: %w", line, err) + } + symbols[uint32(offset)] = symbolEntry{ + offset: uint32(offset), + name: strings.TrimSpace(split[0]), + comment: strings.TrimSpace(split2[1]), + } + } + if err := scanner.Err(); err != nil { + return err + } + offsets := make([]uint32, 0, len(symbols)) + for offset := range symbols { + offsets = append(offsets, offset) + } + sort.Slice(offsets, func(i, j int) bool { + return offsets[i] < offsets[j] + }) + + _ = f.Close() + f, err = os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644) + if err != nil { + return err + } + defer f.Close() + + writer := bufio.NewWriter(f) + for _, offset := range offsets { + entry := symbols[offset] + var line string + if entry.comment != "" { + line = fmt.Sprintf("%s = 0x%08X; %s\n", entry.name, entry.offset, entry.comment) + } else { + line = fmt.Sprintf("%s = 0x%08X;\n", entry.name, entry.offset) + } + if _, err := writer.WriteString(line); err != nil { + return err + } + } + return writer.Flush() +} diff --git a/tools/builder/utils/utils.go b/tools/builder/utils/utils.go new file mode 100644 index 0000000..b9ece49 --- /dev/null +++ b/tools/builder/utils/utils.go @@ -0,0 +1,22 @@ +package utils + +import ( + "fmt" + "strconv" + "strings" +) + +// ParseDigit parses a decimal or hexadecimal string into an int64 +func ParseDigit(s string) (int64, error) { + base := 10 + s = strings.TrimSpace(s) + if strings.HasPrefix(s, "0x") { + base = 16 + s = s[2:] + } + v, err := strconv.ParseInt(s, base, 64) + if err != nil { + return 0, fmt.Errorf("invalid value %q: %w", s, err) + } + return v, nil +} diff --git a/tools/decompile.py b/tools/decompile.py new file mode 100755 index 0000000..e9d72c0 --- /dev/null +++ b/tools/decompile.py @@ -0,0 +1,247 @@ +#!/usr/bin/env python3 +"""This script is intended to make it easier for someone to decompile a function within the sotn-decomp project +and optionally upload that function to decomp.me. +Any questions or issues related to running it should be directed to the sotn-decomp discord #tooling channel: +https://sotn-discord.xee.dev/ + +Original authors: https://github.com/Xeeynamo/sotn-decomp/commits/49cfac4c85a774fa298/tools/decompile.py + +Use `decompile.py --help` for usage and options""" + +import argparse +import io +import os +import sys +import tempfile +from contextlib import redirect_stdout +from pathlib import Path +from typing import Optional + +# Add m2c directory to path so m2c_pycparser can be found +sys.path.insert(0, str(Path(__file__).resolve().parent / "m2c")) + +import m2ctx +import m2c.main as m2c +import fix_structs + + +class SotnFunction(object): + """A representation of a function within sotn-decomp, including paths and code associated with the function""" + + def __init__(self, func_root: Path, function_path: Path, args: argparse.Namespace): + self.name: str = args.function + self.version: str = args.version + self._overlay: str = args.overlay + self.fix_structs: bool = args.fix_structs + + # These directories/paths should be considered to be specific to the function + self.root: Path = func_root + self.asm_dir: Path = func_root.joinpath("asm", args.version) + self.src_dir: Path = func_root.joinpath("src") + self.abspath: Path = function_path.resolve() + self.relpath: Path = function_path.relative_to(func_root) + self.src_path: Path = self._infer_src_path() + self.include_asm: str = ( + f'INCLUDE_ASM("asm/us/{self.abspath.relative_to(self.asm_dir).parent}", {self.relpath.stem});' + ) + self.asm_code: str = self.abspath.read_text() + self.c_code: str = "" + self._context: str = "" + + @property + def overlay(self) -> str: + """Attempts to infer the overlay from the asm file path or returns None if one is not found. + The '_psp' extension will be included if the version is psp because this value is later used + for identifying the correct overlay asm path""" + if not self._overlay: + nonmatching_index = next( + ( + i + for i, part in enumerate(self.relpath.parts) + if part == "nonmatchings" + ), + None, + ) + self._overlay = ( + self.relpath.parts[nonmatching_index - 1] if nonmatching_index else None + ) + return self._overlay + + @property + def asm_differ_command(self) -> str: + """Constructs the command string the user can enter to run asm-differ against the overlay this function resides in""" + return f"{Path(sys.executable).name} {self.root.joinpath("tools/asm-differ/diff.py").relative_to(Path.cwd())} -mwo --overlay {self.overlay.replace("_psp", "")} {self.name}" + + @property + def context(self): + """Leverages m2ctx to create context text""" + if not self._context: + m2ctx.root_dir = self.root + m2ctx.VERSION_DEF = [f"-D_internal_version_{self.version}"] + self._context = m2ctx.import_c_file(self.src_path) + return self._context + + def decompile(self) -> str: + """Leverages m2c to decompile the function and stores it so that decompilation only needs to run once""" + if not self.c_code: + self.c_code = self._guess_unknown_type(self._run_m2c()) + return self.c_code + + def _run_m2c(self) -> str: + with tempfile.NamedTemporaryFile( + mode="w", encoding="utf-8", suffix=".c" + ) as tmp_ctx: + tmp_ctx.writelines(self.context) + tmp_ctx.flush() + options = m2c.parse_flags( + [ + "-P", + "4", + "--pointer-style", + "left", + "--knr", + "--indent-switch-contents", + "--comment-style", + "oneline", + "--target", + "mipsel-gcc-c", + "--context", + tmp_ctx.name, + str(self.abspath), + ] + ) + + with redirect_stdout(io.StringIO()) as f: + m2c.run(options) + return f.getvalue() + + def _guess_unknown_type(self, decompiled_code: str) -> str: + code = ( + decompiled_code.replace("? func_", "/*?*/ void func_") + .replace("extern ? D_", "extern /*?*/s32 D_") + .replace("extern ?* D_", "extern /*?*/u8* D_") + ) + if self.fix_structs: + code = fix_structs.fix_symbols(code) + return code + + def _infer_src_path(self) -> Optional[Path]: + inferred_c_files = ( + file + for file in self.src_dir.rglob(f"{self.abspath.parent.name}.c") + if self.overlay in file.parts or self.overlay in file.name + ) + return next( + (path for path in inferred_c_files if self.name in path.read_text()), None + ) + + +def get_repo_root(current_dir: Path = Path(__file__).resolve().parent) -> Path: + """Steps backward from the file location to infer the root of the repo""" + if next(current_dir.glob("src"), None) or current_dir.name == "/": + return current_dir + else: + return get_repo_root(current_dir.parent) + + +def get_function_path(asm_dir: Path, args: argparse.Namespace) -> Optional[Path]: + """Uses the version asm directory and the passed args to find any files matching the function name.""" + candidates = tuple(file for file in asm_dir.rglob(f"{args.function}.s")) + matching = tuple(c for c in candidates if "matchings" in c.parts) + nonmatching = tuple( + c + for c in candidates + if "nonmatchings" in c.parts and (not args.overlay or args.overlay in c.parts) + ) + + if not matching and not nonmatching: + print( + f"Could not find function {args.function}, are you sure it exists in version {args.version}?" + ) + return None + elif matching and not nonmatching: + print( + f"It appears that {args.function} has already been decompiled and matched." + ) + return None + + if len(nonmatching) > 1: + message = f"{len(nonmatching)} possible files found for {args.function} in the following locations:\n" + message += f"{"\n".join(f"\t{path.relative_to(asm_dir.parent)}" for path in nonmatching)}" + message += "Invoke this tool again using the -o/--overlay argument to specify the appropriate overlay." + print(message) + return None + else: + return nonmatching[0] + + +def safe_write(file_path: Path, lines: list[str]) -> None: + """Writes to a temp file, then replaces the original file after the temp file is successfully written""" + # Since we are using os.replace, the temp file needs to be on the same filesystem as the original. + with tempfile.NamedTemporaryFile( + mode="w", encoding="utf-8", dir=file_path.parent + ) as temp_file: + temp_file.writelines([l.rstrip("\n") + "\n" for l in lines]) + temp_file.flush() + os.replace(temp_file.name, file_path) + + +def inject_decompiled_function(repo_root: Path, sotn_func: SotnFunction) -> None: + """Replaces the INCLUDE_ASM macro line with the decompiled code, writes it, then returns a status based on the results""" + lines = sotn_func.src_path.read_text().splitlines() + + if sotn_func.include_asm in lines: + function_index = lines.index(sotn_func.include_asm) + + # Using copy() so that the lines object is not modified when new_lines is + new_lines = lines.copy() + new_lines[function_index] = sotn_func.decompile() + safe_write(sotn_func.src_path, new_lines) + + print( + f"{sotn_func.name} decompiled in {sotn_func.src_path.relative_to(repo_root)}" + ) + exit(0) + elif [line for line in lines if sotn_func.name in line]: + print(f"{sotn_func.name} found in {sotn_func.src_path.relative_to(repo_root)}") + exit(1) + else: + print(f"{args.function} not found") + exit(1) + + +def main(args: argparse.Namespace) -> None: + """Executes the decompilation workflow and gives console feedback based on the results""" + repo_root = get_repo_root() + function_path = get_function_path(repo_root.joinpath("asm", args.version), args) + if function_path: + sotn_func = SotnFunction(repo_root, function_path, args) + if sotn_func.src_path and sotn_func.decompile(): + inject_decompiled_function(repo_root, sotn_func) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Decompile a function") + parser.add_argument("function", help="The name of the function to decompile") + parser.add_argument( + "-v", + "--version", + required=False, + type=str, + default=os.getenv("VERSION") or "us", + help="Sets the target game version and overrides VERSION environment variable", + ) + parser.add_argument( + "-o", + "--overlay", + help="The overlay to use if there are multiple asm files that match the provided function name", + type=str, + required=False, + ) + parser.add_argument( + "--fix-structs", + action="store_true", + default=False, + help="Replace D_8009XXXX symbols with Savemap.field_name references", + ) + main(parser.parse_args()) diff --git a/tools/docker-build.sh b/tools/docker-build.sh new file mode 100755 index 0000000..119e21b --- /dev/null +++ b/tools/docker-build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Optimized Docker build wrapper for FF7 decomp +# Uses Docker volumes for Go caching (faster on macOS than host mounts) + +set -e + +# Run Docker with volume mounts for source, venv, build output, and Go cache +exec docker run --rm --platform=linux/amd64 \ + --name ff7-work \ + -v "$(pwd)":/ff7 \ + -v ff7_venv:/ff7/.venv \ + -v ff7_build:/ff7/build \ + -v go_cache:/gocache \ + ff7-build:latest -lc "cd /ff7 && $*" diff --git a/tools/fix_structs.py b/tools/fix_structs.py new file mode 100644 index 0000000..13498da --- /dev/null +++ b/tools/fix_structs.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +"""Post-processing script to replace D_8009XXXX symbols with Savemap.field_name. + +This script takes decompiled code and replaces raw address symbols that fall within +the Savemap struct with proper struct member accesses. + +Usage: + python fix_structs.py < input.c > output.c + python fix_structs.py input.c + cat file.c | python fix_structs.py +""" + +import re +import sys + +SAVEMAP_BASE = 0x8009C6E4 + +SAVEMAP_FIELDS = [ + # (offset, size, name, element_size) - element_size > 0 means array + # SaveHeader (embedded) + (0x000, 4, "header.checksum", 0), + (0x004, 1, "header.leader_level", 0), + (0x005, 1, "header.leader_portrait", 0), + (0x006, 1, "header.portrait2", 0), + (0x007, 1, "header.portrait3", 0), + (0x008, 16, "header.leader_name", 1), + (0x018, 2, "header.leader_hp", 0), + (0x01A, 2, "header.leader_hp_max", 0), + (0x01C, 2, "header.leader_mp", 0), + (0x01E, 2, "header.leader_mp_max", 0), + (0x020, 4, "header.gil", 0), + (0x024, 4, "header.time", 0), + (0x028, 32, "header.place_name", 1), + (0x048, 12, "header.menu_color", 4), + # SavePartyMember party[9] - 0x84 bytes each + (0x054, 0x4A4, "party", 0x84), + # Rest of SaveWork + (0x4F8, 4, "partyID", 1), + (0x4FC, 640, "inventory", 2), + (0x77C, 800, "materia", 4), + (0xA9C, 192, "yuffie_stolen_materia", 4), + (0xB5C, 32, "unk_b5c", 1), + (0xB7C, 4, "gil", 0), + (0xB80, 4, "time", 0), + (0xB84, 4, "countdown_timer_seconds", 0), + (0xB88, 4, "game_timer_fraction", 0), + (0xB8C, 4, "countdown_timer_fraction", 0), + (0xB90, 4, "worldmap_exit_action", 0), + (0xB94, 2, "current_module", 0), + (0xB96, 2, "current_location_id", 0), + (0xB98, 2, "padding2", 0), + (0xB9A, 2, "field_x", 0), + (0xB9C, 2, "field_y", 0), + (0xB9E, 2, "field_triangle", 0), + (0xBA0, 1, "field_direction", 0), + (0xBA1, 1, "step_id", 0), + (0xBA2, 1, "step_offset", 0), + (0xBA3, 1, "padding3", 0), + (0xBA4, 256, "memory_bank_1", 1), + (0xCA4, 256, "memory_bank_2", 1), + (0xDA4, 256, "memory_bank_3", 1), + (0xEA4, 256, "memory_bank_4", 1), + (0xFA4, 256, "memory_bank_5", 1), + (0x10A4, 2, "phs_locking_mask", 0), + (0x10A6, 2, "phs_visibility_mask", 0), + (0x10A8, 48, "unk_10a8", 1), + (0x10D8, 1, "battle_speed", 0), + (0x10D9, 1, "battle_msg_speed", 0), + (0x10DA, 2, "config", 0), + (0x10DC, 16, "button_config", 1), + (0x10EC, 1, "field_msg_speed", 0), + (0x10ED, 1, "D_8009D7D1", 0), + (0x10EE, 2, "D_8009D7D2", 0), + (0x10F0, 4, "D_8009D7D4", 0), +] + +SAVEMAP_END = SAVEMAP_BASE + 0x10F4 + + +def build_offset_map(): + """Build a map from offset to (field_name, element_size, field_offset).""" + offset_map = {} + for field_offset, size, name, elem_size in SAVEMAP_FIELDS: + if elem_size > 0: + for i in range(size // elem_size): + offset_map[field_offset + i * elem_size] = (name, elem_size, field_offset) + else: + offset_map[field_offset] = (name, 0, field_offset) + return offset_map + + +def address_to_field(addr, offset_map): + """Convert an address to a Savemap.field reference.""" + if addr < SAVEMAP_BASE or addr >= SAVEMAP_END: + return None + + offset = addr - SAVEMAP_BASE + + if offset in offset_map: + name, elem_size, field_offset = offset_map[offset] + if elem_size > 0: + idx = (offset - field_offset) // elem_size + return f"Savemap.{name}[{idx}]" + return f"Savemap.{name}" + + for field_offset, size, name, elem_size in SAVEMAP_FIELDS: + if field_offset <= offset < field_offset + size: + if elem_size > 0: + idx = (offset - field_offset) // elem_size + remainder = (offset - field_offset) % elem_size + if remainder == 0: + return f"Savemap.{name}[{idx}]" + return f"Savemap.{name}[{idx}] + 0x{remainder:X}" + return f"Savemap.{name}" + + return f"Savemap + 0x{offset:X}" + + +def fix_symbols(code): + """Replace D_8009XXXX symbols with Savemap.field references.""" + offset_map = build_offset_map() + symbol_pattern = re.compile(r'\bD_(8009[0-9A-Fa-f]{4})\b') + extern_pattern = re.compile(r'^extern\s+(?:/\*\?\*/\s*)?\w+\*?\s+Savemap\.[^;]+;\s*\n', re.MULTILINE) + + def replace_symbol(match): + addr = int(match.group(1), 16) + field = address_to_field(addr, offset_map) + if field: + return field + return match.group(0) + + result = symbol_pattern.sub(replace_symbol, code) + result = extern_pattern.sub('', result) + return result + + +def main(): + if len(sys.argv) > 1: + with open(sys.argv[1], 'r') as f: + code = f.read() + result = fix_symbols(code) + print(result, end='') + else: + code = sys.stdin.read() + result = fix_symbols(code) + print(result, end='') + + +if __name__ == "__main__": + main() diff --git a/tools/import_data.py b/tools/import_data.py new file mode 100755 index 0000000..dfcc996 --- /dev/null +++ b/tools/import_data.py @@ -0,0 +1,128 @@ +#!/usr/bin/env python3 +import argparse +import os +import sys + +version = "us" + + +def asm_path(c_path: str): + # src/battle/battle.c 👉 asm/us/battle/ + path = os.path.dirname(c_path).replace("src", f"asm/{version}") + if not os.path.isdir(path): + raise Exception(f"asm_path did not find path {path}") + return path + + +def read_asm_data(asm_path: str, sym_name: str) -> list[str] | None: + search_sym = f"glabel {sym_name}\n" + search_end = f".size {sym_name}, . - {sym_name}\n" + for root, dirs, files in os.walk(asm_path): + for file_name in files: + file_path = os.path.join(root, file_name) + try: + with open(file_path, "r") as file: + for line in file: + if line == search_sym: + line_data = [line] + for line in file: + if line == search_end: + break + line_data.append(line) + return line_data + except Exception as e: + sys.stderr.write(f"find_symbol failed to read file {file_path}: {e}\n") + continue + return None + + +def get_splat_asm_line(line: str) -> str: + idx = line.index("*/ ") + if idx < 0: + return line + return line[idx + 3 :].strip() + + +def to_c_array(asm_data: list[str], is_signed: bool, is_const: bool) -> str: + if len(asm_data) < 2: + sys.stderr.write(f"malformed asm data:\n{asm_data}\n") + return "" + sym_name = asm_data[0].split(" ")[1].strip() + sym_type = get_splat_asm_line(asm_data[1]).split(" ")[0] + data = [get_splat_asm_line(x).split(" ")[1] for x in asm_data[1:]] + if is_signed: + for i in range(len(data)): + n = int(data[i][2:], 16) + if sym_type == ".short": + if n & 0x8000: + n -= 0x10000 + elif sym_type == ".byte": + if n & 0x80: + n -= 0x100 + data[i] = str(n) + if sym_type == ".byte": + sym_type = "s8" if is_signed else "u8" + if sym_type == ".short": + sym_type = "s16" if is_signed else "u16" + if sym_type == ".word": + sym_type = "s32" if is_signed else "u32" + array = "const " if is_const else "" + array += f"{sym_type} {sym_name}[] = {{" + array += ", ".join(data) + array += "};\n" + return array + + +def find_first_function_ref(asm_path: str, sym_name: str) -> str | None: + for root, dirs, files in os.walk(asm_path): + for file_name in files: + if file_name.startswith("D_"): + continue + file_path = os.path.join(root, file_name) + with open(file_path, "r") as file: + if sym_name in file.read(): + return os.path.splitext(file_name)[0] + return None + + +def import_data(c_path: str, sym_name: str, is_signed: bool, is_const: bool): + asm_search_path = asm_path(c_path) + asm_data = read_asm_data(f"{asm_search_path}/data", sym_name) + if not asm_data: + return sys.stderr.write(f"symbol {sym_name} not found in {asm_search_path}\n") + c_array = to_c_array(asm_data, is_signed, is_const) + func_name = find_first_function_ref(f"{asm_search_path}/nonmatchings", sym_name) + if not func_name: + func_name = find_first_function_ref(f"{asm_search_path}/matchings", sym_name) + if not func_name: + print(c_array) + return + with open(c_path, "r") as file: + lines = [] + for line in file: + if "INCLUDE_ASM" in line and func_name in line: + lines.append(c_array) + if ") {" in line and func_name in line: + lines.append(c_array) + lines.append(line) + with open(c_path, "w") as file: + file.writelines(lines) + + +def main(): + parser = argparse.ArgumentParser(description="Import a data or rodata to a C file") + parser.add_argument("c_path", type=str, help="Path of C file to import data into") + parser.add_argument("sym_name", type=str, help="Name of the symbol to import") + parser.add_argument( + "-s", "--signed", action="store_true", help="Import data as signed" + ) + parser.add_argument( + "-c", "--const", action="store_true", help="Import data as const" + ) + args = parser.parse_args() + + import_data(args.c_path, args.sym_name, args.signed, args.const) + + +if __name__ == "__main__": + main() diff --git a/tools/m2c b/tools/m2c new file mode 160000 index 0000000..a21c1dc --- /dev/null +++ b/tools/m2c @@ -0,0 +1 @@ +Subproject commit a21c1dcd7255b176c032bb932f521846e98d4372 diff --git a/tools/m2ctx.py b/tools/m2ctx.py new file mode 100644 index 0000000..e48b67e --- /dev/null +++ b/tools/m2ctx.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 + +import argparse +import os +import sys +import subprocess +import tempfile + +script_dir = os.path.dirname(os.path.realpath(__file__)) +root_dir = os.path.abspath(os.path.join(script_dir, "..")) +src_dir = root_dir + "src/" + +# Project-specific +CPP_FLAGS = [ + "-Iinclude", + "-Isrc", + "-Iinclude/psxsdk", + "-D_LANGUAGE_C", + "-DF3DEX_GBI_2", + "-D_MIPS_SZLONG=32", + "-DSCRIPT(...)={}", + "-D__attribute__(...)=", + "-D__asm__(...)=", + "-ffreestanding", + "-DM2CTX", +] + +VERSION_DEF = [] + + +def import_c_file(in_file) -> str: + in_file = os.path.relpath(in_file, root_dir) + cpp_command = ["gcc", "-E", "-P", "-dM", *CPP_FLAGS, in_file] + cpp_command2 = ["gcc", "-E", "-P", *CPP_FLAGS, *VERSION_DEF, in_file] + + with tempfile.NamedTemporaryFile(suffix=".c") as tmp: + stock_macros = subprocess.check_output( + ["gcc", "-E", "-P", "-dM", *VERSION_DEF, tmp.name], + cwd=root_dir, + encoding="utf-8", + ) + stock_macros += "#define __STDC_HOSTED__ 0\n" + + out_text = "" + try: + out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output( + cpp_command2, cwd=root_dir, encoding="utf-8" + ) + except subprocess.CalledProcessError: + print( + "Failed to preprocess input file, when running command:\n" + + " ".join(cpp_command), + file=sys.stderr, + ) + sys.exit(1) + + if not out_text: + print("Output is empty - aborting") + sys.exit(1) + + for line in stock_macros.strip().splitlines(): + out_text = out_text.replace(line + "\n", "") + return out_text + + +def main(): + parser = argparse.ArgumentParser( + description="""Create a context file which can be used for m2c / decomp.me""" + ) + parser.add_argument( + "c_file", + help="""File from which to create context""", + ) + args = parser.parse_args() + + if "VERSION" in os.environ: + VERSION_DEF.append("-D_internal_version_" + os.environ["VERSION"]) + + output = import_c_file(args.c_file) + + with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: + f.write(output) + + +if __name__ == "__main__": + main() diff --git a/tools/maspsx b/tools/maspsx new file mode 160000 index 0000000..8b4706a --- /dev/null +++ b/tools/maspsx @@ -0,0 +1 @@ +Subproject commit 8b4706a70921df9a4ed3e93299c8f2f366b7107d diff --git a/tools/ninja/gen.py b/tools/ninja/gen.py new file mode 100644 index 0000000..db66e69 --- /dev/null +++ b/tools/ninja/gen.py @@ -0,0 +1,410 @@ +import base64 +import os +import pathlib +import sys +from dataclasses import dataclass +import os + +import ninja_syntax +import yaml + +CPP_FLAGS = "-Iinclude -Iinclude/psxsdk -DUSE_INCLUDE_ASM -DFF7_STR" +LD_FLAGS = "" + +nw: ninja_syntax.Writer = None +objs: list[str] = [] +work_dir = "build/us" +if len(sys.argv) > 1: + work_dir = sys.argv[1] +progress_report = os.environ.get("FF7_PROGRESS_REPORT") == "1" +dummy_object = bytes() +if progress_report: + # https://decomp.wiki/en/tools/decomp-dev + CPP_FLAGS += " -DSKIP_ASM=1" + dummy_object = base64.b64decode( + "f0VMRgEBAQAAAAAAAAAAAAEACAABAAAAAAAAAAAAAABYAAAAABAAADQAAAAAACgABgAFAAAuc2hz" + "dHJ0YWIALnRleHQALmRhdGEALmJzcwAucGRyAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAALAAAAAQAAAAYAAAAAAAAANAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEQAA" + "AAEAAAADAAAAAAAAADQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABcAAAAIAAAAAwAAAAAAAAA0AAAA" + "AAAAAAAAAAAAAAAAEAAAAAAAAAAcAAAAAQAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAQAAAAA" + "AAAAAQAAAAMAAAAAAAAAAAAAADQAAAAhAAAAAAAAAAAAAAABAAAAAAAAAA==" + ) # minimal stripped object file generated from an empty assembly file +check_path = os.path.join(work_dir, "check.sha1") + + +def basename(cfg) -> str: + return cfg["options"]["basename"] + + +def asm_path(cfg) -> str: + return cfg["options"]["asm_path"] + + +def build_path(cfg) -> str: + return cfg["options"]["build_path"] + + +def ld_path(cfg) -> str: + return cfg["options"]["ld_script_path"] + + +def src_path(cfg) -> str: + return cfg["options"]["src_path"] + + +def asset_path(cfg) -> str: + return cfg["options"]["asset_path"] + + +def platform(cfg) -> str: + return cfg["options"]["platform"] + + +@dataclass +class CompilerParams: + cc1: str + cc_opt: str + cc_gp: str + as_flags: str + + +def default_compiler_params() -> CompilerParams: + return CompilerParams( + "cc1-psx-272", "-O2", "-G0", "--expand-div --aspsx-version=2.34" + ) + + +def parse_compiler_params(line: str) -> CompilerParams: + c = default_compiler_params() + for param in line.strip().split(" "): + pair = param.split("=") + if not pair: + continue + if len(pair) == 2: + key, value = pair[0].strip(), pair[1].strip() + elif len(pair) == 1: + key, value = pair[0].strip(), "" + else: + raise Exception(f"compiler flag {param} is invalid") + if key == "PSYQ": + if value == "3.3": + c.cc1 = "cc1-psx-26" + c.as_flags = "--expand-div --aspsx-version=2.21" + elif value == "3.5": + c.cc1 = "cc1-psx-26" + c.as_flags = "--expand-div --aspsx-version=2.34" + elif value == "3.6": + c.cc1 = "cc1-psx-272" + c.as_flags = "--expand-div --aspsx-version=2.34" + elif value == "4.0": + c.cc1 = "cc1-psx-272" + c.as_flags = "--expand-div --aspsx-version=2.56" + else: + raise Exception(f"{key} value {value} is not recognized") + elif key == "CC1": + if value == "2.6.3": + c.cc1 = "cc1-psx-26" + elif value == "2.7.2": + c.cc1 = "cc1-psx-272" + else: + raise Exception(f"{key} value {value} is not recognized") + elif key == "G": + try: + n = int(value) + c.cc_gp = f"-G{n}" + except ValueError: + raise Exception(f"{key} value {value} is not a valid integer") + elif key == "O": + try: + n = int(value) + c.cc_opt = f"-O{n}" + except ValueError: + raise Exception(f"{key} value {value} is not a valid integer") + else: + raise Exception(f"{key} is not recognized") + return c + + +def get_compiler_params(source_file_name: str) -> CompilerParams: + if not os.path.exists(source_file_name): + return default_compiler_params() + with open(source_file_name, "r") as file: + for i in range(10): # read the top 10 lines of code + line = file.readline() + if not line: + break + if line.startswith("//!"): + return parse_compiler_params(line[3:]) + return default_compiler_params() + + +def add_s(cfg: any, file_name: str): + in_path = f"{asm_path(cfg)}/{file_name}.s" + out_path = f"{build_path(cfg)}/{in_path}.o" + if out_path in objs: + return + objs.append(out_path) + if progress_report: + out = pathlib.Path(out_path) + out.parent.mkdir(parents=True, exist_ok=True) + out.write_bytes(dummy_object) + return + nw.build( + rule=f"{platform(cfg)}-as", + outputs=[out_path], + inputs=[in_path], + ) + nw.build( + rule="phony", + outputs=[in_path], + implicit=[ld_path(cfg)], + ) + + +def add_c(cfg: any, file_name: str): + in_path = f"{src_path(cfg)}/{file_name}.c" + out_path = f"{build_path(cfg)}/{in_path}.o" + if out_path in objs: + return + compiler_flags = get_compiler_params(in_path) + objs.append(out_path) + nw.build( + rule=f"{platform(cfg)}-cc", + outputs=[out_path], + inputs=[in_path], + implicit=["include/common.h", "include/game.h"], + variables={ + "cc1": compiler_flags.cc1, + "as_flags": compiler_flags.as_flags, + "cc_flags": f"{compiler_flags.cc_opt} {compiler_flags.cc_gp}", + }, + ) + nw.build( + rule="phony", + outputs=[in_path], + implicit=[ld_path(cfg)], + ) + + +def add_copy(cfg: any, file_name: str): + in_path = f"{asset_path(cfg)}/{file_name}" + out_path = f"{build_path(cfg)}/{in_path}.o" + if out_path in objs: + return + objs.append(out_path) + nw.build( + rule=f"copy", + outputs=[out_path], + inputs=[in_path], + ) + nw.build( + rule="phony", + outputs=[in_path], + implicit=[ld_path(cfg)], + ) + + +def add_splat_config(file_name: str): + with open(file_name) as f: + cfg = yaml.load(f, Loader=yaml.SafeLoader) + nw.build( + rule="splat", + outputs=[ld_path(cfg)], + inputs=file_name, + implicit=cfg["options"]["symbol_addrs_path"], + ) + objs.clear() + is_main = basename(cfg) == "main" + is_battle = basename(cfg) == "battle" + is_batini = basename(cfg) == "batini" + is_magic = "/magic" in src_path(cfg) + if platform(cfg) == "psx" and is_main: + add_s(cfg, "header") + for segment in cfg["segments"]: + if not "type" in segment: + continue + if segment["type"] != "code": + continue + for sub in segment["subsegments"]: + offset = int(sub[0]) + if len(sub) < 2: + kind = "data" + name = segment["name"] + else: + kind = str(sub[1]) + if len(sub) > 2: + name = str(sub[2]) + else: + name = str.format("{0:X}", offset) + if kind == "data": + add_s(cfg, f"data/{name}.data") + elif kind == "rodata": + add_s(cfg, f"data/{name}.rodata") + elif kind == "bss": + add_s(cfg, f"data/{name}.bss") + elif kind == "asm": + add_s(cfg, name) + elif kind == "c" or kind == ".data": + add_c(cfg, name) + if progress_report: + return + output_name = f"{build_path(cfg)}/{basename(cfg)}.elf" + sym_export = "config/sym_export.us.txt" + if is_main: + nw.build( + rule="sym-export", + outputs=[sym_export], + inputs=[output_name], + ) + else: + objs.append(sym_export) + sym_paths = [ + f"-T {cfg["options"]["undefined_syms_auto_path"]}", + f"-T config/sym_extern.us.txt", + ] + if is_main: + sym_paths.append("-T config/sym_ovl_export.us.txt") + if is_battle: + nw.build( # needs to export symbol list for batini + rule="sym-export", + outputs=f"config/sym_export_{basename(cfg)}.us.txt", + inputs=[output_name], + ) + sym_paths.append("-T config/sym_battle_import.us.txt") + if is_batini or is_magic: + # batini uses symbols from battle + sym_paths.append("-T config/sym_export_battle.us.txt") + nw.build( + rule="psx-ld", + outputs=[output_name], + inputs=[ld_path(cfg)], + implicit=objs, + variables={ + "map_path": f"{build_path(cfg)}/{basename(cfg)}.map", + "obj_paths": objs, + "symbol_path": str.join(" ", sym_paths), + }, + ) + if is_main: + # main must be linked twice: + # 1. generate sym_export.*.txt and allow other overlays to use SDK funcs + # 2. to allow overlays re-generating sym_ovl_export.*.txt + nw.build( + rule="sym-export", + outputs=["config/sym_ovl_export.us.txt"], + inputs=get_ovl_elf_list(check_path), + ) + nw.build( + rule="psx-ld", + outputs=[f"{build_path(cfg)}/{basename(cfg)}_final.elf"], + inputs=[ld_path(cfg)], + implicit=objs + ["config/sym_ovl_export.us.txt"], + variables={ + "map_path": f"{build_path(cfg)}/{basename(cfg)}.map", + "obj_paths": objs, + "symbol_path": str.join(" ", sym_paths), + }, + ) + nw.build( + rule="psx-exe", + outputs=[f"{build_path(cfg)}/{basename(cfg)}.exe"], + inputs=[f"{build_path(cfg)}/{basename(cfg)}_final.elf"], + ) + else: + nw.build( + rule="psx-exe", + outputs=[f"{build_path(cfg)}/{basename(cfg)}.exe"], + inputs=[f"{build_path(cfg)}/{basename(cfg)}.elf"], + ) + + +def get_check_list(file_path) -> list[str]: + with open(file_path, "r") as f: + lines = f.readlines() + return [line.strip().split(" ")[2] for line in lines if line] + + +def get_ovl_elf_list(file_path) -> list[str]: + checks = get_check_list(file_path) + return [x.replace(".exe", ".elf") for x in checks if not x.endswith("main.exe")] + + +with open("build.ninja", "w") as f: + nw = ninja_syntax.Writer(f) + nw.rule( + "splat", + command=".venv/bin/splat split $in > /dev/null && touch $out", + description="splat $in", + ) + nw.rule( + "psx-as", + command="mipsel-linux-gnu-as -Iinclude -march=r3000 -mtune=r3000 -no-pad-sections -O1 -G0 -o $out $in", + description="psx as $in", + ) + nw.rule( + "psx-cc", + command=( + f"mipsel-linux-gnu-cpp {CPP_FLAGS} -MMD -MF $out.d -lang-c -Iinclude -Iinclude/psxsdk -undef -Wall -fno-builtin $in" + " | bin/str" # convert C-style strings _S("FOO") into FF7-style strings "\x26\x2F\x2F\xFF" + " | iconv --from-code=UTF-8 --to-code=Shift-JIS" + " | bin/$cc1 -quiet -mcpu=3000 -g -mgas -gcoff $cc_flags" + " | python3 tools/maspsx/maspsx.py $as_flags" + " | mipsel-linux-gnu-as -Iinclude -march=r3000 -mtune=r3000 -no-pad-sections -O1 -G0 -o $out" + ), + depfile="$out.d", + deps="gcc", + description="psx cc $in", + ) + nw.rule( + "copy", + command="mipsel-linux-gnu-ld -r -b binary -o $out $in", + description="copy $in", + ) + nw.rule( + "psx-ld", + command=f"mipsel-linux-gnu-ld -nostdlib --no-check-sections {LD_FLAGS} -Map $map_path -T $in $symbol_path -o $out $obj_paths", + description="psx ld $in", + ) + nw.rule( + "psx-exe", + command=f"mipsel-linux-gnu-objcopy -O binary $in $out", + description="psx exe $in", + ) + nw.rule( + "sym-export", + command=".venv/bin/python3 tools/symbols.py $in > $out", + description="sym export $in", + ) + nw.rule( + "check", + command=f"sha1sum -c {check_path}", + description="check", + ) + if not progress_report: + nw.build( + rule="check", + outputs=["build/check.dummy"], + inputs=get_check_list(check_path), + ) + for ovl in [ + "main", + # BATTLE + "batini", + "battle", + "brom", + # MISC + "dschange", + "ending", + # FIELD + "field", + # MINI + # MENU + "bginmenu", + "cnfgmenu", + "savemenu", + # WORLD + "world", + # MAGIC + "barrier", + ]: + add_splat_config(os.path.join(work_dir, f"{ovl}.yaml")) diff --git a/tools/ninja/ninja_syntax.py b/tools/ninja/ninja_syntax.py new file mode 100644 index 0000000..e73b21a --- /dev/null +++ b/tools/ninja/ninja_syntax.py @@ -0,0 +1,199 @@ +#!/usr/bin/python + +# Copyright 2011 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Python module for generating .ninja files. + +Note that this is emphatically not a required piece of Ninja; it's +just a helpful utility for build-file-generation systems that already +use Python. +""" + +import re +import textwrap + +def escape_path(word): + return word.replace('$ ', '$$ ').replace(' ', '$ ').replace(':', '$:') + +class Writer(object): + def __init__(self, output, width=78): + self.output = output + self.width = width + + def newline(self): + self.output.write('\n') + + def comment(self, text): + for line in textwrap.wrap(text, self.width - 2, break_long_words=False, + break_on_hyphens=False): + self.output.write('# ' + line + '\n') + + def variable(self, key, value, indent=0): + if value is None: + return + if isinstance(value, list): + value = ' '.join(filter(None, value)) # Filter out empty strings. + self._line('%s = %s' % (key, value), indent) + + def pool(self, name, depth): + self._line('pool %s' % name) + self.variable('depth', depth, indent=1) + + def rule(self, name, command, description=None, depfile=None, + generator=False, pool=None, restat=False, rspfile=None, + rspfile_content=None, deps=None): + self._line('rule %s' % name) + self.variable('command', command, indent=1) + if description: + self.variable('description', description, indent=1) + if depfile: + self.variable('depfile', depfile, indent=1) + if generator: + self.variable('generator', '1', indent=1) + if pool: + self.variable('pool', pool, indent=1) + if restat: + self.variable('restat', '1', indent=1) + if rspfile: + self.variable('rspfile', rspfile, indent=1) + if rspfile_content: + self.variable('rspfile_content', rspfile_content, indent=1) + if deps: + self.variable('deps', deps, indent=1) + + def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, + variables=None, implicit_outputs=None, pool=None, dyndep=None): + outputs = as_list(outputs) + out_outputs = [escape_path(x) for x in outputs] + all_inputs = [escape_path(x) for x in as_list(inputs)] + + if implicit: + implicit = [escape_path(x) for x in as_list(implicit)] + all_inputs.append('|') + all_inputs.extend(implicit) + if order_only: + order_only = [escape_path(x) for x in as_list(order_only)] + all_inputs.append('||') + all_inputs.extend(order_only) + if implicit_outputs: + implicit_outputs = [escape_path(x) + for x in as_list(implicit_outputs)] + out_outputs.append('|') + out_outputs.extend(implicit_outputs) + + self._line('build %s: %s' % (' '.join(out_outputs), + ' '.join([rule] + all_inputs))) + if pool is not None: + self._line(' pool = %s' % pool) + if dyndep is not None: + self._line(' dyndep = %s' % dyndep) + + if variables: + if isinstance(variables, dict): + iterator = iter(variables.items()) + else: + iterator = iter(variables) + + for key, val in iterator: + self.variable(key, val, indent=1) + + return outputs + + def include(self, path): + self._line('include %s' % path) + + def subninja(self, path): + self._line('subninja %s' % path) + + def default(self, paths): + self._line('default %s' % ' '.join(as_list(paths))) + + def _count_dollars_before_index(self, s, i): + """Returns the number of '$' characters right in front of s[i].""" + dollar_count = 0 + dollar_index = i - 1 + while dollar_index > 0 and s[dollar_index] == '$': + dollar_count += 1 + dollar_index -= 1 + return dollar_count + + def _line(self, text, indent=0): + """Write 'text' word-wrapped at self.width characters.""" + leading_space = ' ' * indent + while len(leading_space) + len(text) > self.width: + # The text is too wide; wrap if possible. + + # Find the rightmost space that would obey our width constraint and + # that's not an escaped space. + available_space = self.width - len(leading_space) - len(' $') + space = available_space + while True: + space = text.rfind(' ', 0, space) + if (space < 0 or + self._count_dollars_before_index(text, space) % 2 == 0): + break + + if space < 0: + # No such space; just use the first unescaped space we can find. + space = available_space - 1 + while True: + space = text.find(' ', space + 1) + if (space < 0 or + self._count_dollars_before_index(text, space) % 2 == 0): + break + if space < 0: + # Give up on breaking. + break + + self.output.write(leading_space + text[0:space] + ' $\n') + text = text[space+1:] + + # Subsequent lines are continuations, so indent them. + leading_space = ' ' * (indent+2) + + self.output.write(leading_space + text + '\n') + + def close(self): + self.output.close() + + +def as_list(input): + if input is None: + return [] + if isinstance(input, list): + return input + return [input] + + +def escape(string): + """Escape a string such that it can be embedded into a Ninja file without + further interpretation.""" + assert '\n' not in string, 'Ninja syntax does not allow newlines' + # We only have one special metacharacter: '$'. + return string.replace('$', '$$') + + +def expand(string, vars, local_vars={}): + """Expand a string containing $vars as Ninja would. + + Note: doesn't handle the full Ninja variable syntax, but it's enough + to make configure.py's use of it work. + """ + def exp(m): + var = m.group(1) + if var == '$': + return '$' + return local_vars.get(var, vars.get(var, '')) + return re.sub(r'\$(\$|\w*)', exp, string) \ No newline at end of file diff --git a/tools/str.c b/tools/str.c new file mode 100644 index 0000000..be68c9f --- /dev/null +++ b/tools/str.c @@ -0,0 +1,212 @@ +// str.c +// part of Final Fantasy VII Decomp +// converts a C-style string into a FF7-style string +#include +#include +#include + +unsigned char map_ascii[0x80]; +const char* map_utf8[] = { + "\xB4" + "‘", + "\xB5" + "’", + "\xB4" + "❛", + "\xB5" + "❜", +}; + +void init() { + unsigned char ch; + for (ch = ' '; ch <= '~'; ch++) { + map_ascii[ch] = ch - 0x20; + } +} + +const char* remap_string(FILE* out, int padding, const char* str) { + fputs("{", out); + int first = 1; + while (*str) { + unsigned char ch = (unsigned char)*str++; + padding--; + if (!first) { + fputs(", ", out); + } + first = 0; + if (ch == '\\') { + fprintf(out, "0x%02X", (unsigned char)*str++); + } else if (ch == '"') { + // FF7-style string terminator + fputs("0xFF", out); + break; + } else if (ch >= 0x20 && ch < 0x80) { + fprintf(out, "0x%02X", map_ascii[ch]); + } else { + size_t len; + unsigned char re = 0; + for (int i = 0; i < sizeof(map_utf8) / sizeof(void*); i++) { + len = strlen(&map_utf8[i][1]); + if (strncmp(str - 1, &map_utf8[i][1], len) == 0) { + re = map_utf8[i][0]; + break; + } + } + if (!re) { + fprintf(stderr, "WARNING: unrecognized byte %02X\n", ch); + break; + } else { + str += len - 1; + fprintf(out, "0x%02X", re); + } + } + } + while (--padding > 0) { + if (!first) { + fputs(", ", out); + } + first = 0; + fputs("0", out); + } + fputc('}', out); + return str + 1; // skip the ')' character +} + +void rewrite_line(FILE* out, const char* line) { + // checks for all the `_S(x)` and `_S(len, x)` in the current line + while (*line) { + const char* begin = strstr(line, "_S"); + if (begin) { + const char* next = begin; + int padding = 0; + if (strncmp(next, "_S(\"", 4) == 0) { + // it seems to be a _S("") + next += 4; + padding = -1; + } else if (strncmp(next, "_SL(", 4) == 0) { + // it seems to be a _S(len, "") + next += 4; + if (next[0] == '0' && next[1] == 'x') { + next += 2; + padding = (int)strtol(next, NULL, 16); + } else { + padding = (int)strtol(next, NULL, 10); + } + if (padding) { + next = strchr(next, ',') + 1; + if (next) { + next = strchr(next, '"') + 1; + } + } + } + if (padding) { + // padding is non-zero, we probably have a valid macro + fwrite(line, 1, begin - line, out); + line = remap_string(out, padding, next); + continue; // catch more macro at the same line + } + } + // write the rest of the string and returns + fputs(line, out); + return; + } +} + +int rewrite_file(FILE* out, FILE* in) { + char buf[0x2000]; + while (fgets(buf, sizeof(buf), in)) { + rewrite_line(out, buf); + } + return 0; +} + +int preview(const char* file_name, const char* str_offset) { + if (!file_name || !str_offset || !*str_offset) { + return 1; + } + if (str_offset[0] == '0' && str_offset[1] == 'x') { + str_offset += 2; + } + + FILE* f = fopen(file_name, "rb"); + if (!f) { + fprintf(stderr, "failed to open %s\n", file_name); + return 1; + } + fseek(f, strtol(str_offset, NULL, 16), SEEK_SET); + while (1) { + int ch = fgetc(f); + if (ch == -1) { + fprintf(stderr, "EOF\n"); + break; + } + if (ch == 0xFF) { + break; + } + if (ch >= 0x60) { + fprintf(stderr, "unrecognized byte %02X\n", ch); + break; + } else { + fputc(ch + 0x20, stdout); + } + } + fputc('\n', stdout); + fclose(f); + return 0; +} + +int test_str(const char* str, const char* expected) { + char actual[0x2000]; + FILE* stream = fmemopen(actual, sizeof(actual), "w"); + if (!stream) { + perror("fmemopen failed"); + return -1; + } + rewrite_line(stream, str); + fclose(stream); + if (strcmp(actual, expected) != 0) { + printf("[FAIL] %s\n", str); + printf(" expected: %s\n", expected); + printf(" actual : %s\n", actual); + return 1; + } + printf("[PASS] %s\n", str); + return 0; +} + +int test() { + int r = 0; + r |= test_str("ignore me", "ignore me"); + r |= test_str("char str[] = _S(\"Hello FF7\");", + "char str[] = {0x28, 0x45, 0x4C, 0x4C, 0x4F, 0x00, " + "0x26, 0x26, 0x17, 0xFF};"); + r |= test_str("char str[] = _SL(10, \"test\");", + "char str[] = {0x54, 0x45, 0x53, 0x54, 0xFF, 0, 0, 0, 0};"); + r |= test_str("char str[] = _SL(0xA, \"test\");", + "char str[] = {0x54, 0x45, 0x53, 0x54, 0xFF, 0, 0, 0, 0};"); + r |= test_str("_S(99, \"invalid\")", "_S(99, \"invalid\")"); + r |= test_str("_SL(0, \"invalid\")", "_SL(0, \"invalid\")"); + r |= test_str("_SL(\"invalid\")", "_SL(\"invalid\")"); + r |= test_str("_SL(1, \"ok\")", "{0x4F, 0x4B, 0xFF}"); + r |= test_str("_S(\"aa'bb\")", "{0x41, 0x41, 0x07, 0x42, 0x42, 0xFF}"); + r |= test_str("_S(\"‘’❛❜\")", "{0xB4, 0xB5, 0xB4, 0xB5, 0xFF}"); + return r; +} + +int main(int argc, char* argv[]) { + init(); + if (argc == 1) { + // TTY-mode + return rewrite_file(stdout, stdin); + } else if (argc == 3) { + return preview(argv[1], argv[2]); + } else if (argc == 2 && !strcmp(argv[1], "--test")) { + return test(); + } else { + printf("Final Fantasy VII string conversion tool\n"); + printf("Usage\n"); + printf(" cat | bin/str > \n"); + printf(" bin/str 0x\n"); + return 0; + } +} diff --git a/tools/symbols.py b/tools/symbols.py new file mode 100755 index 0000000..0640ba4 --- /dev/null +++ b/tools/symbols.py @@ -0,0 +1,83 @@ +#!.venv/bin/python3 +import os +import sys +import subprocess + + +def parse_symbol_line(symbol_entry: str) -> tuple[str, str, str]: + parts = symbol_entry.strip().split(" ") + if len(parts) != 3: + raise Exception(f"invalid symbol entry: {symbol_entry}") + return parts[0], parts[1], parts[2] + + +def get_symbols_from_file(file_path: str) -> list[tuple[str, str, str]]: + if not os.path.isfile(file_path): + raise Exception(f"file {file_path} not found or is not a file") + result = subprocess.run( + ["nm", file_path], capture_output=True, text=True, check=True + ) + return [ + parse_symbol_line(line) for line in result.stdout.strip().split("\n") if line + ] + + +def is_section_header(name: str) -> bool: + if len(name) < 2: + return False + if name.endswith("_c") or name.endswith("__s"): + return True + if name.endswith("_END") or name.endswith("_START") or name.endswith("VRAM"): + return True + return False + + +def is_label(name: str) -> bool: + return name.startswith(".L") + + +def is_jump_table(name: str) -> bool: + return name.startswith("jtbl_") + + +def is_splat_data(name: str) -> bool: + return name.startswith("D_") + + +def is_function(name: str) -> bool: + return ( + not is_section_header(name) + and not is_label(name) + and not is_jump_table(name) + and not is_splat_data(name) + ) + + +def is_data(name: str) -> bool: + return ( + not is_section_header(name) and not is_label(name) and not is_jump_table(name) + ) + + +def filter_functions( + symbol_list: list[tuple[str, str, str]], +) -> list[tuple[str, str, str]]: + return [ + symbol + for symbol in symbol_list + if (symbol[1] == "T" and is_function(symbol[2])) + or (symbol[1] == "B" and is_data(symbol[2])) + ] + + +if __name__ == "__main__": + if len(sys.argv) < 2: + print( + f"Usage: {sys.executable} {sys.argv[0]} [elf_file_paths...]" + ) + sys.exit(1) + functions = [] + for elf_file_path in sys.argv[1:]: + symbols = get_symbols_from_file(elf_file_path) + functions += filter_functions(symbols) + sys.stdout.writelines([f"{s[2]} = 0x{s[0]};\n" for s in functions]) From 256a4db36044bb80a5757c133f0e984c3f703598 Mon Sep 17 00:00:00 2001 From: armstrca Date: Fri, 24 Apr 2026 18:13:11 -0500 Subject: [PATCH 2/2] battle, ending, field, main, menu, world progress --- src/battle/battle.c | 108 ++++++++- src/battle/battle1.c | 52 ++++- src/battle/battle2.c | 47 +++- src/battle/battle3.c | 34 +++ src/ending/ending.c | 15 +- src/field/field.c | 24 +- src/main/18B8.c | 92 ++++++-- src/main/akao.c | 4 +- src/menu/bginmenu.c | 5 +- src/world/world.c | 532 +++++++++++++++++++++++++++++++++++++++---- 10 files changed, 822 insertions(+), 91 deletions(-) diff --git a/src/battle/battle.c b/src/battle/battle.c index 7c471a7..da17ffa 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -32,6 +32,9 @@ const s32 D_800A0108 = 21; const s32 D_800A010C[] = {2, 22, 3, 23, 4}; // entrypoint + +s32 func_800AD8DC(s32); // extern + INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A1158); INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A1798); @@ -357,6 +360,9 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A5250); INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A555C); +extern s32 D_800F3A40; +extern s32 D_800F3A42; + INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A55BC); INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A55F4); @@ -444,9 +450,22 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A68FC); void func_800A6A3C(s32 arg0, s32 arg1) { D_800F5BB8[arg0].unkE |= arg1; } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6A70); +void func_800A555C(); // extern + +void func_800A6A70(s32 arg0) { + s32 temp_v1; + + func_800A555C(); + temp_v1 = arg0 * 0x44; + *(&D_800F5BB8->unkE + temp_v1) = *(&D_800F5BB8->unkE + temp_v1) | 9; +} -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6AC4); +void func_800A6AC4(void) { + D_800F5F44.D_800F7DC4 &= 0xFC0F; + D_800F5F44.D_800F7DCA = D_800F5F44.D_800F7DCA & 0xFC0F; + D_800F5F44.D_800F7DAC = D_800F5F44.D_800F7DAC & 0xFC0F; + D_800F5F44.D_800F7DC2 = D_800F5F44.D_800F7DC2 & 0xFC0F; +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6B1C); @@ -454,7 +473,13 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6B88); void func_800A6BFC(void) {} -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6C04); +void func_800A6C04(s32 arg0) { + s16 sp10; + + sp10 = (s16)D_801636B8[arg0].D_801636B8; + D_800F5F44.D_800F7DBE = func_800A5EB0(func_800151F4(0x26), &sp10) + 0x100; + D_800F5F44.D_800F7DC0 = 0xF; +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6C5C); @@ -462,7 +487,14 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6CC0); void func_800A6D10(s32 arg0) { func_800A3E98(arg0, 3, 2, 54, 0); } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6D3C); +void func_800A6D3C(s32 arg0) { + s32 temp_v1; + + temp_v1 = D_800F83E0[arg0].unk0; + if (temp_v1 & 0x2000) { + D_800F83E0[arg0].unk0 = (temp_v1 & ~0x2000) | 0x4000; + } +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A6D88); @@ -485,7 +517,12 @@ void func_800A7034(s32 arg0, s16 arg1) { void func_800A7060(s32 arg0, s32 arg1) { func_800A7254(0, arg0, 12, arg1); } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A7090); +void func_800A7090(s32 arg0) { + s32 temp_v1; + + temp_v1 = arg0 * 0x44; + *(&D_800F5BB8->unk29 + temp_v1) = *(&D_800F5BB8->unk29 + temp_v1) | 0x40; +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A70C4); @@ -571,9 +608,17 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A866C); INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8A6C); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8C94); +void func_800A8C94(void) { + D_80063014->unk8C = 0xFF; + D_80063014->unk40 = 0xB0; + D_80063014->unk80 |= 1; + D_80063014->unk3C = (s32)D_80063014->unk3C >> 1; +} -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800A8CC8); +void func_800A8CC8(void) { + D_80063014->unk6C &= ~0x2000; + D_80063014->unk3C /= 3; +} void func_800A8D04(void) { D_80063014->unk48 = 2; } @@ -804,7 +849,15 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD73C); INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD804); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD890); +s32 func_800AD890(s32 arg0) { + s32 var_a0; + + var_a0 = arg0; + if (D_80063014->unk228 & 0x10) { + var_a0 -= (var_a0 * 3) / 10; + } + return var_a0; +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800AD8DC); @@ -823,7 +876,15 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADDE8); void func_800ADE5C(void) { D_80063014->unk214 = D_80063014->unk48 * 20; } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800ADE84); +void func_800ADE84(void) { + s32 var_v1; + + var_v1 = D_80063014->unk48 * (0x200 - D_80063014->unk210); + if (var_v1 < 0) { + var_v1 += 0x1F; + } + D_80063014->unk214 = func_800AD8DC(var_v1 >> 5); +} void func_800ADED8(void) { if (D_80063014->unk230 & 0x40) { @@ -977,9 +1038,30 @@ void func_800B0DF8(void) { } } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0E5C); +s32 func_800B0E5C(s32 arg0) { + s32 var_a0; + + var_a0 = arg0; + if ((var_a0 < 0xFF) && (D_80063014->unkC8 & 0x20)) { + var_a0 -= (var_a0 * 3) / 10; + } + return var_a0; +} + +s32 func_800B0EB4(s32 arg0) { + s32 temp_v1; + s32 var_a0; -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0EB4); + temp_v1 = D_800F83E0[arg0].unk0; + var_a0 = arg0 < 4; + if (temp_v1 & 0x40) { + var_a0 += 1; + } + if (temp_v1 & 0x400000) { + var_a0 += 1; + } + return var_a0 & 1; +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B0F04); @@ -1074,7 +1156,9 @@ u8 func_800B2F30(void) { return func_80014B70(); } u16 func_800B2F50(void) { return func_80014BE4(); } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle", func_800B2F70); +s32 func_800B2F70(void) { + return (((func_800B2F50() & 0xFFFF) * 0x63) / 65535) + 1; +} static s32 func_800B2FC4(s32 arg0) { return (arg0 * (func_800B2F30() + 0xF01)) >> 12; diff --git a/src/battle/battle1.c b/src/battle/battle1.c index efcdc54..127cd91 100644 --- a/src/battle/battle1.c +++ b/src/battle/battle1.c @@ -18,6 +18,19 @@ static void func_800BB864(void); static void func_800C4D10(void); DR_MODE* func_800C4DC8(s16 x, s16 y, s16 w, s16 h, s32*); +extern s8 D_800F8374; +extern s8 D_800F837C; +extern s8 D_800F8380; +extern s32 D_800F9F30; +extern s8 D_801031E0; +extern s8 D_801517C4; +extern s8 D_801620A0; +extern s8 D_801620A4; +extern s8 D_80162974; +extern s8 D_80163B38; + +s16 SquareRoot0(s32, s16); // extern + void func_800B30E4(void) { s32 i; @@ -162,6 +175,9 @@ static void func_800B3DBC(void) { } } +void func_800BC1E0(u8); // extern +void func_800C5BEC(); // extern + INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3E2C); INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800B3FAC); @@ -590,13 +606,34 @@ static void func_800BB944(void) { func_8002DA7C(); } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB978); +void func_800BB978(void) { + *D_8009A000 = 0xC1; + *D_8009A004 = 0x12C; + *D_8009A008 = 0; + func_8002DA7C(); +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB9B8); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BB9FC); +void func_800BB9FC(s32 arg0) { + s32 temp_a0; + + *D_8009A000 = 0x2B; + temp_a0 = arg0 & 0xFFFF; + *D_8009A004 = 0x40; + *D_8009A008 = temp_a0; + func_8002DA7C(temp_a0); +} -INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBA40); +void func_800BBA40(s32 arg0) { + s32 temp_a0; + + *D_8009A000 = 0x20; + temp_a0 = arg0 & 0xFFFF; + *D_8009A004 = 0x40; + *D_8009A008 = temp_a0; + func_8002DA7C(temp_a0); +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800BBA84); @@ -686,7 +723,12 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0254); INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C0314); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C03B8); +s16 func_800C03B8(s16 arg0, s16 arg1) { + s32 temp_a0; + + temp_a0 = arg0 - arg1; + return SquareRoot0(temp_a0 * temp_a0, arg1); +} s32 func_800C03FC(s32 arg0, s32 arg1) { return arg0 < 0 ? -arg1 : arg1; } @@ -998,6 +1040,8 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C59B8); INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5ADC); +extern s32 D_800F9DA8; + INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5BEC); INCLUDE_ASM("asm/us/battle/nonmatchings/battle1", func_800C5C18); diff --git a/src/battle/battle2.c b/src/battle/battle2.c index 3576e70..53b3f8d 100644 --- a/src/battle/battle2.c +++ b/src/battle/battle2.c @@ -39,6 +39,16 @@ void func_801B0040(s16, u8); void func_801B0054(s16, u8); void func_801B0084(s16, u8); +extern u8 D_800F10EC[]; +extern u8 D_800F11E8[]; +extern u8 D_800F1304[]; +extern s32 D_800F14D4; + +void func_800D6F78(); // extern +void func_800D70C0(); // extern + +void func_800D57C0(); // extern + static s32 func_800C7B60(s16 arg0, s16 nItems, u8* arg2) { BattleModelSub* var_a0; s32 var_a1; @@ -1127,7 +1137,15 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5774); INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D57C0); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D58D0); +void func_800D58D0(s16 arg0, s16 arg1, s16 arg2) { + Unk80162978* temp_v0; + + temp_v0 = &D_80162978[func_800BBEAC(func_800D57C0)]; + temp_v0->D_80162978 = 0; + temp_v0->D_80162980 = arg0; + temp_v0->D_8016297E = arg2; + temp_v0->D_8016297C = arg1; +} void func_800D5938(); INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5938); @@ -1141,7 +1159,11 @@ static void func_800D5A68(s16 arg0, s16 arg1) { temp_v0->D_8016297C = arg0; } -INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5AC0); +s32 func_800D5AC0(s32 arg0, s32 arg1) { + return (((s32)(arg0 & 0xFF0000) / arg1) & 0xFF0000) | + (((s32)(arg0 & 0xFF00) / arg1) & 0xFF00) | + (((s32)(arg0 & 0xFF) / arg1) & 0xFF); +} INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D5B6C); @@ -1155,14 +1177,10 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6394); INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D650C); -extern u8 D_800F10EC[]; -extern u8 D_800F11E8[]; -extern u8 D_800F1304[]; u8* const D_800A0DC8[] = {D_800F10EC, D_800F11E8, D_800F1304}; INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D6734); void func_800D6734(s32, s32); -extern s32 D_800F14D4; static void func_800D67BC(s32 arg0) { D_800F14D4 = 0x88; @@ -1196,7 +1214,22 @@ INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D70C0); INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D7178); void func_800D72B4(); -INCLUDE_ASM("asm/us/battle/nonmatchings/battle2", func_800D72B4); + +void func_800D72B4(void) { + Unk801621F0* temp_s0; + + temp_s0 = &D_801621F0[D_801590D4]; + if (D_80062D98 == 0) { + if (temp_s0->D_801621F2 == 0) { + func_800D5138(1); + } + if (temp_s0->D_801621F2 == 2) { + func_800D51D4(1); + temp_s0->D_801621F0 = -1; + } + temp_s0->D_801621F2 = (u16)temp_s0->D_801621F2 + 1; + } +} static void func_800D7340(void) { func_800BBEAC(func_800D72B4); } diff --git a/src/battle/battle3.c b/src/battle/battle3.c index 05ea587..7991b22 100644 --- a/src/battle/battle3.c +++ b/src/battle/battle3.c @@ -5,6 +5,26 @@ static void func_800E5358(void); static void func_800E4B88(void); static s32 func_800E4BCC(void); +extern s8 D_800F389D; +extern s8 D_800F38A4; +extern s8 D_800F38A5; +extern s16 D_800F92E2; +extern s16 D_800F92E4; +extern s16 D_800F92E6; +extern s16 D_800F92E8; +extern s16 D_800F92EA; +extern s8 D_800F92EC; +extern s8 D_800F92ED; +extern s8 D_800F92EE; +extern s8 D_800F92EF; +extern s8 D_800F92F0; +extern s8 D_800F92F1; +extern s8 D_800F92F2; +extern s8 D_800F92F3; +extern s8 D_800F977C; + +extern u16 D_800F3124; + void func_800D8A04(void) {} s32 func_800D8A0C(s32 arg0) { return arg0 < 0 ? -arg0 : arg0; } @@ -77,6 +97,9 @@ static void func_800DBF54(void) { func_800269C0(D_80077F64); } static void func_800DBF7C(void) { D_800F3122 = 0; } +extern s32 D_800492FC; +extern s32 D_800F55D8; + INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DBF8C); INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800DC0CC); @@ -366,6 +389,13 @@ void func_800E084C(void) { INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E08C4); +extern s32 D_800F1E58; +extern s32 D_800F1E5A; +extern s32 D_800F1E5C; +extern s32 D_800F1E5E; +extern s32 D_800F1E60; +extern s32 D_800F1E62; + INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E0BE0); static void func_800E0DF4(void) { @@ -502,6 +532,10 @@ s32 func_800E54EC(void) { INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5530); +extern s32 D_800F33B0; +extern s32 D_80163778; +extern s32 D_80163B70; + INCLUDE_ASM("asm/us/battle/nonmatchings/battle3", func_800E5814); void func_800E58B0(void) { diff --git a/src/ending/ending.c b/src/ending/ending.c index 003733a..e806cc7 100644 --- a/src/ending/ending.c +++ b/src/ending/ending.c @@ -1,5 +1,11 @@ #include "common.h" +s32 func_80034410(); // extern + +extern s32 D_800A6528; + +extern s32 D_800AF410; + INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A0030); INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A04C4); @@ -32,9 +38,9 @@ INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A19A4); INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1E20); -INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1ED4); +void func_800A1ED4(s32 arg0) { D_800A6528 = arg0; } -INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1EE4); +s32 func_800A1EE4(void) { return 0; } INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A1EEC); @@ -62,7 +68,10 @@ INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A2274); INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22A4); -INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22D4); +s32 func_800A22D4(void) { + D_800AF410 = 0; + return 1; +} INCLUDE_ASM("asm/us/ending/nonmatchings/ending", func_800A22E4); diff --git a/src/field/field.c b/src/field/field.c index 0280dd6..f433bf6 100644 --- a/src/field/field.c +++ b/src/field/field.c @@ -41,6 +41,11 @@ static void func_800DA424(s32 val, char* msg_out); static void func_800DA444(s32 val, char* msg_out); static void func_800DA480(s32 val, char* msg_out); +extern MATRIX* D_80083270; +extern MATRIX** D_80083578; +extern u8 D_8009AC2D; +extern u16 D_80114488; + INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800A1368); void func_800A1498(void) { @@ -168,7 +173,16 @@ INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AAB24); void func_800AB2AC(void) {} -INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB2B4); +void func_800AB2B4(void) { + MATRIX* var_v0; + + if ((D_80114488 == 0) || (D_8009AC2D == 1)) { + var_v0 = *D_80083578; + } else { + var_v0 = D_80083270; + } + D_80071E40 = var_v0; +} INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800AB310); @@ -468,7 +482,13 @@ s32 func_800C0B54(void) { return 1; } -INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0BE8); +s32 func_800C0BE8(void) { + u16* temp_v0; + + temp_v0 = &D_800831FC[D_800722C4]; + *temp_v0 += 1; + return 1; +} INCLUDE_ASM("asm/us/field/nonmatchings/field", func_800C0C18); diff --git a/src/main/18B8.c b/src/main/18B8.c index 631cf50..974b356 100644 --- a/src/main/18B8.c +++ b/src/main/18B8.c @@ -169,6 +169,14 @@ void func_8001B834(s32); void func_8001BD50(u8, u8, u8); u8 func_8001F6B4(); +extern s32 D_80048D24; // field.X sector +extern u32 D_80048D28; // field.X size + +extern s8 D_8007EAC2; +extern s8 D_8007EAC4; +extern s8 D_8007EB1E; +extern s8 D_8007EB20; + void __main(void) {} INCLUDE_ASM("asm/us/main/nonmatchings/18B8", __SN_ENTRY_POINT); @@ -226,12 +234,21 @@ void func_8001171C(void) { InitGeom(); } -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80011784); +void func_80011784(void) { + SetDefDispEnv(D_8007EB68, 0, 0xE8, 0x140, 0xF0); + SetDefDispEnv(&D_8007EB68[1], 0, 0, 0x140, 0xF0); + SetDefDrawEnv(D_8007EAAC, 0, 8, 0x140, 0xE0); + SetDefDrawEnv(&D_8007EAAC[1], 0, 0xF0, 0x140, 0xE0); + D_8007EAC2 = 1; + D_8007EB1E = 1; + D_8007EAC4 = 0; + D_8007EB20 = 0; + PutDispEnv(D_8007EB68); + PutDrawEnv(D_8007EAAC); +} -void func_800A16CC(); // field loop -void func_800CF60C(); // field load -extern s32 D_80048D24; // field.X sector -extern u32 D_80048D28; // field.X size +void func_800A16CC(); // field loop +void func_800CF60C(); // field load void func_80011860(void) { if (D_800965EC != 5 && D_800965EC != 13) { @@ -482,7 +499,17 @@ void func_80014C70() { D_80062E20 = 0; } -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80014C80); +u8* func_80014C80(s32 arg0) { + s32 temp_v0; + s32 temp_v1; + + temp_v0 = D_80062E1C; + D_80062E1C = temp_v0 + 1; + temp_v1 = D_80062E20; + D_80069490[temp_v0] = (u16)temp_v1; + D_80062E20 = temp_v1 + arg0; + return &D_80063690[temp_v1]; +} s32 func_80014CBC(s32 arg0, s32 arg1) { s32 var_a2; @@ -562,7 +589,7 @@ INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800159B0); INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015AFC); -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015B44); +void func_80015B44(s32 arg0) { D_80062E30 = arg0; } INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_80015B50); @@ -931,7 +958,10 @@ void SetupGamepad(void) { D_80062FA0 = 0; } -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C484); +void func_8001C484(s32 arg0) { + D_80062E9C = arg0; + D_80062E94 = 0x14; +} INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001C498); @@ -1217,11 +1247,35 @@ void func_8001F6E4(s16 arg0, s16 arg1, s16 arg2) { INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001F710); -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FA28); +void func_8001FA28(s32 arg0) { + s32 temp_a0; -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FA68); + temp_a0 = arg0 & 0xFFFF; + *D_8009A000 = 0x30; + *D_8009A004 = temp_a0; + *D_8009A008 = temp_a0; + func_8002DA7C(temp_a0); +} -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8001FAAC); +void func_8001FA68(s32 arg0) { + s32 temp_a0; + + *D_8009A000 = 0x28; + temp_a0 = arg0 & 0xFFFF; + *D_8009A004 = 0x40; + *D_8009A008 = temp_a0; + func_8002DA7C(temp_a0); +} + +void func_8001FAAC(s32 arg0) { + s32 temp_a0; + + *D_8009A000 = 0x29; + temp_a0 = arg0 & 0xFFFF; + *D_8009A004 = 0x40; + *D_8009A008 = temp_a0; + func_8002DA7C(temp_a0); +} void func_8001FAF0(void) {} @@ -1278,11 +1332,23 @@ void func_80021044(DRAWENV* draw_env, DISPENV* disp_env) { SetDispMask(1); } -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800211B8); +void func_800211B8(s32 arg0) { D_80062DEC = arg0; } INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_800211C4); -INCLUDE_ASM("asm/us/main/nonmatchings/18B8", func_8002120C); +void func_800211C4(); // extern + +void func_8002120C(s32 arg0) { + s32 temp_v0; + + temp_v0 = D_80062DD4; + D_80062DD4 = arg0; + D_80062DD0 = temp_v0; + if ((arg0 != 0) && + (((u32)(temp_v0 - 3) >= 2U) || ((u32)(arg0 - 3) >= 2U))) { + func_800211C4(); + } +} void func_80021258(s32 arg0) { func_80015248(13, arg0, 8); } diff --git a/src/main/akao.c b/src/main/akao.c index e2d2122..84fe789 100644 --- a/src/main/akao.c +++ b/src/main/akao.c @@ -137,6 +137,8 @@ void func_8002BA08(Unk8002B7E0* arg0); void func_8002B8B4(Unk8002B7E0* arg0); void func_8002B668(Unk8002B7E0* arg0); +extern u16 D_80062FC8; + INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800293D0); INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_800293F4); @@ -247,8 +249,6 @@ void func_8002B2F8(Unk8002B7E0* arg0) { INCLUDE_ASM("asm/us/main/nonmatchings/akao", func_8002B3B4); -extern u16 D_80062FC8; - void func_8002B5A8(Unk8002B7E0* arg0) { if (D_8009A14E) { D_80062FC8 = arg0->unk10 ? arg0->unk10 : 0x10; diff --git a/src/menu/bginmenu.c b/src/menu/bginmenu.c index 5c6d513..dc61d38 100644 --- a/src/menu/bginmenu.c +++ b/src/menu/bginmenu.c @@ -20,6 +20,9 @@ extern u8 D_801D085C[2]; extern Unk80026448 D_801D0860[]; extern s8 D_801D086B; +extern u8 D_8009C778[]; // Savemap.party +extern u8 D_8009C798[]; // Savemap.party + void func_801D0000(void) { volatile s32 padding; func_80026448(&D_801D0860[0], 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 0, 1, 0); @@ -52,8 +55,6 @@ static void func_801D01BC(void) {} INCLUDE_ASM("asm/us/menu/nonmatchings/bginmenu", func_801D01C4); #else // -O1 -extern u8 D_8009C778[]; // Savemap.party -extern u8 D_8009C798[]; // Savemap.party s32 func_801D01C4(s32 arg0) { s32 var_a1; s32 var_a2; diff --git a/src/world/world.c b/src/world/world.c index dff8f3b..3469770 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -163,6 +163,68 @@ static const char D_800A0010[] = "JUMP "; static const char D_800A0018[] = "FROM "; static const char D_800A0020[] = "SCR-H"; +extern s16 D_8010AD44; +extern s16 D_8010AD48; +extern s16 D_8010AD4C; + +extern s32 D_800E5604; +extern s32 D_800E564C; +extern s32 D_800E5650; + +extern s32 D_80109D64; +extern s32 D_80109D68; + +extern s32 D_8010CACC; +extern s32 D_8010CAD0; +extern s32 D_8010CAD4; + +extern s32 D_80116274; + +extern s32 D_8010CA8C; + +extern s16 D_8010CB00; +extern s16 D_8010CB04; +extern s16 D_8010CB08; +extern s16 D_8010CB0C; +extern s16 D_8010CB10; + +extern s32 D_801163D8; +extern s32 D_801163DC; + +extern s16 D_800C68EE; +extern s16 D_800C6902; +extern s16 D_800C6916; +extern s32 D_8010CB14; + +extern s32 D_8010CB18; +extern s32 D_8010CB1C; + +extern s32 D_8010CAF4; + +extern s32 D_800BD144; +extern s32 D_8010CA1C; +extern s32 D_8010CA20; +extern s32 D_8010CA74; +extern s32 D_8010CA78; +extern s32 D_8010CAC0; +extern s32 D_8010CAC4; +extern s32 D_8010CAC8; + +extern s32 D_80109D5C; +extern s32 D_80109D60; + +extern s32 D_8010CB20; + +extern s32 D_80115A58; + +extern s32 D_8010C804; + +extern Unk8010AD3C D_80109D74; +extern Unk8010AD3C* D_8010AD38; +extern Unk8010AD3C* D_8010ADE4; + +s32 func_800AA580(Unk8010AD3C*); // extern + static void func_800A0B40(void) {} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A0B48); @@ -197,7 +259,13 @@ s32 func_800A1D14(void) { return D_800E560C & 0xFFF; } static void func_800A1D24(s32 arg0) { D_800E5608 = arg0 & 0xFFF; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1D38); +void func_800A1D38(s32 arg0) { + s32 temp_a0; + + temp_a0 = arg0 & 0xFFF; + D_800E5608 = temp_a0; + D_800E560C = temp_a0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A1D54); @@ -220,7 +288,23 @@ void func_800A2040(void) { static s16 func_800A2078(void) { return D_800E56D8; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A2088); +void func_800A2088(s32 arg0) { + s32 temp_v0; + s32 var_v1; + + temp_v0 = D_800E5648; + D_800E5648 = arg0; + D_800E5650 = temp_v0; + if (((u32)arg0 < 2U) && (D_800E5634 != 3)) { + D_800E5608 = 0; + } + var_v1 = 0xA0; + if (D_800E5648 == 0) { + var_v1 = 0x78; + } + D_800E564C = var_v1; + D_800E5604 = -(D_800E5648 != 3) & 0x78; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A2108); @@ -298,7 +382,9 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A3F4C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4008); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A4080); +s32 func_800A4080(void) { + return (D_800E5648 & 3) | ((func_800BCA38() * 4) & 0xC); +} void func_800A40B8(s32 arg0) { func_800A2088(arg0 & 3); @@ -424,7 +510,23 @@ static void func_800A7E8C(s32 arg0) { D_80109D6C = arg0; } static void func_800A7E9C(void) {} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A7EA4); +void func_800A4DDC(); // extern +void func_800A59A0(); // extern +void func_800A60D8(); // extern + +void func_800A7EA4(void) { + func_800A4DDC(); + func_800A59A0(); + func_800A60D8(); + D_80109D54 = 0; + D_80109D58 = 0; + D_80109D5C = 0; + D_80109D60 = 0; + D_800E5828 = 1; + D_80109D64 = 0; + D_80109D68 = 0; + D_80109D6C = 0; +} void func_800A7F18(void) { func_800A7F38(); } @@ -446,7 +548,10 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A835C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A86C4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A886C); +void func_800A886C(s32 arg0) { + D_80109D64 = 2; + D_80109D68 = arg0; +} void func_800A8888(s32 arg0) { D_800E5824 = arg0; } @@ -464,11 +569,30 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8AF4); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8B30); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8C70); +void func_800A8C70(Unk8010AD3C* arg0) { + Unk8010AD3C* temp_v0; + + if ((arg0 != NULL) && (arg0->unk0 == 0)) { + temp_v0 = D_8010AD38; + D_8010AD38 = arg0; + arg0->unk0 = (s32)temp_v0; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8CA4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8CE4); +void func_800A8B30(Unk8010AD40*); // extern + +void func_800A8CE4(void) { + Unk8010AD40* temp_s0; + + temp_s0 = D_8010AD40; + if ((temp_s0 != NULL) && (D_8010AD3C != NULL) && (D_8010AD3C->unk8 == 0)) { + func_800A8B30(temp_s0); + D_8010AD3C->unk8 = (s32)temp_s0; + D_8010AD40 = (Unk8010AD40*)D_8010AD3C; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8D58); @@ -488,27 +612,93 @@ void func_800A8FA0(void) { } } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A8FCC); +void func_800A8AF4(s32); // extern + +void func_800A8FCC(void) { + s32 temp_a0; + + if (D_8010AD40 != NULL) { + temp_a0 = D_8010AD40->unk8; + if (temp_a0 != 0) { + func_800A8AF4(temp_a0); + D_8010AD40->unk8 = 0; + } + } +} + +void func_800A9018(void) { + s32 temp_a0; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9018); + if (D_8010AD3C != NULL) { + temp_a0 = D_8010AD3C->unk8; + if (temp_a0 != 0) { + func_800A8AF4(temp_a0); + D_8010AD3C->unk8 = 0; + } + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9064); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A90EC); +void func_800A90EC(void) { + if (D_8010AD40 != NULL) { + D_8010AD3C = (Unk8010AD3C*)D_8010AD40; + } +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9110); +void func_800A9110(void) { + if (D_8010AD3C != NULL) { + D_8010AD40 = (Unk8010AD40*)D_8010AD3C; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9134); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9154); +s32 func_800A9154(void) { + u8 var_v0; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9174); + var_v0 = 0; + if (D_8010AD3C != NULL) { + var_v0 = D_8010AD3C->unk50; + } + return (s32)var_v0; +} + +s32 func_800A9174(void) { + u8 var_v0; + + var_v0 = 0; + if (D_8010AD40 != NULL) { + var_v0 = (u8)D_8010AD40->unk50; + } + return (s32)var_v0; +} Unk8010AD3C* func_800A9194(void) { return D_8010AD3C; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A91A4); +s32 func_800A91A4(s32 arg0) { + u8 temp_v1; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A91E0); + if (D_8010AD40 != NULL) { + temp_v1 = (u8)D_8010AD40->unk50; + if (temp_v1 < 0x20U) { + return (arg0 >> temp_v1) & 1; + } + } + return 0; +} + +s32 func_800A91E0(s32 arg0) { + u8 temp_v1; + + if (D_8010AD3C != NULL) { + temp_v1 = D_8010AD3C->unk50; + if (temp_v1 < 0x20U) { + return (arg0 >> temp_v1) & 1; + } + } + return 0; +} s32 func_800A921C(s32 arg0, u8 arg1) { if (arg1 >= 0x20) { @@ -517,11 +707,37 @@ s32 func_800A921C(s32 arg0, u8 arg1) { return (arg0 >> arg1) & 1; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9240); +s32 func_800A9240(void) { + s32 var_a1; + u8 temp_a0; + + if (D_8010AD40 != NULL) { + temp_a0 = (u8)D_8010AD40->unk50; + var_a1 = 0; + if ((temp_a0 == 4) || (temp_a0 == 0x13) || + ((u32)((u8)D_8010AD40->unk50 - 0x29) < 2U)) { + var_a1 = 1; + } + } else { + var_a1 = 0; + } + return var_a1; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A929C); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A92F8); +s32 func_800A92F8(s32 arg0) { + s32 temp_v1; + s32 var_a1; + + temp_v1 = arg0 & 0xFF; + var_a1 = 0; + if ((temp_v1 == 4) || (temp_v1 == 0x13) || + ((u32)((arg0 - 0x29) & 0xFF) < 2U)) { + var_a1 = 1; + } + return var_a1; +} static const s32 D_800A01D8[] = {0, 0xF000}; static const s32 D_800A01E0[] = {0, 0}; @@ -549,7 +765,11 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A97A8); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A97E4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9820); +void func_800A9820(s32 arg0) { + if (D_8010AD3C != NULL) { + D_8010AD3C->unk10 += arg0; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A984C); @@ -563,7 +783,16 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9910); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A993C); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9988); +void func_800A9988(void) { + s32 temp_v0; + + if (D_8010AD40 != NULL) { + temp_v0 = D_8010AD40->unk4; + if (temp_v0 != 0) { + D_8010AD3C = (Unk8010AD3C*)temp_v0; + } + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A99BC); @@ -595,7 +824,17 @@ void func_800A9D5C(s32 arg0) { func_800A9C64(D_8010AD3C, arg0); } void func_800A9D88(s32 arg0) { func_800A9C64(D_8010AD40, arg0); } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9DB4); +void func_800A9C64(Unk8010AD40*, s32); // extern + +void func_800A9DB4(s32 arg0) { + func_800A9C64(D_8010AD40, arg0); + if (D_8010AD40 != NULL) { + D_8010AD40->unk1C = D_8010AD40->unkC; + D_8010AD40->unk20 = D_8010AD40->unk10; + D_8010AD40->unk24 = D_8010AD40->unk14; + D_8010AD40->unk28 = D_8010AD40->unk18; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800A9E14); @@ -637,9 +876,27 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA304); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA580); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA640); +void func_800AA1B8(); // extern + +s32 func_800AA640(void) { + s32 temp_v0; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA684); + temp_v0 = func_800AA580(D_8010AD3C); + if (temp_v0 != 0) { + func_800AA1B8(); + } + return temp_v0; +} + +s32 func_800AA684(void) { + s32 var_v0; + + var_v0 = 0; + if (D_8010AD3C != NULL) { + var_v0 = D_8010AD3C->unk4; + } + return var_v0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA6A4); @@ -647,7 +904,11 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA6D0); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA7DC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8D8); +void func_800AA8D8(s16 arg0, s16 arg1, s16 arg2) { + D_8010AD44 = arg0; + D_8010AD48 = arg1; + D_8010AD4C = arg2; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AA8F8); @@ -663,7 +924,28 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB48C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB4F4); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB570); +void func_800AAB18(Unk8010AD3C*); // extern +void func_800AB398(Unk8010AD3C*); // extern + +void func_800AB570(void) { + Unk8010AD3C* var_s0; + Unk8010AD3C* var_s0_2; + + var_s0 = D_8010AD38; + if (var_s0 != NULL) { + do { + func_800AAB18(var_s0); + var_s0 = (Unk8010AD3C*)var_s0->unk0; + } while (var_s0 != NULL); + } + var_s0_2 = D_8010AD38; + if (var_s0_2 != NULL) { + do { + func_800AB398(var_s0_2); + var_s0_2 = (Unk8010AD3C*)var_s0_2->unk0; + } while (var_s0_2 != NULL); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AB5E4); @@ -695,7 +977,24 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AC700); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD63C); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD788); +void func_800AD63C(Unk8010AD3C*); // extern + +void func_800AD788(void) { + Unk8010AD3C* var_s0; + + D_8010ADE4 = &D_80109D74; + D_8010AD3C = &D_80109D74; + func_800AD63C(&D_80109D74); + var_s0 = D_8010AD38; + if (var_s0 != NULL) { + do { + D_8010AD3C = var_s0; + D_8010ADE4 = var_s0; + func_800AD63C(var_s0); + var_s0 = (Unk8010AD3C*)var_s0->unk0; + } while (var_s0 != NULL); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AD804); @@ -753,9 +1052,23 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF110); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF1A8); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF1E8); +void func_800AF1E8(u32 arg0, u32 arg1) { + if ((D_8010B3B8 != NULL) && (arg0 < 0x24U) && (arg1 < 0x1CU)) { + D_8010B3B8->unk0 &= 0x1FFF; + D_8010B3B8->unk8 &= 0x1FFF; + D_8010B3B8->unk0 |= arg0 << 0xD; + D_8010B3B8->unk8 |= arg1 << 0xD; + } +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF24C); +void func_800AF24C(s32 arg0, s32 arg1) { + if (D_8010B3B8 != NULL) { + D_8010B3B8->unk0 &= ~0x1FFF; + D_8010B3B8->unk8 &= ~0x1FFF; + D_8010B3B8->unk0 |= arg0 & 0x1FFF; + D_8010B3B8->unk8 |= arg1 & 0x1FFF; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800AF2A4); @@ -810,7 +1123,14 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B04AC); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0670); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B075C); +void func_800B0670(); // extern + +void func_800B075C(void) { + if (D_8010C804 == 0) { + func_800B0670(); + D_8010C804 = 1; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0794); @@ -824,7 +1144,19 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0D98); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B0E84); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B104C); +void func_800B104C(void) { + D_8010CA20 = 0; + D_8010CA1C = 0; + D_8010CA78 = 0; + D_8010CA74 = 0; + D_800BD144 = 0; + D_8010CAF0 = 0; + D_8010CA8C = 0; + D_8010CAC8 = 0; + D_8010CAC4 = 0; + D_8010CAC0 = 0; + D_8010CAF4 = 0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B10AC); @@ -890,27 +1222,69 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2E90); static void func_800B2F94(s32 arg0) { D_8010CAF0 = arg0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2FA4); +s32 func_800B2FA4(void) { + if (D_8010CA8C != 2) { + return -(D_8010CA8C == 3); + } + return 1; +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B2FD0); +s32 func_800B2FD0(void) { + s32 var_v1; -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3018); + var_v1 = 0; + if ((D_8010CACC != 0) || (D_8010CAD0 != 0) || (D_8010CAD4 != 0)) { + var_v1 = 1; + } + return var_v1; +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3044); +void func_800B3018(void) { + D_8010CAF4 = 1; + if (D_8010CA8C != 1) { + D_8010CA8C = 0; + } +} + +void func_800B3044(s16 arg0) { + D_8010CAFC = arg0; + D_8010CB10 = 0; + D_8010CB0C = 0; + D_8010CB08 = 0; + D_8010CB04 = 0; + D_8010CB00 = 0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B307C); static s16 func_800B32F0(void) { return D_8010CAFC; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3300); +void func_800B3300(u32 arg0) { + D_800C68EE = arg0 & 0xFF; + D_800C6902 = (arg0 >> 8) & 0xFF; + D_800C6916 = (arg0 >> 0x10) & 0xFF; + D_8010CB14 = (s32)(arg0 >> 0x18); + D_8010CB1C = 0; + D_8010CB18 = 0; +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3350); +s32 func_800B3350(void) { + return D_800C68EE | (D_800C6902 << 8) | (D_800C6916 << 0x10) | + (D_8010CB14 << 0x18); +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B338C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3418); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B37E0); +void func_800B37E0(s32* arg0, s32* arg1) { + if (arg0 != NULL) { + *arg0 += D_8010CB18; + } + if (arg1 != NULL) { + *arg1 += D_8010CB1C; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B3828); @@ -960,15 +1334,45 @@ void func_800B64A0(void) { func_800B63F0(D_801159E0); } static s32 func_800B64C8(void) { return D_801159E0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B64D8); +void func_800B64D8(s32 arg0) { + *D_8009A000 = 0x30; + *D_8009A004 = arg0; + func_8002DA7C(); +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B650C); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6570); +void func_800B6570(s32 arg0) { + *D_8009A000 = 0xC0; + *D_8009A004 = arg0; + func_8002DA7C(); +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B65A4); +void func_800B65A4(s32 arg0, s32 arg1) { + *D_8009A000 = 0xBD; + *D_8009A004 = arg0; + *D_8009A008 = arg1; + func_8002DA7C(); +} -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B65E0); +void func_800B65E0(s32 arg0) { + if (D_8010CB20 < arg0) { + *D_8009A000 = 0x20; + D_8010CB20 = arg0; + *D_8009A004 = 0x40; + *D_8009A008 = arg0; + goto block_4; + } + if (arg0 == -D_8010CB20) { + D_8010CB20 = 0; + *D_8009A000 = 0xF1; + func_8002DA7C(); + *D_8009A000 = 0xBC; + *D_8009A004 = 0; + block_4: + func_8002DA7C(); + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B667C); @@ -1006,7 +1410,12 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6E78); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B6EFC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7104); +void func_800B6B28(s16); // extern + +void func_800B7104(s16 arg0) { + D_80115A58 = (s32)arg0; + func_800B6B28(arg0); +} void func_800B7134(void) { func_8003408C(); @@ -1061,7 +1470,11 @@ void func_800B7820(void) { D_8009D2E7 = 0; } -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7838); +void func_800B7838(void) { + D_8011626C = 2; + D_80116270 = 0; + D_80116274 = 0; +} s32 func_800B785C(void) { return D_8011626C; } @@ -1083,7 +1496,15 @@ u16 func_800B7B3C(void) { return (D_800707BE >> 3) & 1; } INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7B54); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B7B78); +s32 func_800B7B78(void) { + s32 var_v1; + + var_v1 = D_80062F1B & 0x7F; + if (var_v1 >= 0x11) { + var_v1 *= 2; + } + return var_v1; +} u8 func_800B7BA0(void) { return D_80062F1B >> 7; } @@ -1159,7 +1580,12 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B8D4C); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B90C0); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800B95E8); +void func_800B95E8(void) { + *D_8009A000 = 0x30; + *D_8009A004 = 1; + *D_8009A008 = 0x40; + func_8002DA7C(); +} static const char D_800A09AC[] = "No mes data!"; static const char D_800A09BC[] = "mes busy="; @@ -1190,11 +1616,25 @@ INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB650); INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB7DC); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB8B0); +void func_800BB8B0(void) { + D_801163D4 = 0; + D_801163D8 = 0; + D_801163E8 = &D_801163E0; + D_801163EC = 0; + D_801163DC = 0; +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB8E8); -INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB9A0); +void func_800BB9A0(u8 arg0) { + s8* temp_v1; + + temp_v1 = D_801163E8; + if ((u32)temp_v1 < (u32)&D_801163E8) { + D_801163E8 = temp_v1 + 1; + *temp_v1 = (s8)arg0; + } +} INCLUDE_ASM("asm/us/world/nonmatchings/world", func_800BB9D0);