--- trunk/src/devices/dev_fb.c 2007/10/08 16:21:17 34 +++ trunk/src/devices/dev_fb.c 2007/10/08 16:22:32 42 @@ -25,9 +25,9 @@ * SUCH DAMAGE. * * - * $Id: dev_fb.c,v 1.128 2006/12/30 13:30:57 debug Exp $ + * $Id: dev_fb.c,v 1.132 2007/06/15 19:11:15 debug Exp $ * - * Generic framebuffer device. + * COMMENT: Generic framebuffer device * * DECstation VFB01 monochrome framebuffer, 1024x864 * DECstation VFB02 8-bit color framebuffer, 1024x864 @@ -141,11 +141,7 @@ new_bytes_per_line = new_xsize * d->bit_depth / 8; size = new_ysize * new_bytes_per_line; - new_framebuffer = malloc(size); - if (new_framebuffer == NULL) { - fprintf(stderr, "dev_fb_resize(): out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(new_framebuffer = malloc(size)); /* Copy the old framebuffer to the new: */ if (d->framebuffer != NULL) { @@ -268,8 +264,8 @@ d->framebuffer + dest_ofs; if (d->bit_depth == 24) { - for (x=0; xmachine->use_x11) + if (!cpu->machine->x11_md.in_use) return; do { @@ -650,7 +646,7 @@ * of which area(s) we modify, so that the display isn't updated * unnecessarily. */ - if (writeflag == MEM_WRITE && cpu->machine->use_x11) { + if (writeflag == MEM_WRITE && cpu->machine->x11_md.in_use) { int x, y, x2,y2; x = (relative_addr % d->bytes_per_line) * 8 / d->bit_depth; @@ -748,11 +744,7 @@ int reverse_start = 0; char *name2; - d = malloc(sizeof(struct vfb_data)); - if (d == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(d = malloc(sizeof(struct vfb_data))); memset(d, 0, sizeof(struct vfb_data)); if (vfb_type & VFB_REVERSE_START) { @@ -810,16 +802,12 @@ else if (d->bit_depth == 8 || d->bit_depth == 1) set_blackwhite_palette(d, 1 << d->bit_depth); - d->vfb_scaledown = machine->x11_scaledown; + d->vfb_scaledown = machine->x11_md.scaledown; d->bytes_per_line = d->xsize * d->bit_depth / 8; size = d->ysize * d->bytes_per_line; - d->framebuffer = malloc(size); - if (d->framebuffer == NULL) { - fprintf(stderr, "out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(d->framebuffer = malloc(size)); /* Clear the framebuffer (all black pixels): */ d->framebuffer_size = size; @@ -839,14 +827,14 @@ d->update_x2 = d->update_y2 = -1; } - d->name = strdup(name); + CHECK_ALLOCATION(d->name = strdup(name)); set_title(d); #ifdef WITH_X11 - if (machine->use_x11) { + if (machine->x11_md.in_use) { int i = 0; d->fb_window = x11_fb_init(d->x11_xsize, d->x11_ysize, - d->title, machine->x11_scaledown, machine); + d->title, machine->x11_md.scaledown, machine); switch (d->fb_window->x11_screen_depth) { case 15: i = 2; break; case 16: i = 4; break; @@ -862,11 +850,8 @@ d->fb_window = NULL; nlen = strlen(name) + 10; - name2 = malloc(nlen); - if (name2 == NULL) { - fprintf(stderr, "out of memory in dev_fb_init()\n"); - exit(1); - } + CHECK_ALLOCATION(name2 = malloc(nlen)); + snprintf(name2, nlen, "fb [%s]", name); flags = DM_DEFAULT; @@ -878,7 +863,8 @@ memory_device_register(mem, name2, baseaddr, size, dev_fb_access, d, flags, d->framebuffer); - machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT, 0.0); + machine_add_tickfunction(machine, dev_fb_tick, d, FB_TICK_SHIFT); + return d; }