X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=96620f3d1ac1d1897107c9dba777c2fa54c633ad;hb=097d03fa2406fca819b27b698ffb1cfc8ac445c2;hp=840a9e4c94ef4cb137c7178bcb7dda14c85a2d9c;hpb=f73cd25d63806279fb8c6c085f5aa8dfeab8130d;p=gbajam22 diff --git a/src/gamescr.c b/src/gamescr.c index 840a9e4..96620f3 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -21,18 +21,26 @@ static int nframes, num_vbl, backbuf; static uint16_t *vram[] = { (uint16_t*)VRAM_LFB_FB0_ADDR, (uint16_t*)VRAM_LFB_FB1_ADDR }; static const char *testlvl = - "########\n" - "### s#\n" - "### ####\n" - "### #\n" - "## #\n" - "## #\n" - "## #\n" - "## ### #\n" - "## ### #\n" - "## #\n" - "#### ###\n" - "########\n"; + "################\n" + "################\n" + "################\n" + "################\n" + "################\n" + "####### s#####\n" + "####### ########\n" + "####### #####\n" + "###### #####\n" + "###### #####\n" + "###### #####\n" + "###### ### #####\n" + "###### ### #####\n" + "###### #####\n" + "######## #######\n" + "################\n" + "################\n" + "################\n" + "################\n" + "################\n"; static struct xvertex tm_floor[] __attribute__((section(".rodata"))) = { {0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210}, @@ -49,18 +57,28 @@ static struct player player; void gamescr(void) { + int i; unsigned char *fb; + uint16_t *cmap; REG_DISPCNT = 4 | DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1; - vblperf_setcolor(0xff); + vblperf_setcolor(1); lvl = init_level(testlvl); xgl_init(); - memset(&player, 0, sizeof player); - player.y = 0x60000; + init_player(&player, lvl); + player.phi = 0x100; + + cmap = (uint16_t*)CRAM_BG_ADDR; + *cmap++ = 0; + for(i=1; i<255; i++) { + *cmap++ = rand(); + } + *cmap = 0xffff; + select_input(BN_DPAD | BN_A | BN_B); @@ -93,17 +111,33 @@ static void update(void) bnstate = get_input(); player_input(&player, bnstate); + + upd_vis(lvl, &player); } static void draw(void) { + int i, x, y; + struct cell *cell; + xgl_load_identity(); + /*xgl_translate(0, 0, 0x100000);*/ xgl_rotate_x(player.phi); xgl_rotate_y(player.theta); xgl_translate(player.x, 0, player.y); - xgl_rotate_y(X_QPI); - xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor); + for(i=0; inumvis; i++) { + cell = lvl->vis[i]; + + x = (int32_t)(cell->x - player.cx) << 17; + y = -(int32_t)(cell->y - player.cy) << 17; + + xgl_push_matrix(); + xgl_translate(x, 0, y); + xgl_index(i + 1); + xgl_draw(XGL_QUADS, tm_floor, sizeof tm_floor / sizeof *tm_floor); + xgl_pop_matrix(); + } } __attribute__((noinline, target("arm"), section(".iwram")))