2004-06-23 13:47:20 +00:00
|
|
|
/*
|
|
|
|
* video_sdl.cpp - Video/graphics emulation, SDL specific stuff
|
|
|
|
*
|
2008-01-01 09:40:36 +00:00
|
|
|
* Basilisk II (C) 1997-2008 Christian Bauer
|
2004-06-23 13:47:20 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTES:
|
|
|
|
* The Ctrl key works like a qualifier for special actions:
|
2005-06-06 21:20:28 +00:00
|
|
|
* Ctrl-Tab = suspend DGA mode (TODO)
|
2004-06-23 13:47:20 +00:00
|
|
|
* Ctrl-Esc = emergency quit
|
|
|
|
* Ctrl-F1 = mount floppy
|
|
|
|
* Ctrl-F5 = grab mouse (in windowed mode)
|
|
|
|
*
|
|
|
|
* FIXMEs and TODOs:
|
2006-05-14 14:11:46 +00:00
|
|
|
* - Windows requires an extra mouse event to update the actual cursor image?
|
2005-06-06 21:20:28 +00:00
|
|
|
* - Ctr-Tab for suspend/resume but how? SDL does not support that for non-Linux
|
2004-06-23 13:47:20 +00:00
|
|
|
* - Ctrl-Fn doesn't generate SDL_KEYDOWN events (SDL bug?)
|
|
|
|
* - Mouse acceleration, there is no API in SDL yet for that
|
|
|
|
* - Gamma tables support is likely to be broken here
|
2004-06-23 22:37:33 +00:00
|
|
|
* - Events processing is bound to the general emulation thread as SDL requires
|
|
|
|
* to PumpEvents() within the same thread as the one that called SetVideoMode().
|
|
|
|
* Besides, there can't seem to be a way to call SetVideoMode() from a child thread.
|
2004-06-24 22:38:42 +00:00
|
|
|
* - Backport hw cursor acceleration to Basilisk II?
|
2005-06-06 21:20:28 +00:00
|
|
|
* - Factor out code
|
2004-06-23 13:47:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysdeps.h"
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
#include <SDL_mutex.h>
|
|
|
|
#include <SDL_thread.h>
|
|
|
|
#include <errno.h>
|
2004-06-24 15:25:57 +00:00
|
|
|
#include <vector>
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2006-05-14 13:49:53 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include <malloc.h> /* alloca() */
|
|
|
|
#endif
|
|
|
|
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#include <cpu_emulation.h>
|
2004-06-23 13:47:20 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "adb.h"
|
|
|
|
#include "macos_util.h"
|
|
|
|
#include "prefs.h"
|
|
|
|
#include "user_strings.h"
|
|
|
|
#include "video.h"
|
2004-06-24 15:25:57 +00:00
|
|
|
#include "video_defs.h"
|
2004-06-23 13:47:20 +00:00
|
|
|
#include "video_blit.h"
|
2004-11-28 19:31:11 +00:00
|
|
|
#include "vm_alloc.h"
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2011-12-29 07:39:56 +00:00
|
|
|
#define DEBUG 0
|
|
|
|
#include "debug.h"
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Supported video modes
|
2004-06-24 15:25:57 +00:00
|
|
|
using std::vector;
|
|
|
|
static vector<VIDEO_MODE> VideoModes;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Display types
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
2004-06-23 13:47:20 +00:00
|
|
|
enum {
|
2004-06-24 15:25:57 +00:00
|
|
|
DISPLAY_WINDOW = DIS_WINDOW, // windowed display
|
|
|
|
DISPLAY_SCREEN = DIS_SCREEN // fullscreen display
|
2004-06-23 13:47:20 +00:00
|
|
|
};
|
2004-06-24 15:25:57 +00:00
|
|
|
extern int display_type; // See enum above
|
|
|
|
#else
|
|
|
|
enum {
|
|
|
|
DISPLAY_WINDOW, // windowed display
|
|
|
|
DISPLAY_SCREEN // fullscreen display
|
|
|
|
};
|
|
|
|
static int display_type = DISPLAY_WINDOW; // See enum above
|
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Constants
|
2005-03-17 00:19:39 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes";
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#elif __MACOSX__
|
|
|
|
const char KEYCODE_FILE_NAME[] = "BasiliskII_keycodes";
|
2005-03-17 00:19:39 +00:00
|
|
|
#else
|
2004-06-23 13:47:20 +00:00
|
|
|
const char KEYCODE_FILE_NAME[] = DATADIR "/keycodes";
|
2005-03-17 00:19:39 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Global variables
|
2015-08-06 08:12:43 +00:00
|
|
|
static uint32 frame_skip; // Prefs items
|
2004-06-23 13:47:20 +00:00
|
|
|
static int16 mouse_wheel_mode;
|
|
|
|
static int16 mouse_wheel_lines;
|
|
|
|
|
|
|
|
static uint8 *the_buffer = NULL; // Mac frame buffer (where MacOS draws into)
|
|
|
|
static uint8 *the_buffer_copy = NULL; // Copy of Mac frame buffer (for refreshed modes)
|
|
|
|
static uint32 the_buffer_size; // Size of allocated the_buffer
|
|
|
|
|
|
|
|
static bool redraw_thread_active = false; // Flag: Redraw thread installed
|
2005-06-14 22:35:42 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2004-06-23 13:47:20 +00:00
|
|
|
static volatile bool redraw_thread_cancel; // Flag: Cancel Redraw thread
|
|
|
|
static SDL_Thread *redraw_thread = NULL; // Redraw thread
|
2004-11-28 19:31:11 +00:00
|
|
|
static volatile bool thread_stop_req = false;
|
|
|
|
static volatile bool thread_stop_ack = false; // Acknowledge for thread_stop_req
|
2005-06-14 22:35:42 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
2004-06-26 15:22:02 +00:00
|
|
|
static bool use_vosf = false; // Flag: VOSF enabled
|
2004-06-23 13:47:20 +00:00
|
|
|
#else
|
|
|
|
static const bool use_vosf = false; // VOSF not possible
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static bool ctrl_down = false; // Flag: Ctrl key pressed
|
|
|
|
static bool caps_on = false; // Flag: Caps Lock on
|
|
|
|
static bool quit_full_screen = false; // Flag: DGA close requested from redraw thread
|
|
|
|
static bool emerg_quit = false; // Flag: Ctrl-Esc pressed, emergency quit requested from MacOS thread
|
|
|
|
static bool emul_suspended = false; // Flag: Emulator suspended
|
|
|
|
|
|
|
|
static bool classic_mode = false; // Flag: Classic Mac video mode
|
|
|
|
|
|
|
|
static bool use_keycodes = false; // Flag: Use keycodes rather than keysyms
|
|
|
|
static int keycode_table[256]; // X keycode -> Mac keycode translation table
|
|
|
|
|
|
|
|
// SDL variables
|
2017-07-24 00:49:29 +00:00
|
|
|
SDL_Window * sdl_window = NULL; // Wraps an OS-native window
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static SDL_Surface * inner_sdl_surface = NULL; // Surface in guest-OS display format
|
|
|
|
static SDL_Surface * outer_sdl_surface = NULL; // Surface in host-OS display format
|
|
|
|
static SDL_Renderer * sdl_renderer = NULL; // Handle to SDL2 renderer
|
|
|
|
static SDL_Texture * sdl_texture = NULL; // Handle to a GPU texture, with which to draw outer_sdl_surface to
|
2004-06-23 13:47:20 +00:00
|
|
|
static int screen_depth; // Depth of current screen
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
//static SDL_Cursor *sdl_cursor; // Copy of Mac cursor
|
|
|
|
static SDL_Palette *sdl_palette = NULL; // Color palette to be used as CLUT and gamma table
|
2004-06-23 13:47:20 +00:00
|
|
|
static bool sdl_palette_changed = false; // Flag: Palette changed, redraw thread must set new colors
|
2013-02-21 12:54:45 +00:00
|
|
|
static bool toggle_fullscreen = false;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2013-04-07 22:21:10 +00:00
|
|
|
static bool mouse_grabbed = false;
|
|
|
|
|
2005-11-29 23:20:31 +00:00
|
|
|
// Mutex to protect SDL events
|
|
|
|
static SDL_mutex *sdl_events_lock = NULL;
|
|
|
|
#define LOCK_EVENTS SDL_LockMutex(sdl_events_lock)
|
|
|
|
#define UNLOCK_EVENTS SDL_UnlockMutex(sdl_events_lock)
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Mutex to protect palette
|
|
|
|
static SDL_mutex *sdl_palette_lock = NULL;
|
|
|
|
#define LOCK_PALETTE SDL_LockMutex(sdl_palette_lock)
|
|
|
|
#define UNLOCK_PALETTE SDL_UnlockMutex(sdl_palette_lock)
|
|
|
|
|
|
|
|
// Mutex to protect frame buffer
|
|
|
|
static SDL_mutex *frame_buffer_lock = NULL;
|
|
|
|
#define LOCK_FRAME_BUFFER SDL_LockMutex(frame_buffer_lock)
|
|
|
|
#define UNLOCK_FRAME_BUFFER SDL_UnlockMutex(frame_buffer_lock)
|
|
|
|
|
|
|
|
// Video refresh function
|
|
|
|
static void VideoRefreshInit(void);
|
|
|
|
static void (*video_refresh)(void);
|
|
|
|
|
|
|
|
|
|
|
|
// Prototypes
|
|
|
|
static int redraw_func(void *arg);
|
2017-07-24 00:49:29 +00:00
|
|
|
static int update_sdl_video();
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// From sys_unix.cpp
|
|
|
|
extern void SysMountFirstFloppy(void);
|
|
|
|
|
|
|
|
|
2005-11-21 23:38:46 +00:00
|
|
|
/*
|
|
|
|
* SDL surface locking glue
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE) do { \
|
2017-07-24 00:49:29 +00:00
|
|
|
if (sdl_window && SDL_GetWindowFlags(sdl_window) & (SDL_WINDOW_FULLSCREEN)) \
|
2005-11-21 23:38:46 +00:00
|
|
|
the_host_buffer = (uint8 *)(SURFACE)->pixels; \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SDL_VIDEO_LOCK_SURFACE(SURFACE) do { \
|
|
|
|
if (SDL_MUSTLOCK(SURFACE)) { \
|
|
|
|
SDL_LockSurface(SURFACE); \
|
|
|
|
SDL_VIDEO_LOCK_VOSF_SURFACE(SURFACE); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SDL_VIDEO_UNLOCK_SURFACE(SURFACE) do { \
|
|
|
|
if (SDL_MUSTLOCK(SURFACE)) \
|
|
|
|
SDL_UnlockSurface(SURFACE); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
2004-11-28 19:31:11 +00:00
|
|
|
/*
|
|
|
|
* Framebuffer allocation routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void *vm_acquire_framebuffer(uint32 size)
|
|
|
|
{
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#if __MACOSX__
|
|
|
|
return calloc(1, size);
|
|
|
|
#else
|
2007-06-14 14:45:54 +00:00
|
|
|
// always try to reallocate framebuffer at the same address
|
|
|
|
static void *fb = VM_MAP_FAILED;
|
|
|
|
if (fb != VM_MAP_FAILED) {
|
|
|
|
if (vm_acquire_fixed(fb, size) < 0) {
|
|
|
|
#ifndef SHEEPSHAVER
|
|
|
|
printf("FATAL: Could not reallocate framebuffer at previous address\n");
|
|
|
|
#endif
|
|
|
|
fb = VM_MAP_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fb == VM_MAP_FAILED)
|
|
|
|
fb = vm_acquire(size, VM_MAP_DEFAULT | VM_MAP_32BIT);
|
|
|
|
return fb;
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#endif
|
2004-11-28 19:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void vm_release_framebuffer(void *fb, uint32 size)
|
|
|
|
{
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#if __MACOSX__
|
|
|
|
free(fb);
|
|
|
|
#else
|
2004-11-28 19:31:11 +00:00
|
|
|
vm_release(fb, size);
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
#endif
|
2004-11-28 19:31:11 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 11:38:25 +00:00
|
|
|
static inline int get_customized_color_depth(int default_depth)
|
|
|
|
{
|
|
|
|
int display_color_depth = PrefsFindInt32("displaycolordepth");
|
|
|
|
|
|
|
|
D(bug("Get displaycolordepth %d\n", display_color_depth));
|
|
|
|
|
|
|
|
if(0 == display_color_depth)
|
|
|
|
return default_depth;
|
|
|
|
else{
|
|
|
|
switch (display_color_depth) {
|
|
|
|
case 8:
|
|
|
|
return VIDEO_DEPTH_8BIT;
|
|
|
|
case 15: case 16:
|
|
|
|
return VIDEO_DEPTH_16BIT;
|
|
|
|
case 24: case 32:
|
|
|
|
return VIDEO_DEPTH_32BIT;
|
|
|
|
default:
|
|
|
|
return default_depth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-28 19:31:11 +00:00
|
|
|
|
2006-03-28 07:01:19 +00:00
|
|
|
/*
|
|
|
|
* Windows message handler
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <dbt.h>
|
|
|
|
static WNDPROC sdl_window_proc = NULL; // Window proc used by SDL
|
|
|
|
|
|
|
|
extern void SysMediaArrived(void);
|
|
|
|
extern void SysMediaRemoved(void);
|
|
|
|
extern HWND GetMainWindowHandle(void);
|
|
|
|
|
|
|
|
static LRESULT CALLBACK windows_message_handler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
|
|
|
case WM_DEVICECHANGE:
|
|
|
|
if (wParam == DBT_DEVICEREMOVECOMPLETE) {
|
|
|
|
DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam;
|
|
|
|
if (p->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
|
|
|
SysMediaRemoved();
|
|
|
|
}
|
|
|
|
else if (wParam == DBT_DEVICEARRIVAL) {
|
|
|
|
DEV_BROADCAST_HDR *p = (DEV_BROADCAST_HDR *)lParam;
|
|
|
|
if (p->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
|
|
|
SysMediaArrived();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (sdl_window_proc)
|
|
|
|
return CallWindowProc(sdl_window_proc, hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
/*
|
|
|
|
* SheepShaver glue
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
// Color depth modes type
|
|
|
|
typedef int video_depth;
|
|
|
|
|
|
|
|
// 1, 2, 4 and 8 bit depths use a color palette
|
|
|
|
static inline bool IsDirectMode(VIDEO_MODE const & mode)
|
|
|
|
{
|
|
|
|
return IsDirectMode(mode.viAppleMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Abstract base class representing one (possibly virtual) monitor
|
|
|
|
// ("monitor" = rectangular display with a contiguous frame buffer)
|
|
|
|
class monitor_desc {
|
|
|
|
public:
|
|
|
|
monitor_desc(const vector<VIDEO_MODE> &available_modes, video_depth default_depth, uint32 default_id) {}
|
|
|
|
virtual ~monitor_desc() {}
|
|
|
|
|
|
|
|
// Get current Mac frame buffer base address
|
|
|
|
uint32 get_mac_frame_base(void) const {return screen_base;}
|
|
|
|
|
|
|
|
// Set Mac frame buffer base address (called from switch_to_mode())
|
|
|
|
void set_mac_frame_base(uint32 base) {screen_base = base;}
|
|
|
|
|
|
|
|
// Get current video mode
|
|
|
|
const VIDEO_MODE &get_current_mode(void) const {return VModes[cur_mode];}
|
|
|
|
|
|
|
|
// Called by the video driver to switch the video mode on this display
|
|
|
|
// (must call set_mac_frame_base())
|
|
|
|
virtual void switch_to_current_mode(void) = 0;
|
|
|
|
|
|
|
|
// Called by the video driver to set the color palette (in indexed modes)
|
|
|
|
// or the gamma table (in direct modes)
|
|
|
|
virtual void set_palette(uint8 *pal, int num) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Vector of pointers to available monitor descriptions, filled by VideoInit()
|
|
|
|
static vector<monitor_desc *> VideoMonitors;
|
|
|
|
|
|
|
|
// Find Apple mode matching best specified dimensions
|
|
|
|
static int find_apple_resolution(int xsize, int ysize)
|
|
|
|
{
|
2006-05-09 21:41:02 +00:00
|
|
|
if (xsize == 640 && ysize == 480)
|
|
|
|
return APPLE_640x480;
|
|
|
|
if (xsize == 800 && ysize == 600)
|
|
|
|
return APPLE_800x600;
|
|
|
|
if (xsize == 1024 && ysize == 768)
|
|
|
|
return APPLE_1024x768;
|
|
|
|
if (xsize == 1152 && ysize == 768)
|
|
|
|
return APPLE_1152x768;
|
|
|
|
if (xsize == 1152 && ysize == 900)
|
|
|
|
return APPLE_1152x900;
|
|
|
|
if (xsize == 1280 && ysize == 1024)
|
|
|
|
return APPLE_1280x1024;
|
|
|
|
if (xsize == 1600 && ysize == 1200)
|
|
|
|
return APPLE_1600x1200;
|
|
|
|
return APPLE_CUSTOM;
|
2004-06-24 15:25:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display error alert
|
|
|
|
static void ErrorAlert(int error)
|
|
|
|
{
|
|
|
|
ErrorAlert(GetString(error));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
/*
|
|
|
|
* monitor_desc subclass for SDL display
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SDL_monitor_desc : public monitor_desc {
|
|
|
|
public:
|
2004-06-24 15:25:57 +00:00
|
|
|
SDL_monitor_desc(const vector<VIDEO_MODE> &available_modes, video_depth default_depth, uint32 default_id) : monitor_desc(available_modes, default_depth, default_id) {}
|
2004-06-23 13:47:20 +00:00
|
|
|
~SDL_monitor_desc() {}
|
|
|
|
|
|
|
|
virtual void switch_to_current_mode(void);
|
|
|
|
virtual void set_palette(uint8 *pal, int num);
|
|
|
|
|
|
|
|
bool video_open(void);
|
|
|
|
void video_close(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Utility functions
|
|
|
|
*/
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
// Find palette size for given color depth
|
|
|
|
static int palette_size(int mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case VIDEO_DEPTH_1BIT: return 2;
|
|
|
|
case VIDEO_DEPTH_2BIT: return 4;
|
|
|
|
case VIDEO_DEPTH_4BIT: return 16;
|
|
|
|
case VIDEO_DEPTH_8BIT: return 256;
|
|
|
|
case VIDEO_DEPTH_16BIT: return 32;
|
|
|
|
case VIDEO_DEPTH_32BIT: return 256;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Map video_mode depth ID to numerical depth value
|
2004-07-27 21:40:52 +00:00
|
|
|
static int mac_depth_of_video_depth(int video_depth)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
int depth = -1;
|
|
|
|
switch (video_depth) {
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_1BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 1;
|
|
|
|
break;
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_2BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 2;
|
|
|
|
break;
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_4BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 4;
|
|
|
|
break;
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_8BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 8;
|
|
|
|
break;
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_16BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 16;
|
|
|
|
break;
|
2004-06-24 15:25:57 +00:00
|
|
|
case VIDEO_DEPTH_32BIT:
|
2004-06-23 13:47:20 +00:00
|
|
|
depth = 32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
2004-07-27 21:40:52 +00:00
|
|
|
// Map video_mode depth ID to SDL screen depth
|
|
|
|
static int sdl_depth_of_video_depth(int video_depth)
|
|
|
|
{
|
|
|
|
return (video_depth <= VIDEO_DEPTH_8BIT) ? 8 : mac_depth_of_video_depth(video_depth);
|
|
|
|
}
|
|
|
|
|
2006-05-09 21:41:02 +00:00
|
|
|
// Get screen dimensions
|
|
|
|
static void sdl_display_dimensions(int &width, int &height)
|
|
|
|
{
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
SDL_DisplayMode desktop_mode;
|
|
|
|
const int display_index = 0; // TODO: try supporting multiple displays
|
|
|
|
if (SDL_GetDesktopDisplayMode(display_index, &desktop_mode) != 0) {
|
|
|
|
// TODO: report a warning, here?
|
|
|
|
width = height = 0;
|
|
|
|
return;
|
2006-05-09 21:41:02 +00:00
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
width = desktop_mode.w;
|
|
|
|
height = desktop_mode.h;
|
2006-05-09 21:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdl_display_width(void)
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
sdl_display_dimensions(width, height);
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sdl_display_height(void)
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
sdl_display_dimensions(width, height);
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2004-06-24 21:46:55 +00:00
|
|
|
// Check wether specified mode is available
|
2006-05-09 21:41:02 +00:00
|
|
|
static bool has_mode(int type, int width, int height, int depth)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
2006-05-09 21:41:02 +00:00
|
|
|
// Filter out Classic resolutions
|
2004-06-24 15:25:57 +00:00
|
|
|
if (width == 512 && height == 384)
|
2004-06-24 21:46:55 +00:00
|
|
|
return false;
|
2006-05-09 21:41:02 +00:00
|
|
|
#endif
|
2004-06-24 21:46:55 +00:00
|
|
|
|
2006-05-09 21:41:02 +00:00
|
|
|
// Filter out out-of-bounds resolutions
|
|
|
|
if (width > sdl_display_width() || height > sdl_display_height())
|
|
|
|
return false;
|
2005-06-06 21:20:28 +00:00
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
// Whatever size it is, beyond what we've checked, we'll scale to/from as appropriate.
|
|
|
|
return true;
|
2004-06-24 21:46:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add mode to list of supported modes
|
|
|
|
static void add_mode(int type, int width, int height, int resolution_id, int bytes_per_row, int depth)
|
|
|
|
{
|
|
|
|
// Filter out unsupported modes
|
2006-05-09 21:41:02 +00:00
|
|
|
if (!has_mode(type, width, height, depth))
|
2004-06-24 15:25:57 +00:00
|
|
|
return;
|
|
|
|
|
2004-06-24 21:46:55 +00:00
|
|
|
// Fill in VideoMode entry
|
|
|
|
VIDEO_MODE mode;
|
|
|
|
#ifdef SHEEPSHAVER
|
2006-05-09 21:41:02 +00:00
|
|
|
resolution_id = find_apple_resolution(width, height);
|
2004-06-24 15:25:57 +00:00
|
|
|
mode.viType = type;
|
|
|
|
#endif
|
|
|
|
VIDEO_MODE_X = width;
|
|
|
|
VIDEO_MODE_Y = height;
|
|
|
|
VIDEO_MODE_RESOLUTION = resolution_id;
|
|
|
|
VIDEO_MODE_ROW_BYTES = bytes_per_row;
|
2004-06-29 21:50:23 +00:00
|
|
|
VIDEO_MODE_DEPTH = (video_depth)depth;
|
2004-06-23 13:47:20 +00:00
|
|
|
VideoModes.push_back(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set Mac frame layout and base address (uses the_buffer/MacFrameBaseMac)
|
2004-06-24 15:25:57 +00:00
|
|
|
static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth, bool native_byte_order)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING
|
|
|
|
int layout = FLAYOUT_DIRECT;
|
2004-06-24 15:25:57 +00:00
|
|
|
if (depth == VIDEO_DEPTH_16BIT)
|
2004-06-23 13:47:20 +00:00
|
|
|
layout = (screen_depth == 15) ? FLAYOUT_HOST_555 : FLAYOUT_HOST_565;
|
2004-06-24 15:25:57 +00:00
|
|
|
else if (depth == VIDEO_DEPTH_32BIT)
|
2004-06-23 13:47:20 +00:00
|
|
|
layout = (screen_depth == 24) ? FLAYOUT_HOST_888 : FLAYOUT_DIRECT;
|
|
|
|
if (native_byte_order)
|
|
|
|
MacFrameLayout = layout;
|
|
|
|
else
|
|
|
|
MacFrameLayout = FLAYOUT_DIRECT;
|
|
|
|
monitor.set_mac_frame_base(MacFrameBaseMac);
|
|
|
|
|
|
|
|
// Set variables used by UAE memory banking
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE &mode = monitor.get_current_mode();
|
2004-06-23 13:47:20 +00:00
|
|
|
MacFrameBaseHost = the_buffer;
|
2004-06-24 15:25:57 +00:00
|
|
|
MacFrameSize = VIDEO_MODE_ROW_BYTES * VIDEO_MODE_Y;
|
2004-06-23 13:47:20 +00:00
|
|
|
InitFrameBufferMapping();
|
|
|
|
#else
|
|
|
|
monitor.set_mac_frame_base(Host2MacAddr(the_buffer));
|
|
|
|
#endif
|
|
|
|
D(bug("monitor.mac_frame_base = %08x\n", monitor.get_mac_frame_base()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set window name and class
|
|
|
|
static void set_window_name(int name)
|
|
|
|
{
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
if (!sdl_window) {
|
|
|
|
return;
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
const char *str = GetString(name);
|
|
|
|
SDL_SetWindowTitle(sdl_window, str);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set mouse grab mode
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static void set_grab_mode(bool grab)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
if (!sdl_window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SDL_SetWindowGrab(sdl_window, grab ? SDL_TRUE : SDL_FALSE);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
2006-05-09 21:41:02 +00:00
|
|
|
// Migrate preferences items (XXX to be handled in MigratePrefs())
|
|
|
|
static void migrate_screen_prefs(void)
|
|
|
|
{
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
// Look-up priorities are: "screen", "screenmodes", "windowmodes".
|
|
|
|
if (PrefsFindString("screen"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint32 window_modes = PrefsFindInt32("windowmodes");
|
|
|
|
uint32 screen_modes = PrefsFindInt32("screenmodes");
|
|
|
|
int width = 0, height = 0;
|
|
|
|
if (screen_modes) {
|
|
|
|
static const struct {
|
|
|
|
int id;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
}
|
|
|
|
modes[] = {
|
|
|
|
{ 1, 640, 480 },
|
|
|
|
{ 2, 800, 600 },
|
|
|
|
{ 4, 1024, 768 },
|
|
|
|
{ 64, 1152, 768 },
|
|
|
|
{ 8, 1152, 900 },
|
|
|
|
{ 16, 1280, 1024 },
|
|
|
|
{ 32, 1600, 1200 },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
for (int i = 0; modes[i].id != 0; i++) {
|
|
|
|
if (screen_modes & modes[i].id) {
|
|
|
|
if (width < modes[i].width && height < modes[i].height) {
|
|
|
|
width = modes[i].width;
|
|
|
|
height = modes[i].height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (window_modes & 1)
|
|
|
|
width = 640, height = 480;
|
|
|
|
if (window_modes & 2)
|
|
|
|
width = 800, height = 600;
|
|
|
|
}
|
|
|
|
if (width && height) {
|
|
|
|
char str[32];
|
|
|
|
sprintf(str, "%s/%d/%d", screen_modes ? "dga" : "win", width, height);
|
|
|
|
PrefsReplaceString("screen", str);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Display "driver" classes
|
|
|
|
*/
|
|
|
|
|
|
|
|
class driver_base {
|
|
|
|
public:
|
|
|
|
driver_base(SDL_monitor_desc &m);
|
2013-04-22 09:26:44 +00:00
|
|
|
~driver_base();
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2013-04-24 06:07:20 +00:00
|
|
|
void init(); // One-time init
|
|
|
|
void set_video_mode(int flags);
|
|
|
|
void adapt_to_video_mode();
|
|
|
|
|
2013-04-24 05:48:00 +00:00
|
|
|
void update_palette(void);
|
|
|
|
void suspend(void) {}
|
|
|
|
void resume(void) {}
|
2013-04-24 05:27:57 +00:00
|
|
|
void toggle_mouse_grab(void);
|
|
|
|
void mouse_moved(int x, int y) { ADBMouseMoved(x, y); }
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
void disable_mouse_accel(void);
|
|
|
|
void restore_mouse_accel(void);
|
|
|
|
|
2013-04-24 05:27:57 +00:00
|
|
|
void grab_mouse(void);
|
|
|
|
void ungrab_mouse(void);
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SDL_monitor_desc &monitor; // Associated video monitor
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE &mode; // Video mode handled by the driver
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
bool init_ok; // Initialization succeeded (we can't use exceptions because of -fomit-frame-pointer)
|
|
|
|
SDL_Surface *s; // The surface we draw into
|
|
|
|
};
|
|
|
|
|
2012-01-14 15:45:18 +00:00
|
|
|
#ifdef ENABLE_VOSF
|
2013-04-22 09:26:44 +00:00
|
|
|
static void update_display_window_vosf(driver_base *drv);
|
2012-01-14 15:45:18 +00:00
|
|
|
#endif
|
2009-03-03 08:14:53 +00:00
|
|
|
static void update_display_static(driver_base *drv);
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
static driver_base *drv = NULL; // Pointer to currently used driver object
|
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
# include "video_vosf.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
driver_base::driver_base(SDL_monitor_desc &m)
|
|
|
|
: monitor(m), mode(m.get_current_mode()), init_ok(false), s(NULL)
|
|
|
|
{
|
|
|
|
the_buffer = NULL;
|
|
|
|
the_buffer_copy = NULL;
|
|
|
|
}
|
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
static void delete_sdl_video_surfaces()
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
{
|
|
|
|
if (sdl_texture) {
|
|
|
|
SDL_DestroyTexture(sdl_texture);
|
|
|
|
sdl_texture = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inner_sdl_surface) {
|
|
|
|
if (inner_sdl_surface == outer_sdl_surface) {
|
|
|
|
outer_sdl_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_FreeSurface(inner_sdl_surface);
|
|
|
|
inner_sdl_surface = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outer_sdl_surface) {
|
|
|
|
SDL_FreeSurface(outer_sdl_surface);
|
|
|
|
outer_sdl_surface = NULL;
|
|
|
|
}
|
2017-07-23 19:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void delete_sdl_video_window()
|
|
|
|
{
|
|
|
|
if (sdl_renderer) {
|
|
|
|
SDL_DestroyRenderer(sdl_renderer);
|
|
|
|
sdl_renderer = NULL;
|
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
|
|
|
if (sdl_window) {
|
|
|
|
SDL_DestroyWindow(sdl_window);
|
|
|
|
sdl_window = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
static void shutdown_sdl_video()
|
|
|
|
{
|
|
|
|
delete_sdl_video_surfaces();
|
|
|
|
delete_sdl_video_window();
|
|
|
|
}
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static SDL_Surface * init_sdl_video(int width, int height, int bpp, Uint32 flags)
|
|
|
|
{
|
|
|
|
if (outer_sdl_surface) {
|
2017-07-23 19:22:00 +00:00
|
|
|
delete_sdl_video_surfaces();
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int window_width = width;
|
|
|
|
int window_height = height;
|
|
|
|
Uint32 window_flags = 0;
|
2017-07-23 19:22:00 +00:00
|
|
|
const int window_flags_to_monitor = SDL_WINDOW_FULLSCREEN;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
|
|
|
if (flags & SDL_WINDOW_FULLSCREEN) {
|
|
|
|
SDL_DisplayMode desktop_mode;
|
|
|
|
if (SDL_GetDesktopDisplayMode(0, &desktop_mode) != 0) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-07-23 00:40:31 +00:00
|
|
|
window_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
window_width = desktop_mode.w;
|
|
|
|
window_height = desktop_mode.h;
|
|
|
|
}
|
2017-07-23 19:22:00 +00:00
|
|
|
|
|
|
|
if (sdl_window) {
|
|
|
|
int old_window_width, old_window_height, old_window_flags;
|
|
|
|
SDL_GetWindowSize(sdl_window, &old_window_width, &old_window_height);
|
|
|
|
old_window_flags = SDL_GetWindowFlags(sdl_window);
|
|
|
|
if (old_window_width != window_width ||
|
|
|
|
old_window_height != window_height ||
|
|
|
|
(old_window_flags & window_flags_to_monitor) != (window_flags & window_flags_to_monitor))
|
|
|
|
{
|
|
|
|
delete_sdl_video_window();
|
|
|
|
}
|
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
if (!sdl_window) {
|
|
|
|
sdl_window = SDL_CreateWindow(
|
|
|
|
"Basilisk II",
|
|
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
SDL_WINDOWPOS_UNDEFINED,
|
|
|
|
window_width,
|
|
|
|
window_height,
|
|
|
|
window_flags);
|
|
|
|
if (!sdl_window) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
if (!sdl_renderer) {
|
|
|
|
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, SDL_RENDERER_ACCELERATED);
|
|
|
|
if (!sdl_renderer) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
SDL_assert(sdl_texture == NULL);
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
|
|
|
if (!sdl_texture) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
SDL_assert(outer_sdl_surface == NULL);
|
|
|
|
SDL_assert(inner_sdl_surface == NULL);
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
switch (bpp) {
|
|
|
|
case 8:
|
|
|
|
outer_sdl_surface = SDL_CreateRGBSurface(0, width, height, 8, 0, 0, 0, 0);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
outer_sdl_surface = SDL_CreateRGBSurfaceWithFormat(0, width, height, 16, SDL_PIXELFORMAT_RGB565);
|
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
outer_sdl_surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
|
|
|
|
inner_sdl_surface = outer_sdl_surface;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("WARNING: An unsupported bpp of %d was used\n", bpp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!outer_sdl_surface) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!inner_sdl_surface) {
|
|
|
|
inner_sdl_surface = SDL_CreateRGBSurface(0, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
|
|
|
|
if (!inner_sdl_surface) {
|
|
|
|
shutdown_sdl_video();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return outer_sdl_surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int update_sdl_video()
|
|
|
|
{
|
|
|
|
if (!sdl_renderer || !sdl_texture || !outer_sdl_surface) {
|
|
|
|
printf("WARNING: A video mode does not appear to have been set.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inner_sdl_surface != outer_sdl_surface &&
|
|
|
|
inner_sdl_surface != NULL &&
|
|
|
|
outer_sdl_surface != NULL)
|
|
|
|
{
|
|
|
|
SDL_Rect destRect = {0, 0, inner_sdl_surface->w, inner_sdl_surface->h};
|
|
|
|
if (SDL_BlitSurface(outer_sdl_surface, NULL, inner_sdl_surface, &destRect) != 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SDL_UpdateTexture(sdl_texture, NULL, inner_sdl_surface->pixels, inner_sdl_surface->pitch) != 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Rect src_rect = {0, 0, inner_sdl_surface->w, inner_sdl_surface->h};
|
|
|
|
if (SDL_RenderCopy(sdl_renderer, sdl_texture, &src_rect, NULL) != 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_RenderPresent(sdl_renderer);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-24 06:07:20 +00:00
|
|
|
void driver_base::set_video_mode(int flags)
|
2013-04-22 20:17:13 +00:00
|
|
|
{
|
2013-04-22 20:28:30 +00:00
|
|
|
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
if ((s = init_sdl_video(VIDEO_MODE_X, VIDEO_MODE_Y, depth, flags)) == NULL)
|
2013-04-24 05:53:50 +00:00
|
|
|
return;
|
2013-04-24 06:07:20 +00:00
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
the_host_buffer = (uint8 *)s->pixels;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void driver_base::init()
|
|
|
|
{
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
set_video_mode(display_type == DISPLAY_SCREEN ? SDL_WINDOW_FULLSCREEN : 0);
|
2013-04-24 06:07:20 +00:00
|
|
|
int aligned_height = (VIDEO_MODE_Y + 15) & ~15;
|
2013-04-22 20:24:52 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
use_vosf = true;
|
|
|
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary)
|
|
|
|
the_buffer_size = page_extend((aligned_height + 2) * s->pitch);
|
|
|
|
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
|
|
|
|
the_buffer_copy = (uint8 *)malloc(the_buffer_size);
|
|
|
|
D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
|
|
|
|
|
|
|
|
// Check whether we can initialize the VOSF subsystem and it's profitable
|
|
|
|
if (!video_vosf_init(monitor)) {
|
2016-12-18 03:04:57 +00:00
|
|
|
WarningAlert(GetString(STR_VOSF_INIT_ERR));
|
2013-04-22 20:24:52 +00:00
|
|
|
use_vosf = false;
|
|
|
|
}
|
|
|
|
else if (!video_vosf_profitable()) {
|
|
|
|
video_vosf_exit();
|
|
|
|
printf("VOSF acceleration is not profitable on this platform, disabling it\n");
|
|
|
|
use_vosf = false;
|
|
|
|
}
|
|
|
|
if (!use_vosf) {
|
|
|
|
free(the_buffer_copy);
|
|
|
|
vm_release(the_buffer, the_buffer_size);
|
|
|
|
the_host_buffer = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!use_vosf) {
|
|
|
|
// Allocate memory for frame buffer
|
|
|
|
the_buffer_size = (aligned_height + 2) * s->pitch;
|
|
|
|
the_buffer_copy = (uint8 *)calloc(1, the_buffer_size);
|
|
|
|
the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
|
|
|
|
D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy));
|
|
|
|
}
|
2013-04-22 20:28:30 +00:00
|
|
|
|
2013-04-24 06:07:20 +00:00
|
|
|
// Set frame buffer base
|
|
|
|
set_mac_frame_buffer(monitor, VIDEO_MODE_DEPTH, true);
|
|
|
|
|
|
|
|
adapt_to_video_mode();
|
|
|
|
}
|
|
|
|
|
|
|
|
void driver_base::adapt_to_video_mode() {
|
2017-07-16 11:07:08 +00:00
|
|
|
ADBSetRelMouseMode(mouse_grabbed);
|
2013-04-24 06:07:20 +00:00
|
|
|
|
2013-04-22 20:28:30 +00:00
|
|
|
// Init blitting routines
|
|
|
|
SDL_PixelFormat *f = s->format;
|
|
|
|
VisualFormat visualFormat;
|
2013-04-24 06:07:20 +00:00
|
|
|
visualFormat.depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH);
|
2013-04-22 20:28:30 +00:00
|
|
|
visualFormat.Rmask = f->Rmask;
|
|
|
|
visualFormat.Gmask = f->Gmask;
|
|
|
|
visualFormat.Bmask = f->Bmask;
|
|
|
|
Screen_blitter_init(visualFormat, true, mac_depth_of_video_depth(VIDEO_MODE_DEPTH));
|
|
|
|
|
|
|
|
// Load gray ramp to 8->16/32 expand map
|
|
|
|
if (!IsDirectMode(mode))
|
|
|
|
for (int i=0; i<256; i++)
|
|
|
|
ExpandMap[i] = SDL_MapRGB(f, i, i, i);
|
|
|
|
|
|
|
|
|
2013-04-22 06:03:32 +00:00
|
|
|
bool hardware_cursor = false;
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
hardware_cursor = video_can_change_cursor();
|
|
|
|
if (hardware_cursor) {
|
|
|
|
// Create cursor
|
|
|
|
if ((sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, 0, 0)) != NULL) {
|
|
|
|
SDL_SetCursor(sdl_cursor);
|
|
|
|
}
|
|
|
|
}
|
2013-04-08 02:28:46 +00:00
|
|
|
// Tell the video driver there's a change in cursor type
|
|
|
|
if (private_data)
|
|
|
|
private_data->cursorHardware = hardware_cursor;
|
2013-04-22 06:03:32 +00:00
|
|
|
#endif
|
|
|
|
// Hide cursor
|
|
|
|
SDL_ShowCursor(hardware_cursor);
|
|
|
|
|
2013-04-22 09:25:18 +00:00
|
|
|
// Set window name/class
|
2017-07-16 11:07:08 +00:00
|
|
|
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE);
|
2013-04-22 09:25:18 +00:00
|
|
|
|
2013-04-22 20:28:30 +00:00
|
|
|
// Everything went well
|
|
|
|
init_ok = true;
|
2013-04-22 20:17:13 +00:00
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
driver_base::~driver_base()
|
|
|
|
{
|
|
|
|
ungrab_mouse();
|
|
|
|
restore_mouse_accel();
|
|
|
|
|
2017-07-23 19:22:00 +00:00
|
|
|
// HACK: Just delete instances of SDL_Surface and SDL_Texture, rather
|
|
|
|
// than also the SDL_Window and SDL_Renderer. This fixes a bug whereby
|
|
|
|
// OSX hosts, when in fullscreen, will, on a guest OS resolution change,
|
|
|
|
// do a series of switches (using OSX's "Spaces" feature) to and from
|
|
|
|
// the Basilisk II desktop,
|
|
|
|
delete_sdl_video_surfaces(); // This deletes instances of SDL_Surface and SDL_Texture
|
|
|
|
//shutdown_sdl_video(); // This deletes SDL_Window, SDL_Renderer, in addition to
|
|
|
|
// instances of SDL_Surface and SDL_Texture.
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2004-11-28 19:31:11 +00:00
|
|
|
// the_buffer shall always be mapped through vm_acquire_framebuffer()
|
|
|
|
if (the_buffer != VM_MAP_FAILED) {
|
|
|
|
D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size));
|
|
|
|
vm_release_framebuffer(the_buffer, the_buffer_size);
|
|
|
|
the_buffer = NULL;
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Free frame buffer(s)
|
|
|
|
if (!use_vosf) {
|
|
|
|
if (the_buffer_copy) {
|
|
|
|
free(the_buffer_copy);
|
|
|
|
the_buffer_copy = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
else {
|
|
|
|
if (the_buffer_copy) {
|
|
|
|
D(bug(" freeing the_buffer_copy at %p\n", the_buffer_copy));
|
|
|
|
free(the_buffer_copy);
|
|
|
|
the_buffer_copy = NULL;
|
|
|
|
}
|
2004-11-28 19:31:11 +00:00
|
|
|
|
|
|
|
// Deinitialize VOSF
|
|
|
|
video_vosf_exit();
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
2013-04-22 09:28:22 +00:00
|
|
|
|
|
|
|
SDL_ShowCursor(1);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Palette has changed
|
|
|
|
void driver_base::update_palette(void)
|
|
|
|
{
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE &mode = monitor.get_current_mode();
|
2004-06-23 13:47:20 +00:00
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
if ((int)VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT) {
|
|
|
|
SDL_SetSurfacePalette(s, sdl_palette);
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable mouse acceleration
|
|
|
|
void driver_base::disable_mouse_accel(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore mouse acceleration to original value
|
|
|
|
void driver_base::restore_mouse_accel(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle mouse grab
|
2013-04-24 05:27:57 +00:00
|
|
|
void driver_base::toggle_mouse_grab(void)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
if (mouse_grabbed)
|
|
|
|
ungrab_mouse();
|
|
|
|
else
|
|
|
|
grab_mouse();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Grab mouse, switch to relative mouse mode
|
2013-04-24 05:27:57 +00:00
|
|
|
void driver_base::grab_mouse(void)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
if (!mouse_grabbed) {
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
set_grab_mode(true);
|
|
|
|
set_window_name(STR_WINDOW_TITLE_GRABBED);
|
|
|
|
disable_mouse_accel();
|
|
|
|
ADBSetRelMouseMode(mouse_grabbed = true);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ungrab mouse, switch to absolute mouse mode
|
2013-04-24 05:27:57 +00:00
|
|
|
void driver_base::ungrab_mouse(void)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
if (mouse_grabbed) {
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
set_grab_mode(false);
|
|
|
|
set_window_name(STR_WINDOW_TITLE);
|
|
|
|
restore_mouse_accel();
|
|
|
|
ADBSetRelMouseMode(mouse_grabbed = false);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialization
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Init keycode translation table
|
|
|
|
static void keycode_init(void)
|
|
|
|
{
|
|
|
|
bool use_kc = PrefsFindBool("keycodes");
|
|
|
|
if (use_kc) {
|
|
|
|
|
|
|
|
// Get keycode file path from preferences
|
|
|
|
const char *kc_path = PrefsFindString("keycodefile");
|
|
|
|
|
|
|
|
// Open keycode table
|
|
|
|
FILE *f = fopen(kc_path ? kc_path : KEYCODE_FILE_NAME, "r");
|
|
|
|
if (f == NULL) {
|
|
|
|
char str[256];
|
2015-06-30 19:01:51 +00:00
|
|
|
snprintf(str, sizeof(str), GetString(STR_KEYCODE_FILE_WARN), kc_path ? kc_path : KEYCODE_FILE_NAME, strerror(errno));
|
2004-06-23 13:47:20 +00:00
|
|
|
WarningAlert(str);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Default translation table
|
|
|
|
for (int i=0; i<256; i++)
|
|
|
|
keycode_table[i] = -1;
|
|
|
|
|
|
|
|
// Search for server vendor string, then read keycodes
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
const char * video_driver = SDL_GetCurrentVideoDriver();
|
2004-06-23 13:47:20 +00:00
|
|
|
bool video_driver_found = false;
|
|
|
|
char line[256];
|
2005-01-22 17:41:33 +00:00
|
|
|
int n_keys = 0;
|
2004-06-23 13:47:20 +00:00
|
|
|
while (fgets(line, sizeof(line) - 1, f)) {
|
|
|
|
// Read line
|
|
|
|
int len = strlen(line);
|
|
|
|
if (len == 0)
|
|
|
|
continue;
|
|
|
|
line[len-1] = 0;
|
|
|
|
|
|
|
|
// Comments begin with "#" or ";"
|
|
|
|
if (line[0] == '#' || line[0] == ';' || line[0] == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (video_driver_found) {
|
2005-01-22 17:41:33 +00:00
|
|
|
// Skip aliases as long as we have read keycodes yet
|
|
|
|
// Otherwise, it's another mapping and we have to stop
|
2004-06-27 17:31:21 +00:00
|
|
|
static const char sdl_str[] = "sdl";
|
2005-01-22 17:41:33 +00:00
|
|
|
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0 && n_keys == 0)
|
2004-06-23 13:47:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Read keycode
|
|
|
|
int x_code, mac_code;
|
|
|
|
if (sscanf(line, "%d %d", &x_code, &mac_code) == 2)
|
2005-01-22 17:41:33 +00:00
|
|
|
keycode_table[x_code & 0xff] = mac_code, n_keys++;
|
2004-06-23 13:47:20 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
// Search for SDL video driver string
|
2004-06-27 17:31:21 +00:00
|
|
|
static const char sdl_str[] = "sdl";
|
|
|
|
if (strncmp(line, sdl_str, sizeof(sdl_str) - 1) == 0) {
|
|
|
|
char *p = line + sizeof(sdl_str);
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
if (video_driver && strstr(video_driver, p) == video_driver)
|
2004-06-23 13:47:20 +00:00
|
|
|
video_driver_found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keycode file completely read
|
|
|
|
fclose(f);
|
|
|
|
use_keycodes = video_driver_found;
|
|
|
|
|
|
|
|
// Vendor not found? Then display warning
|
|
|
|
if (!video_driver_found) {
|
|
|
|
char str[256];
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
snprintf(str, sizeof(str), GetString(STR_KEYCODE_VENDOR_WARN), video_driver ? video_driver : "", kc_path ? kc_path : KEYCODE_FILE_NAME);
|
2004-06-23 13:47:20 +00:00
|
|
|
WarningAlert(str);
|
|
|
|
return;
|
|
|
|
}
|
2005-01-22 17:41:33 +00:00
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
D(bug("Using SDL/%s keycodes table, %d key mappings\n", video_driver ? video_driver : "", n_keys));
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open display for current mode
|
|
|
|
bool SDL_monitor_desc::video_open(void)
|
|
|
|
{
|
|
|
|
D(bug("video_open()\n"));
|
2004-06-24 21:46:55 +00:00
|
|
|
#if DEBUG
|
2012-01-14 15:45:18 +00:00
|
|
|
const VIDEO_MODE &mode = get_current_mode();
|
2004-06-24 21:46:55 +00:00
|
|
|
D(bug("Current video mode:\n"));
|
|
|
|
D(bug(" %dx%d (ID %02x), %d bpp\n", VIDEO_MODE_X, VIDEO_MODE_Y, VIDEO_MODE_RESOLUTION, 1 << (VIDEO_MODE_DEPTH & 0x0f)));
|
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Create display driver object of requested type
|
2013-04-24 05:56:16 +00:00
|
|
|
drv = new(std::nothrow) driver_base(*this);
|
2004-06-23 13:47:20 +00:00
|
|
|
if (drv == NULL)
|
|
|
|
return false;
|
2013-04-22 20:17:13 +00:00
|
|
|
drv->init();
|
2004-06-23 13:47:20 +00:00
|
|
|
if (!drv->init_ok) {
|
|
|
|
delete drv;
|
|
|
|
drv = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-03-28 07:01:19 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
// Chain in a new message handler for WM_DEVICECHANGE
|
|
|
|
HWND the_window = GetMainWindowHandle();
|
|
|
|
sdl_window_proc = (WNDPROC)GetWindowLongPtr(the_window, GWLP_WNDPROC);
|
|
|
|
SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)windows_message_handler);
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Initialize VideoRefresh function
|
|
|
|
VideoRefreshInit();
|
|
|
|
|
|
|
|
// Lock down frame buffer
|
|
|
|
LOCK_FRAME_BUFFER;
|
|
|
|
|
|
|
|
// Start redraw/input thread
|
2005-06-14 22:35:42 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2004-06-23 13:47:20 +00:00
|
|
|
redraw_thread_cancel = false;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
redraw_thread_active = ((redraw_thread = SDL_CreateThread(redraw_func, "Redraw Thread", NULL)) != NULL);
|
2004-06-23 13:47:20 +00:00
|
|
|
if (!redraw_thread_active) {
|
|
|
|
printf("FATAL: cannot create redraw thread\n");
|
|
|
|
return false;
|
|
|
|
}
|
2005-06-14 22:35:42 +00:00
|
|
|
#else
|
|
|
|
redraw_thread_active = true;
|
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
bool VideoInit(void)
|
|
|
|
{
|
|
|
|
const bool classic = false;
|
|
|
|
#else
|
2004-06-23 13:47:20 +00:00
|
|
|
bool VideoInit(bool classic)
|
|
|
|
{
|
2004-06-24 15:25:57 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
classic_mode = classic;
|
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
// Zero the mainBuffer structure
|
|
|
|
mainBuffer.dirtyPages = NULL;
|
|
|
|
mainBuffer.pageInfo = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Create Mutexes
|
2005-11-29 23:20:31 +00:00
|
|
|
if ((sdl_events_lock = SDL_CreateMutex()) == NULL)
|
|
|
|
return false;
|
2004-06-23 13:47:20 +00:00
|
|
|
if ((sdl_palette_lock = SDL_CreateMutex()) == NULL)
|
|
|
|
return false;
|
|
|
|
if ((frame_buffer_lock = SDL_CreateMutex()) == NULL)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Init keycode translation
|
|
|
|
keycode_init();
|
|
|
|
|
|
|
|
// Read prefs
|
|
|
|
frame_skip = PrefsFindInt32("frameskip");
|
|
|
|
mouse_wheel_mode = PrefsFindInt32("mousewheelmode");
|
|
|
|
mouse_wheel_lines = PrefsFindInt32("mousewheellines");
|
|
|
|
|
|
|
|
// Get screen mode from preferences
|
2006-05-09 21:41:02 +00:00
|
|
|
migrate_screen_prefs();
|
2004-06-24 21:46:55 +00:00
|
|
|
const char *mode_str = NULL;
|
2004-06-23 13:47:20 +00:00
|
|
|
if (classic_mode)
|
|
|
|
mode_str = "win/512/342";
|
|
|
|
else
|
|
|
|
mode_str = PrefsFindString("screen");
|
|
|
|
|
|
|
|
// Determine display type and default dimensions
|
2004-06-24 15:25:57 +00:00
|
|
|
int default_width, default_height;
|
|
|
|
if (classic) {
|
|
|
|
default_width = 512;
|
|
|
|
default_height = 384;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
default_width = 640;
|
|
|
|
default_height = 480;
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
display_type = DISPLAY_WINDOW;
|
|
|
|
if (mode_str) {
|
|
|
|
if (sscanf(mode_str, "win/%d/%d", &default_width, &default_height) == 2)
|
|
|
|
display_type = DISPLAY_WINDOW;
|
2005-06-06 21:20:28 +00:00
|
|
|
else if (sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2)
|
|
|
|
display_type = DISPLAY_SCREEN;
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
if (default_width <= 0)
|
2006-05-09 21:41:02 +00:00
|
|
|
default_width = sdl_display_width();
|
|
|
|
else if (default_width > sdl_display_width())
|
|
|
|
default_width = sdl_display_width();
|
2004-06-23 13:47:20 +00:00
|
|
|
if (default_height <= 0)
|
2006-05-09 21:41:02 +00:00
|
|
|
default_height = sdl_display_height();
|
|
|
|
else if (default_height > sdl_display_height())
|
|
|
|
default_height = sdl_display_height();
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Mac screen depth follows X depth
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
screen_depth = 32;
|
|
|
|
SDL_DisplayMode desktop_mode;
|
|
|
|
if (SDL_GetDesktopDisplayMode(0, &desktop_mode) == 0) {
|
|
|
|
screen_depth = SDL_BITSPERPIXEL(desktop_mode.format);
|
|
|
|
}
|
2004-06-24 15:25:57 +00:00
|
|
|
int default_depth;
|
2004-06-23 13:47:20 +00:00
|
|
|
switch (screen_depth) {
|
|
|
|
case 8:
|
2004-06-24 15:25:57 +00:00
|
|
|
default_depth = VIDEO_DEPTH_8BIT;
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
case 15: case 16:
|
2004-06-24 15:25:57 +00:00
|
|
|
default_depth = VIDEO_DEPTH_16BIT;
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
case 24: case 32:
|
2004-06-24 15:25:57 +00:00
|
|
|
default_depth = VIDEO_DEPTH_32BIT;
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-06-24 15:25:57 +00:00
|
|
|
default_depth = VIDEO_DEPTH_1BIT;
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-09 21:41:02 +00:00
|
|
|
// Initialize list of video modes to try
|
|
|
|
struct {
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
int resolution_id;
|
|
|
|
}
|
|
|
|
video_modes[] = {
|
|
|
|
{ -1, -1, 0x80 },
|
|
|
|
{ 512, 384, 0x80 },
|
|
|
|
{ 640, 480, 0x81 },
|
|
|
|
{ 800, 600, 0x82 },
|
|
|
|
{ 1024, 768, 0x83 },
|
|
|
|
{ 1152, 870, 0x84 },
|
|
|
|
{ 1280, 1024, 0x85 },
|
|
|
|
{ 1600, 1200, 0x86 },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
video_modes[0].w = default_width;
|
|
|
|
video_modes[0].h = default_height;
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Construct list of supported modes
|
|
|
|
if (display_type == DISPLAY_WINDOW) {
|
|
|
|
if (classic)
|
2004-06-24 15:25:57 +00:00
|
|
|
add_mode(display_type, 512, 342, 0x80, 64, VIDEO_DEPTH_1BIT);
|
2004-06-23 13:47:20 +00:00
|
|
|
else {
|
2006-05-09 21:41:02 +00:00
|
|
|
for (int i = 0; video_modes[i].w != 0; i++) {
|
|
|
|
const int w = video_modes[i].w;
|
|
|
|
const int h = video_modes[i].h;
|
|
|
|
if (i > 0 && (w >= default_width || h >= default_height))
|
|
|
|
continue;
|
|
|
|
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++)
|
|
|
|
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)d), d);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-06 21:20:28 +00:00
|
|
|
} else if (display_type == DISPLAY_SCREEN) {
|
|
|
|
for (int i = 0; video_modes[i].w != 0; i++) {
|
|
|
|
const int w = video_modes[i].w;
|
|
|
|
const int h = video_modes[i].h;
|
|
|
|
if (i > 0 && (w >= default_width || h >= default_height))
|
|
|
|
continue;
|
2006-05-09 21:41:02 +00:00
|
|
|
if (w == 512 && h == 384)
|
|
|
|
continue;
|
|
|
|
for (int d = VIDEO_DEPTH_1BIT; d <= default_depth; d++)
|
|
|
|
add_mode(display_type, w, h, video_modes[i].resolution_id, TrivialBytesPerRow(w, (video_depth)d), d);
|
2005-06-06 21:20:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
if (VideoModes.empty()) {
|
|
|
|
ErrorAlert(STR_NO_XVISUAL_ERR);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find requested default mode with specified dimensions
|
|
|
|
uint32 default_id;
|
2004-06-24 15:25:57 +00:00
|
|
|
std::vector<VIDEO_MODE>::const_iterator i, end = VideoModes.end();
|
2004-06-23 13:47:20 +00:00
|
|
|
for (i = VideoModes.begin(); i != end; ++i) {
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE & mode = (*i);
|
|
|
|
if (VIDEO_MODE_X == default_width && VIDEO_MODE_Y == default_height && VIDEO_MODE_DEPTH == default_depth) {
|
|
|
|
default_id = VIDEO_MODE_RESOLUTION;
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
std::vector<VIDEO_MODE>::const_iterator begin = VideoModes.begin();
|
|
|
|
cur_mode = distance(begin, i);
|
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == end) { // not found, use first available mode
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE & mode = VideoModes[0];
|
|
|
|
default_depth = VIDEO_MODE_DEPTH;
|
|
|
|
default_id = VIDEO_MODE_RESOLUTION;
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
cur_mode = 0;
|
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
2004-06-24 21:46:55 +00:00
|
|
|
for (int i = 0; i < VideoModes.size(); i++)
|
2004-06-24 15:25:57 +00:00
|
|
|
VModes[i] = VideoModes[i];
|
2004-06-24 21:46:55 +00:00
|
|
|
VideoInfo *p = &VModes[VideoModes.size()];
|
|
|
|
p->viType = DIS_INVALID; // End marker
|
|
|
|
p->viRowBytes = 0;
|
|
|
|
p->viXsize = p->viYsize = 0;
|
|
|
|
p->viAppleMode = 0;
|
|
|
|
p->viAppleID = 0;
|
2004-06-24 15:25:57 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
#if DEBUG
|
|
|
|
D(bug("Available video modes:\n"));
|
|
|
|
for (i = VideoModes.begin(); i != end; ++i) {
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE & mode = (*i);
|
|
|
|
int bits = 1 << VIDEO_MODE_DEPTH;
|
2004-06-23 13:47:20 +00:00
|
|
|
if (bits == 16)
|
|
|
|
bits = 15;
|
|
|
|
else if (bits == 32)
|
|
|
|
bits = 24;
|
2004-06-24 15:25:57 +00:00
|
|
|
D(bug(" %dx%d (ID %02x), %d colors\n", VIDEO_MODE_X, VIDEO_MODE_Y, VIDEO_MODE_RESOLUTION, 1 << bits));
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-08-15 11:38:25 +00:00
|
|
|
int color_depth = get_customized_color_depth(default_depth);
|
|
|
|
|
|
|
|
D(bug("Return get_customized_color_depth %d\n", color_depth));
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Create SDL_monitor_desc for this (the only) display
|
2016-08-15 11:38:25 +00:00
|
|
|
SDL_monitor_desc *monitor = new SDL_monitor_desc(VideoModes, (video_depth)color_depth, default_id);
|
2004-06-23 13:47:20 +00:00
|
|
|
VideoMonitors.push_back(monitor);
|
|
|
|
|
|
|
|
// Open display
|
|
|
|
return monitor->video_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deinitialization
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Close display
|
|
|
|
void SDL_monitor_desc::video_close(void)
|
|
|
|
{
|
|
|
|
D(bug("video_close()\n"));
|
|
|
|
|
2006-03-28 07:01:19 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
// Remove message handler for WM_DEVICECHANGE
|
|
|
|
HWND the_window = GetMainWindowHandle();
|
|
|
|
SetWindowLongPtr(the_window, GWLP_WNDPROC, (LONG_PTR)sdl_window_proc);
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Stop redraw thread
|
2005-06-14 22:35:42 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2004-06-23 13:47:20 +00:00
|
|
|
if (redraw_thread_active) {
|
|
|
|
redraw_thread_cancel = true;
|
2004-06-23 22:55:47 +00:00
|
|
|
SDL_WaitThread(redraw_thread, NULL);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
2005-06-14 22:35:42 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
redraw_thread_active = false;
|
|
|
|
|
|
|
|
// Unlock frame buffer
|
|
|
|
UNLOCK_FRAME_BUFFER;
|
|
|
|
D(bug(" frame buffer unlocked\n"));
|
|
|
|
|
|
|
|
// Close display
|
|
|
|
delete drv;
|
|
|
|
drv = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VideoExit(void)
|
|
|
|
{
|
|
|
|
// Close displays
|
|
|
|
vector<monitor_desc *>::iterator i, end = VideoMonitors.end();
|
|
|
|
for (i = VideoMonitors.begin(); i != end; ++i)
|
|
|
|
dynamic_cast<SDL_monitor_desc *>(*i)->video_close();
|
|
|
|
|
|
|
|
// Destroy locks
|
|
|
|
if (frame_buffer_lock)
|
|
|
|
SDL_DestroyMutex(frame_buffer_lock);
|
|
|
|
if (sdl_palette_lock)
|
|
|
|
SDL_DestroyMutex(sdl_palette_lock);
|
2005-11-29 23:20:31 +00:00
|
|
|
if (sdl_events_lock)
|
|
|
|
SDL_DestroyMutex(sdl_events_lock);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close down full-screen mode (if bringing up error alerts is unsafe while in full-screen mode)
|
|
|
|
*/
|
|
|
|
|
|
|
|
void VideoQuitFullScreen(void)
|
|
|
|
{
|
|
|
|
D(bug("VideoQuitFullScreen()\n"));
|
|
|
|
quit_full_screen = true;
|
|
|
|
}
|
|
|
|
|
2013-02-21 12:54:45 +00:00
|
|
|
static void do_toggle_fullscreen(void)
|
|
|
|
{
|
2013-04-19 04:18:14 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2013-02-21 12:54:45 +00:00
|
|
|
// pause redraw thread
|
|
|
|
thread_stop_ack = false;
|
|
|
|
thread_stop_req = true;
|
|
|
|
while (!thread_stop_ack) ;
|
2013-04-19 04:18:14 +00:00
|
|
|
#endif
|
2013-02-21 12:54:45 +00:00
|
|
|
|
|
|
|
// save the mouse position
|
|
|
|
int x, y;
|
|
|
|
SDL_GetMouseState(&x, &y);
|
|
|
|
|
|
|
|
// save the screen contents
|
|
|
|
SDL_Surface *tmp_surface = SDL_ConvertSurface(drv->s, drv->s->format,
|
|
|
|
drv->s->flags);
|
|
|
|
|
|
|
|
// switch modes
|
|
|
|
display_type = (display_type == DISPLAY_SCREEN) ? DISPLAY_WINDOW
|
|
|
|
: DISPLAY_SCREEN;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
drv->set_video_mode(display_type == DISPLAY_SCREEN ? SDL_WINDOW_FULLSCREEN : 0);
|
2013-02-21 12:54:45 +00:00
|
|
|
drv->adapt_to_video_mode();
|
|
|
|
|
|
|
|
// reset the palette
|
2013-04-19 04:18:14 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
2013-02-21 12:54:45 +00:00
|
|
|
video_set_palette();
|
2013-04-19 04:18:14 +00:00
|
|
|
#endif
|
2013-02-21 12:54:45 +00:00
|
|
|
drv->update_palette();
|
|
|
|
|
|
|
|
// restore the screen contents
|
|
|
|
SDL_BlitSurface(tmp_surface, NULL, drv->s, NULL);
|
|
|
|
SDL_FreeSurface(tmp_surface);
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
update_sdl_video();
|
2013-02-21 12:54:45 +00:00
|
|
|
|
|
|
|
// reset the video refresh handler
|
|
|
|
VideoRefreshInit();
|
|
|
|
|
|
|
|
// while SetVideoMode is happening, control key up may be missed
|
|
|
|
ADBKeyUp(0x36);
|
|
|
|
|
|
|
|
// restore the mouse position
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
SDL_WarpMouseGlobal(x, y);
|
2013-02-21 12:54:45 +00:00
|
|
|
|
|
|
|
// resume redraw thread
|
|
|
|
toggle_fullscreen = false;
|
2013-04-19 04:18:14 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2013-02-21 12:54:45 +00:00
|
|
|
thread_stop_req = false;
|
|
|
|
#endif
|
2013-04-19 04:18:14 +00:00
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Mac VBL interrupt
|
|
|
|
*/
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
/*
|
|
|
|
* Execute video VBL routine
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
void VideoVBL(void)
|
|
|
|
{
|
|
|
|
// Emergency quit requested? Then quit
|
|
|
|
if (emerg_quit)
|
|
|
|
QuitEmulator();
|
|
|
|
|
2013-02-21 12:54:45 +00:00
|
|
|
if (toggle_fullscreen)
|
|
|
|
do_toggle_fullscreen();
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
// Temporarily give up frame buffer lock (this is the point where
|
|
|
|
// we are suspended when the user presses Ctrl-Tab)
|
|
|
|
UNLOCK_FRAME_BUFFER;
|
|
|
|
LOCK_FRAME_BUFFER;
|
|
|
|
|
|
|
|
// Execute video VBL
|
|
|
|
if (private_data != NULL && private_data->interruptsEnabled)
|
|
|
|
VSLDoInterruptService(private_data->vslServiceID);
|
|
|
|
}
|
|
|
|
#else
|
2004-06-23 13:47:20 +00:00
|
|
|
void VideoInterrupt(void)
|
|
|
|
{
|
2004-06-23 22:37:33 +00:00
|
|
|
// We must fill in the events queue in the same thread that did call SDL_SetVideoMode()
|
|
|
|
SDL_PumpEvents();
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Emergency quit requested? Then quit
|
|
|
|
if (emerg_quit)
|
|
|
|
QuitEmulator();
|
|
|
|
|
2013-04-19 04:18:14 +00:00
|
|
|
if (toggle_fullscreen)
|
|
|
|
do_toggle_fullscreen();
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
// Temporarily give up frame buffer lock (this is the point where
|
|
|
|
// we are suspended when the user presses Ctrl-Tab)
|
|
|
|
UNLOCK_FRAME_BUFFER;
|
|
|
|
LOCK_FRAME_BUFFER;
|
|
|
|
}
|
2004-06-24 15:25:57 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set palette
|
|
|
|
*/
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
void video_set_palette(void)
|
|
|
|
{
|
|
|
|
monitor_desc * monitor = VideoMonitors[0];
|
|
|
|
int n_colors = palette_size(monitor->get_current_mode().viAppleMode);
|
|
|
|
uint8 pal[256 * 3];
|
|
|
|
for (int c = 0; c < n_colors; c++) {
|
|
|
|
pal[c*3 + 0] = mac_pal[c].red;
|
|
|
|
pal[c*3 + 1] = mac_pal[c].green;
|
|
|
|
pal[c*3 + 2] = mac_pal[c].blue;
|
|
|
|
}
|
|
|
|
monitor->set_palette(pal, n_colors);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
void SDL_monitor_desc::set_palette(uint8 *pal, int num_in)
|
|
|
|
{
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE &mode = get_current_mode();
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// FIXME: how can we handle the gamma ramp?
|
2004-06-29 21:50:23 +00:00
|
|
|
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT)
|
2004-06-23 13:47:20 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
LOCK_PALETTE;
|
|
|
|
|
|
|
|
// Convert colors to XColor array
|
|
|
|
int num_out = 256;
|
|
|
|
bool stretch = false;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
|
|
|
if (!sdl_palette) {
|
|
|
|
sdl_palette = SDL_AllocPalette(num_out);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Color *p = sdl_palette->colors;
|
2004-06-23 13:47:20 +00:00
|
|
|
for (int i=0; i<num_out; i++) {
|
|
|
|
int c = (stretch ? (i * num_in) / num_out : i);
|
|
|
|
p->r = pal[c*3 + 0] * 0x0101;
|
|
|
|
p->g = pal[c*3 + 1] * 0x0101;
|
|
|
|
p->b = pal[c*3 + 2] * 0x0101;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recalculate pixel color expansion map
|
|
|
|
if (!IsDirectMode(mode)) {
|
|
|
|
for (int i=0; i<256; i++) {
|
|
|
|
int c = i & (num_in-1); // If there are less than 256 colors, we repeat the first entries (this makes color expansion easier)
|
|
|
|
ExpandMap[i] = SDL_MapRGB(drv->s->format, pal[c*3+0], pal[c*3+1], pal[c*3+2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
2004-06-26 15:22:02 +00:00
|
|
|
if (use_vosf) {
|
|
|
|
// We have to redraw everything because the interpretation of pixel values changed
|
|
|
|
LOCK_VOSF;
|
|
|
|
PFLAG_SET_ALL;
|
|
|
|
UNLOCK_VOSF;
|
|
|
|
memset(the_buffer_copy, 0, VIDEO_MODE_ROW_BYTES * VIDEO_MODE_Y);
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tell redraw thread to change palette
|
|
|
|
sdl_palette_changed = true;
|
|
|
|
|
|
|
|
UNLOCK_PALETTE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Switch video mode
|
|
|
|
*/
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
int16 video_mode_change(VidLocals *csSave, uint32 ParamPtr)
|
|
|
|
{
|
|
|
|
/* return if no mode change */
|
|
|
|
if ((csSave->saveData == ReadMacInt32(ParamPtr + csData)) &&
|
|
|
|
(csSave->saveMode == ReadMacInt16(ParamPtr + csMode))) return noErr;
|
|
|
|
|
|
|
|
/* first find video mode in table */
|
|
|
|
for (int i=0; VModes[i].viType != DIS_INVALID; i++) {
|
|
|
|
if ((ReadMacInt16(ParamPtr + csMode) == VModes[i].viAppleMode) &&
|
|
|
|
(ReadMacInt32(ParamPtr + csData) == VModes[i].viAppleID)) {
|
|
|
|
csSave->saveMode = ReadMacInt16(ParamPtr + csMode);
|
|
|
|
csSave->saveData = ReadMacInt32(ParamPtr + csData);
|
|
|
|
csSave->savePage = ReadMacInt16(ParamPtr + csPage);
|
|
|
|
|
2004-11-28 19:31:11 +00:00
|
|
|
// Disable interrupts and pause redraw thread
|
2004-06-24 15:25:57 +00:00
|
|
|
DisableInterrupt();
|
2004-11-28 19:31:11 +00:00
|
|
|
thread_stop_ack = false;
|
|
|
|
thread_stop_req = true;
|
|
|
|
while (!thread_stop_ack) ;
|
2004-06-24 15:25:57 +00:00
|
|
|
|
|
|
|
cur_mode = i;
|
|
|
|
monitor_desc *monitor = VideoMonitors[0];
|
|
|
|
monitor->switch_to_current_mode();
|
|
|
|
|
|
|
|
WriteMacInt32(ParamPtr + csBaseAddr, screen_base);
|
|
|
|
csSave->saveBaseAddr=screen_base;
|
|
|
|
csSave->saveData=VModes[cur_mode].viAppleID;/* First mode ... */
|
|
|
|
csSave->saveMode=VModes[cur_mode].viAppleMode;
|
|
|
|
|
2004-11-28 19:31:11 +00:00
|
|
|
// Enable interrupts and resume redraw thread
|
|
|
|
thread_stop_req = false;
|
2004-06-24 15:25:57 +00:00
|
|
|
EnableInterrupt();
|
|
|
|
return noErr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return paramErr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
void SDL_monitor_desc::switch_to_current_mode(void)
|
|
|
|
{
|
|
|
|
// Close and reopen display
|
2005-11-29 23:20:31 +00:00
|
|
|
LOCK_EVENTS;
|
2004-06-23 13:47:20 +00:00
|
|
|
video_close();
|
|
|
|
video_open();
|
2005-11-29 23:20:31 +00:00
|
|
|
UNLOCK_EVENTS;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
if (drv == NULL) {
|
|
|
|
ErrorAlert(STR_OPEN_WINDOW_ERR);
|
|
|
|
QuitEmulator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
/*
|
|
|
|
* Can we set the MacOS cursor image into the window?
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
bool video_can_change_cursor(void)
|
|
|
|
{
|
2013-04-22 05:58:05 +00:00
|
|
|
if (display_type != DISPLAY_WINDOW)
|
|
|
|
return false;
|
|
|
|
|
2012-06-18 23:31:50 +00:00
|
|
|
#if defined(__APPLE__)
|
2008-06-25 02:52:52 +00:00
|
|
|
static char driver[] = "Quartz?";
|
|
|
|
static int quartzok = -1;
|
|
|
|
|
|
|
|
if (quartzok < 0) {
|
|
|
|
if (SDL_VideoDriverName(driver, sizeof driver) == NULL || strncmp(driver, "Quartz", sizeof driver))
|
|
|
|
quartzok = true;
|
|
|
|
else {
|
2011-12-30 15:11:08 +00:00
|
|
|
// Quartz driver bug prevents cursor changing in SDL 1.2.11 to 1.2.14.
|
2008-06-25 02:52:52 +00:00
|
|
|
const SDL_version *vp = SDL_Linked_Version();
|
2011-12-30 15:11:08 +00:00
|
|
|
int version = SDL_VERSIONNUM(vp->major, vp->minor, vp->patch);
|
|
|
|
quartzok = (version <= SDL_VERSIONNUM(1, 2, 10) || version >= SDL_VERSIONNUM(1, 2, 15));
|
2008-06-25 02:52:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return quartzok;
|
2012-06-18 23:31:50 +00:00
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
2004-06-24 15:25:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set cursor image for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
void video_set_cursor(void)
|
|
|
|
{
|
2012-06-18 23:31:50 +00:00
|
|
|
// Set new cursor image if it was changed
|
|
|
|
if (sdl_cursor) {
|
|
|
|
SDL_FreeCursor(sdl_cursor);
|
|
|
|
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]);
|
|
|
|
if (sdl_cursor) {
|
|
|
|
SDL_ShowCursor(private_data == NULL || private_data->cursorVisible);
|
|
|
|
SDL_SetCursor(sdl_cursor);
|
2013-04-07 22:21:10 +00:00
|
|
|
|
2012-06-18 23:31:50 +00:00
|
|
|
// XXX Windows apparently needs an extra mouse event to
|
2013-04-07 22:21:10 +00:00
|
|
|
// make the new cursor image visible.
|
|
|
|
// On Mac, if mouse is grabbed, SDL_ShowCursor() recenters the
|
|
|
|
// mouse, we have to put it back.
|
|
|
|
bool move = false;
|
|
|
|
#ifdef WIN32
|
|
|
|
move = true;
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
move = mouse_grabbed;
|
2012-06-18 23:31:50 +00:00
|
|
|
#endif
|
2013-04-07 22:21:10 +00:00
|
|
|
if (move) {
|
|
|
|
int visible = SDL_ShowCursor(-1);
|
|
|
|
if (visible) {
|
|
|
|
int x, y;
|
|
|
|
SDL_GetMouseState(&x, &y);
|
|
|
|
SDL_WarpMouse(x, y);
|
|
|
|
}
|
|
|
|
}
|
2012-06-18 23:31:50 +00:00
|
|
|
}
|
|
|
|
}
|
2004-06-24 15:25:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
/*
|
2004-06-27 17:31:21 +00:00
|
|
|
* Keyboard-related utilify functions
|
2004-06-23 13:47:20 +00:00
|
|
|
*/
|
|
|
|
|
2004-06-27 17:31:21 +00:00
|
|
|
static bool is_modifier_key(SDL_KeyboardEvent const & e)
|
|
|
|
{
|
|
|
|
switch (e.keysym.sym) {
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_NUMLOCKCLEAR:
|
2004-06-27 17:31:21 +00:00
|
|
|
case SDLK_CAPSLOCK:
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_SCROLLLOCK:
|
2004-06-27 17:31:21 +00:00
|
|
|
case SDLK_RSHIFT:
|
|
|
|
case SDLK_LSHIFT:
|
|
|
|
case SDLK_RCTRL:
|
|
|
|
case SDLK_LCTRL:
|
|
|
|
case SDLK_RALT:
|
|
|
|
case SDLK_LALT:
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_RGUI:
|
|
|
|
case SDLK_LGUI:
|
2004-06-27 17:31:21 +00:00
|
|
|
case SDLK_MODE:
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_APPLICATION:
|
2004-06-27 17:31:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static bool is_ctrl_down(SDL_Keysym const & ks)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
return ctrl_down || (ks.mod & KMOD_CTRL);
|
|
|
|
}
|
|
|
|
|
2004-06-27 17:31:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Translate key event to Mac keycode, returns -1 if no keycode was found
|
|
|
|
* and -2 if the key was recognized as a hotkey
|
|
|
|
*/
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static int kc_decode(SDL_Keysym const & ks, bool key_down)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
|
|
|
switch (ks.sym) {
|
|
|
|
case SDLK_a: return 0x00;
|
|
|
|
case SDLK_b: return 0x0b;
|
|
|
|
case SDLK_c: return 0x08;
|
|
|
|
case SDLK_d: return 0x02;
|
|
|
|
case SDLK_e: return 0x0e;
|
|
|
|
case SDLK_f: return 0x03;
|
|
|
|
case SDLK_g: return 0x05;
|
|
|
|
case SDLK_h: return 0x04;
|
|
|
|
case SDLK_i: return 0x22;
|
|
|
|
case SDLK_j: return 0x26;
|
|
|
|
case SDLK_k: return 0x28;
|
|
|
|
case SDLK_l: return 0x25;
|
|
|
|
case SDLK_m: return 0x2e;
|
|
|
|
case SDLK_n: return 0x2d;
|
|
|
|
case SDLK_o: return 0x1f;
|
|
|
|
case SDLK_p: return 0x23;
|
|
|
|
case SDLK_q: return 0x0c;
|
|
|
|
case SDLK_r: return 0x0f;
|
|
|
|
case SDLK_s: return 0x01;
|
|
|
|
case SDLK_t: return 0x11;
|
|
|
|
case SDLK_u: return 0x20;
|
|
|
|
case SDLK_v: return 0x09;
|
|
|
|
case SDLK_w: return 0x0d;
|
|
|
|
case SDLK_x: return 0x07;
|
|
|
|
case SDLK_y: return 0x10;
|
|
|
|
case SDLK_z: return 0x06;
|
|
|
|
|
|
|
|
case SDLK_1: case SDLK_EXCLAIM: return 0x12;
|
|
|
|
case SDLK_2: case SDLK_AT: return 0x13;
|
2005-03-20 23:43:17 +00:00
|
|
|
case SDLK_3: case SDLK_HASH: return 0x14;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_4: case SDLK_DOLLAR: return 0x15;
|
2005-03-20 23:43:17 +00:00
|
|
|
case SDLK_5: return 0x17;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_6: return 0x16;
|
|
|
|
case SDLK_7: return 0x1a;
|
|
|
|
case SDLK_8: return 0x1c;
|
|
|
|
case SDLK_9: return 0x19;
|
|
|
|
case SDLK_0: return 0x1d;
|
|
|
|
|
2005-03-20 23:43:17 +00:00
|
|
|
case SDLK_BACKQUOTE: return 0x0a;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_MINUS: case SDLK_UNDERSCORE: return 0x1b;
|
|
|
|
case SDLK_EQUALS: case SDLK_PLUS: return 0x18;
|
2005-03-20 23:43:17 +00:00
|
|
|
case SDLK_LEFTBRACKET: return 0x21;
|
|
|
|
case SDLK_RIGHTBRACKET: return 0x1e;
|
|
|
|
case SDLK_BACKSLASH: return 0x2a;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_SEMICOLON: case SDLK_COLON: return 0x29;
|
2005-03-20 23:43:17 +00:00
|
|
|
case SDLK_QUOTE: case SDLK_QUOTEDBL: return 0x27;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_COMMA: case SDLK_LESS: return 0x2b;
|
|
|
|
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f;
|
|
|
|
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c;
|
|
|
|
|
|
|
|
case SDLK_TAB: if (is_ctrl_down(ks)) {if (!key_down) drv->suspend(); return -2;} else return 0x30;
|
2013-02-21 12:54:45 +00:00
|
|
|
case SDLK_RETURN: if (is_ctrl_down(ks)) {if (!key_down) toggle_fullscreen = true; return -2;} else return 0x24;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_SPACE: return 0x31;
|
|
|
|
case SDLK_BACKSPACE: return 0x33;
|
|
|
|
|
|
|
|
case SDLK_DELETE: return 0x75;
|
|
|
|
case SDLK_INSERT: return 0x72;
|
|
|
|
case SDLK_HOME: case SDLK_HELP: return 0x73;
|
|
|
|
case SDLK_END: return 0x77;
|
|
|
|
case SDLK_PAGEUP: return 0x74;
|
|
|
|
case SDLK_PAGEDOWN: return 0x79;
|
|
|
|
|
|
|
|
case SDLK_LCTRL: return 0x36;
|
|
|
|
case SDLK_RCTRL: return 0x36;
|
|
|
|
case SDLK_LSHIFT: return 0x38;
|
|
|
|
case SDLK_RSHIFT: return 0x38;
|
2004-06-27 17:31:21 +00:00
|
|
|
#if (defined(__APPLE__) && defined(__MACH__))
|
|
|
|
case SDLK_LALT: return 0x3a;
|
|
|
|
case SDLK_RALT: return 0x3a;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_LGUI: return 0x37;
|
|
|
|
case SDLK_RGUI: return 0x37;
|
2004-06-27 17:31:21 +00:00
|
|
|
#else
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_LALT: return 0x37;
|
|
|
|
case SDLK_RALT: return 0x37;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_LGUI: return 0x3a;
|
|
|
|
case SDLK_RGUI: return 0x3a;
|
2004-06-27 17:31:21 +00:00
|
|
|
#endif
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_MENU: return 0x32;
|
|
|
|
case SDLK_CAPSLOCK: return 0x39;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_NUMLOCKCLEAR: return 0x47;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
case SDLK_UP: return 0x3e;
|
|
|
|
case SDLK_DOWN: return 0x3d;
|
|
|
|
case SDLK_LEFT: return 0x3b;
|
|
|
|
case SDLK_RIGHT: return 0x3c;
|
|
|
|
|
|
|
|
case SDLK_ESCAPE: if (is_ctrl_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
|
|
|
|
|
|
|
|
case SDLK_F1: if (is_ctrl_down(ks)) {if (!key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
|
|
|
|
case SDLK_F2: return 0x78;
|
|
|
|
case SDLK_F3: return 0x63;
|
|
|
|
case SDLK_F4: return 0x76;
|
|
|
|
case SDLK_F5: if (is_ctrl_down(ks)) {if (!key_down) drv->toggle_mouse_grab(); return -2;} else return 0x60;
|
|
|
|
case SDLK_F6: return 0x61;
|
|
|
|
case SDLK_F7: return 0x62;
|
|
|
|
case SDLK_F8: return 0x64;
|
|
|
|
case SDLK_F9: return 0x65;
|
|
|
|
case SDLK_F10: return 0x6d;
|
|
|
|
case SDLK_F11: return 0x67;
|
|
|
|
case SDLK_F12: return 0x6f;
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_PRINTSCREEN: return 0x69;
|
|
|
|
case SDLK_SCROLLLOCK: return 0x6b;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_PAUSE: return 0x71;
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
case SDLK_KP_0: return 0x52;
|
|
|
|
case SDLK_KP_1: return 0x53;
|
|
|
|
case SDLK_KP_2: return 0x54;
|
|
|
|
case SDLK_KP_3: return 0x55;
|
|
|
|
case SDLK_KP_4: return 0x56;
|
|
|
|
case SDLK_KP_5: return 0x57;
|
|
|
|
case SDLK_KP_6: return 0x58;
|
|
|
|
case SDLK_KP_7: return 0x59;
|
|
|
|
case SDLK_KP_8: return 0x5b;
|
|
|
|
case SDLK_KP_9: return 0x5c;
|
2004-06-23 13:47:20 +00:00
|
|
|
case SDLK_KP_PERIOD: return 0x41;
|
|
|
|
case SDLK_KP_PLUS: return 0x45;
|
|
|
|
case SDLK_KP_MINUS: return 0x4e;
|
|
|
|
case SDLK_KP_MULTIPLY: return 0x43;
|
|
|
|
case SDLK_KP_DIVIDE: return 0x4b;
|
|
|
|
case SDLK_KP_ENTER: return 0x4c;
|
|
|
|
case SDLK_KP_EQUALS: return 0x51;
|
|
|
|
}
|
|
|
|
D(bug("Unhandled SDL keysym: %d\n", ks.sym));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int event2keycode(SDL_KeyboardEvent const &ev, bool key_down)
|
|
|
|
{
|
|
|
|
return kc_decode(ev.keysym, key_down);
|
|
|
|
}
|
|
|
|
|
2015-06-30 19:01:51 +00:00
|
|
|
static void force_complete_window_refresh()
|
|
|
|
{
|
|
|
|
if (display_type == DISPLAY_WINDOW) {
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
if (use_vosf) { // VOSF refresh
|
|
|
|
LOCK_VOSF;
|
|
|
|
PFLAG_SET_ALL;
|
|
|
|
UNLOCK_VOSF;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Ensure each byte of the_buffer_copy differs from the_buffer to force a full update.
|
|
|
|
const VIDEO_MODE &mode = VideoMonitors[0]->get_current_mode();
|
|
|
|
const int len = VIDEO_MODE_ROW_BYTES * VIDEO_MODE_Y;
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
the_buffer_copy[i] = !the_buffer[i];
|
|
|
|
}
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SDL event handling
|
|
|
|
*/
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
static void scale_mouse_event_coordinates(void *userdata, SDL_Event * event)
|
|
|
|
{
|
|
|
|
if (!inner_sdl_surface || !sdl_window) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int window_width = 0;
|
|
|
|
int window_height = 0;
|
|
|
|
SDL_GetWindowSize(sdl_window, &window_width, &window_height);
|
|
|
|
if (window_width == 0 || window_height == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float scale_x = (float)inner_sdl_surface->w / (float)window_width;
|
|
|
|
float scale_y = (float)inner_sdl_surface->h / (float)window_height;
|
|
|
|
|
|
|
|
switch (event->type) {
|
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
case SDL_MOUSEBUTTONUP:
|
|
|
|
event->button.x = (int)(event->button.x * scale_x);
|
|
|
|
event->button.y = (int)(event->button.y * scale_y);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SDL_MOUSEMOTION:
|
|
|
|
event->motion.x = (int)(event->motion.x * scale_x);
|
|
|
|
event->motion.y = (int)(event->motion.y * scale_y);
|
|
|
|
event->motion.xrel = (int)(event->motion.xrel * scale_x);
|
|
|
|
event->motion.yrel = (int)(event->motion.yrel * scale_y);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
static void handle_events(void)
|
|
|
|
{
|
2004-06-23 22:37:33 +00:00
|
|
|
SDL_Event events[10];
|
|
|
|
const int n_max_events = sizeof(events) / sizeof(events[0]);
|
|
|
|
int n_events;
|
|
|
|
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
while ((n_events = SDL_PeepEvents(events, n_max_events, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) > 0) {
|
2004-06-23 22:37:33 +00:00
|
|
|
for (int i = 0; i < n_events; i++) {
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
SDL_Event & event = events[i];
|
|
|
|
|
|
|
|
// Make sure events with mouse coordinates get scaled, in case the Mac's
|
|
|
|
// display size is different than the host OS' window.
|
|
|
|
scale_mouse_event_coordinates(NULL, &events[i]);
|
|
|
|
|
2004-06-23 22:37:33 +00:00
|
|
|
switch (event.type) {
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Mouse button
|
|
|
|
case SDL_MOUSEBUTTONDOWN: {
|
|
|
|
unsigned int button = event.button.button;
|
2008-07-20 07:33:09 +00:00
|
|
|
if (button == SDL_BUTTON_LEFT)
|
|
|
|
ADBMouseDown(0);
|
|
|
|
else if (button == SDL_BUTTON_RIGHT)
|
|
|
|
ADBMouseDown(1);
|
|
|
|
else if (button == SDL_BUTTON_MIDDLE)
|
|
|
|
ADBMouseDown(2);
|
2004-06-23 13:47:20 +00:00
|
|
|
else if (button < 6) { // Wheel mouse
|
|
|
|
if (mouse_wheel_mode == 0) {
|
|
|
|
int key = (button == 5) ? 0x79 : 0x74; // Page up/down
|
|
|
|
ADBKeyDown(key);
|
|
|
|
ADBKeyUp(key);
|
|
|
|
} else {
|
|
|
|
int key = (button == 5) ? 0x3d : 0x3e; // Cursor up/down
|
|
|
|
for(int i=0; i<mouse_wheel_lines; i++) {
|
|
|
|
ADBKeyDown(key);
|
|
|
|
ADBKeyUp(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDL_MOUSEBUTTONUP: {
|
|
|
|
unsigned int button = event.button.button;
|
2008-07-20 07:33:09 +00:00
|
|
|
if (button == SDL_BUTTON_LEFT)
|
|
|
|
ADBMouseUp(0);
|
|
|
|
else if (button == SDL_BUTTON_RIGHT)
|
|
|
|
ADBMouseUp(1);
|
|
|
|
else if (button == SDL_BUTTON_MIDDLE)
|
|
|
|
ADBMouseUp(2);
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mouse moved
|
|
|
|
case SDL_MOUSEMOTION:
|
2017-07-16 11:07:08 +00:00
|
|
|
if (mouse_grabbed) {
|
|
|
|
drv->mouse_moved(event.motion.xrel, event.motion.yrel);
|
|
|
|
} else {
|
|
|
|
drv->mouse_moved(event.motion.x, event.motion.y);
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Keyboard
|
|
|
|
case SDL_KEYDOWN: {
|
|
|
|
int code = -1;
|
2004-06-27 17:31:21 +00:00
|
|
|
if (use_keycodes && !is_modifier_key(event.key)) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (event2keycode(event.key, true) != -2) // This is called to process the hotkeys
|
|
|
|
code = keycode_table[event.key.keysym.scancode & 0xff];
|
|
|
|
} else
|
|
|
|
code = event2keycode(event.key, true);
|
|
|
|
if (code >= 0) {
|
|
|
|
if (!emul_suspended) {
|
|
|
|
if (code == 0x39) { // Caps Lock pressed
|
|
|
|
if (caps_on) {
|
|
|
|
ADBKeyUp(code);
|
|
|
|
caps_on = false;
|
|
|
|
} else {
|
|
|
|
ADBKeyDown(code);
|
|
|
|
caps_on = true;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ADBKeyDown(code);
|
|
|
|
if (code == 0x36)
|
|
|
|
ctrl_down = true;
|
|
|
|
} else {
|
|
|
|
if (code == 0x31)
|
|
|
|
drv->resume(); // Space wakes us up
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SDL_KEYUP: {
|
|
|
|
int code = -1;
|
2004-06-27 17:31:21 +00:00
|
|
|
if (use_keycodes && !is_modifier_key(event.key)) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (event2keycode(event.key, false) != -2) // This is called to process the hotkeys
|
|
|
|
code = keycode_table[event.key.keysym.scancode & 0xff];
|
|
|
|
} else
|
|
|
|
code = event2keycode(event.key, false);
|
2004-06-27 17:31:21 +00:00
|
|
|
if (code >= 0) {
|
|
|
|
if (code == 0x39) { // Caps Lock released
|
|
|
|
if (caps_on) {
|
|
|
|
ADBKeyUp(code);
|
|
|
|
caps_on = false;
|
|
|
|
} else {
|
|
|
|
ADBKeyDown(code);
|
|
|
|
caps_on = true;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ADBKeyUp(code);
|
2004-06-23 13:47:20 +00:00
|
|
|
if (code == 0x36)
|
|
|
|
ctrl_down = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
|
|
|
|
case SDL_WINDOWEVENT: {
|
|
|
|
switch (event.window.event) {
|
|
|
|
// Hidden parts exposed, force complete refresh of window
|
|
|
|
case SDL_WINDOWEVENT_EXPOSED:
|
|
|
|
force_complete_window_refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Force a complete window refresh when activating, to avoid redraw artifacts otherwise.
|
|
|
|
case SDL_WINDOWEVENT_RESTORED:
|
|
|
|
force_complete_window_refresh();
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
break;
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// Window "close" widget clicked
|
|
|
|
case SDL_QUIT:
|
|
|
|
ADBKeyDown(0x7f); // Power key
|
|
|
|
ADBKeyUp(0x7f);
|
|
|
|
break;
|
2004-06-23 22:37:33 +00:00
|
|
|
}
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Window display update
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Static display update (fixed frame rate, but incremental)
|
2009-03-03 08:14:53 +00:00
|
|
|
static void update_display_static(driver_base *drv)
|
2004-06-23 13:47:20 +00:00
|
|
|
{
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
// Lock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_LockSurface(drv->s);
|
|
|
|
|
|
|
|
const VIDEO_MODE &mode = drv->mode;
|
|
|
|
|
|
|
|
memcpy(the_buffer_copy, the_buffer, the_buffer_size);
|
|
|
|
|
|
|
|
// HACK: Create a temporary surface, with which to use in color conversion
|
|
|
|
SDL_Surface * mid_surface = NULL;
|
|
|
|
switch (mode.depth) {
|
|
|
|
case VDEPTH_1BIT: {
|
|
|
|
const int pixels_per_byte = VIDEO_MODE_X / VIDEO_MODE_ROW_BYTES;
|
|
|
|
mid_surface = SDL_CreateRGBSurfaceFrom(the_buffer_copy, VIDEO_MODE_X, VIDEO_MODE_Y, 1, (VIDEO_MODE_X / pixels_per_byte), 1, 1, 1, 0);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
// Consider using Screen_blit, for other depths
|
|
|
|
|
|
|
|
default: {
|
|
|
|
printf("WARNING: Unhandled depth mode in SDL backend: %s\n", NameOfDepth(mode.depth));
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Blit to screen surface
|
|
|
|
if (mid_surface) {
|
|
|
|
SDL_BlitSurface(mid_surface, NULL, drv->s, NULL);
|
|
|
|
SDL_FreeSurface(mid_surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unlock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_UnlockSurface(drv->s);
|
|
|
|
|
|
|
|
// Refresh display
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
update_sdl_video();
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
|
|
|
|
/*
|
2004-06-23 13:47:20 +00:00
|
|
|
// Incremental update code
|
2015-08-06 08:12:43 +00:00
|
|
|
int wide = 0, high = 0;
|
|
|
|
uint32 x1, x2, y1, y2;
|
2004-06-24 15:25:57 +00:00
|
|
|
const VIDEO_MODE &mode = drv->mode;
|
|
|
|
int bytes_per_row = VIDEO_MODE_ROW_BYTES;
|
2004-06-23 13:47:20 +00:00
|
|
|
uint8 *p, *p2;
|
|
|
|
|
|
|
|
// Check for first line from top and first line from bottom that have changed
|
|
|
|
y1 = 0;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = 0; j < VIDEO_MODE_Y; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) {
|
|
|
|
y1 = j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
y2 = y1 - 1;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = VIDEO_MODE_Y; j-- > y1; ) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (memcmp(&the_buffer[j * bytes_per_row], &the_buffer_copy[j * bytes_per_row], bytes_per_row)) {
|
|
|
|
y2 = j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
high = y2 - y1 + 1;
|
|
|
|
|
|
|
|
// Check for first column from left and first column from right that have changed
|
|
|
|
if (high) {
|
2015-08-06 08:12:43 +00:00
|
|
|
if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
|
2004-06-23 13:47:20 +00:00
|
|
|
const int src_bytes_per_row = bytes_per_row;
|
|
|
|
const int dst_bytes_per_row = drv->s->pitch;
|
2004-06-24 15:25:57 +00:00
|
|
|
const int pixels_per_byte = VIDEO_MODE_X / src_bytes_per_row;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
x1 = VIDEO_MODE_X / pixels_per_byte;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p = &the_buffer[j * bytes_per_row];
|
|
|
|
p2 = &the_buffer_copy[j * bytes_per_row];
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 i = 0; i < x1; i++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (*p != *p2) {
|
|
|
|
x1 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++; p2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x2 = x1;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p = &the_buffer[j * bytes_per_row];
|
|
|
|
p2 = &the_buffer_copy[j * bytes_per_row];
|
|
|
|
p += bytes_per_row;
|
|
|
|
p2 += bytes_per_row;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 i = (VIDEO_MODE_X / pixels_per_byte); i > x2; i--) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p--; p2--;
|
|
|
|
if (*p != *p2) {
|
|
|
|
x2 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x1 *= pixels_per_byte;
|
|
|
|
x2 *= pixels_per_byte;
|
|
|
|
wide = (x2 - x1 + pixels_per_byte - 1) & -pixels_per_byte;
|
|
|
|
|
|
|
|
// Update copy of the_buffer
|
|
|
|
if (high && wide) {
|
|
|
|
|
|
|
|
// Lock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_LockSurface(drv->s);
|
|
|
|
|
|
|
|
// Blit to screen surface
|
|
|
|
int si = y1 * src_bytes_per_row + (x1 / pixels_per_byte);
|
|
|
|
int di = y1 * dst_bytes_per_row + x1;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
memcpy(the_buffer_copy + si, the_buffer + si, wide / pixels_per_byte);
|
|
|
|
Screen_blit((uint8 *)drv->s->pixels + di, the_buffer + si, wide / pixels_per_byte);
|
|
|
|
si += src_bytes_per_row;
|
|
|
|
di += dst_bytes_per_row;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unlock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_UnlockSurface(drv->s);
|
|
|
|
|
|
|
|
// Refresh display
|
|
|
|
SDL_UpdateRect(drv->s, x1, y1, wide, high);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2004-06-24 15:25:57 +00:00
|
|
|
const int bytes_per_pixel = VIDEO_MODE_ROW_BYTES / VIDEO_MODE_X;
|
2009-03-03 08:14:53 +00:00
|
|
|
const int dst_bytes_per_row = drv->s->pitch;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
x1 = VIDEO_MODE_X;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p = &the_buffer[j * bytes_per_row];
|
|
|
|
p2 = &the_buffer_copy[j * bytes_per_row];
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 i = 0; i < x1 * bytes_per_pixel; i++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
if (*p != *p2) {
|
|
|
|
x1 = i / bytes_per_pixel;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
p++; p2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x2 = x1;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p = &the_buffer[j * bytes_per_row];
|
|
|
|
p2 = &the_buffer_copy[j * bytes_per_row];
|
|
|
|
p += bytes_per_row;
|
|
|
|
p2 += bytes_per_row;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 i = VIDEO_MODE_X * bytes_per_pixel; i > x2 * bytes_per_pixel; i--) {
|
2004-06-23 13:47:20 +00:00
|
|
|
p--;
|
|
|
|
p2--;
|
|
|
|
if (*p != *p2) {
|
|
|
|
x2 = i / bytes_per_pixel;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wide = x2 - x1;
|
|
|
|
|
|
|
|
// Update copy of the_buffer
|
|
|
|
if (high && wide) {
|
|
|
|
|
|
|
|
// Lock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_LockSurface(drv->s);
|
|
|
|
|
|
|
|
// Blit to screen surface
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y1; j <= y2; j++) {
|
|
|
|
uint32 i = j * bytes_per_row + x1 * bytes_per_pixel;
|
2009-03-03 08:14:53 +00:00
|
|
|
int dst_i = j * dst_bytes_per_row + x1 * bytes_per_pixel;
|
2004-06-23 13:47:20 +00:00
|
|
|
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * wide);
|
2009-03-03 08:14:53 +00:00
|
|
|
Screen_blit((uint8 *)drv->s->pixels + dst_i, the_buffer + i, bytes_per_pixel * wide);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unlock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_UnlockSurface(drv->s);
|
|
|
|
|
|
|
|
// Refresh display
|
|
|
|
SDL_UpdateRect(drv->s, x1, y1, wide, high);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
*/
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 07:51:32 +00:00
|
|
|
// Static display update (fixed frame rate, bounding boxes based)
|
|
|
|
// XXX use NQD bounding boxes to help detect dirty areas?
|
2009-03-03 08:14:53 +00:00
|
|
|
static void update_display_static_bbox(driver_base *drv)
|
2006-05-11 07:51:32 +00:00
|
|
|
{
|
|
|
|
const VIDEO_MODE &mode = drv->mode;
|
|
|
|
|
|
|
|
// Allocate bounding boxes for SDL_UpdateRects()
|
2015-08-06 08:12:43 +00:00
|
|
|
const uint32 N_PIXELS = 64;
|
|
|
|
const uint32 n_x_boxes = (VIDEO_MODE_X + N_PIXELS - 1) / N_PIXELS;
|
|
|
|
const uint32 n_y_boxes = (VIDEO_MODE_Y + N_PIXELS - 1) / N_PIXELS;
|
2006-05-11 07:51:32 +00:00
|
|
|
SDL_Rect *boxes = (SDL_Rect *)alloca(sizeof(SDL_Rect) * n_x_boxes * n_y_boxes);
|
2015-08-06 08:12:43 +00:00
|
|
|
uint32 nr_boxes = 0;
|
2006-05-11 07:51:32 +00:00
|
|
|
|
|
|
|
// Lock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_LockSurface(drv->s);
|
|
|
|
|
|
|
|
// Update the surface from Mac screen
|
2015-08-06 08:12:43 +00:00
|
|
|
const uint32 bytes_per_row = VIDEO_MODE_ROW_BYTES;
|
|
|
|
const uint32 bytes_per_pixel = bytes_per_row / VIDEO_MODE_X;
|
|
|
|
const uint32 dst_bytes_per_row = drv->s->pitch;
|
|
|
|
for (uint32 y = 0; y < VIDEO_MODE_Y; y += N_PIXELS) {
|
|
|
|
uint32 h = N_PIXELS;
|
2006-05-11 07:51:32 +00:00
|
|
|
if (h > VIDEO_MODE_Y - y)
|
|
|
|
h = VIDEO_MODE_Y - y;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 x = 0; x < VIDEO_MODE_X; x += N_PIXELS) {
|
|
|
|
uint32 w = N_PIXELS;
|
2006-05-11 07:51:32 +00:00
|
|
|
if (w > VIDEO_MODE_X - x)
|
|
|
|
w = VIDEO_MODE_X - x;
|
|
|
|
const int xs = w * bytes_per_pixel;
|
|
|
|
const int xb = x * bytes_per_pixel;
|
|
|
|
bool dirty = false;
|
2015-08-06 08:12:43 +00:00
|
|
|
for (uint32 j = y; j < (y + h); j++) {
|
|
|
|
const uint32 yb = j * bytes_per_row;
|
|
|
|
const uint32 dst_yb = j * dst_bytes_per_row;
|
2006-05-11 07:51:32 +00:00
|
|
|
if (memcmp(&the_buffer[yb + xb], &the_buffer_copy[yb + xb], xs) != 0) {
|
|
|
|
memcpy(&the_buffer_copy[yb + xb], &the_buffer[yb + xb], xs);
|
2009-03-03 08:14:53 +00:00
|
|
|
Screen_blit((uint8 *)drv->s->pixels + dst_yb + xb, the_buffer + yb + xb, xs);
|
2006-05-11 07:51:32 +00:00
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dirty) {
|
|
|
|
boxes[nr_boxes].x = x;
|
|
|
|
boxes[nr_boxes].y = y;
|
|
|
|
boxes[nr_boxes].w = w;
|
|
|
|
boxes[nr_boxes].h = h;
|
|
|
|
nr_boxes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unlock surface, if required
|
|
|
|
if (SDL_MUSTLOCK(drv->s))
|
|
|
|
SDL_UnlockSurface(drv->s);
|
|
|
|
|
|
|
|
// Refresh display
|
|
|
|
if (nr_boxes)
|
use SDL 2.0.5+, rather than SDL 1.x
This change may end up being a bit slower on some systems, as the SDL backend will now render its content to two, new, SDL_Surfaces: one of which is in the guest OS' resolution, the other of which is application defined.
SDL2's SDL_Render API is used, which exposes some rudimentary elements of GPU + texture-based programming. Basilisk II now maintains a single 'SDL_Texture' object, which is an SDL representation of a GPU texture. The 'outer' surface will be used to update this texture, as requests to redraw are made.
TODO: look into removing the 'outer' SDL surface, and see if we can just copy the 'inner' surface to the SDL_Texture.
TODO: the entire SDL_Texture is updated, any time a request is made to draw. Look into minimizing this a bit.
2017-07-23 00:29:30 +00:00
|
|
|
update_sdl_video();
|
Basilisk II compiles on Xcode 8, as a 64-bit Mac app
SDL 1.x is used for display, rather than Mac OS X specific backend. If time permits, I'll port it to SDL 2, if only to reduce Basilisk's overall code foot-print.
Lots of features are apt to be disabled, as many 'dummy' backends were used.
Video-depths other than 1-bit or 32-bit are untested, and in some cases (4-bit, at least) are currently non-functional. This is due to a partial re-write of the SDL backend's blitting code, which was non-functional when low-bit-depths were used.
The SDL backend was also rewired, on OSX, to not attempt to align the display buffer on page-boundaries. So far, this doesn't seem to cause any notice-able problems, however, that's only using limited knowledge and testing (System 7.5.x does boot and display at 640x480, though!). The original display-buffer allocation code was failing to run, in some cases.
Preferences are, on Mac, currently hardcoded to be accessed at /tmp/BasiliskII/BasiliskII_Prefs. The folder, "/tmp/BasiliskII/", may be a symbolic link to elsewhere, though.
2017-07-22 21:43:42 +00:00
|
|
|
}
|
2006-05-11 07:51:32 +00:00
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
// We suggest the compiler to inline the next two functions so that it
|
|
|
|
// may specialise the code according to the current screen depth and
|
|
|
|
// display type. A clever compiler would do that job by itself though...
|
|
|
|
|
|
|
|
// NOTE: update_display_vosf is inlined too
|
|
|
|
|
|
|
|
static inline void possibly_quit_dga_mode()
|
|
|
|
{
|
|
|
|
// Quit DGA mode if requested (something terrible has happened and we
|
|
|
|
// want to give control back to the user)
|
|
|
|
if (quit_full_screen) {
|
|
|
|
quit_full_screen = false;
|
|
|
|
delete drv;
|
|
|
|
drv = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void possibly_ungrab_mouse()
|
|
|
|
{
|
|
|
|
// Ungrab mouse if requested (something terrible has happened and we
|
|
|
|
// want to give control back to the user)
|
|
|
|
if (quit_full_screen) {
|
|
|
|
quit_full_screen = false;
|
|
|
|
if (drv)
|
|
|
|
drv->ungrab_mouse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void handle_palette_changes(void)
|
|
|
|
{
|
|
|
|
LOCK_PALETTE;
|
|
|
|
|
|
|
|
if (sdl_palette_changed) {
|
|
|
|
sdl_palette_changed = false;
|
|
|
|
drv->update_palette();
|
|
|
|
}
|
|
|
|
|
|
|
|
UNLOCK_PALETTE;
|
|
|
|
}
|
|
|
|
|
2009-03-03 08:14:53 +00:00
|
|
|
static void video_refresh_window_static(void);
|
|
|
|
|
2004-06-23 13:47:20 +00:00
|
|
|
static void video_refresh_dga(void)
|
|
|
|
{
|
|
|
|
// Quit DGA mode if requested
|
|
|
|
possibly_quit_dga_mode();
|
2009-03-03 08:14:53 +00:00
|
|
|
video_refresh_window_static();
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
#if REAL_ADDRESSING || DIRECT_ADDRESSING
|
|
|
|
static void video_refresh_dga_vosf(void)
|
|
|
|
{
|
|
|
|
// Quit DGA mode if requested
|
|
|
|
possibly_quit_dga_mode();
|
|
|
|
|
|
|
|
// Update display (VOSF variant)
|
2015-08-06 08:12:43 +00:00
|
|
|
static uint32 tick_counter = 0;
|
2004-06-23 13:47:20 +00:00
|
|
|
if (++tick_counter >= frame_skip) {
|
|
|
|
tick_counter = 0;
|
|
|
|
if (mainBuffer.dirty) {
|
|
|
|
LOCK_VOSF;
|
2013-04-22 09:26:44 +00:00
|
|
|
update_display_dga_vosf(drv);
|
2004-06-23 13:47:20 +00:00
|
|
|
UNLOCK_VOSF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void video_refresh_window_vosf(void)
|
|
|
|
{
|
|
|
|
// Ungrab mouse if requested
|
|
|
|
possibly_ungrab_mouse();
|
|
|
|
|
|
|
|
// Update display (VOSF variant)
|
2015-08-06 08:12:43 +00:00
|
|
|
static uint32 tick_counter = 0;
|
2004-06-23 13:47:20 +00:00
|
|
|
if (++tick_counter >= frame_skip) {
|
|
|
|
tick_counter = 0;
|
|
|
|
if (mainBuffer.dirty) {
|
|
|
|
LOCK_VOSF;
|
2013-04-22 09:26:44 +00:00
|
|
|
update_display_window_vosf(drv);
|
2004-06-23 13:47:20 +00:00
|
|
|
UNLOCK_VOSF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // def ENABLE_VOSF
|
|
|
|
|
|
|
|
static void video_refresh_window_static(void)
|
|
|
|
{
|
|
|
|
// Ungrab mouse if requested
|
|
|
|
possibly_ungrab_mouse();
|
|
|
|
|
|
|
|
// Update display (static variant)
|
2015-08-06 08:12:43 +00:00
|
|
|
static uint32 tick_counter = 0;
|
2004-06-23 13:47:20 +00:00
|
|
|
if (++tick_counter >= frame_skip) {
|
|
|
|
tick_counter = 0;
|
2006-05-11 07:51:32 +00:00
|
|
|
const VIDEO_MODE &mode = drv->mode;
|
|
|
|
if ((int)VIDEO_MODE_DEPTH >= VIDEO_DEPTH_8BIT)
|
2009-03-03 08:14:53 +00:00
|
|
|
update_display_static_bbox(drv);
|
2006-05-11 07:51:32 +00:00
|
|
|
else
|
2009-03-03 08:14:53 +00:00
|
|
|
update_display_static(drv);
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Thread for screen refresh, input handling etc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void VideoRefreshInit(void)
|
|
|
|
{
|
|
|
|
// TODO: set up specialised 8bpp VideoRefresh handlers ?
|
|
|
|
if (display_type == DISPLAY_SCREEN) {
|
|
|
|
#if ENABLE_VOSF && (REAL_ADDRESSING || DIRECT_ADDRESSING)
|
|
|
|
if (use_vosf)
|
|
|
|
video_refresh = video_refresh_dga_vosf;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
video_refresh = video_refresh_dga;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef ENABLE_VOSF
|
|
|
|
if (use_vosf)
|
|
|
|
video_refresh = video_refresh_window_vosf;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
video_refresh = video_refresh_window_static;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-14 22:35:42 +00:00
|
|
|
static inline void do_video_refresh(void)
|
|
|
|
{
|
|
|
|
// Handle SDL events
|
|
|
|
handle_events();
|
|
|
|
|
|
|
|
// Update display
|
|
|
|
video_refresh();
|
|
|
|
|
|
|
|
|
|
|
|
// Set new palette if it was changed
|
|
|
|
handle_palette_changes();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function is called on non-threaded platforms from a timer interrupt
|
|
|
|
void VideoRefresh(void)
|
|
|
|
{
|
|
|
|
// We need to check redraw_thread_active to inhibit refreshed during
|
|
|
|
// mode changes on non-threaded platforms
|
|
|
|
if (!redraw_thread_active)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Process pending events and update display
|
|
|
|
do_video_refresh();
|
|
|
|
}
|
|
|
|
|
2004-06-24 15:25:57 +00:00
|
|
|
const int VIDEO_REFRESH_HZ = 60;
|
|
|
|
const int VIDEO_REFRESH_DELAY = 1000000 / VIDEO_REFRESH_HZ;
|
|
|
|
|
2005-06-14 22:35:42 +00:00
|
|
|
#ifndef USE_CPU_EMUL_SERVICES
|
2004-06-23 13:47:20 +00:00
|
|
|
static int redraw_func(void *arg)
|
|
|
|
{
|
|
|
|
uint64 start = GetTicks_usec();
|
|
|
|
int64 ticks = 0;
|
2004-06-24 15:25:57 +00:00
|
|
|
uint64 next = GetTicks_usec() + VIDEO_REFRESH_DELAY;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
|
|
|
while (!redraw_thread_cancel) {
|
|
|
|
|
|
|
|
// Wait
|
2004-06-24 15:25:57 +00:00
|
|
|
next += VIDEO_REFRESH_DELAY;
|
2015-08-06 08:12:43 +00:00
|
|
|
int32 delay = int32(next - GetTicks_usec());
|
2004-06-24 15:25:57 +00:00
|
|
|
if (delay > 0)
|
|
|
|
Delay_usec(delay);
|
|
|
|
else if (delay < -VIDEO_REFRESH_DELAY)
|
|
|
|
next = GetTicks_usec();
|
|
|
|
ticks++;
|
2004-06-23 13:47:20 +00:00
|
|
|
|
2004-11-28 19:31:11 +00:00
|
|
|
// Pause if requested (during video mode switches)
|
|
|
|
if (thread_stop_req) {
|
|
|
|
thread_stop_ack = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-06-14 22:35:42 +00:00
|
|
|
// Process pending events and update display
|
|
|
|
do_video_refresh();
|
2004-06-23 13:47:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint64 end = GetTicks_usec();
|
|
|
|
D(bug("%lld refreshes in %lld usec = %f refreshes/sec\n", ticks, end - start, ticks * 1000000.0 / (end - start)));
|
|
|
|
return 0;
|
|
|
|
}
|
2005-06-14 22:35:42 +00:00
|
|
|
#endif
|
2006-05-13 16:58:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record dirty area from NQD
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef SHEEPSHAVER
|
|
|
|
void video_set_dirty_area(int x, int y, int w, int h)
|
|
|
|
{
|
2011-12-28 20:22:25 +00:00
|
|
|
#ifdef ENABLE_VOSF
|
2006-05-13 16:58:44 +00:00
|
|
|
const VIDEO_MODE &mode = drv->mode;
|
2015-08-06 08:12:43 +00:00
|
|
|
const unsigned screen_width = VIDEO_MODE_X;
|
|
|
|
const unsigned screen_height = VIDEO_MODE_Y;
|
|
|
|
const unsigned bytes_per_row = VIDEO_MODE_ROW_BYTES;
|
2006-05-13 16:58:44 +00:00
|
|
|
|
|
|
|
if (use_vosf) {
|
2006-05-14 08:32:05 +00:00
|
|
|
vosf_set_dirty_area(x, y, w, h, screen_width, screen_height, bytes_per_row);
|
2006-05-13 16:58:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// XXX handle dirty bounding boxes for non-VOSF modes
|
|
|
|
}
|
|
|
|
#endif
|