X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgamescr.c;h=7981cb41752c6ea6a0341577183a57b0d9d13132;hb=ddf193afa41762a7b363610ecd3ddd82be9fc4db;hp=bad3bec97eac09df3e4b00b2e6fda2e165742dbf;hpb=79c636931d1f9bf844196e91be171b17bbe9c04f;p=gbajam22 diff --git a/src/gamescr.c b/src/gamescr.c index bad3bec..7981cb4 100644 --- a/src/gamescr.c +++ b/src/gamescr.c @@ -11,8 +11,6 @@ #include "sprite.h" #include "debug.h" #include "level.h" -#include "xgl.h" -#include "polyfill.h" static int gamescr_start(void); static void gamescr_stop(void); @@ -33,39 +31,12 @@ static struct screen gamescr = { static int nframes, num_vbl, backbuf; static uint16_t *vram[] = { gba_vram_lfb0, gba_vram_lfb1 }; -static const char *testlvl = - "################\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}, - {-0x10000, -0x10000, 0x10000, 0, 0x10000, 0, 210}, - {-0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210}, - {0x10000, -0x10000, -0x10000, 0, 0x10000, 0, 210} -}; - +static int32_t pos[2], angle; +static struct voxscape *vox; -static struct level *lvl; +#define COLOR_HORIZON 0xcc77ff +#define COLOR_ZENITH 0x5588cc -static struct player player; struct screen *init_game_screen(void) @@ -75,29 +46,16 @@ struct screen *init_game_screen(void) static int gamescr_start(void) { - int i; - uint16_t *cmap; - gba_setmode(4, DISPCNT_BG2 | DISPCNT_OBJ | DISPCNT_FB1); vblperf_setcolor(1); - lvl = init_level(testlvl); - - xgl_init(); - - init_player(&player, lvl); - player.phi = 0x100; - - cmap = gba_bgpal; - *cmap++ = 0; - for(i=1; i<255; i++) { - *cmap++ = rand(); + if(!(vox = vox_create(512, 512))) { + panic(get_pc(), "vox_create"); } - *cmap = 0xffff; - + vox_proj(vox, 45, 1, 250); - select_input(BN_DPAD | BN_A | BN_B); + /*select_input(BN_DPAD | BN_LT | BN_RT);*/ nframes = 0; return 0; @@ -114,8 +72,7 @@ static void gamescr_frame(void) backbuf = ++nframes & 1; fb = (unsigned char*)vram[backbuf]; - polyfill_framebuffer(fb, 240, 160); - fillblock_16byte(fb, 0, 240 * 160 / 16); + vox_framebuf(vox, 240, 160, fb, -1); update(); draw(); @@ -126,42 +83,48 @@ static void gamescr_frame(void) vblperf_begin(); } +#define WALK_SPEED 0x40000 +#define TURN_SPEED 0x100 + static void update(void) { - uint16_t bnstate; + int32_t fwd[2], right[2]; + uint16_t input; + + input = ~REG_KEYINPUT; + + if(input & BN_LT) angle += TURN_SPEED; + if(input & BN_RT) angle -= TURN_SPEED; - bnstate = get_input(); + fwd[0] = -SIN(angle); + fwd[1] = COS(angle); + right[0] = fwd[1]; + right[1] = -fwd[0]; - player_input(&player, bnstate); + if(input & BN_UP) { + pos[0] += fwd[0]; + pos[1] += fwd[1]; + } + if(input & BN_DOWN) { + pos[0] -= fwd[0]; + pos[1] -= fwd[1]; + } + if(input & BN_RIGHT) { + pos[0] += right[0]; + pos[1] += right[1]; + } + if(input & BN_LEFT) { + pos[0] -= right[0]; + pos[1] -= right[1]; + } - upd_vis(lvl, &player); + vox_view(vox, pos[0], pos[1], -30, angle); } static void draw(void) { - int i, x, y; - struct cell *cell; - - xgl_load_identity(); -#ifndef BUILD_GBA - xgl_translate(0, 0, view_zoom); -#endif - xgl_rotate_x(player.phi); - xgl_rotate_y(player.theta); - xgl_translate(player.x, 0, player.y); - - 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(); - } + vox_render(vox); + vox_sky_grad(vox, COLOR_HORIZON, COLOR_ZENITH); } #ifdef BUILD_GBA