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
Expand Up @@ -39,7 +39,9 @@

#include "kernel.h"

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

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

/* Try to read joystick 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 */
return 1;
Expand Down Expand Up @@ -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, &regs, &regs) == NULL)
if (_kernel_swi(Joystick_Read, &regs, &regs) == NULL)
{
int newstate = regs.r[0];
int oldstate = joystick->hwdata->joystate;
Expand Down
29 changes: 5 additions & 24 deletions src/video/riscos/SDL_riscosFullScreenVideo.c
Expand Up @@ -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, &regs, &regs);
_kernel_osbyte(19, 0, 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)
{
_kernel_swi_regs regs;
regs.r[0] = 112;
regs.r[1] = bank+1;
_kernel_swi(OS_Byte, &regs, &regs);
_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, &regs, &regs);
_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, &regs, &regs);

_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, &regs, &regs);

_kernel_osbyte(229, 0, 0);
}

/** 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
Expand Up @@ -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, &regs, &regs);
_kernel_osword(21, (int *)block);
}
}
} else
Expand Down
10 changes: 3 additions & 7 deletions src/video/riscos/SDL_riscosmouse.c
Expand Up @@ -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, &regs, &regs);
_kernel_osword(21, (int *)block);
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 */
regs.r[1] = (int)block;
_kernel_swi(OS_Word, &regs, &regs);
_kernel_osword(21, (int *)block);
}

return mode;
Expand All @@ -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, &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][3] = (unsigned char)((regs.r[2] >> 16) & 0xFF);
Expand Down
4 changes: 1 addition & 3 deletions src/video/riscos/SDL_riscostask.c
Expand Up @@ -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, &regs, &regs);
_kernel_osbyte(21, 0, 0);

mouseInWindow = 0;

Expand Down

0 comments on commit a1c8bcf

Please sign in to comment.