X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=08bddf800c070078f748ddc239221107299fd20d;hp=fcaee9bf30ada99f3a38b89d02d97f998255a6dc;hb=7cffbf057545fb303ad8f53e432ef42f7708e16d;hpb=68f89fa06ae5cfacde9cf8310e97220e5fc05260 diff --git a/src/sdl/main.c b/src/sdl/main.c index fcaee9b..08bddf8 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -33,9 +33,8 @@ static quat_t rot = {0, 0, 0, 1}; int main(int argc, char **argv) { - int s, i, j; + int s; char *env; - unsigned short *sptr, *dptr; if((env = getenv("FBSCALE")) && (s = atoi(env))) { fbscale = s; @@ -45,17 +44,21 @@ int main(int argc, char **argv) xsz = fb_width * fbscale; ysz = fb_height * fbscale; + /* now start_loadscr sets up fb_pixels to the space used by the loading image, + * so no need to allocate another framebuffer + */ +#if 0 /* 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))) { fprintf(stderr, "failed to allocate virtual framebuffer\n"); return 1; } - vmem = fb_pixels; +#endif SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); if(!(fbsurf = SDL_SetVideoMode(xsz, ysz, fb_bpp, sdl_flags))) { fprintf(stderr, "failed to set video mode %dx%d %dbpp\n", fb_width, fb_height, fb_bpp); - free(fb_pixels); + /*free(fb_pixels);*/ SDL_Quit(); return 1; } @@ -64,10 +67,11 @@ int main(int argc, char **argv) time_msec = 0; if(demo_init(argc, argv) == -1) { - free(fb_pixels); + /*free(fb_pixels);*/ SDL_Quit(); return 1; } + vmem = fb_pixels; if(opt.sball && sball_init() == 0) { use_sball = 1; @@ -93,32 +97,6 @@ int main(int argc, char **argv) time_msec = get_msec(); demo_draw(); - - if(SDL_MUSTLOCK(fbsurf)) { - SDL_LockSurface(fbsurf); - } - - sptr = fb_pixels; - dptr = (unsigned short*)fbsurf->pixels + (fbsurf->w - xsz) / 2; - for(i=0; iw + x] = pixel; - } - } - dptr += fbscale; - } - dptr += (fbsurf->w - fb_width) * fbscale; - } - - if(SDL_MUSTLOCK(fbsurf)) { - SDL_UnlockSurface(fbsurf); - } - SDL_Flip(fbsurf); } break_evloop: @@ -141,12 +119,40 @@ void wait_vsync(void) void swap_buffers(void *pixels) { + int i, j; + unsigned short *sptr, *dptr; + demo_post_draw(pixels ? pixels : fb_pixels); - /* do nothing, all pointers point to the same buffer */ if(opt.vsync) { wait_vsync(); } + + if(SDL_MUSTLOCK(fbsurf)) { + SDL_LockSurface(fbsurf); + } + + sptr = fb_pixels; + dptr = (unsigned short*)fbsurf->pixels + (fbsurf->w - xsz) / 2; + for(i=0; iw + x] = pixel; + } + } + dptr += fbscale; + } + dptr += (fbsurf->w - fb_width) * fbscale; + } + + if(SDL_MUSTLOCK(fbsurf)) { + SDL_UnlockSurface(fbsurf); + } + SDL_Flip(fbsurf); } static int bnmask(int sdlbn)