mov r0, lr
bx lr
+ .globl get_sp
+get_sp:
+ mov r0, sp
+ bx lr
.arm
.extern panic_regs
uint32_t panic_regs[16];
void get_panic_regs(void);
-void panic(uint32_t pc, const char *fmt, ...)
+void panic(void *pc, const char *fmt, ...)
{
int y;
va_list ap;
fillblock_16byte((void*)VRAM_LFB_FB0_ADDR, 0, 240 * 160 / 16);
fillblock_16byte((unsigned char*)VRAM_LFB_FB0_ADDR + 240 * 3, 0xffffffff, 240 / 16);
- dbg_drawstr(44, 0, " Panic at %08x ", pc);
+ dbg_drawstr(44, 0, " Panic at %p ", pc);
va_start(ap, fmt);
y = dbg_vdrawstr(0, 12, fmt, ap) + 8;
} while(0)
-void panic(uint32_t pc, const char *fmt, ...);
+void panic(void *pc, const char *fmt, ...) __attribute__((noreturn));
void dbg_drawglyph(int x, int y, int c);
int dbg_drawstr(int x, int y, const char *fmt, ...);
#include "intr.h"
#include "debug.h"
-static unsigned char tex[32 * 32] __attribute__((section(".iwram")));
+static unsigned char *tex;//[32 * 32] __attribute__((section(".iwram")));
void gamescr(void)
{
fillblock_16byte(vram[0], 0xffffffff, 240 * 160 / 16);
fillblock_16byte(vram[1], 0xffffffff, 240 * 160 / 16);
+ tex = iwram_sbrk(32 * 32);
memcpy(tex, tuncross_pixels, 32 * 32);
nframes = 0;
--- /dev/null
+#include "util.h"
+#include "debug.h"
+
+extern char __data_end__;
+static char *top = &__data_end__;
+
+int iwram_brk(void *addr)
+{
+ if(addr < &__data_end__) {
+ addr = &__data_end__;
+ }
+ if(addr > get_sp()) {
+ /*return -1;*/
+ panic(get_pc(), "iwram_brk (%p) >= sp", addr);
+ }
+ top = addr;
+ return 0;
+}
+
+void *iwram_sbrk(intptr_t delta)
+{
+ void *prev = top;
+ iwram_brk(top + delta);
+ return prev;
+}
#ifndef UTIL_H_
#define UTIL_H_
+#include <stdint.h>
+
#define wait_vblank() \
do { \
while(REG_DISPSTAT & DISPSTAT_VBLANK); \
((uint16_t*)CRAM_BG_ADDR)[idx] = (uint16_t)(r) | ((uint16_t)(g) << 5) | ((uint16_t)(b) << 10); \
} while(0)
+int iwram_brk(void *addr);
+void *iwram_sbrk(intptr_t delta);
void fillblock_16byte(void *dest, uint32_t val, int count);
-uint32_t get_pc(void);
+void *get_pc(void);
+void *get_sp(void);
#endif /* UTIL_H_ */