1 |
|
/* |
2 |
|
* video_x.cpp - Video/graphics emulation, X11 specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 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 |
39 |
|
|
40 |
|
#include <algorithm> |
41 |
|
|
42 |
– |
#ifndef NO_STD_NAMESPACE |
43 |
– |
using std::sort; |
44 |
– |
#endif |
45 |
– |
|
42 |
|
#ifdef HAVE_PTHREADS |
43 |
|
# include <pthread.h> |
44 |
|
#endif |
67 |
|
#include "debug.h" |
68 |
|
|
69 |
|
|
70 |
+ |
// Supported video modes |
71 |
+ |
static vector<video_mode> VideoModes; |
72 |
+ |
|
73 |
|
// Display types |
74 |
|
enum { |
75 |
|
DISPLAY_WINDOW, // X11 window, using MIT SHM extensions if possible |
96 |
|
|
97 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
98 |
|
#ifdef HAVE_PTHREADS |
99 |
+ |
static pthread_attr_t redraw_thread_attr; // Redraw thread attributes |
100 |
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread |
101 |
|
static pthread_t redraw_thread; // Redraw thread |
102 |
|
#endif |
139 |
|
|
140 |
|
static Colormap cmap[2] = {0, 0}; // Colormaps for indexed modes (DGA needs two of them) |
141 |
|
|
142 |
< |
static XColor palette[256]; // Color palette to be used as CLUT and gamma table |
143 |
< |
static bool palette_changed = false; // Flag: Palette changed, redraw thread must set new colors |
142 |
> |
static XColor x_palette[256]; // Color palette to be used as CLUT and gamma table |
143 |
> |
static bool x_palette_changed = false; // Flag: Palette changed, redraw thread must set new colors |
144 |
|
|
145 |
|
#ifdef ENABLE_FBDEV_DGA |
146 |
|
static int fbdev_fd = -1; |
153 |
|
|
154 |
|
// Mutex to protect palette |
155 |
|
#ifdef HAVE_PTHREADS |
156 |
< |
static pthread_mutex_t palette_lock = PTHREAD_MUTEX_INITIALIZER; |
157 |
< |
#define LOCK_PALETTE pthread_mutex_lock(&palette_lock) |
158 |
< |
#define UNLOCK_PALETTE pthread_mutex_unlock(&palette_lock) |
156 |
> |
static pthread_mutex_t x_palette_lock = PTHREAD_MUTEX_INITIALIZER; |
157 |
> |
#define LOCK_PALETTE pthread_mutex_lock(&x_palette_lock) |
158 |
> |
#define UNLOCK_PALETTE pthread_mutex_unlock(&x_palette_lock) |
159 |
|
#else |
160 |
|
#define LOCK_PALETTE |
161 |
|
#define UNLOCK_PALETTE |
184 |
|
|
185 |
|
// Prototypes |
186 |
|
static void *redraw_func(void *arg); |
187 |
– |
static int event2keycode(XKeyEvent &ev); |
187 |
|
|
188 |
|
// From main_unix.cpp |
189 |
|
extern char *x_display_name; |
194 |
|
|
195 |
|
|
196 |
|
/* |
197 |
+ |
* monitor_desc subclass for X11 display |
198 |
+ |
*/ |
199 |
+ |
|
200 |
+ |
class X11_monitor_desc : public monitor_desc { |
201 |
+ |
public: |
202 |
+ |
X11_monitor_desc(const vector<video_mode> &available_modes, video_depth default_depth, uint32 default_id) : monitor_desc(available_modes, default_depth, default_id) {} |
203 |
+ |
~X11_monitor_desc() {} |
204 |
+ |
|
205 |
+ |
virtual void switch_to_current_mode(void); |
206 |
+ |
virtual void set_palette(uint8 *pal, int num); |
207 |
+ |
|
208 |
+ |
bool video_open(void); |
209 |
+ |
void video_close(void); |
210 |
+ |
}; |
211 |
+ |
|
212 |
+ |
|
213 |
+ |
/* |
214 |
|
* Utility functions |
215 |
|
*/ |
216 |
|
|
217 |
+ |
// Map video_mode depth ID to numerical depth value |
218 |
+ |
static inline int depth_of_video_mode(video_mode const & mode) |
219 |
+ |
{ |
220 |
+ |
int depth = -1; |
221 |
+ |
switch (mode.depth) { |
222 |
+ |
case VDEPTH_1BIT: |
223 |
+ |
depth = 1; |
224 |
+ |
break; |
225 |
+ |
case VDEPTH_2BIT: |
226 |
+ |
depth = 2; |
227 |
+ |
break; |
228 |
+ |
case VDEPTH_4BIT: |
229 |
+ |
depth = 4; |
230 |
+ |
break; |
231 |
+ |
case VDEPTH_8BIT: |
232 |
+ |
depth = 8; |
233 |
+ |
break; |
234 |
+ |
case VDEPTH_16BIT: |
235 |
+ |
depth = 16; |
236 |
+ |
break; |
237 |
+ |
case VDEPTH_32BIT: |
238 |
+ |
depth = 32; |
239 |
+ |
break; |
240 |
+ |
default: |
241 |
+ |
abort(); |
242 |
+ |
} |
243 |
+ |
return depth; |
244 |
+ |
} |
245 |
+ |
|
246 |
|
// Map RGB color to pixel value (this only works in TrueColor/DirectColor visuals) |
247 |
|
static inline uint32 map_rgb(uint8 red, uint8 green, uint8 blue) |
248 |
|
{ |
255 |
|
{ |
256 |
|
D(bug("have_visual_for_depth(%d)\n", 1 << depth)); |
257 |
|
|
258 |
+ |
// 1-bit works always and uses default visual |
259 |
+ |
if (depth == VDEPTH_1BIT) { |
260 |
+ |
vis = DefaultVisual(x_display, screen); |
261 |
+ |
visualInfo.visualid = XVisualIDFromVisual(vis); |
262 |
+ |
int num = 0; |
263 |
+ |
XVisualInfo *vi = XGetVisualInfo(x_display, VisualIDMask, &visualInfo, &num); |
264 |
+ |
visualInfo = vi[0]; |
265 |
+ |
XFree(vi); |
266 |
+ |
xdepth = visualInfo.depth; |
267 |
+ |
color_class = visualInfo.c_class; |
268 |
+ |
D(bug(" found visual ID 0x%02x, depth %d\n", visualInfo.visualid, xdepth)); |
269 |
+ |
return true; |
270 |
+ |
} |
271 |
+ |
|
272 |
|
// Calculate minimum and maximum supported X depth |
273 |
|
int min_depth = 1, max_depth = 32; |
274 |
|
switch (depth) { |
216 |
– |
case VDEPTH_1BIT: // 1-bit works always and uses default visual |
217 |
– |
min_depth = max_depth = DefaultDepth(x_display, screen); |
218 |
– |
break; |
275 |
|
#ifdef ENABLE_VOSF |
276 |
|
case VDEPTH_2BIT: |
277 |
|
case VDEPTH_4BIT: // VOSF blitters can convert 2/4/8-bit -> 8/16/32-bit |
349 |
|
case DirectColor: D(bug("DirectColor\n")); break; |
350 |
|
} |
351 |
|
#endif |
352 |
+ |
return true; |
353 |
|
} |
354 |
|
|
355 |
|
// Add mode to list of supported modes |
377 |
|
} |
378 |
|
|
379 |
|
// Set Mac frame layout and base address (uses the_buffer/MacFrameBaseMac) |
380 |
< |
static void set_mac_frame_buffer(video_depth depth, bool native_byte_order) |
380 |
> |
static void set_mac_frame_buffer(X11_monitor_desc &monitor, video_depth depth, bool native_byte_order) |
381 |
|
{ |
382 |
|
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
383 |
|
int layout = FLAYOUT_DIRECT; |
389 |
|
MacFrameLayout = layout; |
390 |
|
else |
391 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
392 |
< |
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
392 |
> |
monitor.set_mac_frame_base(MacFrameBaseMac); |
393 |
|
|
394 |
|
// Set variables used by UAE memory banking |
395 |
+ |
const video_mode &mode = monitor.get_current_mode(); |
396 |
|
MacFrameBaseHost = the_buffer; |
397 |
< |
MacFrameSize = VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y; |
397 |
> |
MacFrameSize = mode.bytes_per_row * mode.y; |
398 |
|
InitFrameBufferMapping(); |
399 |
|
#else |
400 |
< |
VideoMonitor.mac_frame_base = Host2MacAddr(the_buffer); |
400 |
> |
monitor.set_mac_frame_base(Host2MacAddr(the_buffer)); |
401 |
|
#endif |
402 |
< |
D(bug("VideoMonitor.mac_frame_base = %08x\n", VideoMonitor.mac_frame_base)); |
402 |
> |
D(bug("monitor.mac_frame_base = %08x\n", monitor.get_mac_frame_base())); |
403 |
|
} |
404 |
|
|
405 |
|
// Set window name and class |
477 |
|
|
478 |
|
class driver_base { |
479 |
|
public: |
480 |
< |
driver_base(); |
480 |
> |
driver_base(X11_monitor_desc &m); |
481 |
|
virtual ~driver_base(); |
482 |
|
|
483 |
|
virtual void update_palette(void); |
493 |
|
virtual void ungrab_mouse(void) {} |
494 |
|
|
495 |
|
public: |
496 |
+ |
X11_monitor_desc &monitor; // Associated video monitor |
497 |
+ |
const video_mode &mode; // Video mode handled by the driver |
498 |
+ |
|
499 |
|
bool init_ok; // Initialization succeeded (we can't use exceptions because of -fomit-frame-pointer) |
500 |
|
Window w; // The window we draw into |
501 |
|
|
513 |
|
friend void update_display_static(driver_window *drv); |
514 |
|
|
515 |
|
public: |
516 |
< |
driver_window(const video_mode &mode); |
516 |
> |
driver_window(X11_monitor_desc &monitor); |
517 |
|
~driver_window(); |
518 |
|
|
519 |
|
void toggle_mouse_grab(void); |
538 |
|
# include "video_vosf.h" |
539 |
|
#endif |
540 |
|
|
541 |
< |
driver_base::driver_base() |
542 |
< |
: init_ok(false), w(0) |
541 |
> |
driver_base::driver_base(X11_monitor_desc &m) |
542 |
> |
: monitor(m), mode(m.get_current_mode()), init_ok(false), w(0) |
543 |
|
{ |
544 |
|
the_buffer = NULL; |
545 |
|
the_buffer_copy = NULL; |
573 |
|
} |
574 |
|
#ifdef ENABLE_VOSF |
575 |
|
else { |
576 |
+ |
// the_buffer shall always be mapped through vm_acquire() so that we can vm_protect() it at will |
577 |
+ |
if (the_buffer != VM_MAP_FAILED) { |
578 |
+ |
D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size)); |
579 |
+ |
vm_release(the_buffer, the_buffer_size); |
580 |
+ |
the_buffer = NULL; |
581 |
+ |
} |
582 |
|
if (the_host_buffer) { |
583 |
+ |
D(bug(" freeing the_host_buffer at %p\n", the_host_buffer)); |
584 |
|
free(the_host_buffer); |
585 |
|
the_host_buffer = NULL; |
586 |
|
} |
519 |
– |
if (the_buffer) { |
520 |
– |
free(the_buffer); |
521 |
– |
the_buffer = NULL; |
522 |
– |
} |
587 |
|
if (the_buffer_copy) { |
588 |
+ |
D(bug(" freeing the_buffer_copy at %p\n", the_buffer_copy)); |
589 |
|
free(the_buffer_copy); |
590 |
|
the_buffer_copy = NULL; |
591 |
|
} |
598 |
|
{ |
599 |
|
if (color_class == PseudoColor || color_class == DirectColor) { |
600 |
|
int num = vis->map_entries; |
601 |
< |
if (!IsDirectMode(VideoMonitor.mode) && color_class == DirectColor) |
601 |
> |
if (!IsDirectMode(monitor.get_current_mode()) && color_class == DirectColor) |
602 |
|
return; // Indexed mode on true color screen, don't set CLUT |
603 |
< |
XStoreColors(x_display, cmap[0], palette, num); |
604 |
< |
XStoreColors(x_display, cmap[1], palette, num); |
603 |
> |
XStoreColors(x_display, cmap[0], x_palette, num); |
604 |
> |
XStoreColors(x_display, cmap[1], x_palette, num); |
605 |
|
} |
606 |
|
XSync(x_display, false); |
607 |
|
} |
624 |
|
*/ |
625 |
|
|
626 |
|
// Open display |
627 |
< |
driver_window::driver_window(const video_mode &mode) |
628 |
< |
: gc(0), img(NULL), have_shm(false), mouse_grabbed(false), mac_cursor(0) |
627 |
> |
driver_window::driver_window(X11_monitor_desc &m) |
628 |
> |
: driver_base(m), gc(0), img(NULL), have_shm(false), mac_cursor(0), mouse_grabbed(false) |
629 |
|
{ |
630 |
|
int width = mode.x, height = mode.y; |
631 |
|
int aligned_width = (width + 15) & ~15; |
634 |
|
// Set absolute mouse mode |
635 |
|
ADBSetRelMouseMode(mouse_grabbed); |
636 |
|
|
637 |
< |
// Create window (setting backround_pixel, border_pixel and colormap is |
637 |
> |
// Create window (setting background_pixel, border_pixel and colormap is |
638 |
|
// mandatory when using a non-default visual; in 1-bit mode we use the |
639 |
|
// default visual, so we can also use the default colormap) |
640 |
|
XSetWindowAttributes wattr; |
644 |
|
wattr.colormap = (mode.depth == VDEPTH_1BIT ? DefaultColormap(x_display, screen) : cmap[0]); |
645 |
|
w = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth, |
646 |
|
InputOutput, vis, CWEventMask | CWBackPixel | CWBorderPixel | CWColormap, &wattr); |
647 |
+ |
D(bug(" window created\n")); |
648 |
|
|
649 |
|
// Set window name/class |
650 |
|
set_window_name(w, STR_WINDOW_TITLE); |
668 |
|
XFree(hints); |
669 |
|
} |
670 |
|
} |
671 |
+ |
D(bug(" window attributes set\n")); |
672 |
|
|
673 |
|
// Show window |
674 |
|
XMapWindow(x_display, w); |
675 |
|
wait_mapped(w); |
676 |
+ |
D(bug(" window mapped\n")); |
677 |
|
|
678 |
|
// 1-bit mode is big-endian; if the X server is little-endian, we can't |
679 |
|
// use SHM because that doesn't allow changing the image byte order |
684 |
|
|
685 |
|
// Create SHM image ("height + 2" for safety) |
686 |
|
img = XShmCreateImage(x_display, vis, mode.depth == VDEPTH_1BIT ? 1 : xdepth, mode.depth == VDEPTH_1BIT ? XYBitmap : ZPixmap, 0, &shminfo, width, height); |
687 |
+ |
D(bug(" shm image created\n")); |
688 |
|
shminfo.shmid = shmget(IPC_PRIVATE, (aligned_height + 2) * img->bytes_per_line, IPC_CREAT | 0777); |
689 |
|
the_buffer_copy = (uint8 *)shmat(shminfo.shmid, 0, 0); |
690 |
|
shminfo.shmaddr = img->data = (char *)the_buffer_copy; |
705 |
|
have_shm = true; |
706 |
|
shmctl(shminfo.shmid, IPC_RMID, 0); |
707 |
|
} |
708 |
+ |
D(bug(" shm image attached\n")); |
709 |
|
} |
710 |
|
|
711 |
|
// Create normal X image if SHM doesn't work ("height + 2" for safety) |
713 |
|
int bytes_per_row = (mode.depth == VDEPTH_1BIT ? aligned_width/8 : TrivialBytesPerRow(aligned_width, DepthModeForPixelDepth(xdepth))); |
714 |
|
the_buffer_copy = (uint8 *)malloc((aligned_height + 2) * bytes_per_row); |
715 |
|
img = XCreateImage(x_display, vis, mode.depth == VDEPTH_1BIT ? 1 : xdepth, mode.depth == VDEPTH_1BIT ? XYBitmap : ZPixmap, 0, (char *)the_buffer_copy, aligned_width, aligned_height, 32, bytes_per_row); |
716 |
+ |
D(bug(" X image created\n")); |
717 |
|
} |
718 |
|
|
719 |
|
if (need_msb_image) { |
726 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
727 |
|
the_host_buffer = the_buffer_copy; |
728 |
|
the_buffer_size = page_extend((aligned_height + 2) * img->bytes_per_line); |
658 |
– |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
729 |
|
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
730 |
+ |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
731 |
|
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
732 |
|
#else |
733 |
|
// Allocate memory for frame buffer |
754 |
|
native_byte_order = (XImageByteOrder(x_display) == LSBFirst); |
755 |
|
#endif |
756 |
|
#ifdef ENABLE_VOSF |
757 |
< |
Screen_blitter_init(&visualInfo, native_byte_order, mode.depth); |
757 |
> |
Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); |
758 |
|
#endif |
759 |
|
|
760 |
< |
// Set VideoMonitor |
761 |
< |
VideoMonitor.mode = mode; |
691 |
< |
set_mac_frame_buffer(mode.depth, native_byte_order); |
760 |
> |
// Set frame buffer base |
761 |
> |
set_mac_frame_buffer(monitor, mode.depth, native_byte_order); |
762 |
|
|
763 |
|
// Everything went well |
764 |
|
init_ok = true; |
775 |
|
the_buffer_copy = NULL; // don't free() in driver_base dtor |
776 |
|
#endif |
777 |
|
} |
778 |
< |
#ifdef ENABLE_VOSF |
779 |
< |
if (use_vosf) { |
780 |
< |
// don't free() memory mapped buffers in driver_base dtor |
711 |
< |
if (the_buffer != VM_MAP_FAILED) { |
712 |
< |
vm_release(the_buffer, the_buffer_size); |
713 |
< |
the_buffer = NULL; |
714 |
< |
} |
715 |
< |
if (the_buffer_copy != VM_MAP_FAILED) { |
716 |
< |
vm_release(the_buffer_copy, the_buffer_size); |
717 |
< |
the_buffer_copy = NULL; |
718 |
< |
} |
719 |
< |
} |
720 |
< |
#endif |
721 |
< |
if (img) |
778 |
> |
if (img) { |
779 |
> |
if (!have_shm) |
780 |
> |
img->data = NULL; |
781 |
|
XDestroyImage(img); |
782 |
+ |
} |
783 |
|
if (have_shm) { |
784 |
|
shmdt(shminfo.shmaddr); |
785 |
|
shmctl(shminfo.shmid, IPC_RMID, 0); |
838 |
|
// Warped mouse motion (this code is taken from SDL) |
839 |
|
|
840 |
|
// Post first mouse event |
841 |
< |
int width = VideoMonitor.mode.x, height = VideoMonitor.mode.y; |
841 |
> |
int width = monitor.get_current_mode().x, height = monitor.get_current_mode().y; |
842 |
|
int delta_x = x - mouse_last_x, delta_y = y - mouse_last_y; |
843 |
|
mouse_last_x = x; mouse_last_y = y; |
844 |
|
ADBMouseMoved(delta_x, delta_y); |
875 |
|
|
876 |
|
class driver_dga : public driver_base { |
877 |
|
public: |
878 |
< |
driver_dga(); |
878 |
> |
driver_dga(X11_monitor_desc &monitor); |
879 |
|
~driver_dga(); |
880 |
|
|
881 |
|
void suspend(void); |
886 |
|
void *fb_save; // Saved frame buffer for suspend/resume |
887 |
|
}; |
888 |
|
|
889 |
< |
driver_dga::driver_dga() |
890 |
< |
: suspend_win(0), fb_save(NULL) |
889 |
> |
driver_dga::driver_dga(X11_monitor_desc &m) |
890 |
> |
: driver_base(m), suspend_win(0), fb_save(NULL) |
891 |
|
{ |
892 |
|
} |
893 |
|
|
908 |
|
LOCK_FRAME_BUFFER; |
909 |
|
|
910 |
|
// Save frame buffer |
911 |
< |
fb_save = malloc(VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
911 |
> |
fb_save = malloc(mode.y * mode.bytes_per_row); |
912 |
|
if (fb_save) |
913 |
< |
memcpy(fb_save, the_buffer, VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
913 |
> |
memcpy(fb_save, the_buffer, mode.y * mode.bytes_per_row); |
914 |
|
|
915 |
|
// Close full screen display |
916 |
|
#ifdef ENABLE_XF86_DGA |
963 |
|
LOCK_VOSF; |
964 |
|
PFLAG_SET_ALL; |
965 |
|
UNLOCK_VOSF; |
966 |
< |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
966 |
> |
memset(the_buffer_copy, 0, mode.bytes_per_row * mode.y); |
967 |
|
} |
968 |
|
#endif |
969 |
|
|
973 |
|
// Don't copy fb_save to the temporary frame buffer in VOSF mode |
974 |
|
if (!use_vosf) |
975 |
|
#endif |
976 |
< |
memcpy(the_buffer, fb_save, VideoMonitor.mode.y * VideoMonitor.mode.bytes_per_row); |
976 |
> |
memcpy(the_buffer, fb_save, mode.y * mode.bytes_per_row); |
977 |
|
free(fb_save); |
978 |
|
fb_save = NULL; |
979 |
|
} |
995 |
|
|
996 |
|
class driver_fbdev : public driver_dga { |
997 |
|
public: |
998 |
< |
driver_fbdev(const video_mode &mode); |
998 |
> |
driver_fbdev(X11_monitor_desc &monitor); |
999 |
|
~driver_fbdev(); |
1000 |
|
}; |
1001 |
|
|
1002 |
|
// Open display |
1003 |
< |
driver_fbdev::driver_fbdev(const video_mode &mode) |
1003 |
> |
driver_fbdev::driver_fbdev(X11_monitor_desc &m) : driver_dga(m) |
1004 |
|
{ |
1005 |
|
int width = mode.x, height = mode.y; |
1006 |
|
|
1048 |
|
if ((line[0] == '#') || (line[0] == ';') || (line[0] == '\0')) |
1049 |
|
continue; |
1050 |
|
|
1051 |
< |
if ((sscanf(line, "%19s %d %x", &fb_name, &fb_depth, &fb_offset) == 3) |
1051 |
> |
if ((sscanf(line, "%19s %d %x", fb_name, &fb_depth, &fb_offset) == 3) |
1052 |
|
&& (strcmp(fb_name, fb_name) == 0) && (fb_depth == max_depth)) { |
1053 |
|
device_found = true; |
1054 |
|
break; |
1121 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
1122 |
|
the_host_buffer = the_buffer; |
1123 |
|
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
1124 |
< |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
1124 |
> |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
1125 |
|
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
1126 |
|
} |
1127 |
|
#else |
1129 |
|
#endif |
1130 |
|
#endif |
1131 |
|
|
1132 |
< |
// Set VideoMonitor |
1133 |
< |
VideoModes[0].bytes_per_row = bytes_per_row; |
1134 |
< |
VideoModes[0].depth = DepthModeForPixelDepth(fb_depth); |
1135 |
< |
VideoMonitor.mode = mode; |
1076 |
< |
set_mac_frame_buffer(mode.depth, true); |
1132 |
> |
// Set frame buffer base |
1133 |
> |
const_cast<video_mode *>(&mode)->bytes_per_row = bytes_per_row; |
1134 |
> |
const_cast<video_mode *>(&mode)->depth = DepthModeForPixelDepth(fb_depth); |
1135 |
> |
set_mac_frame_buffer(monitor, mode.depth, true); |
1136 |
|
|
1137 |
|
// Everything went well |
1138 |
|
init_ok = true; |
1155 |
|
munmap(the_host_buffer, the_buffer_size); |
1156 |
|
the_host_buffer = NULL; |
1157 |
|
} |
1099 |
– |
if (the_buffer_copy != VM_MAP_FAILED) { |
1100 |
– |
vm_release(the_buffer_copy, the_buffer_size); |
1101 |
– |
the_buffer_copy = NULL; |
1102 |
– |
} |
1103 |
– |
if (the_buffer != VM_MAP_FAILED) { |
1104 |
– |
vm_release(the_buffer, the_buffer_size); |
1105 |
– |
the_buffer = NULL; |
1106 |
– |
} |
1158 |
|
} |
1159 |
|
#endif |
1160 |
|
} |
1168 |
|
|
1169 |
|
class driver_xf86dga : public driver_dga { |
1170 |
|
public: |
1171 |
< |
driver_xf86dga(const video_mode &mode); |
1171 |
> |
driver_xf86dga(X11_monitor_desc &monitor); |
1172 |
|
~driver_xf86dga(); |
1173 |
|
|
1174 |
|
void update_palette(void); |
1179 |
|
}; |
1180 |
|
|
1181 |
|
// Open display |
1182 |
< |
driver_xf86dga::driver_xf86dga(const video_mode &mode) |
1183 |
< |
: current_dga_cmap(0) |
1182 |
> |
driver_xf86dga::driver_xf86dga(X11_monitor_desc &m) |
1183 |
> |
: driver_dga(m), current_dga_cmap(0) |
1184 |
|
{ |
1185 |
|
int width = mode.x, height = mode.y; |
1186 |
|
|
1207 |
|
XSetWindowAttributes wattr; |
1208 |
|
wattr.event_mask = eventmask = dga_eventmask; |
1209 |
|
wattr.override_redirect = True; |
1210 |
+ |
wattr.colormap = (mode.depth == VDEPTH_1BIT ? DefaultColormap(x_display, screen) : cmap[0]); |
1211 |
|
|
1212 |
|
w = XCreateWindow(x_display, rootwin, 0, 0, width, height, 0, xdepth, |
1213 |
< |
InputOutput, vis, CWEventMask | CWOverrideRedirect, &wattr); |
1213 |
> |
InputOutput, vis, CWEventMask | CWOverrideRedirect | |
1214 |
> |
(color_class == DirectColor ? CWColormap : 0), &wattr); |
1215 |
|
|
1216 |
|
// Set window name/class |
1217 |
|
set_window_name(w, STR_WINDOW_TITLE); |
1245 |
|
|
1246 |
|
// Init blitting routines |
1247 |
|
int bytes_per_row = TrivialBytesPerRow((v_width + 7) & ~7, mode.depth); |
1248 |
< |
#if VIDEO_VOSF |
1248 |
> |
#if ENABLE_VOSF |
1249 |
> |
bool native_byte_order; |
1250 |
> |
#ifdef WORDS_BIGENDIAN |
1251 |
> |
native_byte_order = (XImageByteOrder(x_display) == MSBFirst); |
1252 |
> |
#else |
1253 |
> |
native_byte_order = (XImageByteOrder(x_display) == LSBFirst); |
1254 |
> |
#endif |
1255 |
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
1256 |
|
// Screen_blitter_init() returns TRUE if VOSF is mandatory |
1257 |
|
// i.e. the framebuffer update function is not Blit_Copy_Raw |
1258 |
< |
use_vosf = Screen_blitter_init(&visualInfo, true, mode.depth); |
1258 |
> |
use_vosf = Screen_blitter_init(&visualInfo, native_byte_order, depth_of_video_mode(mode)); |
1259 |
|
|
1260 |
|
if (use_vosf) { |
1261 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
1262 |
|
the_host_buffer = the_buffer; |
1263 |
|
the_buffer_size = page_extend((height + 2) * bytes_per_row); |
1264 |
< |
the_buffer_copy = (uint8 *)vm_acquire(the_buffer_size); |
1264 |
> |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
1265 |
|
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
1266 |
|
} |
1267 |
|
#else |
1269 |
|
#endif |
1270 |
|
#endif |
1271 |
|
|
1272 |
< |
// Set VideoMonitor |
1272 |
> |
// Set frame buffer base |
1273 |
|
const_cast<video_mode *>(&mode)->bytes_per_row = bytes_per_row; |
1274 |
< |
VideoMonitor.mode = mode; |
1216 |
< |
set_mac_frame_buffer(mode.depth, true); |
1274 |
> |
set_mac_frame_buffer(monitor, mode.depth, true); |
1275 |
|
|
1276 |
|
// Everything went well |
1277 |
|
init_ok = true; |
1289 |
|
else { |
1290 |
|
// don't free() the screen buffer in driver_base dtor |
1291 |
|
the_host_buffer = NULL; |
1234 |
– |
|
1235 |
– |
if (the_buffer_copy != VM_MAP_FAILED) { |
1236 |
– |
vm_release(the_buffer_copy, the_buffer_size); |
1237 |
– |
the_buffer_copy = NULL; |
1238 |
– |
} |
1239 |
– |
if (the_buffer != VM_MAP_FAILED) { |
1240 |
– |
vm_release(the_buffer, the_buffer_size); |
1241 |
– |
the_buffer = NULL; |
1242 |
– |
} |
1292 |
|
} |
1293 |
|
#endif |
1294 |
|
#ifdef ENABLE_XF86_VIDMODE |
1302 |
|
{ |
1303 |
|
driver_dga::update_palette(); |
1304 |
|
current_dga_cmap ^= 1; |
1305 |
< |
if (!IsDirectMode(VideoMonitor.mode) && cmap[current_dga_cmap]) |
1305 |
> |
if (!IsDirectMode(monitor.get_current_mode()) && cmap[current_dga_cmap]) |
1306 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1307 |
|
} |
1308 |
|
|
1310 |
|
void driver_xf86dga::resume(void) |
1311 |
|
{ |
1312 |
|
driver_dga::resume(); |
1313 |
< |
if (!IsDirectMode(VideoMonitor.mode)) |
1313 |
> |
if (!IsDirectMode(monitor.get_current_mode())) |
1314 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1315 |
|
} |
1316 |
|
#endif |
1385 |
|
} |
1386 |
|
} |
1387 |
|
|
1388 |
< |
// Open display for specified mode |
1389 |
< |
static bool video_open(const video_mode &mode) |
1388 |
> |
// Open display for current mode |
1389 |
> |
bool X11_monitor_desc::video_open(void) |
1390 |
|
{ |
1391 |
+ |
D(bug("video_open()\n")); |
1392 |
+ |
const video_mode &mode = get_current_mode(); |
1393 |
+ |
|
1394 |
|
// Find best available X visual |
1395 |
|
if (!find_visual_for_depth(mode.depth)) { |
1396 |
|
ErrorAlert(STR_NO_XVISUAL_ERR); |
1430 |
|
int num = vis->map_entries; |
1431 |
|
for (int i=0; i<num; i++) { |
1432 |
|
int c = (i * 256) / num; |
1433 |
< |
palette[i].pixel = map_rgb(c, c, c); |
1434 |
< |
palette[i].flags = DoRed | DoGreen | DoBlue; |
1433 |
> |
x_palette[i].pixel = map_rgb(c, c, c); |
1434 |
> |
x_palette[i].flags = DoRed | DoGreen | DoBlue; |
1435 |
|
} |
1436 |
|
} else if (color_class == PseudoColor) { |
1437 |
|
for (int i=0; i<256; i++) { |
1438 |
< |
palette[i].pixel = i; |
1439 |
< |
palette[i].flags = DoRed | DoGreen | DoBlue; |
1438 |
> |
x_palette[i].pixel = i; |
1439 |
> |
x_palette[i].flags = DoRed | DoGreen | DoBlue; |
1440 |
|
} |
1441 |
|
} |
1442 |
|
|
1444 |
|
int num = (color_class == DirectColor ? vis->map_entries : 256); |
1445 |
|
for (int i=0; i<num; i++) { |
1446 |
|
int c = (i * 256) / num; |
1447 |
< |
palette[i].red = c * 0x0101; |
1448 |
< |
palette[i].green = c * 0x0101; |
1449 |
< |
palette[i].blue = c * 0x0101; |
1447 |
> |
x_palette[i].red = c * 0x0101; |
1448 |
> |
x_palette[i].green = c * 0x0101; |
1449 |
> |
x_palette[i].blue = c * 0x0101; |
1450 |
|
} |
1451 |
|
if (color_class == PseudoColor || color_class == DirectColor) { |
1452 |
< |
XStoreColors(x_display, cmap[0], palette, num); |
1453 |
< |
XStoreColors(x_display, cmap[1], palette, num); |
1452 |
> |
XStoreColors(x_display, cmap[0], x_palette, num); |
1453 |
> |
XStoreColors(x_display, cmap[1], x_palette, num); |
1454 |
|
} |
1455 |
|
|
1456 |
|
#ifdef ENABLE_VOSF |
1463 |
|
// Create display driver object of requested type |
1464 |
|
switch (display_type) { |
1465 |
|
case DISPLAY_WINDOW: |
1466 |
< |
drv = new driver_window(mode); |
1466 |
> |
drv = new driver_window(*this); |
1467 |
|
break; |
1468 |
|
#ifdef ENABLE_FBDEV_DGA |
1469 |
|
case DISPLAY_DGA: |
1470 |
< |
drv = new driver_fbdev(mode); |
1470 |
> |
drv = new driver_fbdev(*this); |
1471 |
|
break; |
1472 |
|
#endif |
1473 |
|
#ifdef ENABLE_XF86_DGA |
1474 |
|
case DISPLAY_DGA: |
1475 |
< |
drv = new driver_xf86dga(mode); |
1475 |
> |
drv = new driver_xf86dga(*this); |
1476 |
|
break; |
1477 |
|
#endif |
1478 |
|
} |
1487 |
|
#ifdef ENABLE_VOSF |
1488 |
|
if (use_vosf) { |
1489 |
|
// Initialize the VOSF system |
1490 |
< |
if (!video_vosf_init()) { |
1490 |
> |
if (!video_vosf_init(*this)) { |
1491 |
|
ErrorAlert(STR_VOSF_INIT_ERR); |
1492 |
|
return false; |
1493 |
|
} |
1504 |
|
// Start redraw/input thread |
1505 |
|
#ifdef HAVE_PTHREADS |
1506 |
|
redraw_thread_cancel = false; |
1507 |
< |
redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); |
1507 |
> |
Set_pthread_attr(&redraw_thread_attr, 0); |
1508 |
> |
redraw_thread_active = (pthread_create(&redraw_thread, &redraw_thread_attr, redraw_func, NULL) == 0); |
1509 |
|
if (!redraw_thread_active) { |
1510 |
|
printf("FATAL: cannot create redraw thread\n"); |
1511 |
|
return false; |
1549 |
|
ErrorAlert(STR_UNSUPP_DEPTH_ERR); |
1550 |
|
return false; |
1551 |
|
} |
1552 |
< |
sort(avail_depths, avail_depths + num_depths); |
1552 |
> |
std::sort(avail_depths, avail_depths + num_depths); |
1553 |
|
|
1554 |
|
#ifdef ENABLE_FBDEV_DGA |
1555 |
|
// Frame buffer name |
1652 |
|
ErrorAlert(STR_NO_XVISUAL_ERR); |
1653 |
|
return false; |
1654 |
|
} |
1655 |
< |
video_init_depth_list(); |
1655 |
> |
|
1656 |
> |
// Find requested default mode with specified dimensions |
1657 |
> |
uint32 default_id; |
1658 |
> |
std::vector<video_mode>::const_iterator i, end = VideoModes.end(); |
1659 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
1660 |
> |
if (i->x == default_width && i->y == default_height && i->depth == default_depth) { |
1661 |
> |
default_id = i->resolution_id; |
1662 |
> |
break; |
1663 |
> |
} |
1664 |
> |
} |
1665 |
> |
if (i == end) { // not found, use first available mode |
1666 |
> |
default_depth = VideoModes[0].depth; |
1667 |
> |
default_id = VideoModes[0].resolution_id; |
1668 |
> |
} |
1669 |
|
|
1670 |
|
#if DEBUG |
1671 |
|
D(bug("Available video modes:\n")); |
1672 |
< |
vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
1607 |
< |
while (i != end) { |
1672 |
> |
for (i = VideoModes.begin(); i != end; ++i) { |
1673 |
|
int bits = 1 << i->depth; |
1674 |
|
if (bits == 16) |
1675 |
|
bits = 15; |
1676 |
|
else if (bits == 32) |
1677 |
|
bits = 24; |
1678 |
|
D(bug(" %dx%d (ID %02x), %d colors\n", i->x, i->y, i->resolution_id, 1 << bits)); |
1614 |
– |
++i; |
1679 |
|
} |
1680 |
|
#endif |
1681 |
|
|
1682 |
< |
// Find requested default mode and open display |
1683 |
< |
if (VideoModes.size() == 1) |
1684 |
< |
return video_open(VideoModes[0]); |
1685 |
< |
else { |
1686 |
< |
// Find mode with specified dimensions |
1687 |
< |
std::vector<video_mode>::const_iterator i, end = VideoModes.end(); |
1624 |
< |
for (i = VideoModes.begin(); i != end; ++i) { |
1625 |
< |
if (i->x == default_width && i->y == default_height && i->depth == default_depth) |
1626 |
< |
return video_open(*i); |
1627 |
< |
} |
1628 |
< |
return video_open(VideoModes[0]); |
1629 |
< |
} |
1682 |
> |
// Create X11_monitor_desc for this (the only) display |
1683 |
> |
X11_monitor_desc *monitor = new X11_monitor_desc(VideoModes, default_depth, default_id); |
1684 |
> |
VideoMonitors.push_back(monitor); |
1685 |
> |
|
1686 |
> |
// Open display |
1687 |
> |
return monitor->video_open(); |
1688 |
|
} |
1689 |
|
|
1690 |
|
|
1693 |
|
*/ |
1694 |
|
|
1695 |
|
// Close display |
1696 |
< |
static void video_close(void) |
1696 |
> |
void X11_monitor_desc::video_close(void) |
1697 |
|
{ |
1698 |
+ |
D(bug("video_close()\n")); |
1699 |
+ |
|
1700 |
|
// Stop redraw thread |
1701 |
|
#ifdef HAVE_PTHREADS |
1702 |
|
if (redraw_thread_active) { |
1712 |
|
// Unlock frame buffer |
1713 |
|
UNLOCK_FRAME_BUFFER; |
1714 |
|
XSync(x_display, false); |
1715 |
+ |
D(bug(" frame buffer unlocked\n")); |
1716 |
|
|
1717 |
|
#ifdef ENABLE_VOSF |
1718 |
|
if (use_vosf) { |
1738 |
|
|
1739 |
|
void VideoExit(void) |
1740 |
|
{ |
1741 |
< |
// Close display |
1742 |
< |
video_close(); |
1741 |
> |
// Close displays |
1742 |
> |
vector<monitor_desc *>::iterator i, end = VideoMonitors.end(); |
1743 |
> |
for (i = VideoMonitors.begin(); i != end; ++i) |
1744 |
> |
dynamic_cast<X11_monitor_desc *>(*i)->video_close(); |
1745 |
|
|
1746 |
|
#ifdef ENABLE_XF86_VIDMODE |
1747 |
|
// Free video mode list |
1799 |
|
* Set palette |
1800 |
|
*/ |
1801 |
|
|
1802 |
< |
void video_set_palette(uint8 *pal, int num_in) |
1802 |
> |
void X11_monitor_desc::set_palette(uint8 *pal, int num_in) |
1803 |
|
{ |
1804 |
+ |
const video_mode &mode = get_current_mode(); |
1805 |
+ |
|
1806 |
|
LOCK_PALETTE; |
1807 |
|
|
1808 |
|
// Convert colors to XColor array |
1809 |
|
int num_out = 256; |
1810 |
|
bool stretch = false; |
1811 |
< |
if (IsDirectMode(VideoMonitor.mode)) { |
1811 |
> |
if (IsDirectMode(mode)) { |
1812 |
|
// If X is in 565 mode we have to stretch the gamma table from 32 to 64 entries |
1813 |
|
num_out = vis->map_entries; |
1814 |
|
stretch = true; |
1815 |
|
} |
1816 |
< |
XColor *p = palette; |
1816 |
> |
XColor *p = x_palette; |
1817 |
|
for (int i=0; i<num_out; i++) { |
1818 |
|
int c = (stretch ? (i * num_in) / num_out : i); |
1819 |
|
p->red = pal[c*3 + 0] * 0x0101; |
1824 |
|
|
1825 |
|
#ifdef ENABLE_VOSF |
1826 |
|
// Recalculate pixel color expansion map |
1827 |
< |
if (!IsDirectMode(VideoMonitor.mode) && xdepth > 8) { |
1827 |
> |
if (!IsDirectMode(mode) && xdepth > 8) { |
1828 |
|
for (int i=0; i<256; i++) { |
1829 |
|
int c = i & (num_in-1); // If there are less than 256 colors, we repeat the first entries (this makes color expansion easier) |
1830 |
|
ExpandMap[i] = map_rgb(pal[c*3+0], pal[c*3+1], pal[c*3+2]); |
1834 |
|
LOCK_VOSF; |
1835 |
|
PFLAG_SET_ALL; |
1836 |
|
UNLOCK_VOSF; |
1837 |
< |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
1837 |
> |
memset(the_buffer_copy, 0, mode.bytes_per_row * mode.y); |
1838 |
|
} |
1839 |
|
#endif |
1840 |
|
|
1841 |
|
// Tell redraw thread to change palette |
1842 |
< |
palette_changed = true; |
1842 |
> |
x_palette_changed = true; |
1843 |
|
|
1844 |
|
UNLOCK_PALETTE; |
1845 |
|
} |
1849 |
|
* Switch video mode |
1850 |
|
*/ |
1851 |
|
|
1852 |
< |
void video_switch_to_mode(const video_mode &mode) |
1852 |
> |
void X11_monitor_desc::switch_to_current_mode(void) |
1853 |
|
{ |
1854 |
|
// Close and reopen display |
1855 |
|
video_close(); |
1856 |
< |
video_open(mode); |
1856 |
> |
video_open(); |
1857 |
|
|
1858 |
|
if (drv == NULL) { |
1859 |
|
ErrorAlert(STR_OPEN_WINDOW_ERR); |
2123 |
|
// Hidden parts exposed, force complete refresh of window |
2124 |
|
case Expose: |
2125 |
|
if (display_type == DISPLAY_WINDOW) { |
2126 |
+ |
const video_mode &mode = VideoMonitors[0]->get_current_mode(); |
2127 |
|
#ifdef ENABLE_VOSF |
2128 |
|
if (use_vosf) { // VOSF refresh |
2129 |
|
LOCK_VOSF; |
2130 |
|
PFLAG_SET_ALL; |
2131 |
|
UNLOCK_VOSF; |
2132 |
< |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
2132 |
> |
memset(the_buffer_copy, 0, mode.bytes_per_row * mode.y); |
2133 |
|
} |
2134 |
|
else |
2135 |
|
#endif |
2140 |
|
updt_box[x1][y1] = true; |
2141 |
|
nr_boxes = 16 * 16; |
2142 |
|
} else // Static refresh |
2143 |
< |
memset(the_buffer_copy, 0, VideoMonitor.mode.bytes_per_row * VideoMonitor.mode.y); |
2143 |
> |
memset(the_buffer_copy, 0, mode.bytes_per_row * mode.y); |
2144 |
|
} |
2145 |
|
break; |
2146 |
|
|
2166 |
|
int y1, y2, y2s, y2a, i, x1, xm, xmo, ymo, yo, yi, yil, xi; |
2167 |
|
int xil = 0; |
2168 |
|
int rxm = 0, rxmo = 0; |
2169 |
< |
int bytes_per_row = VideoMonitor.mode.bytes_per_row; |
2170 |
< |
int bytes_per_pixel = VideoMonitor.mode.bytes_per_row / VideoMonitor.mode.x; |
2171 |
< |
int rx = VideoMonitor.mode.bytes_per_row / 16; |
2172 |
< |
int ry = VideoMonitor.mode.y / 16; |
2169 |
> |
const video_mode &mode = drv->monitor.get_current_mode(); |
2170 |
> |
int bytes_per_row = mode.bytes_per_row; |
2171 |
> |
int bytes_per_pixel = mode.bytes_per_row / mode.x; |
2172 |
> |
int rx = mode.bytes_per_row / 16; |
2173 |
> |
int ry = mode.y / 16; |
2174 |
|
int max_box; |
2175 |
|
|
2176 |
|
y2s = sm_uptd[ticker % 8]; |
2224 |
|
i = (yi * bytes_per_row) + xi; |
2225 |
|
for (y2=0; y2 < yil; y2++, i += bytes_per_row) |
2226 |
|
memcpy(&the_buffer_copy[i], &the_buffer[i], xil); |
2227 |
< |
if (VideoMonitor.mode.depth == VDEPTH_1BIT) { |
2227 |
> |
if (mode.depth == VDEPTH_1BIT) { |
2228 |
|
if (drv->have_shm) |
2229 |
|
XShmPutImage(x_display, drv->w, drv->gc, drv->img, xi * 8, yi, xi * 8, yi, xil * 8, yil, 0); |
2230 |
|
else |
2255 |
|
static void update_display_static(driver_window *drv) |
2256 |
|
{ |
2257 |
|
// Incremental update code |
2258 |
< |
int wide = 0, high = 0, x1, x2, y1, y2, i, j; |
2259 |
< |
int bytes_per_row = VideoMonitor.mode.bytes_per_row; |
2260 |
< |
int bytes_per_pixel = VideoMonitor.mode.bytes_per_row / VideoMonitor.mode.x; |
2258 |
> |
unsigned wide = 0, high = 0, x1, x2, y1, y2, i, j; |
2259 |
> |
const video_mode &mode = drv->monitor.get_current_mode(); |
2260 |
> |
int bytes_per_row = mode.bytes_per_row; |
2261 |
> |
int bytes_per_pixel = mode.bytes_per_row / mode.x; |
2262 |
|
uint8 *p, *p2; |
2263 |
|
|
2264 |
|
// Check for first line from top and first line from bottom that have changed |
2265 |
|
y1 = 0; |
2266 |
< |
for (j=0; j<VideoMonitor.mode.y; j++) { |
2266 |
> |
for (j=0; j<mode.y; j++) { |
2267 |
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
2268 |
|
y1 = j; |
2269 |
|
break; |
2270 |
|
} |
2271 |
|
} |
2272 |
|
y2 = y1 - 1; |
2273 |
< |
for (j=VideoMonitor.mode.y-1; j>=y1; j--) { |
2273 |
> |
for (j=mode.y-1; j>=y1; j--) { |
2274 |
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) { |
2275 |
|
y2 = j; |
2276 |
|
break; |
2280 |
|
|
2281 |
|
// Check for first column from left and first column from right that have changed |
2282 |
|
if (high) { |
2283 |
< |
if (VideoMonitor.mode.depth == VDEPTH_1BIT) { |
2284 |
< |
x1 = VideoMonitor.mode.x - 1; |
2283 |
> |
if (mode.depth == VDEPTH_1BIT) { |
2284 |
> |
x1 = mode.x - 1; |
2285 |
|
for (j=y1; j<=y2; j++) { |
2286 |
|
p = &the_buffer[j * bytes_per_row]; |
2287 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
2299 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
2300 |
|
p += bytes_per_row; |
2301 |
|
p2 += bytes_per_row; |
2302 |
< |
for (i=(VideoMonitor.mode.x>>3); i>(x2>>3); i--) { |
2302 |
> |
for (i=(mode.x>>3); i>(x2>>3); i--) { |
2303 |
|
p--; p2--; |
2304 |
|
if (*p != *p2) { |
2305 |
|
x2 = (i << 3) + 7; |
2318 |
|
} |
2319 |
|
|
2320 |
|
} else { |
2321 |
< |
x1 = VideoMonitor.mode.x; |
2321 |
> |
x1 = mode.x; |
2322 |
|
for (j=y1; j<=y2; j++) { |
2323 |
|
p = &the_buffer[j * bytes_per_row]; |
2324 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
2336 |
|
p2 = &the_buffer_copy[j * bytes_per_row]; |
2337 |
|
p += bytes_per_row; |
2338 |
|
p2 += bytes_per_row; |
2339 |
< |
for (i=VideoMonitor.mode.x*bytes_per_pixel; i>x2*bytes_per_pixel; i--) { |
2339 |
> |
for (i=mode.x*bytes_per_pixel; i>x2*bytes_per_pixel; i--) { |
2340 |
|
p--; |
2341 |
|
p2--; |
2342 |
|
if (*p != *p2) { |
2403 |
|
{ |
2404 |
|
LOCK_PALETTE; |
2405 |
|
|
2406 |
< |
if (palette_changed) { |
2407 |
< |
palette_changed = false; |
2406 |
> |
if (x_palette_changed) { |
2407 |
> |
x_palette_changed = false; |
2408 |
|
drv->update_palette(); |
2409 |
|
} |
2410 |
|
|