1 |
|
/* |
2 |
|
* video_x.cpp - Video/graphics emulation, X11 specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2002 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2004 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
62 |
|
#include "prefs.h" |
63 |
|
#include "user_strings.h" |
64 |
|
#include "video.h" |
65 |
+ |
#include "video_blit.h" |
66 |
|
|
67 |
|
#define DEBUG 0 |
68 |
|
#include "debug.h" |
123 |
|
static int keycode_table[256]; // X keycode -> Mac keycode translation table |
124 |
|
|
125 |
|
// X11 variables |
126 |
+ |
char *x_display_name = NULL; // X11 display name |
127 |
+ |
Display *x_display = NULL; // X11 display handle |
128 |
|
static int screen; // Screen number |
129 |
|
static Window rootwin; // Root window and our window |
130 |
|
static int num_depths = 0; // Number of available X depths |
134 |
|
static int eventmask; |
135 |
|
|
136 |
|
static int xdepth; // Depth of X screen |
137 |
+ |
static VisualFormat visualFormat; |
138 |
|
static XVisualInfo visualInfo; |
139 |
|
static Visual *vis; |
140 |
|
static int color_class; |
192 |
|
// From main_unix.cpp |
193 |
|
extern char *x_display_name; |
194 |
|
extern Display *x_display; |
195 |
+ |
extern void *vm_acquire_mac(size_t size); |
196 |
|
|
197 |
|
// From sys_unix.cpp |
198 |
|
extern void SysMountFirstFloppy(void); |
731 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
732 |
|
the_host_buffer = the_buffer_copy; |
733 |
|
the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line); |
734 |
< |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
734 |
> |
the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); |
735 |
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
736 |
|
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
737 |
|
#else |
759 |
|
native_byte_order = (XImageByteOrder(x_display) == LSBFirst); |
760 |
|
#endif |
761 |
|
#ifdef ENABLE_VOSF |
762 |
< |
Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); |
762 |
> |
Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode)); |
763 |
|
#endif |
764 |
|
|
765 |
|
// Set frame buffer base |
1120 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
1121 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
1122 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
1123 |
< |
use_vosf = Screen_blitter_init(&visualInfo, true, mode.depth); |
1123 |
> |
use_vosf = Screen_blitter_init(visualFormat, true, mode.depth); |
1124 |
|
|
1125 |
|
if (use_vosf) { |
1126 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
1127 |
|
the_host_buffer = the_buffer; |
1128 |
|
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
1129 |
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
1130 |
< |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
1130 |
> |
the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); |
1131 |
|
} |
1132 |
|
#else |
1133 |
|
use_vosf = false; |
1260 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
1261 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
1262 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
1263 |
< |
use_vosf = Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); |
1263 |
> |
use_vosf = Screen_blitter_init(visualFormat, native_byte_order, depth_of_video_mode(mode)); |
1264 |
|
|
1265 |
|
if (use_vosf) { |
1266 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
1267 |
|
the_host_buffer = the_buffer; |
1268 |
|
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
1269 |
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
1270 |
< |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
1270 |
> |
the_buffer = (uint8 *)vm_acquire_mac(the_buffer_size); |
1271 |
|
} |
1272 |
|
#else |
1273 |
|
use_vosf = false; |
1402 |
|
return false; |
1403 |
|
} |
1404 |
|
|
1405 |
+ |
// Build up visualFormat structure |
1406 |
+ |
visualFormat.depth = visualInfo.depth; |
1407 |
+ |
visualFormat.Rmask = visualInfo.red_mask; |
1408 |
+ |
visualFormat.Gmask = visualInfo.green_mask; |
1409 |
+ |
visualFormat.Bmask = visualInfo.blue_mask; |
1410 |
+ |
|
1411 |
|
// Create color maps |
1412 |
|
if (color_class == PseudoColor || color_class == DirectColor) { |
1413 |
|
cmap[0] = XCreateColormap(x_display, rootwin, vis, AllocAll); |