added logo splash screen
[gbajam22] / src / util.h
index 3bbafbd..6902d64 100644 (file)
@@ -5,6 +5,9 @@
 #include <stdint.h>
 #include "gba.h"
 
+#define RGB555(r, g, b)        \
+       (((r) >> 3) | (((g) << 2) & 0x3e0) | (((b) << 7) & 0x7c00))
+
 #ifdef BUILD_GBA
 
 #define wait_vblank() \
 
 #define present(x) \
        do { \
-               REG_DISPCNT = DISPCNT_BG2 | DISPCNT_OBJ | 4 | ((x) << 4); \
+               REG_DISPCNT = (REG_DISPCNT & 0xffef) | ((x) << 4); \
        } while(0)
 
+#define ARM_IWRAM      __attribute__((noinline, target("arm"), section(".iwram")))
+
 #else  /* non-GBA build */
 #define wait_vblank()
 
 void present(int buf);         /* defined in src/pc/main.c */
+
+#define ARM_IWRAM
 #endif
 
 #define set_bg_color(idx, r, g, b) \
@@ -29,8 +36,14 @@ void present(int buf);               /* defined in src/pc/main.c */
 
 extern int16_t sinlut[];
 
-#define SIN(x) sinlut[(x) & 0xff]
-#define COS(x) sinlut[((x) + 64) & 0xff]
+#define SINLUT_BITS            8
+#define SINLUT_SIZE            (1 << SINLUT_BITS)
+
+#define SIN(angle) \
+       ((int32_t)sinlut[((angle) >> (16 - SINLUT_BITS)) & (SINLUT_SIZE - 1)] << 1)
+
+#define COS(angle) \
+       ((int32_t)sinlut[(((angle) >> (16 - SINLUT_BITS)) + (SINLUT_SIZE / 4)) & (SINLUT_SIZE - 1)] << 1)
 
 int iwram_brk(void *addr);
 void *iwram_sbrk(intptr_t delta);