static void gamescr_frame(void);
static void gamescr_vblank(void);
-static void update(void);
+static int update(void);
static void draw(void);
static struct screen gamescr = {
prev_iwram_top = iwram_sbrk(0);
gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1);
+ fillblock_16byte(gba_vram_lfb1, 0, 240 * 160 / 16);
vblperf_setcolor(0);
num_enemies = total_enemies = 0;
energy = 5;
- srand(0);
+ memset(enemies, 0, sizeof enemies);
cptr = color_pixels;
for(i=0; i<VOX_SZ; i++) {
for(j=0; j<VOX_SZ; j++) {
vox_objects((struct vox_object*)enemies, total_enemies, sizeof *enemies);
+ energy = MAX_ENERGY;
+ xform_sa = 0;
+ xform_ca = 0x10000;
+ xform_s = 0x100;
+
+ vblcount = 0;
nframes = 0;
return 0;
}
static void gamescr_stop(void)
{
iwram_brk(prev_iwram_top);
+
+ wait_vblank();
+ /* clear sprites */
+ spr_clear();
+ /* reset background rot/scale state */
+ REG_BG2X = 0;
+ REG_BG2Y = 0;
+ REG_BG2PA = 0x100;
+ REG_BG2PB = 0;
+ REG_BG2PC = 0;
+ REG_BG2PD = 0x100;
+
}
static void gamescr_frame(void)
vox_framebuf(240, 160, framebuf, horizon);
- update();
+ if(update() == -1) {
+ return;
+ }
draw();
vblperf_end();
#define TURN_SPEED 0x200
#define ELEV_SPEED 8
-static void update(void)
+static int update(void)
{
int32_t fwd[2], right[2];
int i, snum, ledspr;
if(KEYPRESS(BN_START)) {
/* TODO pause menu */
change_screen(find_screen("menu"));
+ return -1;
}
if(keystate) {
mask(INTR_VBLANK);
dynspr_count = snum;
unmask(INTR_VBLANK);
+
+ return 0;
}
static void draw(void)
#define present(x) \
do { \
- REG_DISPCNT = (REG_DISPCNT & ~DISPCNT_FB1) | ((x) << 4); \
+ REG_DISPCNT = (REG_DISPCNT & 0xffef) | ((x) << 4); \
} while(0)
#define ARM_IWRAM __attribute__((noinline, target("arm"), section(".iwram")))