diff options
Diffstat (limited to 'src/gba')
-rw-r--r-- | src/gba/gba.h | 31 |
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; | |||
98 | typedef Color Palette[16]; | 98 | typedef 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 | |||
419 | void | 419 | void |
420 | dma_copy(void *dst, const void *src, u32 size, int channel) { | 420 | dma_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 | |||
426 | void | 428 | void |
427 | dma_fill(void *dst, vu32 src, u32 size, int channel) { | 429 | dma_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 |