Skip to content

Commit

Permalink
riscos: Clean up SWI calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 committed Apr 26, 2019
1 parent 4e2cbf8 commit a1c8bcf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 40 deletions.
8 changes: 5 additions & 3 deletions src/joystick/riscos/SDL_sysjoystick.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@


#include "kernel.h" #include "kernel.h"


#define JOYSTICK_READ 0x43F40 #ifndef Joystick_Read
#define Joystick_Read 0x43F40
#endif


struct joystick_hwdata struct joystick_hwdata
{ {
Expand All @@ -58,7 +60,7 @@ int SDL_SYS_JoystickInit(void)


/* Try to read joystick 0 */ /* Try to read joystick 0 */
regs.r[0] = 0; regs.r[0] = 0;
if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) if (_kernel_swi(Joystick_Read, &regs, &regs) == NULL)
{ {
/* Switch works so assume we've got a joystick */ /* Switch works so assume we've got a joystick */
return 1; return 1;
Expand Down Expand Up @@ -116,7 +118,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
_kernel_swi_regs regs; _kernel_swi_regs regs;
regs.r[0] = joystick->index; regs.r[0] = joystick->index;


if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) if (_kernel_swi(Joystick_Read, &regs, &regs) == NULL)
{ {
int newstate = regs.r[0]; int newstate = regs.r[0];
int oldstate = joystick->hwdata->joystate; int oldstate = joystick->hwdata->joystate;
Expand Down
29 changes: 5 additions & 24 deletions src/video/riscos/SDL_riscosFullScreenVideo.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -359,16 +359,13 @@ void FULLSCREEN_BuildModeList(_THIS)


static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface) static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface *surface)
{ {
_kernel_swi_regs regs;
regs.r[0] = 19;

FULLSCREEN_SetDisplayBank(this->hidden->current_bank); FULLSCREEN_SetDisplayBank(this->hidden->current_bank);
this->hidden->current_bank ^= 1; this->hidden->current_bank ^= 1;
FULLSCREEN_SetWriteBank(this->hidden->current_bank); FULLSCREEN_SetWriteBank(this->hidden->current_bank);
surface->pixels = this->hidden->bank[this->hidden->current_bank]; surface->pixels = this->hidden->bank[this->hidden->current_bank];


/* Wait for Vsync */ /* Wait for Vsync */
_kernel_swi(OS_Byte, &regs, &regs); _kernel_osbyte(19, 0, 0);


return(0); return(0);
} }
Expand Down Expand Up @@ -618,41 +615,25 @@ static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)


void FULLSCREEN_SetWriteBank(int bank) void FULLSCREEN_SetWriteBank(int bank)
{ {
_kernel_swi_regs regs; _kernel_osbyte(112, bank+1, 0);
regs.r[0] = 112;
regs.r[1] = bank+1;
_kernel_swi(OS_Byte, &regs, &regs);
} }


void FULLSCREEN_SetDisplayBank(int bank) void FULLSCREEN_SetDisplayBank(int bank)
{ {
_kernel_swi_regs regs; _kernel_osbyte(113, bank+1, 0);
regs.r[0] = 113;
regs.r[1] = bank+1;
_kernel_swi(OS_Byte, &regs, &regs);
} }




/** Disable special escape key processing */ /** Disable special escape key processing */
static void FULLSCREEN_DisableEscape() static void FULLSCREEN_DisableEscape()
{ {
_kernel_swi_regs regs; _kernel_osbyte(229, 1, 0);
regs.r[0] = 229;
regs.r[1] = 1;
regs.r[2] = 0;
_kernel_swi(OS_Byte, &regs, &regs);

} }


/** Enable special escape key processing */ /** Enable special escape key processing */
static void FULLSCREEN_EnableEscape() static void FULLSCREEN_EnableEscape()
{ {
_kernel_swi_regs regs; _kernel_osbyte(229, 0, 0);
regs.r[0] = 229;
regs.r[1] = 0;
regs.r[2] = 0;
_kernel_swi(OS_Byte, &regs, &regs);

} }


/** Store caption in case this is called before we create a window */ /** Store caption in case this is called before we create a window */
Expand Down
4 changes: 1 addition & 3 deletions src/video/riscos/SDL_riscosevents.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ void RISCOS_PollMouseHelper(_THIS, int fullscreen)
block[3] = last_y & 0xFF; block[3] = last_y & 0xFF;
block[4] = (last_y >> 8) & 0xFF; block[4] = (last_y >> 8) & 0xFF;


regs.r[0] = 21; /* OSWORD pointer stuff code */ _kernel_osword(21, (int *)block);
regs.r[1] = (int)block;
_kernel_swi(OS_Word, &regs, &regs);
} }
} }
} else } else
Expand Down
10 changes: 3 additions & 7 deletions src/video/riscos/SDL_riscosmouse.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
block[3] = osY & 0xFF; block[3] = osY & 0xFF;
block[4] = (osY >> 8) & 0xFF; block[4] = (osY >> 8) & 0xFF;


regs.r[0] = 21; _kernel_osword(21, (int *)block);
regs.r[1] = (int)block;
_kernel_swi(OS_Word, &regs, &regs);
SDL_PrivateMouseMotion(0, 0, x, y); SDL_PrivateMouseMotion(0, 0, x, y);
} }


Expand Down Expand Up @@ -296,9 +294,7 @@ SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode)


} }


regs.r[0] = 21; /* OS word code */ _kernel_osword(21, (int *)block);
regs.r[1] = (int)block;
_kernel_swi(OS_Word, &regs, &regs);
} }


return mode; return mode;
Expand All @@ -317,7 +313,7 @@ void WIMP_SaveCursorPalette()
regs.r[0] = (int)wimp_cursor_palette[colour][0]; regs.r[0] = (int)wimp_cursor_palette[colour][0];
regs.r[1] = 25; regs.r[1] = 25;
/* Read settings with OS_ReadPalette */ /* Read settings with OS_ReadPalette */
if (_kernel_swi(0x2f, &regs, &regs) == NULL) if (_kernel_swi(OS_ReadPalette, &regs, &regs) == NULL)
{ {
wimp_cursor_palette[colour][2] = (unsigned char)((regs.r[2] >> 8) & 0xFF); wimp_cursor_palette[colour][2] = (unsigned char)((regs.r[2] >> 8) & 0xFF);
wimp_cursor_palette[colour][3] = (unsigned char)((regs.r[2] >> 16) & 0xFF); wimp_cursor_palette[colour][3] = (unsigned char)((regs.r[2] >> 16) & 0xFF);
Expand Down
4 changes: 1 addition & 3 deletions src/video/riscos/SDL_riscostask.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ void RISCOS_RestoreWimpMode()
stored_mode = -1; stored_mode = -1;


/* Flush keyboard buffer to dump the keystrokes we've already polled */ /* Flush keyboard buffer to dump the keystrokes we've already polled */
regs.r[0] = 21; _kernel_osbyte(21, 0, 0);
regs.r[1] = 0; /* Keyboard buffer number */
_kernel_swi(OS_Byte, &regs, &regs);


mouseInWindow = 0; mouseInWindow = 0;


Expand Down

0 comments on commit a1c8bcf

Please sign in to comment.