foo
[gbajam21] / src / debug.c
index 14e00c0..d4c2426 100644 (file)
@@ -1,7 +1,35 @@
 #include <stdio.h>
 #include <stdarg.h>
+#include "gbaregs.h"
+#include "intr.h"
 #include "debug.h"
 
+uint16_t vblperf_color[] = {0x3e0, 0xffc0, 0x3ff, 0x1ff, 0x001f, 0xf81f};
+
+static void vblperf_intr(void)
+{
+       vblperf_count++;
+}
+
+void vblperf_start(int palidx)
+{
+       vblperf_palptr = (uint16_t*)CRAM_BG_ADDR + palidx;
+       intr_disable();
+       REG_DISPSTAT |= DISPSTAT_IEN_VBLANK;
+       interrupt(INTR_VBLANK, vblperf_intr);
+       unmask(INTR_VBLANK);
+       intr_enable();
+}
+
+void vblperf_stop(void)
+{
+       intr_disable();
+       REG_DISPSTAT &= ~DISPSTAT_IEN_VBLANK;
+       interrupt(INTR_VBLANK, 0);
+       mask(INTR_VBLANK);
+       intr_enable();
+}
+
 #ifdef EMUBUILD
 __attribute__((target("arm")))
 void emuprint(const char *fmt, ...)