From a1c8bcf6c5f2eee3a2a8099d59b71ab06261812f Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Fri, 26 Apr 2019 17:41:20 +0100 Subject: [PATCH] riscos: Clean up SWI calls --- src/joystick/riscos/SDL_sysjoystick.c | 8 ++++-- src/video/riscos/SDL_riscosFullScreenVideo.c | 29 ++++---------------- src/video/riscos/SDL_riscosevents.c | 4 +-- src/video/riscos/SDL_riscosmouse.c | 10 ++----- src/video/riscos/SDL_riscostask.c | 4 +-- 5 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/joystick/riscos/SDL_sysjoystick.c b/src/joystick/riscos/SDL_sysjoystick.c index 214d4c747..934714fc6 100644 --- a/src/joystick/riscos/SDL_sysjoystick.c +++ b/src/joystick/riscos/SDL_sysjoystick.c @@ -39,7 +39,9 @@ #include "kernel.h" -#define JOYSTICK_READ 0x43F40 +#ifndef Joystick_Read +#define Joystick_Read 0x43F40 +#endif struct joystick_hwdata { @@ -58,7 +60,7 @@ int SDL_SYS_JoystickInit(void) /* Try to read joystick 0 */ regs.r[0] = 0; - if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) + if (_kernel_swi(Joystick_Read, ®s, ®s) == NULL) { /* Switch works so assume we've got a joystick */ return 1; @@ -116,7 +118,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) _kernel_swi_regs regs; regs.r[0] = joystick->index; - if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) + if (_kernel_swi(Joystick_Read, ®s, ®s) == NULL) { int newstate = regs.r[0]; int oldstate = joystick->hwdata->joystate; diff --git a/src/video/riscos/SDL_riscosFullScreenVideo.c b/src/video/riscos/SDL_riscosFullScreenVideo.c index b8c3cf786..ff7c103d9 100644 --- a/src/video/riscos/SDL_riscosFullScreenVideo.c +++ b/src/video/riscos/SDL_riscosFullScreenVideo.c @@ -359,16 +359,13 @@ void FULLSCREEN_BuildModeList(_THIS) static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface) { - _kernel_swi_regs regs; - regs.r[0] = 19; - FULLSCREEN_SetDisplayBank(this->hidden->current_bank); this->hidden->current_bank ^= 1; FULLSCREEN_SetWriteBank(this->hidden->current_bank); surface->pixels = this->hidden->bank[this->hidden->current_bank]; /* Wait for Vsync */ - _kernel_swi(OS_Byte, ®s, ®s); + _kernel_osbyte(19, 0, 0); return(0); } @@ -618,41 +615,25 @@ static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) void FULLSCREEN_SetWriteBank(int bank) { - _kernel_swi_regs regs; - regs.r[0] = 112; - regs.r[1] = bank+1; - _kernel_swi(OS_Byte, ®s, ®s); + _kernel_osbyte(112, bank+1, 0); } void FULLSCREEN_SetDisplayBank(int bank) { - _kernel_swi_regs regs; - regs.r[0] = 113; - regs.r[1] = bank+1; - _kernel_swi(OS_Byte, ®s, ®s); + _kernel_osbyte(113, bank+1, 0); } /** Disable special escape key processing */ static void FULLSCREEN_DisableEscape() { - _kernel_swi_regs regs; - regs.r[0] = 229; - regs.r[1] = 1; - regs.r[2] = 0; - _kernel_swi(OS_Byte, ®s, ®s); - + _kernel_osbyte(229, 1, 0); } /** Enable special escape key processing */ static void FULLSCREEN_EnableEscape() { - _kernel_swi_regs regs; - regs.r[0] = 229; - regs.r[1] = 0; - regs.r[2] = 0; - _kernel_swi(OS_Byte, ®s, ®s); - + _kernel_osbyte(229, 0, 0); } /** Store caption in case this is called before we create a window */ diff --git a/src/video/riscos/SDL_riscosevents.c b/src/video/riscos/SDL_riscosevents.c index e2525f439..9538a2b5f 100644 --- a/src/video/riscos/SDL_riscosevents.c +++ b/src/video/riscos/SDL_riscosevents.c @@ -329,9 +329,7 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen) block[3] = last_y & 0xFF; block[4] = (last_y >> 8) & 0xFF; - regs.r[0] = 21; /* OSWORD pointer stuff code */ - regs.r[1] = (int)block; - _kernel_swi(OS_Word, ®s, ®s); + _kernel_osword(21, (int *)block); } } } else diff --git a/src/video/riscos/SDL_riscosmouse.c b/src/video/riscos/SDL_riscosmouse.c index b4a0bffc9..90da7324c 100644 --- a/src/video/riscos/SDL_riscosmouse.c +++ b/src/video/riscos/SDL_riscosmouse.c @@ -242,9 +242,7 @@ void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y) block[3] = osY & 0xFF; block[4] = (osY >> 8) & 0xFF; - regs.r[0] = 21; - regs.r[1] = (int)block; - _kernel_swi(OS_Word, ®s, ®s); + _kernel_osword(21, (int *)block); SDL_PrivateMouseMotion(0, 0, x, y); } @@ -296,9 +294,7 @@ SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode) } - regs.r[0] = 21; /* OS word code */ - regs.r[1] = (int)block; - _kernel_swi(OS_Word, ®s, ®s); + _kernel_osword(21, (int *)block); } return mode; @@ -317,7 +313,7 @@ void WIMP_SaveCursorPalette() regs.r[0] = (int)wimp_cursor_palette[colour][0]; regs.r[1] = 25; /* Read settings with OS_ReadPalette */ - if (_kernel_swi(0x2f, ®s, ®s) == NULL) + if (_kernel_swi(OS_ReadPalette, ®s, ®s) == NULL) { wimp_cursor_palette[colour][2] = (unsigned char)((regs.r[2] >> 8) & 0xFF); wimp_cursor_palette[colour][3] = (unsigned char)((regs.r[2] >> 16) & 0xFF); diff --git a/src/video/riscos/SDL_riscostask.c b/src/video/riscos/SDL_riscostask.c index 97b721dda..8ec572f6e 100644 --- a/src/video/riscos/SDL_riscostask.c +++ b/src/video/riscos/SDL_riscostask.c @@ -330,9 +330,7 @@ void RISCOS_RestoreWimpMode() stored_mode = -1; /* Flush keyboard buffer to dump the keystrokes we've already polled */ - regs.r[0] = 21; - regs.r[1] = 0; /* Keyboard buffer number */ - _kernel_swi(OS_Byte, ®s, ®s); + _kernel_osbyte(21, 0, 0); mouseInWindow = 0;