X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=fbgfx;a=blobdiff_plain;f=src%2Fconscr.c;h=51c50f209806988a39dfd4c789f71f4051c95d5b;hp=4c56fb019dca448515d475ebf9fcad0f54d4234f;hb=3a148d92224a9ab88a9c602b072d85d4b1b1eddd;hpb=70c067c2da05fb71f3d2de115cefbc225eff3667 diff --git a/src/conscr.c b/src/conscr.c index 4c56fb0..51c50f2 100644 --- a/src/conscr.c +++ b/src/conscr.c @@ -9,6 +9,7 @@ static void destroy(void); static void start(long trans_time); static void stop(long trans_time); static void draw(void); +static float smoothstep(float a, float b, float x); static struct screen scr = { "console", @@ -21,7 +22,12 @@ static struct screen scr = { static void *saved_fb; static int fbsize; -static long trans_start, trans_dur; +static long trans_start = -1, trans_dur; + +#define NBLOCKS 32 +#define MAX_DELAY 0.5 +static float delay[NBLOCKS]; +static int blksz; struct screen *console_screen(void) { @@ -30,13 +36,21 @@ struct screen *console_screen(void) static int init(void) { + int i; fbsize = fb_width * fb_height * fb_depth / 8; if(!(saved_fb = malloc(fbsize))) { - perror("failed to allocate memory"); + perror("failed to allocate console framebuffer"); return -1; } memcpy(saved_fb, fb_pixels, fbsize); + + blksz = fb_height / NBLOCKS; + + for(i=0; i 0) { memset(dptr, 0, offs * pixsz); } @@ -84,3 +101,12 @@ static void draw(void) sptr += fb_width * pixsz; } } + +static float smoothstep(float a, float b, float x) +{ + if(x < a) return 0.0; + if(x >= b) return 1.0; + + x = (x - a) / (b - a); + return x * x * (3.0 - 2.0 * x); +}