/[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 41 by dpavlin, Mon Oct 8 16:22:11 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_fb.c,v 1.129 2007/04/28 09:19:51 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
# Line 141  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 416  DEVICE_TICK(fb) Line 412  DEVICE_TICK(fb)
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 650  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 748  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 810  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 839  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 862  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 878  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.41  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26