diff -uNr jfbterm-0.4.7-orig/fbdpsp.c jfbterm-0.4.7/fbdpsp.c --- jfbterm-0.4.7-orig/fbdpsp.c 2003-08-30 03:48:16.000000000 +0900 +++ jfbterm-0.4.7/fbdpsp.c 2005-11-19 15:34:49.000000000 +0900 @@ -37,6 +37,66 @@ # define min(a, b) (((a)>(b))?(b):(a)) #endif +#define JFB_SPLASH_SCREEN +#ifdef JFB_SPLASH_SCREEN +/* + * temporary patch for slash screen (background) on jfbterm + * nskystars at yahoo.com, 20051119 + * - image support for 24 bit uncompressed bitmap files + * - framebuffer support for 15, 16, 24, 32bpp + * - little endian support only + */ + +struct bmp_hdr { + unsigned int fsize; + unsigned short int res1, res2; + unsigned int offset; + unsigned int size; + unsigned int width, height; + unsigned short int planes; + unsigned short int bit_count; + unsigned int compression; + unsigned int imagesize; + unsigned int xres; + unsigned int yres; + unsigned int ncolors; + unsigned int impcolors; +}; + +struct bmp_file { + struct bmp_hdr hdr; + unsigned char *data; +}; + +extern struct bmp_file *tbmp; +extern int use_splash; + +unsigned int +bmp_read(struct bmp_file *bmp, int x, int y) +{ + unsigned char *offset; + + if((x < 0) || (x >= bmp->hdr.width) || (y < 0) || (y >= bmp->hdr.height)) + return 0x000000; + + offset = bmp->data + (bmp->hdr.height - y - 1) * bmp->hdr.width * 3; + return offset[x * 3] | (offset[x * 3 + 1] << 8) | (offset[x * 3 + 2] << 16); +} + +int +fb_c24_to_c16(unsigned int c) +{ + return (c >> 19) << 11 | ((c & 0xff00) >> 10) << 5 | (c & 0xff) >> 3; +} + +/* fixme: is 15 bpp code needed? */ +int +fb_c24_to_c15(unsigned int c) +{ + return (c >> 19) << 10 | ((c & 0xff00) >> 10) << 5 | (c & 0xff) >> 3; +} +#endif + #ifdef JFB_2BPP /* 2bpp */ @@ -418,7 +478,15 @@ for (y = sy ; y < min(sy+ly, p->height) ; y++) { d=(u_short*)(p->smem + y * p->bytePerLine + sx * 2); for(x=0;xheight) ; y++) { d=(u_short*)(p->smem + y * p->bytePerLine + sx * 2); for(x=0;xsmem + y * p->bytePerLine + sx * 3; for(x=0;x> 16; + d[1] = (tval & 0xff00) >> 8; + d[2] = tval & 0xff; + } + else { + d[0] = t; + d[1] = m; + d[2] = b; + } +#else d[0] = t; d[1] = m; d[2] = b; +#endif d+=3; } } @@ -745,7 +838,14 @@ for (y = sy ; y < sy+ly ; y++) { d=(u_int*)(p->smem + y * p->bytePerLine + sx * 4); for(x = 0 ; x < lx ; x++){ +#ifdef JFB_SPLASH_SCREEN + if(use_splash != 0 && icol == 0) + *d++ = bmp_read(tbmp, sx + x, y); + else + *d++ = icol; +#else *d++ = icol; +#endif } } } diff -uNr jfbterm-0.4.7-orig/main.c jfbterm-0.4.7/main.c --- jfbterm-0.4.7-orig/main.c 2004-05-11 03:03:44.000000000 +0900 +++ jfbterm-0.4.7/main.c 2005-11-19 15:53:16.000000000 +0900 @@ -68,6 +68,101 @@ TFrameBufferMemory gFramebuffer; +#define JFB_SPLASH_SCREEN +#ifdef JFB_SPLASH_SCREEN +/* + * temporary patch for slash screen (background) on jfbterm + * nskystars at yahoo.com, 20051119 + * - image support for 24 bit uncompressed bitmap files + * - framebuffer support for 15, 16, 24, 32bpp + * - little endian support only + */ + +#define BMP_SIGNATURE 0x4D42 + +struct bmp_hdr { + unsigned int fsize; + unsigned short int res1, res2; + unsigned int offset; + unsigned int size; + unsigned int width, height; + unsigned short int planes; + unsigned short int bit_count; + unsigned int compression; + unsigned int imagesize; + unsigned int xres; + unsigned int yres; + unsigned int ncolors; + unsigned int impcolors; +}; + +struct bmp_file { + struct bmp_hdr hdr; + unsigned char *data; +}; + +struct bmp_file *tbmp; +int use_splash = 0; + +struct bmp_file * +bmp_init(char * filename) +{ + struct bmp_file *bmp; + unsigned int data_size; + FILE *fp; + + if((bmp = (struct bmp_file *)malloc(sizeof(struct bmp_file))) == NULL) { + fprintf(stderr, "read-bmp: malloc error (struct bmp_file)\n"); + return NULL; + } + + memset(bmp, 0, sizeof(struct bmp_file)); + + if((fp = fopen(filename, "rb")) == NULL) { + fprintf(stderr, "read-bmp: can't open file %s\n", filename); + free(bmp); + return NULL; + } + + if((fgetc(fp) | (fgetc(fp) << 8)) != BMP_SIGNATURE) { + fprintf(stderr, "read-bmp: file %s is not a BMP file\n", filename); + free(bmp); + fclose(fp); + return NULL; + } + + fread(&(bmp->hdr), sizeof(struct bmp_hdr), 1, fp); + + if(bmp->hdr.bit_count != 24 || bmp->hdr.compression != 0) { + fprintf(stderr, "read-bmp: we can only handle 24 bit uncompressed BMP files\n"); + free(bmp); + fclose(fp); + return NULL; + } + + fseek(fp, bmp->hdr.offset, SEEK_SET); + data_size = bmp->hdr.width * bmp->hdr.height * 3; + if((bmp->data = (unsigned char *)malloc(data_size * sizeof(unsigned char))) == NULL) { + fprintf(stderr, "read-bmp: malloc error (bmp data)\n"); + free(bmp); + fclose(fp); + return NULL; + } + + fread(bmp->data, 1, data_size, fp); + fclose(fp); + + return bmp; +} + +void +bmp_close(struct bmp_file *bmp) +{ + if(bmp->data != NULL) free(bmp->data); + if(bmp != NULL) free(bmp); +} +#endif + static void tapp_get_options(TApplication* p, int argc, char *argv[]) { static struct option optList[] = { @@ -163,6 +258,10 @@ void tapp_final_at_exit(void) { tapp_final(&gApp); +#ifdef JFB_SPLASH_SCREEN + if(use_splash) + bmp_close(tbmp); +#endif } void tapp_init(TApplication* p) @@ -370,6 +469,9 @@ TCapability* fcap; char* cp; const char* tn; +#ifdef JFB_SPLASH_SCREEN + char* bmpf; +#endif char* en; util_privilege_init(); @@ -427,6 +529,14 @@ } tapp_change_to_new_console(&gApp); +#ifdef JFB_SPLASH_SCREEN + bmpf = tcaps_find_first(&(gApp.gCaps), "splash"); + if(bmpf) { + tbmp = bmp_init(bmpf); + if(tbmp) + use_splash = 1; + } +#endif tfbm_init(&gFramebuffer); tfbm_open(&gFramebuffer);