1 |
|
/* |
2 |
|
* video_sdl.cpp - Video/graphics emulation, SDL specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2004 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 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 |
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" |
58 |
|
#include "video.h" |
59 |
|
#include "video_defs.h" |
60 |
|
#include "video_blit.h" |
61 |
+ |
#include "vm_alloc.h" |
62 |
|
|
63 |
|
#define DEBUG 0 |
64 |
|
#include "debug.h" |
84 |
|
#endif |
85 |
|
|
86 |
|
// Constants |
87 |
+ |
#ifdef WIN32 |
88 |
+ |
const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes"; |
89 |
+ |
#else |
90 |
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes"; |
91 |
+ |
#endif |
92 |
|
|
93 |
|
|
94 |
|
// Global variables |
103 |
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed |
104 |
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread |
105 |
|
static SDL_Thread *redraw_thread = NULL; // Redraw thread |
106 |
+ |
static volatile bool thread_stop_req = false; |
107 |
+ |
static volatile bool thread_stop_ack = false; // Acknowledge for thread_stop_req |
108 |
|
|
109 |
|
#ifdef ENABLE_VOSF |
110 |
|
static bool use_vosf = false; // Flag: VOSF enabled |
154 |
|
|
155 |
|
|
156 |
|
/* |
157 |
+ |
* Framebuffer allocation routines |
158 |
+ |
*/ |
159 |
+ |
|
160 |
+ |
static void *vm_acquire_framebuffer(uint32 size) |
161 |
+ |
{ |
162 |
+ |
#ifdef SHEEPSHAVER |
163 |
+ |
#ifdef DIRECT_ADDRESSING_HACK |
164 |
+ |
const uint32 FRAME_BUFFER_BASE = 0x61000000; |
165 |
+ |
uint8 *fb = Mac2HostAddr(FRAME_BUFFER_BASE); |
166 |
+ |
if (vm_acquire_fixed(fb, size) < 0) |
167 |
+ |
fb = VM_MAP_FAILED; |
168 |
+ |
return fb; |
169 |
+ |
#endif |
170 |
+ |
#endif |
171 |
+ |
return vm_acquire(size); |
172 |
+ |
} |
173 |
+ |
|
174 |
+ |
static inline void vm_release_framebuffer(void *fb, uint32 size) |
175 |
+ |
{ |
176 |
+ |
vm_release(fb, size); |
177 |
+ |
} |
178 |
+ |
|
179 |
+ |
|
180 |
+ |
/* |
181 |
|
* SheepShaver glue |
182 |
|
*/ |
183 |
|
|
357 |
|
} |
358 |
|
|
359 |
|
// Map video_mode depth ID to numerical depth value |
360 |
< |
static int sdl_depth_of_video_depth(int video_depth) |
360 |
> |
static int mac_depth_of_video_depth(int video_depth) |
361 |
|
{ |
362 |
|
int depth = -1; |
363 |
|
switch (video_depth) { |
385 |
|
return depth; |
386 |
|
} |
387 |
|
|
388 |
+ |
// Map video_mode depth ID to SDL screen depth |
389 |
+ |
static int sdl_depth_of_video_depth(int video_depth) |
390 |
+ |
{ |
391 |
+ |
return (video_depth <= VIDEO_DEPTH_8BIT) ? 8 : mac_depth_of_video_depth(video_depth); |
392 |
+ |
} |
393 |
+ |
|
394 |
|
// Check wether specified mode is available |
395 |
|
static bool has_mode(int type, int width, int height) |
396 |
|
{ |
358 |
– |
// FIXME: no fullscreen support yet |
359 |
– |
if (type == DISPLAY_SCREEN) |
360 |
– |
return false; |
361 |
– |
|
397 |
|
#ifdef SHEEPSHAVER |
398 |
|
// Filter out Classic resolutiosn |
399 |
|
if (width == 512 && height == 384) |
400 |
|
return false; |
401 |
|
|
402 |
< |
// Read window modes prefs |
402 |
> |
// "screen" prefs items always succeeds |
403 |
> |
if (PrefsFindString("screen")) |
404 |
> |
return true; |
405 |
> |
|
406 |
> |
// Read window & screen modes prefs |
407 |
|
static uint32 window_modes = 0; |
408 |
|
static uint32 screen_modes = 0; |
409 |
|
if (window_modes == 0 || screen_modes == 0) { |
413 |
|
window_modes |= 3; // Allow at least 640x480 and 800x600 window modes |
414 |
|
} |
415 |
|
|
416 |
< |
if (type == DISPLAY_WINDOW) { |
417 |
< |
int apple_mask, apple_id = find_apple_resolution(width, height); |
418 |
< |
switch (apple_id) { |
419 |
< |
case APPLE_640x480: apple_mask = 0x01; break; |
420 |
< |
case APPLE_800x600: apple_mask = 0x02; break; |
421 |
< |
case APPLE_1024x768: apple_mask = 0x04; break; |
422 |
< |
case APPLE_1152x768: apple_mask = 0x40; break; |
423 |
< |
case APPLE_1152x900: apple_mask = 0x08; break; |
424 |
< |
case APPLE_1280x1024: apple_mask = 0x10; break; |
425 |
< |
case APPLE_1600x1200: apple_mask = 0x20; break; |
426 |
< |
default: apple_mask = 0x00; break; |
388 |
< |
} |
389 |
< |
return (window_modes & apple_mask); |
416 |
> |
int test_modes; |
417 |
> |
switch (type) { |
418 |
> |
case DISPLAY_WINDOW: |
419 |
> |
test_modes = window_modes; |
420 |
> |
break; |
421 |
> |
case DISPLAY_SCREEN: |
422 |
> |
test_modes = screen_modes; |
423 |
> |
break; |
424 |
> |
default: |
425 |
> |
test_modes = 0; |
426 |
> |
break; |
427 |
|
} |
428 |
< |
#else |
429 |
< |
return true; |
428 |
> |
|
429 |
> |
int apple_mask; |
430 |
> |
switch (find_apple_resolution(width, height)) { |
431 |
> |
case APPLE_640x480: apple_mask = 0x01; break; |
432 |
> |
case APPLE_800x600: apple_mask = 0x02; break; |
433 |
> |
case APPLE_1024x768: apple_mask = 0x04; break; |
434 |
> |
case APPLE_1152x768: apple_mask = 0x40; break; |
435 |
> |
case APPLE_1152x900: apple_mask = 0x08; break; |
436 |
> |
case APPLE_1280x1024: apple_mask = 0x10; break; |
437 |
> |
case APPLE_1600x1200: apple_mask = 0x20; break; |
438 |
> |
default: apple_mask = 0x00; break; |
439 |
> |
} |
440 |
> |
return (test_modes & apple_mask); |
441 |
|
#endif |
442 |
< |
return false; |
442 |
> |
return true; |
443 |
|
} |
444 |
|
|
445 |
|
// Add mode to list of supported modes |
516 |
|
// Set mouse grab mode |
517 |
|
static SDL_GrabMode set_grab_mode(SDL_GrabMode mode) |
518 |
|
{ |
519 |
< |
const SDL_VideoInfo *vi =SDL_GetVideoInfo(); |
519 |
> |
const SDL_VideoInfo *vi = SDL_GetVideoInfo(); |
520 |
|
return (vi && vi->wm_available ? SDL_WM_GrabInput(mode) : SDL_GRAB_OFF); |
521 |
|
} |
522 |
|
|
575 |
|
int mouse_last_x, mouse_last_y; // Last mouse position (for relative mode) |
576 |
|
}; |
577 |
|
|
578 |
+ |
class driver_fullscreen : public driver_base { |
579 |
+ |
public: |
580 |
+ |
driver_fullscreen(SDL_monitor_desc &monitor); |
581 |
+ |
~driver_fullscreen(); |
582 |
+ |
}; |
583 |
+ |
|
584 |
|
static driver_base *drv = NULL; // Pointer to currently used driver object |
585 |
|
|
586 |
|
#ifdef ENABLE_VOSF |
602 |
|
if (s) |
603 |
|
SDL_FreeSurface(s); |
604 |
|
|
605 |
+ |
// the_buffer shall always be mapped through vm_acquire_framebuffer() |
606 |
+ |
if (the_buffer != VM_MAP_FAILED) { |
607 |
+ |
D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size)); |
608 |
+ |
vm_release_framebuffer(the_buffer, the_buffer_size); |
609 |
+ |
the_buffer = NULL; |
610 |
+ |
} |
611 |
+ |
|
612 |
|
// Free frame buffer(s) |
613 |
|
if (!use_vosf) { |
553 |
– |
if (the_buffer) { |
554 |
– |
free(the_buffer); |
555 |
– |
the_buffer = NULL; |
556 |
– |
} |
614 |
|
if (the_buffer_copy) { |
615 |
|
free(the_buffer_copy); |
616 |
|
the_buffer_copy = NULL; |
618 |
|
} |
619 |
|
#ifdef ENABLE_VOSF |
620 |
|
else { |
564 |
– |
// the_buffer shall always be mapped through vm_acquire() so that we can vm_protect() it at will |
565 |
– |
if (the_buffer != VM_MAP_FAILED) { |
566 |
– |
D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size)); |
567 |
– |
vm_release(the_buffer, the_buffer_size); |
568 |
– |
the_buffer = NULL; |
569 |
– |
} |
621 |
|
if (the_host_buffer) { |
622 |
|
D(bug(" freeing the_host_buffer at %p\n", the_host_buffer)); |
623 |
|
free(the_host_buffer); |
628 |
|
free(the_buffer_copy); |
629 |
|
the_buffer_copy = NULL; |
630 |
|
} |
631 |
+ |
|
632 |
+ |
// Deinitialize VOSF |
633 |
+ |
video_vosf_exit(); |
634 |
|
} |
635 |
|
#endif |
636 |
|
} |
671 |
|
ADBSetRelMouseMode(mouse_grabbed); |
672 |
|
|
673 |
|
// Create surface |
674 |
< |
int depth = ((int)VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT ? 8 : screen_depth); |
674 |
> |
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); |
675 |
|
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL) |
676 |
|
return; |
677 |
|
|
680 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
681 |
|
the_host_buffer = (uint8 *)s->pixels; |
682 |
|
the_buffer_size = page_extend((aligned_height + 2) * s->pitch); |
683 |
< |
the_buffer = (uint8 *)vm_acquire(the_buffer_size); |
683 |
> |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
684 |
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
685 |
|
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
686 |
|
|
704 |
|
// Allocate memory for frame buffer |
705 |
|
the_buffer_size = (aligned_height + 2) * s->pitch; |
706 |
|
the_buffer_copy = (uint8 *)calloc(1, the_buffer_size); |
707 |
< |
the_buffer = (uint8 *)calloc(1, the_buffer_size); |
707 |
> |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
708 |
|
D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy)); |
709 |
|
} |
710 |
|
|
729 |
|
visualFormat.Rmask = f->Rmask; |
730 |
|
visualFormat.Gmask = f->Gmask; |
731 |
|
visualFormat.Bmask = f->Bmask; |
732 |
< |
Screen_blitter_init(visualFormat, true, sdl_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
732 |
> |
Screen_blitter_init(visualFormat, true, mac_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
733 |
|
|
734 |
|
// Load gray ramp to 8->16/32 expand map |
735 |
|
if (!IsDirectMode(mode)) |
796 |
|
ADBMouseMoved(x, y); |
797 |
|
} |
798 |
|
|
799 |
+ |
|
800 |
+ |
/* |
801 |
+ |
* Full-screen display driver |
802 |
+ |
*/ |
803 |
+ |
|
804 |
+ |
// Open display |
805 |
+ |
driver_fullscreen::driver_fullscreen(SDL_monitor_desc &m) |
806 |
+ |
: driver_base(m) |
807 |
+ |
{ |
808 |
+ |
int width = VIDEO_MODE_X, height = VIDEO_MODE_Y; |
809 |
+ |
int aligned_width = (width + 15) & ~15; |
810 |
+ |
int aligned_height = (height + 15) & ~15; |
811 |
+ |
|
812 |
+ |
// Set absolute mouse mode |
813 |
+ |
ADBSetRelMouseMode(false); |
814 |
+ |
|
815 |
+ |
// Create surface |
816 |
+ |
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); |
817 |
+ |
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE | SDL_FULLSCREEN)) == NULL) |
818 |
+ |
return; |
819 |
+ |
|
820 |
+ |
#ifdef ENABLE_VOSF |
821 |
+ |
use_vosf = true; |
822 |
+ |
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
823 |
+ |
the_host_buffer = (uint8 *)s->pixels; |
824 |
+ |
the_buffer_size = page_extend((aligned_height + 2) * s->pitch); |
825 |
+ |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
826 |
+ |
the_buffer_copy = (uint8 *)malloc(the_buffer_size); |
827 |
+ |
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer)); |
828 |
+ |
|
829 |
+ |
// Check whether we can initialize the VOSF subsystem and it's profitable |
830 |
+ |
if (!video_vosf_init(m)) { |
831 |
+ |
WarningAlert(STR_VOSF_INIT_ERR); |
832 |
+ |
use_vosf = false; |
833 |
+ |
} |
834 |
+ |
else if (!video_vosf_profitable()) { |
835 |
+ |
video_vosf_exit(); |
836 |
+ |
printf("VOSF acceleration is not profitable on this platform, disabling it\n"); |
837 |
+ |
use_vosf = false; |
838 |
+ |
} |
839 |
+ |
if (!use_vosf) { |
840 |
+ |
free(the_buffer_copy); |
841 |
+ |
vm_release(the_buffer, the_buffer_size); |
842 |
+ |
the_host_buffer = NULL; |
843 |
+ |
} |
844 |
+ |
#endif |
845 |
+ |
if (!use_vosf) { |
846 |
+ |
// Allocate memory for frame buffer |
847 |
+ |
the_buffer_size = (aligned_height + 2) * s->pitch; |
848 |
+ |
the_buffer_copy = (uint8 *)calloc(1, the_buffer_size); |
849 |
+ |
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size); |
850 |
+ |
D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy)); |
851 |
+ |
} |
852 |
+ |
|
853 |
+ |
// Hide cursor |
854 |
+ |
SDL_ShowCursor(0); |
855 |
+ |
|
856 |
+ |
// Init blitting routines |
857 |
+ |
SDL_PixelFormat *f = s->format; |
858 |
+ |
VisualFormat visualFormat; |
859 |
+ |
visualFormat.depth = depth; |
860 |
+ |
visualFormat.Rmask = f->Rmask; |
861 |
+ |
visualFormat.Gmask = f->Gmask; |
862 |
+ |
visualFormat.Bmask = f->Bmask; |
863 |
+ |
Screen_blitter_init(visualFormat, true, mac_depth_of_video_depth(VIDEO_MODE_DEPTH)); |
864 |
+ |
|
865 |
+ |
// Load gray ramp to 8->16/32 expand map |
866 |
+ |
if (!IsDirectMode(mode)) |
867 |
+ |
for (int i=0; i<256; i++) |
868 |
+ |
ExpandMap[i] = SDL_MapRGB(f, i, i, i); |
869 |
+ |
|
870 |
+ |
// Set frame buffer base |
871 |
+ |
set_mac_frame_buffer(monitor, VIDEO_MODE_DEPTH, true); |
872 |
+ |
|
873 |
+ |
// Everything went well |
874 |
+ |
init_ok = true; |
875 |
+ |
} |
876 |
+ |
|
877 |
+ |
// Close display |
878 |
+ |
driver_fullscreen::~driver_fullscreen() |
879 |
+ |
{ |
880 |
+ |
#ifdef ENABLE_VOSF |
881 |
+ |
if (use_vosf) |
882 |
+ |
the_host_buffer = NULL; // don't free() in driver_base dtor |
883 |
+ |
#endif |
884 |
+ |
if (s) |
885 |
+ |
SDL_FreeSurface(s); |
886 |
+ |
|
887 |
+ |
// Show cursor |
888 |
+ |
SDL_ShowCursor(1); |
889 |
+ |
} |
890 |
+ |
|
891 |
+ |
|
892 |
|
/* |
893 |
|
* Initialization |
894 |
|
*/ |
920 |
|
SDL_VideoDriverName(video_driver, sizeof(video_driver)); |
921 |
|
bool video_driver_found = false; |
922 |
|
char line[256]; |
923 |
+ |
int n_keys = 0; |
924 |
|
while (fgets(line, sizeof(line) - 1, f)) { |
925 |
|
// Read line |
926 |
|
int len = strlen(line); |
933 |
|
continue; |
934 |
|
|
935 |
|
if (video_driver_found) { |
936 |
< |
// Skip aliases |
936 |
> |
// Skip aliases as long as we have read keycodes yet |
937 |
> |
// Otherwise, it's another mapping and we have to stop |
938 |
|
static const char sdl_str[] = "sdl"; |
939 |
< |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0) |
939 |
> |
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0 && n_keys == 0) |
940 |
|
continue; |
941 |
|
|
942 |
|
// Read keycode |
943 |
|
int x_code, mac_code; |
944 |
|
if (sscanf(line, "%d %d", &x_code, &mac_code) == 2) |
945 |
< |
keycode_table[x_code & 0xff] = mac_code; |
945 |
> |
keycode_table[x_code & 0xff] = mac_code, n_keys++; |
946 |
|
else |
947 |
|
break; |
948 |
|
} else { |
967 |
|
WarningAlert(str); |
968 |
|
return; |
969 |
|
} |
970 |
+ |
|
971 |
+ |
D(bug("Using SDL/%s keycodes table, %d key mappings\n", video_driver, n_keys)); |
972 |
|
} |
973 |
|
} |
974 |
|
|
987 |
|
case DISPLAY_WINDOW: |
988 |
|
drv = new(std::nothrow) driver_window(*this); |
989 |
|
break; |
990 |
+ |
case DISPLAY_SCREEN: |
991 |
+ |
drv = new(std::nothrow) driver_fullscreen(*this); |
992 |
+ |
break; |
993 |
|
} |
994 |
|
if (drv == NULL) |
995 |
|
return false; |
1047 |
|
|
1048 |
|
// Get screen mode from preferences |
1049 |
|
const char *mode_str = NULL; |
896 |
– |
#ifndef SHEEPSHAVER |
1050 |
|
if (classic_mode) |
1051 |
|
mode_str = "win/512/342"; |
1052 |
|
else |
1053 |
|
mode_str = PrefsFindString("screen"); |
901 |
– |
#endif |
1054 |
|
|
1055 |
|
// Determine display type and default dimensions |
1056 |
|
int default_width, default_height; |
1066 |
|
if (mode_str) { |
1067 |
|
if (sscanf(mode_str, "win/%d/%d", &default_width, &default_height) == 2) |
1068 |
|
display_type = DISPLAY_WINDOW; |
1069 |
+ |
else if (sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2) |
1070 |
+ |
display_type = DISPLAY_SCREEN; |
1071 |
|
} |
1072 |
|
int max_width = 640, max_height = 480; |
1073 |
|
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); |
1074 |
|
if (modes && modes != (SDL_Rect **)-1) { |
1075 |
< |
max_width = modes[0]->w; |
1076 |
< |
max_height = modes[0]->h; |
1075 |
> |
// It turns out that on some implementations, and contrary to the documentation, |
1076 |
> |
// the returned list is not sorted from largest to smallest (e.g. Windows) |
1077 |
> |
for (int i = 0; modes[i] != NULL; i++) { |
1078 |
> |
const int w = modes[i]->w; |
1079 |
> |
const int h = modes[i]->h; |
1080 |
> |
if (w > max_width && h > max_height) { |
1081 |
> |
max_width = w; |
1082 |
> |
max_height = h; |
1083 |
> |
} |
1084 |
> |
} |
1085 |
|
if (default_width > max_width) |
1086 |
|
default_width = max_width; |
1087 |
|
if (default_height > max_height) |
1116 |
|
add_mode(display_type, 512, 342, 0x80, 64, VIDEO_DEPTH_1BIT); |
1117 |
|
else { |
1118 |
|
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++) { |
1119 |
< |
int bpp = (d <= VIDEO_DEPTH_8BIT ? 8 : sdl_depth_of_video_depth(d)); |
1119 |
> |
int bpp = sdl_depth_of_video_depth(d); |
1120 |
|
if (SDL_VideoModeOK(max_width, max_height, bpp, SDL_HWSURFACE)) |
1121 |
|
add_window_modes(video_depth(d)); |
1122 |
|
} |
1123 |
|
} |
1124 |
< |
} else |
1125 |
< |
add_mode(display_type, default_width, default_height, 0x80, TrivialBytesPerRow(default_width, (video_depth)default_depth), default_depth); |
1124 |
> |
} else if (display_type == DISPLAY_SCREEN) { |
1125 |
> |
struct { |
1126 |
> |
int w; |
1127 |
> |
int h; |
1128 |
> |
int resolution_id; |
1129 |
> |
} |
1130 |
> |
video_modes[] = { |
1131 |
> |
{ -1, -1, 0x80 }, |
1132 |
> |
{ 640, 480, 0x81 }, |
1133 |
> |
{ 800, 600, 0x82 }, |
1134 |
> |
{ 1024, 768, 0x83 }, |
1135 |
> |
{ 1152, 870, 0x84 }, |
1136 |
> |
{ 1280, 1024, 0x85 }, |
1137 |
> |
{ 1600, 1200, 0x86 }, |
1138 |
> |
{ 0, } |
1139 |
> |
}; |
1140 |
> |
video_modes[0].w = default_width; |
1141 |
> |
video_modes[0].h = default_height; |
1142 |
> |
|
1143 |
> |
for (int i = 0; video_modes[i].w != 0; i++) { |
1144 |
> |
const int w = video_modes[i].w; |
1145 |
> |
const int h = video_modes[i].h; |
1146 |
> |
if (i > 0 && (w >= default_width || h >= default_height)) |
1147 |
> |
continue; |
1148 |
> |
#ifdef ENABLE_VOSF |
1149 |
> |
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++) { |
1150 |
> |
int bpp = sdl_depth_of_video_depth(d); |
1151 |
> |
if (SDL_VideoModeOK(w, h, bpp, SDL_HWSURFACE | SDL_FULLSCREEN)) |
1152 |
> |
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)d), d); |
1153 |
> |
} |
1154 |
> |
#else |
1155 |
> |
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)default_depth), default_depth); |
1156 |
> |
#endif |
1157 |
> |
} |
1158 |
> |
} |
1159 |
> |
|
1160 |
|
if (VideoModes.empty()) { |
1161 |
|
ErrorAlert(STR_NO_XVISUAL_ERR); |
1162 |
|
return false; |
1238 |
|
UNLOCK_FRAME_BUFFER; |
1239 |
|
D(bug(" frame buffer unlocked\n")); |
1240 |
|
|
1045 |
– |
#ifdef ENABLE_VOSF |
1046 |
– |
if (use_vosf) { |
1047 |
– |
// Deinitialize VOSF |
1048 |
– |
video_vosf_exit(); |
1049 |
– |
} |
1050 |
– |
#endif |
1051 |
– |
|
1241 |
|
// Close display |
1242 |
|
delete drv; |
1243 |
|
drv = NULL; |
1396 |
|
csSave->saveData = ReadMacInt32(ParamPtr + csData); |
1397 |
|
csSave->savePage = ReadMacInt16(ParamPtr + csPage); |
1398 |
|
|
1399 |
< |
// Disable interrupts |
1399 |
> |
// Disable interrupts and pause redraw thread |
1400 |
|
DisableInterrupt(); |
1401 |
+ |
thread_stop_ack = false; |
1402 |
+ |
thread_stop_req = true; |
1403 |
+ |
while (!thread_stop_ack) ; |
1404 |
|
|
1405 |
|
cur_mode = i; |
1406 |
|
monitor_desc *monitor = VideoMonitors[0]; |
1411 |
|
csSave->saveData=VModes[cur_mode].viAppleID;/* First mode ... */ |
1412 |
|
csSave->saveMode=VModes[cur_mode].viAppleMode; |
1413 |
|
|
1414 |
< |
// Enable interrupts |
1414 |
> |
// Enable interrupts and resume redraw thread |
1415 |
> |
thread_stop_req = false; |
1416 |
|
EnableInterrupt(); |
1417 |
|
return noErr; |
1418 |
|
} |
1528 |
|
|
1529 |
|
case SDLK_1: case SDLK_EXCLAIM: return 0x12; |
1530 |
|
case SDLK_2: case SDLK_AT: return 0x13; |
1531 |
< |
// case SDLK_3: case SDLK_numbersign: return 0x14; |
1531 |
> |
case SDLK_3: case SDLK_HASH: return 0x14; |
1532 |
|
case SDLK_4: case SDLK_DOLLAR: return 0x15; |
1533 |
< |
// case SDLK_5: case SDLK_percent: return 0x17; |
1533 |
> |
case SDLK_5: return 0x17; |
1534 |
|
case SDLK_6: return 0x16; |
1535 |
|
case SDLK_7: return 0x1a; |
1536 |
|
case SDLK_8: return 0x1c; |
1537 |
|
case SDLK_9: return 0x19; |
1538 |
|
case SDLK_0: return 0x1d; |
1539 |
|
|
1540 |
< |
// case SDLK_BACKQUOTE: case SDLK_asciitilde: return 0x0a; |
1540 |
> |
case SDLK_BACKQUOTE: return 0x0a; |
1541 |
|
case SDLK_MINUS: case SDLK_UNDERSCORE: return 0x1b; |
1542 |
|
case SDLK_EQUALS: case SDLK_PLUS: return 0x18; |
1543 |
< |
// case SDLK_bracketleft: case SDLK_braceleft: return 0x21; |
1544 |
< |
// case SDLK_bracketright: case SDLK_braceright: return 0x1e; |
1545 |
< |
// case SDLK_BACKSLASH: case SDLK_bar: return 0x2a; |
1543 |
> |
case SDLK_LEFTBRACKET: return 0x21; |
1544 |
> |
case SDLK_RIGHTBRACKET: return 0x1e; |
1545 |
> |
case SDLK_BACKSLASH: return 0x2a; |
1546 |
|
case SDLK_SEMICOLON: case SDLK_COLON: return 0x29; |
1547 |
< |
// case SDLK_apostrophe: case SDLK_QUOTEDBL: return 0x27; |
1547 |
> |
case SDLK_QUOTE: case SDLK_QUOTEDBL: return 0x27; |
1548 |
|
case SDLK_COMMA: case SDLK_LESS: return 0x2b; |
1549 |
|
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f; |
1550 |
|
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c; |
1576 |
|
case SDLK_LMETA: return 0x3a; |
1577 |
|
case SDLK_RMETA: return 0x3a; |
1578 |
|
#endif |
1579 |
+ |
case SDLK_LSUPER: return 0x3a; // "Windows" key |
1580 |
+ |
case SDLK_RSUPER: return 0x3a; |
1581 |
|
case SDLK_MENU: return 0x32; |
1582 |
|
case SDLK_CAPSLOCK: return 0x39; |
1583 |
|
case SDLK_NUMLOCK: return 0x47; |
1971 |
|
tick_counter = 0; |
1972 |
|
if (mainBuffer.dirty) { |
1973 |
|
LOCK_VOSF; |
1974 |
< |
update_display_dga_vosf(); |
1974 |
> |
update_display_dga_vosf(static_cast<driver_fullscreen *>(drv)); |
1975 |
|
UNLOCK_VOSF; |
1976 |
|
} |
1977 |
|
} |
2055 |
|
next = GetTicks_usec(); |
2056 |
|
ticks++; |
2057 |
|
|
2058 |
+ |
#ifdef SHEEPSHAVER |
2059 |
+ |
// Pause if requested (during video mode switches) |
2060 |
+ |
if (thread_stop_req) { |
2061 |
+ |
thread_stop_ack = true; |
2062 |
+ |
continue; |
2063 |
+ |
} |
2064 |
+ |
#endif |
2065 |
+ |
|
2066 |
|
// Handle SDL events |
2067 |
|
handle_events(); |
2068 |
|
|