diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 000000000..3ce7a5e7f --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,93 @@ +# Building/Installing SA2 +This doc assumes you are somewhat familiar with using a terminal/command line. If not, you may find these instructions confusing and this project might not be for you at this stage. If you still want to continue, googling anything which you don't understand might be a first step and then asking in the discord would be a fallback option. + +**NOTE**: You can significantly speed up initial build times by passing the number of processes you wish to use for the build `make ... -j` + +## Setup environment + +### Easiest option: Dev container + +This step assumes you have vscode and you can run [Dev Containers](https://code.visualstudio.com/docs/remote/containers) already. If you wanna figure that out, look up a tutorial or something. + +1. Open this project in VSCode and then select "open dev container" when prompted +2. Wait for it to build. +3. Once running, skip to *Build the GBA rom* (no further install requirements) + +## Install system requirements *(without dev container)* + +### On Linux systems +``` +sudo apt update +sudo apt install build-essential binutils-arm-none-eabi gcc-arm-none-eabi libpng-dev xorg-dev libsdl2-dev gcc-mingw-w64 libarchive-tools +``` + +### On MacOS + +``` +brew install libpng sdl2 mingw-w64 +``` + +**ONLY** if building for GBA: Install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM) + + +### On Windows + +Install and use WSL (Ubuntu). Once using WSL follow the linux instructions in your WSL terminal. + +Another option is to install +[**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM) and build the project in MSYS but this is not recomended unless you know what you are doing. + + +## Install `agbcc` into the repo (skip if not compiling for the GBA) + +Clone the [agbcc](https://github.com/SAT-R/agbcc) repo into another folder + +Inside the `agbcc` folder, run `./build.sh` and then install the compiler in this repo `./install.sh path/to/sa2` + + +## Build the GBA rom + +### On Linux and MacOS + +Run `make` in the root of the repo to build + +### On Windows + +If using WSL, follow linux instructions. Otherwise: + +You can build using `make` in the MSYS environment provided with devkitARM. + +### Verify + +If the rom built successfully you will see this output + +```bash +sa2.gba: OK +``` + +## Build the port + +Building the port requires using Linux, MacOS or WSL. **Don't use the msys environement** + +Run all commands in the root directory of the project + +### For Windows + +1. Run `make SDL2.dll` +1. Run `make sdl_win32` +1. `sa2.sdl_win32.exe` will be created + +**NOTE**: If you get an error when running `make SDL2.dll`, you'll need to [download](https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-devel-2.30.3-mingw.zip) and extract SDL2 to an `ext` folder in the root of the repo before building. Afterwards you can re-run `make SDL2.dll` + + +### For Linux/MacOS + +1. Run `make sdl` +1. `sa2.sdl` will be created + +## Code formatting + +All C code in this repo is formatted with `clang-format-13`. If using the Dev Container this is installed automatically. + +To format code run `make format` + diff --git a/Makefile b/Makefile index 8b33f2d08..0e720a80f 100644 --- a/Makefile +++ b/Makefile @@ -436,7 +436,7 @@ ifeq ($(PLATFORM),sdl) else ifeq ($(PLATFORM),sdl_win32) @cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -lmingw32 -L$(ROOT_DIR)/$(SDL_MINGW_LIB) -lSDL2main -lSDL2.dll -lwinmm -lkernel32 -lxinput -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)" else - @cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -L$(ROOT_DIR)/libagbsyscall -lagbsyscall -lkernel32 -lgdi32 -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)" + @cd $(OBJ_DIR) && $(CC1) -mwin32 $(OBJS_REL) -L$(ROOT_DIR)/libagbsyscall -lagbsyscall -lkernel32 -lgdi32 -lwinmm -lxinput -lopengl32 -o $(ROOT_DIR)/$@ -Xlinker -Map "$(ROOT_DIR)/$(MAP)" endif endif diff --git a/README.md b/README.md index c33dda8ca..17d1204cf 100644 --- a/README.md +++ b/README.md @@ -16,19 +16,21 @@ [discord-badge]: https://img.shields.io/discord/1052347299457671200 [discord-link]: https://discord.gg/vZTvVH3gA9 +> :warning: **This project is not completed and still under active development** + This is a work in progress matching decompilation of Sonic Advance 2 It so far builds the following ROMs: * [**sa2.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=0890) `sha1: 7bcd6a07af7c894746fa28073fe0c0e34408022d` (USA) (En,Ja,Fr,De,Es,It) * [**sa2_europe.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=0900) `sha1: b0f64bdca097f2de8f05ac4c8caea2b80c5faeb1` (Europe) (En,Ja,Fr,De,Es,It) -* [**sa2_japan.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=0799) `sha1: dffd0188fc78154b42b401398a224ae0713edf23` (Japan) (En,Ja,Fr,De,Es,It) (:warning: Work in Progress) +* :construction: [**sa2_japan.gba**](https://datomatic.no-intro.org/index.php?page=show_record&s=23&n=0799) `sha1: dffd0188fc78154b42b401398a224ae0713edf23` (Japan) (En,Ja,Fr,De,Es,It) (Work in Progress) -The repo also builds the following: +It can also build: * **sa2.sdl** `make sdl` (Linux/MacOS SDL 64bit port) * **sa2.sdl_win32.exe** `make sdl_win32` (Windows SDL 32bit port) -* **sa2.win32.exe** `make win32` (Win32 native port, not functional) +* :construction: **sa2.win32.exe** `make win32` (Win32 native port, not functional) -### Current state +## Current state - :tada: The build is 100% from C files with [~80 functions which currently don't match](./asm/non_matching) - All assembly code extracted, disassembled, and decompiled by hand to their C equivilent @@ -38,80 +40,27 @@ The repo also builds the following: - The game compiles to a widescreen port (*426x240*) for multiple platforms - The "sub games" (Chao Garden and Collect The Rings) have been disassembled but not yet decompiled -### Community - -Join us on [discord](https://discord.gg/vZTvVH3gA9) to get started in helping out - -### Setting up the repository - -**Dev container** - -If you use `vscode` then consider using the provided [Dev Container](https://code.visualstudio.com/docs/remote/containers) which skips the requirement for any setup. This requires docker is installed on your system. Once running, skip to *Build the GBA rom* - -**Install system requirements** *(without dev container)* - -On Linux systems -``` -sudo apt install build-essential binutils-arm-none-eabi gcc-arm-none-eabi libpng-dev xorg-dev libsdl2-dev gcc-mingw-w64 libarchive-tools -``` - -On MacOS install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM) (if building for GBA) and - -``` -brew install libpng sdl2 mingw-w64 -``` - -On windows install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM) - -***Install `agbcc` into the repo (skip if not compiling for the GBA)*** - -Clone the [agbcc](https://github.com/sa2/agbcc) repo into another folder - -Inside the `agbcc` folder, run `./build.sh` and then install the compiler in this repo `./install.sh path/to/sa2` +## Setting up the repo -**Build the GBA rom** +Please see follow [these instructions](./INSTALL.md) -On Linux and MacOS, run `make` in the root of the repo to build. +## Community -On Windows you can build using `make` in the MSYS environment provided with devkitARM. - -This command will also build all the required tooling in the `tools` directory. -The `tools` directory contains a bunch of tooling (built by [pret](https://github.com/pret)) which is used to build assets and create a matching rom. - -If the rom built successfully you will see this output - -```bash -sa2.gba: OK -``` - -**Build the port** - -For Windows: `make sdl_win32` - -**NOTE**: When building for Windows, you'll need to [download](https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-devel-2.30.3-mingw.zip) and extract SDL2 to the `ext` folder in the root of the repo before building. You can use `make SDL2.dll` to do this for you. - -For Linux and MacOS: `make sdl` - -**NOTE**: You can significantly speed up initial build times by passing the number of processes you wish to use for the build `make ... -j` - -### Code formatting - -All C code in this repo is formatted with `clang-format-13`. If using the Dev Container this is installed automatically. - -To format code run `make format` +Join us on [discord](https://discord.gg/vZTvVH3gA9) to get started in helping out -### Notes +## Notes - The [Kirby & The Amazing Mirror](https://github.com/jiangzhengwenjz/katam/) decompilation uses a very similar codebase, as it was written by the same dev team (Dimps) - https://decomp.me is a great resource for helping to create matching functions - `ldscript.txt` tells the linker the order which files should be linked - For more info, see the [FAQs section](https://zelda64.dev/games/tmc) of TMC -### Credits +## Credits +- [JaceCear](https://github.com/JaceCear) for his dedication to understanding the internals of the graphics engine, writing [tools to extract this data](https://github.com/JaceCear/SA-Trilogy-Animation-Exporter), as well as massive effort in contributing towards the decompilation process, *and* setting up the PC ports - Shout out to [@froggestspirit](https://github.com/froggestspirit) for the drive to set this project up - Special thanks to [@normmatt](https://github.com/normmatt) for the initial repo setup and sounds decompilation -- [JaceCear](https://github.com/JaceCear) for his dedication to understanding the internals of the graphics engine and writing [tools to extract this data](https://github.com/JaceCear/SA-Trilogy-Animation-Exporter), as well as massive effort in contributing towards the decompilation process as well as creating the PC ports -- [Pokemon Reverse Engineering Team](https://github.com/pret) for their help with the project, and tooling for GBA decompilations + +- [Pokemon Reverse Engineering Tools](https://github.com/pret) community for their help with the project, and tooling for GBA decompilations - [Kermalis](https://github.com/Kermalis) for [their tool](https://github.com/Kermalis/VGMusicStudio) which was used to dump the game midis - [琪姬](https://github.com/laqieer) for their exellent work [documenting](https://github.com/FireEmblemUniverse/fireemblem8u/pull/137) all the quirks of matching midis diff --git a/asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc b/asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc deleted file mode 100644 index c7c79f5cb..000000000 --- a/asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc +++ /dev/null @@ -1,175 +0,0 @@ -.include "asm/macros.inc" -.include "constants/constants.inc" - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r7, r0, #0 @ r7 = boss - movs r0, #0x18 - adds r0, r0, r7 - mov ip, r0 @ ip = sub - movs r1, #0 - str r1, [r7, #0x18] - adds r0, r7, #0 - adds r0, #0x80 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r2, r7, #0 - adds r2, #0x82 - movs r0, #0x30 - strb r0, [r2] - adds r2, #1 - movs r0, #3 - strb r0, [r2] - adds r0, r7, #0 - adds r0, #0x84 - strb r1, [r0] - adds r5, r7, #0 - adds r5, #0x88 @ r5 = s - movs r2, #0x16 - ldrsh r0, [r5, r2] - ldr r2, _0804216C @ =gCamera - ldr r4, [r2] - adds r0, r0, r4 - lsls r0, r0, #8 - mov r3, ip @ r3 = ip = sub - str r0, [r3, #4] - movs r6, #0x18 - ldrsh r0, [r5, r6] - ldr r3, [r2, #4] @ r3 = gCamera.y - adds r0, r0, r3 - lsls r0, r0, #8 - mov r2, ip - str r0, [r2, #8] - movs r2, #0xb8 - lsls r2, r2, #3 - mov r6, ip - str r2, [r6, #0xc] - str r1, [r6, #0x10] - str r1, [r6, #0x14] - movs r0, #0x90 - lsls r0, r0, #1 - adds r5, r7, r0 - movs r6, #0x16 - ldrsh r0, [r5, r6] - adds r0, r0, r4 - lsls r0, r0, #8 - mov r4, ip - str r0, [r4, #0x54] - movs r6, #0x18 - ldrsh r0, [r5, r6] - adds r0, r0, r3 - lsls r0, r0, #8 - str r0, [r4, #0x58] - str r2, [r4, #0x5c] - str r1, [r4, #0x60] - str r1, [r4, #0x64] - movs r6, #0 - ldr r0, _08042170 @ =gSineTable - mov r8, r0 @ r8 = &gSineTable - ldr r0, _08042174 @ =gStageTime - ldr r1, [r0] @ r1 = gStageTime - ldr r2, _08042178 @ =0x000003FF - mov sl, r2 @ sl = ONE_CYCLE - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #2 - str r0, [sp] @ sp00 = 12 * gStageTime - mov sb, r6 @ sb = 0 -_080420C2: - lsls r0, r6, #7 @ r0 = i << 7 - ldr r3, [sp] @ r3 = 12 * gStageTime - adds r0, r3, r0 - mov r4, sl - ands r0, r4 - lsls r0, r0, #1 - add r0, r8 - ldrh r1, [r0] - lsls r1, r1, #0x10 - asrs r1, r1, #0x19 - lsls r1, r1, #0x10 - lsrs r1, r1, #0x10 @ r1 = period = SIN_24_8(((i << 7) + (12 * gStageTime)) & ONE_CYCLE) >> 3; - ldr r4, [r7, #4] - asrs r4, r4, #8 @ r4 = bossX = I(boss->main.worldX); - movs r0, #0xfa - lsls r0, r0, #1 - adds r1, r1, r0 - mov r2, sl - ands r1, r2 @ r1 = (period + 500) & ONE_CYCLE - movs r3, #0x80 - lsls r3, r3, #1 - adds r0, r1, r3 - lsls r0, r0, #1 - add r0, r8 - movs r3, #0 - ldrsh r2, [r0, r3] @ r2 = COS(period) - lsls r0, r2, #4 - adds r0, r0, r2 - adds r5, r6, #1 - muls r0, r5, r0 - asrs r0, r0, #0xe - adds r4, r4, r0 @ r4 = bossX += ((COS(period) * 17) * (i + 1)) >> 14 - ldr r3, [r7, #8] - asrs r3, r3, #8 - lsls r1, r1, #1 - add r1, r8 - movs r0, #0 - ldrsh r1, [r1, r0] - lsls r0, r1, #4 - adds r0, r0, r1 - muls r0, r5, r0 - asrs r0, r0, #0xe - adds r0, #0x14 - adds r3, r3, r0 @ r3 = bossY += (((SIN(period) * 17) * (i + 1)) >> 14) + 0x14; - lsls r2, r6, #2 - adds r2, r2, r6 - lsls r2, r2, #2 @ r2 = i * 20 - mov r0, ip - adds r0, #0x18 - adds r0, r0, r2 - lsls r4, r4, #8 - str r4, [r0] - mov r0, ip - adds r0, #0x1c - adds r0, r0, r2 - lsls r3, r3, #8 - str r3, [r0] - mov r0, ip - adds r0, #0x20 - adds r0, r0, r2 - movs r1, #0xb8 - lsls r1, r1, #3 - str r1, [r0] - mov r0, ip - adds r0, #0x24 - adds r0, r0, r2 - mov r1, sb - str r1, [r0] - mov r0, ip - adds r0, #0x28 - adds r0, r0, r2 - str r1, [r0] - lsls r5, r5, #0x18 - lsrs r6, r5, #0x18 - cmp r6, #2 - bls _080420C2 - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804216C: .4byte gCamera -_08042170: .4byte gSineTable -_08042174: .4byte gStageTime -_08042178: .4byte 0x000003FF -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_8__Task_804AB24.inc b/asm/non_matching/game/bosses/boss_8__Task_804AB24.inc deleted file mode 100644 index e041b3431..000000000 --- a/asm/non_matching/game/bosses/boss_8__Task_804AB24.inc +++ /dev/null @@ -1,284 +0,0 @@ - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x14 - ldr r0, _0804AC44 @ =gCurTask - ldr r0, [r0] - ldrh r4, [r0, #6] - movs r0, #0xc0 - lsls r0, r0, #0x12 - adds r7, r4, r0 @ r7 = boss - adds r0, #0x48 - adds r6, r4, r0 - adds r0, r7, #0 - bl sub_804CC98 - adds r0, r7, #0 - bl sub_804CA08 - adds r0, r7, #0 - bl sub_804AE40 - ldr r5, _0804AC48 @ =sArmFuncs - ldr r1, _0804AC4C @ =0x03000000 + 0x3C - adds r0, r4, r1 - ldrb r0, [r0] - lsls r0, r0, #2 - adds r0, r0, r5 - ldr r2, [r0] - adds r0, r7, #0 - movs r1, #0 - bl _call_via_r2 - ldr r2, _0804AC50 @ =0x03000000 + 0x3D - adds r4, r4, r2 - ldrb r0, [r4] - lsls r0, r0, #2 - adds r0, r0, r5 - ldr r2, [r0] - adds r0, r7, #0 - movs r1, #1 - bl _call_via_r2 - adds r0, r7, #0 - bl sub_804C5B8 - adds r0, r7, #0 - bl sub_804C830 - adds r0, r7, #0 - bl sub_804CA70 - ldr r4, _0804AC54 @ =gPlayer - ldr r0, [r4, #0xc] - asrs r0, r0, #8 - cmp r0, #0xb8 - ble _0804ABC0 - ldr r0, [r4, #8] - asrs r0, r0, #8 - ldr r1, _0804AC58 @ =0x0000A819 - cmp r0, r1 - ble _0804ABC0 - adds r0, r4, #0 - bl sub_800CBA4 - movs r1, #0x10 - ldrsh r0, [r4, r1] - cmp r0, #0 - ble _0804ABB4 - rsbs r0, r0, #0 - strh r0, [r4, #0x10] -_0804ABB4: - movs r1, #0x14 - ldrsh r0, [r4, r1] - cmp r0, #0 - ble _0804ABC0 - rsbs r0, r0, #0 - strh r0, [r4, #0x14] -_0804ABC0: - ldr r4, _0804AC54 @ =gPlayer - ldr r0, [r4, #8] - asrs r0, r0, #8 - ldr r1, _0804AC5C @ =0x0000A84F - cmp r0, r1 - ble _0804ABEA - adds r0, r4, #0 - bl sub_800CBA4 - movs r1, #0x10 - ldrsh r0, [r4, r1] - cmp r0, #0 - ble _0804ABDE - rsbs r0, r0, #0 - strh r0, [r4, #0x10] -_0804ABDE: - movs r1, #0x14 - ldrsh r0, [r4, r1] - cmp r0, #0 - ble _0804ABEA - rsbs r0, r0, #0 - strh r0, [r4, #0x14] -_0804ABEA: - ldrb r4, [r7, #8] - cmp r4, #0 - beq _0804ABF2 - b _0804AD54 -_0804ABF2: - ldr r2, _0804AC60 @ =gFlags - ldr r0, [r2] - movs r1, #5 - rsbs r1, r1, #0 - ands r0, r1 - str r0, [r2] - ldr r0, _0804AC44 @ =gCurTask - ldr r1, [r0] - ldr r0, _0804AC64 @ =Task_804AD68 - str r0, [r1, #8] - movs r0, #0xff - str r0, [r7, #0x14] - bl Player_DisableInputAndBossTimer_FinalBoss - ldr r2, _0804AC54 @ =gPlayer - ldr r1, [r2, #0x20] - movs r0, #0x80 - lsls r0, r0, #0xe - orrs r1, r0 - str r1, [r2, #0x20] - adds r0, r2, #0 - adds r0, #0x5c - strh r4, [r0] - adds r0, #2 - strh r4, [r0] - movs r0, #0xa - ands r0, r1 - cmp r0, #0 - beq _0804AC68 - adds r1, r2, #0 - adds r1, #0x64 - movs r0, #0x32 - strh r0, [r1] - movs r0, #0xfe - lsls r0, r0, #8 - strh r0, [r2, #0x10] - strh r4, [r2, #0x12] - adds r1, #9 - movs r0, #5 - strb r0, [r1] - b _0804AC6E - .align 2, 0 -_0804AC44: .4byte gCurTask -_0804AC48: .4byte sArmFuncs -_0804AC4C: .4byte 0x03000000 + 0x3C -_0804AC50: .4byte 0x03000000 + 0x3D -_0804AC54: .4byte gPlayer -_0804AC58: .4byte 0x0000A819 -_0804AC5C: .4byte 0x0000A84F -_0804AC60: .4byte gFlags -_0804AC64: .4byte Task_804AD68 -_0804AC68: - strh r0, [r2, #0x14] - strh r0, [r2, #0x10] - strh r0, [r2, #0x12] -_0804AC6E: - movs r1, #0 - strh r1, [r6] - strh r1, [r6, #4] - movs r0, #1 - strh r0, [r6, #2] - movs r0, #0x10 - strh r0, [r6, #6] - ldr r0, _0804AD2C @ =0x00003FBF - strh r0, [r6, #8] - strh r1, [r6, #0xa] - movs r6, #0 @ r6 = i = 0 - adds r0, r7, #0 @ r0 = r7 = boss - adds r0, #0x18 - str r0, [sp] @ sp00 = &boss->qUnk18[0][0] - adds r1, r7, #0 - adds r1, #0x28 - str r1, [sp, #8] @ sp08 = &boss->qUnk28[0] - adds r2, r7, #0 - adds r2, #0x1c - str r2, [sp, #4] @ sp04 = &boss->qUnk18[0][1] - adds r0, #0x1c - str r0, [sp, #0xc] @ sp08 = &boss->qUnk34[0][0] - adds r1, #0xe - str r1, [sp, #0x10] @ sp08 = &boss->qUnk34[0][1] - movs r2, #0x3c - adds r2, r2, r7 - mov sl, r2 @ sl = &boss->unk3C[0] - movs r0, #0x30 - adds r0, r0, r7 - mov sb, r0 @ sb = &boss->qUnk30[0] - ldr r1, _0804AD30 @ =gSineTable - mov r8, r1 @ r8 = r1 = gSineTable - movs r2, #2 - mov ip, r2 @ ip = r2 = 2 -_0804ACB2: - lsls r2, r6, #3 @ r2 = i * 8 - ldr r0, [sp] - adds r3, r0, r2 @ r3 = &boss->qUnk18[i][0] - lsls r5, r6, #1 @ r5 = i * 2 - ldr r1, [sp, #8] - adds r4, r1, r5 @ r4 = &boss->qUnk28[i] - ldrh r0, [r4] - movs r1, #0x80 - lsls r1, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - add r0, r8 - movs r1, #0 - ldrsh r0, [r0, r1] - lsls r1, r0, #4 - subs r1, r1, r0 - asrs r1, r1, #6 - ldr r0, [r3] - adds r0, r0, r1 - str r0, [r3] - ldr r0, [sp, #4] - adds r2, r0, r2 - ldrh r0, [r4] - lsls r0, r0, #1 - add r0, r8 - movs r1, #0 - ldrsh r0, [r0, r1] - lsls r1, r0, #4 - subs r1, r1, r0 - asrs r1, r1, #6 - ldr r0, [r2] - adds r0, r0, r1 - str r0, [r2] - lsls r1, r6, #2 @ r1 = i * 4 - ldr r2, [sp, #0xc] - adds r0, r2, r1 - ldr r2, _0804AD34 @ =0xFFFFFE80 - strh r2, [r0] @ boss->qUnk34[i][0] = -Q(1.5); - ldr r0, [sp, #0x10] - adds r1, r0, r1 - movs r0, #0xfd - lsls r0, r0, #8 - strh r0, [r1] @ boss->qUnk34[i][1] = -Q(3); - mov r2, sl @ r2 = sl = &boss->unk3C[0] - adds r1, r2, r6 - movs r0, #7 - strb r0, [r1] - add r5, sb - movs r0, #0x3c - strh r0, [r5] - lsls r0, r6, #4 - subs r0, r0, r6 - lsls r0, r0, #2 - adds r0, #0x90 - adds r1, r7, r0 - cmp r6, #0 - beq _0804AD38 - movs r0, #0xb0 - lsls r0, r0, #2 - b _0804AD3A - .align 2, 0 -_0804AD2C: .4byte 0x00003FBF -_0804AD30: .4byte gSineTable -_0804AD34: .4byte 0xFFFFFE80 -_0804AD38: - ldr r0, _0804AD64 @ =0x000002BF -_0804AD3A: - strh r0, [r1, #0xa] - adds r0, r1, #0 - adds r0, #0x20 - mov r2, ip - strb r2, [r0] - adds r1, #0x21 - movs r0, #0xff - strb r0, [r1] - adds r0, r6, #1 - lsls r0, r0, #0x18 - lsrs r6, r0, #0x18 - cmp r6, #1 - bls _0804ACB2 -_0804AD54: - add sp, #0x14 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804AD64: .4byte 0x000002BF - -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_8__sub_804B2EC.inc b/asm/non_matching/game/bosses/boss_8__sub_804B2EC.inc deleted file mode 100644 index fb1fc9569..000000000 --- a/asm/non_matching/game/bosses/boss_8__sub_804B2EC.inc +++ /dev/null @@ -1,169 +0,0 @@ - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r7, r0, #0 @ r7 = boss - lsls r1, r1, #0x18 - lsrs r1, r1, #0x18 - mov sb, r1 - movs r0, #0 - str r0, [sp] - adds r0, r7, #0 - adds r0, #0x3e - add r0, sb - ldrb r0, [r0] - cmp r0, #0 - beq _0804B314 - movs r0, #0 - b _0804B41E -_0804B314: - ldr r1, _0804B3C8 @ =gPlayer - mov r8, r1 @ r8 = gPlayer - mov r0, r8 - adds r0, #0x90 - ldr r0, [r0] - adds r0, #0xc @ r0 = s = &gPlayer.unk90->s; - mov sl, r0 @ sl = s - mov r2, sb @ r2 = sb = arm - lsls r4, r2, #3 @ r4 = arm * 8 - adds r0, r7, #0 - adds r0, #0x18 - adds r0, r0, r4 - ldr r3, [r7] @ r3 = boss->qUnk0 - ldr r0, [r0] @ r0 = qUnk18[arm][0] - ldr r1, _0804B3CC @ r1 = gUnknown_080D8888 - lsls r2, r2, #2 @ r2 = arm * 4 - adds r5, r2, r1 @ r5 = &gUnknown_080D8888[arm][0] - adds r6, r3, r0 @ r6 = boss->qUnk0 + qUnk18[arm][0] - adds r0, r7, #0 - adds r0, #0x1c - adds r0, r0, r4 - ldr r3, [r7, #4] @ r3 = boss->qUnk4 - ldr r0, [r0] @ r0 = qUnk18[arm][1] - adds r1, #2 - adds r2, r2, r1 - adds r0, r3, r0 - ldrh r5, [r5] @ r5 = gUnknown_080D8888[arm][0] - adds r4, r6, r5 @ r4 = boss->qUnk0 + qUnk18[arm][0] - ldrh r2, [r2] - adds r5, r0, r2 - ldr r0, _0804B3D0 @ =gSelectedCharacter - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - beq _0804B364 - adds r0, r4, #0 - adds r1, r5, #0 - bl Player_UpdateHomingPosition -_0804B364: - mov r1, r8 - ldr r0, [r1, #0x20] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _0804B3D8 - mov r2, sl - ldr r1, [r2, #0x30] - movs r0, #1 - rsbs r0, r0, #0 - cmp r1, r0 - beq _0804B3D8 - mov r1, r8 - ldr r0, [r1, #8] - subs r0, r0, r4 - asrs r6, r0, #8 - ldr r0, [r1, #0xc] - subs r0, r0, r5 - asrs r0, r0, #8 - adds r2, r6, #0 - muls r2, r6, r2 - adds r6, r2, #0 - adds r1, r0, #0 - muls r1, r0, r1 - adds r0, r1, #0 - adds r1, r6, r0 - ldr r0, _0804B3D4 @ =0x00000177 - cmp r1, r0 - bgt _0804B3D8 - adds r0, r7, #0 - mov r1, sb - bl sub_804C9B4 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - str r0, [sp] - mov r2, r8 - movs r5, #0x10 - ldrsh r0, [r2, r5] - rsbs r0, r0, #0 - strh r0, [r2, #0x10] - movs r1, #0x12 - ldrsh r0, [r2, r1] - rsbs r0, r0, #0 - strh r0, [r2, #0x12] - movs r5, #0x14 - ldrsh r0, [r2, r5] - rsbs r0, r0, #0 - strh r0, [r2, #0x14] - b _0804B41C - .align 2, 0 -_0804B3C8: .4byte gPlayer -_0804B3CC: .4byte gUnknown_080D8888 -_0804B3D0: .4byte gSelectedCharacter -_0804B3D4: .4byte 0x00000177 -_0804B3D8: - ldr r0, _0804B430 @ =gCheese - ldr r2, [r0] - cmp r2, #0 - beq _0804B41C - ldr r1, [r2, #0x4c] - movs r0, #1 - rsbs r0, r0, #0 - cmp r1, r0 - beq _0804B41C - ldr r0, [r2] - subs r4, r4, r0 - asrs r4, r4, #8 - ldr r0, [r2, #4] - subs r5, r5, r0 - asrs r5, r5, #8 - adds r0, r4, #0 - muls r0, r4, r0 - adds r1, r5, #0 - muls r1, r5, r1 - adds r0, r0, r1 - ldr r1, _0804B434 @ =0x00000177 - cmp r0, r1 - bgt _0804B41C - adds r0, r7, #0 - mov r1, sb - bl sub_804C9B4 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - str r0, [sp] - ldr r0, _0804B438 @ =gCheeseTarget - ldr r1, [r0, #4] - movs r0, #0 - strb r0, [r1, #0x15] -_0804B41C: - ldr r0, [sp] -_0804B41E: - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 - .align 2, 0 -_0804B430: .4byte gCheese -_0804B434: .4byte 0x00000177 -_0804B438: .4byte gCheeseTarget - -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_9__sub_804E15C.inc b/asm/non_matching/game/bosses/boss_9__sub_804E15C.inc deleted file mode 100644 index 260e45b28..000000000 --- a/asm/non_matching/game/bosses/boss_9__sub_804E15C.inc +++ /dev/null @@ -1,424 +0,0 @@ -.include "constants/constants.inc" - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x24 - adds r7, r0, #0 @ r7 = unk48 - ldr r0, _0804E1B8 @ =gCurTask - ldr r0, [r0] - ldrh r0, [r0, #6] - ldr r1, _0804E1BC @ =IWRAM_START + 0x558 - adds r1, r0, r1 - str r1, [sp, #0x10] @ sp10 = unk558 = &boss->unk558 - ldr r2, _0804E1C0 @ =IWRAM_START + 0x1C - adds r4, r0, r2 @ r4 = unk1C - adds r0, r7, #0 - bl sub_8050030 - lsls r0, r0, #0x18 - cmp r0, #0 - beq _0804E1DC - ldr r0, [r7, #0x30] - ldr r1, _0804E1C4 @ =0x00000FFF - ands r0, r1 - str r0, [r7, #0x30] - ldr r1, _0804E1C8 @ =gUnknown_080D8D6C - ldr r0, [r1] - str r0, [r7] - ldr r0, [r1, #4] - str r0, [r7, #0x34] - ldrh r0, [r1, #8] - movs r2, #0 - strh r0, [r7, #0x2e] - ldr r3, _0804E1CC @ =gDispCnt - ldrh r1, [r3] - ldr r0, _0804E1D0 @ =0x0000DFFF - ands r0, r1 - strh r0, [r3] - ldr r0, _0804E1D4 @ =gWinRegs - strh r2, [r0, #8] - strh r2, [r0, #0xa] - ldr r0, _0804E1D8 @ =gBldRegs - strh r2, [r0] - strh r2, [r0, #2] - strh r2, [r0, #4] - b sub_804E15C__return - .align 2, 0 -_0804E1B8: .4byte gCurTask -_0804E1BC: .4byte IWRAM_START + 0x558 -_0804E1C0: .4byte IWRAM_START + 0x1C -_0804E1C4: .4byte 0x00000FFF -_0804E1C8: .4byte gUnknown_080D8D6C -_0804E1CC: .4byte gDispCnt -_0804E1D0: .4byte 0x0000DFFF -_0804E1D4: .4byte gWinRegs -_0804E1D8: .4byte gBldRegs -_0804E1DC: - ldr r0, [r7, #0x30] - lsrs r0, r0, #0xc - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - str r0, [sp, #0x14] @ sp14 = (unk48->unk30 >> 12); - cmp r0, #2 - bhi _0804E1EC - b sub_804E15C__return -_0804E1EC: - movs r3, #0x20 - ldrsh r0, [r4, r3] @ r4 = unk1C - lsls r0, r0, #8 @ r0 = Q(unk1C->unk20) - ldr r1, [r4, #0x24] - adds r1, r1, r0 - mov sb, r1 @ sb = sb - movs r6, #0x22 - ldrsh r0, [r4, r6] - lsls r0, r0, #8 @ r0 = Q(unk1C->unk22) - ldr r1, [r4, #0x28] - adds r1, r1, r0 - mov r8, r1 @ r8 = r8 - ldr r0, [r7, #0x44] - asrs r0, r0, #8 - ldrh r1, [r7, #0x3a] - adds r5, r0, r1 @ r5 - ldr r2, _0804E3F8 @ =0x000003FF - adds r0, r2, #0 - ands r5, r0 - ldr r3, _0804E3FC @ =gSineTable - movs r2, #0x80 - lsls r2, r2, #1 - adds r0, r5, r2 - lsls r0, r0, #1 - adds r0, r0, r3 - movs r4, #0 - ldrsh r0, [r0, r4] @ r0 = COS(r5) - ldr r4, _0804E400 @ =gUnknown_080D89A5 - ldrb r1, [r4] - muls r0, r1, r0 - asrs r0, r0, #6 @ r0 = (COS(r5) * gUnknown_080D89A5) >> 6 - add sb, r0 - lsls r0, r5, #1 - adds r0, r0, r3 - movs r6, #0 - ldrsh r0, [r0, r6] - muls r0, r1, r0 - asrs r0, r0, #6 - add r8, r0 - adds r5, #0x8c - ldr r0, _0804E404 @ =0xFFFFFF00 - adds r1, r5, r0 - ldr r0, _0804E3F8 @ =0x000003FF - ands r1, r0 - adds r2, r1, r2 - lsls r2, r2, #1 - adds r2, r2, r3 - movs r6, #0 - ldrsh r0, [r2, r6] - asrs r0, r0, #2 - add sb, r0 - lsls r1, r1, #1 - adds r1, r1, r3 - movs r2, #0 - ldrsh r0, [r1, r2] - asrs r0, r0, #2 - add r8, r0 - movs r0, #0 - mov sl, r4 @ sl = r4 = gUnknown_080D89A5 - adds r3, r7, #0 - adds r3, #0x3a - str r3, [sp, #0x1c] @ sp1C = unk48->unk3A - adds r4, r7, #0 - adds r4, #0x42 - str r4, [sp, #0x20] @ sp20 = unk48->unk42 - mov r6, sp - adds r6, #0xc - str r6, [sp, #0x18] - ldr r1, _0804E3FC @ =gSineTable - mov ip, r1 -_0804E278: - adds r3, r0, #1 - lsls r0, r3, #1 @ r0 = (i + 1) * 2 - ldr r2, [sp, #0x1c] - adds r0, r2, r0 - ldrh r0, [r0] @ r0 = unk48->unk3A[i + 1] - adds r5, r5, r0 @ r5 += unk48->unk3A[i + 1] - ldr r4, _0804E3F8 @ =0x000003FF - ands r5, r4 - movs r6, #0x80 - lsls r6, r6, #1 - adds r0, r5, r6 - lsls r6, r0, #1 - mov r1, ip @ r1 = ip = gSineTable - adds r0, r6, r1 - movs r2, #0 - ldrsh r1, [r0, r2] @ r1 = COS(r5) - mov r4, sl @ r4 = sl = gUnknown_080D89A5 - adds r0, r3, r4 - ldrb r2, [r0] - adds r0, r1, #0 - muls r0, r2, r0 - asrs r0, r0, #6 - add sb, r0 - lsls r4, r5, #1 - mov r1, ip - adds r0, r4, r1 - movs r1, #0 - ldrsh r0, [r0, r1] - muls r0, r2, r0 - asrs r0, r0, #6 - add r8, r0 - lsls r3, r3, #0x18 - lsrs r0, r3, #0x18 - cmp r0, #2 - bls _0804E278 - ldr r2, _0804E3FC @ =gSineTable - adds r0, r6, r2 @ r0 = gSineTable + - movs r3, #0 - ldrsh r0, [r0, r3] @ r0 = COS(r5) - mov r6, sl @ r6 = sl = gUnknown_080D89A5 - ldrb r1, [r6, #4] - muls r0, r1, r0 - asrs r0, r0, #6 - add sb, r0 - adds r0, r4, r2 - movs r2, #0 - ldrsh r0, [r0, r2] - muls r0, r1, r0 - asrs r0, r0, #6 - add r8, r0 - ldr r3, [sp, #0x20] - ldrh r0, [r3] - adds r5, r5, r0 - ldr r4, _0804E3F8 @ =0x000003FF - ands r5, r4 - ldr r6, [sp, #0x14] - cmp r6, #5 - bhi _0804E2EE - b _0804E43C -_0804E2EE: - ldr r0, _0804E408 @ =gMPlayTable - ldr r1, [r0, #0x18] - ldr r0, _0804E40C @ =gSongTable - ldr r2, _0804E410 @ =0x00000868 - adds r0, r0, r2 - ldr r1, [r1] - ldr r0, [r0] - cmp r1, r0 - beq _0804E30A - cmp r6, #6 - bne _0804E30A - ldr r0, _0804E414 @ =0x0000010D - bl m4aSongNumStart -_0804E30A: - add r0, sp, #8 - ldr r1, [sp, #0x18] - bl SuperSonicGetPos - ldrh r0, [r7, #0x38] @ r0 = unk48->unk38 - adds r6, r5, r0 - ldr r3, _0804E3F8 @ =0x000003FF - adds r0, r3, #0 - ands r6, r0 - ldr r0, [sp, #0xc] - mov r4, r8 @ r4 = r8 = r8 - subs r0, r0, r4 - lsls r0, r0, #8 @ - asrs r0, r0, #0x10 - ldr r1, [sp, #8] - mov r2, sb - subs r1, r1, r2 - lsls r1, r1, #8 - asrs r1, r1, #0x10 - bl sub_8004418 - lsls r0, r0, #0x10 - lsrs r5, r0, #0x10 - adds r0, r5, #0 - adds r0, #0x10 - cmp r6, r0 - bge _0804E350 - subs r0, #0x20 - cmp r6, r0 - ble _0804E350 - bl sub_802BB54 - ldr r0, _0804E418 @ =sub_804F1EC - ldr r3, [sp, #0x10] - str r0, [r3] -_0804E350: - ldr r2, _0804E41C @ =gDispCnt - ldrh r0, [r2] - movs r4, #0x80 - lsls r4, r4, #6 - adds r1, r4, #0 - orrs r0, r1 - strh r0, [r2] - ldr r1, _0804E420 @ =gWinRegs - movs r0, #0xa0 - strh r0, [r1] - movs r0, #0xf0 - strh r0, [r1, #4] - movs r0, #0x3f - strh r0, [r1, #8] - movs r0, #0x15 - strh r0, [r1, #0xa] - ldr r1, _0804E424 @ =gBldRegs - ldr r0, _0804E428 @ =0x00003FBF - strh r0, [r1] - movs r5, #8 - strh r5, [r1, #2] - strh r5, [r1, #4] - ldr r2, _0804E42C @ =gPseudoRandom - ldr r1, [r2] - ldr r0, _0804E430 @ =0x00196225 - muls r0, r1, r0 - ldr r1, _0804E434 @ =0x3C6EF35F - adds r0, r0, r1 - str r0, [r2] - movs r1, #8 - bl Mod - lsls r0, r0, #0x18 - asrs r4, r0, #0x18 - cmp r4, #0 - bge _0804E39A - rsbs r4, r4, #0 -_0804E39A: - ldr r3, _0804E3FC @ =gSineTable - movs r2, #0x80 - lsls r2, r2, #1 - adds r0, r6, r2 - lsls r0, r0, #1 - adds r0, r0, r3 - movs r2, #0 - ldrsh r1, [r0, r2] @ r1 = COS(r6) - ldr r0, _0804E400 @ =gUnknown_080D89A5 - ldrb r2, [r0, #5] - adds r0, r1, #0 - muls r0, r2, r0 - asrs r0, r0, #6 - add sb, r0 - lsls r0, r6, #1 - adds r0, r0, r3 - movs r3, #0 - ldrsh r0, [r0, r3] - muls r0, r2, r0 - asrs r0, r0, #6 - add r8, r0 - lsls r0, r4, #0x18 - asrs r0, r0, #0x18 - movs r1, #0x1a - subs r1, r1, r0 - lsls r1, r1, #0x10 - lsrs r1, r1, #0x10 - mov r4, sb - asrs r3, r4, #8 - ldr r2, _0804E438 @ =gCamera - ldr r0, [r2] - subs r3, r3, r0 - lsls r3, r3, #0x10 - asrs r3, r3, #0x10 - mov r4, r8 - asrs r0, r4, #8 - ldr r2, [r2, #4] - subs r0, r0, r2 - lsls r0, r0, #0x10 - asrs r0, r0, #0x10 - str r0, [sp] - str r5, [sp, #4] - adds r0, r6, #0 - movs r2, #0x10 - bl sub_802E784 - b sub_804E15C__return - .align 2, 0 -_0804E3F8: .4byte 0x000003FF -_0804E3FC: .4byte gSineTable -_0804E400: .4byte gUnknown_080D89A5 -_0804E404: .4byte 0xFFFFFF00 -_0804E408: .4byte gMPlayTable -_0804E40C: .4byte gSongTable -_0804E410: .4byte 0x00000868 -_0804E414: .4byte 0x0000010D -_0804E418: .4byte sub_804F1EC -_0804E41C: .4byte gDispCnt -_0804E420: .4byte gWinRegs -_0804E424: .4byte gBldRegs -_0804E428: .4byte 0x00003FBF -_0804E42C: .4byte gPseudoRandom -_0804E430: .4byte 0x00196225 -_0804E434: .4byte 0x3C6EF35F -_0804E438: .4byte gCamera -_0804E43C: - movs r0, #8 - add r1, sp, #8 - ldr r2, [sp, #0x18] - bl sub_802C704 - ldr r0, [sp, #0xc] - mov r6, r8 - subs r0, r0, r6 - lsls r0, r0, #8 - asrs r0, r0, #0x10 - ldr r1, [sp, #8] - mov r2, sb - subs r1, r1, r2 - lsls r1, r1, #8 - asrs r1, r1, #0x10 - bl sub_8004418 - lsls r0, r0, #0x10 - lsrs r6, r0, #0x10 - ldrh r0, [r7, #0x38] - adds r0, r5, r0 - ldr r3, _0804E490 @ =0x000003FF - ands r0, r3 - adds r1, r6, #0 - movs r2, #0xa - bl sub_808558C - lsls r0, r0, #0x10 - cmp r0, #0 - bge _0804E498 - ldrh r1, [r7, #0x38] - adds r2, r1, #0 - movs r0, #0x80 - lsls r0, r0, #2 - cmp r2, r0 - bls _0804E494 @ unk48->unk38 > Q(2) - movs r0, #0xe0 - lsls r0, r0, #2 - cmp r2, r0 - bls _0804E4AA @ unk48->unk38 > Q(3.5) - subs r0, r1, #4 - b _0804E4A8 - .align 2, 0 -_0804E490: .4byte 0x000003FF -_0804E494: - subs r0, r1, #4 - b _0804E4A8 -_0804E498: - ldrh r1, [r7, #0x38] - adds r2, r1, #0 - ldr r0, _0804E4C4 @ =0x000001FF - cmp r2, r0 - bhi _0804E4A6 - cmp r2, #0x7f - bhi _0804E4AA -_0804E4A6: - adds r0, r1, #4 -_0804E4A8: - strh r0, [r7, #0x38] -_0804E4AA: - ldrh r1, [r7, #0x38] - ldr r0, _0804E4C8 @ =0x000003FF - ands r0, r1 - strh r0, [r7, #0x38] -sub_804E15C__return: - add sp, #0x24 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804E4C4: .4byte 0x000001FF -_0804E4C8: .4byte 0x000003FF - -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_9__sub_804E4CC.inc b/asm/non_matching/game/bosses/boss_9__sub_804E4CC.inc deleted file mode 100644 index 3cfd06a6d..000000000 --- a/asm/non_matching/game/bosses/boss_9__sub_804E4CC.inc +++ /dev/null @@ -1,209 +0,0 @@ -.include "constants/constants.inc" - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - adds r4, r0, #0 - bl sub_8050030 - ldr r0, [r4, #0x30] - ldr r6, _0804E504 @ =0x00000FFF - adds r1, r0, #0 - ands r1, r6 - adds r3, r1, #0 - adds r5, r3, #0 @ r5 = r3 = unk48->unk30 & 0xFFF - lsls r0, r0, #4 - lsrs r0, r0, #0x10 - adds r2, r0, #0 - cmp r0, #4 - bne _0804E50C - str r1, [r4, #0x30] - ldr r1, _0804E508 @ =gUnknown_080D8D6C - ldr r0, [r1] - str r0, [r4] - ldr r0, [r1, #4] - str r0, [r4, #0x34] - ldrh r0, [r1, #8] - strh r0, [r4, #0x2e] - b sub_804E4CC__return - .align 2, 0 -_0804E504: .4byte 0x00000FFF -_0804E508: .4byte gUnknown_080D8D6C -_0804E50C: - cmp r0, #3 - bne _0804E5B0 - ldr r2, _0804E598 @ =_0804E50C - ldrh r1, [r2] - ldr r0, _0804E59C @ =0x0000FDFF - ands r0, r1 - strh r0, [r2] - adds r6, r3, #0 @ r6 = r3 = r5 - movs r5, #0 - adds r4, #0x4c - mov r8, r4 - ldr r0, _0804E5A0 @ =sRGB_080D8E20 - mov ip, r0 - movs r7, #0x1f @ r7 = 0x1F - movs r1, #0x92 - add r1, ip - mov sl, r1 @ sl = r1 = sRGB_080D8E20[i][] - ldr r2, _0804E5A4 @ =gObjPalette - mov sb, r2 -_0804E532: - lsls r4, r5, #1 - adds r1, r4, r5 @ r1 = i * 3 - mov r0, ip - adds r0, #0x90 - adds r0, r1, r0 - ldrb r3, [r0] @ r3 = sRGB_080D8E20[i] - muls r3, r6, r3 - asrs r3, r3, #0xc - ands r3, r7 - mov r0, ip - adds r0, #0x91 - adds r0, r1, r0 - ldrb r2, [r0] - muls r2, r6, r2 - asrs r2, r2, #0xc - ands r2, r7 - add r1, sl - ldrb r0, [r1] - muls r0, r6, r0 - asrs r0, r0, #0xc - ands r0, r7 - adds r1, r5, #0 - adds r1, #0x80 - lsls r1, r1, #1 - add r1, sb - lsls r0, r0, #0xa - lsls r2, r2, #5 - orrs r0, r2 - orrs r0, r3 - strh r0, [r1] - ldr r3, _0804E5A8 @ =gBgPalette - adds r4, r4, r3 - strh r0, [r4] - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - cmp r5, #0xf - bls _0804E532 - ldr r1, _0804E5AC @ =gFlags - ldr r0, [r1] - movs r1, #2 - orrs r0, r1 - movs r1, #1 - orrs r0, r1 - ldr r2, _0804E5AC @ =gFlags - str r0, [r2] - movs r0, #0 - mov r3, r8 - strb r0, [r3] - b sub_804E4CC__return - .align 2, 0 -_0804E598: .4byte gDispCnt -_0804E59C: .4byte 0x0000FDFF -_0804E5A0: .4byte sRGB_080D8E20 -_0804E5A4: .4byte gObjPalette -_0804E5A8: .4byte gBgPalette -_0804E5AC: .4byte gFlags -_0804E5B0: - cmp r2, #2 - bne sub_804E4CC__return - movs r0, #0xe0 - lsls r0, r0, #4 - cmp r5, r0 - bls sub_804E4CC__return -__0804E5BC: - ldr r2, _0804E658 @ =gDispCnt - ldrh r0, [r2] - movs r3, #0x80 - lsls r3, r3, #2 - adds r1, r3, #0 - orrs r0, r1 - strh r0, [r2] - subs r0, r6, r5 @ r0 = 0xFFF - r5 - lsls r0, r0, #0x10 - lsrs r6, r0, #0x10 - movs r2, #0 @ r2 = i = 0 - ldr r0, _0804E65C @ =sRGB_080D8E20 - mov r8, r0 - movs r4, #0x1f - ldr r1, _0804E660 @ =gBgPalette - mov sl, r1 -_0804E5DC: - movs r5, #0 @ r5 = c = 0 - lsls r0, r2, #1 - lsls r1, r2, #4 - adds r3, r2, #1 - mov sb, r3 - adds r0, r0, r2 - lsls r0, r0, #4 - mov ip, r0 @ ip = r0 = i * 0x30 - adds r7, r1, #0 - adds r7, #0x70 -_0804E5F0: - lsls r1, r5, #1 - adds r1, r1, r5 - add r1, ip @ r1 = ((i * 0x30) + (c * 3)) - mov r2, r8 - adds r0, r1, r2 - ldrb r3, [r0] @ r3 = sRGB_080D8E20[i][c][0] - muls r3, r6, r3 - asrs r3, r3, #9 - ands r3, r4 @ r3 = r - mov r0, r8 - adds r0, #1 - adds r0, r1, r0 - ldrb r2, [r0] - muls r2, r6, r2 - asrs r2, r2, #9 - ands r2, r4 @ r2 = g - ldr r0, _0804E664 @ =sRGB_080D8E20+0x2 - adds r1, r1, r0 - ldrb r0, [r1] - muls r0, r6, r0 - asrs r0, r0, #9 - ands r0, r4 @ r0 = b - adds r1, r5, r7 - lsls r1, r1, #1 - add r1, sl - lsls r0, r0, #0xa - lsls r2, r2, #5 - orrs r0, r2 - orrs r0, r3 - strh r0, [r1] - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - cmp r5, #0xf - bls _0804E5F0 - mov r1, sb - lsls r0, r1, #0x18 - lsrs r2, r0, #0x18 - cmp r2, #2 - bls _0804E5DC - ldr r2, _0804E668 @ =gFlags - ldr r0, [r2] - movs r1, #1 - orrs r0, r1 - str r0, [r2] -sub_804E4CC__return: - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804E658: .4byte gDispCnt -_0804E65C: .4byte sRGB_080D8E20 -_0804E660: .4byte gBgPalette -_0804E664: .4byte sRGB_080D8E20+0x2 -_0804E668: .4byte gFlags - -.syntax divided diff --git a/asm/non_matching/game/math/sub_80835E0.inc b/asm/non_matching/game/math/unused_sub_80835E0.inc similarity index 100% rename from asm/non_matching/game/math/sub_80835E0.inc rename to asm/non_matching/game/math/unused_sub_80835E0.inc diff --git a/asm/non_matching/game/math/sub_8083B88.inc b/asm/non_matching/game/math/unused_sub_8083B88.inc similarity index 100% rename from asm/non_matching/game/math/sub_8083B88.inc rename to asm/non_matching/game/math/unused_sub_8083B88.inc diff --git a/asm/non_matching/game/math/sub_8084B54.inc b/asm/non_matching/game/math/unused_sub_8084B54.inc similarity index 100% rename from asm/non_matching/game/math/sub_8084B54.inc rename to asm/non_matching/game/math/unused_sub_8084B54.inc diff --git a/asm/non_matching/game/stage/intro/Task_802F9F8.inc b/asm/non_matching/game/stage/intro/Task_802F9F8.inc deleted file mode 100644 index 1ce3c5a15..000000000 --- a/asm/non_matching/game/stage/intro/Task_802F9F8.inc +++ /dev/null @@ -1,401 +0,0 @@ -.include "constants/gba_constants.inc" -.syntax unified -.text - - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #8 - ldr r0, _0802FB04 @ =gCurTask - ldr r0, [r0] - ldrh r1, [r0, #6] - movs r0, #0xc0 - lsls r0, r0, #0x12 - adds r0, r1, r0 - ldr r0, [r0] - str r0, [sp] @ sp00 = parent - ldr r0, _0802FB08 @ =IWRAM_START+4 - adds r0, r1, r0 - str r0, [sp, #4] @ sp04 = transition - ldr r1, [sp] - ldr r5, [r1] - ldr r2, _0802FB0C @ =gDispCnt - ldrh r1, [r2] - ldr r3, _0802FB10 @ =0x00001FFF - adds r0, r3, #0 - ands r0, r1 - strh r0, [r2] - cmp r5, #0x95 - bhi _0802FA30 - b _0802FC5C -_0802FA30: - subs r5, #0x96 - cmp r5, #0xf - bls _0802FA38 - movs r5, #0x10 -_0802FA38: - lsls r0, r5, #9 - ldr r1, [sp, #4] - strh r0, [r1, #4] - lsls r0, r5, #0x19 - asrs r0, r0, #0x10 - cmp r0, r3 - ble _0802FA4C - movs r0, #0x80 - lsls r0, r0, #6 - strh r0, [r1, #4] -_0802FA4C: - ldr r0, _0802FB14 @ =gGameMode - ldrb r0, [r0] - cmp r0, #2 - bhi _0802FB28 - movs r6, #0 - ldr r3, _0802FB18 @ =gUnknown_080D6FF5 - mov ip, r3 - ldr r0, _0802FB1C @ =gObjPalette - mov sb, r0 @ sb = gObjPalette - mov r8, ip @ r8 = ip = gUnknown_080D6FF5 - movs r1, #2 - add r1, ip - mov sl, r1 @ sl = ip = gUnknown_080D6FF5+2 -_0802FA66: - lsls r3, r6, #1 - adds r7, r3, r6 @ r7 = i*3 - ldr r1, _0802FB20 @ =gSelectedCharacter - movs r0, #0 - ldrsb r0, [r1, r0] - lsls r2, r0, #1 - adds r2, r2, r0 - lsls r2, r2, #4 @ r2 = gSelChar*48 - adds r2, r7, r2 @ r2 += i*3 - mov r1, r8 - adds r0, r2, r1 @ r0 = gUnknown_080D6FF5[r2] - ldrb r4, [r0] - adds r0, r4, #0 - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - mov r0, r8 - adds r0, #1 - adds r0, r2, r0 - ldrb r0, [r0] - adds r1, r0, #0 - muls r1, r5, r1 - lsrs r1, r1, #4 - lsls r1, r1, #0x18 - add r2, sl - ldrb r0, [r2] - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - add r3, sb - lsrs r0, r0, #0xe - lsrs r1, r1, #0x13 - orrs r0, r1 - orrs r0, r4 - strh r0, [r3] - ldr r3, _0802FB24 @ =gCheese - ldr r0, [r3] - cmp r0, #0 - beq _0802FAF8 - mov r0, ip - adds r0, #0xf0 - adds r0, r7, r0 - ldrb r4, [r0] - adds r0, r4, #0 - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - mov r0, ip - adds r0, #0xf1 - adds r0, r7, r0 - ldrb r0, [r0] - adds r2, r0, #0 - muls r2, r5, r2 - lsrs r2, r2, #4 - lsls r2, r2, #0x18 - mov r0, ip - adds r0, #0xf2 - adds r0, r7, r0 - ldrb r0, [r0] - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - adds r1, r6, #0 - adds r1, #0xe0 - lsls r1, r1, #1 - add r1, sb - lsrs r0, r0, #0xe - lsrs r2, r2, #0x13 - orrs r0, r2 - orrs r0, r4 - strh r0, [r1] -_0802FAF8: - adds r0, r6, #1 - lsls r0, r0, #0x18 - lsrs r6, r0, #0x18 - cmp r6, #0xf - bls _0802FA66 - b _0802FC12 - .align 2, 0 -_0802FB04: .4byte gCurTask -_0802FB08: .4byte IWRAM_START+4 -_0802FB0C: .4byte gDispCnt -_0802FB10: .4byte 0x00001FFF -_0802FB14: .4byte gGameMode -_0802FB18: .4byte gUnknown_080D6FF5 -_0802FB1C: .4byte gObjPalette -_0802FB20: .4byte gSelectedCharacter -_0802FB24: .4byte gCheese -_0802FB28: - movs r2, #0 -_0802FB2A: - ldr r0, _0802FC34 @ =gMultiplayerConnections - ldrb r1, [r0] - asrs r1, r2 - movs r0, #1 - ands r1, r0 - adds r3, r2, #1 - mov sb, r3 - cmp r1, #0 - beq _0802FBA8 - movs r6, #0 - ldr r0, _0802FC38 @ =gUnknown_080D6FF5 - mov ip, r0 - lsls r1, r2, #4 - mov r8, r1 - mov r7, ip - ldr r0, _0802FC3C @ =gMultiplayerCharacters - adds r2, r2, r0 - mov ip, r2 - ldr r3, _0802FC40 @ =gObjPalette - mov sl, r3 -_0802FB52: - lsls r3, r6, #1 - adds r3, r3, r6 - mov r0, ip - movs r1, #0 - ldrsb r1, [r0, r1] - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #4 - adds r3, r3, r0 - adds r0, r3, r7 - ldrb r4, [r0] - adds r0, r4, #0 - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - adds r0, r7, #1 - adds r0, r3, r0 - ldrb r0, [r0] - adds r2, r0, #0 - muls r2, r5, r2 - lsrs r2, r2, #4 - lsls r2, r2, #0x18 - ldr r1, _0802FC44 @ =gUnknown_080D6FF5+2 - adds r3, r3, r1 - ldrb r0, [r3] - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - mov r3, r8 - adds r1, r3, r6 - lsls r1, r1, #1 - add r1, sl - lsrs r0, r0, #0xe - lsrs r2, r2, #0x13 - orrs r0, r2 - orrs r0, r4 - strh r0, [r1] - adds r0, r6, #1 - lsls r0, r0, #0x18 - lsrs r6, r0, #0x18 - cmp r6, #0xf - bls _0802FB52 -_0802FBA8: - mov r1, sb - lsls r0, r1, #0x18 - lsrs r2, r0, #0x18 - cmp r2, #3 - bls _0802FB2A - ldr r3, _0802FC48 @ =gCheese - ldr r0, [r3] - cmp r0, #0 - beq _0802FC12 - movs r6, #0 - ldr r3, _0802FC38 @ =gUnknown_080D6FF5 - movs r0, #0xf2 - adds r0, r0, r3 - mov r8, r0 - ldr r7, _0802FC40 @ =gObjPalette -_0802FBC6: - lsls r1, r6, #1 - adds r1, r1, r6 - adds r0, r3, #0 - adds r0, #0xf0 - adds r0, r1, r0 - ldrb r4, [r0] - adds r0, r4, #0 - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - adds r0, r3, #0 - adds r0, #0xf1 - adds r0, r1, r0 - ldrb r0, [r0] - adds r2, r0, #0 - muls r2, r5, r2 - lsrs r2, r2, #4 - lsls r2, r2, #0x18 - add r1, r8 - ldrb r0, [r1] - muls r0, r5, r0 - lsrs r0, r0, #4 - lsls r0, r0, #0x18 - adds r1, r6, #0 - adds r1, #0xe0 - lsls r1, r1, #1 - adds r1, r1, r7 - lsrs r0, r0, #0xe - lsrs r2, r2, #0x13 - orrs r0, r2 - orrs r0, r4 - strh r0, [r1] - adds r0, r6, #1 - lsls r0, r0, #0x18 - lsrs r6, r0, #0x18 - cmp r6, #0xf - bls _0802FBC6 -_0802FC12: - ldr r1, _0802FC4C @ =gFlags - ldr r0, [r1] - movs r1, #2 - orrs r0, r1 - ldr r3, _0802FC4C @ =gFlags - str r0, [r3] - ldr r0, _0802FC50 @ =0x00003FCF - ldr r1, [sp, #4] - strh r0, [r1, #8] - ldr r0, [sp, #4] - bl UpdateScreenFade - ldr r1, _0802FC54 @ =gWinRegs - ldr r0, _0802FC58 @ =0x00001F3F - strh r0, [r1, #8] - movs r0, #0x1f - b _0802FC70 - .align 2, 0 -_0802FC34: .4byte gMultiplayerConnections -_0802FC38: .4byte gUnknown_080D6FF5 -_0802FC3C: .4byte gMultiplayerCharacters -_0802FC40: .4byte gObjPalette -_0802FC44: .4byte gUnknown_080D6FF5+2 -_0802FC48: .4byte gCheese -_0802FC4C: .4byte gFlags -_0802FC50: .4byte 0x00003FCF -_0802FC54: .4byte gWinRegs -_0802FC58: .4byte 0x00001F3F -_0802FC5C: - ldr r0, _0802FCC0 @ =0x000030EF - ldr r3, [sp, #4] - strh r0, [r3, #8] - ldr r0, [sp, #4] - bl UpdateScreenFade - ldr r1, _0802FCC4 @ =gWinRegs - ldr r0, _0802FCC8 @ =0x00003F3F - strh r0, [r1, #8] - ldr r0, _0802FCCC @ =0x00001010 -_0802FC70: - strh r0, [r1, #0xa] - ldr r5, _0802FCD0 @ =gCurrentLevel - movs r0, #0 - ldrsb r0, [r5, r0] - cmp r0, #0x1d - bne _0802FC86 - ldr r2, _0802FCC4 @ =gWinRegs - ldrh r1, [r2, #8] - ldr r0, _0802FCD4 @ =0x0000FFF9 - ands r0, r1 - strh r0, [r2, #8] -_0802FC86: - ldr r1, [sp] - ldr r0, [r1] - cmp r0, #0xc7 - bls _0802FD0C - ldr r4, _0802FCD8 @ =gBldRegs - movs r0, #0 - strh r0, [r4, #4] - strh r0, [r4] - strh r0, [r4, #2] - ldr r3, _0802FCC4 @ =gWinRegs - ldr r2, _0802FCDC @ =0x0000F0F0 - strh r2, [r3] - ldr r1, _0802FCE0 @ =0x0000A0A0 - strh r1, [r3, #4] - strh r2, [r3, #2] - strh r1, [r3, #6] - strh r0, [r3, #8] - strh r0, [r3, #0xa] - movs r0, #0 - ldrsb r0, [r5, r0] - cmp r0, #0x1d - beq _0802FCEC - ldr r2, _0802FCE4 @ =gDispCnt - ldrh r1, [r2] - ldr r0, _0802FCE8 @ =0x00001FFF - ands r0, r1 - strh r0, [r2] - b _0802FD04 - .align 2, 0 -_0802FCC0: .4byte 0x000030EF -_0802FCC4: .4byte gWinRegs -_0802FCC8: .4byte 0x00003F3F -_0802FCCC: .4byte 0x00001010 -_0802FCD0: .4byte gCurrentLevel -_0802FCD4: .4byte 0x0000FFF9 -_0802FCD8: .4byte gBldRegs -_0802FCDC: .4byte 0x0000F0F0 -_0802FCE0: .4byte 0x0000A0A0 -_0802FCE4: .4byte gDispCnt -_0802FCE8: .4byte 0x00001FFF -_0802FCEC: - ldr r2, _0802FD1C @ =gDispCnt - ldrh r1, [r2] - ldr r0, _0802FD20 @ =0x000099FF - ands r0, r1 - strh r0, [r2] - ldr r0, _0802FD24 @ =0x00003735 - strh r0, [r3, #0xa] - ldr r0, _0802FD28 @ =0x00001346 - strh r0, [r4] - ldr r0, _0802FD2C @ =0x00000404 - strh r0, [r4, #2] - strh r0, [r4, #4] -_0802FD04: - ldr r0, _0802FD30 @ =gCurTask - ldr r0, [r0] - bl TaskDestroy -_0802FD0C: - add sp, #8 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0802FD1C: .4byte gDispCnt -_0802FD20: .4byte 0x000099FF -_0802FD24: .4byte 0x00003735 -_0802FD28: .4byte 0x00001346 -_0802FD2C: .4byte 0x00000404 -_0802FD30: .4byte gCurTask - -.syntax divided diff --git a/asm/non_matching/game/stage/intro/Task_IntroZoneNameAndIconAnimations.inc b/asm/non_matching/game/stage/intro/Task_IntroZoneNameAndIconAnimations.inc deleted file mode 100644 index d807cb000..000000000 --- a/asm/non_matching/game/stage/intro/Task_IntroZoneNameAndIconAnimations.inc +++ /dev/null @@ -1,424 +0,0 @@ -.include "constants/gba_constants.inc" -.syntax unified -.text - - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x10 - ldr r0, _0802FFC8 @ =gCurTask - ldr r1, [r0] - ldrh r6, [r1, #6] - movs r0, #0xc0 - lsls r0, r0, #0x12 - adds r0, r0, r6 - mov ip, r0 @ ip = sit_d - ldr r0, [r0] - ldr r3, [r0] @ r3 = counter - adds r0, r3, #0 - subs r0, #0xa - cmp r0, #0x7c - bls _0803004E - cmp r3, #0xc7 - bls _0802FFCC - adds r0, r1, #0 - bl TaskDestroy - b _0803029C - .align 2, 0 -_0802FFC8: .4byte gCurTask -_0802FFCC: - cmp r3, #0x95 - bhi _0802FFD2 - b _0803029C -_0802FFD2: - ldr r0, _08030018 @ =IWRAM_START + 0x1B4 - adds r5, r6, r0 - cmp r3, #0x96 - bne _08030030 - ldr r2, _0803001C @ =sColoredTriangle - ldr r1, _08030020 @ =gSelectedCharacter - movs r0, #0 - ldrsb r0, [r1, r0] - lsls r0, r0, #3 - adds r0, r0, r2 - ldrh r0, [r0, #4] - movs r3, #0 - movs r4, #0 - strh r0, [r5, #0xa] - movs r0, #0 - ldrsb r0, [r1, r0] - lsls r0, r0, #3 - adds r0, r0, r2 - ldrb r1, [r0, #6] - ldr r2, _08030024 @ =IWRAM_START + 0x1D4 - adds r0, r6, r2 - strb r1, [r0] - ldr r7, _08030028 @ =IWRAM_START + 0x1D9 - adds r0, r6, r7 - strb r3, [r0] - ldr r0, _0803002C @ =IWRAM_START + 0x1D5 - adds r1, r6, r0 - movs r0, #0xff - strb r0, [r1] - movs r0, #0xf0 - strh r0, [r5, #0x16] - movs r0, #0xa0 - strh r0, [r5, #0x18] - str r4, [r5, #0x10] - b _08030040 - .align 2, 0 -_08030018: .4byte IWRAM_START + 0x1B4 -_0803001C: .4byte sColoredTriangle -_08030020: .4byte gSelectedCharacter -_08030024: .4byte IWRAM_START + 0x1D4 -_08030028: .4byte IWRAM_START + 0x1D9 -_0803002C: .4byte IWRAM_START + 0x1D5 -_08030030: - cmp r3, #0xbd - bls _08030040 - ldrh r0, [r5, #0x16] - adds r0, #4 - strh r0, [r5, #0x16] - ldrh r0, [r5, #0x18] - adds r0, #4 - strh r0, [r5, #0x18] -_08030040: - adds r0, r5, #0 - bl UpdateSpriteAnimation - adds r0, r5, #0 - bl DisplaySprite - b _0803029C -_0803004E: - subs r3, #9 - ldr r1, _08030074 @ =IWRAM_START + 0x1B4 - adds r5, r6, r1 - cmp r3, #0xc - bhi _08030078 - lsls r1, r3, #2 - adds r1, r1, r3 - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #6 - lsrs r0, r0, #8 - movs r1, #0xfe - subs r1, r1, r0 - strh r1, [r5, #0x16] - lsls r0, r3, #5 - subs r0, r0, r3 - lsls r0, r0, #2 - subs r0, r0, r3 - b _080300A4 - .align 2, 0 -_08030074: .4byte IWRAM_START + 0x1B4 -_08030078: - cmp r3, #0x64 - bhi _08030086 - movs r0, #0x18 - strh r0, [r5, #0x16] - movs r0, #0x4a - strh r0, [r5, #0x18] - b _080300AE -_08030086: - adds r2, r3, #0 - subs r2, #0x58 - lsls r1, r2, #2 - adds r1, r1, r2 - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #6 - lsrs r0, r0, #8 - movs r1, #0xfe - subs r1, r1, r0 - strh r1, [r5, #0x16] - lsls r0, r2, #5 - subs r0, r0, r2 - lsls r0, r0, #2 - subs r0, r0, r2 -_080300A4: - lsls r0, r0, #3 - lsrs r0, r0, #8 - movs r1, #0x79 - subs r1, r1, r0 - strh r1, [r5, #0x18] -_080300AE: - movs r4, #0 - lsls r2, r3, #0x18 - str r2, [sp, #8] - lsls r1, r3, #2 - adds r1, r1, r3 - lsls r0, r1, #4 - subs r0, r0, r1 - lsls r0, r0, #6 - lsrs r0, r0, #8 - movs r7, #0x8e - lsls r7, r7, #1 - mov r8, r7 - mov r1, r8 @ r1 = r8 = 284 - subs r0, r1, r0 - mov sl, r0 - movs r6, #0 - lsls r0, r3, #5 - subs r0, r0, r3 - lsls r0, r0, #2 - subs r0, r0, r3 - lsls r0, r0, #3 - lsrs r0, r0, #8 - movs r7, #0x7f - subs r0, r7, r0 - mov sb, r0 - adds r2, r3, #0 - subs r2, #0x58 -_080300E4: - movs r1, #0xf2 - lsls r1, r1, #1 - adds r0, r6, r1 - mov r1, ip @ r1 = ip = sit_d - adds r5, r1, r0 @ r5 = s = &sit_d->sprZoneName[i]; - cmp r3, #0xc - bhi _080300FC - mov r0, sl - strh r0, [r5, #0x16] - mov r1, sb - strh r1, [r5, #0x18] - b _0803012A -_080300FC: - cmp r3, #0x64 - bhi _08030108 - movs r0, #0x36 - strh r0, [r5, #0x16] - movs r0, #0x50 - b _08030128 -_08030108: - lsls r0, r2, #2 - adds r0, r0, r2 - lsls r1, r0, #4 - subs r1, r1, r0 - lsls r1, r1, #6 - lsrs r1, r1, #8 - mov r0, r8 - subs r1, r0, r1 - strh r1, [r5, #0x16] - lsls r0, r2, #5 - subs r0, r0, r2 - lsls r0, r0, #2 - subs r0, r0, r2 - lsls r0, r0, #3 - lsrs r0, r0, #8 - subs r0, r7, r0 -_08030128: - strh r0, [r5, #0x18] -_0803012A: - cmp r4, #3 - bne _08030134 - ldrh r0, [r5, #0x16] - subs r0, #0x18 - strh r0, [r5, #0x16] -_08030134: - adds r6, #0x30 - adds r4, #1 - cmp r4, #3 - bls _080300E4 - ldr r1, [sp, #8] - lsrs r2, r1, #0x18 @ r2 = (u8)counter - movs r4, #0 - movs r7, #1 - mov r8, r7 @ r8 = 1 - movs r0, #0x14 - mov sl, r0 @ sl = 20 - movs r1, #0xc - mov sb, r1 @ sb = 12 - adds r0, r3, #0 - subs r0, #0x64 @ r0 = (counter - 100) - lsls r1, r2, #2 - adds r1, r1, r2 - lsls r1, r1, #1 - subs r1, #0x16 - str r1, [sp, #0xc] @ sp0C = sp08*10 - 22 - adds r6, r2, #0 @ r6 = sp08 - lsls r1, r0, #1 - adds r1, r1, r0 - lsls r1, r1, #1 - mov r7, sl - subs r7, r7, r1 - str r7, [sp] @ sp = 20 - (counter - 100)*6 - mov r0, sb - subs r0, r0, r1 - str r0, [sp, #4] -_08030170: - movs r0, #8 - subs r0, r0, r4 - lsls r1, r0, #1 - adds r1, r1, r0 - lsls r1, r1, #4 - adds r1, #4 - mov r7, ip - adds r5, r7, r1 - lsls r1, r0, #4 - adds r1, r1, r0 - adds r1, #0x43 - strh r1, [r5, #0x16] - movs r0, #0x16 - rsbs r0, r0, #0 - strh r0, [r5, #0x18] - cmp r2, #0x31 @ sp08 < 50 - bhi _080301C8 - lsls r1, r4, #1 - cmp r2, r1 - blo _080301F8 - adds r0, r4, #0 @ r0 = i - mov r7, r8 - ands r0, r7 - cmp r0, #0 - bne _080301B2 - cmp r6, #4 - bhi _080301AC - mov r0, sp - ldrh r0, [r0, #0xc] @ s->y = [sp, #0xc] - b _080301F6 -_080301AC: - mov r1, sl - strh r1, [r5, #0x18] - b _080301F8 -_080301B2: - subs r1, r2, r1 @ r1 = (sp08 - i*2) - cmp r1, #4 - bhi _080301C2 - lsls r0, r1, #1 - adds r0, r0, r1 - lsls r0, r0, #1 - subs r0, #0x16 - b _080301F6 -_080301C2: - mov r7, sb - strh r7, [r5, #0x18] - b _080301F8 -_080301C8: - cmp r3, #0x63 - bhi _080301E0 - adds r0, r4, #0 @ r0 = r4 = i - mov r1, r8 - ands r0, r1 - cmp r0, #0 - bne _080301DC - mov r7, sl - strh r7, [r5, #0x18] - b _080301F8 -_080301DC: - mov r0, sb - b _080301F6 -_080301E0: - adds r0, r4, #0 - mov r1, r8 - ands r0, r1 - cmp r0, #0 - bne _080301F2 - mov r7, sp - ldrh r7, [r7] - strh r7, [r5, #0x18] - b _080301F8 -_080301F2: - mov r0, sp - ldrh r0, [r0, #4] -_080301F6: - strh r0, [r5, #0x18] -_080301F8: - ldr r1, [sp, #0xc] - subs r1, #0x14 - str r1, [sp, #0xc] - subs r6, #2 - adds r4, #1 - cmp r4, #8 - bls _08030170 - movs r5, #0xa9 - lsls r5, r5, #2 - add r5, ip - movs r0, #0x24 - strh r0, [r5, #0x16] - cmp r3, #0x10 - bhi _0803021C - ldr r0, _08030218 @ =0x0000FFD0 - b _08030240 - .align 2, 0 -_08030218: .4byte 0x0000FFD0 -_0803021C: - cmp r3, #0x19 - bhi _0803022C - adds r0, r3, #0 - subs r0, #0x10 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x15 - subs r0, #0x28 - b _08030240 -_0803022C: - cmp r3, #0x64 - bhi _08030234 - movs r0, #0x20 - b _08030240 -_08030234: - adds r1, r3, #0 - subs r1, #0x64 - lsls r1, r1, #0x18 - lsrs r1, r1, #0x15 - movs r0, #0x20 - subs r0, r0, r1 -_08030240: - strh r0, [r5, #0x18] - movs r5, #0xb5 - lsls r5, r5, #2 - add r5, ip - ldr r2, _08030268 @ =gUnknown_030054B8 - ldrb r0, [r2] - adds r1, r0, #1 - strb r1, [r2] - movs r1, #0x20 - orrs r0, r1 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x18 - str r0, [r5, #0x10] - movs r0, #0x23 - strh r0, [r5, #0x16] - cmp r3, #0x10 - bhi _08030270 - ldr r0, _0803026C @ =0x0000FFCF - b _08030296 - .align 2, 0 -_08030268: .4byte gUnknown_030054B8 -_0803026C: .4byte 0x0000FFCF -_08030270: - cmp r3, #0x19 - bhi _08030280 - adds r0, r3, #0 - subs r0, #0x10 - lsls r0, r0, #0x18 - lsrs r0, r0, #0x15 - subs r0, #0x29 - b _08030296 -_08030280: - cmp r3, #0x64 - bhi _0803028A - strh r0, [r5, #0x16] - movs r0, #0x20 - b _08030296 -_0803028A: - adds r1, r3, #0 - subs r1, #0x64 - lsls r1, r1, #0x18 - lsrs r1, r1, #0x15 - movs r0, #0x20 - subs r0, r0, r1 -_08030296: - strh r0, [r5, #0x18] - bl StageIntroUpdateIcons -_0803029C: - add sp, #0x10 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - -.syntax divided diff --git a/graphics.mk b/graphics.mk index 443bae415..1eecb0663 100644 --- a/graphics.mk +++ b/graphics.mk @@ -26,8 +26,15 @@ tileset_%.4bpp: tileset_%.png tiles.8bpp: tiles.png $(GFX) $< $@ -ignore_trailing +ifeq ($(PLATFORM),win32) + # For experimental OpenGL renderer + GFX_CVT_FLAGS := +else + GFX_CVT_FLAGS := -split_into_oam_shapes +endif + graphics/obj_tiles/4bpp/%.4bpp: graphics/obj_tiles/4bpp/%.png - $(GFX) $< $@ -split_into_oam_shapes + $(GFX) $< $@ $(GFX_CVT_FLAGS) graphics/obj_tiles/8bpp/%.8bpp: graphics/obj_tiles/8bpp/%.png - $(GFX) $< $@ -split_into_oam_shapes + $(GFX) $< $@ $(GFX_CVT_FLAGS) diff --git a/include/config.h b/include/config.h index ee95e6bad..4023644ee 100644 --- a/include/config.h +++ b/include/config.h @@ -30,4 +30,14 @@ #define TAS_TESTING 0 #define TAS_TESTING_WIDESCREEN_HACK 1 +#define RENDERER_SOFTWARE 0 +#define RENDERER_OPENGL 1 +#define RENDERER_COUNT 2 +#if PLATFORM_WIN32 && !PLATFORM_SDL +// TODO: Only win32 for now +#define RENDERER RENDERER_OPENGL +#else +#define RENDERER RENDERER_SOFTWARE +#endif + #endif // GUARD_SA2_CONFIG_H diff --git a/include/game/stage/player.h b/include/game/stage/player.h index 9ca171593..5ae1ae4d6 100644 --- a/include/game/stage/player.h +++ b/include/game/stage/player.h @@ -26,7 +26,7 @@ void sub_80232D0(Player *); void sub_8023610(Player *); void Player_TouchGround(Player *p); void Player_80261D8(Player *p); -void sub_8027EF0(Player *p); +void Player_HandlePhysicsWithAirInput(Player *p); void sub_8028204(Player *p); void sub_80282EC(Player *p); void sub_80283C4(Player *p); diff --git a/include/platform/shared/input.h b/include/platform/shared/input.h new file mode 100644 index 000000000..5b6045212 --- /dev/null +++ b/include/platform/shared/input.h @@ -0,0 +1,8 @@ +#ifndef GUARD_PLATFORM_SHARED_INPUT_H +#define GUARD_PLATFORM_SHARED_INPUT_H + +#include "sprite.h" // for Sprite + +u16 GetXInputKeys(); + +#endif // GUARD_PLATFORM_SHARED_INPUT_H diff --git a/include/platform/shared/opengl.h b/include/platform/shared/opengl.h new file mode 100644 index 000000000..dc643c216 --- /dev/null +++ b/include/platform/shared/opengl.h @@ -0,0 +1,10 @@ +#ifndef GUARD_PLATFORM_SHARED_OPENGL_H +#define GUARD_PLATFORM_SHARED_OPENGL_H + +#include "sprite.h" // for Sprite + +void OpenGL_OnInit(); +void OpenGL_DisplaySprite(Sprite *sprite, u8 oamPaletteNum); +void OpenGL_Render(void *tempBufferPixels, int windowWidth, int windowHeight); + +#endif // GUARD_PLATFORM_SHARED_OPENGL_H diff --git a/scripts/progress.py b/scripts/progress.py index 2c274b8d7..fda8ad49e 100644 --- a/scripts/progress.py +++ b/scripts/progress.py @@ -17,7 +17,7 @@ def collect_non_matching_funcs(): for i in range(len(lines)): line = lines[i] if "NONMATCH" in line: - # if "unused" in line.lower(): + # if "unused_" in line.lower(): # continue matcher = r'(NONMATCH|ASM_FUNC)\(".*",\W*\w*\W*(\w*).*\)' match = re.findall(matcher, line) @@ -88,7 +88,7 @@ def parse_map(non_matching_funcs): if len(arr) == 2 and arr[1] != '': # It is actually a symbol if prev_symbol in non_matching_funcs: - non_matching_funcs.remove(prev_symbol) + # non_matching_funcs.remove(prev_symbol) # Calculate the length for non matching function non_matching += int(arr[0], 16) - prev_addr diff --git a/src/background.c b/src/background.c index 3ff353130..7b9869009 100644 --- a/src/background.c +++ b/src/background.c @@ -88,6 +88,11 @@ NONMATCH("asm/non_matching/engine/sub_8002B20.inc", bool32 sub_8002B20(void)) s32 j; u16 k; +#if (RENDERER == RENDERER_OPENGL) + // TEMP + return TRUE; +#endif + while (gBackgroundsCopyQueueCursor != gBackgroundsCopyQueueIndex) { Background *bg; @@ -626,6 +631,7 @@ END_NONMATCH void UpdateBgAnimationTiles(Background *bg) { +#if (RENDERER == RENDERER_SOFTWARE) Tilemap *tilemap = gTilemapsRef[bg->tilemapId]; if (tilemap->animFrameCount > 0) { if (tilemap->animDelay <= ++bg->animDelayCounter) { @@ -660,6 +666,7 @@ void UpdateBgAnimationTiles(Background *bg) } } } +#endif } // Differences to UpdateSpriteAnimation: @@ -845,6 +852,7 @@ NONMATCH("asm/non_matching/engine/sub_80039E4.inc", bool32 sub_80039E4(void)) return TRUE; #endif +#if (RENDERER == RENDERER_SOFTWARE) if (gUnknown_03005390 != 0) { OamDataShort oam; s32 r5; @@ -983,6 +991,7 @@ NONMATCH("asm/non_matching/engine/sub_80039E4.inc", bool32 sub_80039E4(void)) gUnknown_03005390 = 0; } +#endif return TRUE; } diff --git a/src/core.c b/src/core.c index 6aedab50b..6e6c73bf2 100644 --- a/src/core.c +++ b/src/core.c @@ -720,7 +720,9 @@ static bool32 ProcessVramGraphicsCopyQueue(void) if ((graphics->src != 0) && (graphics->dest != 0)) #endif { +#if (RENDERER == RENDERER_SOFTWARE) DmaCopy16(3, (void *)(graphics->src + offset), (void *)(graphics->dest + offset), COPY_CHUNK_SIZE); +#endif graphics->size -= COPY_CHUNK_SIZE; } #ifdef BUG_FIX @@ -733,7 +735,9 @@ static bool32 ProcessVramGraphicsCopyQueue(void) if ((graphics->src != 0) && (graphics->dest != 0)) #endif { +#if (RENDERER == RENDERER_SOFTWARE) DmaCopy16(3, (void *)(graphics->src + offset), (void *)(graphics->dest + offset), graphics->size); +#endif } graphics->size = 0; } diff --git a/src/game/bosses/boss_4.c b/src/game/bosses/boss_4.c index 669142a02..c9848af5a 100644 --- a/src/game/bosses/boss_4.c +++ b/src/game/bosses/boss_4.c @@ -485,14 +485,14 @@ static void AeroEgg_UpdateBossSpritesOnDefeat(AeroEgg *boss) } // (93.54%) https://decomp.me/scratch/PPILk +// (97.22%) https://decomp.me/scratch/30p2x NONMATCH("asm/non_matching/game/bosses/boss_4__sub_8041D34.inc", void sub_8041D34(AeroEgg *boss)) { ExplosionPartsInfo partsInfo; - s32 res; AeroEggSub *sub = &boss->sub; u32 newUnk6A; - s32 spawnX, spawnY; + u8 i; --sub->unk6A; newUnk6A = sub->unk6A; @@ -502,130 +502,118 @@ NONMATCH("asm/non_matching/game/bosses/boss_4__sub_8041D34.inc", void sub_8041D3 } // _08041D62 - res = Mod(newUnk6A, 12); + if (Mod(newUnk6A, 12) == 0) { + s32 rand, spawnX, spawnY; + +#ifndef NON_MATCHING + do { +#endif + sub->unk6A = 0x30; + rand = PseudoRandom32() + 0; + spawnX = (I(sub->body.x)); + partsInfo.spawnX = (spawnX - gCamera.x) + (rand & 0x1F) - 0x1F; + ; + + rand = PseudoRandom32() + 0; + spawnY = (I(sub->body.y)); + partsInfo.spawnY = (spawnY - gCamera.y) + (rand % 64u) - 48; + partsInfo.velocity = 0; - if (res == 0) { - s32 rand; + partsInfo.rotation = ({ (1000 - (PseudoRandom32() & 0x3F)); }) + 0; + partsInfo.speed = ({ 1024 - (PseudoRandom32() & 0x1FF); }) + 0; - sub->unk6A = 0x30; - rand = PseudoRandom32(); - spawnX = (I(sub->body.x) - gCamera.x); - spawnX += (rand & 0x1F); - spawnX -= 0x1F; - partsInfo.spawnX = spawnX; + partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; + partsInfo.anim = SA2_ANIM_EXPLOSION; + partsInfo.variant = 0; + partsInfo.unk4 = 0; - rand = PseudoRandom32(); - spawnY = (I(sub->body.y) - gCamera.y) + (rand % 64u); - spawnY -= 48; - partsInfo.spawnY = spawnY; - partsInfo.velocity = 0; + CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); +#ifndef NON_MATCHING + } while (0); +#endif + } + // _08041DFA - partsInfo.rotation = (1000 - (PseudoRandom32() & 0x3F)); + if ((sub->unk6A & 0x3) == 0) { + s32 rand; + s32 spawnX; + s32 spawnY, r5, r4; + s32 temp; - partsInfo.speed = 1024 - (PseudoRandom32() & 0x1FF); + rand = ({ PseudoRandom32() & 0xF; }) + 0; - partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; - partsInfo.anim = SA2_ANIM_EXPLOSION; - partsInfo.variant = 0; - partsInfo.unk4 = 0; + i = rand - Div(rand, 6) * 6; + spawnX = I(sub->body.x); + partsInfo.spawnX = (spawnX - gCamera.x) - rand * 2 + rand * 4; - CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); - } - // _08041DFA + rand = ({ PseudoRandom32() & 0xF; }) + 0; + spawnY = I(sub->body.y); + partsInfo.spawnY = (spawnY - gCamera.y) - (rand * 2) + rand * 4; - if ((sub->unk6A & 0x3) == 0) { - s32 rand, spawnY; - u8 r7; - - rand = (PseudoRandom32() & 0xF); - r7 = rand - Div(rand, 6) * 6; - spawnX = I(sub->body.x) - gCamera.x; - spawnX -= rand * 2; - spawnX += rand * 4; - partsInfo.spawnX = spawnX; - - rand = PseudoRandom32() % 16u; - spawnY = I(sub->body.y) - gCamera.y; - spawnY -= rand * 2; - spawnY += rand * 4; - partsInfo.spawnY = spawnY; - - partsInfo.velocity = Q(0.25); - - partsInfo.rotation = (PseudoRandom32() & 0x3FF); - partsInfo.speed = 1792 - (PseudoRandom32() % 512u); - - partsInfo.vram = (void *)(OBJ_VRAM0 + (gTileInfoBossScrews[r7][0] * TILE_SIZE_4BPP)); - partsInfo.anim = gTileInfoBossScrews[r7][1]; - partsInfo.variant = gTileInfoBossScrews[r7][2]; + partsInfo.velocity = Q_24_8(0.25); + + partsInfo.rotation = ({ (PseudoRandom32() & 0x3FF); }) + 0; + partsInfo.speed = ({ 1792 - (PseudoRandom32() & 0x1FF); }) + 0; + + partsInfo.vram = (void *)(OBJ_VRAM0 + (gTileInfoBossScrews[i][0] * TILE_SIZE_4BPP)); + partsInfo.anim = gTileInfoBossScrews[i][1]; + partsInfo.variant = gTileInfoBossScrews[i][2]; partsInfo.unk4 = 1; CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); } // _08041ED0 - { - u8 i; - for (i = 0; i < ARRAY_COUNT(sub->tail); i++) { - s32 temp; - - if (boss->sub.tail[i].status != 0) { - continue; - } - - if ((newUnk6A == i + 4) || (newUnk6A == i + 30)) { - partsInfo.spawnX = I(sub->tail[i].x) - gCamera.x; - partsInfo.spawnY = I(sub->tail[i].y) - gCamera.y; - partsInfo.velocity = 0; - - temp = (1000 - (PseudoRandom32() & 0x3F)); - partsInfo.rotation = temp; + for (i = 0; i < ARRAY_COUNT(sub->tail); i++) { + if (boss->sub.tail[i].status == 0 && ((newUnk6A == i + 4) || (newUnk6A == i + 30))) { + s32 spawnX, spawnY; + spawnX = Q_24_8_TO_INT(sub->tail[i].x); + partsInfo.spawnX = spawnX - gCamera.x; + spawnY = Q_24_8_TO_INT(sub->tail[i].y); + partsInfo.spawnY = spawnY - gCamera.y; - temp = 1152 - (PseudoRandom32() & 0x1FF); - partsInfo.speed = temp; + partsInfo.velocity = 0; + partsInfo.rotation = ({ (1000 - (PseudoRandom32() & 0x3F)); }) + 0; + partsInfo.speed = ({ 1152 - (PseudoRandom32() & 0x1FF); }) + 0; - partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; - partsInfo.anim = SA2_ANIM_EXPLOSION; - partsInfo.variant = 0; - partsInfo.unk4 = 0; - CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); - } + partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; + partsInfo.anim = SA2_ANIM_EXPLOSION; + partsInfo.variant = 0; + partsInfo.unk4 = 0; + CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); } } if ((newUnk6A == 41) || (newUnk6A == 18)) { - ExplosionPartsInfo *localInfo; - s32 tmp; if (sub->tailTip.status == 0) { - partsInfo.spawnX = I(sub->tailTip.x) - gCamera.x; - partsInfo.spawnY = I(sub->tailTip.y) - gCamera.y; - partsInfo.velocity = 0; + s32 spawnX, spawnY; + spawnX = I(sub->tailTip.x); + partsInfo.spawnX = spawnX - gCamera.x; - localInfo = &partsInfo; - tmp = (1000 - (PseudoRandom32() % 64u)); - localInfo->rotation = tmp; + spawnY = I(sub->tailTip.y); + partsInfo.spawnY = spawnY - gCamera.y; - tmp = 1024 - (PseudoRandom32() % 512u); - localInfo->speed = tmp; + partsInfo.velocity = 0; + partsInfo.rotation = ({ (1000 - (PseudoRandom32() % 64u)); }) + 0; + partsInfo.speed = ({ 1024 - (PseudoRandom32() % 512u); }) + 0; - localInfo->vram = RESERVED_EXPLOSION_TILES_VRAM; + partsInfo.vram = RESERVED_EXPLOSION_TILES_VRAM; partsInfo.anim = SA2_ANIM_EXPLOSION; partsInfo.variant = 0; - localInfo->unk4 = 0; + partsInfo.unk4 = 0; CreateBossParticleWithExplosionUpdate(&partsInfo, &sub->unk69); } } } END_NONMATCH -// (99.64%) https://decomp.me/scratch/WJcpn -NONMATCH("asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc", void AeroEgg_InitPartsDefeated(AeroEgg *boss)) +void AeroEgg_InitPartsDefeated(AeroEgg *boss) { Sprite *s; AeroEggSub *sub = &boss->sub; + u8 i; sub->unk00 = 0; - sub->unk68 = 0; sub->unk69 = 0; sub->unk6A = 0x30; @@ -646,36 +634,40 @@ NONMATCH("asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc", void Aero sub->tailTip.dy = Q(0.00); sub->tailTip.status = 0; - { - u8 i; - for (i = 0; i < ARRAY_COUNT(sub->tail); i++) { - u16 period = SIN_24_8(((gStageTime * 12) + (i << 7)) & ONE_CYCLE) >> 3; - s32 bossX, bossY; - s32 sinV, cosV; - - bossX = I(boss->main.qWorldX); - period = (period + 500) & ONE_CYCLE; - cosV = (COS(period) * 17); - cosV *= (i + 1); - cosV >>= 14; - bossX += cosV; - - bossY = I(boss->main.qWorldY); - sinV = (SIN(period) * 17); - sinV *= (i + 1); - sinV >>= 14; - sinV += 0x14; - bossY += sinV; - - sub->tail[i].x = Q(bossX); - sub->tail[i].y = Q(bossY); - sub->tail[i].dx = Q(5.75); - sub->tail[i].dy = 0; + for (i = 0; i < ARRAY_COUNT(sub->tail); i++) { + s32 xVal, yVal; + s32 sinV, cosV; + s32 bossX, bossY; + + u16 period = SIN_24_8(((gStageTime * 12) + (i << 7)) & ONE_CYCLE) >> 3; + + bossX = I(boss->main.qWorldX); + cosV = (COS((period + 500) & ONE_CYCLE) * 17); + cosV *= (i + 1); + cosV >>= 14; + bossX += cosV; + + bossY = I(boss->main.qWorldY); + sinV = (SIN((period + 500) & ONE_CYCLE) * 17); + sinV *= (i + 1); + sinV >>= 14; + sinV += 20; + bossY += sinV; + + sub->tail[i].x = Q_24_8(bossX); + sub->tail[i].y = Q_24_8(bossY); + sub->tail[i].dx = Q_24_8(5.75); + sub->tail[i].dy = 0; + // The scope is actually required to make it match, + // we are gonna assume there was an if here or something +#ifndef NON_MATCHING + if (1) +#endif + { sub->tail[i].status = 0; } } } -END_NONMATCH static void AeroEgg_UpdatePartsAfterBossDefeated(AeroEgg *boss) { diff --git a/src/game/bosses/boss_8.c b/src/game/bosses/boss_8.c index 7143dcc58..2394d90c7 100644 --- a/src/game/bosses/boss_8.c +++ b/src/game/bosses/boss_8.c @@ -891,11 +891,12 @@ static void Task_804A9D8(void) } // (99.89%) https://decomp.me/scratch/kiah8 -NONMATCH("asm/non_matching/game/bosses/boss_8__Task_804AB24.inc", void Task_804AB24(void)) +void Task_804AB24(void) { s32 speed; SuperEggRoboZ *boss = TASK_DATA(gCurTask); ScreenFade *fade = &boss->fade; + Player *p; sub_804CC98(boss); sub_804CA08(boss); @@ -908,34 +909,67 @@ NONMATCH("asm/non_matching/game/bosses/boss_8__Task_804AB24.inc", void Task_804A sub_804C830(boss); sub_804CA70(boss); - if ((I(gPlayer.qWorldY) > 184) && (I(gPlayer.qWorldX) >= 43034)) { - sub_800CBA4(&gPlayer); - - speed = gPlayer.speedAirX; + // TODO: maybe these are macros or inline functions? + p = &gPlayer; + if ((I(p->qWorldY) > 184) && (I(p->qWorldX) >= 43034)) { + sub_800CBA4(p); + // These are just hacks to make the read use the right register + // if we use c it uses r2 on some of these +#ifndef NON_MATCHING + asm("mov r1, %2\n" + "ldrsh %0, [%1, r1]" + : "=r"(speed) + : "r"(p), "I"(offsetof(Player, speedAirX))); +#else + speed = p->speedAirX; +#endif if (speed > 0) { - gPlayer.speedAirX = -speed; + speed = -speed; + p->speedAirX = speed; } - speed = gPlayer.speedGroundX; +#ifndef NON_MATCHING + asm("mov r1, %2\n" + "ldrsh %0, [%1, r1]" + : "=r"(speed) + : "r"(p), "I"(offsetof(Player, speedGroundX))); +#else + speed = p->speedGroundX; +#endif if (speed > 0) { - gPlayer.speedGroundX = -speed; + p->speedGroundX = -speed; } } // _0804ABC0 - if (I(gPlayer.qWorldX) >= 43088) { - sub_800CBA4(&gPlayer); - - speed = gPlayer.speedAirX; + p = &gPlayer; + if (I(p->qWorldX) >= 43088) { + sub_800CBA4(p); +#ifndef NON_MATCHING + asm("mov r1, %2\n" + "ldrsh %0, [%1, r1]" + : "=r"(speed) + : "r"(p), "I"(offsetof(Player, speedAirX))); +#else + speed = p->speedAirX; +#endif if (speed > 0) { - gPlayer.speedAirX = -speed; + p->speedAirX = -speed; } - speed = gPlayer.speedGroundX; +#ifndef NON_MATCHING + asm("mov r1, %2\n" + "ldrsh %0, [%1, r1]" + : "=r"(speed) + : "r"(p), "I"(offsetof(Player, speedGroundX))); +#else + speed = p->speedGroundX; +#endif if (speed > 0) { - gPlayer.speedGroundX = -speed; + p->speedGroundX = -speed; } } + // _0804ABF2 if (boss->livesCockpit == 0) { @@ -989,7 +1023,6 @@ NONMATCH("asm/non_matching/game/bosses/boss_8__Task_804AB24.inc", void Task_804A } } } -END_NONMATCH static void Task_804AD68(void) { @@ -1255,81 +1288,72 @@ static u8 sub_804B0EC(SuperEggRoboZ *boss, u8 arm) return result; } -// Copy-paste of sub_804B0EC() aside from code above: -// if (gSelectedCharacter != CHARACTER_SONIC) { -// ... -// } -// (93.51%) https://decomp.me/scratch/ecqNB -NONMATCH("asm/non_matching/game/bosses/boss_8__sub_804B2EC.inc", bool8 sub_804B2EC(SuperEggRoboZ *boss, u8 arm)) +bool8 sub_804B2EC(SuperEggRoboZ *boss, u8 arm) { u8 result = 0; - s32 sp04, ip; - s32 r3; - s32 r4; - s32 r5; - s32 r6; - s32 r7; - s32 sl; + s32 x, y; + s32 r6, r0; + Sprite *s; if (boss->unk3E[arm] > 0) { return result; } - // _0804B314 - { - s32 r0, r1; - Sprite *s = &gPlayer.spriteInfoBody->s; + s = &gPlayer.spriteInfoBody->s; - r6 = boss->qPos.x + boss->qUnk18[arm].x; - r4 = r6 + gUnknown_080D8888[arm][0]; +#ifndef NON_MATCHING + // unused lines required for match + // maybe they had a calculation here they just forgot about + r0 = boss->qPos.x + boss->qUnk18[arm].x + gUnknown_080D8888[arm][0]; + r6 = boss->qPos.x + boss->qUnk18[arm].x; + r0 = boss->qPos.y + boss->qUnk18[arm].y + gUnknown_080D8888[arm][1]; +#endif - r5 = boss->qPos.y + boss->qUnk18[arm].y; - r5 = r5 + gUnknown_080D8888[arm][1]; + x = boss->qPos.x + boss->qUnk18[arm].x + gUnknown_080D8888[arm][0]; + y = boss->qPos.y + boss->qUnk18[arm].y + gUnknown_080D8888[arm][1]; - if (gSelectedCharacter != CHARACTER_SONIC) { - Player_UpdateHomingPosition(r4, r5); - } + if (gSelectedCharacter != CHARACTER_SONIC) { + Player_UpdateHomingPosition(x, y); + } - if (PLAYER_IS_ALIVE && HITBOX_IS_ACTIVE(s->hitboxes[1])) { - r5 = I(gPlayer.qWorldX - r6); - r4 = I(gPlayer.qWorldY - r7); + if (PLAYER_IS_ALIVE && HITBOX_IS_ACTIVE(s->hitboxes[1])) { + r6 = I(gPlayer.qWorldX - x); + r0 = I(gPlayer.qWorldY - y); - r5 = SQUARE(r5); - r4 = SQUARE(r4); - if ((r5 + r4) < 376) { - s32 speed; - result = sub_804C9B4(boss, arm); + r6 = SQUARE(r6); + r0 = SQUARE(r0); + if ((r6 + r0) < 376) { + s32 speed; + result = sub_804C9B4(boss, arm); - speed = -gPlayer.speedAirX; - gPlayer.speedAirX = speed; + speed = -gPlayer.speedAirX; + gPlayer.speedAirX = speed; - speed = -gPlayer.speedAirY; - gPlayer.speedAirY = speed; + speed = -gPlayer.speedAirY; + gPlayer.speedAirY = speed; - speed = -gPlayer.speedGroundX; - gPlayer.speedGroundX = speed; + speed = -gPlayer.speedGroundX; + gPlayer.speedGroundX = speed; - return result; - } + return result; } + } - if ((gCheese != NULL) && HITBOX_IS_ACTIVE(gCheese->reserved)) { - r6 -= gCheese->posX; - r6 = (r6) >> 8; - r7 -= gCheese->posY; - r7 = (r7) >> 8; + if ((gCheese != NULL) && HITBOX_IS_ACTIVE(gCheese->reserved)) { + x -= gCheese->posX; + x = (x) >> 8; + y -= gCheese->posY; + y = (y) >> 8; - if ((SQUARE(r6) + SQUARE(r7)) < 376) { - result = sub_804C9B4(boss, arm); + if ((SQUARE(x) + SQUARE(y)) < 376) { + result = sub_804C9B4(boss, arm); - gCheeseTarget.task->unk15 = 0; - } + gCheeseTarget.task->unk15 = 0; } } return result; } -END_NONMATCH static void sub_804B43C(SuperEggRoboZ *boss, u8 arm) { diff --git a/src/game/bosses/boss_9.c b/src/game/bosses/boss_9.c index dea1cb276..c55f2b0c1 100644 --- a/src/game/bosses/boss_9.c +++ b/src/game/bosses/boss_9.c @@ -1203,14 +1203,13 @@ void sub_804E078(struct TA53_unk48 *unk48) unk48->unk38 &= ONE_CYCLE; } -// (94.10%) https://decomp.me/scratch/rjfvR -NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804E15C.inc", void sub_804E15C(struct TA53_unk48 *unk48)) +void sub_804E15C(struct TA53_unk48 *unk48) { TA53Boss *boss = TASK_DATA(gCurTask); TA53_unk558 *unk558 = &boss->unk558; TA53_unk1C *unk1C = &boss->unk1C; - Vec2_32 qSonicPos; - u8 i; + s32 sonicX, sonicY; + u8 sp14, i; if (sub_8050030(unk48) != 0) { unk48->unk30 &= 0xFFF; @@ -1225,173 +1224,189 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804E15C.inc", void sub_804E15 gBldRegs.bldCnt = 0; gBldRegs.bldAlpha = 0; gBldRegs.bldY = 0; - } else { - u8 sp14 = (unk48->unk30 >> 12); + return; + } - if (sp14 > 2) { - // _0804E1EC - s32 index; - s32 sb = unk1C->qPos.x + Q(unk1C->unk20); - s32 r8 = unk1C->qPos.y + Q(unk1C->unk22); - s32 r5 = (I(unk48->qPos44.x) + unk48->unk3A[0]) & ONE_CYCLE; - s32 r6; + sp14 = (unk48->unk30 >> 12); + if (sp14 > 2) { + // _0804E1EC + s32 sb = unk1C->qPos.x + Q(unk1C->unk20); + s32 r8 = unk1C->qPos.y + Q(unk1C->unk22); - sb += ((COS(r5) * gUnknown_080D89A5[0]) >> 6); - r8 += ((SIN(r5) * gUnknown_080D89A5[0]) >> 6); + s32 r4, r5 = CLAMP_SIN_PERIOD(I(unk48->qPos44.x) + unk48->unk3A[0]); + u16 r6; - r5 += 0x8C; + sb += ((COS(r5) * gUnknown_080D89A5[0]) >> 6); + r8 += ((SIN(r5) * gUnknown_080D89A5[0]) >> 6); - index = (r5 - Q(1)) & ONE_CYCLE; - sb += (COS(index) >> 2); - r8 += (SIN(index) >> 2); + r5 += 0x8C; - for (i = 0; i < 3; i++) { - // _0804E278 - r5 = (r5 + unk48->unk3A[i + 1]) & ONE_CYCLE; + sb += ({ + s32 val = COS((r5 - Q(1)) & ONE_CYCLE); + val >> 2; + }); + r8 += ({ + s32 val = SIN((r5 - Q(1)) & ONE_CYCLE); + val >> 2; + }); - sb += ((COS(r5) * gUnknown_080D89A5[i + 1]) >> 6); - r8 += ((SIN(r5) * gUnknown_080D89A5[i + 1]) >> 6); - } + for (i = 0; i < 3; i++) { + // _0804E278 + r5 += unk48->unk3A[i + 1]; + r5 &= ONE_CYCLE; - sb += ((COS(r5) * gUnknown_080D89A5[4]) >> 6); - r8 += ((SIN(r5) * gUnknown_080D89A5[4]) >> 6); + sb += ((COS(r5) * gUnknown_080D89A5[i + 1]) >> 6); + r8 += ((SIN(r5) * gUnknown_080D89A5[i + 1]) >> 6); + } - r5 = (r5 + unk48->unk42) & ONE_CYCLE; + sb += ((COS(r5) * gUnknown_080D89A5[4]) >> 6); + r8 += ((SIN(r5) * gUnknown_080D89A5[4]) >> 6); - if (sp14 > 5) { - // _0804E2EE + r5 += unk48->unk42; + r5 &= ONE_CYCLE; - // TODO: Type - u16 result; - s32 r4; - u16 r1; - s32 x, y; + if (sp14 > 5) { + // _0804E2EE - if ((gMPlayTable[2].info->songHeader != gSongTable[SE_269].header) && (sp14 == 6)) { - m4aSongNumStart(SE_269); - } - // _0804E30A - - SuperSonicGetPos(&qSonicPos.x, &qSonicPos.y); + if ((gMPlayTable[2].info->songHeader != gSongTable[SE_269].header) && (sp14 == 6)) { + m4aSongNumStart(SE_269); + } + // _0804E30A - r6 = (r5 + unk48->unk38) & ONE_CYCLE; + SuperSonicGetPos(&sonicX, &sonicY); - result = sub_8004418(I(qSonicPos.y - r8), I(qSonicPos.x - sb)); + r5 += unk48->unk38; + r6 = CLAMP_SIN_PERIOD(r5); - if ((r6 < (result + 0x10)) && (r6 > (result - 0x10))) { - sub_802BB54(); - unk558->callback = sub_804F1EC; - } - // _0804E350 - - gDispCnt |= DISPCNT_WIN0_ON; - gWinRegs[WINREG_WIN0H] = WIN_RANGE(0, DISPLAY_HEIGHT); - gWinRegs[WINREG_WIN0V] = WIN_RANGE(0, DISPLAY_WIDTH); - gWinRegs[WINREG_WININ] = WININ_WIN0_ALL; - gWinRegs[WINREG_WINOUT] = (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_OBJ); - gBldRegs.bldCnt = (BLDCNT_TGT2_ALL | BLDCNT_EFFECT_LIGHTEN | BLDCNT_TGT1_ALL); - gBldRegs.bldAlpha = BLDALPHA_BLEND(8, 0); - gBldRegs.bldY = 8; - - // NOTE: Why would you call Mod() for % 8? *sigh* - r4 = (s8)Mod(PseudoRandom32(), 8); - if (r4 < 0) { - r4 = -r4; - } - // _0804E39A + r5 = (u16)sub_8004418(I(sonicY - r8), I(sonicX - sb)); - sb += ((COS(r6) * gUnknown_080D89A5[5]) >> 6); - r8 += ((SIN(r6) * gUnknown_080D89A5[5]) >> 6); + if ((r6 < (r5 + 0x10)) && (r6 > (r5 - 0x10))) { + sub_802BB54(); + unk558->callback = sub_804F1EC; + } + // _0804E350 + + gDispCnt |= DISPCNT_WIN0_ON; + gWinRegs[WINREG_WIN0H] = WIN_RANGE(0, DISPLAY_HEIGHT); + gWinRegs[WINREG_WIN0V] = WIN_RANGE(0, DISPLAY_WIDTH); + gWinRegs[WINREG_WININ] = WININ_WIN0_ALL; + gWinRegs[WINREG_WINOUT] = (WINOUT_WIN01_BG0 | WINOUT_WIN01_BG2 | WINOUT_WIN01_OBJ); + gBldRegs.bldCnt = (BLDCNT_TGT2_ALL | BLDCNT_EFFECT_LIGHTEN | BLDCNT_TGT1_ALL); + + r5 = 8; + gBldRegs.bldAlpha = BLDALPHA_BLEND(r5, 0); + gBldRegs.bldY = r5; + + // NOTE: Why would you call Mod() for % 8? *sigh* + r4 = (s8)Mod(PseudoRandom32(), 8); + if (r4 < 0) { + r4 = -r4; + } + // _0804E39A - r1 = (26 - (s8)r4); + sb += ((COS(r6) * gUnknown_080D89A5[5]) >> 6); + r8 += ((SIN(r6) * gUnknown_080D89A5[5]) >> 6); - sub_802E784(r6, r1, 16, (I(sb) - gCamera.x), (I(r8) - gCamera.y), r5); - } else { - u16 result; - u32 p0; - // _0804E43C - sub_802C704(8, &qSonicPos.x, &qSonicPos.y); - - result = sub_8004418(I(qSonicPos.y - r8), I(qSonicPos.x - sb)); - if (sub_808558C((r5 + unk48->unk38) & ONE_CYCLE, result, 10) < 0) { - if (unk48->unk38 > 512) { - if (unk48->unk38 > 0x380) - unk48->unk38 -= 4; - } else { + sub_802E784(r6, (26 - (s8)r4), 16, (I(sb) - gCamera.x), (I(r8) - gCamera.y), r5); + } else { + u32 p0; + // _0804E43C + sub_802C704(8, &sonicX, &sonicY); + + r6 = sub_8004418(I(sonicY - r8), I(sonicX - sb)); + p0 = r5; + p0 += unk48->unk38; + if (sub_808558C(p0 & ONE_CYCLE, r6, 10) < 0) { + if (unk48->unk38 > 512) { + if (unk48->unk38 > 0x380) unk48->unk38 -= 4; - } } else { - if (unk48->unk38 < 512) { - if (unk48->unk38 < 128) - unk48->unk38 += 4; - } else { + unk48->unk38 -= 4; + } + } else { + if (unk48->unk38 < 512) { + if (unk48->unk38 < 128) unk48->unk38 += 4; - } + } else { + unk48->unk38 += 4; } - - unk48->unk38 &= ONE_CYCLE; } + + unk48->unk38 &= ONE_CYCLE; } } } -END_NONMATCH -// (89.56%) https://decomp.me/scratch/sGKWf -NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804E4CC.inc", void sub_804E4CC(struct TA53_unk48 *unk48)) +void sub_804E4CC(struct TA53_unk48 *unk48) { - u16 r2; - - s32 r5; +#ifndef NON_MATCHING + register s32 r1 asm("r1"); +#else + s32 r1; +#endif + s32 r3; + u32 r5; + u16 r6, r2; u8 i, c; + u8 r, g, b; sub_8050030(unk48); - r5 = unk48->unk30 & 0xFFF; - r2 = unk48->unk30 >> 12; + r1 = unk48->unk30 & 0xFFF; + r3 = r1; + r5 = r3; + r2 = unk48->unk30 >> 12; if (r2 == 4) { unk48->unk30 &= 0xFFF; unk48->callback = gUnknown_080D8D6C[0].callback; unk48->unk34 = gUnknown_080D8D6C[0].data; unk48->unk2E = gUnknown_080D8D6C[0].unk8; - } else if (r2 == 3) { + return; + } + + if (r2 == 3) { // _0804E50C+0x4 gDispCnt &= ~DISPCNT_BG1_ON; + r6 = r3; for (c = 0; c < 16; c++) { - s32 r = ((sRGB_080D8E20[3][c][0] * r5) >> 12) & 0x1F; - s32 g = ((sRGB_080D8E20[3][c][1] * r5) >> 12) & 0x1F; - s32 b = ((sRGB_080D8E20[3][c][2] * r5) >> 12) & 0x1F; - - gObjPalette[8 * 16 + c] = RGB16_REV(r, g, b); - gBgPalette[8 * 16 + c] = RGB16_REV(r, g, b); + r = sRGB_080D8E20[3][c][0]; + r = ((r * r6) >> 12) & 0x1F; + g = sRGB_080D8E20[3][c][1]; + g = ((g * r6) >> 12) & 0x1F; + b = sRGB_080D8E20[3][c][2]; + b = ((b * r6) >> 12) & 0x1F; + + gObjPalette[c + 8 * 16] = RGB16_REV(r, g, b); + gBgPalette[c] = RGB16_REV(r, g, b); } gFlags |= FLAGS_UPDATE_SPRITE_PALETTES; + gFlags |= FLAGS_UPDATE_BACKGROUND_PALETTES; unk48->unk4C = 0; - } else if ((r2 == 2) && ((u32)r5 > 0xE00)) { - // __0804E5BC - u16 r6; + return; + } + if ((r2 == 2) && (r5 > 0xE00)) { gDispCnt |= DISPCNT_BG1_ON; - r6 = 0xFFF - r5; - for (i = 0; i < ARRAY_COUNT(sRGB_080D8E20) - 1; i++) { for (c = 0; c < ARRAY_COUNT(sRGB_080D8E20[0]); c++) { - s32 r = ((sRGB_080D8E20[i][c][0] * r6) >> 9) & 0x1F; - s32 g = ((sRGB_080D8E20[i][c][1] * r6) >> 9) & 0x1F; - s32 b = ((sRGB_080D8E20[i][c][2] * r6) >> 9) & 0x1F; - - gBgPalette[((7 + i) * 16) + c] = RGB16_REV(r, g, b); + r = sRGB_080D8E20[i][c][0]; + r = ((r * r6) >> 9) & 0x1F; + g = sRGB_080D8E20[i][c][1]; + g = ((g * r6) >> 9) & 0x1F; + b = sRGB_080D8E20[i][c][2]; + b = ((b * r6) >> 9) & 0x1F; + gBgPalette[0x70 + c + (i * 16)] = RGB16_REV(r, g, b); } } gFlags |= FLAGS_UPDATE_BACKGROUND_PALETTES; } } -END_NONMATCH void sub_804E66C(struct TA53_unk98 *unk98) { @@ -2409,10 +2424,14 @@ bool8 sub_8050030(struct TA53_unk48 *unk48) if (r2 != (((unk48->unk30 - unk48->unk2C) >> 12) & 7)) { for (i = 0; i < 5; i++) { - (r4++)[0] = r4[1]; - (r4++)[0] = r4[1]; - (r4++)[0] = r4[1]; - (r4++)[0] = (*ip++)[r3]; + r4[0] = r4[1]; + r4++; + r4[0] = r4[1]; + r4++; + r4[0] = r4[1]; + r4++; + r4[0] = (*ip++)[r3]; + r4++; } r4 = unk48->unk4; @@ -2474,10 +2493,14 @@ bool8 sub_8050104(struct TA53_unk1C *unk1C) if (r2 != (((u32)(unk1C->unk18 - unk1C->unk14) >> 12) & 7)) { for (i = 0; i < 2; i++) { - (r4++)[0] = r4[1]; - (r4++)[0] = r4[1]; - (r4++)[0] = r4[1]; - (r4++)[0] = (*ip++)[r3]; + r4[0] = r4[1]; + r4++; + r4[0] = r4[1]; + r4++; + r4[0] = r4[1]; + r4++; + r4[0] = (*ip++)[r3]; + r4++; } r4 = unk1C->unk4; diff --git a/src/game/interactables_2/egg_utopia/cannon.c b/src/game/interactables_2/egg_utopia/cannon.c index c78b1cd80..ec4cdb5d6 100644 --- a/src/game/interactables_2/egg_utopia/cannon.c +++ b/src/game/interactables_2/egg_utopia/cannon.c @@ -262,7 +262,11 @@ NONMATCH("asm/non_matching/game/interactables_2/egg_utopia/sub_807E66C.inc", boo s32 biggerX, biggerY, temp2, temp3; s32 r4; s16 playerX, playerY; +#ifndef NON_MATCHING register Sprite_Cannon *r3 asm("r3") = cannon; +#else + Sprite_Cannon *r3 = cannon; +#endif Sprite *s2 = &r3->sprite2; if (!PLAYER_IS_ALIVE) { return 0; diff --git a/src/game/math.c b/src/game/math.c index 0123f7224..0efe12bd7 100644 --- a/src/game/math.c +++ b/src/game/math.c @@ -3,8 +3,6 @@ #include "trig.h" -struct UNK_8085F1C_1 *sub_8085EC4(struct UNK_8085F1C *p1); - typedef struct { s16 unk0; s16 unk2; @@ -21,12 +19,6 @@ typedef struct { u32 unk1C; } UNK_8085D14; -// Only used in here -u32 gRngPrevValue = 0; -u32 gRngValue = 0; - -const u16 gUnknown_080E0290[] = { 0x0AAA, 0x02AA }; - typedef struct { void *unk0; void *start; @@ -34,7 +26,15 @@ typedef struct { void *unkC; } UNK_8085DEC; -bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target); +// Only used in here +u32 gRngPrevValue = 0; +u32 gRngValue = 0; + +struct UNK_8085F1C_1 *sub_8085EC4(struct UNK_8085F1C *p1); +static bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target); +void sub_8084B54(struct UNK_8085F1C_1 *, u16, u16, u16); + +const u16 gUnknown_080E0290[] = { 0x0AAA, 0x02AA }; #define RAND_CONST 0x37119371; @@ -47,8 +47,8 @@ END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_8083504.inc", void sub_8083504()) { } END_NONMATCH -// TODO: match this -NONMATCH("asm/non_matching/game/math/sub_80835E0.inc", void sub_80835E0(struct UNK_8085F1C *p2, s32 *b)) { } +// This is used in this file, but it's not used by the game +NONMATCH("asm/non_matching/game/math/unused_sub_80835E0.inc", void sub_80835E0(struct UNK_8085F1C *p2, s32 *b)) { } END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_80836BC.inc", void sub_80836BC()) { } @@ -72,8 +72,8 @@ END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_8083B10.inc", void sub_8083B10()) { } END_NONMATCH -// TODO: match this -NONMATCH("asm/non_matching/game/math/sub_8083B88.inc", +// This is used in this file, but it's not used by the game +NONMATCH("asm/non_matching/game/math/unused_sub_8083B88.inc", void sub_8083B88(struct UNK_8085F1C_1 *a, struct UNK_8085F1C_1 *b, struct UNK_8085F1C_1 *c)) { } @@ -109,8 +109,8 @@ END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_8084A24.inc", void sub_8084A24()) { } END_NONMATCH -// TODO: match this -NONMATCH("asm/non_matching/game/math/sub_8084B54.inc", void sub_8084B54(struct UNK_8085F1C_1 *a, u16 b, u16 c, u16 d)) { } +// This is used in this file, but it's not used by the game +NONMATCH("asm/non_matching/game/math/unused_sub_8084B54.inc", void sub_8084B54(struct UNK_8085F1C_1 *a, u16 b, u16 c, u16 d)) { } END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_8084C70.inc", void sub_8084C70()) { } @@ -125,48 +125,45 @@ END_NONMATCH NONMATCH("asm/non_matching/game/math/unused_sub_80851E0.inc", void sub_80851E0()) { } END_NONMATCH -NONMATCH("asm/non_matching/game/math/unused_sub_8085314.inc", void sub_8085314()) { } -END_NONMATCH - -// void sub_8085314(struct UNK_8085F1C_1 *p1, struct UNK_8085F1C_1 *p2) -// { -// s32 unk0 = p2->unk0 * 2; -// s32 unk2 = p2->unk2[0] * 2; -// s32 unk4 = p2->unk2[1] * 2; -// s32 temp0 = (p2->unk2[0] * unk2 * 0x40) >> 0x10; -// s32 temp1 = (p2->unk2[1] * unk4 * 0x40) >> 0x10; - -// s16 temp2, temp3, temp4, temp5, temp6; +NONMATCH("asm/non_matching/game/math/unused_sub_8085314.inc", void sub_8085314(struct UNK_8085F1C_1 *p1, struct UNK_8085F1C_1 *p2)) +{ + // Incomplete + s32 unk0 = p2->unk0 * 2; + s32 unk2 = p2->unk2[0] * 2; + s32 unk4 = p2->unk2[1] * 2; + s32 temp0 = (p2->unk2[0] * unk2 * 0x40) >> 0x10; + s32 temp1 = (p2->unk2[1] * unk4 * 0x40) >> 0x10; -// p1->unk14 = 0; -// p1->unk2[0] = 0x400 - (temp0 + temp1); + s16 temp2, temp3, temp4, temp5, temp6; -// temp2 = (p2->unk2[2] * unk4 * 0x40) >> 0x10; -// temp3 = (p2->unk0 * unk2 * 0x40) >> 0x10; + p1->unk14 = 0; + p1->unk2[0] = 0x400 - (temp0 + temp1); -// p1->unk2[1] = temp3 - temp2; + temp2 = (p2->unk2[2] * unk4 * 0x40) >> 0x10; + temp3 = (p2->unk0 * unk2 * 0x40) >> 0x10; -// temp4 = (p2->unk0 * unk4 * 0x40) >> 0x10; -// temp5 = (p2->unk2[2] * unk2 * 0x40) >> 0x10; + p1->unk2[1] = temp3 - temp2; -// p1->unk2[2] = temp4 + temp5; -// p1->unk2[3] = temp3 + temp2; + temp4 = (p2->unk0 * unk4 * 0x40) >> 0x10; + temp5 = (p2->unk2[2] * unk2 * 0x40) >> 0x10; -// temp3 = (p2->unk0 * unk0 * 0x40) >> 0x10; -// p1->unk2[4] = 0x400 - (temp1 + temp3); + p1->unk2[2] = temp4 + temp5; + p1->unk2[3] = temp3 + temp2; -// temp1 = (p2->unk2[2] * unk0 * 0x40) >> 0x10; -// temp6 = (p2->unk2[0] * unk4 * 0x40) >> 0x10; + temp3 = (p2->unk0 * unk0 * 0x40) >> 0x10; + p1->unk2[4] = 0x400 - (temp1 + temp3); -// p1->unk2[5] = temp6 - temp1; -// p1->unk2[6] = temp4 - temp5; -// p1->unk2[7] = temp6 + temp1; -// p1->unk2[8] = 0x400 - (temp3 + temp0); -// p1->unk1C = p1->unk14; -// p1->unk18 = p1->unk14; -// } + temp1 = (p2->unk2[2] * unk0 * 0x40) >> 0x10; + temp6 = (p2->unk2[0] * unk4 * 0x40) >> 0x10; -void sub_8084B54(struct UNK_8085F1C_1 *, u16, u16, u16); + p1->unk2[5] = temp6 - temp1; + p1->unk2[6] = temp4 - temp5; + p1->unk2[7] = temp6 + temp1; + p1->unk2[8] = 0x400 - (temp3 + temp0); + p1->unk1C = p1->unk14; + p1->unk18 = p1->unk14; +} +END_NONMATCH struct UNK_8085F1C_1 *sub_80853F8(struct UNK_8085F1C *p1) { @@ -284,7 +281,7 @@ u32 sub_80855C0(s32 a, s32 b, s32 c, u8 d) return a - (e >> d); } -u16 sub_80855F8(u16 r7, u16 r2, u8 r6, s16 r5, u8 r4) +UNUSED u16 sub_80855F8(u16 r7, u16 r2, u8 r6, s16 r5, u8 r4) { u16 r2_2 = r2; u32 r3 = (1 << r6); @@ -322,19 +319,19 @@ s32 sub_8085698(s32 a, s32 b, s32 c, u8 d, u8 e) return b; } -s32 sub_80856DC(s32 a, s32 b, s32 c) { return (a * 7 + b * 6 - c) / 12; } +UNUSED s32 sub_80856DC(s32 a, s32 b, s32 c) { return (a * 7 + b * 6 - c) / 12; } -s32 sub_80856F8(s32 a, s32 b, s32 c) { return ((b * 6 - a) + c * 7) / 12; } +UNUSED s32 sub_80856F8(s32 a, s32 b, s32 c) { return ((b * 6 - a) + c * 7) / 12; } -s32 sub_8085714(s32 a, s32 b, s32 c) { return ((a + b * 8) - c) >> 3; } +UNUSED s32 sub_8085714(s32 a, s32 b, s32 c) { return ((a + b * 8) - c) >> 3; } -s32 sub_8085720(s32 a, s32 b, s32 c) { return ((b * 8 - a) + c) >> 3; } +UNUSED s32 sub_8085720(s32 a, s32 b, s32 c) { return ((b * 8 - a) + c) >> 3; } -s32 sub_808572C(s32 a, s32 b, s32 c, s32 d, u32 e, u8 f) { return ((s64)(b - a) * (s64)((1 << f) - c)) >> f; } +UNUSED s32 sub_808572C(s32 a, s32 b, s32 c, s32 d, u32 e, u8 f) { return ((s64)(b - a) * (s64)((1 << f) - c)) >> f; } -s32 sub_8085758(s32 a, s32 b) { return b - a; } +UNUSED s32 sub_8085758(s32 a, s32 b) { return b - a; } -s32 sub_808575C(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) +UNUSED s32 sub_808575C(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) { a = c - a; a += a >> 1; @@ -342,10 +339,10 @@ s32 sub_808575C(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) return ((s64)(a) * ((1 << g) - d)) >> g; } -s32 sub_8085798(s32 a, s32 b, s32 c) { return ((c - a) + ((c - a) >> 1)) - (b >> 1); } +UNUSED s32 sub_8085798(s32 a, s32 b, s32 c) { return ((c - a) + ((c - a) >> 1)) - (b >> 1); } // same as sub_808575C -s32 sub_80857A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) +UNUSED s32 sub_80857A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) { a = c - a; a += a >> 1; @@ -353,9 +350,9 @@ s32 sub_80857A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) return ((s64)(a) * ((1 << g) - d)) >> g; } -s32 sub_80857E0(s32 a, s32 b, s32 c) { return ((c - a) + ((c - a) >> 1)) - (b >> 1); } +UNUSED s32 sub_80857E0(s32 a, s32 b, s32 c) { return ((c - a) + ((c - a) >> 1)) - (b >> 1); } -s32 sub_80857EC(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) +UNUSED s32 sub_80857EC(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) { s32 h = ((s64)(b - a) * (s64)(f + (1 << g))) >> g; s64 i = ((s64)(c - b) * (s64)((1 << g) - f)) >> g; @@ -364,7 +361,7 @@ s32 sub_80857EC(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) return ((s64)(j + h64) * (s64)((1 << g) - d)) >> g; } -s32 sub_80858A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) +UNUSED s32 sub_80858A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) { s32 h = ((s64)(b - a) * (s64)(f + (1 << g))) >> g; s64 i = ((s64)(c - b) * (s64)((1 << g) - f)) >> g; @@ -373,7 +370,7 @@ s32 sub_80858A4(s32 a, s32 b, s32 c, s32 d, s32 e, s32 f, u8 g) return ((s64)(j + h64) * (s64)((1 << g) - d)) >> g; } -s32 sub_808595C(s32 a, s32 b, s32 c) +UNUSED s32 sub_808595C(s32 a, s32 b, s32 c) { s32 e = (b - a); s32 f = (c - b); @@ -439,7 +436,7 @@ s16 sub_80B1560(s16 *param0, u16 param1) } #endif -void sub_8085A88(UNK_8085D14 *p1) +UNUSED void sub_8085A88(UNK_8085D14 *p1) { p1->unk0 = 0; p1->unk2 = 0x400; @@ -449,7 +446,7 @@ void sub_8085A88(UNK_8085D14 *p1) *(u32 *)&p1->unkC = 0; } -void sub_8085A9C(UNK_8085D14 *p1, u8 p2) +UNUSED void sub_8085A9C(UNK_8085D14 *p1, u8 p2) { u16 dist = Sqrt(SQUARE(p1->unk0) + SQUARE(p1->unk2) + SQUARE(p1->unk4)); u32 thing = (p2 << 1); @@ -459,13 +456,13 @@ void sub_8085A9C(UNK_8085D14 *p1, u8 p2) p1->unk4 = (div * p1->unk4) >> p2; } -s32 sub_8085B00(UNK_8085D14 *p1, UNK_8085D14 *p2, u8 p4) +UNUSED s32 sub_8085B00(UNK_8085D14 *p1, UNK_8085D14 *p2, u8 p4) { u32 something = p4; return ((p1->unk0 * p2->unk0) + (p1->unk2 * p2->unk2) + (p1->unk4 * p2->unk4)) >> p4; } -void sub_8085B34(UNK_8085D14 *p1, UNK_8085D14 *p2, UNK_8085D14 *p3, u8 p4) +UNUSED void sub_8085B34(UNK_8085D14 *p1, UNK_8085D14 *p2, UNK_8085D14 *p3, u8 p4) { u32 something = p4; p3->unk0 = ((p1->unk2 * p2->unk4) - (p1->unk4 * p2->unk2)) >> something; @@ -473,7 +470,7 @@ void sub_8085B34(UNK_8085D14 *p1, UNK_8085D14 *p2, UNK_8085D14 *p3, u8 p4) p3->unk4 = ((p1->unk0 * p2->unk2) - (p1->unk2 * p2->unk0)) >> something; } -void sub_8085B90(UNK_8085D14 *p1) +UNUSED void sub_8085B90(UNK_8085D14 *p1) { p1->unk4 = 0; p1->unk2 = 0; @@ -482,14 +479,14 @@ void sub_8085B90(UNK_8085D14 *p1) p1->unk6 = 0x400; } -void sub_8085BA0(UNK_8085D14 *p1) +UNUSED void sub_8085BA0(UNK_8085D14 *p1) { p1->unk0 = -p1->unk0; p1->unk2 = -p1->unk2; p1->unk4 = -p1->unk4; } -void sub_8085BB4(UNK_8085D14 *p1, u16 rad) +UNUSED void sub_8085BB4(UNK_8085D14 *p1, u16 rad) { s32 sin; rad = rad >> 1; @@ -500,7 +497,7 @@ void sub_8085BB4(UNK_8085D14 *p1, u16 rad) p1->unk6 = COS(rad) >> 4; } -void sub_8085BEC(UNK_8085D14 *p1, u16 rad) +UNUSED void sub_8085BEC(UNK_8085D14 *p1, u16 rad) { s32 sin; rad = rad >> 1; @@ -511,7 +508,7 @@ void sub_8085BEC(UNK_8085D14 *p1, u16 rad) p1->unk6 = COS(rad) >> 4; } -void sub_8085C24(UNK_8085D14 *p1, u16 rad) +UNUSED void sub_8085C24(UNK_8085D14 *p1, u16 rad) { s32 sin; rad = rad >> 1; @@ -522,7 +519,7 @@ void sub_8085C24(UNK_8085D14 *p1, u16 rad) p1->unk6 = COS(rad) >> 4; } -void sub_8085C5C(UNK_8085D14 *p1, u16 rad, UNK_8085D14 *p3) +UNUSED void sub_8085C5C(UNK_8085D14 *p1, u16 rad, UNK_8085D14 *p3) { s32 sin; rad = rad >> 1; @@ -533,7 +530,7 @@ void sub_8085C5C(UNK_8085D14 *p1, u16 rad, UNK_8085D14 *p3) p1->unk6 = COS(rad) >> 4; } -void sub_8085CA8(UNK_8085D14 *p1) +UNUSED void sub_8085CA8(UNK_8085D14 *p1) { u8 i; UNK_8085D14 *curr = p1; @@ -550,7 +547,7 @@ void sub_8085CA8(UNK_8085D14 *p1) } } -void sub_8085CC0(UNK_8085D14 *p1) +UNUSED void sub_8085CC0(UNK_8085D14 *p1) { u8 i; UNK_8085D14 *curr = p1; @@ -570,7 +567,7 @@ void sub_8085CC0(UNK_8085D14 *p1) curr->unk2 = 0x400; } -void sub_8085CE4(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) +UNUSED void sub_8085CE4(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) { u8 i; UNK_8085D14 *curr = p1; @@ -594,7 +591,7 @@ void sub_8085CE4(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) p1->unk1C = p4; } -void sub_8085D14(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) +UNUSED void sub_8085D14(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) { u8 i; UNK_8085D14 *curr = p1; @@ -618,7 +615,7 @@ void sub_8085D14(UNK_8085D14 *p1, u32 p2, u32 p3, u32 p4) p1->unk12 = p4; } -void sub_8085D44(UNK_8085DEC *thing) +UNUSED void sub_8085D44(UNK_8085DEC *thing) { thing->unk0 = NULL; thing->start = NULL; @@ -626,7 +623,7 @@ void sub_8085D44(UNK_8085DEC *thing) thing->unkC = NULL; } -UNK_8085DEC *sub_8085D50(UNK_8085DEC *thing) +UNUSED UNK_8085DEC *sub_8085D50(UNK_8085DEC *thing) { while (thing->unk0 != NULL) { thing = thing->unk0; @@ -635,14 +632,14 @@ UNK_8085DEC *sub_8085D50(UNK_8085DEC *thing) return thing; } -void sub_8085D64(UNK_8085DEC *thing) +UNUSED void sub_8085D64(UNK_8085DEC *thing) { if (thing->unk0 != NULL) { sub_8085D98(thing->unk0, thing); } } -void sub_8085D78(UNK_8085DEC *thing, UNK_8085DEC *target) +UNUSED void sub_8085D78(UNK_8085DEC *thing, UNK_8085DEC *target) { if (target->unk0 != NULL) { sub_8085D98(target->unk0, target); @@ -652,7 +649,7 @@ void sub_8085D78(UNK_8085DEC *thing, UNK_8085DEC *target) thing->start = target; } -bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target) +static bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target) { UNK_8085DEC *curr = thing->start; UNK_8085DEC *prev = NULL; @@ -676,7 +673,7 @@ bool8 sub_8085D98(UNK_8085DEC *thing, UNK_8085DEC *target) return FALSE; } -u16 sub_8085DD0(UNK_8085DEC *thing) +UNUSED u16 sub_8085DD0(UNK_8085DEC *thing) { u16 num = 0; thing = thing->start; @@ -688,7 +685,7 @@ u16 sub_8085DD0(UNK_8085DEC *thing) return num; } -UNK_8085DEC *sub_8085DEC(UNK_8085DEC *thing, u16 num) +UNUSED UNK_8085DEC *sub_8085DEC(UNK_8085DEC *thing, u16 num) { thing = thing->start; while (thing != NULL && num != 0) { @@ -705,7 +702,6 @@ UNUSED void sub_8085E24(struct UNK_8085F1C *p1, struct UNK_8085F1C *p2) { memcpy UNUSED void sub_8085E38(struct UNK_8085F1C *p1, struct UNK_8085F1C *p2) { - memcpy(p2, &p1->unk10, 0x10); while (p1 = p1->unk0, p1 != NULL) { @@ -713,7 +709,7 @@ UNUSED void sub_8085E38(struct UNK_8085F1C *p1, struct UNK_8085F1C *p2) } } -void sub_8085E64(struct UNK_8085F1C *p1) +UNUSED void sub_8085E64(struct UNK_8085F1C *p1) { u8 i; struct UNK_8085F1C_1 *curr; @@ -738,7 +734,7 @@ void sub_8085E64(struct UNK_8085F1C *p1) p1->unkC |= 1; } -void sub_8085E94(struct UNK_8085F1C *p1) +UNUSED void sub_8085E94(struct UNK_8085F1C *p1) { p1->unk10 = 1; p1->unk58 = 0; @@ -752,7 +748,7 @@ void sub_8085E94(struct UNK_8085F1C *p1) p1->unk5C = 0x400; } -struct UNK_8085F1C_1 *sub_8085EC4(struct UNK_8085F1C *p1) +UNUSED struct UNK_8085F1C_1 *sub_8085EC4(struct UNK_8085F1C *p1) { struct UNK_8085F1C_1 *sub = NULL; @@ -776,7 +772,7 @@ struct UNK_8085F1C_1 *sub_8085EC4(struct UNK_8085F1C *p1) return &p1->unk14; } -struct UNK_8085F1C_1 *sub_8085F1C(struct UNK_8085F1C *p1) +UNUSED struct UNK_8085F1C_1 *sub_8085F1C(struct UNK_8085F1C *p1) { struct UNK_8085F1C_1 *sub = NULL; @@ -802,7 +798,7 @@ struct UNK_8085F1C_1 *sub_8085F1C(struct UNK_8085F1C *p1) return &p1->unk14; } -void sub_8085F84(void) +UNUSED void sub_8085F84(void) { // unused } diff --git a/src/game/player_callbacks.c b/src/game/player_callbacks.c index 7cff734da..24234a736 100644 --- a/src/game/player_callbacks.c +++ b/src/game/player_callbacks.c @@ -236,7 +236,7 @@ void Player_SonicAmy_WindupSkidAttack(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_SonicAmy_SkidAttack(Player *p) @@ -265,7 +265,7 @@ void Player_SonicAmy_SkidAttack(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (!(p->moveState & MOVESTATE_IN_AIR)) { sub_8029FA4(p); @@ -507,7 +507,7 @@ void Player_80123D0(Player *p) PLAYERFN_SET(Player_TouchGround); } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_SonicAmy_WindupStopNSlam(Player *p) @@ -543,7 +543,7 @@ void Player_SonicAmy_StopNSlam_AfterGroundCollision(Player *p) void Player_SonicAmy_StopNSlam_FallAfterCollision(Player *p) { - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (!(p->moveState & MOVESTATE_IN_AIR)) { p->transition = PLTRANS_TOUCH_GROUND; @@ -564,7 +564,7 @@ void Player_Sonic_HomingAttack(Player *p) p->moveState &= ~MOVESTATE_BOOST_EFFECT_ON; } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (!(p->moveState & MOVESTATE_IN_AIR)) { // Hit ground instead of targeted enemy @@ -719,7 +719,7 @@ void Player_Cream_ChaoAttack(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Cream_InitStepAttack(Player *p) @@ -778,7 +778,7 @@ void Player_Cream_StepAttack(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } // Mid-Air: Down-B @@ -790,7 +790,7 @@ void Player_Cream_ChaoRollingAttack(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (!(p->moveState & MOVESTATE_IN_AIR)) { p->transition = PLTRANS_TOUCH_GROUND; @@ -799,7 +799,7 @@ void Player_Cream_ChaoRollingAttack(Player *p) void Player_Cream_WindupMidAirChaoAttack(Player *p) { - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (!(p->moveState & MOVESTATE_IN_AIR)) { p->transition = PLTRANS_TOUCH_GROUND; @@ -1005,7 +1005,7 @@ void Player_Tails_TailSwipe(Player *p) PLAYERFN_SET(Player_TouchGround); } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } /* Character: Knuckles */ @@ -1103,7 +1103,7 @@ void Player_Knuckles_PunchLeft(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Knuckles_PunchRight(Player *p) @@ -1130,7 +1130,7 @@ void Player_Knuckles_PunchRight(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Knuckles_InitSpiralAttack(Player *p) @@ -1178,7 +1178,7 @@ void Player_Knuckles_SpiralAttack(Player *p) PLAYERFN_SET(Player_8013B6C); } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Knuckles_Glide_UpdateFrames(Player *p) @@ -1816,7 +1816,7 @@ void Player_8013B6C(Player *p) } } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Knuckles_Glide(Player *p) @@ -1840,7 +1840,7 @@ void Player_Knuckles_GlideSoftLanding(Player *p) p->transition = PLTRANS_TOUCH_GROUND; } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } void Player_Knuckles_GlideHardLanding(Player *p) @@ -1990,7 +1990,7 @@ void Player_Knuckles_DrillClaw(Player *p) void Player_8013E34(Player *p) { - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); p->speedGroundX = 0; p->speedAirX = 0; @@ -2090,5 +2090,5 @@ void Player_Amy_HammerAttack(Player *p) PLAYERFN_SET(Player_TouchGround); } - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); } diff --git a/src/game/stage/intro.c b/src/game/stage/intro.c index b69ad9777..31ebe1898 100644 --- a/src/game/stage/intro.c +++ b/src/game/stage/intro.c @@ -165,23 +165,115 @@ static const u8 sGettingReadyAnimationDuration[NUM_CHARACTERS] = { [CHARACTER_SONIC] = 40, [CHARACTER_CREAM] = 55, [CHARACTER_TAILS] = 52, [CHARACTER_KNUCKLES] = 40, [CHARACTER_AMY] = 40 }; // Each byte represents one RGB channel (0-31) -static const u8 gUnknown_080D6FF5[][3] = { - { 0x00, 0x17, 0x06 }, { 0x16, 0x16, 0x16 }, { 0x00, 0x04, 0x13 }, { 0x00, 0x08, 0x1D }, { 0x00, 0x00, 0x0C }, { 0x00, 0x13, 0x00 }, - { 0x1F, 0x1F, 0x13 }, { 0x1F, 0x1B, 0x00 }, { 0x13, 0x0A, 0x02 }, { 0x1F, 0x15, 0x0A }, { 0x15, 0x00, 0x00 }, { 0x1F, 0x04, 0x04 }, - { 0x04, 0x04, 0x04 }, { 0x1F, 0x1F, 0x1F }, { 0x0E, 0x0E, 0x0E }, { 0x00, 0x13, 0x1F }, { 0x00, 0x19, 0x14 }, { 0x19, 0x19, 0x19 }, - { 0x1F, 0x0B, 0x00 }, { 0x1F, 0x12, 0x00 }, { 0x19, 0x05, 0x00 }, { 0x1C, 0x0B, 0x00 }, { 0x13, 0x00, 0x00 }, { 0x1F, 0x1C, 0x17 }, - { 0x1D, 0x18, 0x10 }, { 0x13, 0x0F, 0x08 }, { 0x1F, 0x1E, 0x00 }, { 0x08, 0x11, 0x1F }, { 0x02, 0x02, 0x02 }, { 0x1F, 0x1F, 0x1F }, - { 0x0E, 0x0E, 0x0E }, { 0x1F, 0x00, 0x1F }, { 0x00, 0x17, 0x06 }, { 0x1F, 0x00, 0x1F }, { 0x1D, 0x11, 0x04 }, { 0x1F, 0x17, 0x04 }, - { 0x17, 0x0A, 0x02 }, { 0x15, 0x19, 0x1B }, { 0x00, 0x13, 0x1F }, { 0x04, 0x08, 0x1F }, { 0x13, 0x13, 0x13 }, { 0x0E, 0x0E, 0x0E }, - { 0x15, 0x00, 0x00 }, { 0x1F, 0x04, 0x04 }, { 0x02, 0x02, 0x02 }, { 0x1F, 0x1F, 0x1F }, { 0x1F, 0x00, 0x1F }, { 0x1F, 0x00, 0x1F }, - { 0x00, 0x16, 0x14 }, { 0x16, 0x16, 0x16 }, { 0x17, 0x00, 0x00 }, { 0x1F, 0x04, 0x00 }, { 0x0E, 0x00, 0x00 }, { 0x04, 0x08, 0x1F }, - { 0x1F, 0x1F, 0x13 }, { 0x1F, 0x1B, 0x00 }, { 0x13, 0x0A, 0x00 }, { 0x1F, 0x15, 0x0A }, { 0x00, 0x15, 0x02 }, { 0x0E, 0x1F, 0x00 }, - { 0x04, 0x04, 0x04 }, { 0x1F, 0x1F, 0x1F }, { 0x0E, 0x0E, 0x0E }, { 0x1F, 0x13, 0x00 }, { 0x00, 0x17, 0x06 }, { 0x15, 0x19, 0x1B }, - { 0x1D, 0x08, 0x13 }, { 0x1F, 0x13, 0x17 }, { 0x17, 0x04, 0x0A }, { 0x00, 0x15, 0x00 }, { 0x0E, 0x0E, 0x0E }, { 0x13, 0x13, 0x13 }, - { 0x13, 0x0A, 0x00 }, { 0x1F, 0x15, 0x0A }, { 0x15, 0x00, 0x00 }, { 0x1F, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x1F, 0x1F, 0x1F }, - { 0x1F, 0x1F, 0x13 }, { 0x1F, 0x1F, 0x00 }, { 0x00, 0x12, 0x0B }, { 0x04, 0x06, 0x0A }, { 0x00, 0x1F, 0x00 }, { 0x1F, 0x1F, 0x1F }, - { 0x14, 0x1F, 0x1F }, { 0x10, 0x1C, 0x1E }, { 0x0C, 0x18, 0x19 }, { 0x09, 0x14, 0x15 }, { 0x00, 0x0E, 0x10 }, { 0x00, 0x1F, 0x00 }, - { 0x1F, 0x16, 0x18 }, { 0x1F, 0x0A, 0x10 }, { 0x1F, 0x1E, 0x00 }, { 0x19, 0x18, 0x00 }, { 0x13, 0x0A, 0x00 }, { 0x1F, 0x00, 0x00 }, +static const u8 gUnknown_080D6FF5[NUM_CHARACTERS + 1][16][3] = { + { + { 0x00, 0x17, 0x06 }, + { 0x16, 0x16, 0x16 }, + { 0x00, 0x04, 0x13 }, + { 0x00, 0x08, 0x1D }, + { 0x00, 0x00, 0x0C }, + { 0x00, 0x13, 0x00 }, + { 0x1F, 0x1F, 0x13 }, + { 0x1F, 0x1B, 0x00 }, + { 0x13, 0x0A, 0x02 }, + { 0x1F, 0x15, 0x0A }, + { 0x15, 0x00, 0x00 }, + { 0x1F, 0x04, 0x04 }, + { 0x04, 0x04, 0x04 }, + { 0x1F, 0x1F, 0x1F }, + { 0x0E, 0x0E, 0x0E }, + { 0x00, 0x13, 0x1F }, + }, + { + { 0x00, 0x19, 0x14 }, + { 0x19, 0x19, 0x19 }, + { 0x1F, 0x0B, 0x00 }, + { 0x1F, 0x12, 0x00 }, + { 0x19, 0x05, 0x00 }, + { 0x1C, 0x0B, 0x00 }, + { 0x13, 0x00, 0x00 }, + { 0x1F, 0x1C, 0x17 }, + { 0x1D, 0x18, 0x10 }, + { 0x13, 0x0F, 0x08 }, + { 0x1F, 0x1E, 0x00 }, + { 0x08, 0x11, 0x1F }, + { 0x02, 0x02, 0x02 }, + { 0x1F, 0x1F, 0x1F }, + { 0x0E, 0x0E, 0x0E }, + { 0x1F, 0x00, 0x1F }, + }, + { + { 0x00, 0x17, 0x06 }, + { 0x1F, 0x00, 0x1F }, + { 0x1D, 0x11, 0x04 }, + { 0x1F, 0x17, 0x04 }, + { 0x17, 0x0A, 0x02 }, + { 0x15, 0x19, 0x1B }, + { 0x00, 0x13, 0x1F }, + { 0x04, 0x08, 0x1F }, + { 0x13, 0x13, 0x13 }, + { 0x0E, 0x0E, 0x0E }, + { 0x15, 0x00, 0x00 }, + { 0x1F, 0x04, 0x04 }, + { 0x02, 0x02, 0x02 }, + { 0x1F, 0x1F, 0x1F }, + { 0x1F, 0x00, 0x1F }, + { 0x1F, 0x00, 0x1F }, + }, + { + { 0x00, 0x16, 0x14 }, + { 0x16, 0x16, 0x16 }, + { 0x17, 0x00, 0x00 }, + { 0x1F, 0x04, 0x00 }, + { 0x0E, 0x00, 0x00 }, + { 0x04, 0x08, 0x1F }, + { 0x1F, 0x1F, 0x13 }, + { 0x1F, 0x1B, 0x00 }, + { 0x13, 0x0A, 0x00 }, + { 0x1F, 0x15, 0x0A }, + { 0x00, 0x15, 0x02 }, + { 0x0E, 0x1F, 0x00 }, + { 0x04, 0x04, 0x04 }, + { 0x1F, 0x1F, 0x1F }, + { 0x0E, 0x0E, 0x0E }, + { 0x1F, 0x13, 0x00 }, + }, + { + { 0x00, 0x17, 0x06 }, + { 0x15, 0x19, 0x1B }, + { 0x1D, 0x08, 0x13 }, + { 0x1F, 0x13, 0x17 }, + { 0x17, 0x04, 0x0A }, + { 0x00, 0x15, 0x00 }, + { 0x0E, 0x0E, 0x0E }, + { 0x13, 0x13, 0x13 }, + { 0x13, 0x0A, 0x00 }, + { 0x1F, 0x15, 0x0A }, + { 0x15, 0x00, 0x00 }, + { 0x1F, 0x00, 0x00 }, + { 0x00, 0x00, 0x00 }, + { 0x1F, 0x1F, 0x1F }, + { 0x1F, 0x1F, 0x13 }, + { 0x1F, 0x1F, 0x00 }, + }, + { + { 0x00, 0x12, 0x0B }, + { 0x04, 0x06, 0x0A }, + { 0x00, 0x1F, 0x00 }, + { 0x1F, 0x1F, 0x1F }, + { 0x14, 0x1F, 0x1F }, + { 0x10, 0x1C, 0x1E }, + { 0x0C, 0x18, 0x19 }, + { 0x09, 0x14, 0x15 }, + { 0x00, 0x0E, 0x10 }, + { 0x00, 0x1F, 0x00 }, + { 0x1F, 0x16, 0x18 }, + { 0x1F, 0x0A, 0x10 }, + { 0x1F, 0x1E, 0x00 }, + { 0x19, 0x18, 0x00 }, + { 0x13, 0x0A, 0x00 }, + { 0x1F, 0x00, 0x00 }, + }, }; const u16 sZoneLoadingCharacterColors[NUM_CHARACTERS] = { @@ -227,9 +319,9 @@ typedef struct { } IntroActLetters; /* size: 0xC4 */ static void Task_IntroControllerMain(void); -void Task_802F9F8(void); +static void Task_802F9F8(void); static void Task_IntroColorAnimation(void); -void Task_IntroZoneNameAndIconAnimations(void); +static void Task_IntroZoneNameAndIconAnimations(void); static void Task_IntroActLettersAnimations(void); static void Task_UpdateStageLoadingScreen(void); static void TaskDestructor_IntroController(struct Task *); @@ -256,7 +348,7 @@ struct Task *SetupStageIntro(void) gStageFlags |= STAGE_FLAG__ACT_START; gStageFlags |= STAGE_FLAG__100; - // These are null when super sonic + // NOTE: null when Super Sonic #ifdef BUG_FIX if (gPlayer.spriteInfoBody) #endif @@ -547,13 +639,26 @@ static void Task_IntroControllerMain(void) p->anim = characterAnimsGettingReady[gSelectedCharacter].anim; p->variant = characterAnimsGettingReady[gSelectedCharacter].variant; p->unk6C = TRUE; - p->spriteInfoBody->s.frameFlags |= MOVESTATE_40000; - p->spriteInfoLimbs->s.frameFlags |= MOVESTATE_40000; - if (IS_MULTI_PLAYER) { - p->spriteInfoBody->s.palId = SIO_MULTI_CNT->id; - } else { - p->spriteInfoBody->s.palId = 0; + // NOTE: null when Super Sonic +#ifdef BUG_FIX + if (p->spriteInfoBody != NULL) +#endif + { + p->spriteInfoBody->s.frameFlags |= MOVESTATE_40000; + +#ifdef BUG_FIX + if (p->spriteInfoLimbs != NULL) +#endif + { + p->spriteInfoLimbs->s.frameFlags |= MOVESTATE_40000; + } + + if (IS_MULTI_PLAYER) { + p->spriteInfoBody->s.palId = SIO_MULTI_CNT->id; + } else { + p->spriteInfoBody->s.palId = 0; + } } } @@ -595,14 +700,14 @@ static void Task_IntroControllerMain(void) } } -// (85.25%) https://decomp.me/scratch/zMdSN -NONMATCH("asm/non_matching/game/stage/intro/Task_802F9F8.inc", void Task_802F9F8(void)) +static void Task_802F9F8(void) { IntroBackgrounds *introBackgrounds = TASK_DATA(gCurTask); IntroController *controller = introBackgrounds->controller; // sp00 ScreenFade *fade = &introBackgrounds->fade; s32 frameCounter = controller->counter; u8 i; + u8 r, g, b; gDispCnt &= ~(DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON); @@ -622,51 +727,47 @@ NONMATCH("asm/non_matching/game/stage/intro/Task_802F9F8.inc", void Task_802F9F8 if (IS_SINGLE_PLAYER) { // _0802FA4C+8 for (i = 0; i < 16; i++) { - const u8 *colors = &gUnknown_080D6FF5[0][0]; - s32 index = (gSelectedCharacter * 16) + i; - u8 r = (gUnknown_080D6FF5[index][0] * frameCounter) / 16u; - u8 g = ((gUnknown_080D6FF5[index][1] * frameCounter) / 16u); - u8 b = ((gUnknown_080D6FF5[index][2] * frameCounter) / 16u); + r = gUnknown_080D6FF5[gSelectedCharacter][i][0]; + r = (r * frameCounter) / 16u; + g = ((gUnknown_080D6FF5[gSelectedCharacter][i][1] * frameCounter) / 16u); + b = ((gUnknown_080D6FF5[gSelectedCharacter][i][2] * frameCounter) / 16u); - gObjPalette[i] = RGB16(r, g, b); + gObjPalette[i] = RGB16_REV(r, g, b); if (gCheese != NULL) { - r = (gUnknown_080D6FF5[index + 80][0] * frameCounter) / 16u; - g = ((gUnknown_080D6FF5[index + 80][1] * frameCounter) / 16u); - b = ((gUnknown_080D6FF5[index + 80][2] * frameCounter) / 16u); + r = gUnknown_080D6FF5[5][i][0]; + r = (r * frameCounter) / 16u; + g = ((gUnknown_080D6FF5[5][i][1] * frameCounter) / 16u); + b = ((gUnknown_080D6FF5[5][i][2] * frameCounter) / 16u); - gObjPalette[i + 0xE0] = RGB16(r, g, b); + gObjPalette[14 * 16 + i] = RGB16_REV(r, g, b); } } } else { // _0802FB28 u8 sid; + for (sid = 0; sid < MULTI_SIO_PLAYERS_MAX; sid++) { - if ((gMultiplayerConnections >> sid) & 0x1) { + if (GetBit(gMultiplayerConnections, sid)) { for (i = 0; i < 16; i++) { - s32 index = (sid * 48) + i * 3; - u8 r = (gUnknown_080D6FF5[index][0] * frameCounter) / 16u; - u8 g = ((gUnknown_080D6FF5[index][1] * frameCounter) / 16u); - u8 b = ((gUnknown_080D6FF5[index][2] * frameCounter) / 16u); + r = gUnknown_080D6FF5[(gMultiplayerCharacters)[sid]][i][0]; + r = (r * frameCounter) / 16u; + g = ((gUnknown_080D6FF5[(gMultiplayerCharacters)[sid]][i][1] * frameCounter) / 16u); + b = ((gUnknown_080D6FF5[(gMultiplayerCharacters)[sid]][i][2] * frameCounter) / 16u); - gObjPalette[i] = RGB16(r, g, b); + gObjPalette[sid * 16 + i] = RGB16_REV(r, g, b); } } } - } - if (gCheese != NULL) { - for (i = 0; i < 16; i++) { - s32 index; - u8 r, b, g; - { - const u8 *colors = &gUnknown_080D6FF5[0][0]; - index = (0 * 48) + i; - colors = &gUnknown_080D6FF5[index + 80][0]; - r = (colors[0] * frameCounter) / 16u; - g = ((gUnknown_080D6FF5[index + 80][1] * frameCounter) / 16u); - b = ((gUnknown_080D6FF5[index + 80][2] * frameCounter) / 16u); - - gObjPalette[i + 0xE0] = RGB16(r, g, b); + + if (gCheese != NULL) { + for (i = 0; i < 16; i++) { + r = gUnknown_080D6FF5[5][i][0]; + r = (r * frameCounter) / 16u; + g = ((gUnknown_080D6FF5[5][i][1] * frameCounter) / 16u); + b = ((gUnknown_080D6FF5[5][i][2] * frameCounter) / 16u); + + gObjPalette[14 * 16 + i] = RGB16_REV(r, g, b); } } } @@ -716,8 +817,7 @@ NONMATCH("asm/non_matching/game/stage/intro/Task_802F9F8.inc", void Task_802F9F8 gBldRegs.bldCnt = (BLDCNT_TGT2_OBJ | BLDCNT_TGT2_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2); - gBldRegs.bldAlpha = BLDALPHA_BLEND(4, 4); - // Bug: this shouldn't be set any large than 31, possibly copy and paste from the above line? + gBldRegs.bldAlpha = 1028; #ifdef BUG_FIX gBldRegs.bldY = SCREEN_FADE_BLEND_MAX; #else @@ -726,10 +826,8 @@ NONMATCH("asm/non_matching/game/stage/intro/Task_802F9F8.inc", void Task_802F9F8 } TaskDestroy(gCurTask); - return; } } -END_NONMATCH static void Task_IntroColorAnimation(void) { @@ -872,21 +970,23 @@ static void StageIntroUpdateIcons(void) DisplaySprite(s); } -// (88.38%) https://decomp.me/scratch/HozxE -NONMATCH("asm/non_matching/game/stage/intro/Task_IntroZoneNameAndIconAnimations.inc", void Task_IntroZoneNameAndIconAnimations(void)) +static inline int InlineIconsCalc(u8 arg0, int arg1) { return (arg0 * arg1) - 22; } + +static void Task_IntroZoneNameAndIconAnimations(void) { IntroUI *introUI = TASK_DATA(gCurTask); u32 counter = introUI->controller->counter; Sprite *s; - u8 sp08; - s32 sl; u32 i; + u8 counterByte; if (counter - 10 > 124) { if (counter >= 200) { TaskDestroy(gCurTask); return; - } else if (counter >= 150) { + } + + if (counter >= 150) { // _0802FFD2 s = &introUI->sprCharacterLogo; @@ -906,134 +1006,144 @@ NONMATCH("asm/non_matching/game/stage/intro/Task_IntroZoneNameAndIconAnimations. UpdateSpriteAnimation(s); DisplaySprite(s); } + return; + } + + // _0803004E + counter -= 9; + + s = &introUI->sprCharacterLogo; + + if (counter <= 12) { + s->x = 254 - (((counter * 75) << 6) >> 8); + s->y = ((DISPLAY_HEIGHT / 2) + 41) - (((counter * 123) << 3) >> 8); + + } else if (counter <= 100) { + // _08030078 + s->x = 254 - (((13 * 75) << 6) >> 8) + 13; + s->y = ((DISPLAY_HEIGHT / 2) + 41) - (((13 * 123) << 3) >> 8) + 2; } else { - // _0803004E - counter -= 9; + // _08030086 + u32 innerCount = counter - (100 - 12); + s->x = 254 - (((innerCount * 75) << 6) >> 8); + s->y = ((DISPLAY_HEIGHT / 2) + 41) - (((innerCount * 123) << 3) >> 8); + } - s = &introUI->sprCharacterLogo; + // _080300AE + for (i = 0; i < ARRAY_COUNT(introUI->sprZoneName); i++) { + s = &introUI->sprZoneName[i]; if (counter <= 12) { - s->x = 254 - (((counter * 75) << 6) >> 8); - s->y = ((DISPLAY_HEIGHT / 2) + 41) - (((counter * 123) << 3) >> 8); + s->x = 284 - (((counter * 75) << 6) >> 8); + s->y = ((DISPLAY_HEIGHT / 2) + 47) - (((counter * 123) << 3) >> 8); } else if (counter <= 100) { - // _08030078 - s->x = 254 - (((13 * 75) << 6) >> 8) + 13; - s->y = ((DISPLAY_HEIGHT / 2) + 41) - (((13 * 123) << 3) >> 8) + 2; + s->x = 284 - (((13 * 75) << 6) >> 8) + 13; + s->y = ((DISPLAY_HEIGHT / 2) + 47) - (((13 * 123) << 3) >> 8) + 2; } else { - // _08030086 - u32 innerCount = counter - (100 - 12); - s->x = 254 - (((innerCount * 75) << 6) >> 8); - s->y = ((DISPLAY_HEIGHT / 2) + 47) - (((innerCount * 123) << 3) >> 8); + s->x = 284 - ((((counter - (100 - 12)) * 75) << 6) >> 8); + s->y = ((DISPLAY_HEIGHT / 2) + 47) - ((((counter - (100 - 12)) * 123) << 3) >> 8); } - // _080300AE - i = 0; - sp08 = counter; - - for (i = 0; i < ARRAY_COUNT(introUI->sprZoneName); i++) { - s = &introUI->sprZoneName[i]; - - if (counter <= 12) { - s->x = 284 - (((counter * 75) << 6) >> 8); - s->y = ((DISPLAY_HEIGHT / 2) + 47) - (((counter * 123) << 3) >> 8); - } else if (counter <= 100) { - s->x = 284 - (((13 * 75) << 6) >> 8) + 13; - s->y = ((DISPLAY_HEIGHT / 2) + 47) - (((13 * 123) << 3) >> 8) + 2; - } else { - s->x = 284 - ((((counter - (100 - 12)) * 75) << 6) >> 8); - s->y = ((DISPLAY_HEIGHT / 2) + 47) - ((((counter - (100 - 12)) * 123) << 3) >> 8); - } - // _0803012A + // _0803012A - // TODO: This looks like a programmer added a @HACK here? - if (i == 3) { - s->x -= 24; - } + // TODO: This looks like a programmer added a @HACK here? + if (i == 3) { + s->x -= 24; } - // _08030134+8 + } + // _08030134+8 - for (i = 0; i < ARRAY_COUNT(introUI->sprUnlockedIcons); i++) { - // _08030170 - u32 lastIconIndex = ((ARRAY_COUNT(introUI->sprUnlockedIcons) - 1) - i); - s = &introUI->sprUnlockedIcons[lastIconIndex]; - s->x = (DISPLAY_WIDTH - (ARRAY_COUNT(introUI->sprUnlockedIcons) * 17) - ((ARRAY_COUNT(introUI->sprUnlockedIcons) + 1) * 2)) - + lastIconIndex * 17; - s->y = -22; - - if (sp08 < 50) { - if (sp08 >= i * 2) { - if (!(i & 0x1)) { - if (sp08 < 5) { - s->y = (sp08 * 10 - 22) - i * 20; - } else { - s->y = 20; - asm(""); // TEMP? - } + counterByte = counter; + for (i = 0; i < ARRAY_COUNT(introUI->sprUnlockedIcons); i++) { + s32 x, y; +// _08030170 +#ifndef NON_MATCHING + register u32 lastIconIndex asm("r0"); +#else + u32 lastIconIndex; +#endif + lastIconIndex = ((ARRAY_COUNT(introUI->sprUnlockedIcons) - 1) - i); + s = &introUI->sprUnlockedIcons[lastIconIndex]; + + x = (DISPLAY_WIDTH - (ARRAY_COUNT(introUI->sprUnlockedIcons) * 17) - ((ARRAY_COUNT(introUI->sprUnlockedIcons) + 1) * 2)) + + lastIconIndex * 17; + s->x = x; + + y = -22; + s->y = y; + + if (counterByte < 50) { + if (counterByte >= i * 2) { + if (!(i & 1)) { + s32 offset = i * -20; + if (counterByte + (i * -2) < 5) { + s->y = InlineIconsCalc(counterByte, 10) + offset; } else { - // _080301B2 - u32 yVal = (sp08 - i * 2); - if (yVal < 5) { - s->y = (yVal * 6) - 22; - } else { - // _080301C2 - s->y = 12; - asm(""); // TEMP - } + s->y = 20; } - } - } else if (counter < 100) { - // _080301C8+4 - if (!(i & 0x1)) { - s->y = 20; } else { - s->y = 12; + // _080301B2 + if ((counterByte + (i * -2)) < 5) { + s->y = ((counterByte + (i * -2)) * 6) - 22; + } else { + s->y = 12; + } } + } + } else if (counter < 100) { + // _080301C8+4 + if (!(i & 1)) { + s->y = 20; } else { - // _080301E0 - if (!(i & 0x1)) { - s->y = 20 - (counter - 100) * 6; - } else { - s->y = 12 - (counter - 100) * 6; - } + s->y = 12; } - } - - /* Loading Wheel */ - s = &introUI->sprLoadingWheel; - s->x = 36; - - if (counter <= 16) { - s->y = -48; - } else if (counter <= 25) { - u8 xw = counter - 16; - s->y = (xw * 8) - 40; - } else if (counter <= 100) { - s->y = 32; } else { - s->y = 32 - ((u8)(counter - 100) * 8u); + // _080301E0 + if (!(i & 1)) { + s->y = 20 - (counter - 100) * 6; + + } else { + s->y = 12 - (counter - 100) * 6; + } } + } - // _08030240 - /* Loading Wheel Icon */ - s = &introUI->sprLoadingWheelIcon; + /* Loading Wheel */ + s = &introUI->sprLoadingWheel; + s->x = 36; + + if (counter <= 16) { + s->y = -48; + } else if (counter <= 25) { + counterByte = counter - 16; + s->y = (counterByte * 8) - 40; + } else if (counter <= 100) { + s->y = 32; + } else { + counterByte = counter - 100; + s->y = 32 - (counterByte * 8); + } - s->frameFlags = (gUnknown_030054B8++ | SPRITE_FLAG_MASK_ROT_SCALE_ENABLE); + // _08030240 + /* Loading Wheel Icon */ + s = &introUI->sprLoadingWheelIcon; + s->frameFlags = (gUnknown_030054B8++ | SPRITE_FLAG_MASK_ROT_SCALE_ENABLE); + s->x = 35; + + if (counter <= 16) { + s->y = -49; + } else if (counter <= 25) { + counterByte = counter - 16; + s->y = (counterByte * 8) - 41; + } else if (counter <= 100) { s->x = 35; - - if (counter <= 16) { - s->y = -49; - } else if (counter <= 25) { - s->y = ((u8)(counter - 16) * 8u) - 41; - } else if (counter <= 100) { - s->x = 35; - s->y = 32; - } else { - s->y = 32 - ((u8)(counter - 100) * 8u); - } - - StageIntroUpdateIcons(); + s->y = 32; + } else { + counterByte = counter - 100; + s->y = 32 - (counterByte * 8); } + + StageIntroUpdateIcons(); } -END_NONMATCH static inline void sub_8030488_inline() { diff --git a/src/game/stage/player.c b/src/game/stage/player.c index 9262bf9c7..9b6ac6d2c 100644 --- a/src/game/stage/player.c +++ b/src/game/stage/player.c @@ -68,7 +68,7 @@ void Player_8026BCC(Player *); s32 sub_8029BB8(Player *p, u8 *p1, s32 *out); -void Player_8025A0C(Player *p); +void Player_SpinAttack(Player *p); void Player_Idle(Player *); void Player_8025AB8(Player *); @@ -115,7 +115,7 @@ bool32 Player_TryCrouchOrSpinAttack(Player *); bool32 Player_TryInitSpindash(Player *); void Player_InitCrouch(Player *); void Player_InitIceSlide(Player *); -void Player_802A3B8(Player *); +void PlayerFn_Cmd_HandlePhysics(Player *); void Player_802A3C4(Player *); void Player_CameraShift(Player *); void Player_InitSpecialStageTransition(Player *); @@ -3385,7 +3385,7 @@ void CallPlayerTransition(Player *p) PLAYERFN_SET(Player_TouchGround); } break; case PLTRANS_PT2 - 1: { - PLAYERFN_SET(Player_8025A0C); + PLAYERFN_SET(Player_SpinAttack); } break; case PLTRANS_INIT_JUMP - 1: { p->moveState &= ~(MOVESTATE_400000 | MOVESTATE_IGNORE_INPUT); @@ -4194,7 +4194,7 @@ void Player_Crouch(Player *p) } } -void Player_8025A0C(Player *p) +void Player_SpinAttack(Player *p) { if (IS_BOSS_STAGE(gCurrentLevel)) { if ((p->moveState & MOVESTATE_IN_AIR)) { @@ -4547,7 +4547,7 @@ void Player_Spindash(Player *p) p->speedGroundX = speed; - gPlayer.callback = Player_8025A0C; + gPlayer.callback = Player_SpinAttack; m4aSongNumStart(SE_SPIN_DASH_RELEASE); } else { @@ -4957,7 +4957,7 @@ void Player_8026E24(Player *p) m4aSongNumStart(SE_SPIN); - PLAYERFN_SET_AND_CALL(Player_802A3B8, p); + PLAYERFN_SET_AND_CALL(PlayerFn_Cmd_HandlePhysics, p); } void Player_8026F10(Player *p) @@ -5461,7 +5461,8 @@ void Player_8027D3C(Player *p) } } -void sub_8027EF0(Player *p) +// Generic function for movement and collision, has aerial input, used in character aerial/landing states +void Player_HandlePhysicsWithAirInput(Player *p) { if (p->moveState & MOVESTATE_IN_AIR) { sub_8023610(p); @@ -5485,7 +5486,8 @@ void sub_8027EF0(Player *p) } } -void sub_802808C(Player *p) +// Generic function for movement and collision that doesn't allow player influence +void Player_HandlePhysics(Player *p) { if (p->moveState & MOVESTATE_IN_AIR) { sub_80232D0(p); @@ -6746,7 +6748,7 @@ bool32 Player_TryCrouchOrSpinAttack(Player *p) return TRUE; } else if (((u16)(p->speedGroundX + (Q(0.5) - 1)) > Q(1.0) - 2) && !(p->moveState & (MOVESTATE_1000000 | MOVESTATE_4 | MOVESTATE_IN_AIR))) { - PLAYERFN_SET(Player_8025A0C); + PLAYERFN_SET(Player_SpinAttack); m4aSongNumStart(SE_SPIN_ATTACK); return TRUE; } @@ -6799,7 +6801,7 @@ void Player_802A258(Player *p) { if (!(p->moveState & MOVESTATE_IN_AIR)) { if (p->moveState & MOVESTATE_4) - Player_8025A0C(p); + Player_SpinAttack(p); else Player_TouchGround(p); } else { @@ -6842,14 +6844,14 @@ void Player_InitDashRing(Player *p) void Player_InitIceSlide(Player *p) { Player_InitIceSlide_inline(p); } -void Player_802A3B8(Player *p) { sub_802808C(p); } +void PlayerFn_Cmd_HandlePhysics(Player *p) { Player_HandlePhysics(p); } void Player_802A3C4(Player *p) { - sub_8027EF0(p); + Player_HandlePhysicsWithAirInput(p); if (p->spriteInfoBody->s.frameFlags & SPRITE_FLAG_MASK_ANIM_OVER) - PLAYERFN_SET(Player_8025A0C); + PLAYERFN_SET(Player_SpinAttack); } void Player_CameraShift(Player *p) { Player_CameraShift_inline(p); } diff --git a/src/game/stage/rings_scatter.c b/src/game/stage/rings_scatter.c index 18bbb7dfd..3f769aff8 100644 --- a/src/game/stage/rings_scatter.c +++ b/src/game/stage/rings_scatter.c @@ -300,7 +300,8 @@ void RingsScatterSingleplayer_FlippedGravity(void) ring->velY -= sp08; - if ((screenX + TILE_WIDTH) > 0 && screenX + TILE_WIDTH < 256 && screenY > -8 && screenY < (DISPLAY_HEIGHT + TILE_WIDTH)) { + if ((screenX + TILE_WIDTH) > 0 && screenX + TILE_WIDTH < (DISPLAY_WIDTH + (TILE_WIDTH * 2)) && screenY > -TILE_WIDTH + && screenY < (DISPLAY_HEIGHT + TILE_WIDTH)) { if (ring->unkC >= 32 || (gStageTime & 0x2) == 0) { if ((!sp10) || (s->oamBaseIndex == 0xFF)) { s->oamBaseIndex = 0xFF; @@ -413,7 +414,8 @@ void RingsScatterSingleplayer_NormalGravity(void) ring->velY += sp08; - if ((screenX + TILE_WIDTH) > 0 && screenX + TILE_WIDTH < 256 && (screenY > -8) && (screenY < (DISPLAY_HEIGHT + 8))) { + if ((screenX + TILE_WIDTH) > 0 && screenX + TILE_WIDTH < (DISPLAY_WIDTH + (TILE_WIDTH * 2)) && (screenY > -TILE_WIDTH) + && (screenY < (DISPLAY_HEIGHT + TILE_WIDTH))) { if (ring->unkC >= 32 || ((gStageTime & 0x2) == 0)) { if ((!sp10) || (s->oamBaseIndex == 0xFF)) { s->oamBaseIndex = 0xFF; diff --git a/src/platform/pret_sdl/sdl2.c b/src/platform/pret_sdl/sdl2.c index cd4d6691c..019db4f4f 100644 --- a/src/platform/pret_sdl/sdl2.c +++ b/src/platform/pret_sdl/sdl2.c @@ -18,6 +18,7 @@ #include "gba/types.h" #include "lib/agb_flash/flash_internal.h" #include "platform/shared/dma.h" +#include "platform/shared/input.h" #if ENABLE_AUDIO #include "platform/shared/audio/cgb_audio.h" @@ -494,60 +495,6 @@ void ProcessSDLEvents(void) } } -#ifdef _WIN32 -#define STICK_THRESHOLD 0.5f -u16 GetXInputKeys() -{ - XINPUT_STATE state; - ZeroMemory(&state, sizeof(XINPUT_STATE)); - - DWORD dwResult = XInputGetState(0, &state); - u16 xinputKeys = 0; - - if (dwResult == ERROR_SUCCESS) { - /* A */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) >> 12; - /* B */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) >> 13; - /* Start */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) >> 1; - /* Select */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) >> 3; - /* L */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) << 1; - /* R */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) >> 1; - /* Up */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) << 6; - /* Down */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) << 6; - /* Left */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) << 3; - /* Right */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) << 1; - - /* Control Stick */ - float xAxis = (float)state.Gamepad.sThumbLX / (float)SHRT_MAX; - float yAxis = (float)state.Gamepad.sThumbLY / (float)SHRT_MAX; - - if (xAxis < -STICK_THRESHOLD) - xinputKeys |= DPAD_LEFT; - else if (xAxis > STICK_THRESHOLD) - xinputKeys |= DPAD_RIGHT; - if (yAxis < -STICK_THRESHOLD) - xinputKeys |= DPAD_DOWN; - else if (yAxis > STICK_THRESHOLD) - xinputKeys |= DPAD_UP; - - /* Speedup */ - // Note: 'speedup' variable is only (un)set on keyboard input - double oldTimeScale = timeScale; - timeScale = (state.Gamepad.bRightTrigger > 0x80 || speedUp) ? 5.0 : 1.0; - - if (oldTimeScale != timeScale) { - if (timeScale > 1.0) { - SDL_PauseAudio(1); - } else { - SDL_ClearQueuedAudio(1); - SDL_PauseAudio(0); - } - } - } - - return xinputKeys; -} -#endif // _WIN32 - u16 Platform_GetKeyInput(void) { #ifdef _WIN32 diff --git a/src/platform/shared/input.c b/src/platform/shared/input.c new file mode 100644 index 000000000..d4b3a3878 --- /dev/null +++ b/src/platform/shared/input.c @@ -0,0 +1,44 @@ +#ifdef _WIN32 +#include +#include +#include "gba/io_reg.h" +#include "gba/types.h" + +#define STICK_THRESHOLD 0.5f +u16 GetXInputKeys() +{ + XINPUT_STATE state; + ZeroMemory(&state, sizeof(XINPUT_STATE)); + + DWORD dwResult = XInputGetState(0, &state); + u16 xinputKeys = 0; + + if (dwResult == ERROR_SUCCESS) { + /* A */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_A) >> 12; + /* B */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_X) >> 13; + /* Start */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_START) >> 1; + /* Select */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) >> 3; + /* L */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) << 1; + /* R */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) >> 1; + /* Up */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) << 6; + /* Down */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) << 6; + /* Left */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) << 3; + /* Right */ xinputKeys |= (state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) << 1; + + /* Control Stick */ + float xAxis = (float)state.Gamepad.sThumbLX / (float)SHRT_MAX; + float yAxis = (float)state.Gamepad.sThumbLY / (float)SHRT_MAX; + + if (xAxis < -STICK_THRESHOLD) + xinputKeys |= DPAD_LEFT; + else if (xAxis > STICK_THRESHOLD) + xinputKeys |= DPAD_RIGHT; + if (yAxis < -STICK_THRESHOLD) + xinputKeys |= DPAD_DOWN; + else if (yAxis > STICK_THRESHOLD) + xinputKeys |= DPAD_UP; + } + + return xinputKeys; +} +#endif // _WIN32 diff --git a/src/platform/win32/opengl.c b/src/platform/win32/opengl.c new file mode 100644 index 000000000..5ff9897c4 --- /dev/null +++ b/src/platform/win32/opengl.c @@ -0,0 +1,249 @@ +#include // realloc +#include // printf +#include +#include "global.h" // TEMP for PLTT +#include "platform/shared/opengl.h" + +// NOTE: This is NOT final at all. EXPERIMENTAL!!!!! + +// TODO: Move this file into /platform/shared + +// TEMP +static GLuint sTempTextureHandles[3] = { 0 }; + +#define NUM_RGB_CHANNELS 4 +u8 tempRgbaPalette[16 * 32][NUM_RGB_CHANNELS] = {}; +u8 tempRgbaFrame[DISPLAY_WIDTH * DISPLAY_HEIGHT][NUM_RGB_CHANNELS] = {}; + +typedef struct { + u8 *data; + int width, height; +} TextureBuffer; +static TextureBuffer sDynTextureBuffer = { 0 }; + +static void TempConvertPLTTToRGBA8(void) +{ + // Convert PLTT from ABGR1555 -> RGBA8 + for (int i = 0; i < ARRAY_COUNT(tempRgbaPalette); i++) { + u16 color = PLTT[i]; + float r = (float)(color & 0x01F) / 31.0; + float g = (float)((color & 0x3E0) >> 5) / 31.0; + float b = (float)((color & 0x7C00) >> 10) / 31.0; + + tempRgbaPalette[i][0] = r * 255.0; + tempRgbaPalette[i][1] = g * 255.0; + tempRgbaPalette[i][2] = b * 255.0; + tempRgbaPalette[i][3] = 1 * 255.0; + } +} + +static u8 *TempConvertPLTTEntryToRGBA8(u8 paletteId) +{ + // Convert PLTT from ABGR1555 -> RGBA8 + u16 *pal4BPP = &PLTT[(paletteId + 16) * 16]; + + for (int i = 0; i < 16; i++) { + u16 color = pal4BPP[i]; + + float r = (float)(color & 0x01F) / 31.0; + float g = (float)((color & 0x3E0) >> 5) / 31.0; + float b = (float)((color & 0x7C00) >> 10) / 31.0; + + tempRgbaPalette[paletteId * 16 + i][0] = r * 255.0; + tempRgbaPalette[paletteId * 16 + i][1] = g * 255.0; + tempRgbaPalette[paletteId * 16 + i][2] = b * 255.0; + tempRgbaPalette[paletteId * 16 + i][3] = 1 * 255.0; + } + + return tempRgbaPalette[paletteId * 16]; +} + +// TODO: This should be done offline. +// Just load all assets in RGB8 or RGBA8 on boot. +static void TempConvert4bppToRGBA8_DynTextureBuffer(const u8 *bitmap4bpp, int width, int height, u8 paletteId) +{ + if (sDynTextureBuffer.width * sDynTextureBuffer.height < width * height) { + sDynTextureBuffer.data = realloc(sDynTextureBuffer.data, width * height * sizeof(u32)); + + if (!sDynTextureBuffer.data) { + printf("WARNING: realloc in %s failed!\n", __FUNCTION__); + return; + } else { + printf("realloc: w 0x%X, h 0x%X, full: 0x%X\n", width, height, (u32)(width * height * sizeof(u32))); + } + } + + u8 *texturePalette = TempConvertPLTTEntryToRGBA8(paletteId); + + sDynTextureBuffer.width = width; + sDynTextureBuffer.height = height; + + u16 widthInTiles = width >> 3; + + int numSourcePixels = width * height; + for (int frameY = 0; frameY < height; frameY++) { + for (int frameX = 0; frameX < width; frameX++) { + u8 colorIndex = ((frameY & 0x7) * 8 + (frameX & 0x7)); + + bool8 doShift = (colorIndex & 1); + u8 textureColorId = bitmap4bpp[colorIndex >> 1] & (0xF << (doShift * 4)); + textureColorId >>= doShift * 4; + + sDynTextureBuffer.data[colorIndex * 4 + 0] = tempRgbaPalette[textureColorId][0]; + sDynTextureBuffer.data[colorIndex * 4 + 1] = tempRgbaPalette[textureColorId][1]; + sDynTextureBuffer.data[colorIndex * 4 + 2] = tempRgbaPalette[textureColorId][2]; + sDynTextureBuffer.data[colorIndex * 4 + 3] = 0xFF; + } + } +} + +void OpenGL_OnInit() +{ + // Enable texturing + glEnable(GL_TEXTURE_2D); + + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + + // NOTE: Modelview matrix is a legacy feature + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glGenTextures(2, &sTempTextureHandles[0]); +} + +void OpenGL_DisplaySprite(Sprite *sprite, u8 oamPaletteNum) +{ + const SpriteOffset *dims = sprite->dimensions; + + if (dims != (void *)-1) { + // Convert vertices screenspace -> unit space + glMatrixMode(GL_PROJECTION); +#if 0 + glLoadIdentity(); +#else + float a = 2.0f / DISPLAY_WIDTH; + float b = 2.0f / DISPLAY_HEIGHT; + float projMtx[] = { a, 0, 0, 0, 0, b, 0, 0, 0, 0, 1, 0, -1, -1, 0, 1 }; + glLoadMatrixf(projMtx); +#endif + + TempConvert4bppToRGBA8_DynTextureBuffer(sprite->graphics.src, dims->width, dims->height, sprite->palId + oamPaletteNum); + + // glGenTextures(1, &sTempTextureHandles[2]); + glBindTexture(GL_TEXTURE_2D, sTempTextureHandles[2]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dims->width, dims->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, sDynTextureBuffer.data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // downscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // upscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + // glClearColor((float)tempRgbaPalette[1][0] / 255., + // (float)tempRgbaPalette[1][1] / 255., + // (float)tempRgbaPalette[1][2] / 255., + // 1.0); + // glClear(GL_COLOR_BUFFER_BIT); + + float minX = sprite->x - (dims->width >> 1); + float maxX = minX + dims->width; + + float minY = sprite->y - (dims->height >> 1); + float maxY = minY + dims->height; + + glBegin(GL_TRIANGLES); + { + glTexCoord2f(0.0, 0.0); + glVertex2f(minX, maxY); + glTexCoord2f(1.0, 1.0); + glVertex2f(maxX, minY); + glTexCoord2f(0.0, 1.0); + glVertex2f(minX, minY); + + glTexCoord2f(0.0, 0.0); + glVertex2f(minX, maxY); + glTexCoord2f(1.0, 0.0); + glVertex2f(maxX, maxY); + glTexCoord2f(1.0, 1.0); + glVertex2f(maxX, minY); + } + glEnd(); + } +} + +void OpenGL_Render(void *tempBufferPixels, int viewportWidth, int viewportHeight) +{ + glViewport(0, 0, viewportWidth, viewportHeight); + +#if 0 + // Don't convert input-vertices + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#else + // Convert vertices screenspace -> unit space + glMatrixMode(GL_PROJECTION); + float a = 2.0f / DISPLAY_WIDTH; + float b = 2.0f / DISPLAY_HEIGHT; + float projMtx[] = { + a, 0, 0, 0, // + 0, b, 0, 0, // + 0, 0, 1, 0, // + -1, -1, 0, 1 // + }; + glLoadMatrixf(projMtx); +#endif + + // TempConvertPLTTToRGBA8(); + + // Convert the "software-rendered" image from ABGR1555 -> RGBA8 + for (int i = 0; i < ARRAY_COUNT(tempRgbaFrame); i++) { + u16 color = ((u16 *)tempBufferPixels)[i]; + float r = (float)(color & 0x01F) / 31.0; + float g = (float)((color & 0x3E0) >> 5) / 31.0; + float b = (float)((color & 0x7C00) >> 10) / 31.0; + + tempRgbaFrame[i][0] = b * 255.0; + tempRgbaFrame[i][1] = g * 255.0; + tempRgbaFrame[i][2] = r * 255.0; + tempRgbaFrame[i][3] = 1 * 255.0; + } + + glBindTexture(GL_TEXTURE_2D, sTempTextureHandles[0]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, tempRgbaPalette); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // downscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // upscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glBindTexture(GL_TEXTURE_2D, sTempTextureHandles[1]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, DISPLAY_WIDTH, DISPLAY_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, tempRgbaFrame); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // downscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // upscale filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glClearColor(1.0, 1.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + glBindTexture(GL_TEXTURE_2D, sTempTextureHandles[1]); + glBegin(GL_TRIANGLES); + { + glTexCoord2f(0.0, 0.0); + glVertex2f(0.0, +DISPLAY_HEIGHT); + glTexCoord2f(1.0, 1.0); + glVertex2f(+DISPLAY_WIDTH, 0); + glTexCoord2f(0.0, 1.0); + glVertex2f(0, 0); + + glTexCoord2f(0.0, 0.0); + glVertex2f(0, DISPLAY_HEIGHT); + glTexCoord2f(1.0, 0.0); + glVertex2f(DISPLAY_WIDTH, DISPLAY_HEIGHT); + glTexCoord2f(1.0, 1.0); + glVertex2f(DISPLAY_WIDTH, 0); + } + glEnd(); +} \ No newline at end of file diff --git a/src/platform/win32/win32.c b/src/platform/win32/win32.c index 896ef06a5..89ab44870 100644 --- a/src/platform/win32/win32.c +++ b/src/platform/win32/win32.c @@ -3,6 +3,14 @@ #include "global.h" #include "core.h" +#include "gba/io_reg.h" + +#if (RENDERER == RENDERER_OPENGL) +#include +#include "platform/shared/opengl.h" +#endif + +#include "platform/shared/input.h" extern void GameInit(void); @@ -11,6 +19,10 @@ LRESULT CALLBACK Win32_WindowCallback(HWND window, UINT message, WPARAM wParam, static void Win32_ProcessPendingMessages(HWND window); static RECT Win32_GetWindowDimension(HWND Window); +#if (RENDERER == RENDERER_OPENGL) +static void Win32_InitOpenGL(HWND window); +#endif + static u16 ALIGNED(8) sImageBuffer[DISPLAY_WIDTH * DISPLAY_HEIGHT] = { RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, RGB_GREEN, @@ -19,6 +31,7 @@ static BITMAPINFO sBMInfo = { 0 }; static bool32 sRunning = TRUE; static HWND sWindowHandle = 0; static HDC sDeviceContext = 0; +static u16 sInputKeys = 0; #define ENABLE_RESIZE TRUE @@ -79,6 +92,10 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR lpCmdLine, if (sWindowHandle) { sDeviceContext = GetDC(sWindowHandle); +#if (RENDERER == RENDERER_OPENGL) + Win32_InitOpenGL(sWindowHandle); +#endif + sBMInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); sBMInfo.bmiHeader.biWidth = DISPLAY_WIDTH; sBMInfo.bmiHeader.biHeight = -DISPLAY_HEIGHT; // negative biHeight: bottom->down image @@ -91,6 +108,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR lpCmdLine, sBMInfo.bmiHeader.biClrUsed = 0; sBMInfo.bmiHeader.biClrImportant = 0; + timeBeginPeriod(1); + Win32_ProcessPendingMessages(sWindowHandle); // If this isn't set, gFlags gets set to FLAGS_200, leading to the MP menu being @@ -105,12 +124,18 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR lpCmdLine, #if 01 REG_KEYINPUT &= ~START_BUTTON; - // while (sRunning) - { + while (sRunning) { + memset(sImageBuffer, 0, sizeof(sImageBuffer)); + gFlags |= 0x4000; EngineMainLoop(); - REG_KEYINPUT ^= (A_BUTTON | START_BUTTON); - REG_KEYINPUT |= (DPAD_RIGHT); + // REG_KEYINPUT ^= (A_BUTTON | START_BUTTON); + + // NOTE: This is an OR because sInputKeys can get set + // through keyboard events. + sInputKeys |= GetXInputKeys(); + + REG_KEYINPUT = ~sInputKeys; } #else HANDLE GameThreadHandle = CreateThread(NULL, 0, GameThread, NULL, 0, &threadId); @@ -134,10 +159,50 @@ DWORD WINAPI GameThread(void *pThreadParam) } } +#if (RENDERER == RENDERER_OPENGL) +// From "Handmade Hero 235 - Initializing OpenGL on Windows" +// https://www.youtube.com/watch?v=5Klc9RZPG7M +static void Win32_InitOpenGL(HWND window) +{ + HDC deviceContext = GetDC(window); + + PIXELFORMATDESCRIPTOR desiredPixelFormat = {}; + PIXELFORMATDESCRIPTOR suggestedPixelFormat; + + // TODO: Find out if double-buffering is necessary for us! + desiredPixelFormat.nSize = sizeof(PIXELFORMATDESCRIPTOR); + desiredPixelFormat.nVersion = 1; + desiredPixelFormat.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER); + desiredPixelFormat.cColorBits = 24; + desiredPixelFormat.cAlphaBits = 8; + desiredPixelFormat.iLayerType = PFD_MAIN_PLANE; + + int suggestedPixelFormatIndex = ChoosePixelFormat(deviceContext, &desiredPixelFormat); + DescribePixelFormat(deviceContext, suggestedPixelFormatIndex, sizeof(PIXELFORMATDESCRIPTOR), &suggestedPixelFormat); + SetPixelFormat(deviceContext, suggestedPixelFormatIndex, &suggestedPixelFormat); + + // RC = "Rendering Context" + HGLRC openGLRC = wglCreateContext(deviceContext); + + if (wglMakeCurrent(deviceContext, openGLRC)) { + OpenGL_OnInit(); + } else { + // LOG fail + } + + ReleaseDC(window, deviceContext); +} +#endif + static void Win32_DisplayBufferInWindow(HDC deviceContext, int windowWidth, int windowHeight) { +#if (RENDERER == RENDERER_OPENGL) + OpenGL_Render(sImageBuffer, windowWidth, windowHeight); + SwapBuffers(deviceContext); +#else StretchDIBits(deviceContext, 0, 0, windowWidth, windowHeight, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, sImageBuffer, &sBMInfo, DIB_RGB_COLORS, SRCCOPY); +#endif } LRESULT CALLBACK Win32_WindowCallback(HWND window, UINT message, WPARAM wParam, LPARAM lParam) @@ -179,11 +244,66 @@ LRESULT CALLBACK Win32_WindowCallback(HWND window, UINT message, WPARAM wParam, return result; } +static u16 Win32_KeyboardKeyToGameKey(char key) +{ + switch (key) { + case 'C': { + return A_BUTTON; + } break; + + case 'X': { + return B_BUTTON; + } break; + + case VK_RETURN: { + return START_BUTTON; + } break; + + case VK_BACK: { + return SELECT_BUTTON; + } break; + + case VK_LEFT: { + return DPAD_LEFT; + } break; + + case VK_UP: { + return DPAD_UP; + } break; + + case VK_RIGHT: { + return DPAD_RIGHT; + } break; + + case VK_DOWN: { + return DPAD_DOWN; + } break; + + case 'S': { + return L_BUTTON; + } break; + + case 'D': { + return R_BUTTON; + } break; + } + + return 0; +} + static void Win32_ProcessPendingMessages(HWND window) { MSG message; while (PeekMessage(&message, 0, 0, 0, PM_REMOVE)) { switch (message.message) { + case WM_KEYUP: { + sInputKeys &= ~Win32_KeyboardKeyToGameKey(message.wParam); + } break; + + case WM_KEYDOWN: { + sInputKeys |= Win32_KeyboardKeyToGameKey(message.wParam); + } break; + case WM_QUIT: { printf("Closing"); sRunning = FALSE; @@ -197,19 +317,131 @@ static void Win32_ProcessPendingMessages(HWND window) } } +// Converts GBA -> Win32 RGB value +#define RGB_SHIFT(value) (((value >> 10) & 0x1F) | (value & 0x3E0) | (((value & 0x1F) << 10))) + +void Platform_DisplaySprite(Sprite *sprite, u8 oamPaletteNum) +{ + if (sprite->graphics.src == NULL) + return; + +#if (RENDERER == RENDERER_OPENGL) + // TEMP - Currently the display buffer gets drawn in software, but we should load the assets as a textures and let OpenGL render + // everything + // OpenGL_DisplaySprite(sprite, oamPaletteNum); + // return; +#endif + + const SpriteOffset *dims = sprite->dimensions; + + bool32 xFlip = SPRITE_FLAG_GET(sprite, X_FLIP); + bool32 yFlip = SPRITE_FLAG_GET(sprite, Y_FLIP); + + // printf("Sprite: %d\n", sprite->graphics.anim); + + s32 x, y, sprWidth, sprHeight; + + x = sprite->x; + y = sprite->y; + + { + // TEMP - from sprite.c + sprWidth = dims->width; + sprHeight = dims->height; + if (sprite->frameFlags & SPRITE_FLAG_MASK_ROT_SCALE_ENABLE) { + if (sprite->frameFlags & SPRITE_FLAG_MASK_ROT_SCALE_DOUBLE_SIZE) { + x -= dims->width / 2; + y -= dims->height / 2; + sprWidth *= 2; + sprHeight *= 2; + } + } else { + if (sprite->frameFlags & SPRITE_FLAG_MASK_Y_FLIP) { + y -= sprHeight - dims->offsetY; + } else { + y -= dims->offsetY; + } + + if (sprite->frameFlags & SPRITE_FLAG_MASK_X_FLIP) { + x -= sprWidth - dims->offsetX; + } else { + x -= dims->offsetX; + } + } + } + + s32 tempX = x; + s32 tempY = y; + + u16 widthInTiles = dims->width >> 3; + + for (int frameY = 0; frameY < dims->height; frameY++) { + s32 finalY = (tempY + frameY); + + if (finalY < 0) + continue; + + if (finalY >= DISPLAY_HEIGHT) + break; + + for (int frameX = 0; frameX < dims->width; frameX++) { + + s32 finalX = (tempX + frameX); + + if (finalX < 0) + continue; + + if (finalX >= DISPLAY_WIDTH) + break; + + int bufferPixelIndex = finalY * DISPLAY_WIDTH + finalX; + int imagePixelIndex = frameY * dims->width + frameX; + + if (bufferPixelIndex >= 0 && bufferPixelIndex < DISPLAY_WIDTH * DISPLAY_HEIGHT) { + u16 *pal = &PLTT[oamPaletteNum * 16 + (BG_PLTT_SIZE / 2)]; + u16 tileNumX = (frameX >> 3); + u16 tileNumY = (frameY >> 3); + u16 tileNum = tileNumY * widthInTiles + tileNumX; + u32 offset = tileNum * TILE_SIZE_4BPP; + + u8 *tile = &((u8 *)sprite->graphics.src)[offset]; + + u8 colorIndex = ((frameY & 0x7) * 8 + (frameX & 0x7)); + + bool8 doShift = (colorIndex & 1); + u8 colorId = tile[colorIndex >> 1] & (0xF << (doShift * 4)); + colorId >>= doShift * 4; + if (colorId != 0) + sImageBuffer[bufferPixelIndex] = RGB_SHIFT(pal[colorId]); + } + } + } +} + void VBlankIntrWait() { - while (sRunning) { + // while (sRunning) + { // NOTE: This wouldn't work here with multiple threads, because PeekMessage() // only gets messages in the thread the specified window was created in. Win32_ProcessPendingMessages(sWindowHandle); RECT clientRect; GetClientRect(sWindowHandle, &clientRect); - Win32_DisplayBufferInWindow(sDeviceContext, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); - Sleep(16); static u8 test = 0; + sImageBuffer[test++] = RGB_BLACK; sImageBuffer[test] = RGB_GREEN; + Win32_DisplayBufferInWindow(sDeviceContext, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); + + // TODO: Remove Sleep, use high-resolution timer instead! + Sleep(10); + +#if (RENDERER == RENDERER_OPENGL) + // TODO: Don't do this here!!! + // This should be called in src/platform/shared/opengl.c + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); +#endif } } diff --git a/src/sprite.c b/src/sprite.c index 0f49ddff6..555286db1 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -7,6 +7,11 @@ #include "lib/m4a/m4a.h" #include "data/sprite_data.h" #include "animation_commands.h" +#include "platform/platform.h" + +#if !PLATFORM_GBA && !PLATFORM_SDL +extern void Platform_DisplaySprite(Sprite *sprite, u8 oamPaletteNum); +#endif extern const AnimationCommandFunc animCmdTable[]; @@ -533,6 +538,7 @@ void DisplaySprite(Sprite *sprite) const u16 *oamData; if (sprite->dimensions != (void *)-1) { + const SpriteOffset *sprDims = sprite->dimensions; sprite->numSubFrames = sprDims->numSubframes; @@ -592,6 +598,15 @@ void DisplaySprite(Sprite *sprite) oam->all.attr0 &= 0xFE00; oam->all.attr2 += sprite->palId << 12; + +#if !PLATFORM_GBA && !PLATFORM_SDL + // TEMP + // Quick hack for getting output in OpenGL test + // The whole function call should be replaced by this! + Platform_DisplaySprite(sprite, oam->split.paletteNum); + return; +#endif + if (sprite->frameFlags & SPRITE_FLAG_MASK_ROT_SCALE_ENABLE) { oam->all.attr0 |= 0x100; if (sprite->frameFlags & SPRITE_FLAG_MASK_ROT_SCALE_DOUBLE_SIZE) { @@ -799,7 +814,7 @@ void CopyOamBufferToOam(void) u8 i = 0; s32 r3; - for (r3 = 0; r3 < 32; r3++) { + for (r3 = 0; r3 < (s32)ARRAY_COUNT(gUnknown_03001850); r3++) { s8 index = gUnknown_03001850[r3]; while (index != -1) { diff --git a/tools/_shared/c_header_parser/tilemaps.h b/tools/_shared/c_header_parser/tilemaps.h deleted file mode 100644 index 83f2fbe4a..000000000 --- a/tools/_shared/c_header_parser/tilemaps.h +++ /dev/null @@ -1,308 +0,0 @@ -#ifndef GUARD_TILEMAPS -#define GUARD_TILEMAPS - -// NOTE: * 0-92 are MapHeaders -// * 93 == NULL -#define TM_LEVEL_METATILES_0(level) (((level)*3) + 0) -#define TM_LEVEL_METATILES_1(level) (((level)*3) + 1) -#define TM_LEVEL_BG(level) (((level)*3) + 2) - -#define TM_SA1_TITLE_LOGO 94 -#define TM_SA1_TITLE_BG 95 -#define TM_INTRO_PRESENTED_BY_SEGA 96 -#define TM_INTRO_CREATED_BY_SONIC_TEAM 97 -#define TM_CHAR_SELECT_BACKGROUND 98 -#define TM_CHAR_SELECT_WHEEL 99 -#define TM_STAGE_SELECT_BG_SONIC 100 -#define TM_STAGE_SELECT_BG_CREAM 101 -#define TM_STAGE_SELECT_BG_TAILS 102 -#define TM_STAGE_SELECT_BG_KNUCKLES 103 -#define TM_STAGE_SELECT_BG_AMY 104 -#define TM_STAGE_SELECT_MAP 105 -#define TM_EGG_SAUCER_WHEEL_COPY 106 -#define TM_UNKNOWN_OPTIONS_BG 107 -#define TM_108 108 -#define TM_SA2_TITLE_LOGO_JP 109 -#define TM_TA_AND_MP_WHITE_BG 110 -#define TM_MP_ORANGE_BG 111 -#define TM_TA_ORANGE_BG 112 -#define TM_STAGE_1_BG_0_COPY 113 -#define TM_MP_WAIT_CONNECTION 114 -#define TM_MP_MESSAGE_BOX_UNKNOWN 115 -#define TM_MP_CHARACTERS_SELECTED_JP 116 -#define TM_MP_CHARACTERS_SELECTED_EN 117 -#define TM_MP_CHARACTERS_SELECTED_DE 118 -#define TM_MP_CHARACTERS_SELECTED_FR 119 -#define TM_MP_CHARACTERS_SELECTED_ES 120 -#define TM_MP_CHARACTERS_SELECTED_IT 121 -#define TM_MP_UNKNOWN_ORANGE_ZIGZAG 122 -#define TM_MP_UNKNOWN_GREEN 123 -#define TM_UNKNOWN_MESSAGE_BOX_WHITE 124 -#define TM_UNKNOWN_MESSAGE_BOX_WHITE_SMALL 125 -#define TM_MP_VS_BACKGROUND_TEXT 126 -#define TM_MP_CHEESE_PLEASE_WAIT_JP 127 -#define TM_MP_CHEESE_PLEASE_WAIT_EN 128 -#define TM_MP_CHEESE_PLEASE_WAIT_DE 129 -#define TM_MP_CHEESE_PLEASE_WAIT_FR 130 -#define TM_MP_CHEESE_PLEASE_WAIT_ES 131 -#define TM_MP_CHEESE_PLEASE_WAIT_IT 132 -#define TM_OPTIONS_BG0 133 -#define TM_OPTIONS_LANGUAGE_SELECT 134 -#define TM_OPTIONS_ENTER_NAME 135 -#define TM_OPTIONS_ENTER_NAME_CHARACTERS 136 -#define TM_OPTIONS_TIME_RECORD_BG0 137 -#define TM_OPTIONS_TIME_RECORD_BG1 138 -#define TM_139 139 -#define TM_MP_CHARACTER_SELECTED_SONIC_BG 140 -#define TM_MP_CHARACTER_SELECTED_SONIC 141 -#define TM_MP_CHARACTER_SELECTED_TAILS_BG 142 -#define TM_MP_CHARACTER_SELECTED_TAILS 143 -#define TM_MP_CHARACTER_SELECTED_KNUCKLES_BG 144 -#define TM_MP_CHARACTER_SELECTED_KNUCKLES 145 -#define TM_MP_CHARACTER_SELECTED_AMY_BG 146 -#define TM_MP_CHARACTER_SELECTED_AMY 147 -#define TM_MP_CHARACTER_SELECTED_CREAM_BG 148 -#define TM_MP_CHARACTER_SELECTED_CREAM 149 -#define TM_150_MESSAGE_BOX_BLACK 150 -#define TM_151_GREEN_CARET 151 -#define TM_OPTIONS_VS_RECORD_BG1 152 -#define TM_SPECIAL_STAGE_1 153 -#define TM_SPECIAL_STAGE_1_BG 154 -#define TM_SPECIAL_STAGE_2 155 -#define TM_SPECIAL_STAGE_2_BG 156 -#define TM_SPECIAL_STAGE_3 157 -#define TM_SPECIAL_STAGE_3_BG 158 -#define TM_SPECIAL_STAGE_4 159 -#define TM_SPECIAL_STAGE_4_BG 160 -#define TM_SPECIAL_STAGE_5 161 -#define TM_SPECIAL_STAGE_5_BG 162 -#define TM_SPECIAL_STAGE_6 163 -#define TM_SPECIAL_STAGE_6_BG 164 -#define TM_SPECIAL_STAGE_7 165 -#define TM_SPECIAL_STAGE_7_BG 166 -#define TM_TECHNO_BASE_BG_PURPLE_GRID 167 -#define TM_TECHNO_BASE_BG_CIRCUIT_MASK 168 -#define TM_SOUND_TEST_BG 169 -#define TM_CUTSCENE_POST_EXTRA_BOSS_BG 170 -#define TM_CUTSCENE_FINAL_ENDING_FALL_BG 171 -#define TM_CUTSCENE_FINAL_ENDING_FALL_CLOUDS 172 -#define TM_CUTSCENE_FINAL_ENDING_FALL_BG_DARK 173 -#define TM_CUTSCENE_FINAL_ENDING_FALL_BG_DARK_2 174 -// JP has an image of Eggman, other languages are only the textbox -#define TM_COLLECT_ALL_CHAOS_EMERALDS_JP 175 -#define TM_COLLECT_ALL_CHAOS_EMERALDS_EN 176 -#define TM_COLLECT_ALL_CHAOS_EMERALDS_FR 177 -#define TM_COLLECT_ALL_CHAOS_EMERALDS_DE 178 -#define TM_COLLECT_ALL_CHAOS_EMERALDS_IT 179 -#define TM_COLLECT_ALL_CHAOS_EMERALDS_ES 180 - -// (Also used as BG for SoundTest unlock) -// JP fills the entire screen, other languages are only the textbox -#define TM_UNLOCKED_TINY_CHAO_GARDEN_JP 181 -#define TM_UNLOCKED_TINY_CHAO_GARDEN_EN 182 -#define TM_UNLOCKED_TINY_CHAO_GARDEN_FR 183 -#define TM_UNLOCKED_TINY_CHAO_GARDEN_DE 184 -#define TM_UNLOCKED_TINY_CHAO_GARDEN_IT 185 -#define TM_UNLOCKED_TINY_CHAO_GARDEN_ES 186 - -// Uses TM_UNLOCKED_TINY_CHAO_GARDEN_JP as BG -#define TM_UNLOCKED_SOUND_TEST_JP 187 -#define TM_UNLOCKED_SOUND_TEST_EN 188 -#define TM_UNLOCKED_SOUND_TEST_FR 189 -#define TM_UNLOCKED_SOUND_TEST_DE 190 -#define TM_UNLOCKED_SOUND_TEST_IT 191 -#define TM_UNLOCKED_SOUND_TEST_ES 192 - -// Uses TM_UNLOCKED_TINY_CHAO_GARDEN_JP as BG -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_JP 193 -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_EN 194 -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_FR 195 -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_DE 196 -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_IT 197 -#define TM_UNLOCKED_BOSSES_TIME_ATTACK_ES 198 -#define TM_UNLOCKED_AMY_JP 199 -#define TM_UNLOCKED_AMY_EN 200 -#define TM_UNLOCKED_AMY_FR 201 -#define TM_UNLOCKED_AMY_DE 202 -#define TM_UNLOCKED_AMY_IT 203 -#define TM_UNLOCKED_AMY_ES 204 -#define TM_CUTSCENE_FINAL_ENDING_LAND_FG 205 -#define TM_CUTSCENE_FINAL_ENDING_LAND_BG 206 -#define TM_CUTSCENE_FINAL_ENDING_LAND_FLOWER_FIELD 207 -#define TM_CUTSCENE_FINAL_ENDING_LAND_BG_ALT 208 -#define TM_UNK_SPACE_BG 209 -#define TM_STORYFRAME_SONIC_CATCHES_VANILLA 210 -#define TM_STORYFRAME_SONIC_FINDS_FRIENDS 211 -#define TM_STORYFRAME_SONIC_PATS_TAILS 212 -#define TM_STORYFRAME_CREAM_HUGS_VANILLA 213 -#define TM_STORYFRAME_CREAM_TAILS_VANILLA_LOOK_AROUND 214 -#define TM_STORYFRAME_CREAM_CHEESE_VANILLA_HAPPY 215 -#define TM_STORYFRAME_SONIC_LEAVES_0 216 -#define TM_STORYFRAME_SONIC_LEAVES_1 217 -#define TM_STORYFRAME_SONIC_LEAVES_2 218 -#define TM_STORYFRAME_SONIC_LEAVES_3 219 -#define TM_STORYFRAME_SONIC_LEAVES_4 220 -#define TM_STORYFRAME_SONIC_LEAVES_5 221 -#define TM_STORYFRAME_SONIC_LEAVES_6 222 -#define TM_STORYFRAME_SONIC_LEAVES_7 223 -#define TM_STORYFRAME_SONIC_LEAVES_8 224 -#define TM_STORYFRAME_SONIC_LEAVES_9 225 -#define TM_STORYFRAME_SONIC_LEAVES_10 226 -#define TM_STORYFRAME_CREAM_UNLOCK_0_SEPIA 227 -#define TM_STORYFRAME_CREAM_UNLOCK_1_SEPIA 228 -#define TM_STORYFRAME_TAILS_UNLOCK_1_SEPIA 229 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_SEPIA 230 -#define TM_STORYFRAME_CREAM_UNLOCK_3_SEPIA 231 -#define TM_CREDITS_SA2_LOGO_JP 232 -#define TM_CREDITS_SA2_LOGO_EN 233 -#define TM_CREDITS_0 234 -#define TM_CREDITS_1 235 -#define TM_CREDITS_2 236 -#define TM_CREDITS_3 237 -#define TM_CREDITS_4 238 -#define TM_CREDITS_5 239 -#define TM_CREDITS_6 240 -#define TM_CREDITS_7 241 -#define TM_CREDITS_8 242 -#define TM_CREDITS_9 243 -#define TM_CREDITS_10 244 -#define TM_CREDITS_11 245 -#define TM_CREDITS_12 246 -#define TM_CREDITS_13 247 -#define TM_CREDITS_14 248 -#define TM_CREDITS_15 249 -#define TM_CREDITS_16 250 -#define TM_CREDITS_17 251 -#define TM_CREDITS_18 252 -#define TM_CREDITS_19 253 -#define TM_CREDITS_20 254 -#define TM_CREDITS_21 255 -#define TM_CREDITS_22 256 -#define TM_CREDITS_23 257 -#define TM_CREDITS_24 258 -#define TM_CREDITS_COPYRIGHT 259 -#define TM_CREDITS_PRESENTED_BY_SEGA 260 -#define TM_TITLE_SCREEN_BG 261 -#define TM_INTRO_WATER 262 -#define TM_LENS_FLARE_BG 263 -#define TM_SA2_LOGO_JP 264 -#define TM_SA2_LOGO_EN 265 -#define TM_STORYFRAME_CREAM_UNLOCK_0 266 -#define TM_STORYFRAME_CREAM_UNLOCK_1 267 -#define TM_STORYFRAME_CREAM_UNLOCK_2 268 -#define TM_STORYFRAME_CREAM_UNLOCK_3 269 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_JP 270 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_JP 271 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_JP 272 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_JP 273 -#define TM_STORYFRAME_CREAM_UNLOCKED_JP 274 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_EN 275 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_EN 276 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_EN 277 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_EN 278 -#define TM_STORYFRAME_CREAM_UNLOCKED_EN 279 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_FR 280 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_FR 281 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_FR 282 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_FR 283 -#define TM_STORYFRAME_CREAM_UNLOCKED_FR 284 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_DE 285 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_DE 286 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_DE 287 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_DE 288 -#define TM_STORYFRAME_CREAM_UNLOCKED_DE 289 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_IT 290 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_IT 291 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_IT 292 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_IT 293 -#define TM_STORYFRAME_CREAM_UNLOCKED_IT 294 -#define TM_STORYFRAME_CREAM_UNLOCK_0_DLG_ES 295 -#define TM_STORYFRAME_CREAM_UNLOCK_1_DLG_ES 296 -#define TM_STORYFRAME_CREAM_UNLOCK_2_DLG_ES 297 -#define TM_STORYFRAME_CREAM_UNLOCK_3_DLG_ES 298 -#define TM_STORYFRAME_CREAM_UNLOCKED_ES 299 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0 300 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1 301 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2 302 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3 303 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_JP 304 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_JP 305 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_JP 306 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_JP 307 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_JP 308 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_EN 309 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_EN 310 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_EN 311 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_EN 312 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_EN 313 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_FR 314 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_FR 315 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_FR 316 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_FR 317 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_FR 318 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_DE 319 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_DE 320 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_DE 321 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_DE 322 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_DE 323 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_IT 324 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_IT 325 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_IT 326 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_IT 327 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_IT 328 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_0_DLG_ES 329 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_1_DLG_ES 330 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_2_DLG_ES 331 -#define TM_STORYFRAME_KNUCKLES_UNLOCK_3_DLG_ES 332 -#define TM_STORYFRAME_KNUCKLES_UNLOCKED_ES 333 -#define TM_STORYFRAME_TAILS_UNLOCK_0 334 -#define TM_STORYFRAME_TAILS_UNLOCK_1 335 -#define TM_STORYFRAME_TAILS_UNLOCK_2 336 -#define TM_STORYFRAME_TAILS_UNLOCK_3 337 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_JP 338 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_JP 339 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_JP 340 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_JP 341 -#define TM_STORYFRAME_TAILS_UNLOCKED_JP 342 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_EN 343 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_EN 344 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_EN 345 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_EN 346 -#define TM_STORYFRAME_TAILS_UNLOCKED_EN 347 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_FR 348 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_FR 349 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_FR 350 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_FR 351 -#define TM_STORYFRAME_TAILS_UNLOCKED_FR 352 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_DE 353 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_DE 354 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_DE 355 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_DE 356 -#define TM_STORYFRAME_TAILS_UNLOCKED_DE 357 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_IT 358 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_IT 359 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_IT 360 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_IT 361 -#define TM_STORYFRAME_TAILS_UNLOCKED_IT 362 -#define TM_STORYFRAME_TAILS_UNLOCK_0_DLG_ES 363 -#define TM_STORYFRAME_TAILS_UNLOCK_1_DLG_ES 364 -#define TM_STORYFRAME_TAILS_UNLOCK_2_DLG_ES 365 -#define TM_STORYFRAME_TAILS_UNLOCK_3_DLG_ES 366 -#define TM_STORYFRAME_TAILS_UNLOCKED_ES 367 -#define TM_REGULAR_FINAL_BOSS 368 -#define TM_UNKNOWN_STARS 369 -#define TM_SKY_CANYON_CLOUDS_FOREGROUND 370 -#define TM_371 371 -#define TM_EXTRA_BOSS_BACKGROUND 372 -#define TM_CHARACTER_SELECT_BACKGROUND_0 373 -#define TM_CHARACTER_SELECT_BACKGROUND_1 374 -#define TM_EXTRA_BOSS_COCKPIT 375 -#define TM_EXTRA_BOSS_BACKGROUND_COPY 376 -#define TM_EXTRA_BOSS_BACKGROUND_COPY 376 -#define TM_CUTSCENE_VANILLA_KIDNAPPED_FULL_MAP 377 -#define TM_CUTSCENE_VANILLA_KIDNAPPED_FULL_MAP_COPY 378 -#define TM_CUTSCENE_VANILLA_KIDNAPPED_SUPER_SONIC_ART 379 -#define TM_REGULAR_FINAL_BOSS_BUILDING_BG 380 -#define TM_COUNT 381 - -#endif // GUARD_TILEMAPS