Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pret/pokeemerald into bui…
Browse files Browse the repository at this point in the history
…ld-makefile-cleanup
  • Loading branch information
GriffinRichards committed Aug 31, 2024
2 parents 2198ca3 + 625a006 commit 19ad2e1
Show file tree
Hide file tree
Showing 173 changed files with 1,450 additions and 1,155 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ sound/**/*.bin
sound/songs/midi/*.s
tools/agbcc
*.map
*.ld
*.bat
*.dump
*.sa*
Expand Down
27 changes: 15 additions & 12 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,23 @@ WSL1 is the preferred terminal to build **pokeemerald**. The following instructi
- Otherwise, **open WSL** and go to [Choosing where to store pokeemerald (WSL1)](#Choosing-where-to-store-pokeemerald-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).
1. Open [Windows Powershell **as Administrator**](https://i.imgur.com/QKmVbP9.png), and run the following commands (Right Click or Shift+Insert is paste in the Powershell).

```powershell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
wsl --install -d Ubuntu --enable-wsl1
```
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>
3. Open Windows Powershell **as Administrator** again (after restarting), and run the following command to configure Ubuntu to use WSL1.
4. Open the [Microsoft Store Linux Selection](https://aka.ms/wslstore), click Ubuntu, then click Get, which will install the Ubuntu distribution.
```powershell
wsl --set-version Ubuntu 1
```
<details>
<summary><i>Notes...</i></summary>
<summary><i>Note...</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).
> WSL may open automatically after restarting, but you can ignore it for now.
</details>
### Setting up WSL1
Expand Down Expand Up @@ -354,6 +350,13 @@ Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to
> [install devkitARM on Arch Linux](#installing-devkitarm-on-arch-linux).
</details>

### NixOS
Run the following command to start an interactive shell with the necessary packages:
```bash
nix-shell -p pkgsCross.arm-embedded.stdenv.cc git pkg-config libpng
```
Then proceed to [Choosing where to store pokeemerald (Linux)](#choosing-where-to-store-pokeemerald-linux).

### Other distributions
_(Specific instructions for other distributions would be greatly appreciated!)_

Expand Down
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR)
SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR)
MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR)

SHELL := /bin/bash -o pipefail
SHELL := bash -o pipefail

# Set flags for tools
ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
Expand Down Expand Up @@ -137,8 +137,6 @@ ifeq ($(DINFO),1)
override CFLAGS += -g
endif

LDFLAGS = -Map ../../$(MAP)

# Variable filled out in other make files
AUTO_GEN_TARGETS :=
include make_tools.mk
Expand Down Expand Up @@ -265,6 +263,8 @@ include spritesheet_rules.mk
include json_data_rules.mk
include songs.mk

generated: $(AUTO_GEN_TARGETS)

%.s: ;
%.png: ;
%.pal: ;
Expand All @@ -286,15 +286,15 @@ clean-generated:
-rm -f $(AUTO_GEN_TARGETS)

ifeq ($(MODERN),0)
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/libc.o: CC1 := $(TOOLS_DIR)/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
$(C_BUILDDIR)/siirtc.o: CFLAGS := -mthumb-interwork
$(C_BUILDDIR)/agb_flash.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE)
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
$(C_BUILDDIR)/librfu_intr.o: CC1 := tools/agbcc/bin/agbcc_arm$(EXE)
$(C_BUILDDIR)/librfu_intr.o: CC1 := $(TOOLS_DIR)/agbcc/bin/agbcc_arm$(EXE)
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -O2 -mthumb-interwork -quiet
else
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
Expand All @@ -318,7 +318,7 @@ define C_DEP_IMPL
$1.o: $2
ifeq (,$(KEEP_TEMPS))
@echo "$$(CC1) <flags> -o $$@ $$<"
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) $$< charmap.txt -i | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
@$$(CPP) $$(CPPFLAGS) $$< | $$(PREPROC) -i $$< charmap.txt | $$(CC1) $$(CFLAGS) -o - - | cat - <(echo -e ".text\n\t.align\t2, 0") | $$(AS) $$(ASFLAGS) -o $$@ -
else
@$$(CPP) $$(CPPFLAGS) $$< -o $3.i
@$$(PREPROC) $3.i charmap.txt | $$(CC1) $$(CFLAGS) -o $3.s
Expand Down Expand Up @@ -353,7 +353,7 @@ endef
# As above but first doing a preprocessor pass
define ASM_DEP_PREPROC
$1.o: $2
$$(PREPROC) $$< charmap.txt | $$(CPP) $(INCLUDE_SCANINC_ARGS) - | $$(AS) $$(ASFLAGS) -o $$@
$$(PREPROC) $$< charmap.txt | $$(CPP) $(INCLUDE_SCANINC_ARGS) - | $$(PREPROC) -ie $$< charmap.txt | $$(AS) $$(ASFLAGS) -o $$@
$(call ASM_SCANINC,$1,$2)
endef

Expand Down Expand Up @@ -389,10 +389,10 @@ $(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt

# Linker script
ifeq ($(MODERN),0)
LD_SCRIPT := ld_script.txt
LD_SCRIPT := ld_script.ld
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
else
LD_SCRIPT := ld_script_modern.txt
LD_SCRIPT := ld_script_modern.ld
LD_SCRIPT_DEPS :=
endif

Expand All @@ -407,7 +407,7 @@ libagbsyscall:
# Elf from object files
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) libagbsyscall
@echo "cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ <objects> <lib>"
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
@cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld --print-memory-usage -o ../../$@ $(OBJS_REL) $(LIB) | cat
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent

# Builds the rom from the elf file
Expand Down
2 changes: 1 addition & 1 deletion asmdiff.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

if [[ -d "$DEVKITARM/bin/" ]]; then
OBJDUMP_BIN="$DEVKITARM/bin/arm-none-eabi-objdump"
Expand Down
3 changes: 3 additions & 0 deletions data/maps/MossdeepCity_SpaceCenter_2F/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ MossdeepCity_SpaceCenter_2F_EventScript_DefeatedMaxieTabitha::
setobjectmovementtype LOCALID_SCIENTIST, MOVEMENT_TYPE_WANDER_AROUND
addobject LOCALID_SCIENTIST
fadescreen FADE_FROM_BLACK
#ifdef BUGFIX
releaseall
#endif
end

MossdeepCity_SpaceCenter_2F_EventScript_StevenFacePlayer::
Expand Down
4 changes: 2 additions & 2 deletions data/script_cmd_table.inc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ gScriptCmdTable::
.4byte ScrCmd_nop1 @ 0xca
.4byte ScrCmd_nop1 @ 0xcb
.4byte ScrCmd_nop1 @ 0xcc
.4byte ScrCmd_setmonmodernfatefulencounter @ 0xcd
.4byte ScrCmd_checkmonmodernfatefulencounter @ 0xce
.4byte ScrCmd_setmodernfatefulencounter @ 0xcd
.4byte ScrCmd_checkmodernfatefulencounter @ 0xce
.4byte ScrCmd_trywondercardscript @ 0xcf
.4byte ScrCmd_nop1 @ 0xd0
.4byte ScrCmd_warpspinenter @ 0xd1
Expand Down
3 changes: 3 additions & 0 deletions data/scripts/safari_zone.inc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ SafariZone_EventScript_ChoosePokeblock::
special OpenPokeblockCaseOnFeeder
waitstate
goto_if_ne VAR_RESULT, 0xFFFF, SafariZone_EventScript_PokeblockPlaced
#ifdef BUGFIX
releaseall @ Only gets called from EventScript_PokeBlockFeeder which uses lockall.
#endif
end

SafariZone_EventScript_PokeblockPlaced::
Expand Down
37 changes: 26 additions & 11 deletions gflib/malloc.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "global.h"
#include "malloc.h"

static void *sHeapStart;
static u32 sHeapSize;

ALIGNED(4) EWRAM_DATA u8 gHeap[HEAP_SIZE] = {0};

#define MALLOC_SYSTEM_ID 0xA3A3

struct MemBlock {
Expand Down Expand Up @@ -52,18 +55,24 @@ void *AllocInternal(void *heapStart, u32 size)
if (size & 3)
size = 4 * ((size / 4) + 1);

for (;;) {
for (;;)
{
// Loop through the blocks looking for unused block that's big enough.

if (!pos->flag) {
if (!pos->flag)
{
foundBlockSize = pos->size;

if (foundBlockSize >= size) {
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
if (foundBlockSize >= size)
{
if (foundBlockSize - size < 2 * sizeof(struct MemBlock))
{
// The block isn't much bigger than the requested size,
// so just use it.
pos->flag = TRUE;
} else {
}
else
{
// The block is significantly bigger than the requested
// size, so split the rest into a separate block.
foundBlockSize -= sizeof(struct MemBlock);
Expand Down Expand Up @@ -95,15 +104,18 @@ void *AllocInternal(void *heapStart, u32 size)

void FreeInternal(void *heapStart, void *pointer)
{
if (pointer) {
if (pointer)
{
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
block->flag = FALSE;

// If the freed block isn't the last one, merge with the next block
// if it's not in use.
if (block->next != head) {
if (!block->next->flag) {
if (block->next != head)
{
if (!block->next->flag)
{
block->size += sizeof(struct MemBlock) + block->next->size;
block->next->magic = 0;
block->next = block->next->next;
Expand All @@ -114,8 +126,10 @@ void FreeInternal(void *heapStart, void *pointer)

// If the freed block isn't the first one, merge with the previous block
// if it's not in use.
if (block != head) {
if (!block->prev->flag) {
if (block != head)
{
if (!block->prev->flag)
{
block->prev->next = block->next;

if (block->next != head)
Expand All @@ -132,7 +146,8 @@ void *AllocZeroedInternal(void *heapStart, u32 size)
{
void *mem = AllocInternal(heapStart, size);

if (mem != NULL) {
if (mem != NULL)
{
if (size & 3)
size = 4 * ((size / 4) + 1);

Expand Down
4 changes: 2 additions & 2 deletions gflib/malloc.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef GUARD_ALLOC_H
#define GUARD_ALLOC_H

#define HEAP_SIZE 0x1C000

#define FREE_AND_SET_NULL(ptr) \
{ \
Expand All @@ -11,7 +10,8 @@

#define TRY_FREE_AND_SET_NULL(ptr) if (ptr != NULL) FREE_AND_SET_NULL(ptr)

extern u8 gHeap[];
#define HEAP_SIZE 0x1C000
extern u8 gHeap[HEAP_SIZE];

void *Alloc(u32 size);
void *AllocZeroed(u32 size);
Expand Down
File renamed without changes
File renamed without changes
50 changes: 49 additions & 1 deletion graphics/pokedex/bg_hoenn.pal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
JASC-PAL
0100
48
96
123 131 0
255 255 255
222 222 222
Expand Down Expand Up @@ -49,3 +49,51 @@ JASC-PAL
49 139 255
189 156 90
0 0 0
123 131 0
255 255 255
255 238 0
255 189 0
255 115 0
98 98 115
41 57 65
41 57 106
0 0 41
255 255 255
238 246 57
255 0 189
49 213 74
24 131 32
189 156 90
0 0 0
123 131 0
255 255 255
197 32 32
189 189 189
164 164 164
98 98 115
41 57 65
41 57 106
0 0 41
255 255 255
238 246 57
189 0 0
74 148 180
8 90 131
189 156 90
0 0 0
123 131 0
255 255 255
197 32 32
189 189 189
164 164 164
98 98 115
41 57 65
41 57 106
0 0 41
255 255 255
238 246 57
255 0 189
180 205 246
49 139 255
189 156 90
0 0 0
51 changes: 0 additions & 51 deletions graphics/pokedex/caught_screen.pal

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions graphics/unused/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redyellowgreen_frame.bin
Binary file removed graphics/unused/redyellowgreen_frame.bin
Binary file not shown.
Loading

0 comments on commit 19ad2e1

Please sign in to comment.