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 |
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) { |
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 { |
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; |
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) { |
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; |
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; |
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; |
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 |
|
|