Skip to content

Commit

Permalink
Remove NONMATCHING
Browse files Browse the repository at this point in the history
-fprologue-bugfix has now been added

Also, pokedex_end.c still has issues :(
  • Loading branch information
WhenGryphonsFly committed Aug 13, 2023
1 parent 299eae4 commit 24a95e8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 207 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR)
ASFLAGS := -mcpu=arm7tdmi

CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -fprologue-bugfix

CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -nostdinc -undef

Expand Down Expand Up @@ -144,9 +144,7 @@ include graphics_rules.mk
%.rl: % ; $(GFX) $< $@

# TODO: these "match" under old_agbcc, but the true compiler is agbcc -fprologue-bugfix
$(C_BUILDDIR)/rom_850.o: CC1 := tools/agbcc/bin/old_agbcc
$(C_BUILDDIR)/gbplayer.o: CC1 := tools/agbcc/bin/old_agbcc

$(C_BUILDDIR)/m4a.o: CFLAGS := -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc

$(C_BUILDDIR)/agb_sram.o: CFLAGS := -mthumb-interwork -Wimplicit -Wparentheses -Werror -O1
Expand Down
150 changes: 0 additions & 150 deletions src/gbplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
sGbPlayerCurKeys = keyInput;
}

#ifdef NONMATCHING
/* This matches under agbcc. However, until -fprologue-bugfix is merged in,
this file is compiled under old_agbcc because otherwise multiple functions
would be NONMATCHING. */
static u8 CheckGameBoyPlayer(void)
{
u32 i;
Expand Down Expand Up @@ -83,152 +79,6 @@ static u8 CheckGameBoyPlayer(void)
else
return 0;
}
#else
NAKED
static u8 CheckGameBoyPlayer(void)
{
asm_unified("\n\
push {r4, r5, r6, r7, lr}\n\
mov r7, sl\n\
mov r6, sb\n\
mov r5, r8\n\
push {r5, r6, r7}\n\
movs r7, #0\n\
movs r0, #0\n\
mov sl, r0\n\
mov sb, r0\n\
mov r8, r0\n\
bl VBlankIntrWait\n\
ldr r0, _08000F30 @ =0x040000D4\n\
ldr r1, _08000F34 @ =0x08058248\n\
str r1, [r0]\n\
ldr r1, _08000F38 @ =0x06008000\n\
str r1, [r0, #4]\n\
ldr r1, _08000F3C @ =0x80002000\n\
str r1, [r0, #8]\n\
ldr r1, [r0, #8]\n\
ldr r1, _08000F40 @ =0x08058048\n\
str r1, [r0]\n\
movs r1, #0xa0\n\
lsls r1, r1, #0x13\n\
str r1, [r0, #4]\n\
ldr r1, _08000F44 @ =0x80000100\n\
str r1, [r0, #8]\n\
ldr r1, [r0, #8]\n\
ldr r1, _08000F48 @ =0x0805C248\n\
str r1, [r0]\n\
ldr r2, _08000F4C @ =0x02002008\n\
str r2, [r0, #4]\n\
ldr r1, _08000F50 @ =0x80000280\n\
str r1, [r0, #8]\n\
ldr r1, [r0, #8]\n\
str r2, [r0]\n\
movs r1, #0xc0\n\
lsls r1, r1, #0x13\n\
str r1, [r0, #4]\n\
ldr r1, _08000F54 @ =0x80000400\n\
str r1, [r0, #8]\n\
ldr r0, [r0, #8]\n\
ldr r1, _08000F58 @ =0x04000008\n\
movs r0, #0x88\n\
strh r0, [r1]\n\
movs r4, #0\n\
ldr r6, _08000F5C @ =0x04000054\n\
movs r5, #0x10\n\
_08000F18:\n\
bl VBlankIntrWait\n\
subs r0, r5, r4\n\
strh r0, [r6]\n\
adds r4, #1\n\
cmp r4, #0x10\n\
bls _08000F18\n\
ldr r6, _08000F60 @ =0x02002002\n\
ldr r5, _08000F64 @ =0x02002000\n\
ldr r4, _08000F30 @ =0x040000D4\n\
b _08000FA4\n\
.align 2, 0\n\
_08000F30: .4byte 0x040000D4\n\
_08000F34: .4byte 0x08058248\n\
_08000F38: .4byte 0x06008000\n\
_08000F3C: .4byte 0x80002000\n\
_08000F40: .4byte 0x08058048\n\
_08000F44: .4byte 0x80000100\n\
_08000F48: .4byte 0x0805C248\n\
_08000F4C: .4byte 0x02002008\n\
_08000F50: .4byte 0x80000280\n\
_08000F54: .4byte 0x80000400\n\
_08000F58: .4byte 0x04000008\n\
_08000F5C: .4byte 0x04000054\n\
_08000F60: .4byte 0x02002002\n\
_08000F64: .4byte 0x02002000\n\
_08000F68:\n\
ldrh r0, [r6]\n\
ldrh r1, [r5]\n\
eors r0, r1\n\
ands r0, r1\n\
movs r1, #0xf0\n\
ands r0, r1\n\
cmp r0, #0xf0\n\
bne _08000F7C\n\
mov r8, sb\n\
mov sb, r7\n\
_08000F7C:\n\
mov r1, r8\n\
cmp r1, #0\n\
beq _08000F8E\n\
mov r2, sb\n\
subs r0, r2, r1\n\
cmp r0, #3\n\
bgt _08000F8E\n\
movs r0, #1\n\
mov sl, r0\n\
_08000F8E:\n\
adds r7, #1\n\
bl VBlankIntrWait\n\
ldr r0, _08000FB0 @ =0x02002008\n\
str r0, [r4]\n\
movs r0, #0xc0\n\
lsls r0, r0, #0x13\n\
str r0, [r4, #4]\n\
ldr r0, _08000FB4 @ =0x84000200\n\
str r0, [r4, #8]\n\
ldr r0, [r4, #8]\n\
_08000FA4:\n\
cmp r7, #0x1d\n\
bgt _08000FB8\n\
bl ReadGbPlayerKeys\n\
b _08000F68\n\
.align 2, 0\n\
_08000FB0: .4byte 0x02002008\n\
_08000FB4: .4byte 0x84000200\n\
_08000FB8:\n\
movs r4, #0\n\
ldr r5, _08000FD4 @ =0x04000054\n\
_08000FBC:\n\
bl VBlankIntrWait\n\
strh r4, [r5]\n\
adds r4, #1\n\
cmp r4, #0x10\n\
bls _08000FBC\n\
mov r1, sl\n\
cmp r1, #0\n\
bne _08000FD8\n\
movs r0, #0\n\
b _08000FDA\n\
.align 2, 0\n\
_08000FD4: .4byte 0x04000054\n\
_08000FD8:\n\
movs r0, #1\n\
_08000FDA:\n\
pop {r3, r4, r5}\n\
mov r8, r3\n\
mov sb, r4\n\
mov sl, r5\n\
pop {r4, r5, r6, r7}\n\
pop {r1}\n\
bx r1");
}
#endif // NONMATCHING

void InitGameBoyPlayer(void)
{
Expand Down
21 changes: 0 additions & 21 deletions src/rom_1068C.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,10 @@ void sub_10860(void (*func)(void))
MainLoopIter();
}

#ifdef NONMATCHING
// Like sub_0C24, it matches except for that damn 'push {lr}/pop {lr}'
void ClearSomeArray(void)
{
int i;

for (i = 0; i < 4; i++)
gUnknown_0201A500[i] = 0;
}
#else
NAKED
void ClearSomeArray(void)
{
asm_unified("\n\
ldr r1, _08010920 @ =gUnknown_0201A500\n\
movs r2, #0\n\
adds r0, r1, #0\n\
adds r0, #0xc\n\
_08010914:\n\
str r2, [r0]\n\
subs r0, #4\n\
cmp r0, r1\n\
bge _08010914\n\
bx lr\n\
.align 2, 0\n\
_08010920: .4byte gUnknown_0201A500");
}
#endif
32 changes: 0 additions & 32 deletions src/rom_528AC.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ extern const u16 gUnknown_08527F18[];
static void sub_52940(u16, s8, s8, u8, int);
static u16 LoadSaveDataFromSram(void);

#ifdef NONMATCHING
// Like sub_0C24, it matches except for that damn 'push {lr}/pop {lr}'
int sub_528AC(u16 a)
{
if (a <= 0xFA)
Expand All @@ -18,36 +16,6 @@ int sub_528AC(u16 a)
return 0xC8;
return gUnknown_08527F18[a - 0x114];
}
#else
NAKED
int sub_528AC(u16 a)
{
asm_unified("\n\
lsls r0, r0, #0x10\n\
lsrs r0, r0, #0x10\n\
adds r1, r0, #0\n\
cmp r0, #0xfa\n\
bls _080528DA\n\
ldr r0, _080528CC @ =0x00000113\n\
cmp r1, r0\n\
bls _080528D8\n\
ldr r0, _080528D0 @ =gUnknown_08527F18\n\
ldr r2, _080528D4 @ =0xFFFFFEEC\n\
adds r1, r1, r2\n\
lsls r1, r1, #1\n\
adds r1, r1, r0\n\
ldrh r0, [r1]\n\
b _080528DA\n\
.align 2, 0\n\
_080528CC: .4byte 0x00000113\n\
_080528D0: .4byte gUnknown_08527F18\n\
_080528D4: .4byte 0xFFFFFEEC\n\
_080528D8:\n\
movs r0, #0xc8\n\
_080528DA:\n\
bx lr");
}
#endif

void sub_528DC(u16 a, s8 b)
{
Expand Down

0 comments on commit 24a95e8

Please sign in to comment.