mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 19:22:30 +00:00
feat(gx): add incomplete 'CGxDeviceGLSDL' (#2)
* chore(build): add vendored SDL 3.0.0 library * chore(build): add vendored glew-cmake-2.2.0 library * feat(console): in the presence of -opengl launch flag, change GxApi to OpenGl * feat(gx): add uncompleted CGxDeviceGLSDL targeting Windows and Linux * chore(build): change SDL3 linkage from shared (bad) to to static (good)
This commit is contained in:
parent
934e0fb600
commit
706c8903a1
2043 changed files with 663533 additions and 5 deletions
51
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosdefs.h
vendored
Normal file
51
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosdefs.h
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_riscosdefs_h_
|
||||
#define SDL_riscosdefs_h_
|
||||
|
||||
typedef struct sprite_area
|
||||
{
|
||||
int size; /* +0 */
|
||||
int count; /* +4 */
|
||||
int start; /* +8 */
|
||||
int end; /* +12 */
|
||||
} sprite_area;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16);
|
||||
|
||||
typedef struct sprite_header
|
||||
{
|
||||
int next; /* +0 */
|
||||
char name[12]; /* +4 */
|
||||
int width; /* +16 */
|
||||
int height; /* +20 */
|
||||
int first_bit; /* +24 */
|
||||
int last_bit; /* +28 */
|
||||
int image_offset; /* +32 */
|
||||
int mask_offset; /* +36 */
|
||||
int mode; /* +40 */
|
||||
} sprite_header;
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(sprite_header, sizeof(sprite_header) == 44);
|
||||
|
||||
#endif /* SDL_riscosdefs_h_ */
|
||||
176
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosevents.c
vendored
Normal file
176
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosevents.c
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosevents_c.h"
|
||||
#include "scancodes_riscos.h"
|
||||
|
||||
#include <kernel.h>
|
||||
#include <swis.h>
|
||||
|
||||
static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode)
|
||||
{
|
||||
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
|
||||
|
||||
if (keycode < SDL_arraysize(riscos_scancode_table)) {
|
||||
scancode = riscos_scancode_table[keycode];
|
||||
|
||||
#ifdef DEBUG_SCANCODES
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN) {
|
||||
SDL_Log("The key you just pressed is not recognized by SDL: %d", keycode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return scancode;
|
||||
}
|
||||
|
||||
void RISCOS_PollKeyboard(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *driverdata = _this->driverdata;
|
||||
Uint8 key = 2;
|
||||
int i;
|
||||
|
||||
/* Check for key releases */
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||
if (driverdata->key_pressed[i] != 255) {
|
||||
if ((_kernel_osbyte(129, driverdata->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) {
|
||||
SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_RISCOS_translate_keycode(driverdata->key_pressed[i]));
|
||||
driverdata->key_pressed[i] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for key presses */
|
||||
while (key < 0xff) {
|
||||
key = _kernel_osbyte(121, key + 1, 0) & 0xff;
|
||||
switch (key) {
|
||||
case 255:
|
||||
/* Ignore mouse keys */
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
/* Ignore keys with multiple INKEY codes */
|
||||
case 24:
|
||||
case 40:
|
||||
case 71:
|
||||
case 87:
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_RISCOS_translate_keycode(key));
|
||||
|
||||
/* Record the press so we can detect release later. */
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||
if (driverdata->key_pressed[i] == key) {
|
||||
break;
|
||||
}
|
||||
if (driverdata->key_pressed[i] == 255) {
|
||||
driverdata->key_pressed[i] = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const Uint8 mouse_button_map[] = {
|
||||
SDL_BUTTON_RIGHT,
|
||||
SDL_BUTTON_MIDDLE,
|
||||
SDL_BUTTON_LEFT,
|
||||
SDL_BUTTON_X1,
|
||||
SDL_BUTTON_X2,
|
||||
SDL_BUTTON_X2 + 1,
|
||||
SDL_BUTTON_X2 + 2,
|
||||
SDL_BUTTON_X2 + 3
|
||||
};
|
||||
|
||||
void RISCOS_PollMouse(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *driverdata = _this->driverdata;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_Rect rect;
|
||||
_kernel_swi_regs regs;
|
||||
int i, x, y, buttons;
|
||||
|
||||
if (SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &rect) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_kernel_swi(OS_Mouse, ®s, ®s);
|
||||
x = (regs.r[0] >> 1);
|
||||
y = rect.h - (regs.r[1] >> 1);
|
||||
buttons = regs.r[2];
|
||||
|
||||
if (mouse->x != x || mouse->y != y) {
|
||||
SDL_SendMouseMotion(0, mouse->focus, mouse->mouseID, 0, (float)x, (float)y);
|
||||
}
|
||||
|
||||
if (driverdata->last_mouse_buttons != buttons) {
|
||||
for (i = 0; i < SDL_arraysize(mouse_button_map); i++) {
|
||||
SDL_SendMouseButton(0, mouse->focus, mouse->mouseID, (buttons & (1 << i)) ? SDL_PRESSED : SDL_RELEASED, mouse_button_map[i]);
|
||||
}
|
||||
driverdata->last_mouse_buttons = buttons;
|
||||
}
|
||||
}
|
||||
|
||||
int RISCOS_InitEvents(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_VideoData *driverdata = _this->driverdata;
|
||||
_kernel_swi_regs regs;
|
||||
int i, status;
|
||||
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||
driverdata->key_pressed[i] = 255;
|
||||
}
|
||||
|
||||
status = (_kernel_osbyte(202, 0, 255) & 0xFF);
|
||||
SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? SDL_FALSE : SDL_TRUE);
|
||||
SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? SDL_FALSE : SDL_TRUE);
|
||||
SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? SDL_TRUE : SDL_FALSE);
|
||||
|
||||
_kernel_swi(OS_Mouse, ®s, ®s);
|
||||
driverdata->last_mouse_buttons = regs.r[2];
|
||||
|
||||
/* Disable escape. */
|
||||
_kernel_osbyte(229, 1, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RISCOS_PumpEvents(SDL_VideoDevice *_this)
|
||||
{
|
||||
RISCOS_PollMouse(_this);
|
||||
RISCOS_PollKeyboard(_this);
|
||||
}
|
||||
|
||||
void RISCOS_QuitEvents(SDL_VideoDevice *_this)
|
||||
{
|
||||
/* Re-enable escape. */
|
||||
_kernel_osbyte(229, 0, 0);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
33
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosevents_c.h
vendored
Normal file
33
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosevents_c.h
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_riscosevents_c_h_
|
||||
#define SDL_riscosevents_c_h_
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
|
||||
extern int RISCOS_InitEvents(SDL_VideoDevice *_this);
|
||||
extern void RISCOS_PumpEvents(SDL_VideoDevice *_this);
|
||||
extern void RISCOS_QuitEvents(SDL_VideoDevice *_this);
|
||||
|
||||
#endif /* SDL_riscosevents_c_h_ */
|
||||
127
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosframebuffer.c
vendored
Normal file
127
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosframebuffer.c
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_riscosframebuffer_c.h"
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
|
||||
#include <kernel.h>
|
||||
#include <swis.h>
|
||||
|
||||
int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *driverdata = window->driverdata;
|
||||
const char *sprite_name = "display";
|
||||
unsigned int sprite_mode;
|
||||
_kernel_oserror *error;
|
||||
_kernel_swi_regs regs;
|
||||
const SDL_DisplayMode *mode;
|
||||
int size;
|
||||
int w, h;
|
||||
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
RISCOS_DestroyWindowFramebuffer(_this, window);
|
||||
|
||||
/* Create a new one */
|
||||
mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window));
|
||||
if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) {
|
||||
*format = mode->format;
|
||||
sprite_mode = (unsigned int)mode->driverdata;
|
||||
} else {
|
||||
*format = SDL_PIXELFORMAT_XBGR8888;
|
||||
sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27));
|
||||
}
|
||||
|
||||
/* Calculate pitch */
|
||||
*pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
|
||||
|
||||
/* Allocate the sprite area */
|
||||
size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h);
|
||||
driverdata->fb_area = SDL_malloc(size);
|
||||
if (!driverdata->fb_area) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
driverdata->fb_area->size = size;
|
||||
driverdata->fb_area->count = 0;
|
||||
driverdata->fb_area->start = 16;
|
||||
driverdata->fb_area->end = 16;
|
||||
|
||||
/* Create the actual image */
|
||||
regs.r[0] = 256 + 15;
|
||||
regs.r[1] = (int)driverdata->fb_area;
|
||||
regs.r[2] = (int)sprite_name;
|
||||
regs.r[3] = 0;
|
||||
regs.r[4] = w;
|
||||
regs.r[5] = h;
|
||||
regs.r[6] = sprite_mode;
|
||||
error = _kernel_swi(OS_SpriteOp, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
SDL_free(driverdata->fb_area);
|
||||
return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
driverdata->fb_sprite = (sprite_header *)(((Uint8 *)driverdata->fb_area) + driverdata->fb_area->start);
|
||||
*pixels = ((Uint8 *)driverdata->fb_sprite) + driverdata->fb_sprite->image_offset;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects)
|
||||
{
|
||||
SDL_WindowData *driverdata = window->driverdata;
|
||||
_kernel_swi_regs regs;
|
||||
_kernel_oserror *error;
|
||||
|
||||
regs.r[0] = 512 + 52;
|
||||
regs.r[1] = (int)driverdata->fb_area;
|
||||
regs.r[2] = (int)driverdata->fb_sprite;
|
||||
regs.r[3] = 0; /* window->x << 1; */
|
||||
regs.r[4] = 0; /* window->y << 1; */
|
||||
regs.r[5] = 0x50;
|
||||
regs.r[6] = 0;
|
||||
regs.r[7] = 0;
|
||||
error = _kernel_swi(OS_SpriteOp, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *driverdata = window->driverdata;
|
||||
|
||||
if (driverdata->fb_area) {
|
||||
SDL_free(driverdata->fb_area);
|
||||
driverdata->fb_area = NULL;
|
||||
}
|
||||
driverdata->fb_sprite = NULL;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
31
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosframebuffer_c.h
vendored
Normal file
31
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosframebuffer_c.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_riscosframebuffer_c_h_
|
||||
#define SDL_riscosframebuffer_c_h_
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
|
||||
extern int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
#endif /* SDL_riscosframebuffer_c_h_ */
|
||||
67
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmessagebox.c
vendored
Normal file
67
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmessagebox.c
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "SDL_riscosmessagebox.h"
|
||||
|
||||
#include <kernel.h>
|
||||
#include <swis.h>
|
||||
|
||||
int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
_kernel_swi_regs regs;
|
||||
_kernel_oserror error;
|
||||
char buttonstring[1024];
|
||||
int i;
|
||||
|
||||
error.errnum = 0;
|
||||
SDL_strlcpy(error.errmess, messageboxdata->message, 252);
|
||||
regs.r[0] = (unsigned int)&error;
|
||||
|
||||
regs.r[1] = (1 << 8) | (1 << 4);
|
||||
if (messageboxdata->flags == SDL_MESSAGEBOX_INFORMATION) {
|
||||
regs.r[1] |= (1 << 9);
|
||||
} else if (messageboxdata->flags == SDL_MESSAGEBOX_WARNING) {
|
||||
regs.r[1] |= (2 << 9);
|
||||
}
|
||||
|
||||
regs.r[2] = (unsigned int)messageboxdata->title;
|
||||
regs.r[3] = 0;
|
||||
regs.r[4] = 0;
|
||||
|
||||
SDL_strlcpy(buttonstring, "", 1024);
|
||||
for (i = 0; i < messageboxdata->numbuttons; i++) {
|
||||
SDL_strlcat(buttonstring, messageboxdata->buttons[i].text, 1024);
|
||||
if (i + 1 < messageboxdata->numbuttons) {
|
||||
SDL_strlcat(buttonstring, ",", 1024);
|
||||
}
|
||||
}
|
||||
regs.r[5] = (unsigned int)buttonstring;
|
||||
|
||||
_kernel_swi(Wimp_ReportError, ®s, ®s);
|
||||
|
||||
*buttonid = (regs.r[1] == 0) ? -1 : messageboxdata->buttons[regs.r[1] - 3].buttonid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
27
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmessagebox.h
vendored
Normal file
27
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmessagebox.h
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
extern int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
310
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmodes.c
vendored
Normal file
310
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmodes.c
vendored
Normal file
|
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosmodes.h"
|
||||
|
||||
#include <kernel.h>
|
||||
#include <swis.h>
|
||||
|
||||
enum
|
||||
{
|
||||
MODE_FLAG_565 = 1 << 7,
|
||||
|
||||
MODE_FLAG_COLOUR_SPACE = 0xF << 12,
|
||||
|
||||
MODE_FLAG_TBGR = 0,
|
||||
MODE_FLAG_TRGB = 1 << 14,
|
||||
MODE_FLAG_ABGR = 1 << 15,
|
||||
MODE_FLAG_ARGB = MODE_FLAG_TRGB | MODE_FLAG_ABGR
|
||||
};
|
||||
|
||||
static const struct
|
||||
{
|
||||
SDL_PixelFormatEnum pixel_format;
|
||||
int modeflags, ncolour, log2bpp;
|
||||
} mode_to_pixelformat[] = {
|
||||
/* { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, */
|
||||
/* { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 }, */
|
||||
/* { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 }, */
|
||||
/* { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 }, */
|
||||
{ SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 },
|
||||
{ SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 },
|
||||
{ SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 },
|
||||
{ SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 },
|
||||
{ SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 },
|
||||
{ SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 },
|
||||
{ SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 },
|
||||
{ SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 },
|
||||
{ SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 },
|
||||
{ SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 },
|
||||
{ SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 }
|
||||
};
|
||||
|
||||
static SDL_PixelFormatEnum RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(mode_to_pixelformat); i++) {
|
||||
if (log2bpp == mode_to_pixelformat[i].log2bpp &&
|
||||
(ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) &&
|
||||
(modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) {
|
||||
return mode_to_pixelformat[i].pixel_format;
|
||||
}
|
||||
}
|
||||
|
||||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static size_t measure_mode_block(const int *block)
|
||||
{
|
||||
size_t blockSize = ((block[0] & 0xFF) == 3) ? 7 : 5;
|
||||
while (block[blockSize] != -1) {
|
||||
blockSize += 2;
|
||||
}
|
||||
blockSize++;
|
||||
|
||||
return blockSize * 4;
|
||||
}
|
||||
|
||||
static int read_mode_variable(int *block, int var)
|
||||
{
|
||||
_kernel_swi_regs regs;
|
||||
regs.r[0] = (int)block;
|
||||
regs.r[1] = var;
|
||||
_kernel_swi(OS_ReadModeVariable, ®s, ®s);
|
||||
return regs.r[2];
|
||||
}
|
||||
|
||||
static SDL_bool read_mode_block(int *block, SDL_DisplayMode *mode, SDL_bool extended)
|
||||
{
|
||||
int xres, yres, ncolour, modeflags, log2bpp, rate;
|
||||
|
||||
if ((block[0] & 0xFF) == 1) {
|
||||
xres = block[1];
|
||||
yres = block[2];
|
||||
log2bpp = block[3];
|
||||
rate = block[4];
|
||||
ncolour = (1 << (1 << log2bpp)) - 1;
|
||||
modeflags = MODE_FLAG_TBGR;
|
||||
} else if ((block[0] & 0xFF) == 3) {
|
||||
xres = block[1];
|
||||
yres = block[2];
|
||||
ncolour = block[3];
|
||||
modeflags = block[4];
|
||||
log2bpp = block[5];
|
||||
rate = block[6];
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (extended) {
|
||||
xres = read_mode_variable(block, 11) + 1;
|
||||
yres = read_mode_variable(block, 12) + 1;
|
||||
log2bpp = read_mode_variable(block, 9);
|
||||
ncolour = read_mode_variable(block, 3);
|
||||
modeflags = read_mode_variable(block, 0);
|
||||
}
|
||||
|
||||
SDL_zerop(mode);
|
||||
mode->w = xres;
|
||||
mode->h = yres;
|
||||
mode->format = RISCOS_ModeToPixelFormat(ncolour, modeflags, log2bpp);
|
||||
mode->refresh_rate = (float)rate;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static void *convert_mode_block(const int *block)
|
||||
{
|
||||
int xres, yres, log2bpp, rate, ncolour = 0, modeflags = 0;
|
||||
size_t pos = 0;
|
||||
int *dst;
|
||||
|
||||
if ((block[0] & 0xFF) == 1) {
|
||||
xres = block[1];
|
||||
yres = block[2];
|
||||
log2bpp = block[3];
|
||||
rate = block[4];
|
||||
} else if ((block[0] & 0xFF) == 3) {
|
||||
xres = block[1];
|
||||
yres = block[2];
|
||||
ncolour = block[3];
|
||||
modeflags = block[4];
|
||||
log2bpp = block[5];
|
||||
rate = block[6];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dst = SDL_malloc(40);
|
||||
if (dst == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dst[pos++] = 1;
|
||||
dst[pos++] = xres;
|
||||
dst[pos++] = yres;
|
||||
dst[pos++] = log2bpp;
|
||||
dst[pos++] = rate;
|
||||
if (ncolour != 0) {
|
||||
dst[pos++] = 3;
|
||||
dst[pos++] = ncolour;
|
||||
}
|
||||
if (modeflags != 0) {
|
||||
dst[pos++] = 0;
|
||||
dst[pos++] = modeflags;
|
||||
}
|
||||
dst[pos++] = -1;
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void *copy_memory(const void *src, size_t size, size_t alloc)
|
||||
{
|
||||
void *dst = SDL_malloc(alloc);
|
||||
if (dst) {
|
||||
SDL_memcpy(dst, src, size);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
int RISCOS_InitModes(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
int *current_mode;
|
||||
_kernel_swi_regs regs;
|
||||
_kernel_oserror *error;
|
||||
size_t size;
|
||||
|
||||
regs.r[0] = 1;
|
||||
error = _kernel_swi(OS_ScreenMode, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
current_mode = (int *)regs.r[1];
|
||||
if (!read_mode_block(current_mode, &mode, SDL_TRUE)) {
|
||||
return SDL_SetError("Unsupported mode block format %d", current_mode[0]);
|
||||
}
|
||||
|
||||
size = measure_mode_block(current_mode);
|
||||
mode.driverdata = copy_memory(current_mode, size, size);
|
||||
if (!mode.driverdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (SDL_AddBasicVideoDisplay(&mode) == 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
_kernel_swi_regs regs;
|
||||
_kernel_oserror *error;
|
||||
void *block, *pos;
|
||||
|
||||
regs.r[0] = 2;
|
||||
regs.r[2] = 0;
|
||||
regs.r[6] = 0;
|
||||
regs.r[7] = 0;
|
||||
error = _kernel_swi(OS_ScreenMode, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
block = SDL_malloc(-regs.r[7]);
|
||||
if (block == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
regs.r[6] = (int)block;
|
||||
regs.r[7] = -regs.r[7];
|
||||
error = _kernel_swi(OS_ScreenMode, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
SDL_free(block);
|
||||
return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
for (pos = block; pos < (void *)regs.r[6]; pos += *((int *)pos)) {
|
||||
if (!read_mode_block(pos + 4, &mode, SDL_FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode.format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mode.driverdata = convert_mode_block(pos + 4);
|
||||
if (!mode.driverdata) {
|
||||
SDL_free(block);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
|
||||
SDL_free(mode.driverdata);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(block);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
|
||||
{
|
||||
const char disable_cursor[] = { 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
_kernel_swi_regs regs;
|
||||
_kernel_oserror *error;
|
||||
int i;
|
||||
|
||||
regs.r[0] = 0;
|
||||
regs.r[1] = (int)mode->driverdata;
|
||||
error = _kernel_swi(OS_ScreenMode, ®s, ®s);
|
||||
if (error != NULL) {
|
||||
return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum);
|
||||
}
|
||||
|
||||
/* Turn the text cursor off */
|
||||
for (i = 0; i < SDL_arraysize(disable_cursor); i++) {
|
||||
_kernel_oswrch(disable_cursor[i]);
|
||||
}
|
||||
|
||||
/* Update cursor visibility, since it may have been disabled by the mode change. */
|
||||
SDL_SetCursor(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
31
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmodes.h
vendored
Normal file
31
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmodes.h
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_riscosmodes_h_
|
||||
#define SDL_riscosmodes_h_
|
||||
|
||||
extern int RISCOS_InitModes(SDL_VideoDevice *_this);
|
||||
extern int RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
|
||||
extern int RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display,
|
||||
SDL_DisplayMode *mode);
|
||||
|
||||
#endif /* SDL_riscosmodes_h_ */
|
||||
83
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmouse.c
vendored
Normal file
83
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmouse.c
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosmouse.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
static SDL_Cursor *RISCOS_CreateDefaultCursor()
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
/* NULL is used to indicate the default cursor */
|
||||
cursor->driverdata = NULL;
|
||||
} else {
|
||||
SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static void RISCOS_FreeCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
static int RISCOS_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
if (cursor) {
|
||||
/* Turn the mouse pointer on */
|
||||
_kernel_osbyte(106, 1, 0);
|
||||
} else {
|
||||
/* Turn the mouse pointer off */
|
||||
_kernel_osbyte(106, 0, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RISCOS_InitMouse(SDL_VideoDevice *_this)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
|
||||
/* mouse->CreateCursor = RISCOS_CreateCursor; */
|
||||
/* mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; */
|
||||
mouse->ShowCursor = RISCOS_ShowCursor;
|
||||
mouse->FreeCursor = RISCOS_FreeCursor;
|
||||
/* mouse->WarpMouse = RISCOS_WarpMouse; */
|
||||
/* mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; */
|
||||
/* mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; */
|
||||
/* mouse->CaptureMouse = RISCOS_CaptureMouse; */
|
||||
/* mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; */
|
||||
|
||||
SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
28
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmouse.h
vendored
Normal file
28
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosmouse.h
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_riscosmouse_h_
|
||||
#define SDL_riscosmouse_h_
|
||||
|
||||
extern int RISCOS_InitMouse(SDL_VideoDevice *_this);
|
||||
|
||||
#endif /* SDL_riscosmouse_h_ */
|
||||
121
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosvideo.c
vendored
Normal file
121
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosvideo.c
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosevents_c.h"
|
||||
#include "SDL_riscosframebuffer_c.h"
|
||||
#include "SDL_riscosmouse.h"
|
||||
#include "SDL_riscosmodes.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
|
||||
#define RISCOSVID_DRIVER_NAME "riscos"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int RISCOS_VideoInit(SDL_VideoDevice *_this);
|
||||
static void RISCOS_VideoQuit(SDL_VideoDevice *_this);
|
||||
|
||||
/* RISC OS driver bootstrap functions */
|
||||
|
||||
static void RISCOS_DeleteDevice(SDL_VideoDevice *device)
|
||||
{
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *RISCOS_CreateDevice(void)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *phdata;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Initialize internal data */
|
||||
phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
if (phdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device->driverdata = phdata;
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = RISCOS_VideoInit;
|
||||
device->VideoQuit = RISCOS_VideoQuit;
|
||||
device->PumpEvents = RISCOS_PumpEvents;
|
||||
|
||||
device->GetDisplayModes = RISCOS_GetDisplayModes;
|
||||
device->SetDisplayMode = RISCOS_SetDisplayMode;
|
||||
|
||||
device->CreateSDLWindow = RISCOS_CreateWindow;
|
||||
device->DestroyWindow = RISCOS_DestroyWindow;
|
||||
device->GetWindowWMInfo = RISCOS_GetWindowWMInfo;
|
||||
|
||||
device->CreateWindowFramebuffer = RISCOS_CreateWindowFramebuffer;
|
||||
device->UpdateWindowFramebuffer = RISCOS_UpdateWindowFramebuffer;
|
||||
device->DestroyWindowFramebuffer = RISCOS_DestroyWindowFramebuffer;
|
||||
|
||||
device->free = RISCOS_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap RISCOS_bootstrap = {
|
||||
RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver",
|
||||
RISCOS_CreateDevice
|
||||
};
|
||||
|
||||
static int RISCOS_VideoInit(SDL_VideoDevice *_this)
|
||||
{
|
||||
if (RISCOS_InitEvents(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (RISCOS_InitMouse(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (RISCOS_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We're done! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void RISCOS_VideoQuit(SDL_VideoDevice *_this)
|
||||
{
|
||||
RISCOS_QuitEvents(_this);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
36
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosvideo.h
vendored
Normal file
36
vendor/sdl-3.0.0/src/video/riscos/SDL_riscosvideo.h
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_riscosvideo_h_
|
||||
#define SDL_riscosvideo_h_
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#define RISCOS_MAX_KEYS_PRESSED 6
|
||||
|
||||
struct SDL_VideoData
|
||||
{
|
||||
int last_mouse_buttons;
|
||||
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
|
||||
};
|
||||
|
||||
#endif /* SDL_riscosvideo_h_ */
|
||||
70
vendor/sdl-3.0.0/src/video/riscos/SDL_riscoswindow.c
vendored
Normal file
70
vendor/sdl-3.0.0/src/video/riscos/SDL_riscoswindow.c
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
|
||||
int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *driverdata;
|
||||
|
||||
driverdata = (SDL_WindowData *)SDL_calloc(1, sizeof(*driverdata));
|
||||
if (driverdata == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
driverdata->window = window;
|
||||
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
SDL_SetMouseFocus(window);
|
||||
|
||||
/* All done! */
|
||||
window->driverdata = driverdata;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *driverdata = window->driverdata;
|
||||
|
||||
if (driverdata == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_free(driverdata);
|
||||
window->driverdata = NULL;
|
||||
}
|
||||
|
||||
int RISCOS_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info)
|
||||
{
|
||||
info->subsystem = SDL_SYSWM_RISCOS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_RISCOS */
|
||||
39
vendor/sdl-3.0.0/src/video/riscos/SDL_riscoswindow.h
vendored
Normal file
39
vendor/sdl-3.0.0/src/video/riscos/SDL_riscoswindow.h
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_riscoswindow_h_
|
||||
#define SDL_riscoswindow_h_
|
||||
|
||||
#include "SDL_riscosdefs.h"
|
||||
|
||||
struct SDL_WindowData
|
||||
{
|
||||
SDL_Window *window;
|
||||
sprite_area *fb_area;
|
||||
sprite_header *fb_sprite;
|
||||
};
|
||||
|
||||
extern int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
extern int RISCOS_GetWindowWMInfo(SDL_VideoDevice *_this, SDL_Window *window, struct SDL_SysWMinfo *info);
|
||||
|
||||
#endif /* SDL_riscoswindow_h_ */
|
||||
157
vendor/sdl-3.0.0/src/video/riscos/scancodes_riscos.h
vendored
Normal file
157
vendor/sdl-3.0.0/src/video/riscos/scancodes_riscos.h
vendored
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* RISC OS key code to SDL_Keycode mapping table
|
||||
Sources:
|
||||
- https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes
|
||||
*/
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
static SDL_Scancode const riscos_scancode_table[] = {
|
||||
/* 0 */ SDL_SCANCODE_UNKNOWN, /* Shift */
|
||||
/* 1 */ SDL_SCANCODE_UNKNOWN, /* Ctrl */
|
||||
/* 2 */ SDL_SCANCODE_UNKNOWN, /* Alt */
|
||||
/* 3 */ SDL_SCANCODE_LSHIFT,
|
||||
/* 4 */ SDL_SCANCODE_LCTRL,
|
||||
/* 5 */ SDL_SCANCODE_LALT,
|
||||
/* 6 */ SDL_SCANCODE_RSHIFT,
|
||||
/* 7 */ SDL_SCANCODE_RCTRL,
|
||||
/* 8 */ SDL_SCANCODE_RALT,
|
||||
/* 9 */ SDL_SCANCODE_UNKNOWN, /* Left mouse */
|
||||
/* 10 */ SDL_SCANCODE_UNKNOWN, /* Center mouse */
|
||||
/* 11 */ SDL_SCANCODE_UNKNOWN, /* Right mouse */
|
||||
/* 12 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 13 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 14 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 15 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 16 */ SDL_SCANCODE_Q,
|
||||
/* 17 */ SDL_SCANCODE_3,
|
||||
/* 18 */ SDL_SCANCODE_4,
|
||||
/* 19 */ SDL_SCANCODE_5,
|
||||
/* 20 */ SDL_SCANCODE_F4,
|
||||
/* 21 */ SDL_SCANCODE_8,
|
||||
/* 22 */ SDL_SCANCODE_F7,
|
||||
/* 23 */ SDL_SCANCODE_MINUS,
|
||||
/* 24 */ SDL_SCANCODE_6, /* Duplicate of 52 */
|
||||
/* 25 */ SDL_SCANCODE_LEFT,
|
||||
/* 26 */ SDL_SCANCODE_KP_6,
|
||||
/* 27 */ SDL_SCANCODE_KP_7,
|
||||
/* 28 */ SDL_SCANCODE_F11,
|
||||
/* 29 */ SDL_SCANCODE_F12,
|
||||
/* 30 */ SDL_SCANCODE_F10,
|
||||
/* 31 */ SDL_SCANCODE_SCROLLLOCK,
|
||||
/* 32 */ SDL_SCANCODE_PRINTSCREEN,
|
||||
/* 33 */ SDL_SCANCODE_W,
|
||||
/* 34 */ SDL_SCANCODE_E,
|
||||
/* 35 */ SDL_SCANCODE_T,
|
||||
/* 36 */ SDL_SCANCODE_7,
|
||||
/* 37 */ SDL_SCANCODE_I,
|
||||
/* 38 */ SDL_SCANCODE_9,
|
||||
/* 39 */ SDL_SCANCODE_0,
|
||||
/* 40 */ SDL_SCANCODE_MINUS, /* Duplicate of 23 */
|
||||
/* 41 */ SDL_SCANCODE_DOWN,
|
||||
/* 42 */ SDL_SCANCODE_KP_8,
|
||||
/* 43 */ SDL_SCANCODE_KP_9,
|
||||
/* 44 */ SDL_SCANCODE_PAUSE,
|
||||
/* 45 */ SDL_SCANCODE_GRAVE,
|
||||
/* 46 */ SDL_SCANCODE_CURRENCYUNIT,
|
||||
/* 47 */ SDL_SCANCODE_BACKSPACE,
|
||||
/* 48 */ SDL_SCANCODE_1,
|
||||
/* 49 */ SDL_SCANCODE_2,
|
||||
/* 50 */ SDL_SCANCODE_D,
|
||||
/* 51 */ SDL_SCANCODE_R,
|
||||
/* 52 */ SDL_SCANCODE_6,
|
||||
/* 53 */ SDL_SCANCODE_U,
|
||||
/* 54 */ SDL_SCANCODE_O,
|
||||
/* 55 */ SDL_SCANCODE_P,
|
||||
/* 56 */ SDL_SCANCODE_LEFTBRACKET,
|
||||
/* 57 */ SDL_SCANCODE_UP,
|
||||
/* 58 */ SDL_SCANCODE_KP_PLUS,
|
||||
/* 59 */ SDL_SCANCODE_KP_MINUS,
|
||||
/* 60 */ SDL_SCANCODE_KP_ENTER,
|
||||
/* 61 */ SDL_SCANCODE_INSERT,
|
||||
/* 62 */ SDL_SCANCODE_HOME,
|
||||
/* 63 */ SDL_SCANCODE_PAGEUP,
|
||||
/* 64 */ SDL_SCANCODE_CAPSLOCK,
|
||||
/* 65 */ SDL_SCANCODE_A,
|
||||
/* 66 */ SDL_SCANCODE_X,
|
||||
/* 67 */ SDL_SCANCODE_F,
|
||||
/* 68 */ SDL_SCANCODE_Y,
|
||||
/* 69 */ SDL_SCANCODE_J,
|
||||
/* 70 */ SDL_SCANCODE_K,
|
||||
/* 71 */ SDL_SCANCODE_2, /* Duplicate of 49 */
|
||||
/* 72 */ SDL_SCANCODE_SEMICOLON, /* Duplicate of 87 */
|
||||
/* 73 */ SDL_SCANCODE_RETURN,
|
||||
/* 74 */ SDL_SCANCODE_KP_DIVIDE,
|
||||
/* 75 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 76 */ SDL_SCANCODE_KP_PERIOD,
|
||||
/* 77 */ SDL_SCANCODE_NUMLOCKCLEAR,
|
||||
/* 78 */ SDL_SCANCODE_PAGEDOWN,
|
||||
/* 79 */ SDL_SCANCODE_APOSTROPHE,
|
||||
/* 80 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 81 */ SDL_SCANCODE_S,
|
||||
/* 82 */ SDL_SCANCODE_C,
|
||||
/* 83 */ SDL_SCANCODE_G,
|
||||
/* 84 */ SDL_SCANCODE_H,
|
||||
/* 85 */ SDL_SCANCODE_N,
|
||||
/* 86 */ SDL_SCANCODE_L,
|
||||
/* 87 */ SDL_SCANCODE_SEMICOLON,
|
||||
/* 88 */ SDL_SCANCODE_RIGHTBRACKET,
|
||||
/* 89 */ SDL_SCANCODE_DELETE,
|
||||
/* 90 */ SDL_SCANCODE_KP_HASH,
|
||||
/* 91 */ SDL_SCANCODE_KP_MULTIPLY,
|
||||
/* 92 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 93 */ SDL_SCANCODE_EQUALS,
|
||||
/* 94 */ SDL_SCANCODE_NONUSBACKSLASH,
|
||||
/* 95 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 96 */ SDL_SCANCODE_TAB,
|
||||
/* 97 */ SDL_SCANCODE_Z,
|
||||
/* 98 */ SDL_SCANCODE_SPACE,
|
||||
/* 99 */ SDL_SCANCODE_V,
|
||||
/* 100 */ SDL_SCANCODE_B,
|
||||
/* 101 */ SDL_SCANCODE_M,
|
||||
/* 102 */ SDL_SCANCODE_COMMA,
|
||||
/* 103 */ SDL_SCANCODE_PERIOD,
|
||||
/* 104 */ SDL_SCANCODE_SLASH,
|
||||
/* 105 */ SDL_SCANCODE_END,
|
||||
/* 106 */ SDL_SCANCODE_KP_0,
|
||||
/* 107 */ SDL_SCANCODE_KP_1,
|
||||
/* 108 */ SDL_SCANCODE_KP_3,
|
||||
/* 109 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 110 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 111 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 112 */ SDL_SCANCODE_ESCAPE,
|
||||
/* 113 */ SDL_SCANCODE_F1,
|
||||
/* 114 */ SDL_SCANCODE_F2,
|
||||
/* 115 */ SDL_SCANCODE_F3,
|
||||
/* 116 */ SDL_SCANCODE_F5,
|
||||
/* 117 */ SDL_SCANCODE_F6,
|
||||
/* 118 */ SDL_SCANCODE_F8,
|
||||
/* 119 */ SDL_SCANCODE_F9,
|
||||
/* 120 */ SDL_SCANCODE_BACKSLASH,
|
||||
/* 121 */ SDL_SCANCODE_RIGHT,
|
||||
/* 122 */ SDL_SCANCODE_KP_4,
|
||||
/* 123 */ SDL_SCANCODE_KP_5,
|
||||
/* 124 */ SDL_SCANCODE_KP_2,
|
||||
/* 125 */ SDL_SCANCODE_LGUI,
|
||||
/* 126 */ SDL_SCANCODE_RGUI,
|
||||
/* 127 */ SDL_SCANCODE_MENU
|
||||
};
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
Loading…
Add table
Add a link
Reference in a new issue