--- trunk/src/devices/dev_fb.c 2007/10/08 16:18:27 10 +++ trunk/src/devices/dev_fb.c 2007/10/08 16:19:11 18 @@ -25,14 +25,14 @@ * SUCH DAMAGE. * * - * $Id: dev_fb.c,v 1.99 2005/06/26 13:49:06 debug Exp $ + * $Id: dev_fb.c,v 1.108 2005/10/20 22:49:07 debug Exp $ * * Generic framebuffer device. * * DECstation VFB01 monochrome framebuffer, 1024x864 * DECstation VFB02 8-bit color framebuffer, 1024x864 * DECstation Maxine, 1024x768 8-bit color - * HPCmips framebuffer + * HPC (mips, arm, ..) framebuffer * Playstation 2 (24-bit color) * generic (any resolution, several bit depths possible) * @@ -65,14 +65,7 @@ #endif -#define FB_TICK_SHIFT 18 - -#define LOGO_XSIZE 256 -#define LOGO_YSIZE 256 -#define LOGO_BOTTOM_MARGIN 60 -/* This must be a 256*256 pixels P4 ppm: */ -#include "fb_logo.c" -unsigned char *fb_logo = fb_logo_ppm + 11; +#define FB_TICK_SHIFT 19 /* #define FB_DEBUG */ @@ -298,51 +291,58 @@ #ifdef WITH_X11 #define macro_put_pixel() { \ - /* Combine the color into an X11 long and display it: */ \ - /* TODO: construct color in a more portable way: */ \ - switch (d->fb_window->x11_screen_depth) { \ - case 24: \ - if (d->fb_window->fb_ximage->byte_order) \ - color = (b << 16) + (g << 8) + r; \ - else \ - color = (r << 16) + (g << 8) + b; \ - break; \ - case 16: \ - r >>= 3; g >>= 2; b >>= 3; \ - if (d->fb_window->fb_ximage->byte_order) { \ - /* Big endian 16-bit X server: */ \ - static int first = 1; \ - if (first) { \ - fprintf(stderr, "\n*** Please report to the author whether 16-bit X11 colors are rendered correctly or not!\n\n"); \ - first = 0; \ - } \ - color = (b << 11) + (g << 5) + r; \ - } else { \ - /* Little endian (eg PC) X servers: */ \ - color = (r << 11) + (g << 5) + b; \ - } \ - break; \ - case 15: \ - r >>= 3; g >>= 3; b >>= 3; \ - if (d->fb_window->fb_ximage->byte_order) { \ - /* Big endian 15-bit X server: */ \ - static int first = 1; \ - if (first) { \ - fprintf(stderr, "\n*** Please report to the author whether 15-bit X11 colors are rendered correctly or not!\n\n"); \ - first = 0; \ - } \ - color = (b << 10) + (g << 5) + r; \ - } else { \ - /* Little endian (eg PC) X servers: */ \ - color = (r << 10) + (g << 5) + b; \ - } \ - break; \ - default: \ - color = d->fb_window->x11_graycolor[15 * (r + g + b) / (255 * 3)].pixel; \ - } \ - if (x>=0 && xx11_xsize && y>=0 && yx11_ysize) \ - XPutPixel(d->fb_window->fb_ximage, x, y, color); \ - } + /* Combine the color into an X11 long and display it: */ \ + /* TODO: construct color in a more portable way: */ \ + switch (d->fb_window->x11_screen_depth) { \ + case 24: \ + if (d->fb_window->fb_ximage->byte_order) \ + color = (b << 16) + (g << 8) + r; \ + else \ + color = (r << 16) + (g << 8) + b; \ + break; \ + case 16: \ + r >>= 3; g >>= 2; b >>= 3; \ + if (d->fb_window->fb_ximage->byte_order) { \ + /* Big endian 16-bit X server: */ \ + static int first = 1; \ + if (first) { \ + fprintf(stderr, "\n*** Please report " \ + "to the author whether 16-bit X11 " \ + "colors are rendered correctly or " \ + "not!\n\n"); \ + first = 0; \ + } \ + color = (b << 11) + (g << 5) + r; \ + } else { \ + /* Little endian (eg PC) X servers: */ \ + color = (r << 11) + (g << 5) + b; \ + } \ + break; \ + case 15: \ + r >>= 3; g >>= 3; b >>= 3; \ + if (d->fb_window->fb_ximage->byte_order) { \ + /* Big endian 15-bit X server: */ \ + static int first = 1; \ + if (first) { \ + fprintf(stderr, "\n*** Please report " \ + "to the author whether 15-bit X11 " \ + "colors are rendered correctly or " \ + "not!\n\n"); \ + first = 0; \ + } \ + color = (b << 10) + (g << 5) + r; \ + } else { \ + /* Little endian (eg PC) X servers: */ \ + color = (r << 10) + (g << 5) + b; \ + } \ + break; \ + default: \ + color = d->fb_window->x11_graycolor[15 * (r + g + b) \ + / (255 * 3)].pixel; \ + } \ + if (x>=0 && xx11_xsize && y>=0 && yx11_ysize) \ + XPutPixel(d->fb_window->fb_ximage, x, y, color); \ + } #else /* If not WITH_X11: */ #define macro_put_pixel() { } @@ -388,8 +388,8 @@ c = d->framebuffer[fb_addr >> 3]; fb_addr &= 7; - /* HPCmips is reverse: */ - if (d->vfb_type == VFB_HPCMIPS) + /* HPC is reverse: */ + if (d->vfb_type == VFB_HPC) fb_addr = 8 - d->bit_depth - fb_addr; c = (c >> fb_addr) & ((1<bit_depth) - 1); @@ -435,9 +435,10 @@ break; /* TODO: copy to the scaledown code below */ case 16: - if (d->vfb_type == VFB_HPCMIPS) { + if (d->vfb_type == VFB_HPC) { b = d->framebuffer[fb_addr] + - (d->framebuffer[fb_addr+1] << 8); + (d->framebuffer[fb_addr+1] + << 8); if (d->color32k) { r = b >> 11; @@ -458,10 +459,10 @@ b = b & 0x1f; } } else { - r = d->framebuffer[fb_addr] >> 3; - g = (d->framebuffer[fb_addr] << 5) + - (d->framebuffer[fb_addr + 1] >> 5); - b = d->framebuffer[fb_addr + 1] & 0x1f; + r = d->framebuffer[fb_addr] >> 3; + g = (d->framebuffer[fb_addr] << 5) + + (d->framebuffer[fb_addr + 1] >>5); + b = d->framebuffer[fb_addr + 1]&31; } r *= 8; @@ -480,7 +481,7 @@ return; } - /* scaledown != 1: */ + /* scaledown > 1: */ scaledown = d->vfb_scaledown; scaledownXscaledown = scaledown * scaledown; @@ -520,8 +521,8 @@ c = d->framebuffer[fb_addr >> 3]; fb_addr &= 7; - /* HPCmips is reverse: */ - if (d->vfb_type == VFB_HPCMIPS) + /* HPC is reverse: */ + if (d->vfb_type == VFB_HPC) fb_addr = 8 - d->bit_depth - fb_addr; c = (c >> fb_addr) & ((1<bit_depth) - 1); @@ -623,12 +624,11 @@ if (!cpu->machine->use_x11) return; -#ifdef BINTRANS do { - uint64_t low = -1, high; + uint64_t high, low = (uint64_t)(int64_t) -1; int x, y; - memory_device_bintrans_access(cpu, cpu->mem, + memory_device_dyntrans_access(cpu, cpu->mem, extra, &low, &high); if ((int64_t)low == -1) break; @@ -689,7 +689,6 @@ d->update_x2 = d->xsize-1; } } while (0); -#endif #ifdef WITH_X11 /* Do we need to redraw the cursor? */ @@ -701,20 +700,25 @@ need_to_redraw_cursor = 1; if (d->update_x2 != -1) { - if ( (d->update_x1 >= d->fb_window->OLD_cursor_x && - d->update_x1 < (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) || + if (((d->update_x1 >= d->fb_window->OLD_cursor_x && + d->update_x1 < (d->fb_window->OLD_cursor_x + + d->fb_window->OLD_cursor_xsize)) || (d->update_x2 >= d->fb_window->OLD_cursor_x && - d->update_x2 < (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) || + d->update_x2 < (d->fb_window->OLD_cursor_x + + d->fb_window->OLD_cursor_xsize)) || (d->update_x1 < d->fb_window->OLD_cursor_x && - d->update_x2 >= (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) ) { - if ( (d->update_y1 >= d->fb_window->OLD_cursor_y && - d->update_y1 < (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) || - (d->update_y2 >= d->fb_window->OLD_cursor_y && - d->update_y2 < (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) || - (d->update_y1 < d->fb_window->OLD_cursor_y && - d->update_y2 >= (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) ) - need_to_redraw_cursor = 1; - } + d->update_x2 >= (d->fb_window->OLD_cursor_x + + d->fb_window->OLD_cursor_xsize)) ) && + ( (d->update_y1 >= d->fb_window->OLD_cursor_y && + d->update_y1 < (d->fb_window->OLD_cursor_y + + d->fb_window->OLD_cursor_ysize)) || + (d->update_y2 >= d->fb_window->OLD_cursor_y && + d->update_y2 < (d->fb_window->OLD_cursor_y + + d->fb_window->OLD_cursor_ysize)) || + (d->update_y1 < d->fb_window->OLD_cursor_y && + d->update_y2 >= (d->fb_window->OLD_cursor_y + + d->fb_window->OLD_cursor_ysize)) ) ) + need_to_redraw_cursor = 1; } if (need_to_redraw_cursor) { @@ -728,7 +732,7 @@ d->fb_window->OLD_cursor_x/d->vfb_scaledown, d->fb_window->OLD_cursor_y/d->vfb_scaledown, d->fb_window->OLD_cursor_xsize/d->vfb_scaledown + 1, - d->fb_window->OLD_cursor_ysize/d->vfb_scaledown + 1); + d->fb_window->OLD_cursor_ysize/d->vfb_scaledown +1); } } #endif @@ -736,12 +740,16 @@ if (d->update_x2 != -1) { int y, addr, addr2, q = d->vfb_scaledown; - if (d->update_x1 >= d->visible_xsize) d->update_x1 = d->visible_xsize - 1; - if (d->update_x2 >= d->visible_xsize) d->update_x2 = d->visible_xsize - 1; - if (d->update_y1 >= d->visible_ysize) d->update_y1 = d->visible_ysize - 1; - if (d->update_y2 >= d->visible_ysize) d->update_y2 = d->visible_ysize - 1; + if (d->update_x1 >= d->visible_xsize) + d->update_x1 = d->visible_xsize - 1; + if (d->update_x2 >= d->visible_xsize) + d->update_x2 = d->visible_xsize - 1; + if (d->update_y1 >= d->visible_ysize) + d->update_y1 = d->visible_ysize - 1; + if (d->update_y2 >= d->visible_ysize) + d->update_y2 = d->visible_ysize - 1; - /* Without these, we might miss the right most / bottom pixel: */ + /* Without these, we might miss the rightmost/bottom pixel: */ d->update_x2 += (q - 1); d->update_y2 += (q - 1); @@ -750,8 +758,10 @@ d->update_y1 = d->update_y1 / q * q; d->update_y2 = d->update_y2 / q * q; - addr = d->update_y1 * d->bytes_per_line + d->update_x1 * d->bit_depth / 8; - addr2 = d->update_y1 * d->bytes_per_line + d->update_x2 * d->bit_depth / 8; + addr = d->update_y1 * d->bytes_per_line + + d->update_x1 * d->bit_depth / 8; + addr2 = d->update_y1 * d->bytes_per_line + + d->update_x2 * d->bit_depth / 8; for (y=d->update_y1; y<=d->update_y2; y+=q) { update_framebuffer(d, addr, addr2 - addr); @@ -760,9 +770,11 @@ } #ifdef WITH_X11 - XPutImage(d->fb_window->x11_display, d->fb_window->x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->fb_ximage, - d->update_x1/d->vfb_scaledown, d->update_y1/d->vfb_scaledown, - d->update_x1/d->vfb_scaledown, d->update_y1/d->vfb_scaledown, + XPutImage(d->fb_window->x11_display, d->fb_window-> + x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window-> + fb_ximage, d->update_x1/d->vfb_scaledown, d->update_y1/ + d->vfb_scaledown, d->update_x1/d->vfb_scaledown, + d->update_y1/d->vfb_scaledown, (d->update_x2 - d->update_x1)/d->vfb_scaledown + 1, (d->update_y2 - d->update_y1)/d->vfb_scaledown + 1); @@ -777,12 +789,15 @@ if (need_to_redraw_cursor) { /* Paint new cursor: */ if (d->fb_window->cursor_on) { - x11_redraw_cursor(cpu->machine, d->fb_window->fb_number); + x11_redraw_cursor(cpu->machine, + d->fb_window->fb_number); d->fb_window->OLD_cursor_on = d->fb_window->cursor_on; d->fb_window->OLD_cursor_x = d->fb_window->cursor_x; d->fb_window->OLD_cursor_y = d->fb_window->cursor_y; - d->fb_window->OLD_cursor_xsize = d->fb_window->cursor_xsize; - d->fb_window->OLD_cursor_ysize = d->fb_window->cursor_ysize; + d->fb_window->OLD_cursor_xsize = d->fb_window-> + cursor_xsize; + d->fb_window->OLD_cursor_ysize = d->fb_window-> + cursor_ysize; } } #endif @@ -921,18 +936,18 @@ * * VFB_DEC_VFB01, _VFB02, and VFB_DEC_MAXINE are DECstation specific. * - * If type is VFB_HPCMIPS, then color encoding differs from the generic case. + * If type is VFB_HPC, then color encoding differs from the generic case. * * If bit_depth = -15 (note the minus sign), then a special hack is used for * the Playstation Portable's 5-bit R, 5-bit G, 5-bit B. */ struct vfb_data *dev_fb_init(struct machine *machine, struct memory *mem, uint64_t baseaddr, int vfb_type, int visible_xsize, int visible_ysize, - int xsize, int ysize, int bit_depth, char *name, int logo) + int xsize, int ysize, int bit_depth, char *name) { struct vfb_data *d; size_t size, nlen; - int x, y, flags; + int flags; char title[400]; char *name2; @@ -1016,27 +1031,6 @@ d->update_x2 = d->update_y2 = -1; - /* A nice bootup logo: */ - if (logo) { - int logo_bottom_margin = LOGO_BOTTOM_MARGIN; - - d->update_x1 = 0; - d->update_x2 = LOGO_XSIZE-1; - d->update_y1 = d->visible_ysize-LOGO_YSIZE-logo_bottom_margin; - d->update_y2 = d->visible_ysize-logo_bottom_margin; - for (y=0; yvisible_ysize - LOGO_YSIZE - - logo_bottom_margin)*d->xsize + x) - * d->bit_depth / 8; - int b = fb_logo[(y*LOGO_XSIZE+x) / 8] & - (128 >> (x&7)); - for (s=0; sbit_depth / 8; s++) - if (a+s >= 0 && a+s < size) - d->framebuffer[a+s] = b? 0:255; - } - } - /* Don't set the title to include the size of the framebuffer for VGA, since then the resolution might change during runtime. */ if (strcmp(name, "VGA") == 0) @@ -1064,7 +1058,7 @@ flags = MEM_DEFAULT; if ((baseaddr & 0xfff) == 0) - flags = MEM_BINTRANS_OK | MEM_BINTRANS_WRITE_OK; + flags = MEM_DYNTRANS_OK | MEM_DYNTRANS_WRITE_OK; flags |= MEM_READING_HAS_NO_SIDE_EFFECTS;