Skip to content

Commit

Permalink
3 air
Browse files Browse the repository at this point in the history
  • Loading branch information
CCIGAMES committed Mar 2, 2024
1 parent 971a781 commit bacaf67
Show file tree
Hide file tree
Showing 14 changed files with 1,716 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
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"

#if SDL_VIDEO_DRIVER_RISCOS

#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(_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 */

/* vi: set ts=4 sw=4 expandtab: */
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
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(_THIS);

#endif /* SDL_riscosmouse_h_ */

/* vi: set ts=4 sw=4 expandtab: */
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
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"

#if SDL_VIDEO_DRIVER_RISCOS

#include "SDL_video.h"
#include "SDL_mouse.h"
#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(_THIS);
static void RISCOS_VideoQuit(_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) {
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(_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(_THIS)
{
RISCOS_QuitEvents(_this);
}

#endif /* SDL_VIDEO_DRIVER_RISCOS */

/* vi: set ts=4 sw=4 expandtab: */
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
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

typedef struct SDL_VideoData
{
int last_mouse_buttons;
Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED];
} SDL_VideoData;

#endif /* SDL_riscosvideo_h_ */

/* vi: set ts=4 sw=4 expandtab: */
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
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"

#if SDL_VIDEO_DRIVER_RISCOS

#include "SDL_version.h"
#include "SDL_syswm.h"
#include "../SDL_sysvideo.h"
#include "../../events/SDL_mouse_c.h"


#include "SDL_riscosvideo.h"
#include "SDL_riscoswindow.h"

int
RISCOS_CreateWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *driverdata;

driverdata = (SDL_WindowData *) SDL_calloc(1, sizeof(*driverdata));
if (!driverdata) {
return SDL_OutOfMemory();
}
driverdata->window = window;

window->flags |= SDL_WINDOW_FULLSCREEN;

SDL_SetMouseFocus(window);

/* All done! */
window->driverdata = driverdata;
return 0;
}

void
RISCOS_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *driverdata = (SDL_WindowData *) window->driverdata;

if (!driverdata)
return;

SDL_free(driverdata);
window->driverdata = NULL;
}

SDL_bool
RISCOS_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
{
if (info->version.major == SDL_MAJOR_VERSION) {
info->subsystem = SDL_SYSWM_RISCOS;
return SDL_TRUE;
} else {
SDL_SetError("Application not compiled with SDL %d",
SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}

#endif /* SDL_VIDEO_DRIVER_RISCOS */

/* vi: set ts=4 sw=4 expandtab: */
Loading

0 comments on commit bacaf67

Please sign in to comment.