Mercurial > sdl-ios-xcode
comparison src/video/riscos/SDL_riscossprite.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 |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
32 #include "swis.h" | 32 #include "swis.h" |
33 | 33 |
34 #include "SDL_stdinc.h" | 34 #include "SDL_stdinc.h" |
35 #include "SDL_riscosvideo.h" | 35 #include "SDL_riscosvideo.h" |
36 | 36 |
37 extern void WIMP_ReadModeInfo (_THIS); | 37 extern void WIMP_ReadModeInfo(_THIS); |
38 | 38 |
39 void WIMP_PaletteChanged (_THIS); | 39 void WIMP_PaletteChanged(_THIS); |
40 | 40 |
41 | 41 |
42 /* Create sprite buffer for screen */ | 42 /* Create sprite buffer for screen */ |
43 | 43 |
44 unsigned char * | 44 unsigned char * |
45 WIMP_CreateBuffer (int width, int height, int bpp) | 45 WIMP_CreateBuffer(int width, int height, int bpp) |
46 { | 46 { |
47 int size; | 47 int size; |
48 char sprite_name[12] = "display"; | 48 char sprite_name[12] = "display"; |
49 unsigned char *buffer; | 49 unsigned char *buffer; |
50 _kernel_swi_regs regs; | 50 _kernel_swi_regs regs; |
73 if ((bytesPerRow & 3) != 0) { | 73 if ((bytesPerRow & 3) != 0) { |
74 bytesPerRow += 4 - (bytesPerRow & 3); | 74 bytesPerRow += 4 - (bytesPerRow & 3); |
75 } | 75 } |
76 size = bytesPerRow * height; | 76 size = bytesPerRow * height; |
77 | 77 |
78 buffer = SDL_malloc ((size_t) size + offsetToSpriteData); | 78 buffer = SDL_malloc((size_t) size + offsetToSpriteData); |
79 if (!buffer) | 79 if (!buffer) |
80 return NULL; | 80 return NULL; |
81 | 81 |
82 /* Initialise a sprite area */ | 82 /* Initialise a sprite area */ |
83 | 83 |
84 *(unsigned int *) buffer = size + offsetToSpriteData; | 84 *(unsigned int *) buffer = size + offsetToSpriteData; |
85 *(unsigned int *) (buffer + 8) = 16; | 85 *(unsigned int *) (buffer + 8) = 16; |
86 | 86 |
87 regs.r[0] = 256 + 9; | 87 regs.r[0] = 256 + 9; |
88 regs.r[1] = (unsigned int) buffer; | 88 regs.r[1] = (unsigned int) buffer; |
89 _kernel_swi (OS_SpriteOp, ®s, ®s); | 89 _kernel_swi(OS_SpriteOp, ®s, ®s); |
90 | 90 |
91 regs.r[0] = 256 + 15; | 91 regs.r[0] = 256 + 15; |
92 regs.r[1] = (unsigned int) buffer; | 92 regs.r[1] = (unsigned int) buffer; |
93 regs.r[2] = (unsigned int) &sprite_name; | 93 regs.r[2] = (unsigned int) &sprite_name; |
94 regs.r[3] = 0; /* Palette flag: 0 = no palette */ | 94 regs.r[3] = 0; /* Palette flag: 0 = no palette */ |
101 regs.r[6] = (((bpp == 16) ? 5 : 6) << 27) /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */ | 101 regs.r[6] = (((bpp == 16) ? 5 : 6) << 27) /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */ |
102 |(90 << 14) /* Vertical dpi */ | 102 |(90 << 14) /* Vertical dpi */ |
103 |(90 << 1) /* Horizontal dpi */ | 103 |(90 << 1) /* Horizontal dpi */ |
104 |1; /* Marker to distinguish between mode selectors and sprite modes */ | 104 |1; /* Marker to distinguish between mode selectors and sprite modes */ |
105 } | 105 } |
106 if (_kernel_swi (OS_SpriteOp, ®s, ®s) == NULL) { | 106 if (_kernel_swi(OS_SpriteOp, ®s, ®s) == NULL) { |
107 if (bpp == 8) { | 107 if (bpp == 8) { |
108 /* Modify sprite to take into account 256 colour palette */ | 108 /* Modify sprite to take into account 256 colour palette */ |
109 int *sprite = (int *) (buffer + 16); | 109 int *sprite = (int *) (buffer + 16); |
110 /* Adjust sprite offsets */ | 110 /* Adjust sprite offsets */ |
111 sprite[0] += 2048; | 111 sprite[0] += 2048; |
128 } | 128 } |
129 } | 129 } |
130 */ | 130 */ |
131 } | 131 } |
132 } else { | 132 } else { |
133 SDL_free (buffer); | 133 SDL_free(buffer); |
134 buffer = NULL; | 134 buffer = NULL; |
135 } | 135 } |
136 | 136 |
137 return buffer; | 137 return buffer; |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 /* Setup translation buffers for the sprite plotting */ | 141 /* Setup translation buffers for the sprite plotting */ |
142 | 142 |
143 void | 143 void |
144 WIMP_SetupPlotInfo (_THIS) | 144 WIMP_SetupPlotInfo(_THIS) |
145 { | 145 { |
146 _kernel_swi_regs regs; | 146 _kernel_swi_regs regs; |
147 int *sprite = ((int *) this->hidden->bank[1]) + 4; | 147 int *sprite = ((int *) this->hidden->bank[1]) + 4; |
148 | 148 |
149 regs.r[0] = (unsigned int) this->hidden->bank[1]; | 149 regs.r[0] = (unsigned int) this->hidden->bank[1]; |
154 regs.r[5] = 1 | 2 | 16; /* R1 - pointer to sprite and can use full palette words */ | 154 regs.r[5] = 1 | 2 | 16; /* R1 - pointer to sprite and can use full palette words */ |
155 regs.r[6] = 0; | 155 regs.r[6] = 0; |
156 regs.r[7] = 0; | 156 regs.r[7] = 0; |
157 | 157 |
158 if (this->hidden->pixtrans) | 158 if (this->hidden->pixtrans) |
159 SDL_free (this->hidden->pixtrans); | 159 SDL_free(this->hidden->pixtrans); |
160 this->hidden->pixtrans = 0; | 160 this->hidden->pixtrans = 0; |
161 | 161 |
162 /* Get the size required for the buffer */ | 162 /* Get the size required for the buffer */ |
163 _kernel_swi (ColourTrans_GenerateTable, ®s, ®s); | 163 _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); |
164 if (regs.r[4]) { | 164 if (regs.r[4]) { |
165 this->hidden->pixtrans = SDL_malloc (regs.r[4]); | 165 this->hidden->pixtrans = SDL_malloc(regs.r[4]); |
166 | 166 |
167 regs.r[4] = (unsigned int) this->hidden->pixtrans; | 167 regs.r[4] = (unsigned int) this->hidden->pixtrans; |
168 /* Actually read the buffer */ | 168 /* Actually read the buffer */ |
169 _kernel_swi (ColourTrans_GenerateTable, ®s, ®s); | 169 _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 /* Plot the sprite in the given context */ | 173 /* Plot the sprite in the given context */ |
174 void | 174 void |
175 WIMP_PlotSprite (_THIS, int x, int y) | 175 WIMP_PlotSprite(_THIS, int x, int y) |
176 { | 176 { |
177 _kernel_swi_regs regs; | 177 _kernel_swi_regs regs; |
178 _kernel_oserror *err; | 178 _kernel_oserror *err; |
179 | 179 |
180 regs.r[0] = 52 + 512; | 180 regs.r[0] = 52 + 512; |
184 regs.r[4] = y; | 184 regs.r[4] = y; |
185 regs.r[5] = 0 | 32; /* Overwrite screen and pixtrans contains wide colour entries */ | 185 regs.r[5] = 0 | 32; /* Overwrite screen and pixtrans contains wide colour entries */ |
186 regs.r[6] = 0; /* No scale factors i.e. 1:1 */ | 186 regs.r[6] = 0; /* No scale factors i.e. 1:1 */ |
187 regs.r[7] = (int) this->hidden->pixtrans; | 187 regs.r[7] = (int) this->hidden->pixtrans; |
188 | 188 |
189 if ((err = _kernel_swi (OS_SpriteOp, ®s, ®s)) != 0) { | 189 if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) { |
190 int *p = (int *) this->hidden->pixtrans; | 190 int *p = (int *) this->hidden->pixtrans; |
191 printf ("OS_SpriteOp failed \n%s\n", err->errmess); | 191 printf("OS_SpriteOp failed \n%s\n", err->errmess); |
192 printf ("pixtrans %d\n", (int) this->hidden->pixtrans); | 192 printf("pixtrans %d\n", (int) this->hidden->pixtrans); |
193 printf ("%x %x %x\n", p[0], p[1], p[2]); | 193 printf("%x %x %x\n", p[0], p[1], p[2]); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 | 197 |
198 /* Wimp mode has changes so update colour mapping and pixel sizes | 198 /* Wimp mode has changes so update colour mapping and pixel sizes |
199 of windows and the sprites they plot */ | 199 of windows and the sprites they plot */ |
200 | 200 |
201 void | 201 void |
202 WIMP_ModeChanged (_THIS) | 202 WIMP_ModeChanged(_THIS) |
203 { | 203 { |
204 int oldXeig = this->hidden->xeig; | 204 int oldXeig = this->hidden->xeig; |
205 int oldYeig = this->hidden->yeig; | 205 int oldYeig = this->hidden->yeig; |
206 | 206 |
207 WIMP_ReadModeInfo (this); | 207 WIMP_ReadModeInfo(this); |
208 | 208 |
209 if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) { | 209 if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) { |
210 /* Only need to update the palette */ | 210 /* Only need to update the palette */ |
211 WIMP_PaletteChanged (this); | 211 WIMP_PaletteChanged(this); |
212 } else { | 212 } else { |
213 _kernel_swi_regs regs; | 213 _kernel_swi_regs regs; |
214 int window_state[9]; | 214 int window_state[9]; |
215 int extent[4]; | 215 int extent[4]; |
216 int currWidth, currHeight; | 216 int currWidth, currHeight; |
217 int newWidth, newHeight; | 217 int newWidth, newHeight; |
218 | 218 |
219 /* Need to resize windows and update the palette */ | 219 /* Need to resize windows and update the palette */ |
220 WIMP_SetupPlotInfo (this); | 220 WIMP_SetupPlotInfo(this); |
221 | 221 |
222 | 222 |
223 window_state[0] = this->hidden->window_handle; | 223 window_state[0] = this->hidden->window_handle; |
224 regs.r[1] = (unsigned int) window_state; | 224 regs.r[1] = (unsigned int) window_state; |
225 _kernel_swi (Wimp_GetWindowState, ®s, ®s); | 225 _kernel_swi(Wimp_GetWindowState, ®s, ®s); |
226 | 226 |
227 currWidth = window_state[3] - window_state[1]; | 227 currWidth = window_state[3] - window_state[1]; |
228 currHeight = window_state[4] - window_state[2]; | 228 currHeight = window_state[4] - window_state[2]; |
229 | 229 |
230 newWidth = (currWidth >> oldXeig) << this->hidden->xeig; | 230 newWidth = (currWidth >> oldXeig) << this->hidden->xeig; |
244 } | 244 } |
245 extent[3] = 0; | 245 extent[3] = 0; |
246 | 246 |
247 regs.r[0] = this->hidden->window_handle; | 247 regs.r[0] = this->hidden->window_handle; |
248 regs.r[1] = (int) extent; | 248 regs.r[1] = (int) extent; |
249 _kernel_swi (Wimp_SetExtent, ®s, ®s); | 249 _kernel_swi(Wimp_SetExtent, ®s, ®s); |
250 | 250 |
251 /*TODO: May need to set flag to resize window on next open */ | 251 /*TODO: May need to set flag to resize window on next open */ |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 /* Palette has changed so update palettes used for windows sprites */ | 255 /* Palette has changed so update palettes used for windows sprites */ |
256 | 256 |
257 void | 257 void |
258 WIMP_PaletteChanged (_THIS) | 258 WIMP_PaletteChanged(_THIS) |
259 { | 259 { |
260 WIMP_SetupPlotInfo (this); | 260 WIMP_SetupPlotInfo(this); |
261 } | 261 } |
262 | 262 |
263 /* vi: set ts=4 sw=4 expandtab: */ | 263 /* vi: set ts=4 sw=4 expandtab: */ |