21 |
|
/* |
22 |
|
* NOTES: |
23 |
|
* The Ctrl key works like a qualifier for special actions: |
24 |
< |
* Ctrl-Tab = suspend DGA mode |
24 |
> |
* Ctrl-Tab = suspend DGA mode (TODO) |
25 |
|
* Ctrl-Esc = emergency quit |
26 |
|
* Ctrl-F1 = mount floppy |
27 |
|
* Ctrl-F5 = grab mouse (in windowed mode) |
28 |
|
* |
29 |
|
* FIXMEs and TODOs: |
30 |
+ |
* - Ctr-Tab for suspend/resume but how? SDL does not support that for non-Linux |
31 |
|
* - Ctrl-Fn doesn't generate SDL_KEYDOWN events (SDL bug?) |
32 |
|
* - Mouse acceleration, there is no API in SDL yet for that |
33 |
|
* - Force relative mode in Grab mode even if SDL provides absolute coordinates? |
38 |
|
* Besides, there can't seem to be a way to call SetVideoMode() from a child thread. |
39 |
|
* - Refresh performance is still slow. Use SDL_CreateRGBSurface()? |
40 |
|
* - Backport hw cursor acceleration to Basilisk II? |
41 |
+ |
* - Factor out code |
42 |
|
*/ |
43 |
|
|
44 |
|
#include "sysdeps.h" |
101 |
|
static uint32 the_buffer_size; // Size of allocated the_buffer |
102 |
|
|
103 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
104 |
+ |
#ifndef USE_CPU_EMUL_SERVICES |
105 |
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread |
106 |
|
static SDL_Thread *redraw_thread = NULL; // Redraw thread |
107 |
+ |
#ifdef SHEEPSHAVER |
108 |
|
static volatile bool thread_stop_req = false; |
109 |
|
static volatile bool thread_stop_ack = false; // Acknowledge for thread_stop_req |
110 |
+ |
#endif |
111 |
+ |
#endif |
112 |
|
|
113 |
|
#ifdef ENABLE_VOSF |
114 |
|
static bool use_vosf = false; // Flag: VOSF enabled |
135 |
|
static bool sdl_palette_changed = false; // Flag: Palette changed, redraw thread must set new colors |
136 |
|
static const int sdl_eventmask = SDL_MOUSEBUTTONDOWNMASK | SDL_MOUSEBUTTONUPMASK | SDL_MOUSEMOTIONMASK | SDL_KEYUPMASK | SDL_KEYDOWNMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK; |
137 |
|
|
138 |
+ |
// Mutex to protect SDL events |
139 |
+ |
static SDL_mutex *sdl_events_lock = NULL; |
140 |
+ |
#define LOCK_EVENTS SDL_LockMutex(sdl_events_lock) |
141 |
+ |
#define UNLOCK_EVENTS SDL_UnlockMutex(sdl_events_lock) |
142 |
+ |
|
143 |
|
// Mutex to protect palette |
144 |
|
static SDL_mutex *sdl_palette_lock = NULL; |
145 |
|
#define LOCK_PALETTE SDL_LockMutex(sdl_palette_lock) |
163 |
|
|
164 |
|
|
165 |
|
/* |
166 |
+ |
* SDL surface locking glue |
167 |
+ |
*/ |
168 |
+ |
|
169 |
+ |
#ifdef ENABLE_VOSF |
170 |
+ |
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE) do { \ |
171 |
+ |
if ((SURFACE)->flags & (SDL_HWSURFACE | SDL_FULLSCREEN)) \ |
172 |
+ |
the_host_buffer = (uint8 *)(SURFACE)->pixels; \ |
173 |
+ |
} while (0) |
174 |
+ |
#else |
175 |
+ |
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE) |
176 |
+ |
#endif |
177 |
+ |
|
178 |
+ |
#define SDL_VIDEO_LOCK_SURFACE(SURFACE) do { \ |
179 |
+ |
if (SDL_MUSTLOCK(SURFACE)) { \ |
180 |
+ |
SDL_LockSurface(SURFACE); \ |
181 |
+ |
SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE); \ |
182 |
+ |
} \ |
183 |
+ |
} while (0) |
184 |
+ |
|
185 |
+ |
#define SDL_VIDEO_UNLOCK_SURFACE(SURFACE) do { \ |
186 |
+ |
if (SDL_MUSTLOCK(SURFACE)) \ |
187 |
+ |
SDL_UnlockSurface(SURFACE); \ |
188 |
+ |
} while (0) |
189 |
+ |
|
190 |
+ |
|
191 |
+ |
/* |
192 |
|
* Framebuffer allocation routines |
193 |
|
*/ |
194 |
|
|
195 |
|
static void *vm_acquire_framebuffer(uint32 size) |
196 |
|
{ |
160 |
– |
#ifdef SHEEPSHAVER |
161 |
– |
#ifdef DIRECT_ADDRESSING_HACK |
162 |
– |
const uint32 FRAME_BUFFER_BASE = 0x61000000; |
163 |
– |
uint8 *fb = Mac2HostAddr(FRAME_BUFFER_BASE); |
164 |
– |
if (vm_acquire_fixed(fb, size) < 0) |
165 |
– |
fb = VM_MAP_FAILED; |
166 |
– |
return fb; |
167 |
– |
#endif |
168 |
– |
#endif |
197 |
|
return vm_acquire(size); |
198 |
|
} |
199 |
|
|
420 |
|
// Check wether specified mode is available |
421 |
|
static bool has_mode(int type, int width, int height) |
422 |
|
{ |
395 |
– |
// FIXME: no fullscreen support yet |
396 |
– |
if (type == DISPLAY_SCREEN) |
397 |
– |
return false; |
398 |
– |
|
423 |
|
#ifdef SHEEPSHAVER |
424 |
|
// Filter out Classic resolutiosn |
425 |
|
if (width == 512 && height == 384) |
426 |
|
return false; |
427 |
|
|
428 |
< |
// Read window modes prefs |
428 |
> |
// "screen" prefs items always succeeds |
429 |
> |
if (PrefsFindString("screen")) |
430 |
> |
return true; |
431 |
> |
|
432 |
> |
// Read window & screen modes prefs |
433 |
|
static uint32 window_modes = 0; |
434 |
|
static uint32 screen_modes = 0; |
435 |
|
if (window_modes == 0 || screen_modes == 0) { |
439 |
|
window_modes |= 3; // Allow at least 640x480 and 800x600 window modes |
440 |
|
} |
441 |
|
|
442 |
< |
if (type == DISPLAY_WINDOW) { |
443 |
< |
int apple_mask, apple_id = find_apple_resolution(width, height); |
444 |
< |
switch (apple_id) { |
445 |
< |
case APPLE_640x480: apple_mask = 0x01; break; |
446 |
< |
case APPLE_800x600: apple_mask = 0x02; break; |
447 |
< |
case APPLE_1024x768: apple_mask = 0x04; break; |
448 |
< |
case APPLE_1152x768: apple_mask = 0x40; break; |
449 |
< |
case APPLE_1152x900: apple_mask = 0x08; break; |
450 |
< |
case APPLE_1280x1024: apple_mask = 0x10; break; |
451 |
< |
case APPLE_1600x1200: apple_mask = 0x20; break; |
452 |
< |
default: apple_mask = 0x00; break; |
425 |
< |
} |
426 |
< |
return (window_modes & apple_mask); |
442 |
> |
int test_modes; |
443 |
> |
switch (type) { |
444 |
> |
case DISPLAY_WINDOW: |
445 |
> |
test_modes = window_modes; |
446 |
> |
break; |
447 |
> |
case DISPLAY_SCREEN: |
448 |
> |
test_modes = screen_modes; |
449 |
> |
break; |
450 |
> |
default: |
451 |
> |
test_modes = 0; |
452 |
> |
break; |
453 |
|
} |
454 |
< |
#else |
455 |
< |
return true; |
454 |
> |
|
455 |
> |
int apple_mask; |
456 |
> |
switch (find_apple_resolution(width, height)) { |
457 |
> |
case APPLE_640x480: apple_mask = 0x01; break; |
458 |
> |
case APPLE_800x600: apple_mask = 0x02; break; |
459 |
> |
case APPLE_1024x768: apple_mask = 0x04; break; |
460 |
> |
case APPLE_1152x768: apple_mask = 0x40; break; |
461 |
> |
case APPLE_1152x900: apple_mask = 0x08; break; |
462 |
> |
case APPLE_1280x1024: apple_mask = 0x10; break; |
463 |
> |
case APPLE_1600x1200: apple_mask = 0x20; break; |
464 |
> |
default: apple_mask = 0x00; break; |
465 |
> |
} |
466 |
> |
return (test_modes & apple_mask); |
467 |
|
#endif |
468 |
< |
return false; |
468 |
> |
return true; |
469 |
|
} |
470 |
|
|
471 |
|
// Add mode to list of supported modes |
542 |
|
// Set mouse grab mode |
543 |
|
static SDL_GrabMode set_grab_mode(SDL_GrabMode mode) |
544 |
|
{ |
545 |
< |
const SDL_VideoInfo *vi =SDL_GetVideoInfo(); |
545 |
> |
const SDL_VideoInfo *vi = SDL_GetVideoInfo(); |
546 |
|
return (vi && vi->wm_available ? SDL_WM_GrabInput(mode) : SDL_GRAB_OFF); |
547 |
|
} |
548 |
|
|
601 |
|
int mouse_last_x, mouse_last_y; // Last mouse position (for relative mode) |
602 |
|
}; |
603 |
|
|
604 |
+ |
class driver_fullscreen : public driver_base { |
605 |
+ |
public: |
606 |
+ |
driver_fullscreen(SDL_monitor_desc &monitor); |
607 |
+ |
~driver_fullscreen(); |
608 |
+ |
}; |
609 |
+ |
|
610 |
|
static driver_base *drv = NULL; // Pointer to currently used driver object |
611 |
|
|
612 |
|
#ifdef ENABLE_VOSF |
822 |
|
ADBMouseMoved(x, y); |
823 |
|
} |
824 |
|
|
825 |
+ |
|
826 |
+ |
/* |
827 |
+ |
* Full-screen display driver |
828 |
+ |
*/ |
829 |
+ |
|
830 |
+ |
// Open display |
831 |
+ |
driver_fullscreen::driver_fullscreen(SDL_monitor_desc &m) |
832 |
+ |
: driver_base(m) |
833 |
+ |
{ |
834 |
+ |
int width = VIDEO_MODE_X, height = VIDEO_MODE_Y; |
835 |
+ |
int aligned_width = (width + 15) & ~15; |
836 |
+ |
int aligned_height = (height + 15) & ~15; |
837 |
+ |
|
838 |
+ |
// Set absolute mouse mode |
839 |
+ |
ADBSetRelMouseMode(false); |
840 |
+ |
|
841 |
+ |
// Create surface |
842 |
+ |
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); |
843 |
+ |
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE | SDL_FULLSCREEN)) == NULL) |
844 |
+ |
return; |
845 |
+ |
|
846 |
+ |
#ifdef ENABLE_VOSF |
847 |
+ |
use_vosf = true; |
848 |
+ |
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
849 |
+ |
the_host_buffer = (uint8 *)s->pixels; |
850 |
+ |
the_buffer_size = page_extend((aligned_height + 2) * s->pitch); |
851 |
+ |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
852 |
+ |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
853 |
+ |
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
854 |
+ |
|
855 |
+ |
// Check whether we can initialize the VOSF subsystem and it's profitable |
856 |
+ |
if (!video_vosf_init(m)) { |
857 |
+ |
WarningAlert(STR_VOSF_INIT_ERR); |
858 |
+ |
use_vosf = false; |
859 |
+ |
} |
860 |
+ |
else if (!video_vosf_profitable()) { |
861 |
+ |
video_vosf_exit(); |
862 |
+ |
printf("VOSF acceleration is not profitable on this platform, disabling it\n"); |
863 |
+ |
use_vosf = false; |
864 |
+ |
} |
865 |
+ |
if (!use_vosf) { |
866 |
+ |
free(the_buffer_copy); |
867 |
+ |
vm_release(the_buffer, the_buffer_size); |
868 |
+ |
the_host_buffer = NULL; |
869 |
+ |
} |
870 |
+ |
#endif |
871 |
+ |
if (!use_vosf) { |
872 |
+ |
// Allocate memory for frame buffer |
873 |
+ |
the_buffer_size = (aligned_height + 2) * s->pitch; |
874 |
+ |
the_buffer_copy = (uint8 *)calloc(1, the_buffer_size); |
875 |
+ |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
876 |
+ |
D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy)); |
877 |
+ |
} |
878 |
+ |
|
879 |
+ |
// Hide cursor |
880 |
+ |
SDL_ShowCursor(0); |
881 |
+ |
|
882 |
+ |
// Init blitting routines |
883 |
+ |
SDL_PixelFormat *f = s->format; |
884 |
+ |
VisualFormat visualFormat; |
885 |
+ |
visualFormat.depth = depth; |
886 |
+ |
visualFormat.Rmask = f->Rmask; |
887 |
+ |
visualFormat.Gmask = f->Gmask; |
888 |
+ |
visualFormat.Bmask = f->Bmask; |
889 |
+ |
Screen_blitter_init(visualFormat, true, mac_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
890 |
+ |
|
891 |
+ |
// Load gray ramp to 8->16/32 expand map |
892 |
+ |
if (!IsDirectMode(mode)) |
893 |
+ |
for (int i=0; i<256; i++) |
894 |
+ |
ExpandMap[i] = SDL_MapRGB(f, i, i, i); |
895 |
+ |
|
896 |
+ |
// Set frame buffer base |
897 |
+ |
set_mac_frame_buffer(monitor, VIDEO_MODE_DEPTH, true); |
898 |
+ |
|
899 |
+ |
// Everything went well |
900 |
+ |
init_ok = true; |
901 |
+ |
} |
902 |
+ |
|
903 |
+ |
// Close display |
904 |
+ |
driver_fullscreen::~driver_fullscreen() |
905 |
+ |
{ |
906 |
+ |
#ifdef ENABLE_VOSF |
907 |
+ |
if (use_vosf) |
908 |
+ |
the_host_buffer = NULL; // don't free() in driver_base dtor |
909 |
+ |
#endif |
910 |
+ |
if (s) |
911 |
+ |
SDL_FreeSurface(s); |
912 |
+ |
|
913 |
+ |
// Show cursor |
914 |
+ |
SDL_ShowCursor(1); |
915 |
+ |
} |
916 |
+ |
|
917 |
+ |
|
918 |
|
/* |
919 |
|
* Initialization |
920 |
|
*/ |
1013 |
|
case DISPLAY_WINDOW: |
1014 |
|
drv = new(std::nothrow) driver_window(*this); |
1015 |
|
break; |
1016 |
+ |
case DISPLAY_SCREEN: |
1017 |
+ |
drv = new(std::nothrow) driver_fullscreen(*this); |
1018 |
+ |
break; |
1019 |
|
} |
1020 |
|
if (drv == NULL) |
1021 |
|
return false; |
1032 |
|
LOCK_FRAME_BUFFER; |
1033 |
|
|
1034 |
|
// Start redraw/input thread |
1035 |
+ |
#ifndef USE_CPU_EMUL_SERVICES |
1036 |
|
redraw_thread_cancel = false; |
1037 |
|
redraw_thread_active = ((redraw_thread = SDL_CreateThread(redraw_func, NULL)) != NULL); |
1038 |
|
if (!redraw_thread_active) { |
1039 |
|
printf("FATAL: cannot create redraw thread\n"); |
1040 |
|
return false; |
1041 |
|
} |
1042 |
+ |
#else |
1043 |
+ |
redraw_thread_active = true; |
1044 |
+ |
#endif |
1045 |
|
return true; |
1046 |
|
} |
1047 |
|
|
1062 |
|
#endif |
1063 |
|
|
1064 |
|
// Create Mutexes |
1065 |
+ |
if ((sdl_events_lock = SDL_CreateMutex()) == NULL) |
1066 |
+ |
return false; |
1067 |
|
if ((sdl_palette_lock = SDL_CreateMutex()) == NULL) |
1068 |
|
return false; |
1069 |
|
if ((frame_buffer_lock = SDL_CreateMutex()) == NULL) |
1079 |
|
|
1080 |
|
// Get screen mode from preferences |
1081 |
|
const char *mode_str = NULL; |
937 |
– |
#ifndef SHEEPSHAVER |
1082 |
|
if (classic_mode) |
1083 |
|
mode_str = "win/512/342"; |
1084 |
|
else |
1085 |
|
mode_str = PrefsFindString("screen"); |
942 |
– |
#endif |
1086 |
|
|
1087 |
|
// Determine display type and default dimensions |
1088 |
|
int default_width, default_height; |
1098 |
|
if (mode_str) { |
1099 |
|
if (sscanf(mode_str, "win/%d/%d", &default_width, &default_height) == 2) |
1100 |
|
display_type = DISPLAY_WINDOW; |
1101 |
+ |
else if (sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2) |
1102 |
+ |
display_type = DISPLAY_SCREEN; |
1103 |
|
} |
1104 |
|
int max_width = 640, max_height = 480; |
1105 |
|
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); |
1106 |
|
if (modes && modes != (SDL_Rect **)-1) { |
1107 |
< |
max_width = modes[0]->w; |
1108 |
< |
max_height = modes[0]->h; |
1107 |
> |
// It turns out that on some implementations, and contrary to the documentation, |
1108 |
> |
// the returned list is not sorted from largest to smallest (e.g. Windows) |
1109 |
> |
for (int i = 0; modes[i] != NULL; i++) { |
1110 |
> |
const int w = modes[i]->w; |
1111 |
> |
const int h = modes[i]->h; |
1112 |
> |
if (w > max_width && h > max_height) { |
1113 |
> |
max_width = w; |
1114 |
> |
max_height = h; |
1115 |
> |
} |
1116 |
> |
} |
1117 |
|
if (default_width > max_width) |
1118 |
|
default_width = max_width; |
1119 |
|
if (default_height > max_height) |
1153 |
|
add_window_modes(video_depth(d)); |
1154 |
|
} |
1155 |
|
} |
1156 |
< |
} else |
1157 |
< |
add_mode(display_type, default_width, default_height, 0x80, TrivialBytesPerRow(default_width, (video_depth)default_depth), default_depth); |
1156 |
> |
} else if (display_type == DISPLAY_SCREEN) { |
1157 |
> |
struct { |
1158 |
> |
int w; |
1159 |
> |
int h; |
1160 |
> |
int resolution_id; |
1161 |
> |
} |
1162 |
> |
video_modes[] = { |
1163 |
> |
{ -1, -1, 0x80 }, |
1164 |
> |
{ 640, 480, 0x81 }, |
1165 |
> |
{ 800, 600, 0x82 }, |
1166 |
> |
{ 1024, 768, 0x83 }, |
1167 |
> |
{ 1152, 870, 0x84 }, |
1168 |
> |
{ 1280, 1024, 0x85 }, |
1169 |
> |
{ 1600, 1200, 0x86 }, |
1170 |
> |
{ 0, } |
1171 |
> |
}; |
1172 |
> |
video_modes[0].w = default_width; |
1173 |
> |
video_modes[0].h = default_height; |
1174 |
> |
|
1175 |
> |
for (int i = 0; video_modes[i].w != 0; i++) { |
1176 |
> |
const int w = video_modes[i].w; |
1177 |
> |
const int h = video_modes[i].h; |
1178 |
> |
if (i > 0 && (w >= default_width || h >= default_height)) |
1179 |
> |
continue; |
1180 |
> |
#ifdef ENABLE_VOSF |
1181 |
> |
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++) { |
1182 |
> |
int bpp = sdl_depth_of_video_depth(d); |
1183 |
> |
if (SDL_VideoModeOK(w, h, bpp, SDL_HWSURFACE | SDL_FULLSCREEN)) |
1184 |
> |
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)d), d); |
1185 |
> |
} |
1186 |
> |
#else |
1187 |
> |
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)default_depth), default_depth); |
1188 |
> |
#endif |
1189 |
> |
} |
1190 |
> |
} |
1191 |
> |
|
1192 |
|
if (VideoModes.empty()) { |
1193 |
|
ErrorAlert(STR_NO_XVISUAL_ERR); |
1194 |
|
return false; |
1260 |
|
D(bug("video_close()\n")); |
1261 |
|
|
1262 |
|
// Stop redraw thread |
1263 |
+ |
#ifndef USE_CPU_EMUL_SERVICES |
1264 |
|
if (redraw_thread_active) { |
1265 |
|
redraw_thread_cancel = true; |
1266 |
|
SDL_WaitThread(redraw_thread, NULL); |
1267 |
|
} |
1268 |
+ |
#endif |
1269 |
|
redraw_thread_active = false; |
1270 |
|
|
1271 |
|
// Unlock frame buffer |
1289 |
|
SDL_DestroyMutex(frame_buffer_lock); |
1290 |
|
if (sdl_palette_lock) |
1291 |
|
SDL_DestroyMutex(sdl_palette_lock); |
1292 |
+ |
if (sdl_events_lock) |
1293 |
+ |
SDL_DestroyMutex(sdl_events_lock); |
1294 |
|
} |
1295 |
|
|
1296 |
|
|
1460 |
|
void SDL_monitor_desc::switch_to_current_mode(void) |
1461 |
|
{ |
1462 |
|
// Close and reopen display |
1463 |
+ |
LOCK_EVENTS; |
1464 |
|
video_close(); |
1465 |
|
video_open(); |
1466 |
+ |
UNLOCK_EVENTS; |
1467 |
|
|
1468 |
|
if (drv == NULL) { |
1469 |
|
ErrorAlert(STR_OPEN_WINDOW_ERR); |
1566 |
|
|
1567 |
|
case SDLK_1: case SDLK_EXCLAIM: return 0x12; |
1568 |
|
case SDLK_2: case SDLK_AT: return 0x13; |
1569 |
< |
// case SDLK_3: case SDLK_numbersign: return 0x14; |
1569 |
> |
case SDLK_3: case SDLK_HASH: return 0x14; |
1570 |
|
case SDLK_4: case SDLK_DOLLAR: return 0x15; |
1571 |
< |
// case SDLK_5: case SDLK_percent: return 0x17; |
1571 |
> |
case SDLK_5: return 0x17; |
1572 |
|
case SDLK_6: return 0x16; |
1573 |
|
case SDLK_7: return 0x1a; |
1574 |
|
case SDLK_8: return 0x1c; |
1575 |
|
case SDLK_9: return 0x19; |
1576 |
|
case SDLK_0: return 0x1d; |
1577 |
|
|
1578 |
< |
// case SDLK_BACKQUOTE: case SDLK_asciitilde: return 0x0a; |
1578 |
> |
case SDLK_BACKQUOTE: return 0x0a; |
1579 |
|
case SDLK_MINUS: case SDLK_UNDERSCORE: return 0x1b; |
1580 |
|
case SDLK_EQUALS: case SDLK_PLUS: return 0x18; |
1581 |
< |
// case SDLK_bracketleft: case SDLK_braceleft: return 0x21; |
1582 |
< |
// case SDLK_bracketright: case SDLK_braceright: return 0x1e; |
1583 |
< |
// case SDLK_BACKSLASH: case SDLK_bar: return 0x2a; |
1581 |
> |
case SDLK_LEFTBRACKET: return 0x21; |
1582 |
> |
case SDLK_RIGHTBRACKET: return 0x1e; |
1583 |
> |
case SDLK_BACKSLASH: return 0x2a; |
1584 |
|
case SDLK_SEMICOLON: case SDLK_COLON: return 0x29; |
1585 |
< |
// case SDLK_apostrophe: case SDLK_QUOTEDBL: return 0x27; |
1585 |
> |
case SDLK_QUOTE: case SDLK_QUOTEDBL: return 0x27; |
1586 |
|
case SDLK_COMMA: case SDLK_LESS: return 0x2b; |
1587 |
|
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f; |
1588 |
|
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c; |
1614 |
|
case SDLK_LMETA: return 0x3a; |
1615 |
|
case SDLK_RMETA: return 0x3a; |
1616 |
|
#endif |
1617 |
+ |
case SDLK_LSUPER: return 0x3a; // "Windows" key |
1618 |
+ |
case SDLK_RSUPER: return 0x3a; |
1619 |
|
case SDLK_MENU: return 0x32; |
1620 |
|
case SDLK_CAPSLOCK: return 0x39; |
1621 |
|
case SDLK_NUMLOCK: return 0x47; |
2009 |
|
tick_counter = 0; |
2010 |
|
if (mainBuffer.dirty) { |
2011 |
|
LOCK_VOSF; |
2012 |
< |
update_display_dga_vosf(); |
2012 |
> |
update_display_dga_vosf(static_cast<driver_fullscreen *>(drv)); |
2013 |
|
UNLOCK_VOSF; |
2014 |
|
} |
2015 |
|
} |
2073 |
|
} |
2074 |
|
} |
2075 |
|
|
2076 |
+ |
static inline void do_video_refresh(void) |
2077 |
+ |
{ |
2078 |
+ |
// Handle SDL events |
2079 |
+ |
handle_events(); |
2080 |
+ |
|
2081 |
+ |
// Update display |
2082 |
+ |
video_refresh(); |
2083 |
+ |
|
2084 |
+ |
#ifdef SHEEPSHAVER |
2085 |
+ |
// Set new cursor image if it was changed |
2086 |
+ |
if (cursor_changed && sdl_cursor) { |
2087 |
+ |
cursor_changed = false; |
2088 |
+ |
LOCK_EVENTS; |
2089 |
+ |
SDL_FreeCursor(sdl_cursor); |
2090 |
+ |
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]); |
2091 |
+ |
if (sdl_cursor) |
2092 |
+ |
SDL_SetCursor(sdl_cursor); |
2093 |
+ |
UNLOCK_EVENTS; |
2094 |
+ |
} |
2095 |
+ |
#endif |
2096 |
+ |
|
2097 |
+ |
// Set new palette if it was changed |
2098 |
+ |
handle_palette_changes(); |
2099 |
+ |
} |
2100 |
+ |
|
2101 |
+ |
// This function is called on non-threaded platforms from a timer interrupt |
2102 |
+ |
void VideoRefresh(void) |
2103 |
+ |
{ |
2104 |
+ |
// We need to check redraw_thread_active to inhibit refreshed during |
2105 |
+ |
// mode changes on non-threaded platforms |
2106 |
+ |
if (!redraw_thread_active) |
2107 |
+ |
return; |
2108 |
+ |
|
2109 |
+ |
// Process pending events and update display |
2110 |
+ |
do_video_refresh(); |
2111 |
+ |
} |
2112 |
+ |
|
2113 |
|
const int VIDEO_REFRESH_HZ = 60; |
2114 |
|
const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ; |
2115 |
|
|
2116 |
+ |
#ifndef USE_CPU_EMUL_SERVICES |
2117 |
|
static int redraw_func(void *arg) |
2118 |
|
{ |
2119 |
|
uint64 start = GetTicks_usec(); |
2139 |
|
} |
2140 |
|
#endif |
2141 |
|
|
2142 |
< |
// Handle SDL events |
2143 |
< |
handle_events(); |
1911 |
< |
|
1912 |
< |
// Refresh display |
1913 |
< |
video_refresh(); |
1914 |
< |
|
1915 |
< |
#ifdef SHEEPSHAVER |
1916 |
< |
// Set new cursor image if it was changed |
1917 |
< |
if (cursor_changed && sdl_cursor) { |
1918 |
< |
cursor_changed = false; |
1919 |
< |
SDL_FreeCursor(sdl_cursor); |
1920 |
< |
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]); |
1921 |
< |
if (sdl_cursor) |
1922 |
< |
SDL_SetCursor(sdl_cursor); |
1923 |
< |
} |
1924 |
< |
#endif |
1925 |
< |
|
1926 |
< |
// Set new palette if it was changed |
1927 |
< |
handle_palette_changes(); |
2142 |
> |
// Process pending events and update display |
2143 |
> |
do_video_refresh(); |
2144 |
|
} |
2145 |
|
|
2146 |
|
uint64 end = GetTicks_usec(); |
2147 |
|
D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start))); |
2148 |
|
return 0; |
2149 |
|
} |
2150 |
+ |
#endif |