/[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 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_fb.c,v 1.106 2005/08/14 11:14:38 debug Exp $   *  $Id: dev_fb.c,v 1.107 2005/09/18 19:54:15 debug Exp $
29   *     *  
30   *  Generic framebuffer device.   *  Generic framebuffer device.
31   *   *
# Line 291  void framebuffer_blockcopyfill(struct vf Line 291  void framebuffer_blockcopyfill(struct vf
291    
292  #ifdef WITH_X11  #ifdef WITH_X11
293  #define macro_put_pixel() {     \  #define macro_put_pixel() {     \
294                          /*  Combine the color into an X11 long and display it:  */      \          /*  Combine the color into an X11 long and display it:  */      \
295                          /*  TODO:  construct color in a more portable way:  */          \          /*  TODO:  construct color in a more portable way:  */          \
296                          switch (d->fb_window->x11_screen_depth) {                                       \          switch (d->fb_window->x11_screen_depth) {                       \
297                          case 24:                                                        \          case 24:                                                        \
298                                  if (d->fb_window->fb_ximage->byte_order)                \                  if (d->fb_window->fb_ximage->byte_order)                \
299                                          color = (b << 16) + (g << 8) + r;               \                          color = (b << 16) + (g << 8) + r;               \
300                                  else                                                    \                  else                                                    \
301                                          color = (r << 16) + (g << 8) + b;               \                          color = (r << 16) + (g << 8) + b;               \
302                                  break;                                                  \                  break;                                                  \
303                          case 16:                                                        \          case 16:                                                        \
304                                  r >>= 3; g >>= 2; b >>= 3;                              \                  r >>= 3; g >>= 2; b >>= 3;                              \
305                                  if (d->fb_window->fb_ximage->byte_order) {              \                  if (d->fb_window->fb_ximage->byte_order) {              \
306                                          /*  Big endian 16-bit X server:  */             \                          /*  Big endian 16-bit X server:  */             \
307                                          static int first = 1;                           \                          static int first = 1;                           \
308                                          if (first) {                                    \                          if (first) {                                    \
309                                                  fprintf(stderr, "\n*** Please report to the author whether 16-bit X11 colors are rendered correctly or not!\n\n"); \                                  fprintf(stderr, "\n*** Please report "  \
310                                                  first = 0;                              \                                      "to the author whether 16-bit X11 " \
311                                          }                                               \                                      "colors are rendered correctly or " \
312                                          color = (b << 11) + (g << 5) + r;               \                                      "not!\n\n");                        \
313                                  } else {                                                \                                  first = 0;                              \
314                                          /*  Little endian (eg PC) X servers:  */        \                          }                                               \
315                                          color = (r << 11) + (g << 5) + b;               \                          color = (b << 11) + (g << 5) + r;               \
316                                  }                                                       \                  } else {                                                \
317                                  break;                                                  \                          /*  Little endian (eg PC) X servers:  */        \
318                          case 15:                                                        \                          color = (r << 11) + (g << 5) + b;               \
319                                  r >>= 3; g >>= 3; b >>= 3;                              \                  }                                                       \
320                                  if (d->fb_window->fb_ximage->byte_order) {              \                  break;                                                  \
321                                          /*  Big endian 15-bit X server:  */             \          case 15:                                                        \
322                                          static int first = 1;                           \                  r >>= 3; g >>= 3; b >>= 3;                              \
323                                          if (first) {                                    \                  if (d->fb_window->fb_ximage->byte_order) {              \
324                                                  fprintf(stderr, "\n*** Please report to the author whether 15-bit X11 colors are rendered correctly or not!\n\n"); \                          /*  Big endian 15-bit X server:  */             \
325                                                  first = 0;                              \                          static int first = 1;                           \
326                                          }                                               \                          if (first) {                                    \
327                                          color = (b << 10) + (g << 5) + r;               \                                  fprintf(stderr, "\n*** Please report "  \
328                                  } else {                                                \                                      "to the author whether 15-bit X11 " \
329                                          /*  Little endian (eg PC) X servers:  */        \                                      "colors are rendered correctly or " \
330                                          color = (r << 10) + (g << 5) + b;               \                                      "not!\n\n");                        \
331                                  }                                                       \                                  first = 0;                              \
332                                  break;                                                  \                          }                                               \
333                          default:                                                        \                          color = (b << 10) + (g << 5) + r;               \
334                                  color = d->fb_window->x11_graycolor[15 * (r + g + b) / (255 * 3)].pixel; \                  } else {                                                \
335                          }                                                               \                          /*  Little endian (eg PC) X servers:  */        \
336                          if (x>=0 && x<d->x11_xsize && y>=0 && y<d->x11_ysize)           \                          color = (r << 10) + (g << 5) + b;               \
337                                  XPutPixel(d->fb_window->fb_ximage, x, y, color);        \                  }                                                       \
338                  }                  break;                                                  \
339            default:                                                        \
340                    color = d->fb_window->x11_graycolor[15 * (r + g + b)    \
341                        / (255 * 3)].pixel;                                 \
342            }                                                               \
343            if (x>=0 && x<d->x11_xsize && y>=0 && y<d->x11_ysize)           \
344                    XPutPixel(d->fb_window->fb_ximage, x, y, color);        \
345        }
346  #else  #else
347  /*  If not WITH_X11:  */  /*  If not WITH_X11:  */
348  #define macro_put_pixel() { }  #define macro_put_pixel() { }
# Line 430  void update_framebuffer(struct vfb_data Line 437  void update_framebuffer(struct vfb_data
437                                  case 16:                                  case 16:
438                                          if (d->vfb_type == VFB_HPCMIPS) {                                          if (d->vfb_type == VFB_HPCMIPS) {
439                                                  b = d->framebuffer[fb_addr] +                                                  b = d->framebuffer[fb_addr] +
440                                                      (d->framebuffer[fb_addr+1] << 8);                                                      (d->framebuffer[fb_addr+1]
441                                                        << 8);
442    
443                                                  if (d->color32k) {                                                  if (d->color32k) {
444                                                          r = b >> 11;                                                          r = b >> 11;
# Line 451  void update_framebuffer(struct vfb_data Line 459  void update_framebuffer(struct vfb_data
459                                                          b = b & 0x1f;                                                          b = b & 0x1f;
460                                                  }                                                  }
461                                          } else {                                          } else {
462                                                  r = d->framebuffer[fb_addr] >> 3;                                              r = d->framebuffer[fb_addr] >> 3;
463                                                  g = (d->framebuffer[fb_addr] << 5) +                                              g = (d->framebuffer[fb_addr] << 5) +
464                                                      (d->framebuffer[fb_addr + 1] >> 5);                                                (d->framebuffer[fb_addr + 1] >>5);
465                                                  b = d->framebuffer[fb_addr + 1] & 0x1f;                                              b = d->framebuffer[fb_addr + 1]&31;
466                                          }                                          }
467    
468                                          r *= 8;                                          r *= 8;
# Line 692  void dev_fb_tick(struct cpu *cpu, void * Line 700  void dev_fb_tick(struct cpu *cpu, void *
700                  need_to_redraw_cursor = 1;                  need_to_redraw_cursor = 1;
701    
702          if (d->update_x2 != -1) {          if (d->update_x2 != -1) {
703                  if ( (d->update_x1 >= d->fb_window->OLD_cursor_x &&                  if (((d->update_x1 >= d->fb_window->OLD_cursor_x &&
704                        d->update_x1 < (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) ||                        d->update_x1 < (d->fb_window->OLD_cursor_x +
705                          d->fb_window->OLD_cursor_xsize)) ||
706                       (d->update_x2 >= d->fb_window->OLD_cursor_x &&                       (d->update_x2 >= d->fb_window->OLD_cursor_x &&
707                        d->update_x2 < (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) ||                        d->update_x2 < (d->fb_window->OLD_cursor_x +
708                          d->fb_window->OLD_cursor_xsize)) ||
709                       (d->update_x1 <  d->fb_window->OLD_cursor_x &&                       (d->update_x1 <  d->fb_window->OLD_cursor_x &&
710                        d->update_x2 >= (d->fb_window->OLD_cursor_x + d->fb_window->OLD_cursor_xsize)) ) {                        d->update_x2 >= (d->fb_window->OLD_cursor_x +
711                          if ( (d->update_y1 >= d->fb_window->OLD_cursor_y &&                        d->fb_window->OLD_cursor_xsize)) ) &&
712                                d->update_y1 < (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) ||                     ( (d->update_y1 >= d->fb_window->OLD_cursor_y &&
713                               (d->update_y2 >= d->fb_window->OLD_cursor_y &&                        d->update_y1 < (d->fb_window->OLD_cursor_y +
714                                d->update_y2 < (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) ||                        d->fb_window->OLD_cursor_ysize)) ||
715                               (d->update_y1 <  d->fb_window->OLD_cursor_y &&                       (d->update_y2 >= d->fb_window->OLD_cursor_y &&
716                                d->update_y2 >= (d->fb_window->OLD_cursor_y + d->fb_window->OLD_cursor_ysize)) )                        d->update_y2 < (d->fb_window->OLD_cursor_y +
717                                  need_to_redraw_cursor = 1;                        d->fb_window->OLD_cursor_ysize)) ||
718                  }                       (d->update_y1 <  d->fb_window->OLD_cursor_y &&
719                          d->update_y2 >= (d->fb_window->OLD_cursor_y +
720                         d->fb_window->OLD_cursor_ysize)) ) )
721                            need_to_redraw_cursor = 1;
722          }          }
723    
724          if (need_to_redraw_cursor) {          if (need_to_redraw_cursor) {
# Line 719  void dev_fb_tick(struct cpu *cpu, void * Line 732  void dev_fb_tick(struct cpu *cpu, void *
732                              d->fb_window->OLD_cursor_x/d->vfb_scaledown,                              d->fb_window->OLD_cursor_x/d->vfb_scaledown,
733                              d->fb_window->OLD_cursor_y/d->vfb_scaledown,                              d->fb_window->OLD_cursor_y/d->vfb_scaledown,
734                              d->fb_window->OLD_cursor_xsize/d->vfb_scaledown + 1,                              d->fb_window->OLD_cursor_xsize/d->vfb_scaledown + 1,
735                              d->fb_window->OLD_cursor_ysize/d->vfb_scaledown + 1);                              d->fb_window->OLD_cursor_ysize/d->vfb_scaledown +1);
736                  }                  }
737          }          }
738  #endif  #endif
# Line 727  void dev_fb_tick(struct cpu *cpu, void * Line 740  void dev_fb_tick(struct cpu *cpu, void *
740          if (d->update_x2 != -1) {          if (d->update_x2 != -1) {
741                  int y, addr, addr2, q = d->vfb_scaledown;                  int y, addr, addr2, q = d->vfb_scaledown;
742    
743                  if (d->update_x1 >= d->visible_xsize)   d->update_x1 = d->visible_xsize - 1;                  if (d->update_x1 >= d->visible_xsize)
744                  if (d->update_x2 >= d->visible_xsize)   d->update_x2 = d->visible_xsize - 1;                          d->update_x1 = d->visible_xsize - 1;
745                  if (d->update_y1 >= d->visible_ysize)   d->update_y1 = d->visible_ysize - 1;                  if (d->update_x2 >= d->visible_xsize)
746                  if (d->update_y2 >= d->visible_ysize)   d->update_y2 = d->visible_ysize - 1;                          d->update_x2 = d->visible_xsize - 1;
747                    if (d->update_y1 >= d->visible_ysize)
748                            d->update_y1 = d->visible_ysize - 1;
749                    if (d->update_y2 >= d->visible_ysize)
750                            d->update_y2 = d->visible_ysize - 1;
751    
752                  /*  Without these, we might miss the right most / bottom pixel:  */                  /*  Without these, we might miss the rightmost/bottom pixel:  */
753                  d->update_x2 += (q - 1);                  d->update_x2 += (q - 1);
754                  d->update_y2 += (q - 1);                  d->update_y2 += (q - 1);
755    
# Line 741  void dev_fb_tick(struct cpu *cpu, void * Line 758  void dev_fb_tick(struct cpu *cpu, void *
758                  d->update_y1 = d->update_y1 / q * q;                  d->update_y1 = d->update_y1 / q * q;
759                  d->update_y2 = d->update_y2 / q * q;                  d->update_y2 = d->update_y2 / q * q;
760    
761                  addr  = d->update_y1 * d->bytes_per_line + d->update_x1 * d->bit_depth / 8;                  addr  = d->update_y1 * d->bytes_per_line +
762                  addr2 = d->update_y1 * d->bytes_per_line + d->update_x2 * d->bit_depth / 8;                      d->update_x1 * d->bit_depth / 8;
763                    addr2 = d->update_y1 * d->bytes_per_line +
764                        d->update_x2 * d->bit_depth / 8;
765    
766                  for (y=d->update_y1; y<=d->update_y2; y+=q) {                  for (y=d->update_y1; y<=d->update_y2; y+=q) {
767                          update_framebuffer(d, addr, addr2 - addr);                          update_framebuffer(d, addr, addr2 - addr);
# Line 751  void dev_fb_tick(struct cpu *cpu, void * Line 770  void dev_fb_tick(struct cpu *cpu, void *
770                  }                  }
771    
772  #ifdef WITH_X11  #ifdef WITH_X11
773                  XPutImage(d->fb_window->x11_display, d->fb_window->x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->fb_ximage,                  XPutImage(d->fb_window->x11_display, d->fb_window->
774                      d->update_x1/d->vfb_scaledown, d->update_y1/d->vfb_scaledown,                      x11_fb_window, d->fb_window->x11_fb_gc, d->fb_window->
775                      d->update_x1/d->vfb_scaledown, d->update_y1/d->vfb_scaledown,                      fb_ximage, d->update_x1/d->vfb_scaledown, d->update_y1/
776                        d->vfb_scaledown, d->update_x1/d->vfb_scaledown,
777                        d->update_y1/d->vfb_scaledown,
778                      (d->update_x2 - d->update_x1)/d->vfb_scaledown + 1,                      (d->update_x2 - d->update_x1)/d->vfb_scaledown + 1,
779                      (d->update_y2 - d->update_y1)/d->vfb_scaledown + 1);                      (d->update_y2 - d->update_y1)/d->vfb_scaledown + 1);
780    
# Line 768  void dev_fb_tick(struct cpu *cpu, void * Line 789  void dev_fb_tick(struct cpu *cpu, void *
789          if (need_to_redraw_cursor) {          if (need_to_redraw_cursor) {
790                  /*  Paint new cursor:  */                  /*  Paint new cursor:  */
791                  if (d->fb_window->cursor_on) {                  if (d->fb_window->cursor_on) {
792                          x11_redraw_cursor(cpu->machine, d->fb_window->fb_number);                          x11_redraw_cursor(cpu->machine,
793                                d->fb_window->fb_number);
794                          d->fb_window->OLD_cursor_on = d->fb_window->cursor_on;                          d->fb_window->OLD_cursor_on = d->fb_window->cursor_on;
795                          d->fb_window->OLD_cursor_x = d->fb_window->cursor_x;                          d->fb_window->OLD_cursor_x = d->fb_window->cursor_x;
796                          d->fb_window->OLD_cursor_y = d->fb_window->cursor_y;                          d->fb_window->OLD_cursor_y = d->fb_window->cursor_y;
797                          d->fb_window->OLD_cursor_xsize = d->fb_window->cursor_xsize;                          d->fb_window->OLD_cursor_xsize = d->fb_window->
798                          d->fb_window->OLD_cursor_ysize = d->fb_window->cursor_ysize;                              cursor_xsize;
799                            d->fb_window->OLD_cursor_ysize = d->fb_window->
800                                cursor_ysize;
801                  }                  }
802          }          }
803  #endif  #endif

Legend:
Removed from v.12  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26