Skip to content

Commit

Permalink
Fix issues when building tests with agbcc (#4689)
Browse files Browse the repository at this point in the history
* fix build errors with agbcc

* make clean removes build/test and build/modern-test regardless of MODERN setting
  • Loading branch information
u8-Salem authored Jun 2, 2024
1 parent 86b7613 commit 2d1ef1f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ ELF = $(ROM:.gba=.elf)
MAP = $(ROM:.gba=.map)
SYM = $(ROM:.gba=.sym)

TEST_OBJ_DIR_NAME_MODERN := build/modern-test
TEST_OBJ_DIR_NAME_AGBCC := build/test

ifeq ($(MODERN),0)
TEST_OBJ_DIR_NAME := build/test
TEST_OBJ_DIR_NAME := $(TEST_OBJ_DIR_NAME_AGBCC)
else
TEST_OBJ_DIR_NAME := build/modern-test
TEST_OBJ_DIR_NAME := $(TEST_OBJ_DIR_NAME_MODERN)
endif
TESTELF = $(ROM:.gba=-test.elf)
HEADLESSELF = $(ROM:.gba=-test-headless.elf)
Expand Down Expand Up @@ -309,7 +312,9 @@ tidymodern:

tidycheck:
rm -f $(TESTELF) $(HEADLESSELF)
rm -rf $(TEST_OBJ_DIR_NAME)
rm -rf $(TEST_OBJ_DIR_NAME_MODERN)
rm -rf $(TEST_OBJ_DIR_NAME_AGBCC)


ifneq ($(MODERN),0)
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
Expand Down
15 changes: 11 additions & 4 deletions test/species.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ TEST("Form species ID tables are shared between all forms")
{
u32 i;
u32 species = SPECIES_NONE;
const u16 *formSpeciesIdTable;

for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formSpeciesIdTable) PARAMETRIZE { species = i; }
}

const u16 *formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
for (i = 0; formSpeciesIdTable[i] != FORM_SPECIES_END; i++)
{
u32 formSpeciesId = formSpeciesIdTable[i];
Expand All @@ -23,13 +25,16 @@ TEST("Form change tables contain only forms in the form species ID table")
{
u32 i, j;
u32 species = SPECIES_NONE;
const struct FormChange *formChangeTable;
const u16 *formSpeciesIdTable;

for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formChangeTable) PARAMETRIZE { species = i; }
}

const struct FormChange *formChangeTable = gSpeciesInfo[species].formChangeTable;
const u16 *formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
formChangeTable = gSpeciesInfo[species].formChangeTable;
formSpeciesIdTable = gSpeciesInfo[species].formSpeciesIdTable;
EXPECT(formSpeciesIdTable);

for (i = 0; formChangeTable[i].method != FORM_CHANGE_TERMINATOR; i++)
Expand All @@ -51,12 +56,14 @@ TEST("Form change targets have the appropriate species flags")
{
u32 i;
u32 species = SPECIES_NONE;
const struct FormChange *formChangeTable;

for (i = 0; i < NUM_SPECIES; i++)
{
if (gSpeciesInfo[i].formChangeTable) PARAMETRIZE { species = i; }
}

const struct FormChange *formChangeTable = gSpeciesInfo[species].formChangeTable;
formChangeTable = gSpeciesInfo[species].formChangeTable;
for (i = 0; formChangeTable[i].method != FORM_CHANGE_TERMINATOR; i++)
{
const struct SpeciesInfo *targetSpeciesInfo = &gSpeciesInfo[formChangeTable[i].targetSpecies];
Expand Down
4 changes: 4 additions & 0 deletions test/test_runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ static s32 MgbaVPrintf_(const char *fmt, va_list va)
/* Entry point for the Debugging and Control System. Handles illegal
* instructions, which are typically caused by branching to an invalid
* address. */
#if MODERN
__attribute__((naked, section(".dacs"), target("arm")))
#else
__attribute__((naked, section(".dacs")))
#endif
void DACSEntry(void)
{
asm(".arm\n\
Expand Down

0 comments on commit 2d1ef1f

Please sign in to comment.