From d4fe4d95f105d8b9b47d26264c4876cbf4095a5d Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 22 Apr 2023 18:45:35 +0200 Subject: Prepare profiling macros --- src/gba/gba.h | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/gba') diff --git a/src/gba/gba.h b/src/gba/gba.h index b02d745..27a6a9a 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -98,18 +98,18 @@ typedef u16 Color; typedef Color Palette[16]; // Inline function to calculate the 15 bit color value. -#define RGB15(R,G,B) (u16)(((B) << 10) | ((G) << 5) | (R)); +#define RGB15(R,G,B) (u16)(((B) << 10) | ((G) << 5) | (R)) // Some nice default colors. -#define COLOR_BLACK RGB15(0, 0, 0) -#define COLOR_RED RGB15(31, 0,10) -#define COLOR_GREEN RGB15(31, 0,10) -#define COLOR_YELLOW RGB15(31, 0,10) -#define COLOR_BLUE RGB15(2, 17,31) -#define COLOR_PURPLE RGB15(2, 17,31) -#define COLOR_CYAN RGB15(0, 27,30) -#define COLOR_GREY RGB15(16,17,19) -#define COLOR_WHITE RGB15(28,28,28) +#define COLOR_BLACK RGB15( 0, 0, 0) +#define COLOR_RED RGB15(31, 0, 10) +#define COLOR_GREEN RGB15( 0, 31, 18) +#define COLOR_YELLOW RGB15(31, 31, 0) +#define COLOR_BLUE RGB15( 2, 17, 31) +#define COLOR_PURPLE RGB15(15, 7, 31) +#define COLOR_CYAN RGB15( 0, 27, 30) +#define COLOR_GREY RGB15(16, 17, 19) +#define COLOR_WHITE RGB15(28, 28, 28) // // Tile memory access. @@ -419,6 +419,8 @@ inline void dma_copy(void *dst, const void *src, u32 size, int channel) { dma_transfer_copy(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE); + // Stall for 2 cycles in case we call this function more than once. + asm("nop"); asm("nop"); } // Fill the dst location with the word set at src. @@ -426,6 +428,8 @@ inline void dma_fill(void *dst, vu32 src, u32 size, int channel) { dma_transfer_fill(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE); + // Stall for 2 cycles in case we call this function more than once. + asm("nop"); asm("nop"); } // @@ -661,6 +665,7 @@ wait_vsync(void) { #define LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0])) // Fixed-point arithmetic for (i.P) numbers. +#define FP_NUM(A,P) ((A) << (P)) #define FP_MUL(A,B,P) (((A) * (B)) >> (P)) #define FP_DIV(A,B,P) (((A) << (P)) / (B)) #define FP_LERP(Y0,Y1,X,P) ((Y0) + FP_MUL((X), ((Y1) - (Y0)), P)) @@ -683,4 +688,10 @@ memcpy32(u32 *dst, const u32 *src, u32 size) { } } +// +// Compiler hints. +// + +#define UNROLL_LOOPS __attribute__((optimize("unroll-loops"))) + #endif // GBA_H -- cgit v1.2.1