34 |
|
#include <X11/extensions/XShm.h> |
35 |
|
#include <sys/ipc.h> |
36 |
|
#include <sys/shm.h> |
37 |
– |
#include <pthread.h> |
37 |
|
#include <errno.h> |
38 |
|
|
39 |
+ |
#ifdef HAVE_PTHREADS |
40 |
+ |
# include <pthread.h> |
41 |
+ |
#endif |
42 |
+ |
|
43 |
+ |
#ifdef ENABLE_XF86_DGA |
44 |
+ |
# include <X11/extensions/xf86dga.h> |
45 |
+ |
#endif |
46 |
+ |
|
47 |
+ |
#ifdef ENABLE_XF86_VIDMODE |
48 |
+ |
# include <X11/extensions/xf86vmode.h> |
49 |
+ |
#endif |
50 |
+ |
|
51 |
+ |
#ifdef ENABLE_FBDEV_DGA |
52 |
+ |
# include <sys/mman.h> |
53 |
+ |
#endif |
54 |
+ |
|
55 |
|
#include "cpu_emulation.h" |
56 |
|
#include "main.h" |
57 |
|
#include "adb.h" |
63 |
|
#define DEBUG 1 |
64 |
|
#include "debug.h" |
65 |
|
|
51 |
– |
#if ENABLE_XF86_DGA |
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 |
62 |
– |
|
63 |
– |
|
66 |
|
|
67 |
|
// Display types |
68 |
|
enum { |
82 |
|
|
83 |
|
static int display_type = DISPLAY_WINDOW; // See enum above |
84 |
|
static uint8 *the_buffer; // Mac frame buffer |
85 |
+ |
|
86 |
+ |
#ifdef HAVE_PTHREADS |
87 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
88 |
|
static volatile bool redraw_thread_cancel = false; // Flag: Cancel Redraw thread |
89 |
|
static pthread_t redraw_thread; // Redraw thread |
90 |
+ |
#endif |
91 |
|
|
92 |
|
static bool has_dga = false; // Flag: Video DGA capable |
93 |
|
static bool has_vidmode = false; // Flag: VidMode extension available |
117 |
|
static const int win_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | ExposureMask; |
118 |
|
static const int dga_eventmask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask; |
119 |
|
|
115 |
– |
static pthread_mutex_t palette_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect palette |
120 |
|
static XColor palette[256]; // Color palette for 8-bit mode |
121 |
|
static bool palette_changed = false; // Flag: Palette changed, redraw thread must set new colors |
122 |
+ |
#ifdef HAVE_PTHREADS |
123 |
+ |
static pthread_mutex_t palette_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect palette |
124 |
+ |
#endif |
125 |
|
|
126 |
|
// Variables for window mode |
127 |
|
static GC the_gc; |
143 |
|
static int current_dga_cmap; // Number (0 or 1) of currently installed DGA colormap |
144 |
|
static Window suspend_win; // "Suspend" window |
145 |
|
static void *fb_save = NULL; // Saved frame buffer for suspend |
146 |
+ |
#ifdef HAVE_PTHREADS |
147 |
|
static pthread_mutex_t frame_buffer_lock = PTHREAD_MUTEX_INITIALIZER; // Mutex to protect frame buffer |
148 |
+ |
#endif |
149 |
|
|
150 |
|
// Variables for fbdev DGA mode |
151 |
|
const char FBDEVICE_FILE_NAME[] = "/dev/fb"; |
152 |
|
static int fbdev_fd; |
153 |
|
|
154 |
< |
#if ENABLE_XF86_VIDMODE |
154 |
> |
#ifdef ENABLE_XF86_VIDMODE |
155 |
|
// Variables for XF86 VidMode support |
156 |
|
static XF86VidModeModeInfo **x_video_modes; // Array of all available modes |
157 |
|
static int num_x_video_modes; |
177 |
|
// Set VideoMonitor according to video mode |
178 |
|
void set_video_monitor(int width, int height, int bytes_per_row, bool native_byte_order) |
179 |
|
{ |
180 |
+ |
#if !REAL_ADDRESSING |
181 |
|
int layout = FLAYOUT_DIRECT; |
182 |
|
switch (depth) { |
183 |
|
case 1: |
184 |
|
layout = FLAYOUT_DIRECT; |
175 |
– |
VideoMonitor.mode = VMODE_1BIT; |
185 |
|
break; |
186 |
|
case 8: |
187 |
|
layout = FLAYOUT_DIRECT; |
179 |
– |
VideoMonitor.mode = VMODE_8BIT; |
188 |
|
break; |
189 |
|
case 15: |
190 |
|
layout = FLAYOUT_HOST_555; |
183 |
– |
VideoMonitor.mode = VMODE_16BIT; |
191 |
|
break; |
192 |
|
case 16: |
193 |
|
layout = FLAYOUT_HOST_565; |
187 |
– |
VideoMonitor.mode = VMODE_16BIT; |
194 |
|
break; |
195 |
|
case 24: |
196 |
|
case 32: |
197 |
|
layout = FLAYOUT_HOST_888; |
192 |
– |
VideoMonitor.mode = VMODE_32BIT; |
198 |
|
break; |
199 |
|
} |
195 |
– |
VideoMonitor.x = width; |
196 |
– |
VideoMonitor.y = height; |
197 |
– |
VideoMonitor.bytes_per_row = bytes_per_row; |
200 |
|
if (native_byte_order) |
201 |
|
MacFrameLayout = layout; |
202 |
|
else |
203 |
|
MacFrameLayout = FLAYOUT_DIRECT; |
204 |
+ |
#endif |
205 |
+ |
switch (depth) { |
206 |
+ |
case 1: |
207 |
+ |
VideoMonitor.mode = VMODE_1BIT; |
208 |
+ |
break; |
209 |
+ |
case 8: |
210 |
+ |
VideoMonitor.mode = VMODE_8BIT; |
211 |
+ |
break; |
212 |
+ |
case 15: |
213 |
+ |
VideoMonitor.mode = VMODE_16BIT; |
214 |
+ |
break; |
215 |
+ |
case 16: |
216 |
+ |
VideoMonitor.mode = VMODE_16BIT; |
217 |
+ |
break; |
218 |
+ |
case 24: |
219 |
+ |
case 32: |
220 |
+ |
VideoMonitor.mode = VMODE_32BIT; |
221 |
+ |
break; |
222 |
+ |
} |
223 |
+ |
VideoMonitor.x = width; |
224 |
+ |
VideoMonitor.y = height; |
225 |
+ |
VideoMonitor.bytes_per_row = bytes_per_row; |
226 |
|
} |
227 |
|
|
228 |
|
// Trap SHM errors |
364 |
|
|
365 |
|
#if REAL_ADDRESSING |
366 |
|
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
343 |
– |
MacFrameLayout = FLAYOUT_DIRECT; |
367 |
|
#else |
368 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
369 |
|
#endif |
373 |
|
// Init fbdev DGA display |
374 |
|
static bool init_fbdev_dga(char *in_fb_name) |
375 |
|
{ |
376 |
< |
#if ENABLE_FBDEV_DGA |
376 |
> |
#ifdef ENABLE_FBDEV_DGA |
377 |
|
// Find the maximum depth available |
378 |
|
int ndepths, max_depth(0); |
379 |
|
int *depths = XListDepths(x_display, screen, &ndepths); |
499 |
|
set_video_monitor(width, height, bytes_per_row, true); |
500 |
|
#if REAL_ADDRESSING |
501 |
|
VideoMonitor.mac_frame_base = (uint32)the_buffer; |
479 |
– |
MacFrameLayout = FLAYOUT_DIRECT; |
502 |
|
#else |
503 |
|
VideoMonitor.mac_frame_base = MacFrameBaseMac; |
504 |
|
#endif |
512 |
|
// Init XF86 DGA display |
513 |
|
static bool init_xf86_dga(int width, int height) |
514 |
|
{ |
515 |
< |
#if ENABLE_XF86_DGA |
515 |
> |
#ifdef ENABLE_XF86_DGA |
516 |
|
// Set relative mouse mode |
517 |
|
ADBSetRelMouseMode(true); |
518 |
|
|
519 |
< |
#if ENABLE_XF86_VIDMODE |
519 |
> |
#ifdef ENABLE_XF86_VIDMODE |
520 |
|
// Switch to best mode |
521 |
|
if (has_vidmode) { |
522 |
|
int best = 0; |
674 |
|
// Get screen depth |
675 |
|
xdepth = DefaultDepth(x_display, screen); |
676 |
|
|
677 |
< |
#if ENABLE_FBDEV_DGA |
677 |
> |
#ifdef ENABLE_FBDEV_DGA |
678 |
|
// Frame buffer name |
679 |
|
char fb_name[20]; |
680 |
|
|
685 |
|
has_dga = false; |
686 |
|
#endif |
687 |
|
|
688 |
< |
#if ENABLE_XF86_DGA |
688 |
> |
#ifdef ENABLE_XF86_DGA |
689 |
|
// DGA available? |
690 |
|
int dga_event_base, dga_error_base; |
691 |
|
if (XF86DGAQueryExtension(x_display, &dga_event_base, &dga_error_base)) { |
696 |
|
has_dga = false; |
697 |
|
#endif |
698 |
|
|
699 |
< |
#if ENABLE_XF86_VIDMODE |
699 |
> |
#ifdef ENABLE_XF86_VIDMODE |
700 |
|
// VidMode available? |
701 |
|
int vm_event_base, vm_error_base; |
702 |
|
has_vidmode = XF86VidModeQueryExtension(x_display, &vm_event_base, &vm_error_base); |
769 |
|
if (mode_str) { |
770 |
|
if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) |
771 |
|
display_type = DISPLAY_WINDOW; |
772 |
< |
#if ENABLE_FBDEV_DGA |
772 |
> |
#ifdef ENABLE_FBDEV_DGA |
773 |
|
else if (has_dga && sscanf(mode_str, "dga/%19s", fb_name) == 1) { |
774 |
|
#else |
775 |
|
else if (has_dga && sscanf(mode_str, "dga/%d/%d", &width, &height) == 2) { |
793 |
|
return false; |
794 |
|
break; |
795 |
|
case DISPLAY_DGA: |
796 |
< |
#if ENABLE_FBDEV_DGA |
796 |
> |
#ifdef ENABLE_FBDEV_DGA |
797 |
|
if (!init_fbdev_dga(fb_name)) |
798 |
|
#else |
799 |
|
if (!init_xf86_dga(width, height)) |
802 |
|
break; |
803 |
|
} |
804 |
|
|
805 |
+ |
#ifdef HAVE_PTHREADS |
806 |
|
// Lock down frame buffer |
807 |
|
pthread_mutex_lock(&frame_buffer_lock); |
808 |
+ |
#endif |
809 |
|
|
810 |
|
#if !REAL_ADDRESSING |
811 |
|
// Set variables for UAE memory mapping |
817 |
|
MacFrameLayout = FLAYOUT_NONE; |
818 |
|
#endif |
819 |
|
|
796 |
– |
// Start redraw/input thread |
820 |
|
XSync(x_display, false); |
821 |
+ |
|
822 |
+ |
#ifdef HAVE_PTHREADS |
823 |
+ |
// Start redraw/input thread |
824 |
|
redraw_thread_active = (pthread_create(&redraw_thread, NULL, redraw_func, NULL) == 0); |
825 |
< |
if (!redraw_thread_active) |
825 |
> |
if (!redraw_thread_active) { |
826 |
|
printf("FATAL: cannot create redraw thread\n"); |
827 |
< |
return redraw_thread_active; |
827 |
> |
return false; |
828 |
> |
} |
829 |
> |
#endif |
830 |
> |
return true; |
831 |
|
} |
832 |
|
|
833 |
|
|
837 |
|
|
838 |
|
void VideoExit(void) |
839 |
|
{ |
840 |
+ |
#ifdef HAVE_PTHREADS |
841 |
|
// Stop redraw thread |
842 |
|
if (redraw_thread_active) { |
843 |
|
redraw_thread_cancel = true; |
847 |
|
pthread_join(redraw_thread, NULL); |
848 |
|
redraw_thread_active = false; |
849 |
|
} |
850 |
+ |
#endif |
851 |
|
|
852 |
+ |
#ifdef HAVE_PTHREADS |
853 |
|
// Unlock frame buffer |
854 |
|
pthread_mutex_unlock(&frame_buffer_lock); |
855 |
+ |
#endif |
856 |
|
|
857 |
|
// Close window and server connection |
858 |
|
if (x_display != NULL) { |
859 |
|
XSync(x_display, false); |
860 |
|
|
861 |
< |
#if ENABLE_XF86_DGA |
861 |
> |
#ifdef ENABLE_XF86_DGA |
862 |
|
if (display_type == DISPLAY_DGA) { |
863 |
|
XF86DGADirectVideo(x_display, screen, 0); |
864 |
|
XUngrabPointer(x_display, CurrentTime); |
866 |
|
} |
867 |
|
#endif |
868 |
|
|
869 |
< |
#if ENABLE_XF86_VIDMODE |
869 |
> |
#ifdef ENABLE_XF86_VIDMODE |
870 |
|
if (has_vidmode && display_type == DISPLAY_DGA) |
871 |
|
XF86VidModeSwitchToMode(x_display, screen, x_video_modes[0]); |
872 |
|
#endif |
873 |
|
|
874 |
< |
#if ENABLE_FBDEV_DGA |
874 |
> |
#ifdef ENABLE_FBDEV_DGA |
875 |
|
if (display_type == DISPLAY_DGA) { |
876 |
|
XUngrabPointer(x_display, CurrentTime); |
877 |
|
XUngrabKeyboard(x_display, CurrentTime); |
921 |
|
if (emerg_quit) |
922 |
|
QuitEmulator(); |
923 |
|
|
924 |
+ |
#ifdef HAVE_PTHREADS |
925 |
|
// Temporarily give up frame buffer lock (this is the point where |
926 |
|
// we are suspended when the user presses Ctrl-Tab) |
927 |
|
pthread_mutex_unlock(&frame_buffer_lock); |
928 |
|
pthread_mutex_lock(&frame_buffer_lock); |
929 |
+ |
#endif |
930 |
|
} |
931 |
|
|
932 |
|
|
936 |
|
|
937 |
|
void video_set_palette(uint8 *pal) |
938 |
|
{ |
939 |
+ |
#ifdef HAVE_PTHREDS |
940 |
|
pthread_mutex_lock(&palette_lock); |
941 |
+ |
#endif |
942 |
|
|
943 |
|
// Convert colors to XColor array |
944 |
|
for (int i=0; i<256; i++) { |
952 |
|
// Tell redraw thread to change palette |
953 |
|
palette_changed = true; |
954 |
|
|
955 |
+ |
#ifdef HAVE_PTHREADS |
956 |
|
pthread_mutex_unlock(&palette_lock); |
957 |
+ |
#endif |
958 |
|
} |
959 |
|
|
960 |
|
|
962 |
|
* Suspend/resume emulator |
963 |
|
*/ |
964 |
|
|
965 |
< |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
965 |
> |
#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) |
966 |
|
static void suspend_emul(void) |
967 |
|
{ |
968 |
|
if (display_type == DISPLAY_DGA) { |
970 |
|
ADBKeyUp(0x36); |
971 |
|
ctrl_down = false; |
972 |
|
|
973 |
+ |
#ifdef HAVE_PTHREADS |
974 |
|
// Lock frame buffer (this will stop the MacOS thread) |
975 |
|
pthread_mutex_lock(&frame_buffer_lock); |
976 |
+ |
#endif |
977 |
|
|
978 |
|
// Save frame buffer |
979 |
|
fb_save = malloc(VideoMonitor.y * VideoMonitor.bytes_per_row); |
981 |
|
memcpy(fb_save, the_buffer, VideoMonitor.y * VideoMonitor.bytes_per_row); |
982 |
|
|
983 |
|
// Close full screen display |
984 |
< |
#if ENABLE_XF86_DGA |
984 |
> |
#ifdef ENABLE_XF86_DGA |
985 |
|
XF86DGADirectVideo(x_display, screen, 0); |
986 |
|
#endif |
987 |
|
XUngrabPointer(x_display, CurrentTime); |
1022 |
|
XSync(x_display, false); |
1023 |
|
XGrabKeyboard(x_display, rootwin, 1, GrabModeAsync, GrabModeAsync, CurrentTime); |
1024 |
|
XGrabPointer(x_display, rootwin, 1, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime); |
1025 |
< |
#if ENABLE_XF86_DGA |
1025 |
> |
#ifdef ENABLE_XF86_DGA |
1026 |
|
XF86DGADirectVideo(x_display, screen, XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse); |
1027 |
|
XF86DGASetViewPort(x_display, screen, 0, 0); |
1028 |
|
#endif |
1035 |
|
fb_save = NULL; |
1036 |
|
} |
1037 |
|
|
1038 |
+ |
#ifdef ENABLE_XF86_DGA |
1039 |
|
if (depth == 8) |
998 |
– |
#if ENABLE_XF86_DGA |
1040 |
|
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1041 |
|
#endif |
1042 |
|
|
1043 |
+ |
#ifdef HAVE_PTHREADS |
1044 |
|
// Unlock frame buffer (and continue MacOS thread) |
1045 |
|
pthread_mutex_unlock(&frame_buffer_lock); |
1046 |
|
emul_suspended = false; |
1047 |
+ |
#endif |
1048 |
|
} |
1049 |
|
#endif |
1050 |
|
|
1106 |
|
case XK_period: case XK_greater: return 0x2f; |
1107 |
|
case XK_slash: case XK_question: return 0x2c; |
1108 |
|
|
1109 |
< |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
1109 |
> |
#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) |
1110 |
|
case XK_Tab: if (ctrl_down) {suspend_emul(); return -1;} else return 0x30; |
1111 |
|
#else |
1112 |
|
case XK_Tab: return 0x30; |
1285 |
|
if (code == 0x36) |
1286 |
|
ctrl_down = true; |
1287 |
|
} else { |
1288 |
< |
#if ENABLE_XF86_DGA || ENABLE_FBDEV_DGA |
1288 |
> |
#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) |
1289 |
|
if (code == 0x31) |
1290 |
|
resume_emul(); // Space wakes us up |
1291 |
|
#endif |
1421 |
|
* Thread for screen refresh, input handling etc. |
1422 |
|
*/ |
1423 |
|
|
1424 |
< |
static void *redraw_func(void *arg) |
1424 |
> |
void VideoRefresh(void) |
1425 |
|
{ |
1426 |
< |
int tick_counter = 0; |
1427 |
< |
|
1428 |
< |
while (!redraw_thread_cancel) { |
1429 |
< |
|
1430 |
< |
// Wait |
1431 |
< |
#ifdef HAVE_NANOSLEEP |
1432 |
< |
struct timespec req = {0, 16666667}; |
1390 |
< |
nanosleep(&req, NULL); |
1391 |
< |
#else |
1392 |
< |
usleep(16667); |
1426 |
> |
#if defined(ENABLE_XF86_DGA) || defined(ENABLE_FBDEV_DGA) |
1427 |
> |
// Quit DGA mode if requested |
1428 |
> |
if (quit_full_screen) { |
1429 |
> |
quit_full_screen = false; |
1430 |
> |
if (display_type == DISPLAY_DGA) { |
1431 |
> |
#ifdef ENABLE_XF86_DGA |
1432 |
> |
XF86DGADirectVideo(x_display, screen, 0); |
1433 |
|
#endif |
1434 |
< |
|
1435 |
< |
#if ENABLE_XF86_DGA |
1436 |
< |
// Quit DGA mode if requested |
1437 |
< |
if (quit_full_screen) { |
1398 |
< |
quit_full_screen = false; |
1399 |
< |
if (display_type == DISPLAY_DGA) { |
1400 |
< |
XF86DGADirectVideo(x_display, screen, 0); |
1401 |
< |
XUngrabPointer(x_display, CurrentTime); |
1402 |
< |
XUngrabKeyboard(x_display, CurrentTime); |
1403 |
< |
XUnmapWindow(x_display, the_win); |
1404 |
< |
XSync(x_display, false); |
1405 |
< |
} |
1434 |
> |
XUngrabPointer(x_display, CurrentTime); |
1435 |
> |
XUngrabKeyboard(x_display, CurrentTime); |
1436 |
> |
XUnmapWindow(x_display, the_win); |
1437 |
> |
XSync(x_display, false); |
1438 |
|
} |
1439 |
+ |
} |
1440 |
|
#endif |
1441 |
|
|
1442 |
< |
#if ENABLE_FBDEV_DGA |
1443 |
< |
// Quit DGA mode if requested |
1444 |
< |
if (quit_full_screen) { |
1445 |
< |
quit_full_screen = false; |
1442 |
> |
// Handle X events |
1443 |
> |
handle_events(); |
1444 |
> |
|
1445 |
> |
// Handle palette changes |
1446 |
> |
#ifdef HAVE_PTHREADS |
1447 |
> |
pthread_mutex_lock(&palette_lock); |
1448 |
> |
#endif |
1449 |
> |
if (palette_changed) { |
1450 |
> |
palette_changed = false; |
1451 |
> |
if (depth == 8) { |
1452 |
> |
XStoreColors(x_display, cmap[0], palette, 256); |
1453 |
> |
XStoreColors(x_display, cmap[1], palette, 256); |
1454 |
> |
|
1455 |
> |
#ifdef ENABLE_XF86_DGA |
1456 |
|
if (display_type == DISPLAY_DGA) { |
1457 |
< |
XUngrabPointer(x_display, CurrentTime); |
1458 |
< |
XUngrabKeyboard(x_display, CurrentTime); |
1416 |
< |
XUnmapWindow(x_display, the_win); |
1417 |
< |
XSync(x_display, false); |
1457 |
> |
current_dga_cmap ^= 1; |
1458 |
> |
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1459 |
|
} |
1460 |
+ |
#endif |
1461 |
|
} |
1462 |
+ |
} |
1463 |
+ |
#ifdef HAVE_PTHREADS |
1464 |
+ |
pthread_mutex_unlock(&palette_lock); |
1465 |
|
#endif |
1421 |
– |
// Handle X events |
1422 |
– |
handle_events(); |
1466 |
|
|
1467 |
< |
// Handle palette changes |
1468 |
< |
pthread_mutex_lock(&palette_lock); |
1469 |
< |
if (palette_changed) { |
1470 |
< |
palette_changed = false; |
1471 |
< |
if (depth == 8) { |
1472 |
< |
XStoreColors(x_display, cmap[0], palette, 256); |
1473 |
< |
XStoreColors(x_display, cmap[1], palette, 256); |
1431 |
< |
|
1432 |
< |
#if ENABLE_XF86_DGA |
1433 |
< |
if (display_type == DISPLAY_DGA) { |
1434 |
< |
current_dga_cmap ^= 1; |
1435 |
< |
XF86DGAInstallColormap(x_display, screen, cmap[current_dga_cmap]); |
1436 |
< |
} |
1437 |
< |
#endif |
1438 |
< |
} |
1439 |
< |
} |
1440 |
< |
pthread_mutex_unlock(&palette_lock); |
1467 |
> |
// In window mode, update display |
1468 |
> |
static int tick_counter = 0; |
1469 |
> |
if (display_type == DISPLAY_WINDOW) { |
1470 |
> |
tick_counter++; |
1471 |
> |
update_display(tick_counter); |
1472 |
> |
} |
1473 |
> |
} |
1474 |
|
|
1475 |
< |
// In window mode, update display |
1476 |
< |
if (display_type == DISPLAY_WINDOW) { |
1477 |
< |
tick_counter++; |
1478 |
< |
update_display(tick_counter); |
1479 |
< |
} |
1475 |
> |
#ifdef HAVE_PTHREADS |
1476 |
> |
static void *redraw_func(void *arg) |
1477 |
> |
{ |
1478 |
> |
while (!redraw_thread_cancel) { |
1479 |
> |
#ifdef HAVE_NANOSLEEP |
1480 |
> |
struct timespec req = {0, 16666667}; |
1481 |
> |
nanosleep(&req, NULL); |
1482 |
> |
#else |
1483 |
> |
usleep(16667); |
1484 |
> |
#endif |
1485 |
> |
VideoRefresh(); |
1486 |
|
} |
1487 |
|
return NULL; |
1488 |
|
} |
1489 |
+ |
#endif |