diff --git a/Makefile b/Makefile index a7cf50d..3d2558b 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ export INCLUDE := -I"$(shell pwd)/common" export ASFLAGS := -g -x assembler-with-cpp $(INCLUDE) export CFLAGS := -DDBUILTS="\"$(DBUILTS)\"" -DDBUILTL="\"$(DBUILTL)\"" -DVERSION="\"$(VERSION)\"" -DFLAVOR="\"$(FLAVOR)\"" \ - -g -O2 -Wall -Wextra -Wpedantic -Wcast-align -Wformat=2 -Wno-main \ + -g -Os -Wall -Wextra -Wpedantic -Wcast-align -Wformat=2 -Wno-main \ -fomit-frame-pointer -ffast-math -std=gnu11 -MMD -MP \ -Wno-unused-function -Wno-format-truncation $(INCLUDE) -ffunction-sections -fdata-sections export LDFLAGS := -Tlink.ld -nostartfiles -Wl,--gc-sections,-z,max-page-size=512 diff --git a/arm11/source/main.c b/arm11/source/main.c index 84fe7c2..2a37508 100644 --- a/arm11/source/main.c +++ b/arm11/source/main.c @@ -151,12 +151,13 @@ void PXI_RX_Handler(u32 __attribute__((unused)) irqn) void __attribute__((noreturn)) MainLoop(void) { // enable PXI RX interrupt - GIC_Enable(PXI_RX_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO, PXI_RX_Handler); + GIC_Enable(PXI_RX_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO + 2, PXI_RX_Handler); // enable MCU interrupts GIC_Enable(MCU_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO + 1, MCU_HandleInterrupts); - GIC_Enable(VBLANK_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO + 2, VBlank_Handler); + // set up VBlank interrupt to always have the highest priority + GIC_Enable(VBLANK_INTERRUPT, BIT(0), GIC_HIGHEST_PRIO, VBlank_Handler); // ARM9 won't try anything funny until this point PXI_Barrier(ARM11_READY_BARRIER); diff --git a/arm9/source/crypto/crc32.c b/arm9/source/crypto/crc32.c index b73b7a6..6245ce3 100644 --- a/arm9/source/crypto/crc32.c +++ b/arm9/source/crypto/crc32.c @@ -2,8 +2,9 @@ // https://github.com/eai04191/beat/blob/master/nall/crc32.hpp // Ported by Hyarion for use with VirtualFatFS -#include "crc32.h" #include "common.h" +#include "crc32.h" +#include "vff.h" u32 crc32_adjust(u32 crc32, u8 input) { static const u32 crc32_table[256] = { diff --git a/arm9/source/crypto/crc32.h b/arm9/source/crypto/crc32.h index 2a92d31..5f3c1a0 100644 --- a/arm9/source/crypto/crc32.h +++ b/arm9/source/crypto/crc32.h @@ -3,7 +3,8 @@ // Ported by Hyarion for use with VirtualFatFS #pragma once -#include "vff.h" + +#include "common.h" u32 crc32_adjust(u32 crc32, u8 input); u32 crc32_calculate(u32 crc32, const u8* data, u32 length); diff --git a/arm9/source/game/codelzss.c b/arm9/source/game/codelzss.c index 7a75393..16d4014 100644 --- a/arm9/source/game/codelzss.c +++ b/arm9/source/game/codelzss.c @@ -215,7 +215,7 @@ void slideByte(sCompressInfo* a_pInfo, const u8* a_pSrc) { } } -inline void slide(sCompressInfo* a_pInfo, const u8* a_pSrc, int a_nSize) { +static inline void slide(sCompressInfo* a_pInfo, const u8* a_pSrc, int a_nSize) { for (int i = 0; i < a_nSize; i++) { slideByte(a_pInfo, a_pSrc--); } diff --git a/arm9/source/gamecart/protocol.c b/arm9/source/gamecart/protocol.c index 5685664..db08305 100644 --- a/arm9/source/gamecart/protocol.c +++ b/arm9/source/gamecart/protocol.c @@ -36,13 +36,6 @@ static u32 A0_Response = 0xFFFFFFFFu; static u32 rand1 = 0; static u32 rand2 = 0; -u32 BSWAP32(u32 val) { - return (((val >> 24) & 0xFF)) | - (((val >> 16) & 0xFF) << 8) | - (((val >> 8) & 0xFF) << 16) | - ((val & 0xFF) << 24); -} - // updated function by profi200 static void ResetCardSlot(void) { diff --git a/arm9/source/gamecart/protocol.h b/arm9/source/gamecart/protocol.h index b785189..bcb8935 100644 --- a/arm9/source/gamecart/protocol.h +++ b/arm9/source/gamecart/protocol.h @@ -12,8 +12,8 @@ #define LATENCY 0x822Cu +#define BSWAP32(n) __builtin_bswap32(n) -u32 BSWAP32(u32 val); void Cart_Init(void); int Cart_IsInserted(void); diff --git a/arm9/source/lodepng/lodepng.h b/arm9/source/lodepng/lodepng.h index 8e0f742..ba8c41a 100644 --- a/arm9/source/lodepng/lodepng.h +++ b/arm9/source/lodepng/lodepng.h @@ -39,6 +39,18 @@ compiler command to disable them without modifying this header, e.g. In addition to those below, you can also define LODEPNG_NO_COMPILE_CRC to allow implementing a custom lodepng_crc32. */ + +#define LODEPNG_NO_COMPILE_CRC +#define LODEPNG_NO_COMPILE_DISK +#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS +#define LODEPNG_NO_COMPILE_ERROR_TEXT + +#include "crc32.h" +static inline unsigned lodepng_crc32(const unsigned char *data, size_t length) +{ + return crc32_calculate(0, data, length); +} + /*deflate & zlib. If disabled, you must specify alternative zlib functions in the custom_zlib field of the compress and decompress settings*/ #ifndef LODEPNG_NO_COMPILE_ZLIB diff --git a/common/arm.h b/common/arm.h index 67a4fb0..28fc084 100644 --- a/common/arm.h +++ b/common/arm.h @@ -18,6 +18,7 @@ #define SR_NOINT (SR_NOFIQ | SR_NOIRQ) #ifdef ARM9 + #define CPU_FREQ (134055928) #define CR_MPU BIT(0) #define CR_DCACHE BIT(2) #define CR_ICACHE BIT(12) @@ -38,6 +39,7 @@ #define MAX_IRQ (32) #define MAX_CPU (1) #else // ARM11 + #define CPU_FREQ (268111856) #define CR_MMU BIT(0) #define CR_ALIGN BIT(1) #define CR_DCACHE BIT(2)