X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=cc089f22a8f0326272de7b0c67f56657b61b4287;hb=53c0ee3332822465be7dcf923ca3c6445076b555;hp=a84aa123b48154843fb22d079d16b4d3f87af545;hpb=198dd3b315f6e04fe6843d4d371e97e5d60e6309;p=gbajam22 diff --git a/src/gamescr.c b/src/gamescr.c index a84aa12..cc089f2 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -36,8 +36,9 @@ struct enemy { struct vox_object vobj; short hp; short anm; - short last_fire; + int last_fire; }; +#define ENEMY_VALID(e) ((e)->anm != 0) static uint16_t *framebuf; @@ -45,7 +46,6 @@ static int nframes, backbuf; static uint16_t *vram[] = { gba_vram_lfb0, gba_vram_lfb1 }; static int32_t pos[2], angle, horizon = 80; -static struct voxscape *vox; #define COLOR_HORIZON 192 #define COLOR_ZENITH 255 @@ -55,7 +55,7 @@ static uint16_t oam[4 * MAX_SPR]; static int dynspr_base, dynspr_count; -#define MAX_ENEMIES 64 +#define MAX_ENEMIES (255 - CMAP_SPAWN0) struct enemy enemies[MAX_ENEMIES]; int num_enemies, total_enemies; static int energy; @@ -68,6 +68,7 @@ static int32_t xform_sa, xform_ca; /* for viewport bank/zoom */ static int xform_s; static short vblcount; +static void *prev_iwram_top; static inline void xform_pixel(int *xp, int *yp); @@ -80,21 +81,21 @@ struct screen *init_game_screen(void) static int gamescr_start(void) { - int i, sidx; + int i, j, sidx; + uint8_t *cptr; + struct enemy *enemy; + + prev_iwram_top = iwram_sbrk(0); gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1); vblperf_setcolor(0); - pos[0] = VOX_SZ << 15; - pos[1] = (VOX_SZ << 15) + 0x100000; - angle = 0x8000; + pos[0] = pos[1] = VOX_SZ << 15; - if(!(vox = vox_create(VOX_SZ, VOX_SZ, height_pixels, color_pixels))) { - panic(get_pc(), "vox_create"); - } - vox_proj(vox, FOV, NEAR, FAR); - vox_view(vox, pos[0], pos[1], -40, angle); + vox_init(VOX_SZ, VOX_SZ, height_pixels, color_pixels); + vox_proj(FOV, NEAR, FAR); + vox_view(pos[0], pos[1], -40, angle); /* setup color image palette */ for(i=0; i<256; i++) { @@ -103,13 +104,6 @@ static int gamescr_start(void) int b = color_cmap[i * 3 + 2]; gba_bgpal[i] = (((uint16_t)b << 7) & 0x7c00) | (((uint16_t)g << 2) & 0x3e0) | (((uint16_t)r >> 3) & 0x1f); } - /* - intr_disable(); - interrupt(INTR_HBLANK, hblank); - REG_DISPSTAT |= DISPSTAT_IEN_HBLANK; - unmask(INTR_HBLANK); - intr_enable(); - */ spr_setup(16, 16, spr_game_pixels, spr_game_cmap); wait_vblank(); @@ -128,23 +122,49 @@ static int gamescr_start(void) spr_oam(oam, sidx++, SPRID_UISLASH, 216, 144, SPR_VRECT | SPR_256COL); dynspr_base = sidx; - wait_vblank(); - dma_copy32(3, (void*)OAM_ADDR, oam, sidx * 2, 0); - - num_enemies = 0; - total_enemies = 8; + num_enemies = total_enemies = 0; energy = 5; srand(0); + cptr = color_pixels; + for(i=0; i= CMAP_SPAWN0 && *cptr != 255) { + /* enemy spawn point */ + int idx = *cptr - CMAP_SPAWN0; + enemy = enemies + idx; + if(enemy->anm) { + panic(get_pc(), "double spawn %d at %d,%d (prev: %d,%d)", idx, + j, i, enemy->vobj.x, enemy->vobj.y); + } + enemy->vobj.x = j; + enemy->vobj.y = i; + enemy->vobj.px = -1; + enemy->anm = 0xff; + enemy->hp = 2; + enemy->last_fire = 0; + if(++total_enemies >= MAX_ENEMIES) { + goto endspawn; + } + } + cptr++; + } + } +endspawn: + /* check continuity */ for(i=0; i