52 |
|
#include <X11/extensions/xf86dga.h> |
53 |
|
#endif |
54 |
|
|
55 |
+ |
#if ENABLE_XF86_VIDMODE |
56 |
+ |
#include <X11/extensions/xf86vmode.h> |
57 |
+ |
#endif |
58 |
+ |
|
59 |
|
#if ENABLE_FBDEV_DGA |
60 |
|
#include <sys/mman.h> |
61 |
|
#endif |
68 |
|
DISPLAY_DGA // DGA fullscreen display |
69 |
|
}; |
70 |
|
|
67 |
– |
|
71 |
|
// Constants |
72 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
73 |
|
const char FBDEVICES_FILE_NAME[] = DATADIR "/fbdevices"; |
74 |
|
|
75 |
|
|
76 |
|
// Global variables |
77 |
< |
static int32 frame_skip; |
77 |
> |
static int32 frame_skip; // Prefs items |
78 |
> |
static int16 mouse_wheel_mode = 1; |
79 |
> |
static int16 mouse_wheel_lines = 3; |
80 |
> |
|
81 |
|
static int display_type = DISPLAY_WINDOW; // See enum above |
82 |
|
static uint8 *the_buffer; // Mac frame buffer |
83 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
85 |
|
static pthread_t redraw_thread; // Redraw thread |
86 |
|
|
87 |
|
static bool has_dga = false; // Flag: Video DGA capable |
88 |
+ |
static bool has_vidmode = false; // Flag: VidMode extension available |
89 |
|
|
90 |
|
static bool ctrl_down = false; // Flag: Ctrl key pressed |
91 |
|
static bool caps_on = false; // Flag: Caps Lock on |
127 |
|
static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer |
128 |
|
static uint8 the_cursor[64]; // Cursor image data |
129 |
|
static bool have_shm = false; // Flag: SHM extensions available |
130 |
+ |
static bool updt_box[17][17]; // Flag for Update |
131 |
+ |
static int nr_boxes; |
132 |
+ |
static const int sm_uptd[] = {4,1,6,3,0,5,2,7}; |
133 |
+ |
static int sm_no_boxes[] = {1,8,32,64,128,300}; |
134 |
|
|
135 |
|
// Variables for XF86 DGA mode |
136 |
|
static int current_dga_cmap; // Number (0 or 1) of currently installed DGA colormap |
142 |
|
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
143 |
|
static int fbdev_fd; |
144 |
|
|
145 |
+ |
#if ENABLE_XF86_VIDMODE |
146 |
+ |
// Variables for XF86 VidMode support |
147 |
+ |
static XF86VidModeModeInfo **x_video_modes; // Array of all available modes |
148 |
+ |
static int num_x_video_modes; |
149 |
+ |
#endif |
150 |
+ |
|
151 |
|
|
152 |
|
// Prototypes |
153 |
|
static void *redraw_func(void *arg); |
217 |
|
// Init window mode |
218 |
|
static bool init_window(int width, int height) |
219 |
|
{ |
220 |
+ |
int aligned_width = (width + 15) & ~15; |
221 |
+ |
int aligned_height = (height + 15) & ~15; |
222 |
+ |
|
223 |
|
// Set absolute mouse mode |
224 |
|
ADBSetRelMouseMode(false); |
225 |
|
|
233 |
|
wattr.event_mask = eventmask = win_eventmask; |
234 |
|
wattr.background_pixel = black_pixel; |
235 |
|
wattr.border_pixel = black_pixel; |
236 |
< |
wattr.backing_store = Always; |
236 |
> |
wattr.backing_store = NotUseful; |
237 |
> |
wattr.save_under = false; |
238 |
|
wattr.backing_planes = xdepth; |
239 |
|
|
240 |
|
XSync(x_display, false); |
270 |
|
|
271 |
|
// Create SHM image ("height + 2" for safety) |
272 |
|
img = XShmCreateImage(x_display, vis, depth, depth == 1 ? XYBitmap : ZPixmap, 0, &shminfo, width, height); |
273 |
< |
shminfo.shmid = shmget(IPC_PRIVATE, (height + 2) * img->bytes_per_line, IPC_CREAT | 0777); |
274 |
< |
the_buffer = (uint8 *)shmat(shminfo.shmid, 0, 0); |
275 |
< |
shminfo.shmaddr = img->data = (char *)the_buffer; |
273 |
> |
shminfo.shmid = shmget(IPC_PRIVATE, (aligned_height + 2) * img->bytes_per_line, IPC_CREAT | 0777); |
274 |
> |
the_buffer_copy = (uint8 *)shmat(shminfo.shmid, 0, 0); |
275 |
> |
shminfo.shmaddr = img->data = (char *)the_buffer_copy; |
276 |
|
shminfo.readOnly = False; |
277 |
|
|
278 |
|
// Try to attach SHM image, catching errors |
293 |
|
|
294 |
|
// Create normal X image if SHM doesn't work ("height + 2" for safety) |
295 |
|
if (!have_shm) { |
296 |
< |
int bytes_per_row = width; |
296 |
> |
int bytes_per_row = aligned_width; |
297 |
|
switch (depth) { |
298 |
|
case 1: |
299 |
|
bytes_per_row /= 8; |
307 |
|
bytes_per_row *= 4; |
308 |
|
break; |
309 |
|
} |
310 |
< |
the_buffer = (uint8 *)malloc((height + 2) * bytes_per_row); |
311 |
< |
img = XCreateImage(x_display, vis, depth, depth == 1 ? XYBitmap : ZPixmap, 0, (char *)the_buffer, width, height, 32, bytes_per_row); |
310 |
> |
the_buffer_copy = (uint8 *)malloc((aligned_height + 2) * bytes_per_row); |
311 |
> |
img = XCreateImage(x_display, vis, depth, depth == 1 ? XYBitmap : ZPixmap, 0, (char *)the_buffer_copy, aligned_width, aligned_height, 32, bytes_per_row); |
312 |
|
} |
313 |
|
|
314 |
|
// 1-Bit mode is big-endian |
318 |
|
} |
319 |
|
|
320 |
|
// Allocate memory for frame buffer copy |
321 |
< |
the_buffer_copy = (uint8 *)malloc((height + 2) * img->bytes_per_line); |
321 |
> |
the_buffer = (uint8 *)malloc((aligned_height + 2) * img->bytes_per_line); |
322 |
|
|
323 |
|
// Create GC |
324 |
|
the_gc = XCreateGC(x_display, the_win, 0, 0); |
325 |
|
XSetState(x_display, the_gc, black_pixel, white_pixel, GXcopy, AllPlanes); |
326 |
|
|
327 |
< |
// Create cursor |
328 |
< |
cursor_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)the_cursor, 16, 16, 16, 2); |
329 |
< |
cursor_image->byte_order = MSBFirst; |
330 |
< |
cursor_image->bitmap_bit_order = MSBFirst; |
331 |
< |
cursor_mask_image = XCreateImage(x_display, vis, 1, XYPixmap, 0, (char *)the_cursor+32, 16, 16, 16, 2); |
332 |
< |
cursor_mask_image->byte_order = MSBFirst; |
312 |
< |
cursor_mask_image->bitmap_bit_order = MSBFirst; |
313 |
< |
cursor_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
314 |
< |
cursor_mask_map = XCreatePixmap(x_display, the_win, 16, 16, 1); |
315 |
< |
cursor_gc = XCreateGC(x_display, cursor_map, 0, 0); |
316 |
< |
cursor_mask_gc = XCreateGC(x_display, cursor_mask_map, 0, 0); |
317 |
< |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, 0, 0); |
327 |
> |
// Create no_cursor |
328 |
> |
mac_cursor = XCreatePixmapCursor (x_display, |
329 |
> |
XCreatePixmap (x_display, the_win, 1, 1, 1), |
330 |
> |
XCreatePixmap (x_display, the_win, 1, 1, 1), |
331 |
> |
&black, &white, 0, 0); |
332 |
> |
XDefineCursor (x_display, the_win, mac_cursor); |
333 |
|
|
334 |
|
// Set VideoMonitor |
335 |
|
#ifdef WORDS_BIGENDIAN |
355 |
|
int ndepths, max_depth(0); |
356 |
|
int *depths = XListDepths(x_display, screen, &ndepths); |
357 |
|
if (depths == NULL) { |
358 |
< |
fprintf(stderr, "Error: could not determine the maximal depth available\n"); |
358 |
> |
printf("FATAL: Could not determine the maximal depth available\n"); |
359 |
|
return false; |
360 |
|
} else { |
361 |
|
while (ndepths-- > 0) { |
444 |
|
|
445 |
|
// Set colormap |
446 |
|
if (depth == 8) { |
447 |
< |
XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap = 0]); |
447 |
> |
XSetWindowColormap(x_display, the_win, cmap[0]); |
448 |
|
XSetWMColormapWindows(x_display, the_win, &the_win, 1); |
449 |
|
} |
450 |
|
|
480 |
|
#else |
481 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
482 |
|
#endif |
468 |
– |
|
469 |
– |
printf("FbDev DGA with %s in %d-bit mode enabled\n", fb_name, fb_depth); |
483 |
|
return true; |
484 |
|
#else |
485 |
|
ErrorAlert("Basilisk II has been compiled with fbdev DGA support disabled."); |
494 |
|
// Set relative mouse mode |
495 |
|
ADBSetRelMouseMode(true); |
496 |
|
|
497 |
+ |
#if ENABLE_XF86_VIDMODE |
498 |
+ |
// Switch to best mode |
499 |
+ |
if (has_vidmode) { |
500 |
+ |
int best = 0; |
501 |
+ |
for (int i=1; i<num_x_video_modes; i++) { |
502 |
+ |
if (x_video_modes[i]->hdisplay >= width && x_video_modes[i]->vdisplay >= height && |
503 |
+ |
x_video_modes[i]->hdisplay <= x_video_modes[best]->hdisplay && x_video_modes[i]->vdisplay <= x_video_modes[best]->vdisplay) { |
504 |
+ |
best = i; |
505 |
+ |
} |
506 |
+ |
} |
507 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[best]); |
508 |
+ |
XF86VidModeSetViewPort(x_display, screen, 0, 0); |
509 |
+ |
} |
510 |
+ |
#endif |
511 |
+ |
|
512 |
|
// Create window |
513 |
|
XSetWindowAttributes wattr; |
514 |
|
wattr.event_mask = eventmask = dga_eventmask; |
641 |
|
// Init keycode translation |
642 |
|
keycode_init(); |
643 |
|
|
644 |
+ |
// Read prefs |
645 |
+ |
mouse_wheel_mode = PrefsFindInt16("mousewheelmode"); |
646 |
+ |
mouse_wheel_lines = PrefsFindInt16("mousewheellines"); |
647 |
+ |
|
648 |
|
// Find screen and root window |
649 |
|
screen = XDefaultScreen(x_display); |
650 |
|
rootwin = XRootWindow(x_display, screen); |
662 |
|
else |
663 |
|
has_dga = false; |
664 |
|
#endif |
665 |
< |
|
665 |
> |
|
666 |
|
#if ENABLE_XF86_DGA |
667 |
|
// DGA available? |
668 |
< |
int event_base, error_base; |
669 |
< |
if (XF86DGAQueryExtension(x_display, &event_base, &error_base)) { |
668 |
> |
int dga_event_base, dga_error_base; |
669 |
> |
if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) { |
670 |
|
int dga_flags = 0; |
671 |
|
XF86DGAQueryDirectVideo(x_display, screen, &dga_flags); |
672 |
|
has_dga = dga_flags & XF86DGADirectPresent; |
674 |
|
has_dga = false; |
675 |
|
#endif |
676 |
|
|
677 |
+ |
#if ENABLE_XF86_VIDMODE |
678 |
+ |
// VidMode available? |
679 |
+ |
int vm_event_base, vm_error_base; |
680 |
+ |
has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base); |
681 |
+ |
if (has_vidmode) |
682 |
+ |
XF86VidModeGetAllModeLines(x_display, screen, &num_x_video_modes, &x_video_modes); |
683 |
+ |
#endif |
684 |
+ |
|
685 |
|
// Find black and white colors |
686 |
|
XParseColor(x_display, DefaultColormap(x_display, screen), "rgb:00/00/00", &black); |
687 |
|
XAllocColor(x_display, DefaultColormap(x_display, screen), &black); |
833 |
|
} |
834 |
|
#endif |
835 |
|
|
836 |
+ |
#if ENABLE_XF86_VIDMODE |
837 |
+ |
if (has_vidmode && display_type == DISPLAY_DGA) |
838 |
+ |
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); |
839 |
+ |
#endif |
840 |
+ |
|
841 |
|
#if ENABLE_FBDEV_DGA |
842 |
|
if (display_type == DISPLAY_DGA) { |
843 |
|
XUngrabPointer(x_display, CurrentTime); |
845 |
|
close(fbdev_fd); |
846 |
|
} |
847 |
|
#endif |
803 |
– |
|
804 |
– |
if (the_buffer_copy) { |
805 |
– |
free(the_buffer_copy); |
806 |
– |
the_buffer_copy = NULL; |
807 |
– |
} |
848 |
|
|
849 |
|
XFlush(x_display); |
850 |
|
XSync(x_display, false); |
852 |
|
XFreeColormap(x_display, cmap[0]); |
853 |
|
XFreeColormap(x_display, cmap[1]); |
854 |
|
} |
855 |
+ |
|
856 |
+ |
if (the_buffer) { |
857 |
+ |
free(the_buffer); |
858 |
+ |
the_buffer = NULL; |
859 |
+ |
} |
860 |
+ |
|
861 |
+ |
if (!have_shm && the_buffer_copy) { |
862 |
+ |
free(the_buffer_copy); |
863 |
+ |
the_buffer_copy = NULL; |
864 |
+ |
} |
865 |
|
} |
866 |
|
} |
867 |
|
|
998 |
|
#if ENABLE_XF86_DGA |
999 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1000 |
|
#endif |
951 |
– |
#if ENABLE_FBDEV_DGA |
952 |
– |
XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap]); |
953 |
– |
#endif |
1001 |
|
|
1002 |
|
// Unlock frame buffer (and continue MacOS thread) |
1003 |
|
pthread_mutex_unlock(&frame_buffer_lock); |
1189 |
|
unsigned int button = ((XButtonEvent *)&event)->button; |
1190 |
|
if (button < 4) |
1191 |
|
ADBMouseDown(button - 1); |
1192 |
+ |
else if (button < 6) { // Wheel mouse |
1193 |
+ |
if (mouse_wheel_mode == 0) { |
1194 |
+ |
int key = (button == 5) ? 0x79 : 0x74; // Page up/down |
1195 |
+ |
ADBKeyDown(key); |
1196 |
+ |
ADBKeyUp(key); |
1197 |
+ |
} else { |
1198 |
+ |
int key = (button == 5) ? 0x3d : 0x3e; // Cursor up/down |
1199 |
+ |
for(int i=0; i<mouse_wheel_lines; i++) { |
1200 |
+ |
ADBKeyDown(key); |
1201 |
+ |
ADBKeyUp(key); |
1202 |
+ |
} |
1203 |
+ |
} |
1204 |
+ |
} |
1205 |
|
break; |
1206 |
|
} |
1207 |
|
case ButtonRelease: { |
1267 |
|
|
1268 |
|
// Hidden parts exposed, force complete refresh of window |
1269 |
|
case Expose: |
1270 |
< |
if (display_type == DISPLAY_WINDOW) |
1271 |
< |
memset(the_buffer_copy, 0, VideoMonitor.bytes_per_row * VideoMonitor.y); |
1270 |
> |
if (display_type == DISPLAY_WINDOW) { |
1271 |
> |
int x1, y1; |
1272 |
> |
for (y1=0; y1<16; y1++) |
1273 |
> |
for (x1=0; x1<16; x1++) |
1274 |
> |
updt_box[x1][y1] = true; |
1275 |
> |
nr_boxes = 16 * 16; |
1276 |
> |
} |
1277 |
|
break; |
1278 |
|
} |
1279 |
|
} |
1284 |
|
* Window display update |
1285 |
|
*/ |
1286 |
|
|
1287 |
< |
static void update_display(void) |
1287 |
> |
static void update_display(int ticker) |
1288 |
|
{ |
1289 |
< |
// In classic mode, copy the frame buffer from Mac RAM |
1290 |
< |
if (classic_mode) |
1291 |
< |
memcpy(the_buffer, Mac2HostAddr(0x3fa700), VideoMonitor.bytes_per_row * VideoMonitor.y); |
1227 |
< |
|
1228 |
< |
// Incremental update code |
1229 |
< |
int wide = 0, high = 0, x1, x2, y1, y2, i, j; |
1289 |
> |
int y1, y2, y2s, y2a, i, x1, xm, xmo, ymo, yo, yi, yil, xic, xicl, xi; |
1290 |
> |
int xil = 0; |
1291 |
> |
int rxm = 0, rxmo = 0; |
1292 |
|
int bytes_per_row = VideoMonitor.bytes_per_row; |
1293 |
|
int bytes_per_pixel = VideoMonitor.bytes_per_row / VideoMonitor.x; |
1294 |
< |
uint8 *p, *p2; |
1295 |
< |
|
1296 |
< |
// Check for first line from top and first line from bottom that have changed |
1297 |
< |
y1 = 0; |
1298 |
< |
for (j=0; j<VideoMonitor.y; j++) { |
1299 |
< |
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
1300 |
< |
y1 = j; |
1301 |
< |
break; |
1240 |
< |
} |
1241 |
< |
} |
1242 |
< |
y2 = y1 - 1; |
1243 |
< |
for (j=VideoMonitor.y-1; j>=y1; j--) { |
1244 |
< |
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
1245 |
< |
y2 = j; |
1294 |
> |
int rx = VideoMonitor.bytes_per_row / 16; |
1295 |
> |
int ry = VideoMonitor.y / 16; |
1296 |
> |
int max_box; |
1297 |
> |
|
1298 |
> |
y2s = sm_uptd[ticker % 8]; |
1299 |
> |
y2a = 8; |
1300 |
> |
for (i = 0; i < 6; i++) |
1301 |
> |
if (ticker % (2 << i)) |
1302 |
|
break; |
1303 |
< |
} |
1248 |
< |
} |
1249 |
< |
high = y2 - y1 + 1; |
1303 |
> |
max_box = sm_no_boxes[i]; |
1304 |
|
|
1305 |
< |
// Check for first column from left and first column from right that have changed |
1306 |
< |
if (high) { |
1307 |
< |
if (depth == 1) { |
1308 |
< |
x1 = VideoMonitor.x; |
1309 |
< |
for (j=y1; j<=y2; j++) { |
1310 |
< |
p = &the_buffer[j * bytes_per_row]; |
1311 |
< |
p2 = &the_buffer_copy[j * bytes_per_row]; |
1312 |
< |
for (i=0; i<(x1>>3); i++) { |
1313 |
< |
if (*p != *p2) { |
1314 |
< |
x1 = i << 3; |
1261 |
< |
break; |
1305 |
> |
if (y2a) { |
1306 |
> |
for (y1=0; y1<16; y1++) { |
1307 |
> |
for (y2=y2s; y2 < ry; y2 += y2a) { |
1308 |
> |
i = ((y1 * ry) + y2) * bytes_per_row; |
1309 |
> |
for (x1=0; x1<16; x1++, i += rx) { |
1310 |
> |
if (updt_box[x1][y1] == false) { |
1311 |
> |
if (memcmp(&the_buffer_copy[i], &the_buffer[i], rx)) { |
1312 |
> |
updt_box[x1][y1] = true; |
1313 |
> |
nr_boxes++; |
1314 |
> |
} |
1315 |
|
} |
1263 |
– |
p++; |
1264 |
– |
p2++; |
1316 |
|
} |
1317 |
|
} |
1318 |
< |
x2 = x1; |
1319 |
< |
for (j=y1; j<=y2; j++) { |
1269 |
< |
p = &the_buffer[j * bytes_per_row]; |
1270 |
< |
p2 = &the_buffer_copy[j * bytes_per_row]; |
1271 |
< |
p += bytes_per_row; |
1272 |
< |
p2 += bytes_per_row; |
1273 |
< |
for (i=(VideoMonitor.x>>3); i>(x2>>3); i--) { |
1274 |
< |
p--; |
1275 |
< |
p2--; |
1276 |
< |
if (*p != *p2) { |
1277 |
< |
x2 = i << 3; |
1278 |
< |
break; |
1279 |
< |
} |
1280 |
< |
} |
1281 |
< |
} |
1282 |
< |
wide = x2 - x1; |
1318 |
> |
} |
1319 |
> |
} |
1320 |
|
|
1321 |
< |
// Update copy of the_buffer |
1322 |
< |
if (high && wide) { |
1323 |
< |
for (j=y1; j<=y2; j++) { |
1324 |
< |
i = j * bytes_per_row + (x1 >> 3); |
1325 |
< |
memcpy(&the_buffer_copy[i], &the_buffer[i], wide >> 3); |
1321 |
> |
if ((nr_boxes <= max_box) && (nr_boxes)) { |
1322 |
> |
for (y1=0; y1<16; y1++) { |
1323 |
> |
for (x1=0; x1<16; x1++) { |
1324 |
> |
if (updt_box[x1][y1] == true) { |
1325 |
> |
if (rxm == 0) |
1326 |
> |
xm = x1; |
1327 |
> |
rxm += rx; |
1328 |
> |
updt_box[x1][y1] = false; |
1329 |
|
} |
1330 |
< |
} |
1331 |
< |
|
1332 |
< |
} else { |
1333 |
< |
x1 = VideoMonitor.x; |
1334 |
< |
for (j=y1; j<=y2; j++) { |
1335 |
< |
p = &the_buffer[j * bytes_per_row]; |
1336 |
< |
p2 = &the_buffer_copy[j * bytes_per_row]; |
1337 |
< |
for (i=0; i<x1; i++) { |
1338 |
< |
if (memcmp(p, p2, bytes_per_pixel)) { |
1339 |
< |
x1 = i; |
1340 |
< |
break; |
1330 |
> |
if (((updt_box[x1+1][y1] == false) || (x1 == 15)) && (rxm)) { |
1331 |
> |
if ((rxmo != rxm) || (xmo != xm) || (yo != y1 - 1)) { |
1332 |
> |
if (rxmo) { |
1333 |
> |
xi = xmo * rx; |
1334 |
> |
yi = ymo * ry; |
1335 |
> |
xil = rxmo; |
1336 |
> |
yil = (yo - ymo +1) * ry; |
1337 |
> |
} |
1338 |
> |
rxmo = rxm; |
1339 |
> |
xmo = xm; |
1340 |
> |
ymo = y1; |
1341 |
|
} |
1342 |
< |
p += bytes_per_pixel; |
1343 |
< |
p2 += bytes_per_pixel; |
1344 |
< |
} |
1345 |
< |
} |
1346 |
< |
x2 = x1; |
1347 |
< |
for (j=y1; j<=y2; j++) { |
1348 |
< |
p = &the_buffer[j * bytes_per_row]; |
1349 |
< |
p2 = &the_buffer_copy[j * bytes_per_row]; |
1350 |
< |
p += bytes_per_row; |
1351 |
< |
p2 += bytes_per_row; |
1352 |
< |
for (i=VideoMonitor.x; i>x2; i--) { |
1353 |
< |
p -= bytes_per_pixel; |
1354 |
< |
p2 -= bytes_per_pixel; |
1355 |
< |
if (memcmp(p, p2, bytes_per_pixel)) { |
1356 |
< |
x2 = i; |
1357 |
< |
break; |
1342 |
> |
rxm = 0; |
1343 |
> |
yo = y1; |
1344 |
> |
} |
1345 |
> |
if (xil) { |
1346 |
> |
i = (yi * bytes_per_row) + xi; |
1347 |
> |
for (y2=0; y2 < yil; y2++, i += bytes_per_row) |
1348 |
> |
memcpy(&the_buffer_copy[i], &the_buffer[i], xil); |
1349 |
> |
if (depth == 1) { |
1350 |
> |
if (have_shm) |
1351 |
> |
XShmPutImage(x_display, the_win, the_gc, img, xi * 8, yi, xi * 8, yi, xil * 8, yil, 0); |
1352 |
> |
else |
1353 |
> |
XPutImage(x_display, the_win, the_gc, img, xi * 8, yi, xi * 8, yi, xil * 8, yil); |
1354 |
> |
} else { |
1355 |
> |
if (have_shm) |
1356 |
> |
XShmPutImage(x_display, the_win, the_gc, img, xi / bytes_per_pixel, yi, xi / bytes_per_pixel, yi, xil / bytes_per_pixel, yil, 0); |
1357 |
> |
else |
1358 |
> |
XPutImage(x_display, the_win, the_gc, img, xi / bytes_per_pixel, yi, xi / bytes_per_pixel, yi, xil / bytes_per_pixel, yil); |
1359 |
|
} |
1360 |
+ |
xil = 0; |
1361 |
|
} |
1362 |
< |
} |
1363 |
< |
wide = x2 - x1; |
1364 |
< |
|
1365 |
< |
// Update copy of the_buffer |
1366 |
< |
if (high && wide) { |
1367 |
< |
for (j=y1; j<=y2; j++) { |
1368 |
< |
i = j * bytes_per_row + x1 * bytes_per_pixel; |
1327 |
< |
memcpy(&the_buffer_copy[i], &the_buffer[i], bytes_per_pixel * wide); |
1362 |
> |
if ((x1 == 15) && (y1 == 15) && (rxmo)) { |
1363 |
> |
x1--; |
1364 |
> |
xi = xmo * rx; |
1365 |
> |
yi = ymo * ry; |
1366 |
> |
xil = rxmo; |
1367 |
> |
yil = (yo - ymo +1) * ry; |
1368 |
> |
rxmo = 0; |
1369 |
|
} |
1370 |
|
} |
1371 |
|
} |
1372 |
< |
} |
1332 |
< |
|
1333 |
< |
// Refresh display |
1334 |
< |
if (high && wide) { |
1335 |
< |
if (have_shm) |
1336 |
< |
XShmPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, wide, high, 0); |
1337 |
< |
else |
1338 |
< |
XPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, wide, high); |
1339 |
< |
} |
1340 |
< |
|
1341 |
< |
// Has the Mac started? (cursor data is not valid otherwise) |
1342 |
< |
if (HasMacStarted()) { |
1343 |
< |
|
1344 |
< |
// Set new cursor image if it was changed |
1345 |
< |
if (memcmp(the_cursor, Mac2HostAddr(0x844), 64)) { |
1346 |
< |
memcpy(the_cursor, Mac2HostAddr(0x844), 64); |
1347 |
< |
memcpy(cursor_image->data, the_cursor, 32); |
1348 |
< |
memcpy(cursor_mask_image->data, the_cursor+32, 32); |
1349 |
< |
XFreeCursor(x_display, mac_cursor); |
1350 |
< |
XPutImage(x_display, cursor_map, cursor_gc, cursor_image, 0, 0, 0, 0, 16, 16); |
1351 |
< |
XPutImage(x_display, cursor_mask_map, cursor_mask_gc, cursor_mask_image, 0, 0, 0, 0, 16, 16); |
1352 |
< |
mac_cursor = XCreatePixmapCursor(x_display, cursor_map, cursor_mask_map, &black, &white, ReadMacInt8(0x885), ReadMacInt8(0x887)); |
1353 |
< |
XDefineCursor(x_display, the_win, mac_cursor); |
1354 |
< |
} |
1372 |
> |
nr_boxes = 0; |
1373 |
|
} |
1374 |
|
} |
1375 |
|
|
1435 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1436 |
|
} |
1437 |
|
#endif |
1420 |
– |
|
1421 |
– |
#if ENABLE_FBDEV_DGA |
1422 |
– |
if (display_type == DISPLAY_DGA) |
1423 |
– |
XSetWindowColormap(x_display, the_win, cmap[current_dga_cmap]); |
1424 |
– |
#endif |
1438 |
|
} |
1439 |
|
} |
1440 |
|
pthread_mutex_unlock(&palette_lock); |
1441 |
|
|
1442 |
< |
// In window mode, update display and mouse pointer |
1442 |
> |
// In window mode, update display |
1443 |
|
if (display_type == DISPLAY_WINDOW) { |
1444 |
|
tick_counter++; |
1445 |
< |
if (tick_counter >= frame_skip) { |
1433 |
< |
tick_counter = 0; |
1434 |
< |
update_display(); |
1435 |
< |
} |
1445 |
> |
update_display(tick_counter); |
1446 |
|
} |
1447 |
|
} |
1448 |
|
return NULL; |