/[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 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2007  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.123 2006/07/24 08:08:39 debug Exp $   *  $Id: dev_fb.c,v 1.132 2007/06/15 19:11:15 debug Exp $
29   *     *  
30   *  Generic framebuffer device.   *  COMMENT: Generic framebuffer device
31   *   *
32   *      DECstation VFB01 monochrome framebuffer, 1024x864   *      DECstation VFB01 monochrome framebuffer, 1024x864
33   *      DECstation VFB02 8-bit color framebuffer, 1024x864   *      DECstation VFB02 8-bit color framebuffer, 1024x864
34   *      DECstation Maxine, 1024x768 8-bit color   *      DECstation Maxine, 1024x768 8-bit color
  *      HPC (mips, arm, ..) framebuffer  
35   *      Playstation 2 (24-bit color)   *      Playstation 2 (24-bit color)
36   *      Generic (any resolution, several bit depths possible, useful for   *      Generic (any resolution, several bit depths possible, useful for
37   *              testmachines)   *              testmachines)
# Line 142  void dev_fb_resize(struct vfb_data *d, i Line 141  void dev_fb_resize(struct vfb_data *d, i
141          new_bytes_per_line = new_xsize * d->bit_depth / 8;          new_bytes_per_line = new_xsize * d->bit_depth / 8;
142          size = new_ysize * new_bytes_per_line;          size = new_ysize * new_bytes_per_line;
143    
144          new_framebuffer = malloc(size);          CHECK_ALLOCATION(new_framebuffer = malloc(size));
         if (new_framebuffer == NULL) {  
                 fprintf(stderr, "dev_fb_resize(): out of memory\n");  
                 exit(1);  
         }  
145    
146          /*  Copy the old framebuffer to the new:  */          /*  Copy the old framebuffer to the new:  */
147          if (d->framebuffer != NULL) {          if (d->framebuffer != NULL) {
# Line 219  void dev_fb_setcursor(struct vfb_data *d Line 214  void dev_fb_setcursor(struct vfb_data *d
214          }          }
215  #endif  #endif
216    
         if (d->fb_window != NULL)  
                 console_set_framebuffer_mouse(cursor_x, cursor_y,  
                     d->fb_window->fb_number);  
   
217          /*  debug("dev_fb_setcursor(%i,%i, size %i,%i, on=%i)\n",          /*  debug("dev_fb_setcursor(%i,%i, size %i,%i, on=%i)\n",
218              cursor_x, cursor_y, cursor_xsize, cursor_ysize, on);  */              cursor_x, cursor_y, cursor_xsize, cursor_ysize, on);  */
219  }  }
# Line 273  void framebuffer_blockcopyfill(struct vf Line 264  void framebuffer_blockcopyfill(struct vf
264                                      d->framebuffer + dest_ofs;                                      d->framebuffer + dest_ofs;
265    
266                                  if (d->bit_depth == 24) {                                  if (d->bit_depth == 24) {
267                                          for (x=0; x<linelen && x<sizeof(buf);                                          for (x=0; x<linelen && x <
268                                              x += 3) {                                              (int) sizeof(buf); x += 3) {
269                                                  buf[x] = fill_r;                                                  buf[x] = fill_r;
270                                                  buf[x+1] = fill_g;                                                  buf[x+1] = fill_g;
271                                                  buf[x+2] = fill_b;                                                  buf[x+2] = fill_b;
# Line 413  void (*redraw[2 * 4 * 2])(struct vfb_dat Line 404  void (*redraw[2 * 4 * 2])(struct vfb_dat
404  #endif  /*  WITH_X11  */  #endif  /*  WITH_X11  */
405    
406    
407  /*  DEVICE_TICK(fb)
  *  dev_fb_tick():  
  *  
  */  
 void dev_fb_tick(struct cpu *cpu, void *extra)  
408  {  {
409          struct vfb_data *d = extra;          struct vfb_data *d = extra;
410  #ifdef WITH_X11  #ifdef WITH_X11
# Line 425  void dev_fb_tick(struct cpu *cpu, void * Line 412  void dev_fb_tick(struct cpu *cpu, void *
412          int need_to_redraw_cursor = 0;          int need_to_redraw_cursor = 0;
413  #endif  #endif
414    
415          if (!cpu->machine->use_x11)          if (!cpu->machine->x11_md.in_use)
416                  return;                  return;
417    
418          do {          do {
# Line 617  void dev_fb_tick(struct cpu *cpu, void * Line 604  void dev_fb_tick(struct cpu *cpu, void *
604  }  }
605    
606    
 /*  
  *  dev_fb_access():  
  */  
607  DEVICE_ACCESS(fb)  DEVICE_ACCESS(fb)
608  {  {
609          struct vfb_data *d = extra;          struct vfb_data *d = extra;
# Line 662  DEVICE_ACCESS(fb) Line 646  DEVICE_ACCESS(fb)
646           *  of which area(s) we modify, so that the display isn't updated           *  of which area(s) we modify, so that the display isn't updated
647           *  unnecessarily.           *  unnecessarily.
648           */           */
649          if (writeflag == MEM_WRITE && cpu->machine->use_x11) {          if (writeflag == MEM_WRITE && cpu->machine->x11_md.in_use) {
650                  int x, y, x2,y2;                  int x, y, x2,y2;
651    
652                  x = (relative_addr % d->bytes_per_line) * 8 / d->bit_depth;                  x = (relative_addr % d->bytes_per_line) * 8 / d->bit_depth;
# Line 744  DEVICE_ACCESS(fb) Line 728  DEVICE_ACCESS(fb)
728   *   *
729   *  VFB_DEC_VFB01, _VFB02, and VFB_DEC_MAXINE are DECstation specific.   *  VFB_DEC_VFB01, _VFB02, and VFB_DEC_MAXINE are DECstation specific.
730   *   *
731   *  If type is VFB_HPC, then color encoding differs from the generic case.   *  VFB_HPC is like generic, but the color encoding is done as on HPCmips
732     *  and Dreamcast.
733   *   *
734   *  If bit_depth = -15 (note the minus sign), then a special hack is used for   *  If bit_depth = -15 (note the minus sign), then a special hack is used for
735   *  the Playstation Portable's 5-bit R, 5-bit G, 5-bit B.   *  the Playstation Portable's 5-bit R, 5-bit G, 5-bit B.
# Line 759  struct vfb_data *dev_fb_init(struct mach Line 744  struct vfb_data *dev_fb_init(struct mach
744          int reverse_start = 0;          int reverse_start = 0;
745          char *name2;          char *name2;
746    
747          d = malloc(sizeof(struct vfb_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct vfb_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
748          memset(d, 0, sizeof(struct vfb_data));          memset(d, 0, sizeof(struct vfb_data));
749    
750          if (vfb_type & VFB_REVERSE_START) {          if (vfb_type & VFB_REVERSE_START) {
# Line 821  struct vfb_data *dev_fb_init(struct mach Line 802  struct vfb_data *dev_fb_init(struct mach
802          else if (d->bit_depth == 8 || d->bit_depth == 1)          else if (d->bit_depth == 8 || d->bit_depth == 1)
803                  set_blackwhite_palette(d, 1 << d->bit_depth);                  set_blackwhite_palette(d, 1 << d->bit_depth);
804    
805          d->vfb_scaledown = machine->x11_scaledown;          d->vfb_scaledown = machine->x11_md.scaledown;
806    
807          d->bytes_per_line = d->xsize * d->bit_depth / 8;          d->bytes_per_line = d->xsize * d->bit_depth / 8;
808          size = d->ysize * d->bytes_per_line;          size = d->ysize * d->bytes_per_line;
809    
810          d->framebuffer = malloc(size);          CHECK_ALLOCATION(d->framebuffer = malloc(size));
         if (d->framebuffer == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
811    
812          /*  Clear the framebuffer (all black pixels):  */          /*  Clear the framebuffer (all black pixels):  */
813          d->framebuffer_size = size;          d->framebuffer_size = size;
# Line 850  struct vfb_data *dev_fb_init(struct mach Line 827  struct vfb_data *dev_fb_init(struct mach
827                  d->update_x2 = d->update_y2 = -1;                  d->update_x2 = d->update_y2 = -1;
828          }          }
829    
830          d->name = strdup(name);          CHECK_ALLOCATION(d->name = strdup(name));
831          set_title(d);          set_title(d);
832    
833  #ifdef WITH_X11  #ifdef WITH_X11
834          if (machine->use_x11) {          if (machine->x11_md.in_use) {
835                  int i = 0;                  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                      d->title, machine->x11_scaledown, machine);                      d->title, machine->x11_md.scaledown, machine);
838                  switch (d->fb_window->x11_screen_depth) {                  switch (d->fb_window->x11_screen_depth) {
839                  case 15: i = 2; break;                  case 15: i = 2; break;
840                  case 16: i = 4; break;                  case 16: i = 4; break;
# Line 873  struct vfb_data *dev_fb_init(struct mach Line 850  struct vfb_data *dev_fb_init(struct mach
850                  d->fb_window = NULL;                  d->fb_window = NULL;
851    
852          nlen = strlen(name) + 10;          nlen = strlen(name) + 10;
853          name2 = malloc(nlen);          CHECK_ALLOCATION(name2 = malloc(nlen));
854          if (name2 == NULL) {  
                 fprintf(stderr, "out of memory in dev_fb_init()\n");  
                 exit(1);  
         }  
855          snprintf(name2, nlen, "fb [%s]", name);          snprintf(name2, nlen, "fb [%s]", name);
856    
857          flags = DM_DEFAULT;          flags = DM_DEFAULT;
# Line 889  struct vfb_data *dev_fb_init(struct mach Line 863  struct vfb_data *dev_fb_init(struct mach
863          memory_device_register(mem, name2, baseaddr, size, dev_fb_access,          memory_device_register(mem, name2, baseaddr, size, dev_fb_access,
864              d, flags, d->framebuffer);              d, flags, d->framebuffer);
865    
866          machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT, 0.0);          machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT);
867    
868          return d;          return d;
869  }  }
870    

Legend:
Removed from v.30  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26