Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ else
MODERNCC := $(PREFIX)gcc
PATH_MODERNCC := PATH="$(PATH)" $(MODERNCC)
CC1 := $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
override CFLAGS += -mthumb -mthumb-interwork -O$(O_LEVEL) -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
override CFLAGS += -mthumb -mthumb-interwork -O$(O_LEVEL) -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-strict-aliasing -Wno-pointer-to-int-cast
LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"
LIB := $(LIBPATH) -lc -lnosys -lgcc -L../../libagbsyscall -lagbsyscall
endif
Expand Down Expand Up @@ -293,7 +293,9 @@ $(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
$(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
$(C_BUILDDIR)/m4a.o: CFLAGS += -fno-toplevel-reorder
$(C_BUILDDIR)/librfu_intr.o: CFLAGS := -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-strict-aliasing -Wno-pointer-to-int-cast
$(C_BUILDDIR)/agb_flash.o: CFLAGS += -fno-toplevel-reorder
$(C_BUILDDIR)/berry_crush.o: override CFLAGS += -Wno-address-of-packed-member
endif

Expand Down
3 changes: 2 additions & 1 deletion include/gba/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define GUARD_GBA_TYPES_H

#include <stdint.h>
#include "gba/defines.h"

typedef uint8_t u8;
typedef uint16_t u16;
Expand Down Expand Up @@ -69,7 +70,7 @@ struct OamData
u16 priority:2; // 0x400, 0x800 -> 0xC00
u16 paletteNum:4;
/*0x06*/ u16 affineParam;
};
} ALIGNED(4); // Modern compilers will use wrong align-of sometimes.

#define ST_OAM_HFLIP 0x08
#define ST_OAM_VFLIP 0x10
Expand Down
9 changes: 5 additions & 4 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
#include "constants/easy_chat.h"
#include "constants/trainer_hill.h"

// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");

// to help in decompiling
// Unified Thumb/ARM asm. Modern (Clang): no .syntax divided — Clang rejects it. Legacy agbcc output still expects divided after the block.
#if MODERN
#define asm_unified(x) asm(".syntax unified\n" x)
#else
#define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided")
#endif
#define NAKED __attribute__((naked))

#if MODERN
Expand Down
14 changes: 7 additions & 7 deletions src/multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,16 @@ static void MultiBootWaitCycles(u32 cycles)
{
asm_unified("\
mov r2, pc\n\
lsrs r2, 24\n\
movs r1, 12\n\
cmp r2, 2\n\
lsrs r2, r2, #24\n\
movs r1, #12\n\
cmp r2, #2\n\
beq MultiBootWaitCyclesLoop\n\
movs r1, 13\n\
cmp r2, 8\n\
movs r1, #13\n\
cmp r2, #8\n\
beq MultiBootWaitCyclesLoop\n\
movs r1, 4\n\
movs r1, #4\n\
MultiBootWaitCyclesLoop:\n\
subs r0, r1\n\
subs r0, r0, r1\n\
bgt MultiBootWaitCyclesLoop\n\
bx lr\n");
}
Expand Down