X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=fbgfx;a=blobdiff_plain;f=src%2Fconscr.c;fp=src%2Fconscr.c;h=4c56fb019dca448515d475ebf9fcad0f54d4234f;hp=0000000000000000000000000000000000000000;hb=70c067c2da05fb71f3d2de115cefbc225eff3667;hpb=21180fdf54f0c578af0959df088de308ce25ca61 diff --git a/src/conscr.c b/src/conscr.c new file mode 100644 index 0000000..4c56fb0 --- /dev/null +++ b/src/conscr.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include "screen.h" +#include "demo.h" + +static int init(void); +static void destroy(void); +static void start(long trans_time); +static void stop(long trans_time); +static void draw(void); + +static struct screen scr = { + "console", + init, + destroy, + start, + stop, + draw +}; + +static void *saved_fb; +static int fbsize; +static long trans_start, trans_dur; + +struct screen *console_screen(void) +{ + return &scr; +} + +static int init(void) +{ + fbsize = fb_width * fb_height * fb_depth / 8; + + if(!(saved_fb = malloc(fbsize))) { + perror("failed to allocate memory"); + return -1; + } + memcpy(saved_fb, fb_pixels, fbsize); + return 0; +} + +static void destroy(void) +{ + memcpy(fb_pixels, saved_fb, fbsize); + free(saved_fb); +} + +static void start(long trans_time) +{ +} + +static void stop(long trans_time) +{ + trans_start = time_msec; + trans_dur = trans_time; +} + +static void draw(void) +{ + int i, pixsz = fb_depth / 8; + long elapsed, offs, rem; + unsigned char *dptr = fb_pixels; + unsigned char *sptr = saved_fb; + + if(!trans_start) { + return; + } + printf("console draw\n"); + + elapsed = time_msec - trans_start; + offs = fb_width * elapsed / trans_dur; + rem = fb_width - offs; + + for(i=0; i 0) { + memset(dptr, 0, offs * pixsz); + } + if(rem > 0) { + memcpy(dptr + offs * pixsz, sptr, rem * pixsz); + } + + dptr += fb_width * pixsz; + sptr += fb_width * pixsz; + } +}