/[gxemul]/trunk/src/devices/dev_fb.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_fb.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_fb.c,v 1.110 2005/11/13 00:14:08 debug Exp $   *  $Id: dev_fb.c,v 1.116 2006/02/05 10:26:36 debug Exp $
29   *     *  
30   *  Generic framebuffer device.   *  Generic framebuffer device.
31   *   *
# Line 37  Line 37 
37   *      generic (any resolution, several bit depths possible)   *      generic (any resolution, several bit depths possible)
38   *   *
39   *   *
40   *  TODO:  There is still a bug when redrawing the cursor. The underlying   *  TODO:  This should actually be independent of X11, but that
  *         image is moved 1 pixel (?), or something like that.  
  *  
  *  TODO:  This should actually be independant of X11, but that  
41   *         might be too hard to do right now.   *         might be too hard to do right now.
42   *   *
43   *  TODO:  playstation 2 pixels are stored in another format, actually   *  TODO:  playstation 2 pixels are stored in another format, actually
# Line 153  void dev_fb_resize(struct vfb_data *d, i Line 150  void dev_fb_resize(struct vfb_data *d, i
150          d->framebuffer = new_framebuffer;          d->framebuffer = new_framebuffer;
151          d->framebuffer_size = size;          d->framebuffer_size = size;
152    
153          if (new_xsize > d->x11_xsize || new_ysize > d->x11_ysize) {          if (new_xsize > d->xsize || new_ysize > d->ysize) {
154                  d->update_x1 = d->update_y1 = 0;                  d->update_x1 = d->update_y1 = 0;
155                  d->update_x2 = new_xsize - 1;                  d->update_x2 = new_xsize - 1;
156                  d->update_y2 = new_ysize - 1;                  d->update_y2 = new_ysize - 1;
157          }          }
158    
159          d->bytes_per_line = new_bytes_per_line;          d->bytes_per_line = new_bytes_per_line;
160          d->x11_xsize = d->visible_xsize = new_xsize;          d->xsize = d->visible_xsize = new_xsize;
161          d->x11_ysize = d->visible_ysize = new_ysize;          d->ysize = d->visible_ysize = new_ysize;
162    
163            d->x11_xsize = d->xsize / d->vfb_scaledown;
164            d->x11_ysize = d->ysize / d->vfb_scaledown;
165    
166  #ifdef WITH_X11  #ifdef WITH_X11
167          if (d->fb_window != NULL)          if (d->fb_window != NULL)
# Line 248  void framebuffer_blockcopyfill(struct vf Line 248  void framebuffer_blockcopyfill(struct vf
248                                  int x;                                  int x;
249                                  char buf[8192 * 3];                                  char buf[8192 * 3];
250                                  if (d->bit_depth == 24)                                  if (d->bit_depth == 24)
251                                          for (x=0; x<linelen; x+=3) {                                          for (x=0; x<linelen && x<sizeof(buf);
252                                                x += 3) {
253                                                  buf[x] = fill_r;                                                  buf[x] = fill_r;
254                                                  buf[x+1] = fill_g;                                                  buf[x+1] = fill_g;
255                                                  buf[x+2] = fill_b;                                                  buf[x+2] = fill_b;
256                                          }                                          }
257                                  else                                  else {
258                                          printf("TODO: fill for non-24-bit"                                          fatal("[ fb: TODO: fill for non-24-bit"
259                                              " modes\n");                                              " modes ]\n");
260                                    }
261    
262                                  memmove(d->framebuffer + dest_ofs, buf,                                  memmove(d->framebuffer + dest_ofs, buf,
263                                      linelen);                                      linelen);
# Line 290  void framebuffer_blockcopyfill(struct vf Line 292  void framebuffer_blockcopyfill(struct vf
292    
293    
294  #ifdef WITH_X11  #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 && x<d->x11_xsize && y>=0 && y<d->x11_ysize)           \  
                 XPutPixel(d->fb_window->fb_ximage, x, y, color);        \  
     }  
 #else  
 /*  If not WITH_X11:  */  
 #define macro_put_pixel() { }  
 #endif  
   
   
 /*  
  *  update_framebuffer():  
  *  
  *  The framebuffer memory has been updated. This function tries to make  
  *  sure that the XImage is also updated (1 or more pixels).  
  */  
 void update_framebuffer(struct vfb_data *d, int addr, int len)  
 {  
         int x, y, pixel, npixels;  
         long color_r, color_g, color_b;  
 #ifdef WITH_X11  
         long color;  
 #endif  
         int scaledown = d->vfb_scaledown;  
         int scaledownXscaledown = 1;  
295    
296          if (scaledown == 1) {  #define REDRAW  redraw_fallback
297                  /*  Which framebuffer pixel does addr correspond to?  */  #include "fb_include.c"
298                  pixel = addr * 8 / d->bit_depth;  #undef REDRAW
299                  y = pixel / d->xsize;  
300                  x = pixel % d->xsize;  #define FB_24
301    #define REDRAW  redraw_24
302                  /*  How many framebuffer pixels?  */  #include "fb_include.c"
303                  npixels = len * 8 / d->bit_depth;  #undef REDRAW
304                  if (npixels == 0)  #undef FB_24
305                          npixels = 1;  #define FB_16
306    #define REDRAW  redraw_16
307                  if (d->bit_depth < 8) {  #include "fb_include.c"
308                          for (pixel=0; pixel<npixels; pixel++) {  #undef FB_16
309                                  int fb_addr, c, r, g, b;  #undef REDRAW
310                                  color_r = color_g = color_b = 0;  #define FB_15
311    #define REDRAW  redraw_15
312                                  fb_addr = (y * d->xsize + x) * d->bit_depth;  #include "fb_include.c"
313                                  /*  fb_addr is now which _bit_ in  #undef REDRAW
314                                      the framebuffer  */  #undef FB_15
315    
316                                  c = d->framebuffer[fb_addr >> 3];  #define FB_BO
317                                  fb_addr &= 7;  #define FB_24
318    #define REDRAW  redraw_24_bo
319                                  /*  HPC is reverse:  */  #include "fb_include.c"
320                                  if (d->vfb_type == VFB_HPC)  #undef REDRAW
321                                          fb_addr = 8 - d->bit_depth - fb_addr;  #undef FB_24
322    #define FB_16
323                                  c = (c >> fb_addr) & ((1<<d->bit_depth) - 1);  #define REDRAW  redraw_16_bo
324                                  /*  c <<= (8 - d->bit_depth);  */  #include "fb_include.c"
325    #undef FB_16
326                                  r = d->rgb_palette[c*3 + 0];  #undef REDRAW
327                                  g = d->rgb_palette[c*3 + 1];  #define FB_15
328                                  b = d->rgb_palette[c*3 + 2];  #define REDRAW  redraw_15_bo
329    #include "fb_include.c"
330    #undef REDRAW
331    #undef FB_15
332    #undef FB_BO
333    
334    #define FB_SCALEDOWN
335    
336    #define REDRAW  redraw_fallback_sd
337    #include "fb_include.c"
338    #undef REDRAW
339    
340    #define FB_24
341    #define REDRAW  redraw_24_sd
342    #include "fb_include.c"
343    #undef REDRAW
344    #undef FB_24
345    #define FB_16
346    #define REDRAW  redraw_16_sd
347    #include "fb_include.c"
348    #undef FB_16
349    #undef REDRAW
350    #define FB_15
351    #define REDRAW  redraw_15_sd
352    #include "fb_include.c"
353    #undef REDRAW
354    #undef FB_15
355    
356    #define FB_BO
357    #define FB_24
358    #define REDRAW  redraw_24_bo_sd
359    #include "fb_include.c"
360    #undef REDRAW
361    #undef FB_24
362    #define FB_16
363    #define REDRAW  redraw_16_bo_sd
364    #include "fb_include.c"
365    #undef FB_16
366    #undef REDRAW
367    #define FB_15
368    #define REDRAW  redraw_15_bo_sd
369    #include "fb_include.c"
370    #undef REDRAW
371    #undef FB_15
372    #undef FB_BO
373    
374    void (*redraw[2 * 4 * 2])(struct vfb_data *, int, int) = {
375            redraw_fallback, redraw_fallback,
376            redraw_15, redraw_15_bo,
377            redraw_16, redraw_16_bo,
378            redraw_24, redraw_24_bo,
379            redraw_fallback_sd, redraw_fallback_sd,
380            redraw_15_sd, redraw_15_bo_sd,
381            redraw_16_sd, redraw_16_bo_sd,
382            redraw_24_sd, redraw_24_bo_sd  };
383    
384                                  macro_put_pixel();  #endif  /*  WITH_X11  */
                                 x++;  
                         }  
                 } else if (d->bit_depth == 8) {  
                         for (pixel=0; pixel<npixels; pixel++) {  
                                 int fb_addr, c, r, g, b;  
                                 color_r = color_g = color_b = 0;  
   
                                 fb_addr = y * d->xsize + x;  
                                 /*  fb_addr is now which byte in framebuffer  */  
                                 c = d->framebuffer[fb_addr];  
                                 r = d->rgb_palette[c*3 + 0];  
                                 g = d->rgb_palette[c*3 + 1];  
                                 b = d->rgb_palette[c*3 + 2];  
   
                                 macro_put_pixel();  
                                 x++;  
                         }  
                 } else {        /*  d->bit_depth > 8  */  
                         for (pixel=0; pixel<npixels; pixel++) {  
                                 int fb_addr, r, g, b;  
                                 color_r = color_g = color_b = 0;  
   
                                 fb_addr = (y * d->xsize + x) * d->bit_depth;  
                                 /*  fb_addr is now which byte in framebuffer  */  
   
                                 /*  > 8 bits color.  */  
                                 fb_addr >>= 3;  
                                 switch (d->bit_depth) {  
                                 case 24:  
                                         r = d->framebuffer[fb_addr];  
                                         g = d->framebuffer[fb_addr + 1];  
                                         b = d->framebuffer[fb_addr + 2];  
                                         break;  
                                 /*  TODO: copy to the scaledown code below  */  
                                 case 16:  
                                         if (d->vfb_type == VFB_HPC) {  
                                                 b = d->framebuffer[fb_addr] +  
                                                     (d->framebuffer[fb_addr+1]  
                                                     << 8);  
   
                                                 if (d->color32k) {  
                                                         r = b >> 11;  
                                                         g = b >> 5;  
                                                         r = r & 31;  
                                                         g = (g & 31) * 2;  
                                                         b = b & 31;  
                                                 } else if (d->psp_15bit) {  
                                                         int tmp;  
                                                         r = (b >> 10) & 0x1f;  
                                                         g = (b >>  5) & 0x1f;  
                                                         b = b & 0x1f;  
                                                         g <<= 1;  
                                                         tmp = r; r = b; b = tmp;  
                                                 } else {  
                                                         r = (b >> 11) & 0x1f;  
                                                         g = (b >>  5) & 0x3f;  
                                                         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]&31;  
                                         }  
   
                                         r *= 8;  
                                         g *= 4;  
                                         b *= 8;  
                                         break;  
                                 default:  
                                         r = g = b = random() & 255;  
                                 }  
   
                                 macro_put_pixel();  
                                 x++;  
                         }  
                 }  
   
                 return;  
         }  
   
         /*  scaledown > 1:  */  
   
         scaledown = d->vfb_scaledown;  
         scaledownXscaledown = scaledown * scaledown;  
   
         /*  Which framebuffer pixel does addr correspond to?  */  
         pixel = addr * 8 / d->bit_depth;  
         y = pixel / d->xsize;  
         x = pixel % d->xsize;  
   
         /*  How many framebuffer pixels?  */  
         npixels = len * 8 / d->bit_depth;  
   
         /*  Which x11 pixel?  */  
         x /= scaledown;  
         y /= scaledown;  
   
         /*  How many x11 pixels:  */  
         npixels /= scaledown;  
         if (npixels == 0)  
                 npixels = 1;  
   
         if (d->bit_depth < 8) {  
                 for (pixel=0; pixel<npixels; pixel++) {  
                         int subx, suby, r, g, b;  
                         color_r = color_g = color_b = 0;  
                         for (suby=0; suby<scaledown; suby++)  
                             for (subx=0; subx<scaledown; subx++) {  
                                 int fb_x, fb_y, fb_addr, c;  
   
                                 fb_x = x * scaledown + subx;  
                                 fb_y = y * scaledown + suby;  
                                 fb_addr = fb_y * d->xsize + fb_x;  
                                 fb_addr = fb_addr * d->bit_depth;  
                                 /*  fb_addr is now which _bit_ in  
                                     the framebuffer  */  
   
                                 c = d->framebuffer[fb_addr >> 3];  
                                 fb_addr &= 7;  
   
                                 /*  HPC is reverse:  */  
                                 if (d->vfb_type == VFB_HPC)  
                                         fb_addr = 8 - d->bit_depth - fb_addr;  
   
                                 c = (c >> fb_addr) & ((1<<d->bit_depth) - 1);  
                                 /*  c <<= (8 - d->bit_depth);  */  
   
                                 r = d->rgb_palette[c*3 + 0];  
                                 g = d->rgb_palette[c*3 + 1];  
                                 b = d->rgb_palette[c*3 + 2];  
   
                                 color_r += r;  
                                 color_g += g;  
                                 color_b += b;  
                             }  
   
                         r = color_r / scaledownXscaledown;  
                         g = color_g / scaledownXscaledown;  
                         b = color_b / scaledownXscaledown;  
                         macro_put_pixel();  
                         x++;  
                 }  
         } else if (d->bit_depth == 8) {  
                 for (pixel=0; pixel<npixels; pixel++) {  
                         int subx, suby, r, g, b;  
                         color_r = color_g = color_b = 0;  
                         for (suby=0; suby<scaledown; suby++)  
                             for (subx=0; subx<scaledown; subx++) {  
                                 int fb_x, fb_y, fb_addr, c;  
   
                                 fb_x = x * scaledown + subx;  
                                 fb_y = y * scaledown + suby;  
                                 fb_addr = fb_y * d->xsize + fb_x;  
                                 /*  fb_addr is which _byte_ in framebuffer  */  
                                 c = d->framebuffer[fb_addr] * 3;  
                                 r = d->rgb_palette[c + 0];  
                                 g = d->rgb_palette[c + 1];  
                                 b = d->rgb_palette[c + 2];  
                                 color_r += r;  
                                 color_g += g;  
                                 color_b += b;  
                             }  
   
                         r = color_r / scaledownXscaledown;  
                         g = color_g / scaledownXscaledown;  
                         b = color_b / scaledownXscaledown;  
                         macro_put_pixel();  
                         x++;  
                 }  
         } else {  
                 /*  Generic > 8 bit bit-depth:  */  
                 for (pixel=0; pixel<npixels; pixel++) {  
                         int subx, suby, r, g, b;  
                         color_r = color_g = color_b = 0;  
                         for (suby=0; suby<scaledown; suby++)  
                             for (subx=0; subx<scaledown; subx++) {  
                                 int fb_x, fb_y, fb_addr;  
   
                                 fb_x = x * scaledown + subx;  
                                 fb_y = y * scaledown + suby;  
                                 fb_addr = fb_y * d->xsize + fb_x;  
                                 fb_addr = (fb_addr * d->bit_depth) >> 3;  
                                 /*  fb_addr is which _byte_ in framebuffer  */  
   
                                 /*  > 8 bits color.  */  
                                 switch (d->bit_depth) {  
                                 case 24:  
                                         r = d->framebuffer[fb_addr];  
                                         g = d->framebuffer[fb_addr + 1];  
                                         b = d->framebuffer[fb_addr + 2];  
                                         break;  
                                 default:  
                                         r = g = b = random() & 255;  
                                 }  
                                 color_r += r;  
                                 color_g += g;  
                                 color_b += b;  
                             }  
                         r = color_r / scaledownXscaledown;  
                         g = color_g / scaledownXscaledown;  
                         b = color_b / scaledownXscaledown;  
                         macro_put_pixel();  
                         x++;  
                 }  
         }  
 }  
385    
386    
387  /*  /*
# Line 763  void dev_fb_tick(struct cpu *cpu, void * Line 538  void dev_fb_tick(struct cpu *cpu, void *
538                  addr2 = d->update_y1 * d->bytes_per_line +                  addr2 = d->update_y1 * d->bytes_per_line +
539                      d->update_x2 * d->bit_depth / 8;                      d->update_x2 * d->bit_depth / 8;
540    
541    #ifdef WITH_X11
542                  for (y=d->update_y1; y<=d->update_y2; y+=q) {                  for (y=d->update_y1; y<=d->update_y2; y+=q) {
543                          update_framebuffer(d, addr, addr2 - addr);                          d->redraw_func(d, addr, addr2 - addr);
544                          addr  += d->bytes_per_line * q;                          addr  += d->bytes_per_line * q;
545                          addr2 += d->bytes_per_line * q;                          addr2 += d->bytes_per_line * q;
546                  }                  }
547    
 #ifdef WITH_X11  
548                  XPutImage(d->fb_window->x11_display, d->fb_window->                  XPutImage(d->fb_window->x11_display, d->fb_window->
549                      x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->                      x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->
550                      fb_ximage, d->update_x1/d->vfb_scaledown, d->update_y1/                      fb_ximage, d->update_x1/d->vfb_scaledown, d->update_y1/
# Line 798  void dev_fb_tick(struct cpu *cpu, void * Line 573  void dev_fb_tick(struct cpu *cpu, void *
573                              cursor_xsize;                              cursor_xsize;
574                          d->fb_window->OLD_cursor_ysize = d->fb_window->                          d->fb_window->OLD_cursor_ysize = d->fb_window->
575                              cursor_ysize;                              cursor_ysize;
576                            need_to_flush_x11 = 1;
577                  }                  }
578          }          }
579  #endif  #endif
# Line 812  void dev_fb_tick(struct cpu *cpu, void * Line 588  void dev_fb_tick(struct cpu *cpu, void *
588  /*  /*
589   *  dev_fb_access():   *  dev_fb_access():
590   */   */
591  int dev_fb_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(fb)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
592  {  {
593          struct vfb_data *d = extra;          struct vfb_data *d = extra;
594          int i;          size_t i;
595    
596  #ifdef FB_DEBUG  #ifdef FB_DEBUG
597          if (writeflag == MEM_WRITE) { if (data[0]) {          if (writeflag == MEM_WRITE) { if (data[0]) {
# Line 846  int dev_fb_access(struct cpu *cpu, struc Line 620  int dev_fb_access(struct cpu *cpu, struc
620    
621                          /*  If all bytes are equal to what is already stored                          /*  If all bytes are equal to what is already stored
622                              in the framebuffer, then simply return:  */                              in the framebuffer, then simply return:  */
623                          if (i==len-1)                          if (i == len-1)
624                                  return 1;                                  return 1;
625                  }                  }
626          }          }
# Line 905  int dev_fb_access(struct cpu *cpu, struc Line 679  int dev_fb_access(struct cpu *cpu, struc
679          if (writeflag == MEM_WRITE) {          if (writeflag == MEM_WRITE) {
680                  if (len > 8)                  if (len > 8)
681                          memcpy(d->framebuffer + relative_addr, data, len);                          memcpy(d->framebuffer + relative_addr, data, len);
682                  else                  else {
683                          for (i=0; i<len; i++)                          for (i=0; i<len; i++)
684                                  d->framebuffer[relative_addr + i] = data[i];                                  d->framebuffer[relative_addr + i] = data[i];
685                    }
686          } else {          } else {
687                  if (len > 8)                  if (len > 8)
688                          memcpy(data, d->framebuffer + relative_addr, len);                          memcpy(data, d->framebuffer + relative_addr, len);
689                  else                  else {
690                          for (i=0; i<len; i++)                          for (i=0; i<len; i++)
691                                  data[i] = d->framebuffer[relative_addr + i];                                  data[i] = d->framebuffer[relative_addr + i];
692                    }
693          }          }
694    
695          return 1;          return 1;
# Line 948  struct vfb_data *dev_fb_init(struct mach Line 724  struct vfb_data *dev_fb_init(struct mach
724          struct vfb_data *d;          struct vfb_data *d;
725          size_t size, nlen;          size_t size, nlen;
726          int flags;          int flags;
727            int reverse_start = 0;
728          char title[400];          char title[400];
729          char *name2;          char *name2;
730    
# Line 958  struct vfb_data *dev_fb_init(struct mach Line 735  struct vfb_data *dev_fb_init(struct mach
735          }          }
736          memset(d, 0, sizeof(struct vfb_data));          memset(d, 0, sizeof(struct vfb_data));
737    
738            if (vfb_type & VFB_REVERSE_START) {
739                    vfb_type &= ~VFB_REVERSE_START;
740                    reverse_start = 1;
741            }
742    
743          d->vfb_type = vfb_type;          d->vfb_type = vfb_type;
744    
745          /*  Defaults:  */          /*  Defaults:  */
# Line 1000  struct vfb_data *dev_fb_init(struct mach Line 782  struct vfb_data *dev_fb_init(struct mach
782                  d->ysize = ysize;  d->visible_ysize = d->ysize;                  d->ysize = ysize;  d->visible_ysize = d->ysize;
783                  d->bit_depth = 24;                  d->bit_depth = 24;
784                  break;                  break;
         default:  
                 ;  
785          }          }
786    
787          if (d->bit_depth == 2 || d->bit_depth == 4)          if (d->bit_depth == 2 || d->bit_depth == 4)
# Line 1022  struct vfb_data *dev_fb_init(struct mach Line 802  struct vfb_data *dev_fb_init(struct mach
802    
803          /*  Clear the framebuffer (all black pixels):  */          /*  Clear the framebuffer (all black pixels):  */
804          d->framebuffer_size = size;          d->framebuffer_size = size;
805          memset(d->framebuffer, 0, size);          memset(d->framebuffer, reverse_start? 255 : 0, size);
806    
807          d->x11_xsize = d->visible_xsize / d->vfb_scaledown;          d->x11_xsize = d->visible_xsize / d->vfb_scaledown;
808          d->x11_ysize = d->visible_ysize / d->vfb_scaledown;          d->x11_ysize = d->visible_ysize / d->vfb_scaledown;
809    
810          d->update_x1 = d->update_y1 = 99999;          /*  Only "update" from the start if we need to fill with white.  */
811          d->update_x2 = d->update_y2 = -1;          /*  (The Ximage will be black from the start anyway.)  */
812            if (reverse_start) {
813                    d->update_x1 = d->update_y1 = 0;
814                    d->update_x2 = d->xsize - 1;
815                    d->update_y2 = d->ysize - 1;
816            } else {
817                    d->update_x1 = d->update_y1 = 99999;
818                    d->update_x2 = d->update_y2 = -1;
819            }
820    
821          /*  Don't set the title to include the size of the framebuffer for          /*  Don't set the title to include the size of the framebuffer for
822              VGA, since then the resolution might change during runtime.  */              VGA, since then the resolution might change during runtime.  */
# Line 1041  struct vfb_data *dev_fb_init(struct mach Line 828  struct vfb_data *dev_fb_init(struct mach
828          title[sizeof(title)-1] = '\0';          title[sizeof(title)-1] = '\0';
829    
830  #ifdef WITH_X11  #ifdef WITH_X11
831          if (machine->use_x11)          if (machine->use_x11) {
832                    int i = 0;
833                  d->fb_window = x11_fb_init(d->x11_xsize, d->x11_ysize,                  d->fb_window = x11_fb_init(d->x11_xsize, d->x11_ysize,
834                      title, machine->x11_scaledown, machine);                      title, machine->x11_scaledown, machine);
835          else                  switch (d->fb_window->x11_screen_depth) {
836                    case 15: i = 2; break;
837                    case 16: i = 4; break;
838                    case 24: i = 6; break;
839                    }
840                    if (d->fb_window->fb_ximage->byte_order)
841                            i ++;
842                    if (d->vfb_scaledown > 1)
843                            i += 8;
844                    d->redraw_func = redraw[i];
845            } else
846  #endif  #endif
847                  d->fb_window = NULL;                  d->fb_window = NULL;
848    

Legend:
Removed from v.20  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26