Makefile and Install.md Revamp (#41)

* Makefile: move over to gcc for preproc and ditch cpp

* INSTALL: rewrite INSTALL

* README: add CI badge

* Makefile: make tools build before anything else
This commit is contained in:
Seth Barberee 2021-07-09 17:35:12 -07:00 committed by GitHub
parent f55ac4c552
commit 386299d1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 413 additions and 137 deletions

View File

@ -1,25 +1,304 @@
First, you must put a Pokémon Mystery Dungeon Red Rescue Team 1.0 (US) ROM in the root directory of the repository and name it `baserom.gba`. It should have a SHA1 checksum of `9f4cfc5b5f4859d17169a485462e977c7aac2b89`. Then, follow the OS-specific instructions below.
# Linux
# Instructions
Install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM).
These instructions explain how to set up the tools required to build **pmd-red**, which assembles the source files into a ROM.
Make sure that there is an environment variable called DEVKITARM with the path of the directory before the "bin" directory containing "arm-none-eabi-as", "arm-none-eabi-cpp", "arm-none-eabi-ld" and "arm-none-eabi-objcopy".
These instructions come with notes which can be expanded by clicking the "<i>Note...</i>" text.
In general, you should not need to open these unless if you get an error or if you need additional clarification.
Then get the compiler from https://github.com/pret/agbcc and run the following commands.
If you run into trouble, ask for help on Discord or IRC (see [README.md](README.md)).
build.sh
install.sh PATH_OF_PMD-RED_DIRECTORY
${DEVKITARM}/bin/arm-none-eabi/ranlib PATH_OF_PMD-RED_DIRECTORY/tools/agbcc/lib/libgcc.a lib/libc.a
## Prerequisites
Finally, in the pmd-red directory, build the rom.
First, you must put a Pokémon Mystery Dungeon Red Rescue Team 1.0 (US) ROM in the root directory of the repository and name it `baserom.gba`. It should have a SHA1 checksum of `9f4cfc5b5f4859d17169a485462e977c7aac2b89`. Then, follow the OS-specific instructions below:
make
- [Windows](#windows)
- [macOS](#macos)
- [Linux](#linux)
# Windows
## Windows
- [Windows 10 (WSL1)](#windows-10-wsl1) (**Fastest, highly recommended**, Windows 10 only)
Install [**devkitARM**](http://devkitpro.org/wiki/Getting_Started/devkitARM).
<details>
<summary><i>Note for advanced users: <b>WSL2</b>...</i></summary>
Then get the compiled tools from https://github.com/pret/pokeruby-tools. Copy the `tools/` folder over the `tools/` folder in your pmd-red directory.
> <b>WSL2</b> is an option and is even faster than <b>WSL1</b> if files are stored on the WSL2 file system, but some tools may have trouble interacting
> with the WSL2 file system over the network drive. For example, tools which use Qt versions before 5.15.2 such as <a href="https://github.com/huderlem/porymap">porymap</a>
> may <a href="https://bugreports.qt.io/browse/QTBUG-86277">have problems with parsing the <code>\\wsl$</code> network drive path</a>.
</details>
You can then build pmd-red using `make` in the MSYS environment provided with devkitARM.
All of the Windows instructions assume that the default drive is C:\\. If this differs to your actual drive letter, then replace C with the correct drive letter when reading the instructions.
**A note of caution**: As Windows 7 is officially unsupported by Microsoft and Windows 8 has very little usage, some maintainers are unwilling to maintain the Windows 7/8 instructions. Thus, these instructions may break in the future with fixes taking longer than fixes to the Windows 10 instructions.
## Windows 10 (WSL1)
WSL1 is the preferred terminal to build **pmd-red**. The following instructions will explain how to install WSL1 (referred to interchangeably as WSL).
- If WSL (Debian or Ubuntu) is **not installed**, then go to [Installing WSL1](#installing-wsl1).
- Otherwise, if WSL is installed, but it **hasn't previously been set up for another decompilation project**, then go to [Setting up WSL1](#setting-up-wsl1).
- Otherwise, **open WSL** and go to [Choosing where to store pmd-red (WSL1)](#choosing-where-to-store-pmd-red-wsl1).
### Installing WSL1
1. Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following command (Right Click or Shift+Insert is paste in the Powershell).
```powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```
2. Once the process finishes, restart your machine.
3. The next step is to choose and install a Linux distribution from the Microsoft Store. The following instructions will assume Ubuntu as the Linux distribution of choice.
<details>
<summary><i>Note for advanced users...</i></summary>
> You can pick a preferred Linux distribution, but setup instructions may differ. Debian should work with the given instructions, but has not been tested.
</details>
4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution.
<details>
<summary><i>Notes...</i></summary>
> Note 1: If a dialog pops up asking for you to sign into a Microsoft Account, then just close the dialog.
> Note 2: If the link does not work, then open the Microsoft Store manually, and search for the Ubuntu app (choose the one with no version number).
</details>
### Setting up WSL1
Some tips before proceeding:
- In WSL, Copy and Paste is either done via
- **right-click** (selection + right click to Copy, right click with no selection to Paste)
- **Ctrl+Shift+C/Ctrl+Shift+V** (enabled by right-clicking the title bar, going to Properties, then checking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste").
- Some of the commands that you'll run will ask for your WSL password and/or confirmation to perform the stated action. This is to be expected, just enter your WSL password and/or the yes action when necessary.
1. Open **Ubuntu** (e.g. using Search).
2. WSL/Ubuntu will set up its own installation when it runs for the first time. Once WSL/Ubuntu finishes installing, it will ask for a username and password (to be input in).
<details>
<summary><i>Note...</i></summary>
> When typing in the password, there will be no visible response, but the terminal will still read in input.
</details>
3. Update WSL/Ubuntu before continuing. Do this by running the following command. These commands will likely take a long time to finish:
```bash
sudo apt update && sudo apt upgrade
```
> Note: If the repository you plan to build has an **[older revision of the INSTALL.md](https://github.com/pret/pokeemerald/blob/571c598/INSTALL.md)**, then follow the [legacy WSL1 instructions](docs/legacy_WSL1_INSTALL.md) from here.
4. Certain packages are required to build pmd-red. Install these packages by running the following command:
```bash
sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
```
<details>
<summary><i>Note...</i></summary>
> If the above command does not work, try the above command but replacing `apt` with `apt-get`.
</details>
### Choosing where to store pmd-red (WSL1)
WSL has its own file system that's not natively accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to store pmd-red within Windows.
For example, say you want to store pmd-red (and agbcc) in **C:\Users\\_\<user>_\Desktop\decomps**. First, ensure that the folder already exists. Then, enter this command to **change directory** to said folder, where *\<user>* is your **Windows** username:
```bash
cd /mnt/c/Users/<user>/Desktop/decomps
```
<details>
<summary><i>Notes...</i></summary>
> Note 1: The Windows C:\ drive is called /mnt/c/ in WSL.
> Note 2: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "/mnt/c/users/<user>/Desktop/decomp folder"`.
> Note 3: Windows path names are case-insensitive so adhering to capitalization isn't needed
</details>
If this works, then proceed to [Installation](#installation).
## macOS
1. If the Xcode Command Line Tools are not installed, download the tools [here](https://developer.apple.com/xcode/resources/), open your Terminal, and run the following command:
```bash
xcode-select --install
```
2. - If libpng is **not installed**, then go to [Installing libpng (macOS)](#installing-libpng-macos).
- Otherwise, **open the Terminal** and go to [Choosing where to store pmd-red (macOS)](#choosing-where-to-store-pmd-red-macos)
### Installing libpng (macOS)
<details>
<summary><i>Note for advanced users...</i></summary>
> This guide installs libpng via Homebrew as it is the easiest method, however advanced users can install libpng through other means if they so desire.
</details>
1. Open the Terminal.
2. If Homebrew is not installed, then install [Homebrew](https://brew.sh/) by following the instructions on the website.
3. Run the following command to install libpng.
```bash
brew install libpng
```
libpng is now installed.
### Choosing where to store pmd-red (macOS)
At this point, you can choose a folder to store pmd-red into. If you're okay with storing pmd-red in the user folder, then proceed to [Installation](#installation). Otherwise, you'll need to account for where pmd-red is stored when changing directory to the pmd-red folder.
For example, if you want to store pmd-red (and agbcc) in **~/Desktop/decomps**, enter this command to **change directory** to the desired folder:
```bash
cd Desktop/decomps
```
Note that the directory **must exist** in the folder system. If you want to store pmd-red in a dedicated folder that doesn't exist (e.g. the example provided above), then create the folder (e.g. using Finder) before executing the `cd` command.
<details>
<summary><i>Note..</i>.</summary>
> Note: If the path has spaces, then the path must be wrapped with quotations, e.g. `cd "Desktop/decomp folder"`
</details>
If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)).
## Linux
Open Terminal and enter the following commands, depending on which distro you're using.
### Debian/Ubuntu-based distributions
Run the following command to install the necessary packages:
```bash
sudo apt install build-essential binutils-arm-none-eabi git libpng-dev
```
Then proceed to [Choosing where to store pmd-red (Linux)](#choosing-where-to-store-pmd-red-(linux)).
### Other distributions
_(Specific instructions for other distributions would be greatly appreciated!)_
1. Try to find the required software in its repositories:
- `gcc`
- `g++`
- `make`
- `git`
- `libpng-dev`
### Choosing where to store pmd-red (Linux)
At this point, you can choose a folder to store pmd-red (and agbcc) into. If so, you'll have to account for the modified folder path when changing directory to the pmd-red folder.
If this works, then proceed to [Installation](#installation). Otherwise, ask for help on Discord or IRC (see [README.md](README.md)).
## Installation
<details>
<summary><i>Note for Windows users...</i></summary>
> Consider adding an exception for the `pmd-red` and/or `decomps` folder in Windows Security using
> [these instructions](https://support.microsoft.com/help/4028485). This prevents Microsoft Defender from
> scanning them which might improve performance while building.
</details>
1. If pmd-red is not already downloaded (some users may prefer to download pmd-red via a git client like GitHub Desktop), run:
```bash
git clone https://github.com/pret/pmd-red
```
<details>
<summary><i>Note for WSL1...</i></summary>
> If you get an error stating `fatal: could not set 'core.filemode' to 'false'`, then run the following commands:
> ```bash
> cd
> sudo umount /mnt/c
> sudo mount -t drvfs C: /mnt/c -o metadata,noatime
> cd <folder where pmd-red is to be stored>
> ```
> Where *\<folder where pmd-red is to be stored>* is the path of the folder [where you chose to store pmd-red](#Choosing-where-to-store-pmd-red-WSL1). Then run the `git clone` command again.
</details>
2. Install agbcc into pmd-red. The commands to run depend on certain conditions. **You should only follow one of the listed instructions**:
- If agbcc has **not been built before** in the folder where you chose to store pmd-red, run the following commands to build and install it into pmd-red:
```bash
git clone https://github.com/pret/agbcc
cd agbcc
./build.sh
./install.sh ../pmd-red
```
- **Otherwise**, if agbcc has been built before (e.g. if the git clone above fails), but was **last built on a different terminal** than the one currently used (only relevant to Windows, e.g. switching from msys2 to WSL1), then run the following commands to build and install it into pmd-red:
```bash
cd agbcc
git clean -fX
./build.sh
./install.sh ../pmd-red
```
- **Otherwise**, if agbcc has been built before on the same terminal, run the following commands to install agbcc into pmd-red:
```bash
cd agbcc
./install.sh ../pmd-red
```
<details>
<summary><i>Note...</i></summary>
> If building agbcc or pmd-red results in an error, try deleting the agbcc folder and re-installing agbcc as if it has not been built before.
</details>
3. Once agbcc is installed, change directory back to the base directory where pmd-red and agbcc are stored:
```bash
cd ..
```
Now you're ready to [build **pmd-red**](#build-pmd-red)
## Build pmd-red
If you aren't in the pmd-red directory already, then **change directory** to the pmd-red folder:
```bash
cd pmd-red
```
To build **pmd-red.gba** for the first time and confirm it matches the official ROM image (Note: to speed up builds, see [Parallel builds](#parallel-builds)):
```bash
make compare
```
If an OK is returned, then the installation went smoothly.
<details>
<summary>Note for Windows...</summary>
> If you switched terminals since the last build (e.g. from msys2 to WSL1), you must run `make clean-tools` once before any subsequent `make` commands.
</details>
To build **pmd-red.gba** with your changes:
```bash
make
```
# Building guidance
## Parallel builds
See [the GNU docs](https://www.gnu.org/software/make/manual/html_node/Parallel.html) and [this Stack Exchange thread](https://unix.stackexchange.com/questions/208568) for more information.
To speed up building, first get the value of `nproc` by running the following command:
```bash
nproc
```
Builds can then be sped up by running the following command:
```bash
make -j<output of nproc>
```
Replace `<output of nproc>` with the number that the `nproc` command returned.
`nproc` is not available on macOS. The alternative is `sysctl -n hw.ncpu` ([relevant Stack Overflow thread](https://stackoverflow.com/questions/1715580)).
## Other toolchains
To build using a toolchain other than devkitARM, override the `TOOLCHAIN` environment variable with the path to your toolchain, which must contain the subdirectory `bin`.
```bash
make TOOLCHAIN="/path/to/toolchain/here"
```
The following is an example:
```bash
make TOOLCHAIN="/usr/local/arm-none-eabi"
```
To compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present.
# Useful additional tools
* [Tilemap Studio](https://github.com/Rangi42/tilemap-studio) for viewing and editing tilemaps

View File

@ -21,7 +21,7 @@ OBJCOPY := $(PREFIX)objcopy
export CC := $(PREFIX)gcc
export AS := $(PREFIX)as
endif
export CPP := $(PREFIX)cpp
export CPP := $(CC) -E
export LD := $(PREFIX)ld
ifeq ($(OS),Windows_NT)
@ -114,12 +114,6 @@ $(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc
#### Main Rules ####
# Disable dependency scanning when NODEP is used for quick building
ifeq ($(NODEP),1)
$(C_BUILDDIR)/%.o: C_DEP :=
else
$(C_BUILDDIR)/%.o: C_DEP = $(shell [[ -f $(C_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(C_SUBDIR)/$*.c)
endif
ALL_BUILDS := red
@ -137,9 +131,29 @@ MAKEFLAGS += --no-print-directory
# Delete files that weren't built properly
.DELETE_ON_ERROR:
infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))
# Build tools when building the rom
# Disable dependency scanning for clean/tidy/tools
# Use a separate minimal makefile for speed
# Since we don't need to reload most of this makefile
ifeq (,$(filter-out all rom compare libagbsyscall syms,$(MAKECMDGOALS)))
$(call infoshell, $(MAKE) -f make_tools.mk)
else
NODEP ?= 1
endif
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl %.pcm %.bin
# Disable dependency scanning when NODEP is used for quick building
ifeq ($(NODEP),1)
$(C_BUILDDIR)/%.o: C_DEP :=
else
$(C_BUILDDIR)/%.o: C_DEP = $(shell [[ -f $(C_SUBDIR)/$*.c ]] && $(SCANINC) -I include -I tools/agbcc/include -I gflib $(C_SUBDIR)/$*.c)
endif
# Create build subdirectories
$(shell mkdir -p $(SUBDIRS))
@ -175,7 +189,7 @@ $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.c $$(C_DEP)
$(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s
$(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $$(ASM_DEP) dungeon_pokemon dungeon_floor
$(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@
$(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@
$(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(ASM_DEP)
$(AS) $(ASFLAGS) $< -o $@
@ -183,10 +197,11 @@ $(ASM_BUILDDIR)/%.o: $(ASM_SUBDIR)/%.s $$(ASM_DEP)
libagbsyscall:
@$(MAKE) -C libagbsyscall TOOLCHAIN=$(TOOLCHAIN)
$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_ewram2.ld $(BUILD_DIR)/sym_iwram.ld
$(BUILD_DIR)/sym_%.txt: sym_%.txt
cp $< $(BUILD_DIR)
$(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_ewram.txt $(BUILD_DIR)/sym_ewram2.txt $(BUILD_DIR)/sym_iwram.txt
cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld
$(BUILD_DIR)/sym_%.ld: sym_%.txt
$(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@
$(ELF): $(LD_SCRIPT) $(ALL_OBJECTS) $(LIBC) libagbsyscall tools
cd $(BUILD_DIR) && $(LD) -T ld_script.ld -Map ../../$(MAP) -o ../../$@ $(LIB)

View File

@ -1,5 +1,7 @@
# Pokémon Mystery Dungeon: Red Rescue Team
[![build](https://github.com/pret/pmd-red/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/pret/pmd-red/actions/workflows/build.yml)
This is a disassembly of Pokémon Mystery Dungeon: Red Rescue Team.
It builds the following rom:
@ -16,9 +18,10 @@ To set up the repository, see [INSTALL.md](INSTALL.md).
* Disassembly of [**Pokémon Crystal**][pokecrystal]
* Disassembly of [**Pokémon Pinball**][pokepinball]
* Disassembly of [**Pokémon TCG**][poketcg]
* Disassembly of [**Pokémon Fire Red**][pokefirered]
* Disassembly of [**Pokémon Fire Red**/**Leaf Green**][pokefirered]
* Disassembly of [**Pokémon Ruby/Sapphire**][pokeruby]
* Disassembly of [**Pokémon Emerald**][pokeemerald]
* Disassembly of [**Pokémon Diamond/Pearl**][pokediamond]
* Discord: [**pret**][Discord]
* irc: **irc.freenode.net** [**#pret**][irc]
@ -31,5 +34,6 @@ To set up the repository, see [INSTALL.md](INSTALL.md).
[pokefirered]: https://github.com/pret/pokefirered
[pokeruby]: https://github.com/pret/pokeruby
[pokeemerald]: https://github.com/pret/pokeemerald
[pokediamond]: https://github.com/pret/pokediamond
[Discord]: https://discord.gg/d5dubZ3
[irc]: https://kiwiirc.com/client/irc.freenode.net/?#pret

View File

@ -2272,7 +2272,7 @@ _0802005C: .4byte gUnknown_203B27C
_08020060: .4byte gGulpinDialogue
_08020064:
movs r0, 0x3
bl sub_8016C40
bl DrawTeamMoneyBox
b _08020562
_0802006C:
ldr r2, [r5]
@ -6233,12 +6233,12 @@ _08021FE2:
bl sub_8021354
_08021FE8:
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
b _080222B6
_08021FF0:
bl sub_8021494
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
bl sub_8022380
ldr r0, _08022020
ldr r2, [r0]
@ -6976,7 +6976,7 @@ _080225B0:
b _080225C2
_080225BC:
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
_080225C2:
pop {r4}
pop {r0}

View File

@ -5,51 +5,6 @@
.text
thumb_func_start sub_8018280
sub_8018280:
push {r4,lr}
sub sp, 0x4
ldr r4, _080182DC
ldr r0, [r4]
adds r0, 0xD4
ldr r0, [r0]
bl sub_8008C54
ldr r0, [r4]
adds r0, 0xD4
ldr r0, [r0]
bl sub_80073B8
ldr r2, _080182E0
ldr r0, [r4]
adds r0, 0xD4
ldr r3, [r0]
movs r0, 0
str r0, [sp]
movs r0, 0x4
movs r1, 0
bl xxx_call_draw_string
ldr r0, [r4]
adds r0, 0xC0
bl sub_8013C68
ldr r0, [r4]
adds r0, 0xD4
ldr r0, [r0]
bl sub_80073E0
bl sub_801CCD8
movs r0, 0
bl sub_801AD34
ldr r0, [r4]
adds r0, 0x70
movs r1, 0
bl sub_8012EA4
add sp, 0x4
pop {r4}
pop {r0}
bx r0
.align 2, 0
_080182DC: .4byte gUnknown_203B20C
_080182E0: .4byte gUnknown_80DB830
thumb_func_end sub_8018280
thumb_func_start sub_80182E4
sub_80182E4:
push {r4-r7,lr}

View File

@ -426,7 +426,7 @@ _0801922A:
movs r0, 0
bl sub_801AD34
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
bl sub_80195C0
ldr r0, _08019250
ldr r2, [r0]
@ -579,12 +579,12 @@ _08019372:
bl sub_801A8D0
_08019378:
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
b _080194E8
_08019380:
bl sub_801A9E0
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
bl sub_8019660
ldr r0, _080193B0
ldr r2, [r0]
@ -1520,7 +1520,7 @@ _08019AF4:
movs r0, 0
bl sub_801AD34
movs r0, 0x1
bl sub_8016C40
bl DrawTeamMoneyBox
_08019B00:
pop {r4,r5}
pop {r0}

View File

@ -2,6 +2,7 @@
#define GUARD_TRADE_ITEMS_MENU_H
#include "text.h"
#include "item.h"
struct TradeSubStruct
{
@ -41,12 +42,11 @@ struct TradeItemsMenu
struct TradeSubStruct unk24C;
struct TradeSubStruct unk254;
/* 0x254 */ struct TradeSubStruct sentItem;
u8 unk25C;
u8 chosenNum;
u8 chosenItem;
u8 fill25F[0x3A0 - 0x25F];
/* 0x25C */ struct ItemStruct_203B460 itemToSend;
u8 fill25F[0x3A0 - 0x260];
};

View File

@ -10,13 +10,13 @@ SECTIONS {
ALIGN(4)
{
ewram_start = .;
INCLUDE "sym_ewram.ld"
INCLUDE "sym_ewram.txt"
src/agb_flash.o(.bss);
*libgcc.a:fp-bit.o(.bss);
*libgcc.a:dp-bit.o(.bss);
*libc.a:syscalls.o(.bss);
. = ALIGN(16);
INCLUDE "sym_ewram2.ld"
INCLUDE "sym_ewram2.txt"
*libc.a:impure.o(.data);
*libc.a:locale.o(.data);
*libc.a:mallocr.o(.data);
@ -30,7 +30,7 @@ SECTIONS {
ALIGN(4)
{
iwram_start = .;
INCLUDE "sym_iwram.ld"
INCLUDE "sym_iwram.txt"
. = 0x8000;
}

11
make_tools.mk Normal file
View File

@ -0,0 +1,11 @@
MAKEFLAGS += --no-print-directory
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
.PHONY: all $(TOOLDIRS)
all: $(TOOLDIRS)
$(TOOLDIRS):
@$(MAKE) -C $@

View File

@ -140,7 +140,7 @@ void CreateFelicityMoneySavingsHeader(u32 param_1)
sub_80073E0(param_1);
}
void sub_8016C40(u32 param_1)
void DrawTeamMoneyBox(u32 param_1)
{
sub_8008C54(param_1);
sub_80073B8(param_1);

View File

@ -57,7 +57,7 @@ u32 DisplayGulpinDialogueSprite(s32 param_1,s16 param_2,struct unkStruct_Gulpin
param2_32 = param_2; // dumb cast needed to get lsr/asr combo
gUnknown_203B26C = MemoryAlloc(0x18c,8);
gUnknown_203B26C = MemoryAlloc(sizeof(struct unkStruct_203B26C),8);
gUnknown_203B26C->unk0 = param_1;
gUnknown_203B26C->unkC = param2_32;
gUnknown_203B26C->unk10 = param_3;

View File

@ -40,7 +40,7 @@ u32 DisplayKangaskhanDialogueSprite(s32 param_1)
ResetUnusedInputStruct();
sub_800641C(0,1,1);
gUnknown_203B208 = MemoryAlloc(0x14c,8);
gUnknown_203B208 = MemoryAlloc(sizeof(struct unkStruct_203B208),8);
gUnknown_203B208->unk18 = 0;
gUnknown_203B208->unk1C = 0;
gUnknown_203B208->unk20 = 0;

View File

@ -21,8 +21,7 @@ struct unkStruct_203B20C
u32 unk1C;
u32 unk20;
u8 fill24[0x60 - 0x24];
u32 unk60;
u8 fill64[0x70 - 0x64];
u16 unk60[8];
u32 unk70;
u8 fill74[0xC0 - 0x74];
u32 unkC0;
@ -77,6 +76,13 @@ extern u32 sub_801A8AC(void);
extern void sub_801A928(void);
extern void sub_8012CAC(struct UnkTextStruct2 *, u32 *);
extern void sub_80182E4(void);
extern void sub_8008C54(u32);
extern void sub_80073B8(u32);
extern void sub_8013C68(u32 *);
extern void sub_80073E0(u32);
extern void sub_8012EA4(u32 *, u32);
extern void xxx_call_draw_string(u32 x, u32 y, u8 *, u32, u32);
extern void sub_801A9E0();
extern void sub_801841C();
@ -87,7 +93,7 @@ extern void sub_8013AA0(u32 *);
extern void sub_801B3C0(struct ItemStruct_203B460 *);
extern void sub_801A5D8(u32, u32, u32, u32);
extern void sub_801C8C4(u32, u32, u32, u32);
extern void sub_8012D60(u32 *, u32 *, u32, u32 *, u32, u32);
extern void sub_8012D60(u32 *, u32 *, u32, u16 *, u32, u32);
extern void sub_801CB5C(u32);
extern void sub_801A8D0(u32);
@ -96,6 +102,7 @@ extern struct UnkTextStruct2 gUnknown_80DB7E8;
extern struct UnkTextStruct2 gUnknown_80DB7D0;
extern struct UnkTextStruct2 gUnknown_80DB800;
extern struct UnkTextStruct2 gUnknown_80DB818;
extern u8 gUnknown_80DB830[];
void sub_8017AF8(void)
{
@ -410,7 +417,7 @@ void sub_8018100(void)
switch(gUnknown_203B20C->state)
{
case 1:
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, &gUnknown_203B20C->unk60, gUnknown_203B20C->unk14, 2);
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, gUnknown_203B20C->unk60, gUnknown_203B20C->unk14, 2);
break;
case 4:
sub_801A5D8(3, 3, 0, 0xA);
@ -421,7 +428,7 @@ void sub_8018100(void)
case 6:
sub_801A9E0();
sub_801841C();
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, &gUnknown_203B20C->unk60, gUnknown_203B20C->unk18, 2);
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, gUnknown_203B20C->unk60, gUnknown_203B20C->unk18, 2);
break;
case 7:
sub_801B3C0(&gUnknown_203B20C->unk8);
@ -453,7 +460,7 @@ void sub_8018100(void)
sub_801CCD8();
sub_801AD34(0);
sub_80184D4();
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, &gUnknown_203B20C->unk60, gUnknown_203B20C->unk1C, 2);
sub_8012D60(&gUnknown_203B20C->unk70, &gUnknown_203B20C->unk20, 0, gUnknown_203B20C->unk60, gUnknown_203B20C->unk1C, 2);
break;
case 14:
sub_801B3C0(&gUnknown_203B20C->unk8);
@ -463,3 +470,15 @@ void sub_8018100(void)
break;
}
}
void sub_8018280(void)
{
sub_8008C54(gUnknown_203B20C->unkD4);
sub_80073B8(gUnknown_203B20C->unkD4);
xxx_call_draw_string(4, 0, gUnknown_80DB830, gUnknown_203B20C->unkD4, 0); // Number?
sub_8013C68(&gUnknown_203B20C->unkC0);
sub_80073E0(gUnknown_203B20C->unkD4);
sub_801CCD8();
sub_801AD34(0);
sub_8012EA4(&gUnknown_203B20C->unk70,0);
}

View File

@ -35,7 +35,7 @@ u32 DisplayKeckleonDialogueSprite(u32 param_1)
char *monName;
struct OpenedFile *faceFile;
gUnknown_203B210 = MemoryAlloc(0x148,8);
gUnknown_203B210 = MemoryAlloc(sizeof(struct unkStruct_203B210),8);
gUnknown_203B210->unk28 = 0;
gUnknown_203B210->unk2C = 0;
gUnknown_203B210->unk30 = 0;

View File

@ -26,7 +26,7 @@ extern void sub_801A2A8(u32);
extern s32 sub_801A8AC(void);
extern u32 sub_801A6E8(u32);
extern void sub_801A928(void);
extern void sub_8016C40(u32);
extern void DrawTeamMoneyBox(u32);
void sub_8019B08(void)
{
@ -53,7 +53,7 @@ void sub_8019B08(void)
break;
case 1:
default:
sub_8016C40(1);
DrawTeamMoneyBox(1);
break;
}
}
@ -168,13 +168,9 @@ void sub_8019D68(void)
u32 sub_8019D8C(void)
{
if(gUnknown_203B210->unk4)
{
return sub_8091814();
}
else
{
return sub_8091A48();
}
}
void sub_8019DAC(void)
@ -195,7 +191,7 @@ void sub_8019DAC(void)
}
}
void sub_8019E04(int param_1)
void sub_8019E04(s32 param_1)
{
if (gUnknown_203B210->unk4) {

View File

@ -33,7 +33,7 @@ struct unkStruct_203B330
u8 fillE[2];
u32 unk10;
struct UnkTextStruct2 *unk14;
struct UnkTextStruct2 unk18[3];
struct UnkTextStruct2 unk18[4];
};
extern struct unkStruct_203B330 *gUnknown_203B330;
@ -536,7 +536,7 @@ void ReturnToGetHelpMenu(void)
u32 sub_80319A4(u8 param_1,u8 param_2,int param_3)
{
gUnknown_203B330 = MemoryAlloc(0x78,8);
gUnknown_203B330 = MemoryAlloc(sizeof(struct unkStruct_203B330),8);
gUnknown_203B330->unkC = param_1;
gUnknown_203B330->unkD = param_2;
sub_801317C(&gUnknown_203B330->unk0);

View File

@ -1,7 +1,7 @@
#include "global.h"
#include "input.h"
#include "trade_items_menu.h"
#include "item.h"
#include "trade_items_menu.h"
#include "gUnknown_203B460.h"
#include "memory.h"
#include "save.h"
@ -44,7 +44,7 @@ extern s32 sub_80144A4(s32 *);
extern u32 sub_801CA08(u32);
extern void sub_801CBB8();
extern u8 sub_801CB24();
extern void sub_801B3C0(u8 *);
extern void sub_801B3C0(struct ItemStruct_203B460 *);
extern u8 sub_8012FD8(u32 *);
extern void sub_8013114(u32 *, s32 *);
extern void sub_8035CC0(struct UnkTextStruct2 *, u32);
@ -54,8 +54,6 @@ extern void sub_801B450();
extern void sub_801CB5C(u32);
extern void sub_8035CF4(u32 *, u32, u32);
extern u32 sub_8013BBC(u32 *);
void sub_8036F30();
extern void TradeItem_AddItem();
extern void sub_80141B4(u32 *, u32, u32, u32);
extern void sub_8008C54(u32);
@ -68,9 +66,8 @@ extern u32 sub_801D008();
extern void sub_8090DC4(u32 *, u8, u32);
extern void sub_801C8C4(u32, u32, s32 *, u32);
void sub_8036F30();
void TradeItem_AddItem();
void SetTradeItemMenu(u32);
void PrintTradeItemsLinkError(u32);
void TradeItem_MainMenu();
@ -230,9 +227,9 @@ void sub_8036590(void)
void sub_80365AC(void)
{
gTradeItemsMenu->chosenItem = 0;
gTradeItemsMenu->chosenNum = 1;
gTradeItemsMenu->unk25C = 0;
gTradeItemsMenu->itemToSend.itemIndex = 0;
gTradeItemsMenu->itemToSend.numItems = 1;
gTradeItemsMenu->itemToSend.unk0 = 0;
switch(sub_801CA08(1)){
case 2:
// Cancel
@ -241,18 +238,18 @@ void sub_80365AC(void)
break;
case 3:
// Pop up menu with Confirm, Info, Cancel
gTradeItemsMenu->chosenItem = sub_801CB24();
gTradeItemsMenu->chosenNum = 1;
gTradeItemsMenu->itemToSend.itemIndex = sub_801CB24();
gTradeItemsMenu->itemToSend.numItems = 1;
SetTradeItemMenu(TRADE_ITEMS_SEND_ITEM_POPUP_MENU);
break;
case 4:
gTradeItemsMenu->unk4 = 2;
gTradeItemsMenu->chosenItem = sub_801CB24();
gTradeItemsMenu->chosenNum = 1;
gTradeItemsMenu->itemToSend.itemIndex = sub_801CB24();
gTradeItemsMenu->itemToSend.numItems = 1;
sub_8006518(gTradeItemsMenu->unk1E4);
ResetUnusedInputStruct();
sub_800641C(0,1,1);
sub_801B3C0(&gTradeItemsMenu->unk25C);
sub_801B3C0(&gTradeItemsMenu->itemToSend);
SetTradeItemMenu(TRADE_ITEMS_ITEM_INFO);
break;
}
@ -276,7 +273,7 @@ void sub_8036674(void)
sub_8006518(gTradeItemsMenu->unk1E4);
ResetUnusedInputStruct();
sub_800641C(0,1,1);
sub_801B3C0(&gTradeItemsMenu->unk25C);
sub_801B3C0(&gTradeItemsMenu->itemToSend);
SetTradeItemMenu(TRADE_ITEMS_ITEM_INFO);
break;
case 7:
@ -332,9 +329,9 @@ void sub_8036788(void)
break;
case 3:
// Confirm # of item
gTradeItemsMenu->chosenNum = gTradeItemsMenu->numItemsToSend;
gTradeItemsMenu->unk254.itemIndex = gTradeItemsMenu->chosenItem;
gTradeItemsMenu->unk254.numItems = gTradeItemsMenu->numItemsToSend;
gTradeItemsMenu->itemToSend.numItems = gTradeItemsMenu->numItemsToSend;
gTradeItemsMenu->sentItem.itemIndex = gTradeItemsMenu->itemToSend.itemIndex;
gTradeItemsMenu->sentItem.numItems = gTradeItemsMenu->numItemsToSend;
sub_801CBB8();
SetTradeItemMenu(TRADE_ITEMS_SEND_ITEM_CONFIRM);
break;
@ -354,9 +351,9 @@ void TradeItem_SendItemConfirm(void)
case 5:
sub_801CBB8();
// Used temp var to get correct statements
load = gUnknown_203B460->unk50[gTradeItemsMenu->chosenItem];
load = gUnknown_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex];
load -= gTradeItemsMenu->numItemsToSend;
gUnknown_203B460->unk50[gTradeItemsMenu->chosenItem] = load;
gUnknown_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex] = load;
SetTradeItemMenu(TRADE_ITEMS_PREPARE_TRADE_SAVING);
PrepareSavePakWrite(SPECIES_NONE);
break;
@ -396,7 +393,7 @@ void sub_80368D4(void)
break;
case 7:
case 0:
if ((gTradeItemsMenu->unk254.itemIndex != 0) && (gTradeItemsMenu->unk254.numItems != 0))
if ((gTradeItemsMenu->sentItem.itemIndex != 0) && (gTradeItemsMenu->sentItem.numItems != 0))
{
TradeItem_AddItem();
SetTradeItemMenu(0x11);
@ -434,8 +431,8 @@ void sub_8036950(void)
}
}
else {
if (((gTradeItemsMenu->itemMode == TRADE_ITEMS_SEND_ITEM_MODE) && (gTradeItemsMenu->unk254.itemIndex != 0))
&& (gTradeItemsMenu->unk254.numItems != 0)) {
if (((gTradeItemsMenu->itemMode == TRADE_ITEMS_SEND_ITEM_MODE) && (gTradeItemsMenu->sentItem.itemIndex != 0))
&& (gTradeItemsMenu->sentItem.numItems != 0)) {
// Link Failure
TradeItem_AddItem(); // Add back the item
SetTradeItemMenu(0xb);
@ -453,9 +450,9 @@ void TradeItem_AddItem(void)
{
// Use temp var to get correct statements
u16 load;
load = gUnknown_203B460->unk50[gTradeItemsMenu->unk254.itemIndex];
load += gTradeItemsMenu->unk254.numItems;
gUnknown_203B460->unk50[gTradeItemsMenu->unk254.itemIndex] = load;
load = gUnknown_203B460->unk50[gTradeItemsMenu->sentItem.itemIndex];
load += gTradeItemsMenu->sentItem.numItems;
gUnknown_203B460->unk50[gTradeItemsMenu->sentItem.itemIndex] = load;
}
void sub_80369FC(void)
@ -597,7 +594,7 @@ void sub_8036B28(void)
break;
case 6:
gUnknown_202DE30 = gTradeItemsMenu->numItemsToSend;
sub_8090DC4(&gUnknown_202DE58,gTradeItemsMenu->chosenItem,0);
sub_8090DC4(&gUnknown_202DE58,gTradeItemsMenu->itemToSend.itemIndex,0);
sub_8014248(&gUnknown_80E61E4,0,5, &gUnknown_80E6154,0,4,0,0,0x101);
break;
case 7:
@ -634,7 +631,7 @@ void sub_8036B28(void)
// Fallthrough needed on each case
case TRADE_ITEMS_SEND_ITEM_MODE:
temp = &gTradeItemsMenu->unk244;
temp2 = &gTradeItemsMenu->unk254;
temp2 = &gTradeItemsMenu->sentItem;
load_2 = temp2->numItems;
temp->itemIndex = temp2->itemIndex;
temp->numItems = load_2;
@ -665,7 +662,7 @@ void sub_8036B28(void)
break;
case 0xd:
gUnknown_202DE30 = gTradeItemsMenu->numItemsToSend;
sub_8090DC4(&gUnknown_202DE58,gTradeItemsMenu->chosenItem,0);
sub_8090DC4(&gUnknown_202DE58,gTradeItemsMenu->itemToSend.itemIndex,0);
sub_80141B4(&gUnknown_80E6358,0,0,0x101);
break;
case 0xB:
@ -1085,7 +1082,7 @@ void sub_8036F30(void)
void sub_8036F74(void)
{
sub_8006518(gTradeItemsMenu->unk184);
sub_8036ECC(2, gUnknown_203B460->unk50[gTradeItemsMenu->chosenItem]);
sub_8036ECC(2, gUnknown_203B460->unk50[gTradeItemsMenu->itemToSend.itemIndex]);
sub_801CCD8();
sub_8035CF4(&gTradeItemsMenu->unk44, 3, 0);
sub_8036F30();