X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=84bbe00fd910808c060ed30caa425cd919f12b03;hb=ae47c13224ea63ac83f80ab332f7436b3265cdce;hp=9b109c8af02ad2173d28309266ffa490568ef396;hpb=a77883f4cefd1af3d71588871ef27e81a49194d8;p=eradicate diff --git a/src/sdl/main.c b/src/sdl/main.c index 9b109c8..84bbe00 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -18,7 +18,7 @@ static int sdlkey_to_gamekey(int sdlkey, unsigned int mod); static int quit; static SDL_Surface *fbsurf; -static int fbscale = 2; +static int fbscale = 1; static int xsz, ysz; static unsigned int sdl_flags = SDL_SWSURFACE; @@ -27,6 +27,7 @@ int main(int argc, char **argv) { int s; char *env; + void *fb_buf; if((env = getenv("FBSCALE")) && (s = atoi(env))) { fbscale = s; @@ -35,12 +36,15 @@ int main(int argc, char **argv) xsz = FB_WIDTH * fbscale; ysz = FB_HEIGHT * fbscale; + fb_width = xsz; + fb_height = ysz; - /* allocate 1 extra row as a guard band, until we fucking fix the rasterizer */ - if(!(fb_pixels = malloc(FB_WIDTH * (FB_HEIGHT + 1) * FB_BPP / CHAR_BIT))) { + fb_size = FB_WIDTH * FB_HEIGHT * FB_BPP / 8; + if(!(fb_buf = malloc(fb_size + FB_WIDTH * 4))) { fprintf(stderr, "failed to allocate virtual framebuffer\n"); return 1; } + fb_pixels = (uint16_t*)((char*)fb_buf + FB_WIDTH * 2); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); if(!(fbsurf = SDL_SetVideoMode(xsz, ysz, FB_BPP, sdl_flags))) { @@ -103,7 +107,7 @@ void blit_frame(void *pixels, int vsync) SDL_LockSurface(fbsurf); } - sptr = fb_pixels; + sptr = pixels; dptr = (unsigned short*)fbsurf->pixels + (fbsurf->w - xsz) / 2; for(i=0; ikey.keysym.sym, ev->key.keysym.mod); - key_event(key, ev->key.state == SDL_PRESSED ? 1 : 0); + if(key_event) { + key = sdlkey_to_gamekey(ev->key.keysym.sym, ev->key.keysym.mod); + key_event(key, ev->key.state == SDL_PRESSED ? 1 : 0); + } else { + if(ev->key.keysym.sym == SDLK_ESCAPE) { + quit = 1; + } + } break; /*