Mercurial > sdl-ios-xcode
diff src/video/riscos/SDL_wimpvideo.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
line wrap: on
line diff
--- a/src/video/riscos/SDL_wimpvideo.c Mon May 29 03:53:21 2006 +0000 +++ b/src/video/riscos/SDL_wimpvideo.c Mon May 29 04:04:35 2006 +0000 @@ -43,34 +43,34 @@ #include "swis.h" /* Initialization/Query functions */ -SDL_Rect **WIMP_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags); -SDL_Surface *WIMP_SetVideoMode (_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -int WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors); -void WIMP_SetWMCaption (_THIS, const char *title, const char *icon); +SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); +SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width, + int height, int bpp, Uint32 flags); +int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors); +void WIMP_SetWMCaption(_THIS, const char *title, const char *icon); -extern unsigned char *WIMP_CreateBuffer (int width, int height, int bpp); -extern void WIMP_PumpEvents (_THIS); -extern void WIMP_PlotSprite (_THIS, int x, int y); -extern void WIMP_SetupPlotInfo (_THIS); -extern void WIMP_SetFocus (int win); +extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); +extern void WIMP_PumpEvents(_THIS); +extern void WIMP_PlotSprite(_THIS, int x, int y); +extern void WIMP_SetupPlotInfo(_THIS); +extern void WIMP_SetFocus(int win); /* etc. */ -static void WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects); +static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects); /* RISC OS Wimp handling helpers */ -void WIMP_ReadModeInfo (_THIS); -unsigned int WIMP_SetupWindow (_THIS, SDL_Surface * surface); -void WIMP_SetDeviceMode (_THIS); -void WIMP_DeleteWindow (_THIS); +void WIMP_ReadModeInfo(_THIS); +unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface); +void WIMP_SetDeviceMode(_THIS); +void WIMP_DeleteWindow(_THIS); /* FULLSCREEN function required for wimp/fullscreen toggling */ -extern int FULLSCREEN_SetMode (int width, int height, int bpp); +extern int FULLSCREEN_SetMode(int width, int height, int bpp); /* Currently need to set this up here as it only works if you start up in a Wimp mode */ -extern int RISCOS_ToggleFullScreen (_THIS, int fullscreen); +extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen); extern int riscos_backbuffer; extern int mouseInWindow; @@ -78,11 +78,11 @@ /* Following needed to ensure window is shown immediately */ extern int hasFocus; -extern void WIMP_Poll (_THIS, int waitTime); +extern void WIMP_Poll(_THIS, int waitTime); SDL_Surface * -WIMP_SetVideoMode (_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) +WIMP_SetVideoMode(_THIS, SDL_Surface * current, + int width, int height, int bpp, Uint32 flags) { Uint32 Rmask = 0; Uint32 Gmask = 0; @@ -116,7 +116,7 @@ break; default: - SDL_SetError ("Pixel depth not supported"); + SDL_SetError("Pixel depth not supported"); return NULL; break; } @@ -124,9 +124,8 @@ /* printf("Setting mode %dx%d\n", width, height);*/ /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat (current, bpp, Rmask, Gmask, Bmask, 0)) { - SDL_SetError - ("Couldn't allocate new pixel format for requested mode"); + if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { + SDL_SetError("Couldn't allocate new pixel format for requested mode"); return (NULL); } @@ -136,9 +135,9 @@ if (bpp == 15) bpp = 16; - buffer = WIMP_CreateBuffer (width, height, bpp); + buffer = WIMP_CreateBuffer(width, height, bpp); if (buffer == NULL) { - SDL_SetError ("Couldn't create sprite for video memory"); + SDL_SetError("Couldn't create sprite for video memory"); return (NULL); } @@ -150,7 +149,7 @@ /* Remember sprite buffer so it can be freed later */ if (this->hidden->alloc_bank) - SDL_free (this->hidden->alloc_bank); + SDL_free(this->hidden->alloc_bank); this->hidden->alloc_bank = buffer; current->pitch = width * bytesPerPixel; @@ -161,34 +160,34 @@ current->flags = flags | SDL_PREALLOC; - WIMP_ReadModeInfo (this); + WIMP_ReadModeInfo(this); - SDL_memset (this->hidden->bank[0], 0, height * current->pitch); + SDL_memset(this->hidden->bank[0], 0, height * current->pitch); this->hidden->current_bank = 0; current->pixels = this->hidden->bank[0]; - if (WIMP_SetupWindow (this, current) == 0) { - SDL_SetError ("Unable to create window to display surface"); + if (WIMP_SetupWindow(this, current) == 0) { + SDL_SetError("Unable to create window to display surface"); return NULL; } /* Reset device functions for the wimp */ - WIMP_SetDeviceMode (this); + WIMP_SetDeviceMode(this); /* Needs to set up plot info after window has been created */ /* Not sure why, but plots don't work if I do it earlier */ - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); /* Poll until window is shown */ { /* We wait until it gets the focus, but give up after 5 seconds in case the focus is prevented in any way. */ - Uint32 now = SDL_GetTicks (); - while (!hasFocus && SDL_GetTicks () - now < 5000) { - WIMP_Poll (this, 0); + Uint32 now = SDL_GetTicks(); + while (!hasFocus && SDL_GetTicks() - now < 5000) { + WIMP_Poll(this, 0); } } @@ -198,7 +197,7 @@ void -WIMP_ReadModeInfo (_THIS) +WIMP_ReadModeInfo(_THIS) { _kernel_swi_regs regs; int vars[6]; @@ -213,7 +212,7 @@ regs.r[0] = (int) vars; regs.r[1] = (int) vals; - _kernel_swi (OS_ReadVduVariables, ®s, ®s); + _kernel_swi(OS_ReadVduVariables, ®s, ®s); this->hidden->xeig = vals[0]; this->hidden->yeig = vals[1]; this->hidden->screen_bpp = 1 << vals[2]; @@ -225,7 +224,7 @@ in a wimp window */ void -WIMP_SetDeviceMode (_THIS) +WIMP_SetDeviceMode(_THIS) { if (this->UpdateRects == WIMP_UpdateRects) return; /* Already set up */ @@ -249,7 +248,7 @@ /* Setup the Window to display the surface */ unsigned int -WIMP_SetupWindow (_THIS, SDL_Surface * surface) +WIMP_SetupWindow(_THIS, SDL_Surface * surface) { _kernel_swi_regs regs; int window_data[23]; @@ -263,7 +262,7 @@ /* Always delete the window and recreate on a change */ if (this->hidden->window_handle) - WIMP_DeleteWindow (this); + WIMP_DeleteWindow(this); /* Setup window co-ordinates */ window_block[0] = x << xeig; @@ -300,15 +299,15 @@ regs.r[1] = (unsigned int) (window_block); /* Create the window */ - if (_kernel_swi (Wimp_CreateWindow, ®s, ®s) == NULL) { + if (_kernel_swi(Wimp_CreateWindow, ®s, ®s) == NULL) { this->hidden->window_handle = window_data[0] = regs.r[0]; /* Show the window on the screen */ regs.r[1] = (unsigned int) window_data; - if (_kernel_swi (Wimp_OpenWindow, ®s, ®s) == NULL) { - WIMP_SetFocus (this->hidden->window_handle); + if (_kernel_swi(Wimp_OpenWindow, ®s, ®s) == NULL) { + WIMP_SetFocus(this->hidden->window_handle); } else { - WIMP_DeleteWindow (this); + WIMP_DeleteWindow(this); } } @@ -318,17 +317,17 @@ /* Destroy the Window */ void -WIMP_DeleteWindow (_THIS) +WIMP_DeleteWindow(_THIS) { _kernel_swi_regs regs; regs.r[1] = (unsigned int) &(this->hidden->window_handle); - _kernel_swi (Wimp_DeleteWindow, ®s, ®s); + _kernel_swi(Wimp_DeleteWindow, ®s, ®s); this->hidden->window_handle = 0; } void -WIMP_UpdateRects (_THIS, int numrects, SDL_Rect * rects) +WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects) { _kernel_swi_regs regs; int update_block[12]; @@ -345,10 +344,10 @@ regs.r[1] = (int) update_block; /* Update window can fail if called before first poll */ - if (_kernel_swi (Wimp_UpdateWindow, ®s, ®s) == 0) { + if (_kernel_swi(Wimp_UpdateWindow, ®s, ®s) == 0) { while (regs.r[0]) { - WIMP_PlotSprite (this, update_block[1], update_block[2]); - _kernel_swi (Wimp_GetRectangle, ®s, ®s); + WIMP_PlotSprite(this, update_block[1], update_block[2]); + _kernel_swi(Wimp_GetRectangle, ®s, ®s); } } } @@ -356,7 +355,7 @@ int -WIMP_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) +WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) { unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60); int j; @@ -372,40 +371,40 @@ colors++; } - WIMP_SetupPlotInfo (this); + WIMP_SetupPlotInfo(this); /* Need to refresh the window */ update.x = 0; update.y = 0; update.w = SDL_VideoSurface->w; update.h = SDL_VideoSurface->h; - WIMP_UpdateRects (this, 1, &update); + WIMP_UpdateRects(this, 1, &update); return 1; } void -WIMP_SetWMCaption (_THIS, const char *title, const char *icon) +WIMP_SetWMCaption(_THIS, const char *title, const char *icon) { _kernel_swi_regs regs; - SDL_strlcpy (this->hidden->title, title, - SDL_arraysize (this->hidden->title)); + SDL_strlcpy(this->hidden->title, title, + SDL_arraysize(this->hidden->title)); - if (RISCOS_GetWimpVersion () < 380) { + if (RISCOS_GetWimpVersion() < 380) { int block[6]; regs.r[1] = (int) block; - _kernel_swi (Wimp_GetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_GetCaretPosition, ®s, ®s); if (block[0] == (int) this->hidden->window_handle) { regs.r[0] = -1; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = -1; regs.r[2] = -1; regs.r[3] = -1; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } regs.r[0] = block[0]; regs.r[1] = block[1]; @@ -413,17 +412,17 @@ regs.r[3] = block[3]; regs.r[4] = block[4]; regs.r[5] = block[5]; - _kernel_swi (Wimp_SetCaretPosition, ®s, ®s); + _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = 0x4b534154; /* "TASK" */ regs.r[2] = 3; /* Redraw title */ - _kernel_swi (Wimp_ForceRedraw, ®s, ®s); + _kernel_swi(Wimp_ForceRedraw, ®s, ®s); } } void -WIMP_RefreshDesktop (_THIS) +WIMP_RefreshDesktop(_THIS) { int width = this->hidden->screen_width << this->hidden->xeig; int height = this->hidden->screen_height << this->hidden->yeig; @@ -433,12 +432,12 @@ regs.r[2] = 0; regs.r[3] = width; regs.r[4] = height; - _kernel_swi (Wimp_ForceRedraw, ®s, ®s); + _kernel_swi(Wimp_ForceRedraw, ®s, ®s); } /* Toggle to window from full screen */ int -WIMP_ToggleFromFullScreen (_THIS) +WIMP_ToggleFromFullScreen(_THIS) { int width = this->screen->w; int height = this->screen->h; @@ -454,15 +453,15 @@ || riscos_backbuffer == 0) { /* Need to create a sprite for the screen and copy the data to it */ char *data; - buffer = WIMP_CreateBuffer (width, height, bpp); + buffer = WIMP_CreateBuffer(width, height, bpp); data = buffer + 60; /* Start of sprite data */ if (bpp == 8) data += 2048; /* 8bpp sprite have palette first */ if (buffer == NULL) return 0; - SDL_memcpy (data, this->hidden->bank[0], - width * height * this->screen->format->BytesPerPixel); + SDL_memcpy(data, this->hidden->bank[0], + width * height * this->screen->format->BytesPerPixel); } /* else We've switch to full screen before so we already have a sprite */ @@ -481,17 +480,17 @@ this->hidden->current_bank = 0; this->screen->pixels = this->hidden->bank[0]; - RISCOS_RestoreWimpMode (); - WIMP_ReadModeInfo (this); - if (WIMP_SetupWindow (this, this->screen)) { - WIMP_SetDeviceMode (this); - WIMP_SetupPlotInfo (this); + RISCOS_RestoreWimpMode(); + WIMP_ReadModeInfo(this); + if (WIMP_SetupWindow(this, this->screen)) { + WIMP_SetDeviceMode(this); + WIMP_SetupPlotInfo(this); if (riscos_backbuffer == 0) riscos_backbuffer = 1; if (buffer && old_alloc_bank) - SDL_free (old_alloc_bank); + SDL_free(old_alloc_bank); return 1; } else { @@ -500,10 +499,10 @@ this->hidden->bank[1] = old_bank[1]; this->hidden->alloc_bank = old_alloc_bank; if (buffer) - SDL_free (buffer); + SDL_free(buffer); - RISCOS_StoreWimpMode (); - FULLSCREEN_SetMode (width, height, bpp); + RISCOS_StoreWimpMode(); + FULLSCREEN_SetMode(width, height, bpp); } return 0;