Skip to content

Commit

Permalink
Merge branch 'main' into msys2
Browse files Browse the repository at this point in the history
  • Loading branch information
bitten2up authored Jan 14, 2025
2 parents 80ff34f + 20dbc83 commit d1852a0
Show file tree
Hide file tree
Showing 36 changed files with 1,460 additions and 3,124 deletions.
93 changes: 93 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -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<number of CPU cores>`

## 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`

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
81 changes: 15 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<number of CPU cores>`

### 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
175 changes: 0 additions & 175 deletions asm/non_matching/game/bosses/AeroEgg_InitPartsDefeated.inc

This file was deleted.

Loading

0 comments on commit d1852a0

Please sign in to comment.