annotate src/video/riscos/SDL_wimpvideo.c @ 1338:604d73db6802

Removed uses of stdlib.h and string.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 09:29:18 +0000
parents 3692456e7b0f
children c71e05b4dc2e
rev   line source
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 634
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1035
diff changeset
20 slouken@libsdl.org
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 /*
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
24 File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 27 March 2003
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
27 Implements RISC OS Wimp display.
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include "SDL.h"
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
31 #include "SDL_stdlib.h"
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
32 #include "SDL_string.h"
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 #include "SDL_error.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include "SDL_video.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "SDL_mouse.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "SDL_sysvideo.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 #include "SDL_pixels_c.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #include "SDL_events_c.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 #include "SDL_riscostask.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 #include "SDL_riscosvideo.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 #include "SDL_riscosevents_c.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 #include "SDL_riscosmouse_c.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 #include "kernel.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #include "swis.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 /* Initialization/Query functions */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 void WIMP_SetWMCaption(_THIS, const char *title, const char *icon);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 extern void WIMP_PumpEvents(_THIS);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 extern void WIMP_PlotSprite(_THIS, int x, int y);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 extern void WIMP_SetupPlotInfo(_THIS);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 extern void WIMP_SetFocus(int win);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 /* etc. */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* RISC OS Wimp handling helpers */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 void WIMP_ReadModeInfo(_THIS);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 unsigned int WIMP_SetupWindow(_THIS, SDL_Surface *surface);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 void WIMP_SetDeviceMode(_THIS);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 void WIMP_DeleteWindow(_THIS);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 /* FULLSCREEN function required for wimp/fullscreen toggling */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 extern int FULLSCREEN_SetMode(int width, int height, int bpp);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 /* Currently need to set this up here as it only works if you
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 start up in a Wimp mode */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 extern int riscos_backbuffer;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 extern int mouseInWindow;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 extern int riscos_closeaction;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
634
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
81 /* Following needed to ensure window is shown immediately */
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
82 extern int hasFocus;
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
83 extern void WIMP_Poll(_THIS, int waitTime);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface *current,
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 int width, int height, int bpp, Uint32 flags)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 Uint32 Rmask = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 Uint32 Gmask = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 Uint32 Bmask = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 char *buffer = NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 int bytesPerPixel = 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 /* Don't support double buffering in Wimp mode */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 flags &= ~SDL_DOUBLEBUF;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 flags &= ~SDL_HWSURFACE;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 switch(bpp)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 case 8:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 /* Emulated palette using ColourTrans */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 flags |= SDL_HWPALETTE;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 break;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 case 15:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 case 16:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 Bmask = 0x00007c00;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 Gmask = 0x000003e0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 Rmask = 0x0000001f;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 bytesPerPixel = 2;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 break;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 case 32:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 Bmask = 0x00ff0000;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 Gmask = 0x0000ff00;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 Rmask = 0x000000ff;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 bytesPerPixel = 4;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 break;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 default:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 SDL_SetError("Pixel depth not supported");
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 return NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 break;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 /* printf("Setting mode %dx%d\n", width, height);*/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 /* Allocate the new pixel format for the screen */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 if ( ! SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0) ) {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 SDL_SetError("Couldn't allocate new pixel format for requested mode");
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 return(NULL);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 /* Set up the new mode framebuffer */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 current->w = width;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 this->hidden->height = current->h = height;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 if (bpp == 15) bpp = 16;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 buffer = WIMP_CreateBuffer(width, height, bpp);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 if (buffer == NULL)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 SDL_SetError("Couldn't create sprite for video memory");
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 return (NULL);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 this->hidden->bank[0] = buffer + 60; /* Start of sprite data */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 this->hidden->bank[1] = buffer; /* Start of buffer */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 /* Remember sprite buffer so it can be freed later */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
152 if (this->hidden->alloc_bank) SDL_free(this->hidden->alloc_bank);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 this->hidden->alloc_bank = buffer;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 current->pitch = width * bytesPerPixel;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 if ((current->pitch & 3))
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 /* Sprites are 32bit word aligned */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 current->pitch += (4 - (current->pitch & 3));
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 current->flags = flags | SDL_PREALLOC;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 WIMP_ReadModeInfo(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
166 SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 this->hidden->current_bank = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 current->pixels = this->hidden->bank[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 if (WIMP_SetupWindow(this, current) == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDL_SetError("Unable to create window to display surface");
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 return NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 /* Reset device functions for the wimp */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 WIMP_SetDeviceMode(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
634
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
181 /* Needs to set up plot info after window has been created */
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
182 /* Not sure why, but plots don't work if I do it earlier */
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
183 WIMP_SetupPlotInfo(this);
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
184
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
185 /* Poll until window is shown */
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
186 {
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
187 /* We wait until it gets the focus, but give up after 5 seconds
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
188 in case the focus is prevented in any way.
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
189 */
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
190 Uint32 now = SDL_GetTicks();
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
191 while (!hasFocus && SDL_GetTicks() - now < 5000)
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
192 {
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
193 WIMP_Poll(this, 0);
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
194 }
44d574ed4780 Date: Thu, 05 Jun 2003 09:36:40 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 630
diff changeset
195 }
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 /* We're done */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 return(current);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 void WIMP_ReadModeInfo(_THIS)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 int vars[6];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 int vals[5];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 vars[0] = 4; /* XEig */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 vars[1] = 5; /* YEig */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 vars[2] = 9; /* Log base 2 bpp */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 vars[3] = 11; /* Screen Width - 1 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 vars[4] = 12; /* Screen Depth - 1 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 vars[5] = -1; /* Terminate list */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 regs.r[0] = (int)vars;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 regs.r[1] = (int)vals;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 _kernel_swi(OS_ReadVduVariables, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 this->hidden->xeig = vals[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 this->hidden->yeig = vals[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 this->hidden->screen_bpp = 1 << vals[2];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 this->hidden->screen_width = vals[3] + 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 this->hidden->screen_height = vals[4] + 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 /* Set device function to call the correct versions for running
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 in a wimp window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 void WIMP_SetDeviceMode(_THIS)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 if (this->UpdateRects == WIMP_UpdateRects) return; /* Already set up */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 this->SetColors = WIMP_SetColors;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 this->UpdateRects = WIMP_UpdateRects;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 this->FlipHWSurface = NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 this->SetCaption = WIMP_SetWMCaption;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 this->SetIcon = NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 this->IconifyWindow = NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 this->ShowWMCursor = WIMP_ShowWMCursor;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 this->WarpWMCursor = WIMP_WarpWMCursor;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 this->ToggleFullScreen = RISCOS_ToggleFullScreen;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 this->PumpEvents = WIMP_PumpEvents;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 /* Setup the Window to display the surface */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 unsigned int WIMP_SetupWindow(_THIS, SDL_Surface *surface)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 int window_data[23];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 int *window_block = window_data+1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 int x = (this->hidden->screen_width - surface->w) / 2;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 int y = (this->hidden->screen_height - surface->h) / 2;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 int xeig = this->hidden->xeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 int yeig = this->hidden->yeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 mouseInWindow = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 /* Always delete the window and recreate on a change */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 if (this->hidden->window_handle) WIMP_DeleteWindow(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 /* Setup window co-ordinates */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 window_block[0] = x << xeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 window_block[1] = y << yeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 window_block[2] = window_block[0] + (surface->w << xeig);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 window_block[3] = window_block[1] + (surface->h << yeig);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 window_block[4] = 0; /* Scroll offsets */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 window_block[5] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 window_block[6] = -1; /* Open on top of window stack */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 window_block[7] = 0x85040042; /* Window flags */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 if (riscos_closeaction != 0) window_block[7] |= 0x2000000;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 /* TODO: Take into account surface->flags */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 window_block[8] = 0xff070207; /* Window colours */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 window_block[9] = 0x000c0103;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 window_block[10] = 0; /* Work area minimum */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 window_block[11] = -surface->h << yeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 window_block[12] = surface->w << xeig; /* Work area maximum */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 window_block[13] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 window_block[14] = 0x2700013d; /* Title icon flags */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 window_block[15] = 0x00003000; /* Work area flags - Mouse click down reported */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 window_block[16] = 1; /* Sprite area control block pointer */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 window_block[17] = 0x00100010; /* Minimum window size (width & height) (16x16)*/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 window_block[18] = (int)this->hidden->title; /* Title data */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 window_block[19] = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 window_block[20] = 256;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 window_block[21] = 0; /* Number of icons */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 regs.r[1] = (unsigned int)(window_block);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 /* Create the window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 if (_kernel_swi(Wimp_CreateWindow, &regs, &regs) == NULL)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 this->hidden->window_handle = window_data[0] = regs.r[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 /* Show the window on the screen */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 regs.r[1] = (unsigned int)window_data;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 if (_kernel_swi(Wimp_OpenWindow, &regs, &regs) == NULL)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 WIMP_SetFocus(this->hidden->window_handle);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 } else
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 WIMP_DeleteWindow(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 return this->hidden->window_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 /* Destroy the Window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 void WIMP_DeleteWindow(_THIS)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 regs.r[1] = (unsigned int)&(this->hidden->window_handle);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 _kernel_swi(Wimp_DeleteWindow, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 this->hidden->window_handle = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 int update_block[12];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 int xeig = this->hidden->xeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 int yeig = this->hidden->yeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 int j;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 update_block[0] = this->hidden->window_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 for (j = 0; j < numrects; j++)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 update_block[1] = rects[j].x << xeig; /* Min X */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 update_block[4] = -(rects[j].y << yeig);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 update_block[3] = update_block[1] + (rects[j].w << xeig);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 update_block[2] = update_block[4] - (rects[j].h << yeig);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 regs.r[1] = (int)update_block;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 /* Update window can fail if called before first poll */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 if (_kernel_swi(Wimp_UpdateWindow, &regs, &regs) == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 while (regs.r[0])
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 WIMP_PlotSprite(this, update_block[1], update_block[2]);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 _kernel_swi(Wimp_GetRectangle, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 unsigned int *pal = (unsigned int *)(this->hidden->bank[1]+60);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 int j;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 SDL_Rect update;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 pal += firstcolor*2;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 for (j = 0; j < ncolors; j++)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
367 *pal = (((unsigned int)colors->r) << 8)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 + (((unsigned int)colors->g) << 16)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 + (((unsigned int)colors->b) << 24);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 pal[1] = *pal;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 pal += 2;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 colors++;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 WIMP_SetupPlotInfo(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 /* Need to refresh the window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 update.x = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 update.y = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 update.w = SDL_VideoSurface->w;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 update.h = SDL_VideoSurface->h;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 WIMP_UpdateRects(this, 1, &update);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384 return 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387 void WIMP_SetWMCaption(_THIS, const char *title, const char *icon)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
391 SDL_strncpy(this->hidden->title, title, 255);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 this->hidden->title[255] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 if (RISCOS_GetWimpVersion() < 380)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 int block[6];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 regs.r[1] = (int)block;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 _kernel_swi(Wimp_GetCaretPosition, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 if (block[0] == (int)this->hidden->window_handle)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 regs.r[0] = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
403 _kernel_swi(Wimp_SetCaretPosition, &regs,&regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 } else
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 regs.r[0] = this->hidden->window_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 regs.r[1] = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408 regs.r[2] = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 regs.r[3] = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 _kernel_swi(Wimp_SetCaretPosition, &regs,&regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 regs.r[0] = block[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 regs.r[1] = block[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 regs.r[2] = block[2];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 regs.r[3] = block[3];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 regs.r[4] = block[4];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 regs.r[5] = block[5];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 _kernel_swi(Wimp_SetCaretPosition, &regs,&regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 } else
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 regs.r[0] = this->hidden->window_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 regs.r[1] = 0x4b534154; /* "TASK" */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 regs.r[2] = 3; /* Redraw title */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 void WIMP_RefreshDesktop(_THIS)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 int width = this->hidden->screen_width << this->hidden->xeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 int height = this->hidden->screen_height << this->hidden->yeig;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 regs.r[0] = -1; /* Whole screen */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 regs.r[1] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 regs.r[2] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 regs.r[3] = width;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 regs.r[4] = height;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
438 _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
440
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
441 /* Toggle to window from full screen */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442 int WIMP_ToggleFromFullScreen(_THIS)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
443 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 int width = this->screen->w;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
445 int height = this->screen->h;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
446 int bpp = this->screen->format->BitsPerPixel;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 char *buffer = NULL;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
448 char *old_bank[2];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
449 char *old_alloc_bank;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
450
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
451 /* Ensure flags are OK */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 this->screen->flags &= ~(SDL_DOUBLEBUF|SDL_HWSURFACE);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 if (this->hidden->bank[0] == this->hidden->alloc_bank || riscos_backbuffer == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 /* Need to create a sprite for the screen and copy the data to it */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 char *data;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 buffer = WIMP_CreateBuffer(width, height, bpp);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 data = buffer + 60; /* Start of sprite data */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 if (bpp == 8) data += 2048; /* 8bpp sprite have palette first */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 if (buffer == NULL) return 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
463 SDL_memcpy(data, this->hidden->bank[0], width * height * this->screen->format->BytesPerPixel);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 /* else We've switch to full screen before so we already have a sprite */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467 old_bank[0] = this->hidden->bank[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 old_bank[1] = this->hidden->bank[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 old_alloc_bank = this->hidden->alloc_bank;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471 if (buffer != NULL) this->hidden->alloc_bank = buffer;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 this->hidden->bank[1] = this->hidden->alloc_bank;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
474 this->hidden->bank[0] = this->hidden->bank[1] + 60; /* Start of sprite data */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 if (bpp == 8) this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
476
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 this->hidden->current_bank = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 this->screen->pixels = this->hidden->bank[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480 RISCOS_RestoreWimpMode();
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 WIMP_ReadModeInfo(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 if (WIMP_SetupWindow(this, this->screen))
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 WIMP_SetDeviceMode(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 WIMP_SetupPlotInfo(this);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
487 if (riscos_backbuffer == 0) riscos_backbuffer = 1;
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
489 if (buffer && old_alloc_bank) SDL_free(old_alloc_bank);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 return 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 } else
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 /* Drop back to full screen mode on failure */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 this->hidden->bank[0] = old_bank[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 this->hidden->bank[1] = old_bank[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 this->hidden->alloc_bank = old_alloc_bank;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
498 if (buffer) SDL_free(buffer);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 RISCOS_StoreWimpMode();
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501 FULLSCREEN_SetMode(width, height, bpp);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 return 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505 }