summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/riscos
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/riscos')
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h51
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c177
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h33
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c127
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h31
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c67
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h27
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c310
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h30
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c79
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h28
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c130
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h36
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c56
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h38
-rw-r--r--contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h157
16 files changed, 1377 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h
new file mode 100644
index 0000000..85be939
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h
@@ -0,0 +1,51 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_riscosdefs_h_
24#define SDL_riscosdefs_h_
25
26typedef struct sprite_area
27{
28 int size; // +0
29 int count; // +4
30 int start; // +8
31 int end; // +12
32} sprite_area;
33
34SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16);
35
36typedef struct sprite_header
37{
38 int next; // +0
39 char name[12]; // +4
40 int width; // +16
41 int height; // +20
42 int first_bit; // +24
43 int last_bit; // +28
44 int image_offset; // +32
45 int mask_offset; // +36
46 int mode; // +40
47} sprite_header;
48
49SDL_COMPILE_TIME_ASSERT(sprite_header, sizeof(sprite_header) == 44);
50
51#endif // SDL_riscosdefs_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c
new file mode 100644
index 0000000..367ea47
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c
@@ -0,0 +1,177 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "../../events/SDL_events_c.h"
26
27#include "SDL_riscosvideo.h"
28#include "SDL_riscosevents_c.h"
29#include "scancodes_riscos.h"
30
31#include <kernel.h>
32#include <swis.h>
33
34static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode)
35{
36 SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
37
38 if (keycode < SDL_arraysize(riscos_scancode_table)) {
39 scancode = riscos_scancode_table[keycode];
40
41#ifdef DEBUG_SCANCODES
42 if (scancode == SDL_SCANCODE_UNKNOWN) {
43 SDL_Log("The key you just pressed is not recognized by SDL: %d", keycode);
44 }
45#endif
46 }
47
48 return scancode;
49}
50
51void RISCOS_PollKeyboard(SDL_VideoDevice *_this)
52{
53 SDL_VideoData *internal = _this->internal;
54 Uint8 key = 2;
55 int i;
56
57 // Check for key releases
58 for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
59 if (internal->key_pressed[i] != 255) {
60 if ((_kernel_osbyte(129, internal->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) {
61 SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, internal->key_pressed[i], SDL_RISCOS_translate_keycode(internal->key_pressed[i]), false);
62 internal->key_pressed[i] = 255;
63 }
64 }
65 }
66
67 // Check for key presses
68 while (key < 0xff) {
69 key = _kernel_osbyte(121, key + 1, 0) & 0xff;
70 switch (key) {
71 case 255:
72 // Ignore mouse keys
73 case 9:
74 case 10:
75 case 11:
76 // Ignore keys with multiple INKEY codes
77 case 24:
78 case 40:
79 case 71:
80 case 87:
81 break;
82
83 default:
84 SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, key, SDL_RISCOS_translate_keycode(key), true);
85
86 // Record the press so we can detect release later.
87 for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
88 if (internal->key_pressed[i] == key) {
89 break;
90 }
91 if (internal->key_pressed[i] == 255) {
92 internal->key_pressed[i] = key;
93 break;
94 }
95 }
96 }
97 }
98}
99
100static const Uint8 mouse_button_map[] = {
101 SDL_BUTTON_RIGHT,
102 SDL_BUTTON_MIDDLE,
103 SDL_BUTTON_LEFT,
104 SDL_BUTTON_X1,
105 SDL_BUTTON_X2,
106 SDL_BUTTON_X2 + 1,
107 SDL_BUTTON_X2 + 2,
108 SDL_BUTTON_X2 + 3
109};
110
111void RISCOS_PollMouse(SDL_VideoDevice *_this)
112{
113 SDL_VideoData *internal = _this->internal;
114 SDL_Mouse *mouse = SDL_GetMouse();
115 SDL_Rect rect;
116 _kernel_swi_regs regs;
117 int i, x, y, buttons;
118
119 if (!SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &rect)) {
120 return;
121 }
122
123 _kernel_swi(OS_Mouse, &regs, &regs);
124 x = (regs.r[0] >> 1);
125 y = rect.h - (regs.r[1] >> 1);
126 buttons = regs.r[2];
127
128 if (mouse->x != x || mouse->y != y) {
129 SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y);
130 }
131
132 if (internal->last_mouse_buttons != buttons) {
133 for (i = 0; i < SDL_arraysize(mouse_button_map); i++) {
134 bool down = ((buttons & (1 << i)) != 0);
135 SDL_SendMouseButton(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, mouse_button_map[i], down);
136 }
137 internal->last_mouse_buttons = buttons;
138 }
139}
140
141bool RISCOS_InitEvents(SDL_VideoDevice *_this)
142{
143 SDL_VideoData *internal = _this->internal;
144 _kernel_swi_regs regs;
145 int i, status;
146
147 for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
148 internal->key_pressed[i] = 255;
149 }
150
151 status = (_kernel_osbyte(202, 0, 255) & 0xFF);
152 SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? false : true);
153 SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? false : true);
154 SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? true : false);
155
156 _kernel_swi(OS_Mouse, &regs, &regs);
157 internal->last_mouse_buttons = regs.r[2];
158
159 // Disable escape.
160 _kernel_osbyte(229, 1, 0);
161
162 return true;
163}
164
165void RISCOS_PumpEvents(SDL_VideoDevice *_this)
166{
167 RISCOS_PollMouse(_this);
168 RISCOS_PollKeyboard(_this);
169}
170
171void RISCOS_QuitEvents(SDL_VideoDevice *_this)
172{
173 // Re-enable escape.
174 _kernel_osbyte(229, 0, 0);
175}
176
177#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h
new file mode 100644
index 0000000..5db26fd
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h
@@ -0,0 +1,33 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef SDL_riscosevents_c_h_
23#define SDL_riscosevents_c_h_
24
25#include "SDL_internal.h"
26
27#include "SDL_riscosvideo.h"
28
29extern bool RISCOS_InitEvents(SDL_VideoDevice *_this);
30extern void RISCOS_PumpEvents(SDL_VideoDevice *_this);
31extern void RISCOS_QuitEvents(SDL_VideoDevice *_this);
32
33#endif // SDL_riscosevents_c_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c
new file mode 100644
index 0000000..a13cab8
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c
@@ -0,0 +1,127 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "../SDL_sysvideo.h"
26#include "SDL_riscosframebuffer_c.h"
27#include "SDL_riscosvideo.h"
28#include "SDL_riscoswindow.h"
29
30#include <kernel.h>
31#include <swis.h>
32
33bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
34{
35 SDL_WindowData *internal = window->internal;
36 const char *sprite_name = "display";
37 unsigned int sprite_mode;
38 _kernel_oserror *error;
39 _kernel_swi_regs regs;
40 const SDL_DisplayMode *mode;
41 int size;
42 int w, h;
43
44 SDL_GetWindowSizeInPixels(window, &w, &h);
45
46 // Free the old framebuffer surface
47 RISCOS_DestroyWindowFramebuffer(_this, window);
48
49 // Create a new one
50 mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window));
51 if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) {
52 *format = mode->format;
53 sprite_mode = (unsigned int)mode->internal;
54 } else {
55 *format = SDL_PIXELFORMAT_XBGR8888;
56 sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27));
57 }
58
59 // Calculate pitch
60 *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3);
61
62 // Allocate the sprite area
63 size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h);
64 internal->fb_area = SDL_malloc(size);
65 if (!internal->fb_area) {
66 return false;
67 }
68
69 internal->fb_area->size = size;
70 internal->fb_area->count = 0;
71 internal->fb_area->start = 16;
72 internal->fb_area->end = 16;
73
74 // Create the actual image
75 regs.r[0] = 256 + 15;
76 regs.r[1] = (int)internal->fb_area;
77 regs.r[2] = (int)sprite_name;
78 regs.r[3] = 0;
79 regs.r[4] = w;
80 regs.r[5] = h;
81 regs.r[6] = sprite_mode;
82 error = _kernel_swi(OS_SpriteOp, &regs, &regs);
83 if (error) {
84 SDL_free(internal->fb_area);
85 return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum);
86 }
87
88 internal->fb_sprite = (sprite_header *)(((Uint8 *)internal->fb_area) + internal->fb_area->start);
89 *pixels = ((Uint8 *)internal->fb_sprite) + internal->fb_sprite->image_offset;
90
91 return true;
92}
93
94bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects)
95{
96 SDL_WindowData *internal = window->internal;
97 _kernel_swi_regs regs;
98 _kernel_oserror *error;
99
100 regs.r[0] = 512 + 52;
101 regs.r[1] = (int)internal->fb_area;
102 regs.r[2] = (int)internal->fb_sprite;
103 regs.r[3] = 0; // window->x << 1;
104 regs.r[4] = 0; // window->y << 1;
105 regs.r[5] = 0x50;
106 regs.r[6] = 0;
107 regs.r[7] = 0;
108 error = _kernel_swi(OS_SpriteOp, &regs, &regs);
109 if (error) {
110 return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum);
111 }
112
113 return true;
114}
115
116void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window)
117{
118 SDL_WindowData *internal = window->internal;
119
120 if (internal->fb_area) {
121 SDL_free(internal->fb_area);
122 internal->fb_area = NULL;
123 }
124 internal->fb_sprite = NULL;
125}
126
127#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h
new file mode 100644
index 0000000..ee3c847
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h
@@ -0,0 +1,31 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22#ifndef SDL_riscosframebuffer_c_h_
23#define SDL_riscosframebuffer_c_h_
24
25#include "SDL_internal.h"
26
27extern bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
28extern bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
29extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
30
31#endif // SDL_riscosframebuffer_c_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c
new file mode 100644
index 0000000..a4b358c
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c
@@ -0,0 +1,67 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "SDL_riscosmessagebox.h"
26
27#include <kernel.h>
28#include <swis.h>
29
30bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
31{
32 _kernel_swi_regs regs;
33 _kernel_oserror error;
34 char buttonstring[1024];
35 int i;
36
37 error.errnum = 0;
38 SDL_strlcpy(error.errmess, messageboxdata->message, 252);
39 regs.r[0] = (unsigned int)&error;
40
41 regs.r[1] = (1 << 8) | (1 << 4);
42 if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) {
43 regs.r[1] |= (1 << 9);
44 } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) {
45 regs.r[1] |= (2 << 9);
46 }
47
48 regs.r[2] = (unsigned int)messageboxdata->title;
49 regs.r[3] = 0;
50 regs.r[4] = 0;
51
52 SDL_strlcpy(buttonstring, "", 1024);
53 for (i = 0; i < messageboxdata->numbuttons; i++) {
54 SDL_strlcat(buttonstring, messageboxdata->buttons[i].text, 1024);
55 if (i + 1 < messageboxdata->numbuttons) {
56 SDL_strlcat(buttonstring, ",", 1024);
57 }
58 }
59 regs.r[5] = (unsigned int)buttonstring;
60
61 _kernel_swi(Wimp_ReportError, &regs, &regs);
62
63 *buttonID = (regs.r[1] == 0) ? -1 : messageboxdata->buttons[regs.r[1] - 3].buttonID;
64 return true;
65}
66
67#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h
new file mode 100644
index 0000000..21af02f
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h
@@ -0,0 +1,27 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25extern bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID);
26
27#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c
new file mode 100644
index 0000000..d4e9a53
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c
@@ -0,0 +1,310 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "../SDL_sysvideo.h"
26#include "../../events/SDL_mouse_c.h"
27
28#include "SDL_riscosvideo.h"
29#include "SDL_riscosmodes.h"
30
31#include <kernel.h>
32#include <swis.h>
33
34enum
35{
36 MODE_FLAG_565 = 1 << 7,
37
38 MODE_FLAG_COLOUR_SPACE = 0xF << 12,
39
40 MODE_FLAG_TBGR = 0,
41 MODE_FLAG_TRGB = 1 << 14,
42 MODE_FLAG_ABGR = 1 << 15,
43 MODE_FLAG_ARGB = MODE_FLAG_TRGB | MODE_FLAG_ABGR
44};
45
46static const struct
47{
48 SDL_PixelFormat pixel_format;
49 int modeflags, ncolour, log2bpp;
50} mode_to_pixelformat[] = {
51 // { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 },
52 // { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 },
53 // { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 },
54 // { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 },
55 { SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 },
56 { SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 },
57 { SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 },
58 { SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 },
59 { SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 },
60 { SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 },
61 { SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 },
62 { SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 },
63 { SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 },
64 { SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 },
65 { SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 },
66 { SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 },
67 { SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 },
68 { SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 },
69 { SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 },
70 { SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 }
71};
72
73static SDL_PixelFormat RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp)
74{
75 int i;
76
77 for (i = 0; i < SDL_arraysize(mode_to_pixelformat); i++) {
78 if (log2bpp == mode_to_pixelformat[i].log2bpp &&
79 (ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) &&
80 (modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) {
81 return mode_to_pixelformat[i].pixel_format;
82 }
83 }
84
85 return SDL_PIXELFORMAT_UNKNOWN;
86}
87
88static size_t measure_mode_block(const int *block)
89{
90 size_t blockSize = ((block[0] & 0xFF) == 3) ? 7 : 5;
91 while (block[blockSize] != -1) {
92 blockSize += 2;
93 }
94 blockSize++;
95
96 return blockSize * 4;
97}
98
99static bool read_mode_variable(int *block, int var)
100{
101 _kernel_swi_regs regs;
102 regs.r[0] = (int)block;
103 regs.r[1] = var;
104 _kernel_swi(OS_ReadModeVariable, &regs, &regs);
105 return regs.r[2];
106}
107
108static bool read_mode_block(int *block, SDL_DisplayMode *mode, bool extended)
109{
110 int xres, yres, ncolour, modeflags, log2bpp, rate;
111
112 if ((block[0] & 0xFF) == 1) {
113 xres = block[1];
114 yres = block[2];
115 log2bpp = block[3];
116 rate = block[4];
117 ncolour = (1 << (1 << log2bpp)) - 1;
118 modeflags = MODE_FLAG_TBGR;
119 } else if ((block[0] & 0xFF) == 3) {
120 xres = block[1];
121 yres = block[2];
122 ncolour = block[3];
123 modeflags = block[4];
124 log2bpp = block[5];
125 rate = block[6];
126 } else {
127 return false;
128 }
129
130 if (extended) {
131 xres = read_mode_variable(block, 11) + 1;
132 yres = read_mode_variable(block, 12) + 1;
133 log2bpp = read_mode_variable(block, 9);
134 ncolour = read_mode_variable(block, 3);
135 modeflags = read_mode_variable(block, 0);
136 }
137
138 SDL_zerop(mode);
139 mode->w = xres;
140 mode->h = yres;
141 mode->format = RISCOS_ModeToPixelFormat(ncolour, modeflags, log2bpp);
142 mode->refresh_rate = (float)rate;
143
144 return true;
145}
146
147static void *convert_mode_block(const int *block)
148{
149 int xres, yres, log2bpp, rate, ncolour = 0, modeflags = 0;
150 size_t pos = 0;
151 int *dst;
152
153 if ((block[0] & 0xFF) == 1) {
154 xres = block[1];
155 yres = block[2];
156 log2bpp = block[3];
157 rate = block[4];
158 } else if ((block[0] & 0xFF) == 3) {
159 xres = block[1];
160 yres = block[2];
161 ncolour = block[3];
162 modeflags = block[4];
163 log2bpp = block[5];
164 rate = block[6];
165 } else {
166 return NULL;
167 }
168
169 dst = SDL_malloc(40);
170 if (!dst) {
171 return NULL;
172 }
173
174 dst[pos++] = 1;
175 dst[pos++] = xres;
176 dst[pos++] = yres;
177 dst[pos++] = log2bpp;
178 dst[pos++] = rate;
179 if (ncolour != 0) {
180 dst[pos++] = 3;
181 dst[pos++] = ncolour;
182 }
183 if (modeflags != 0) {
184 dst[pos++] = 0;
185 dst[pos++] = modeflags;
186 }
187 dst[pos++] = -1;
188
189 return dst;
190}
191
192static void *copy_memory(const void *src, size_t size, size_t alloc)
193{
194 void *dst = SDL_malloc(alloc);
195 if (dst) {
196 SDL_memcpy(dst, src, size);
197 }
198 return dst;
199}
200
201bool RISCOS_InitModes(SDL_VideoDevice *_this)
202{
203 SDL_DisplayMode mode;
204 int *current_mode;
205 _kernel_swi_regs regs;
206 _kernel_oserror *error;
207 size_t size;
208
209 regs.r[0] = 1;
210 error = _kernel_swi(OS_ScreenMode, &regs, &regs);
211 if (error) {
212 return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum);
213 }
214
215 current_mode = (int *)regs.r[1];
216 if (!read_mode_block(current_mode, &mode, true)) {
217 return SDL_SetError("Unsupported mode block format %d", current_mode[0]);
218 }
219
220 size = measure_mode_block(current_mode);
221 mode.internal = copy_memory(current_mode, size, size);
222 if (!mode.internal) {
223 return false;
224 }
225
226 if (SDL_AddBasicVideoDisplay(&mode) == 0) {
227 return false;
228 }
229 return true;
230}
231
232bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
233{
234 SDL_DisplayMode mode;
235 _kernel_swi_regs regs;
236 _kernel_oserror *error;
237 void *block, *pos;
238
239 regs.r[0] = 2;
240 regs.r[2] = 0;
241 regs.r[6] = 0;
242 regs.r[7] = 0;
243 error = _kernel_swi(OS_ScreenMode, &regs, &regs);
244 if (error) {
245 return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum);
246 }
247
248 block = SDL_malloc(-regs.r[7]);
249 if (!block) {
250 return false;
251 }
252
253 regs.r[6] = (int)block;
254 regs.r[7] = -regs.r[7];
255 error = _kernel_swi(OS_ScreenMode, &regs, &regs);
256 if (error) {
257 SDL_free(block);
258 return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum);
259 }
260
261 for (pos = block; pos < (void *)regs.r[6]; pos += *((int *)pos)) {
262 if (!read_mode_block(pos + 4, &mode, false)) {
263 continue;
264 }
265
266 if (mode.format == SDL_PIXELFORMAT_UNKNOWN) {
267 continue;
268 }
269
270 mode.internal = convert_mode_block(pos + 4);
271 if (!mode.internal) {
272 SDL_free(block);
273 return false;
274 }
275
276 if (!SDL_AddFullscreenDisplayMode(display, &mode)) {
277 SDL_free(mode.internal);
278 }
279 }
280
281 SDL_free(block);
282 return true;
283}
284
285bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
286{
287 const char disable_cursor[] = { 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
288 _kernel_swi_regs regs;
289 _kernel_oserror *error;
290 int i;
291
292 regs.r[0] = 0;
293 regs.r[1] = (int)mode->internal;
294 error = _kernel_swi(OS_ScreenMode, &regs, &regs);
295 if (error) {
296 return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum);
297 }
298
299 // Turn the text cursor off
300 for (i = 0; i < SDL_arraysize(disable_cursor); i++) {
301 _kernel_oswrch(disable_cursor[i]);
302 }
303
304 // Update cursor visibility, since it may have been disabled by the mode change.
305 SDL_SetCursor(NULL);
306
307 return true;
308}
309
310#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h
new file mode 100644
index 0000000..fa5d65c
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h
@@ -0,0 +1,30 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_riscosmodes_h_
24#define SDL_riscosmodes_h_
25
26extern bool RISCOS_InitModes(SDL_VideoDevice *_this);
27extern bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display);
28extern bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
29
30#endif // SDL_riscosmodes_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c
new file mode 100644
index 0000000..d67e7c8
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c
@@ -0,0 +1,79 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "SDL_riscosvideo.h"
26#include "SDL_riscosmouse.h"
27#include "../../events/SDL_mouse_c.h"
28
29#include <kernel.h>
30
31static SDL_Cursor *RISCOS_CreateDefaultCursor(void)
32{
33 SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor));
34 if (cursor) {
35 // NULL is used to indicate the default cursor
36 cursor->internal = NULL;
37 }
38
39 return cursor;
40}
41
42static void RISCOS_FreeCursor(SDL_Cursor *cursor)
43{
44 SDL_free(cursor);
45}
46
47static bool RISCOS_ShowCursor(SDL_Cursor *cursor)
48{
49 if (cursor) {
50 // Turn the mouse pointer on
51 _kernel_osbyte(106, 1, 0);
52 } else {
53 // Turn the mouse pointer off
54 _kernel_osbyte(106, 0, 0);
55 }
56
57 return true;
58}
59
60bool RISCOS_InitMouse(SDL_VideoDevice *_this)
61{
62 SDL_Mouse *mouse = SDL_GetMouse();
63
64 // mouse->CreateCursor = RISCOS_CreateCursor;
65 // mouse->CreateSystemCursor = RISCOS_CreateSystemCursor;
66 mouse->ShowCursor = RISCOS_ShowCursor;
67 mouse->FreeCursor = RISCOS_FreeCursor;
68 // mouse->WarpMouse = RISCOS_WarpMouse;
69 // mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal;
70 // mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode;
71 // mouse->CaptureMouse = RISCOS_CaptureMouse;
72 // mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState;
73
74 SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor());
75
76 return true;
77}
78
79#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h
new file mode 100644
index 0000000..e28d1dc
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h
@@ -0,0 +1,28 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_riscosmouse_h_
24#define SDL_riscosmouse_h_
25
26extern bool RISCOS_InitMouse(SDL_VideoDevice *_this);
27
28#endif // SDL_riscosmouse_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c
new file mode 100644
index 0000000..1f556d2
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c
@@ -0,0 +1,130 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "../SDL_sysvideo.h"
26#include "../SDL_pixels_c.h"
27#include "../../events/SDL_events_c.h"
28#include "../../events/SDL_keyboard_c.h"
29#include "../../events/SDL_mouse_c.h"
30
31#include "SDL_riscosvideo.h"
32#include "SDL_riscosevents_c.h"
33#include "SDL_riscosframebuffer_c.h"
34#include "SDL_riscosmouse.h"
35#include "SDL_riscosmodes.h"
36#include "SDL_riscoswindow.h"
37#include "SDL_riscosmessagebox.h"
38
39#define RISCOSVID_DRIVER_NAME "riscos"
40
41// Initialization/Query functions
42static bool RISCOS_VideoInit(SDL_VideoDevice *_this);
43static void RISCOS_VideoQuit(SDL_VideoDevice *_this);
44
45// RISC OS driver bootstrap functions
46
47static void RISCOS_DeleteDevice(SDL_VideoDevice *device)
48{
49 SDL_free(device->internal);
50 SDL_free(device);
51}
52
53static SDL_VideoDevice *RISCOS_CreateDevice(void)
54{
55 SDL_VideoDevice *device;
56 SDL_VideoData *data;
57
58 // Initialize all variables that we clean on shutdown
59 device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
60 if (!device) {
61 return NULL;
62 }
63
64 // Initialize internal data
65 data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
66 if (!data) {
67 SDL_free(device);
68 return NULL;
69 }
70
71 device->internal = data;
72
73 // Set the function pointers
74 device->VideoInit = RISCOS_VideoInit;
75 device->VideoQuit = RISCOS_VideoQuit;
76 device->PumpEvents = RISCOS_PumpEvents;
77
78 device->GetDisplayModes = RISCOS_GetDisplayModes;
79 device->SetDisplayMode = RISCOS_SetDisplayMode;
80
81 device->CreateSDLWindow = RISCOS_CreateWindow;
82 device->DestroyWindow = RISCOS_DestroyWindow;
83
84 device->CreateWindowFramebuffer = RISCOS_CreateWindowFramebuffer;
85 device->UpdateWindowFramebuffer = RISCOS_UpdateWindowFramebuffer;
86 device->DestroyWindowFramebuffer = RISCOS_DestroyWindowFramebuffer;
87
88 device->free = RISCOS_DeleteDevice;
89
90 // TODO: Support windowed mode
91 device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY;
92
93 return device;
94}
95
96VideoBootStrap RISCOS_bootstrap = {
97 RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver",
98 RISCOS_CreateDevice,
99 RISCOS_ShowMessageBox,
100 false
101};
102
103static bool RISCOS_VideoInit(SDL_VideoDevice *_this)
104{
105 if (!RISCOS_InitEvents(_this)) {
106 return false;
107 }
108
109 if (!RISCOS_InitMouse(_this)) {
110 return false;
111 }
112
113 // Assume we have a mouse and keyboard
114 SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false);
115 SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false);
116
117 if (!RISCOS_InitModes(_this)) {
118 return false;
119 }
120
121 // We're done!
122 return true;
123}
124
125static void RISCOS_VideoQuit(SDL_VideoDevice *_this)
126{
127 RISCOS_QuitEvents(_this);
128}
129
130#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h
new file mode 100644
index 0000000..f9e42ee
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h
@@ -0,0 +1,36 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_riscosvideo_h_
24#define SDL_riscosvideo_h_
25
26#include "../SDL_sysvideo.h"
27
28#define RISCOS_MAX_KEYS_PRESSED 6
29
30struct SDL_VideoData
31{
32 int last_mouse_buttons;
33 Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
34};
35
36#endif // SDL_riscosvideo_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c
new file mode 100644
index 0000000..cc28123
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c
@@ -0,0 +1,56 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifdef SDL_VIDEO_DRIVER_RISCOS
24
25#include "../SDL_sysvideo.h"
26#include "../../events/SDL_mouse_c.h"
27
28#include "SDL_riscosvideo.h"
29#include "SDL_riscoswindow.h"
30
31bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
32{
33 SDL_WindowData *data;
34
35 data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data));
36 if (!data) {
37 return false;
38 }
39 data->window = window;
40
41 SDL_SetMouseFocus(window);
42
43 // All done!
44 window->internal = data;
45 return true;
46}
47
48void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
49{
50 if (window->internal) {
51 SDL_free(window->internal);
52 window->internal = NULL;
53 }
54}
55
56#endif // SDL_VIDEO_DRIVER_RISCOS
diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h
new file mode 100644
index 0000000..eefec97
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h
@@ -0,0 +1,38 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "SDL_internal.h"
22
23#ifndef SDL_riscoswindow_h_
24#define SDL_riscoswindow_h_
25
26#include "SDL_riscosdefs.h"
27
28struct SDL_WindowData
29{
30 SDL_Window *window;
31 sprite_area *fb_area;
32 sprite_header *fb_sprite;
33};
34
35extern bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props);
36extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
37
38#endif // SDL_riscoswindow_h_
diff --git a/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h
new file mode 100644
index 0000000..2b99135
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h
@@ -0,0 +1,157 @@
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/* RISC OS key code to SDL_Keycode mapping table
23 Sources:
24 - https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes
25*/
26/* *INDENT-OFF* */ // clang-format off
27static SDL_Scancode const riscos_scancode_table[] = {
28 /* 0 */ SDL_SCANCODE_UNKNOWN, // Shift
29 /* 1 */ SDL_SCANCODE_UNKNOWN, // Ctrl
30 /* 2 */ SDL_SCANCODE_UNKNOWN, // Alt
31 /* 3 */ SDL_SCANCODE_LSHIFT,
32 /* 4 */ SDL_SCANCODE_LCTRL,
33 /* 5 */ SDL_SCANCODE_LALT,
34 /* 6 */ SDL_SCANCODE_RSHIFT,
35 /* 7 */ SDL_SCANCODE_RCTRL,
36 /* 8 */ SDL_SCANCODE_RALT,
37 /* 9 */ SDL_SCANCODE_UNKNOWN, // Left mouse
38 /* 10 */ SDL_SCANCODE_UNKNOWN, // Center mouse
39 /* 11 */ SDL_SCANCODE_UNKNOWN, // Right mouse
40 /* 12 */ SDL_SCANCODE_UNKNOWN,
41 /* 13 */ SDL_SCANCODE_UNKNOWN,
42 /* 14 */ SDL_SCANCODE_UNKNOWN,
43 /* 15 */ SDL_SCANCODE_UNKNOWN,
44 /* 16 */ SDL_SCANCODE_Q,
45 /* 17 */ SDL_SCANCODE_3,
46 /* 18 */ SDL_SCANCODE_4,
47 /* 19 */ SDL_SCANCODE_5,
48 /* 20 */ SDL_SCANCODE_F4,
49 /* 21 */ SDL_SCANCODE_8,
50 /* 22 */ SDL_SCANCODE_F7,
51 /* 23 */ SDL_SCANCODE_MINUS,
52 /* 24 */ SDL_SCANCODE_6, // Duplicate of 52
53 /* 25 */ SDL_SCANCODE_LEFT,
54 /* 26 */ SDL_SCANCODE_KP_6,
55 /* 27 */ SDL_SCANCODE_KP_7,
56 /* 28 */ SDL_SCANCODE_F11,
57 /* 29 */ SDL_SCANCODE_F12,
58 /* 30 */ SDL_SCANCODE_F10,
59 /* 31 */ SDL_SCANCODE_SCROLLLOCK,
60 /* 32 */ SDL_SCANCODE_PRINTSCREEN,
61 /* 33 */ SDL_SCANCODE_W,
62 /* 34 */ SDL_SCANCODE_E,
63 /* 35 */ SDL_SCANCODE_T,
64 /* 36 */ SDL_SCANCODE_7,
65 /* 37 */ SDL_SCANCODE_I,
66 /* 38 */ SDL_SCANCODE_9,
67 /* 39 */ SDL_SCANCODE_0,
68 /* 40 */ SDL_SCANCODE_MINUS, // Duplicate of 23
69 /* 41 */ SDL_SCANCODE_DOWN,
70 /* 42 */ SDL_SCANCODE_KP_8,
71 /* 43 */ SDL_SCANCODE_KP_9,
72 /* 44 */ SDL_SCANCODE_PAUSE,
73 /* 45 */ SDL_SCANCODE_GRAVE,
74 /* 46 */ SDL_SCANCODE_CURRENCYUNIT,
75 /* 47 */ SDL_SCANCODE_BACKSPACE,
76 /* 48 */ SDL_SCANCODE_1,
77 /* 49 */ SDL_SCANCODE_2,
78 /* 50 */ SDL_SCANCODE_D,
79 /* 51 */ SDL_SCANCODE_R,
80 /* 52 */ SDL_SCANCODE_6,
81 /* 53 */ SDL_SCANCODE_U,
82 /* 54 */ SDL_SCANCODE_O,
83 /* 55 */ SDL_SCANCODE_P,
84 /* 56 */ SDL_SCANCODE_LEFTBRACKET,
85 /* 57 */ SDL_SCANCODE_UP,
86 /* 58 */ SDL_SCANCODE_KP_PLUS,
87 /* 59 */ SDL_SCANCODE_KP_MINUS,
88 /* 60 */ SDL_SCANCODE_KP_ENTER,
89 /* 61 */ SDL_SCANCODE_INSERT,
90 /* 62 */ SDL_SCANCODE_HOME,
91 /* 63 */ SDL_SCANCODE_PAGEUP,
92 /* 64 */ SDL_SCANCODE_CAPSLOCK,
93 /* 65 */ SDL_SCANCODE_A,
94 /* 66 */ SDL_SCANCODE_X,
95 /* 67 */ SDL_SCANCODE_F,
96 /* 68 */ SDL_SCANCODE_Y,
97 /* 69 */ SDL_SCANCODE_J,
98 /* 70 */ SDL_SCANCODE_K,
99 /* 71 */ SDL_SCANCODE_2, // Duplicate of 49
100 /* 72 */ SDL_SCANCODE_SEMICOLON, // Duplicate of 87
101 /* 73 */ SDL_SCANCODE_RETURN,
102 /* 74 */ SDL_SCANCODE_KP_DIVIDE,
103 /* 75 */ SDL_SCANCODE_UNKNOWN,
104 /* 76 */ SDL_SCANCODE_KP_PERIOD,
105 /* 77 */ SDL_SCANCODE_NUMLOCKCLEAR,
106 /* 78 */ SDL_SCANCODE_PAGEDOWN,
107 /* 79 */ SDL_SCANCODE_APOSTROPHE,
108 /* 80 */ SDL_SCANCODE_UNKNOWN,
109 /* 81 */ SDL_SCANCODE_S,
110 /* 82 */ SDL_SCANCODE_C,
111 /* 83 */ SDL_SCANCODE_G,
112 /* 84 */ SDL_SCANCODE_H,
113 /* 85 */ SDL_SCANCODE_N,
114 /* 86 */ SDL_SCANCODE_L,
115 /* 87 */ SDL_SCANCODE_SEMICOLON,
116 /* 88 */ SDL_SCANCODE_RIGHTBRACKET,
117 /* 89 */ SDL_SCANCODE_DELETE,
118 /* 90 */ SDL_SCANCODE_KP_HASH,
119 /* 91 */ SDL_SCANCODE_KP_MULTIPLY,
120 /* 92 */ SDL_SCANCODE_UNKNOWN,
121 /* 93 */ SDL_SCANCODE_EQUALS,
122 /* 94 */ SDL_SCANCODE_NONUSBACKSLASH,
123 /* 95 */ SDL_SCANCODE_UNKNOWN,
124 /* 96 */ SDL_SCANCODE_TAB,
125 /* 97 */ SDL_SCANCODE_Z,
126 /* 98 */ SDL_SCANCODE_SPACE,
127 /* 99 */ SDL_SCANCODE_V,
128 /* 100 */ SDL_SCANCODE_B,
129 /* 101 */ SDL_SCANCODE_M,
130 /* 102 */ SDL_SCANCODE_COMMA,
131 /* 103 */ SDL_SCANCODE_PERIOD,
132 /* 104 */ SDL_SCANCODE_SLASH,
133 /* 105 */ SDL_SCANCODE_END,
134 /* 106 */ SDL_SCANCODE_KP_0,
135 /* 107 */ SDL_SCANCODE_KP_1,
136 /* 108 */ SDL_SCANCODE_KP_3,
137 /* 109 */ SDL_SCANCODE_UNKNOWN,
138 /* 110 */ SDL_SCANCODE_UNKNOWN,
139 /* 111 */ SDL_SCANCODE_UNKNOWN,
140 /* 112 */ SDL_SCANCODE_ESCAPE,
141 /* 113 */ SDL_SCANCODE_F1,
142 /* 114 */ SDL_SCANCODE_F2,
143 /* 115 */ SDL_SCANCODE_F3,
144 /* 116 */ SDL_SCANCODE_F5,
145 /* 117 */ SDL_SCANCODE_F6,
146 /* 118 */ SDL_SCANCODE_F8,
147 /* 119 */ SDL_SCANCODE_F9,
148 /* 120 */ SDL_SCANCODE_BACKSLASH,
149 /* 121 */ SDL_SCANCODE_RIGHT,
150 /* 122 */ SDL_SCANCODE_KP_4,
151 /* 123 */ SDL_SCANCODE_KP_5,
152 /* 124 */ SDL_SCANCODE_KP_2,
153 /* 125 */ SDL_SCANCODE_LGUI,
154 /* 126 */ SDL_SCANCODE_RGUI,
155 /* 127 */ SDL_SCANCODE_MENU
156};
157/* *INDENT-ON* */ // clang-format on