int lcd_bmp(uchar *logo_bmp) { int i; uchar *ptr; ushort *ptr2; ushort val; unsigned char *dst = NULL; int x, y; int width, height, bpp, colors, line_size; int header_size; unsigned char *bmp; unsigned char r, g, b; BITMAPINFOHEADER *bm_info; ulong len; /* * Check for bmp mark 'BM' */ if (*(ushort *)logo_bmp != 0x424d) { /* * Decompress bmp image */ len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE); if (dst == NULL) { printf("Error: malloc for gunzip failed!\n"); return 1; } if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) { free(dst); return 1; } if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) { printf("Image could be truncated" " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); } /* * Check for bmp mark 'BM' */ if (*(ushort *)dst != 0x424d) { printf("LCD: Unknown image format!\n"); free(dst); return 1; } } else { /* * Uncompressed BMP image, just use this pointer */ dst = (uchar *)logo_bmp; } /* * Get image info from bmp-header */ bm_info = (BITMAPINFOHEADER *)(dst + 14); bpp = LOAD_SHORT(bm_info->biBitCount); width = LOAD_LONG(bm_info->biWidth); height = LOAD_LONG(bm_info->biHeight); switch (bpp) { case 1: colors = 1; line_size = width >> 3; break; case 4: colors = 16; line_size = width >> 1; break; case 8: colors = 256; line_size = width; break; case 24: colors = 0; line_size = width * 3; break; default: printf("LCD: Unknown bpp (%d) im image!\n", bpp); if ((dst != NULL) && (dst != (uchar *)logo_bmp)) free(dst); return 1; } printf(" (%d*%d, %dbpp)\n", width, height, bpp); /* * Write color palette */ if ((colors <= 256) && (lcd_depth <= 8)) { ptr = (unsigned char *)(dst + 14 + 40); for (i = 0; i < colors; i++) { b = *ptr++; g = *ptr++; r = *ptr++; ptr++; S1D_WRITE_PALETTE(glob_lcd_reg, i, r, g, b); } } /* * Write bitmap data into framebuffer */ ptr = glob_lcd_mem; ptr2 = (ushort *)glob_lcd_mem; header_size = 14 + 40 + 4*colors; /* skip bmp header */ for (y = 0; y < height; y++) { bmp = &dst[(height-1-y)*line_size + header_size]; if (lcd_depth == 16) { if (bpp == 24) { for (x = 0; x < width; x++) { /* * Generate epson 16bpp fb-format * from 24bpp image */ b = *bmp++ >> 3; g = *bmp++ >> 2; r = *bmp++ >> 3; val = ((r & 0x1f) << 11) | ((g & 0x3f) << 5) | (b & 0x1f); *ptr2++ = val; } } else if (bpp == 8) { for (x = 0; x < line_size; x++) { /* query rgb value from palette */ ptr = (unsigned char *)(dst + 14 + 40); ptr += (*bmp++) << 2; b = *ptr++ >> 3; g = *ptr++ >> 2; r = *ptr++ >> 3; val = ((r & 0x1f) << 11) | ((g & 0x3f) << 5) | (b & 0x1f); *ptr2++ = val; } } } else { for (x = 0; x < line_size; x++)
/* Currently, this procedure handles: * - jump threading */ void optimize_icode P3(char *, start, char *, pc, char *, end) { int instr; if (start == 0) { /* we don't optimize the initializer block right now b/c all the * stuff we do (jump threading, etc) can't occur there. */ start = mem_block[A_PROGRAM].block; pc = start; end = pc + mem_block[A_PROGRAM].current_size; if (*pc == 0) { /* no initializer jump */ pc += 3; } } while (pc < end) { switch (instr = EXTRACT_UCHAR(pc++)) { case F_NUMBER: case F_REAL: case F_CALL_INHERITED: pc += 4; break; case F_SIMUL_EFUN: case F_CALL_FUNCTION_BY_ADDRESS: pc += 3; break; case F_BRANCH: case F_BRANCH_WHEN_ZERO: case F_BRANCH_WHEN_NON_ZERO: case F_BBRANCH: case F_BBRANCH_WHEN_ZERO: case F_BBRANCH_WHEN_NON_ZERO: { char *tmp; short sarg; /* thread jumps */ COPY_SHORT(&sarg, pc); if (instr > F_BRANCH) tmp = pc - sarg; else tmp = pc + sarg; sarg = 0; while (1) { if (EXTRACT_UCHAR(tmp) == F_BRANCH) { COPY_SHORT(&sarg, tmp + 1); tmp += sarg + 1; } else if (EXTRACT_UCHAR(tmp) == F_BBRANCH) { COPY_SHORT(&sarg, tmp + 1); tmp -= sarg - 1; } else break; } if (!sarg) { pc += 2; break; } /* be careful; in the process of threading a forward jump * may have changed to a reverse one or vice versa */ if (tmp > pc) { if (instr > F_BRANCH) { pc[-1] -= 3; /* change to forward branch */ } sarg = tmp - pc; } else { if (instr <= F_BRANCH) { pc[-1] += 3; /* change to backwards branch */ } sarg = pc - tmp; } STORE_SHORT(pc, sarg); break; } #ifdef F_LOR case F_LOR: case F_LAND: { char *tmp; short sarg; /* thread jumps */ COPY_SHORT(&sarg, pc); tmp = pc + sarg; sarg = 0; while (1) { if (EXTRACT_UCHAR(tmp) == F_BRANCH) { COPY_SHORT(&sarg, tmp + 1); tmp += sarg + 1; } else if (EXTRACT_UCHAR(tmp) == F_BBRANCH) { COPY_SHORT(&sarg, tmp + 1); tmp -= sarg - 1; } else break; } if (!sarg) { pc += 2; break; } /* be careful; in the process of threading a forward jump * may have changed to a reverse one or vice versa */ if (tmp > pc) { sarg = tmp - pc; } else { #ifdef DEBUG fprintf(stderr,"Optimization failed; can't || or && backwards.\n"); #endif pc += 2; break; } STORE_SHORT(pc, sarg); break; } #endif case F_CATCH: case F_AGGREGATE: case F_AGGREGATE_ASSOC: case F_STRING: #ifdef F_JUMP_WHEN_ZERO case F_JUMP_WHEN_ZERO: case F_JUMP_WHEN_NON_ZERO: #endif #ifdef F_JUMP case F_JUMP: #endif pc += 2; break; case F_GLOBAL_LVALUE: case F_GLOBAL: case F_SHORT_STRING: case F_LOOP_INCR: case F_WHILE_DEC: case F_LOCAL: case F_LOCAL_LVALUE: case F_SSCANF: case F_PARSE_COMMAND: case F_BYTE: case F_POP_BREAK: case F_NBYTE: pc++; break; case F_FUNCTION_CONSTRUCTOR: switch (EXTRACT_UCHAR(pc++)) { case FP_SIMUL: case FP_LOCAL: pc += 2; break; case FP_FUNCTIONAL: case FP_FUNCTIONAL | FP_NOT_BINDABLE: pc += 3; break; case FP_ANONYMOUS: pc += 4; break; case FP_EFUN: #ifdef NEEDS_CALL_EXTRA if (EXTRACT_UCHAR(pc++) == F_CALL_EXTRA) #endif pc++; break; } break; case F_LOOP_COND: if (*pc++ == F_LOCAL) pc += 3; else pc += 7; break; case F_SWITCH: { unsigned short stable, etable; pc++; /* table type */ LOAD_SHORT(stable, pc); LOAD_SHORT(etable, pc); pc += 2; /* def */ DEBUG_CHECK(stable < pc - start || etable < pc - start || etable < stable, "Error in switch table found while optimizing\n"); /* recursively optimize the inside of the switch */ optimize_icode(start, pc, start + stable); pc = start + etable; break; } case F_CALL_EXTRA: instr = EXTRACT_UCHAR(pc++) + 0xff; default: if ((instr >= BASE) && (instrs[instr].min_arg != instrs[instr].max_arg)) pc++; } } }