diff -ruwN source/configure.in source-new/configure.in --- source/configure.in 2018-10-31 09:07:22.000000000 -0600 +++ source-new/configure.in 2018-12-10 14:20:34.303368238 -0700 @@ -2282,6 +2282,20 @@ fi } +dnl Set up the Orbital video driver. +CheckOrbitalVideo() +{ + AC_ARG_ENABLE(video-orbital, +AC_HELP_STRING([--enable-video-orbital], [use orbital video driver [[default=yes]]]), + , enable_video_orbital=yes) + if test x$enable_video_orbital = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_ORBITAL) + SOURCES="$SOURCES $srcdir/src/video/orbital/*.c" + SDL_LIBS="$SDL_LIBS -Wl,--gc-sections -lorbital" + have_video=yes + fi +} + dnl Set up the QNX video driver if enabled CheckQNXVideo() { @@ -3362,7 +3376,7 @@ dnl Set up the configuration based on the host platform! case "$host" in - *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*) + *-*-linux*|*-*-uclinux*|*-*-redox*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*) case "$host" in *-*-android*) # Android @@ -3383,6 +3397,7 @@ ;; *-*-linux*) ARCH=linux ;; *-*-uclinux*) ARCH=linux ;; + *-*-redox*) ARCH=redox ;; *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;; *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;; *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;; @@ -3404,6 +3419,7 @@ CheckVisibilityHidden CheckDeclarationAfterStatement CheckDummyVideo + CheckOrbitalVideo CheckDiskAudio CheckDummyAudio CheckDLOPEN diff -ruwN source/include/SDL_config.h.in source-new/include/SDL_config.h.in --- source/include/SDL_config.h.in 2018-10-31 09:07:22.000000000 -0600 +++ source-new/include/SDL_config.h.in 2018-12-10 14:21:20.848804696 -0700 @@ -320,6 +320,7 @@ #undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC #undef SDL_VIDEO_DRIVER_DUMMY +#undef SDL_VIDEO_DRIVER_ORBITAL #undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_WAYLAND #undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH diff -ruwN source/src/dynapi/SDL_dynapi.h source-new/src/dynapi/SDL_dynapi.h --- source/src/dynapi/SDL_dynapi.h 2018-10-31 09:07:22.000000000 -0600 +++ source-new/src/dynapi/SDL_dynapi.h 2018-12-10 14:27:37.746233683 -0700 @@ -55,6 +55,8 @@ #define SDL_DYNAMIC_API 0 #elif defined(__clang_analyzer__) #define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ +#elif defined(__redox__) +#define SDL_DYNAMIC_API 0 #endif /* everyone else. This is where we turn on the API if nothing forced it off. */ diff -ruwN source/src/video/orbital/SDL_orbitalevents.c source-new/src/video/orbital/SDL_orbitalevents.c --- source/src/video/orbital/SDL_orbitalevents.c 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalevents.c 2018-12-10 14:40:45.587655256 -0700 @@ -0,0 +1,197 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL.h" +#include "../../events/SDL_sysevents.h" +#include "../../events/SDL_events_c.h" + +#include +#include "SDL_orbitalvideo.h" +#include "SDL_orbitalevents_c.h" + +#include + +static SDL_Keycode keymap[128]; + +/* Static variables so only changes are reported */ +static bool last_button_left = false; +static bool last_button_middle = false; +static bool last_button_right = false; + +void ORBITAL_PumpEvents(_THIS) +{ + SDL_Keysym keysym; + + void* event_iter = orb_window_events(this->hidden->window); + OrbEventOption oeo = orb_events_next(event_iter); + + while (oeo.tag != OrbEventOption_None) { + switch (oeo.tag) { + case OrbEventOption_Key: + keysym.unicode = oeo.key.character; + keysym.scancode = oeo.key.scancode; + keysym.sym = keymap[oeo.key.scancode]; + keysym.mod = KMOD_NONE; + + SDL_PrivateKeyboard(oeo.key.pressed ? SDL_PRESSED : SDL_RELEASED, &keysym); + break; + case OrbEventOption_Mouse: + SDL_PrivateMouseMotion(0, 0, oeo.mouse.x, oeo.mouse.y); + break; + case OrbEventOption_Button: + if (oeo.button.left ^ last_button_left) + SDL_PrivateMouseButton(oeo.button.left ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); + if (oeo.button.middle ^ last_button_middle) + SDL_PrivateMouseButton(oeo.button.middle ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); + if (oeo.button.right ^ last_button_right) + SDL_PrivateMouseButton(oeo.button.right ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); + + last_button_left = oeo.button.left; + last_button_middle = oeo.button.middle; + last_button_right = oeo.button.right; + break; + case OrbEventOption_Scroll: + if (oeo.scroll.y > 0) { + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELUP, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELUP, 0, 0); + } else if (oeo.scroll.y < 0) { + SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_WHEELDOWN, 0, 0); + SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_WHEELDOWN, 0, 0); + } + break; + case OrbEventOption_Quit: + SDL_PrivateQuit(); + break; + case OrbEventOption_Focus: + SDL_PrivateAppActive(oeo.focus.focused, SDL_APPMOUSEFOCUS); + break; + case OrbEventOption_Move: + // oeo.move.x, oeo.move.y + break; + case OrbEventOption_Resize: + SDL_PrivateResize(oeo.resize.width, oeo.resize.height); + break; + case OrbEventOption_Screen: + // oeo.screen.width, oeo.screen.height + break; + case OrbEventOption_Unknown: + // oeo.unknown.code, oeo.unknown.a, oeo.unknown.b + break; + default: + break; + } + + oeo = orb_events_next(event_iter); + } + + orb_events_destroy(event_iter); +} + +void ORBITAL_InitOSKeymap(_THIS) +{ + int i; + for ( i = 0; i < SDL_arraysize(keymap); ++i ) + keymap[i] = SDLK_UNKNOWN; + + keymap[ORB_KEY_ESC] = SDLK_ESCAPE; + keymap[ORB_KEY_1] = SDLK_1; + keymap[ORB_KEY_2] = SDLK_2; + keymap[ORB_KEY_3] = SDLK_3; + keymap[ORB_KEY_4] = SDLK_4; + keymap[ORB_KEY_5] = SDLK_5; + keymap[ORB_KEY_6] = SDLK_6; + keymap[ORB_KEY_7] = SDLK_7; + keymap[ORB_KEY_8] = SDLK_8; + keymap[ORB_KEY_9] = SDLK_9; + keymap[ORB_KEY_0] = SDLK_0; + keymap[ORB_KEY_MINUS] = SDLK_MINUS; + keymap[ORB_KEY_EQUALS] = SDLK_EQUALS; + keymap[ORB_KEY_BKSP] = SDLK_BACKSPACE; + keymap[ORB_KEY_TAB] = SDLK_TAB; + keymap[ORB_KEY_Q] = SDLK_q; + keymap[ORB_KEY_W] = SDLK_w; + keymap[ORB_KEY_E] = SDLK_e; + keymap[ORB_KEY_R] = SDLK_r; + keymap[ORB_KEY_T] = SDLK_t; + keymap[ORB_KEY_Y] = SDLK_y; + keymap[ORB_KEY_U] = SDLK_u; + keymap[ORB_KEY_I] = SDLK_i; + keymap[ORB_KEY_O] = SDLK_o; + keymap[ORB_KEY_P] = SDLK_p; + keymap[ORB_KEY_BRACE_OPEN] = SDLK_LEFTBRACKET; + keymap[ORB_KEY_BRACE_CLOSE] = SDLK_RIGHTBRACKET; + keymap[ORB_KEY_ENTER] = SDLK_RETURN; + keymap[ORB_KEY_CTRL] = SDLK_LCTRL; + keymap[ORB_KEY_A] = SDLK_a; + keymap[ORB_KEY_S] = SDLK_s; + keymap[ORB_KEY_D] = SDLK_d; + keymap[ORB_KEY_F] = SDLK_f; + keymap[ORB_KEY_G] = SDLK_g; + keymap[ORB_KEY_H] = SDLK_h; + keymap[ORB_KEY_J] = SDLK_j; + keymap[ORB_KEY_K] = SDLK_k; + keymap[ORB_KEY_L] = SDLK_l; + keymap[ORB_KEY_SEMICOLON] = SDLK_SEMICOLON; + keymap[ORB_KEY_QUOTE] = SDLK_QUOTE; + keymap[ORB_KEY_TICK] = SDLK_BACKQUOTE; + keymap[ORB_KEY_LEFT_SHIFT] = SDLK_LSHIFT; + keymap[ORB_KEY_RIGHT_SHIFT] = SDLK_RSHIFT; + keymap[ORB_KEY_BACKSLASH] = SDLK_BACKSLASH; + keymap[ORB_KEY_Z] = SDLK_z; + keymap[ORB_KEY_X] = SDLK_x; + keymap[ORB_KEY_C] = SDLK_c; + keymap[ORB_KEY_V] = SDLK_v; + keymap[ORB_KEY_B] = SDLK_b; + keymap[ORB_KEY_N] = SDLK_n; + keymap[ORB_KEY_M] = SDLK_m; + keymap[ORB_KEY_COMMA] = SDLK_COMMA; + keymap[ORB_KEY_PERIOD] = SDLK_PERIOD; + keymap[ORB_KEY_SLASH] = SDLK_SLASH; + keymap[ORB_KEY_ALT] = SDLK_LALT; + keymap[ORB_KEY_SPACE] = SDLK_SPACE; + keymap[ORB_KEY_CAPS] = SDLK_CAPSLOCK; + keymap[ORB_KEY_F1] = SDLK_F1; + keymap[ORB_KEY_F2] = SDLK_F2; + keymap[ORB_KEY_F3] = SDLK_F3; + keymap[ORB_KEY_F4] = SDLK_F4; + keymap[ORB_KEY_F5] = SDLK_F5; + keymap[ORB_KEY_F6] = SDLK_F6; + keymap[ORB_KEY_F7] = SDLK_F7; + keymap[ORB_KEY_F8] = SDLK_F8; + keymap[ORB_KEY_F9] = SDLK_F9; + keymap[ORB_KEY_F10] = SDLK_F10; + keymap[ORB_KEY_F11] = SDLK_F11; + keymap[ORB_KEY_F12] = SDLK_F12; + keymap[ORB_KEY_HOME] = SDLK_HOME; + keymap[ORB_KEY_UP] = SDLK_UP; + keymap[ORB_KEY_PGUP] = SDLK_PAGEUP; + keymap[ORB_KEY_LEFT] = SDLK_LEFT; + keymap[ORB_KEY_RIGHT] = SDLK_RIGHT; + keymap[ORB_KEY_END] = SDLK_END; + keymap[ORB_KEY_DOWN] = SDLK_DOWN; + keymap[ORB_KEY_PGDN] = SDLK_PAGEDOWN; + keymap[ORB_KEY_INSERT] = SDLK_INSERT; + keymap[ORB_KEY_DEL] = SDLK_DELETE; +} + +/* end of SDL_orbitalevents.c ... */ diff -ruwN source/src/video/orbital/SDL_orbitalevents_c.h source-new/src/video/orbital/SDL_orbitalevents_c.h --- source/src/video/orbital/SDL_orbitalevents_c.h 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalevents_c.h 2018-12-10 14:30:44.441918559 -0700 @@ -0,0 +1,32 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_orbitalvideo.h" + +/* Variables and functions exported by SDL_sysevents.c to other parts + of the native video subsystem (SDL_sysvideo.c) +*/ +extern void ORBITAL_InitOSKeymap(_THIS); +extern void ORBITAL_PumpEvents(_THIS); + +/* end of SDL_orbitalevents_c.h ... */ diff -ruwN source/src/video/orbital/SDL_orbitalmouse.c source-new/src/video/orbital/SDL_orbitalmouse.c --- source/src/video/orbital/SDL_orbitalmouse.c 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalmouse.c 2018-12-10 14:30:44.441918559 -0700 @@ -0,0 +1,33 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_mouse.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_orbitalmouse_c.h" + + +/* The implementation dependent data for the window manager cursor */ +struct WMcursor { + int unused; +}; diff -ruwN source/src/video/orbital/SDL_orbitalmouse_c.h source-new/src/video/orbital/SDL_orbitalmouse_c.h --- source/src/video/orbital/SDL_orbitalmouse_c.h 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalmouse_c.h 2018-12-10 14:30:44.441918559 -0700 @@ -0,0 +1,26 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_orbitalvideo.h" + +/* Functions to be exported */ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.c source-new/src/video/orbital/SDL_orbitalvideo.c --- source/src/video/orbital/SDL_orbitalvideo.c 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalvideo.c 2018-12-10 14:30:44.441918559 -0700 @@ -0,0 +1,252 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* Orbital SDL video driver implementation + * + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. + * Repurposed to ORBITAL by Jeremy Soller. + */ + +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include +#include "SDL_orbitalvideo.h" +#include "SDL_orbitalevents_c.h" +#include "SDL_orbitalmouse_c.h" + +#include +#include +#include +#include + +#define ORBITALVID_DRIVER_NAME "orbital" + +/* Initialization/Query functions */ +static int ORBITAL_VideoInit(_THIS, SDL_PixelFormat *vformat); +static SDL_Rect **ORBITAL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); +static SDL_Surface *ORBITAL_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); +static int ORBITAL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); +static void ORBITAL_VideoQuit(_THIS); +static void ORBITAL_SetCaption(_THIS, const char *title, const char *icon); + +/* Hardware surface functions */ +static int ORBITAL_AllocHWSurface(_THIS, SDL_Surface *surface); +static int ORBITAL_LockHWSurface(_THIS, SDL_Surface *surface); +static void ORBITAL_UnlockHWSurface(_THIS, SDL_Surface *surface); +static void ORBITAL_FreeHWSurface(_THIS, SDL_Surface *surface); + +/* etc. */ +static void ORBITAL_UpdateRects(_THIS, int numrects, SDL_Rect *rects); + +/* ORBITAL driver bootstrap functions */ + +static int ORBITAL_Available(void) +{ + return(1); +} + +static void ORBITAL_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->hidden); + SDL_free(device); +} + +static SDL_VideoDevice *ORBITAL_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *) + SDL_malloc((sizeof *device->hidden)); + } + if ( (device == NULL) || (device->hidden == NULL) ) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return(0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + /* Set the function pointers */ + device->VideoInit = ORBITAL_VideoInit; + device->ListModes = ORBITAL_ListModes; + device->SetVideoMode = ORBITAL_SetVideoMode; + device->CreateYUVOverlay = NULL; + device->SetColors = ORBITAL_SetColors; + device->UpdateRects = ORBITAL_UpdateRects; + device->VideoQuit = ORBITAL_VideoQuit; + device->AllocHWSurface = ORBITAL_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = ORBITAL_LockHWSurface; + device->UnlockHWSurface = ORBITAL_UnlockHWSurface; + device->FlipHWSurface = NULL; + device->FreeHWSurface = ORBITAL_FreeHWSurface; + device->SetCaption = ORBITAL_SetCaption; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GrabInput = NULL; + device->GetWMInfo = NULL; + device->InitOSKeymap = ORBITAL_InitOSKeymap; + device->PumpEvents = ORBITAL_PumpEvents; + + device->free = ORBITAL_DeleteDevice; + + return device; +} + +VideoBootStrap ORBITAL_bootstrap = { + ORBITALVID_DRIVER_NAME, "SDL orbital video driver", + ORBITAL_Available, ORBITAL_CreateDevice +}; + + +int ORBITAL_VideoInit(_THIS, SDL_PixelFormat *vformat) +{ + fprintf(stderr, "WARNING: You are using the SDL orbital video driver!\n"); + + /* Determine the screen depth (use default 32-bit depth) */ + /* we change this during the SDL_SetVideoMode implementation... */ + vformat->BitsPerPixel = 32; + vformat->BytesPerPixel = 4; + + /* We're done! */ + return(0); +} + +SDL_Rect **ORBITAL_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) +{ + if (format->BitsPerPixel != 32) + return NULL; + + return (SDL_Rect **) -1; +} + +SDL_Surface *ORBITAL_SetVideoMode(_THIS, SDL_Surface *current, + int width, int height, int bpp, Uint32 flags) +{ + if ( bpp != 32 ) { + SDL_SetError("Unsupported color depth - must use 32-bits per pixel"); + return(NULL); + } + + if (this->hidden->window) { + orb_window_set_size(this->hidden->window, width, height); + } else { + uint32_t orb_flags = ORB_WINDOW_ASYNC; + if (flags & SDL_RESIZABLE) + orb_flags |= ORB_WINDOW_RESIZABLE; + + this->hidden->window = orb_window_new_flags(-1, -1, width, height, "SDL", orb_flags); + if (!this->hidden->window) { + SDL_SetError("Couldn't create window for requested mode"); + return(NULL); + } + } + + fprintf(stderr, "Setting mode %dx%d@%d\n", width, height, bpp); + + /* Allocate the new pixel format for the screen */ + if ( ! SDL_ReallocFormat(current, bpp, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000) ) { + orb_window_destroy(this->hidden->window); + this->hidden->window = NULL; + + SDL_SetError("Couldn't allocate new pixel format for requested mode"); + return(NULL); + } + + /* Set up the new mode framebuffer */ + current->flags = flags /*& SDL_FULLSCREEN*/; + current->w = width; + current->h = height; + current->pitch = width * (bpp / 8); + current->pixels = orb_window_data(this->hidden->window); + + /* We're done */ + return(current); +} + +static void ORBITAL_SetCaption(_THIS, const char *title, const char *icon) +{ + if (this->hidden->window) + orb_window_set_title(this->hidden->window, title); +} + +/* We don't actually allow hardware surfaces other than the main one */ +static int ORBITAL_AllocHWSurface(_THIS, SDL_Surface *surface) +{ + return(-1); +} +static void ORBITAL_FreeHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +/* We need to wait for vertical retrace on page flipped displays */ +static int ORBITAL_LockHWSurface(_THIS, SDL_Surface *surface) +{ + return(0); +} + +static void ORBITAL_UnlockHWSurface(_THIS, SDL_Surface *surface) +{ + return; +} + +static void ORBITAL_UpdateRects(_THIS, int numrects, SDL_Rect *rects) +{ + if (this->hidden->window) { + SDL_SetAlphaChannel(this->screen, SDL_ALPHA_OPAQUE); + orb_window_sync(this->hidden->window); + } +} + +int ORBITAL_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) +{ + /* do nothing of note. */ + return(1); +} + +/* Note: If we are terminated, this could be called in the middle of + another SDL video routine -- notably UpdateRects. +*/ +void ORBITAL_VideoQuit(_THIS) +{ + if (this->hidden->window) { + orb_window_destroy(this->hidden->window); + this->hidden->window = NULL; + this->screen->pixels = NULL; + } +} diff -ruwN source/src/video/orbital/SDL_orbitalvideo.h source-new/src/video/orbital/SDL_orbitalvideo.h --- source/src/video/orbital/SDL_orbitalvideo.h 1969-12-31 17:00:00.000000000 -0700 +++ source-new/src/video/orbital/SDL_orbitalvideo.h 2018-12-10 14:30:44.441918559 -0700 @@ -0,0 +1,39 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_orbitalvideo_h +#define _SDL_orbitalvideo_h + +#include "../SDL_sysvideo.h" + +/* Hidden "this" pointer for the video functions */ +#define _THIS SDL_VideoDevice *this + + +/* Private display data */ + +struct SDL_PrivateVideoData { + void *window; +}; + +#endif /* _SDL_orbitalvideo_h */