/[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 24 by dpavlin, Mon Oct 8 16:19:56 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.118 2006/03/04 12:38:47 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;  
   
         if (scaledown == 1) {  
                 /*  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;  
                 if (npixels == 0)  
                         npixels = 1;  
   
                 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) * 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];  
295    
296                                  macro_put_pixel();  #define REDRAW  redraw_fallback
297                                  x++;  #include "fb_include.c"
298                          }  #undef REDRAW
299                  } else if (d->bit_depth == 8) {  
300                          for (pixel=0; pixel<npixels; pixel++) {  #define FB_24
301                                  int fb_addr, c, r, g, b;  #define REDRAW  redraw_24
302                                  color_r = color_g = color_b = 0;  #include "fb_include.c"
303    #undef REDRAW
304                                  fb_addr = y * d->xsize + x;  #undef FB_24
305                                  /*  fb_addr is now which byte in framebuffer  */  #define FB_16
306                                  c = d->framebuffer[fb_addr];  #define REDRAW  redraw_16
307                                  r = d->rgb_palette[c*3 + 0];  #include "fb_include.c"
308                                  g = d->rgb_palette[c*3 + 1];  #undef FB_16
309                                  b = d->rgb_palette[c*3 + 2];  #undef REDRAW
310    #define FB_15
311                                  macro_put_pixel();  #define REDRAW  redraw_15
312                                  x++;  #include "fb_include.c"
313                          }  #undef REDRAW
314                  } else {        /*  d->bit_depth > 8  */  #undef FB_15
315                          for (pixel=0; pixel<npixels; pixel++) {  
316                                  int fb_addr, r, g, b;  #define FB_BO
317                                  color_r = color_g = color_b = 0;  #define FB_24
318    #define REDRAW  redraw_24_bo
319                                  fb_addr = (y * d->xsize + x) * d->bit_depth;  #include "fb_include.c"
320                                  /*  fb_addr is now which byte in framebuffer  */  #undef REDRAW
321    #undef FB_24
322                                  /*  > 8 bits color.  */  #define FB_16
323                                  fb_addr >>= 3;  #define REDRAW  redraw_16_bo
324                                  switch (d->bit_depth) {  #include "fb_include.c"
325                                  case 24:  #undef FB_16
326                                          r = d->framebuffer[fb_addr];  #undef REDRAW
327                                          g = d->framebuffer[fb_addr + 1];  #define FB_15
328                                          b = d->framebuffer[fb_addr + 2];  #define REDRAW  redraw_15_bo
329                                          break;  #include "fb_include.c"
330                                  /*  TODO: copy to the scaledown code below  */  #undef REDRAW
331                                  case 16:  #undef FB_15
332                                          if (d->vfb_type == VFB_HPC) {  #undef FB_BO
333                                                  b = d->framebuffer[fb_addr] +  
334                                                      (d->framebuffer[fb_addr+1]  #define FB_SCALEDOWN
335                                                      << 8);  
336    #define REDRAW  redraw_fallback_sd
337                                                  if (d->color32k) {  #include "fb_include.c"
338                                                          r = b >> 11;  #undef REDRAW
339                                                          g = b >> 5;  
340                                                          r = r & 31;  #define FB_24
341                                                          g = (g & 31) * 2;  #define REDRAW  redraw_24_sd
342                                                          b = b & 31;  #include "fb_include.c"
343                                                  } else if (d->psp_15bit) {  #undef REDRAW
344                                                          int tmp;  #undef FB_24
345                                                          r = (b >> 10) & 0x1f;  #define FB_16
346                                                          g = (b >>  5) & 0x1f;  #define REDRAW  redraw_16_sd
347                                                          b = b & 0x1f;  #include "fb_include.c"
348                                                          g <<= 1;  #undef FB_16
349                                                          tmp = r; r = b; b = tmp;  #undef REDRAW
350                                                  } else {  #define FB_15
351                                                          r = (b >> 11) & 0x1f;  #define REDRAW  redraw_15_sd
352                                                          g = (b >>  5) & 0x3f;  #include "fb_include.c"
353                                                          b = b & 0x1f;  #undef REDRAW
354                                                  }  #undef FB_15
355                                          } else {  
356                                              r = d->framebuffer[fb_addr] >> 3;  #define FB_BO
357                                              g = (d->framebuffer[fb_addr] << 5) +  #define FB_24
358                                                (d->framebuffer[fb_addr + 1] >>5);  #define REDRAW  redraw_24_bo_sd
359                                              b = d->framebuffer[fb_addr + 1]&31;  #include "fb_include.c"
360                                          }  #undef REDRAW
361    #undef FB_24
362                                          r *= 8;  #define FB_16
363                                          g *= 4;  #define REDRAW  redraw_16_bo_sd
364                                          b *= 8;  #include "fb_include.c"
365                                          break;  #undef FB_16
366                                  default:  #undef REDRAW
367                                          r = g = b = random() & 255;  #define FB_15
368                                  }  #define REDRAW  redraw_15_bo_sd
369    #include "fb_include.c"
370                                  macro_put_pixel();  #undef REDRAW
371                                  x++;  #undef FB_15
372                          }  #undef FB_BO
373                  }  
374    void (*redraw[2 * 4 * 2])(struct vfb_data *, int, int) = {
375                  return;          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          /*  scaledown > 1:  */  #endif  /*  WITH_X11  */
   
         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 738  void dev_fb_tick(struct cpu *cpu, void * Line 513  void dev_fb_tick(struct cpu *cpu, void *
513  #endif  #endif
514    
515          if (d->update_x2 != -1) {          if (d->update_x2 != -1) {
516                  int y, addr, addr2, q = d->vfb_scaledown;  #ifdef WITH_X11
517                    int y;
518    #endif
519                    int addr, addr2, q = d->vfb_scaledown;
520    
521                  if (d->update_x1 >= d->visible_xsize)                  if (d->update_x1 >= d->visible_xsize)
522                          d->update_x1 = d->visible_xsize - 1;                          d->update_x1 = d->visible_xsize - 1;
# Line 763  void dev_fb_tick(struct cpu *cpu, void * Line 541  void dev_fb_tick(struct cpu *cpu, void *
541                  addr2 = d->update_y1 * d->bytes_per_line +                  addr2 = d->update_y1 * d->bytes_per_line +
542                      d->update_x2 * d->bit_depth / 8;                      d->update_x2 * d->bit_depth / 8;
543    
544    #ifdef WITH_X11
545                  for (y=d->update_y1; y<=d->update_y2; y+=q) {                  for (y=d->update_y1; y<=d->update_y2; y+=q) {
546                          update_framebuffer(d, addr, addr2 - addr);                          d->redraw_func(d, addr, addr2 - addr);
547                          addr  += d->bytes_per_line * q;                          addr  += d->bytes_per_line * q;
548                          addr2 += d->bytes_per_line * q;                          addr2 += d->bytes_per_line * q;
549                  }                  }
550    
 #ifdef WITH_X11  
551                  XPutImage(d->fb_window->x11_display, d->fb_window->                  XPutImage(d->fb_window->x11_display, d->fb_window->
552                      x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->                      x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->
553                      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 576  void dev_fb_tick(struct cpu *cpu, void *
576                              cursor_xsize;                              cursor_xsize;
577                          d->fb_window->OLD_cursor_ysize = d->fb_window->                          d->fb_window->OLD_cursor_ysize = d->fb_window->
578                              cursor_ysize;                              cursor_ysize;
579                            need_to_flush_x11 = 1;
580                  }                  }
581          }          }
582  #endif  #endif
# Line 812  void dev_fb_tick(struct cpu *cpu, void * Line 591  void dev_fb_tick(struct cpu *cpu, void *
591  /*  /*
592   *  dev_fb_access():   *  dev_fb_access():
593   */   */
594  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)  
595  {  {
596          struct vfb_data *d = extra;          struct vfb_data *d = extra;
597          int i;          size_t i;
598    
599  #ifdef FB_DEBUG  #ifdef FB_DEBUG
600          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 623  int dev_fb_access(struct cpu *cpu, struc
623    
624                          /*  If all bytes are equal to what is already stored                          /*  If all bytes are equal to what is already stored
625                              in the framebuffer, then simply return:  */                              in the framebuffer, then simply return:  */
626                          if (i==len-1)                          if (i == len-1)
627                                  return 1;                                  return 1;
628                  }                  }
629          }          }
# Line 905  int dev_fb_access(struct cpu *cpu, struc Line 682  int dev_fb_access(struct cpu *cpu, struc
682          if (writeflag == MEM_WRITE) {          if (writeflag == MEM_WRITE) {
683                  if (len > 8)                  if (len > 8)
684                          memcpy(d->framebuffer + relative_addr, data, len);                          memcpy(d->framebuffer + relative_addr, data, len);
685                  else                  else {
686                          for (i=0; i<len; i++)                          for (i=0; i<len; i++)
687                                  d->framebuffer[relative_addr + i] = data[i];                                  d->framebuffer[relative_addr + i] = data[i];
688                    }
689          } else {          } else {
690                  if (len > 8)                  if (len > 8)
691                          memcpy(data, d->framebuffer + relative_addr, len);                          memcpy(data, d->framebuffer + relative_addr, len);
692                  else                  else {
693                          for (i=0; i<len; i++)                          for (i=0; i<len; i++)
694                                  data[i] = d->framebuffer[relative_addr + i];                                  data[i] = d->framebuffer[relative_addr + i];
695                    }
696          }          }
697    
698          return 1;          return 1;
# Line 948  struct vfb_data *dev_fb_init(struct mach Line 727  struct vfb_data *dev_fb_init(struct mach
727          struct vfb_data *d;          struct vfb_data *d;
728          size_t size, nlen;          size_t size, nlen;
729          int flags;          int flags;
730            int reverse_start = 0;
731          char title[400];          char title[400];
732          char *name2;          char *name2;
733    
# Line 958  struct vfb_data *dev_fb_init(struct mach Line 738  struct vfb_data *dev_fb_init(struct mach
738          }          }
739          memset(d, 0, sizeof(struct vfb_data));          memset(d, 0, sizeof(struct vfb_data));
740    
741            if (vfb_type & VFB_REVERSE_START) {
742                    vfb_type &= ~VFB_REVERSE_START;
743                    reverse_start = 1;
744            }
745    
746          d->vfb_type = vfb_type;          d->vfb_type = vfb_type;
747    
748          /*  Defaults:  */          /*  Defaults:  */
# Line 1000  struct vfb_data *dev_fb_init(struct mach Line 785  struct vfb_data *dev_fb_init(struct mach
785                  d->ysize = ysize;  d->visible_ysize = d->ysize;                  d->ysize = ysize;  d->visible_ysize = d->ysize;
786                  d->bit_depth = 24;                  d->bit_depth = 24;
787                  break;                  break;
         default:  
                 ;  
788          }          }
789    
790          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 805  struct vfb_data *dev_fb_init(struct mach
805    
806          /*  Clear the framebuffer (all black pixels):  */          /*  Clear the framebuffer (all black pixels):  */
807          d->framebuffer_size = size;          d->framebuffer_size = size;
808          memset(d->framebuffer, 0, size);          memset(d->framebuffer, reverse_start? 255 : 0, size);
809    
810          d->x11_xsize = d->visible_xsize / d->vfb_scaledown;          d->x11_xsize = d->visible_xsize / d->vfb_scaledown;
811          d->x11_ysize = d->visible_ysize / d->vfb_scaledown;          d->x11_ysize = d->visible_ysize / d->vfb_scaledown;
812    
813          d->update_x1 = d->update_y1 = 99999;          /*  Only "update" from the start if we need to fill with white.  */
814          d->update_x2 = d->update_y2 = -1;          /*  (The Ximage will be black from the start anyway.)  */
815            if (reverse_start) {
816                    d->update_x1 = d->update_y1 = 0;
817                    d->update_x2 = d->xsize - 1;
818                    d->update_y2 = d->ysize - 1;
819            } else {
820                    d->update_x1 = d->update_y1 = 99999;
821                    d->update_x2 = d->update_y2 = -1;
822            }
823    
824          /*  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
825              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 831  struct vfb_data *dev_fb_init(struct mach
831          title[sizeof(title)-1] = '\0';          title[sizeof(title)-1] = '\0';
832    
833  #ifdef WITH_X11  #ifdef WITH_X11
834          if (machine->use_x11)          if (machine->use_x11) {
835                    int i = 0;
836                  d->fb_window = x11_fb_init(d->x11_xsize, d->x11_ysize,                  d->fb_window = x11_fb_init(d->x11_xsize, d->x11_ysize,
837                      title, machine->x11_scaledown, machine);                      title, machine->x11_scaledown, machine);
838          else                  switch (d->fb_window->x11_screen_depth) {
839                    case 15: i = 2; break;
840                    case 16: i = 4; break;
841                    case 24: i = 6; break;
842                    }
843                    if (d->fb_window->fb_ximage->byte_order)
844                            i ++;
845                    if (d->vfb_scaledown > 1)
846                            i += 8;
847                    d->redraw_func = redraw[i];
848            } else
849  #endif  #endif
850                  d->fb_window = NULL;                  d->fb_window = NULL;
851    
# Line 1065  struct vfb_data *dev_fb_init(struct mach Line 866  struct vfb_data *dev_fb_init(struct mach
866          memory_device_register(mem, name2, baseaddr, size, dev_fb_access,          memory_device_register(mem, name2, baseaddr, size, dev_fb_access,
867              d, flags, d->framebuffer);              d, flags, d->framebuffer);
868    
869          machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT);          machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT, 0.0);
870          return d;          return d;
871  }  }
872    

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

  ViewVC Help
Powered by ViewVC 1.1.26