aboutsummaryrefslogtreecommitdiffstats
path: root/src/gba
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-22 18:45:35 +0200
committerBad Diode <bd@badd10de.dev>2023-04-22 18:45:35 +0200
commitd4fe4d95f105d8b9b47d26264c4876cbf4095a5d (patch)
treec85cee096603ab54301537add8f7d6e231bdbd81 /src/gba
parent320690edaff025d4d446e2f67d23304e1810196e (diff)
downloadstepper-d4fe4d95f105d8b9b47d26264c4876cbf4095a5d.tar.gz
stepper-d4fe4d95f105d8b9b47d26264c4876cbf4095a5d.zip
Prepare profiling macros
Diffstat (limited to 'src/gba')
-rw-r--r--src/gba/gba.h31
1 files changed, 21 insertions, 10 deletions
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;
98typedef Color Palette[16]; 98typedef Color Palette[16];
99 99
100// Inline function to calculate the 15 bit color value. 100// Inline function to calculate the 15 bit color value.
101#define RGB15(R,G,B) (u16)(((B) << 10) | ((G) << 5) | (R)); 101#define RGB15(R,G,B) (u16)(((B) << 10) | ((G) << 5) | (R))
102 102
103// Some nice default colors. 103// Some nice default colors.
104#define COLOR_BLACK RGB15(0, 0, 0) 104#define COLOR_BLACK RGB15( 0, 0, 0)
105#define COLOR_RED RGB15(31, 0,10) 105#define COLOR_RED RGB15(31, 0, 10)
106#define COLOR_GREEN RGB15(31, 0,10) 106#define COLOR_GREEN RGB15( 0, 31, 18)
107#define COLOR_YELLOW RGB15(31, 0,10) 107#define COLOR_YELLOW RGB15(31, 31, 0)
108#define COLOR_BLUE RGB15(2, 17,31) 108#define COLOR_BLUE RGB15( 2, 17, 31)
109#define COLOR_PURPLE RGB15(2, 17,31) 109#define COLOR_PURPLE RGB15(15, 7, 31)
110#define COLOR_CYAN RGB15(0, 27,30) 110#define COLOR_CYAN RGB15( 0, 27, 30)
111#define COLOR_GREY RGB15(16,17,19) 111#define COLOR_GREY RGB15(16, 17, 19)
112#define COLOR_WHITE RGB15(28,28,28) 112#define COLOR_WHITE RGB15(28, 28, 28)
113 113
114// 114//
115// Tile memory access. 115// Tile memory access.
@@ -419,6 +419,8 @@ inline
419void 419void
420dma_copy(void *dst, const void *src, u32 size, int channel) { 420dma_copy(void *dst, const void *src, u32 size, int channel) {
421 dma_transfer_copy(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE); 421 dma_transfer_copy(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE);
422 // Stall for 2 cycles in case we call this function more than once.
423 asm("nop"); asm("nop");
422} 424}
423 425
424// Fill the dst location with the word set at src. 426// Fill the dst location with the word set at src.
@@ -426,6 +428,8 @@ inline
426void 428void
427dma_fill(void *dst, vu32 src, u32 size, int channel) { 429dma_fill(void *dst, vu32 src, u32 size, int channel) {
428 dma_transfer_fill(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE); 430 dma_transfer_fill(dst, src, size / 4, channel, DMA_CHUNK_32 | DMA_ENABLE);
431 // Stall for 2 cycles in case we call this function more than once.
432 asm("nop"); asm("nop");
429} 433}
430 434
431// 435//
@@ -661,6 +665,7 @@ wait_vsync(void) {
661#define LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0])) 665#define LEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
662 666
663// Fixed-point arithmetic for (i.P) numbers. 667// Fixed-point arithmetic for (i.P) numbers.
668#define FP_NUM(A,P) ((A) << (P))
664#define FP_MUL(A,B,P) (((A) * (B)) >> (P)) 669#define FP_MUL(A,B,P) (((A) * (B)) >> (P))
665#define FP_DIV(A,B,P) (((A) << (P)) / (B)) 670#define FP_DIV(A,B,P) (((A) << (P)) / (B))
666#define FP_LERP(Y0,Y1,X,P) ((Y0) + FP_MUL((X), ((Y1) - (Y0)), P)) 671#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) {
683 } 688 }
684} 689}
685 690
691//
692// Compiler hints.
693//
694
695#define UNROLL_LOOPS __attribute__((optimize("unroll-loops")))
696
686#endif // GBA_H 697#endif // GBA_H