Mercurial > sdl-ios-xcode
comparison src/video/aalib/SDL_aavideo.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | d910939febfa |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
39 #include "SDL_aamouse_c.h" | 39 #include "SDL_aamouse_c.h" |
40 | 40 |
41 #include <aalib.h> | 41 #include <aalib.h> |
42 | 42 |
43 /* Initialization/Query functions */ | 43 /* Initialization/Query functions */ |
44 static int AA_VideoInit(_THIS, SDL_PixelFormat *vformat); | 44 static int AA_VideoInit (_THIS, SDL_PixelFormat * vformat); |
45 static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 45 static SDL_Rect **AA_ListModes (_THIS, SDL_PixelFormat * format, |
46 static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 46 Uint32 flags); |
47 static int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); | 47 static SDL_Surface *AA_SetVideoMode (_THIS, SDL_Surface * current, int width, |
48 static void AA_VideoQuit(_THIS); | 48 int height, int bpp, Uint32 flags); |
49 static int AA_SetColors (_THIS, int firstcolor, int ncolors, | |
50 SDL_Color * colors); | |
51 static void AA_VideoQuit (_THIS); | |
49 | 52 |
50 /* Hardware surface functions */ | 53 /* Hardware surface functions */ |
51 static int AA_AllocHWSurface(_THIS, SDL_Surface *surface); | 54 static int AA_AllocHWSurface (_THIS, SDL_Surface * surface); |
52 static int AA_LockHWSurface(_THIS, SDL_Surface *surface); | 55 static int AA_LockHWSurface (_THIS, SDL_Surface * surface); |
53 static int AA_FlipHWSurface(_THIS, SDL_Surface *surface); | 56 static int AA_FlipHWSurface (_THIS, SDL_Surface * surface); |
54 static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface); | 57 static void AA_UnlockHWSurface (_THIS, SDL_Surface * surface); |
55 static void AA_FreeHWSurface(_THIS, SDL_Surface *surface); | 58 static void AA_FreeHWSurface (_THIS, SDL_Surface * surface); |
56 | 59 |
57 /* Cache the VideoDevice struct */ | 60 /* Cache the VideoDevice struct */ |
58 static struct SDL_VideoDevice *local_this; | 61 static struct SDL_VideoDevice *local_this; |
59 | 62 |
60 /* AAlib driver bootstrap functions */ | 63 /* AAlib driver bootstrap functions */ |
61 | 64 |
62 static int AA_Available(void) | 65 static int |
63 { | 66 AA_Available (void) |
64 return 1; /* Always available ! */ | 67 { |
65 } | 68 return 1; /* Always available ! */ |
66 | 69 } |
67 static void AA_DeleteDevice(SDL_VideoDevice *device) | 70 |
68 { | 71 static void |
69 SDL_free(device->hidden); | 72 AA_DeleteDevice (SDL_VideoDevice * device) |
70 SDL_free(device); | 73 { |
71 } | 74 SDL_free (device->hidden); |
72 | 75 SDL_free (device); |
73 static SDL_VideoDevice *AA_CreateDevice(int devindex) | 76 } |
74 { | 77 |
75 SDL_VideoDevice *device; | 78 static SDL_VideoDevice * |
76 | 79 AA_CreateDevice (int devindex) |
77 /* Initialize all variables that we clean on shutdown */ | 80 { |
78 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 81 SDL_VideoDevice *device; |
79 if ( device ) { | 82 |
80 SDL_memset(device, 0, (sizeof *device)); | 83 /* Initialize all variables that we clean on shutdown */ |
81 device->hidden = (struct SDL_PrivateVideoData *) | 84 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)); |
82 SDL_malloc((sizeof *device->hidden)); | 85 if (device) { |
83 } | 86 SDL_memset (device, 0, (sizeof *device)); |
84 if ( (device == NULL) || (device->hidden == NULL) ) { | 87 device->hidden = (struct SDL_PrivateVideoData *) |
85 SDL_OutOfMemory(); | 88 SDL_malloc ((sizeof *device->hidden)); |
86 if ( device ) { | 89 } |
87 SDL_free(device); | 90 if ((device == NULL) || (device->hidden == NULL)) { |
88 } | 91 SDL_OutOfMemory (); |
89 return(0); | 92 if (device) { |
90 } | 93 SDL_free (device); |
91 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | 94 } |
92 | 95 return (0); |
93 /* Set the function pointers */ | 96 } |
94 device->VideoInit = AA_VideoInit; | 97 SDL_memset (device->hidden, 0, (sizeof *device->hidden)); |
95 device->ListModes = AA_ListModes; | 98 |
96 device->SetVideoMode = AA_SetVideoMode; | 99 /* Set the function pointers */ |
97 device->CreateYUVOverlay = NULL; | 100 device->VideoInit = AA_VideoInit; |
98 device->SetColors = AA_SetColors; | 101 device->ListModes = AA_ListModes; |
99 device->UpdateRects = NULL; | 102 device->SetVideoMode = AA_SetVideoMode; |
100 device->VideoQuit = AA_VideoQuit; | 103 device->CreateYUVOverlay = NULL; |
101 device->AllocHWSurface = AA_AllocHWSurface; | 104 device->SetColors = AA_SetColors; |
102 device->CheckHWBlit = NULL; | 105 device->UpdateRects = NULL; |
103 device->FillHWRect = NULL; | 106 device->VideoQuit = AA_VideoQuit; |
104 device->SetHWColorKey = NULL; | 107 device->AllocHWSurface = AA_AllocHWSurface; |
105 device->SetHWAlpha = NULL; | 108 device->CheckHWBlit = NULL; |
106 device->LockHWSurface = AA_LockHWSurface; | 109 device->FillHWRect = NULL; |
107 device->UnlockHWSurface = AA_UnlockHWSurface; | 110 device->SetHWColorKey = NULL; |
108 device->FlipHWSurface = NULL; | 111 device->SetHWAlpha = NULL; |
109 device->FreeHWSurface = AA_FreeHWSurface; | 112 device->LockHWSurface = AA_LockHWSurface; |
110 device->SetCaption = NULL; | 113 device->UnlockHWSurface = AA_UnlockHWSurface; |
111 device->SetIcon = NULL; | 114 device->FlipHWSurface = NULL; |
112 device->IconifyWindow = NULL; | 115 device->FreeHWSurface = AA_FreeHWSurface; |
113 device->GrabInput = NULL; | 116 device->SetCaption = NULL; |
114 device->GetWMInfo = NULL; | 117 device->SetIcon = NULL; |
115 device->InitOSKeymap = AA_InitOSKeymap; | 118 device->IconifyWindow = NULL; |
116 device->PumpEvents = AA_PumpEvents; | 119 device->GrabInput = NULL; |
117 | 120 device->GetWMInfo = NULL; |
118 device->free = AA_DeleteDevice; | 121 device->InitOSKeymap = AA_InitOSKeymap; |
119 | 122 device->PumpEvents = AA_PumpEvents; |
120 return device; | 123 |
124 device->free = AA_DeleteDevice; | |
125 | |
126 return device; | |
121 } | 127 } |
122 | 128 |
123 VideoBootStrap AALIB_bootstrap = { | 129 VideoBootStrap AALIB_bootstrap = { |
124 "aalib", "ASCII Art Library", | 130 "aalib", "ASCII Art Library", |
125 AA_Available, AA_CreateDevice | 131 AA_Available, AA_CreateDevice |
126 }; | 132 }; |
127 | 133 |
128 static void AA_ResizeHandler(aa_context *); | 134 static void AA_ResizeHandler (aa_context *); |
129 | 135 |
130 int AA_VideoInit(_THIS, SDL_PixelFormat *vformat) | 136 int |
131 { | 137 AA_VideoInit (_THIS, SDL_PixelFormat * vformat) |
132 int keyboard; | 138 { |
133 int i; | 139 int keyboard; |
134 | 140 int i; |
135 /* Initialize all variables that we clean on shutdown */ | 141 |
136 for ( i=0; i<SDL_NUMMODES; ++i ) { | 142 /* Initialize all variables that we clean on shutdown */ |
137 SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect)); | 143 for (i = 0; i < SDL_NUMMODES; ++i) { |
138 SDL_modelist[i]->x = SDL_modelist[i]->y = 0; | 144 SDL_modelist[i] = SDL_malloc (sizeof (SDL_Rect)); |
139 } | 145 SDL_modelist[i]->x = SDL_modelist[i]->y = 0; |
140 /* Modes sorted largest to smallest */ | 146 } |
141 SDL_modelist[0]->w = 1024; SDL_modelist[0]->h = 768; | 147 /* Modes sorted largest to smallest */ |
142 SDL_modelist[1]->w = 800; SDL_modelist[1]->h = 600; | 148 SDL_modelist[0]->w = 1024; |
143 SDL_modelist[2]->w = 640; SDL_modelist[2]->h = 480; | 149 SDL_modelist[0]->h = 768; |
144 SDL_modelist[3]->w = 320; SDL_modelist[3]->h = 400; | 150 SDL_modelist[1]->w = 800; |
145 SDL_modelist[4]->w = 320; SDL_modelist[4]->h = 240; | 151 SDL_modelist[1]->h = 600; |
146 SDL_modelist[5]->w = 320; SDL_modelist[5]->h = 200; | 152 SDL_modelist[2]->w = 640; |
147 SDL_modelist[6] = NULL; | 153 SDL_modelist[2]->h = 480; |
148 | 154 SDL_modelist[3]->w = 320; |
149 /* Initialize the library */ | 155 SDL_modelist[3]->h = 400; |
150 | 156 SDL_modelist[4]->w = 320; |
151 AA_mutex = SDL_CreateMutex(); | 157 SDL_modelist[4]->h = 240; |
152 | 158 SDL_modelist[5]->w = 320; |
153 aa_parseoptions (NULL, NULL, NULL, NULL); | 159 SDL_modelist[5]->h = 200; |
154 | 160 SDL_modelist[6] = NULL; |
155 AA_context = aa_autoinit(&aa_defparams); | 161 |
156 if ( ! AA_context ) { | 162 /* Initialize the library */ |
157 SDL_SetError("Unable to initialize AAlib"); | 163 |
158 return(-1); | 164 AA_mutex = SDL_CreateMutex (); |
159 } | 165 |
160 | 166 aa_parseoptions (NULL, NULL, NULL, NULL); |
161 /* Enable mouse and keyboard support */ | 167 |
162 | 168 AA_context = aa_autoinit (&aa_defparams); |
163 if ( ! aa_autoinitkbd (AA_context, AA_SENDRELEASE) ) { | 169 if (!AA_context) { |
164 SDL_SetError("Unable to initialize AAlib keyboard"); | 170 SDL_SetError ("Unable to initialize AAlib"); |
165 return(-1); | 171 return (-1); |
166 } | 172 } |
167 if ( ! aa_autoinitmouse (AA_context, AA_SENDRELEASE) ) { | 173 |
168 fprintf(stderr,"Warning: Unable to initialize AAlib mouse"); | 174 /* Enable mouse and keyboard support */ |
169 } | 175 |
170 AA_rparams = aa_getrenderparams(); | 176 if (!aa_autoinitkbd (AA_context, AA_SENDRELEASE)) { |
171 | 177 SDL_SetError ("Unable to initialize AAlib keyboard"); |
172 local_this = this; | 178 return (-1); |
173 | 179 } |
174 aa_resizehandler(AA_context, AA_ResizeHandler); | 180 if (!aa_autoinitmouse (AA_context, AA_SENDRELEASE)) { |
175 | 181 fprintf (stderr, "Warning: Unable to initialize AAlib mouse"); |
176 fprintf(stderr,"Using AAlib driver: %s (%s)\n", AA_context->driver->name, AA_context->driver->shortname); | 182 } |
177 | 183 AA_rparams = aa_getrenderparams (); |
178 AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname,"X11") == 0); | 184 |
179 /* Determine the screen depth (use default 8-bit depth) */ | 185 local_this = this; |
180 vformat->BitsPerPixel = 8; | 186 |
181 vformat->BytesPerPixel = 1; | 187 aa_resizehandler (AA_context, AA_ResizeHandler); |
182 | 188 |
183 /* We're done! */ | 189 fprintf (stderr, "Using AAlib driver: %s (%s)\n", |
184 return(0); | 190 AA_context->driver->name, AA_context->driver->shortname); |
185 } | 191 |
186 | 192 AA_in_x11 = (SDL_strcmp (AA_context->driver->shortname, "X11") == 0); |
187 SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 193 /* Determine the screen depth (use default 8-bit depth) */ |
188 { | 194 vformat->BitsPerPixel = 8; |
189 if(format->BitsPerPixel != 8) | 195 vformat->BytesPerPixel = 1; |
190 return NULL; | 196 |
191 | 197 /* We're done! */ |
192 if ( flags & SDL_FULLSCREEN ) { | 198 return (0); |
193 return SDL_modelist; | 199 } |
194 } else { | 200 |
195 return (SDL_Rect **) -1; | 201 SDL_Rect ** |
196 } | 202 AA_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) |
203 { | |
204 if (format->BitsPerPixel != 8) | |
205 return NULL; | |
206 | |
207 if (flags & SDL_FULLSCREEN) { | |
208 return SDL_modelist; | |
209 } else { | |
210 return (SDL_Rect **) - 1; | |
211 } | |
197 } | 212 } |
198 | 213 |
199 /* From aavga.c | 214 /* From aavga.c |
200 AAlib does not give us the choice of the actual resolution, thus we have to simulate additional | 215 AAlib does not give us the choice of the actual resolution, thus we have to simulate additional |
201 resolution by scaling down manually each frame | 216 resolution by scaling down manually each frame |
202 */ | 217 */ |
203 static void fastscale (register char *b1, register char *b2, int x1, int x2, int y1, int y2) | 218 static void |
204 { | 219 fastscale (register char *b1, register char *b2, int x1, int x2, int y1, |
205 register int ex, spx = 0, ddx, ddx1; | 220 int y2) |
206 int ddy1, ddy, spy = 0, ey; | 221 { |
207 int x; | 222 register int ex, spx = 0, ddx, ddx1; |
208 char *bb1 = b1; | 223 int ddy1, ddy, spy = 0, ey; |
209 if (!x1 || !x2 || !y1 || !y2) | 224 int x; |
210 return; | 225 char *bb1 = b1; |
211 ddx = x1 + x1; | 226 if (!x1 || !x2 || !y1 || !y2) |
212 ddx1 = x2 + x2; | 227 return; |
213 if (ddx1 < ddx) | 228 ddx = x1 + x1; |
214 spx = ddx / ddx1, ddx %= ddx1; | 229 ddx1 = x2 + x2; |
215 ddy = y1 + y1; | 230 if (ddx1 < ddx) |
216 ddy1 = y2 + y2; | 231 spx = ddx / ddx1, ddx %= ddx1; |
217 if (ddy1 < ddy) | 232 ddy = y1 + y1; |
218 spy = (ddy / ddy1) * x1, ddy %= ddy1; | 233 ddy1 = y2 + y2; |
219 ey = -ddy1; | 234 if (ddy1 < ddy) |
220 for (; y2; y2--) { | 235 spy = (ddy / ddy1) * x1, ddy %= ddy1; |
221 ex = -ddx1; | 236 ey = -ddy1; |
222 for (x = x2; x; x--) { | 237 for (; y2; y2--) { |
223 *b2 = *b1; | 238 ex = -ddx1; |
224 b2++; | 239 for (x = x2; x; x--) { |
225 b1 += spx; | 240 *b2 = *b1; |
226 ex += ddx; | 241 b2++; |
227 if (ex > 0) { | 242 b1 += spx; |
228 b1++; | 243 ex += ddx; |
229 ex -= ddx1; | 244 if (ex > 0) { |
230 } | 245 b1++; |
231 } | 246 ex -= ddx1; |
232 bb1 += spy; | 247 } |
233 ey += ddy; | 248 } |
234 if (ey > 0) { | 249 bb1 += spy; |
235 bb1 += x1; | 250 ey += ddy; |
236 ey -= ddy1; | 251 if (ey > 0) { |
237 } | 252 bb1 += x1; |
238 b1 = bb1; | 253 ey -= ddy1; |
239 } | 254 } |
255 b1 = bb1; | |
256 } | |
240 } | 257 } |
241 | 258 |
242 /* Various screen update functions available */ | 259 /* Various screen update functions available */ |
243 static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | 260 static void AA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects); |
244 | 261 |
245 SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, | 262 SDL_Surface * |
246 int width, int height, int bpp, Uint32 flags) | 263 AA_SetVideoMode (_THIS, SDL_Surface * current, |
247 { | 264 int width, int height, int bpp, Uint32 flags) |
248 int mode; | 265 { |
249 | 266 int mode; |
250 if ( AA_buffer ) { | 267 |
251 SDL_free( AA_buffer ); | 268 if (AA_buffer) { |
252 } | 269 SDL_free (AA_buffer); |
253 | 270 } |
254 AA_buffer = SDL_malloc(width * height); | 271 |
255 if ( ! AA_buffer ) { | 272 AA_buffer = SDL_malloc (width * height); |
256 SDL_SetError("Couldn't allocate buffer for requested mode"); | 273 if (!AA_buffer) { |
257 return(NULL); | 274 SDL_SetError ("Couldn't allocate buffer for requested mode"); |
258 } | 275 return (NULL); |
276 } | |
259 | 277 |
260 /* printf("Setting mode %dx%d\n", width, height); */ | 278 /* printf("Setting mode %dx%d\n", width, height); */ |
261 | 279 |
262 SDL_memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context)); | 280 SDL_memset (aa_image (AA_context), 0, |
263 SDL_memset(AA_buffer, 0, width * height); | 281 aa_imgwidth (AA_context) * aa_imgheight (AA_context)); |
264 | 282 SDL_memset (AA_buffer, 0, width * height); |
265 /* Allocate the new pixel format for the screen */ | 283 |
266 if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) { | 284 /* Allocate the new pixel format for the screen */ |
267 return(NULL); | 285 if (!SDL_ReallocFormat (current, 8, 0, 0, 0, 0)) { |
268 } | 286 return (NULL); |
269 | 287 } |
270 /* Set up the new mode framebuffer */ | 288 |
271 current->flags = SDL_FULLSCREEN; | 289 /* Set up the new mode framebuffer */ |
272 AA_w = current->w = width; | 290 current->flags = SDL_FULLSCREEN; |
273 AA_h = current->h = height; | 291 AA_w = current->w = width; |
274 current->pitch = current->w; | 292 AA_h = current->h = height; |
275 current->pixels = AA_buffer; | 293 current->pitch = current->w; |
276 | 294 current->pixels = AA_buffer; |
277 AA_x_ratio = ((double)aa_imgwidth(AA_context)) / ((double)width); | 295 |
278 AA_y_ratio = ((double)aa_imgheight(AA_context)) / ((double)height); | 296 AA_x_ratio = ((double) aa_imgwidth (AA_context)) / ((double) width); |
279 | 297 AA_y_ratio = ((double) aa_imgheight (AA_context)) / ((double) height); |
280 /* Set the blit function */ | 298 |
281 this->UpdateRects = AA_DirectUpdate; | 299 /* Set the blit function */ |
282 | 300 this->UpdateRects = AA_DirectUpdate; |
283 /* We're done */ | 301 |
284 return(current); | 302 /* We're done */ |
285 } | 303 return (current); |
286 | 304 } |
287 static void AA_ResizeHandler(aa_context *context) | 305 |
288 { | 306 static void |
289 aa_resize(context); | 307 AA_ResizeHandler (aa_context * context) |
290 local_this->hidden->x_ratio = ((double)aa_imgwidth(context)) / ((double)local_this->screen->w); | 308 { |
291 local_this->hidden->y_ratio = ((double)aa_imgheight(context)) / ((double)local_this->screen->h); | 309 aa_resize (context); |
292 | 310 local_this->hidden->x_ratio = |
293 fastscale (local_this->hidden->buffer, aa_image(context), local_this->hidden->w, aa_imgwidth (context), local_this->hidden->h, aa_imgheight (context)); | 311 ((double) aa_imgwidth (context)) / ((double) local_this->screen->w); |
294 aa_renderpalette(context, local_this->hidden->palette, local_this->hidden->rparams, 0, 0, aa_scrwidth(context), aa_scrheight(context)); | 312 local_this->hidden->y_ratio = |
295 aa_flush(context); | 313 ((double) aa_imgheight (context)) / ((double) local_this->screen->h); |
314 | |
315 fastscale (local_this->hidden->buffer, aa_image (context), | |
316 local_this->hidden->w, aa_imgwidth (context), | |
317 local_this->hidden->h, aa_imgheight (context)); | |
318 aa_renderpalette (context, local_this->hidden->palette, | |
319 local_this->hidden->rparams, 0, 0, | |
320 aa_scrwidth (context), aa_scrheight (context)); | |
321 aa_flush (context); | |
296 } | 322 } |
297 | 323 |
298 /* We don't actually allow hardware surfaces other than the main one */ | 324 /* We don't actually allow hardware surfaces other than the main one */ |
299 static int AA_AllocHWSurface(_THIS, SDL_Surface *surface) | 325 static int |
300 { | 326 AA_AllocHWSurface (_THIS, SDL_Surface * surface) |
301 return(-1); | 327 { |
302 } | 328 return (-1); |
303 static void AA_FreeHWSurface(_THIS, SDL_Surface *surface) | 329 } |
304 { | 330 static void |
305 return; | 331 AA_FreeHWSurface (_THIS, SDL_Surface * surface) |
332 { | |
333 return; | |
306 } | 334 } |
307 | 335 |
308 /* We need to wait for vertical retrace on page flipped displays */ | 336 /* We need to wait for vertical retrace on page flipped displays */ |
309 static int AA_LockHWSurface(_THIS, SDL_Surface *surface) | 337 static int |
310 { | 338 AA_LockHWSurface (_THIS, SDL_Surface * surface) |
311 /* TODO ? */ | 339 { |
312 return(0); | 340 /* TODO ? */ |
313 } | 341 return (0); |
314 static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface) | 342 } |
315 { | 343 static void |
316 return; | 344 AA_UnlockHWSurface (_THIS, SDL_Surface * surface) |
345 { | |
346 return; | |
317 } | 347 } |
318 | 348 |
319 /* FIXME: How is this done with AAlib? */ | 349 /* FIXME: How is this done with AAlib? */ |
320 static int AA_FlipHWSurface(_THIS, SDL_Surface *surface) | 350 static int |
321 { | 351 AA_FlipHWSurface (_THIS, SDL_Surface * surface) |
322 SDL_mutexP(AA_mutex); | 352 { |
323 aa_flush(AA_context); | 353 SDL_mutexP (AA_mutex); |
324 SDL_mutexV(AA_mutex); | 354 aa_flush (AA_context); |
325 return(0); | 355 SDL_mutexV (AA_mutex); |
326 } | 356 return (0); |
327 | 357 } |
328 static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | 358 |
329 { | 359 static void |
330 int i; | 360 AA_DirectUpdate (_THIS, int numrects, SDL_Rect * rects) |
331 SDL_Rect *rect; | 361 { |
332 | 362 int i; |
333 fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context)); | 363 SDL_Rect *rect; |
364 | |
365 fastscale (AA_buffer, aa_image (AA_context), AA_w, | |
366 aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context)); | |
334 #if 1 | 367 #if 1 |
335 aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context)); | 368 aa_renderpalette (AA_context, AA_palette, AA_rparams, 0, 0, |
369 aa_scrwidth (AA_context), aa_scrheight (AA_context)); | |
336 #else | 370 #else |
337 /* Render only the rectangles in the list */ | 371 /* Render only the rectangles in the list */ |
338 printf("Update rects : "); | 372 printf ("Update rects : "); |
339 for ( i=0; i < numrects; ++i ) { | 373 for (i = 0; i < numrects; ++i) { |
340 rect = &rects[i]; | 374 rect = &rects[i]; |
341 printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); | 375 printf ("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); |
342 aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio); | 376 aa_renderpalette (AA_context, AA_palette, AA_rparams, |
343 } | 377 rect->x * AA_x_ratio, rect->y * AA_y_ratio, |
344 printf("\n"); | 378 rect->w * AA_x_ratio, rect->h * AA_y_ratio); |
379 } | |
380 printf ("\n"); | |
345 #endif | 381 #endif |
346 SDL_mutexP(AA_mutex); | 382 SDL_mutexP (AA_mutex); |
347 aa_flush(AA_context); | 383 aa_flush (AA_context); |
348 SDL_mutexV(AA_mutex); | 384 SDL_mutexV (AA_mutex); |
349 return; | 385 return; |
350 } | 386 } |
351 | 387 |
352 int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 388 int |
353 { | 389 AA_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
354 int i; | 390 { |
355 | 391 int i; |
356 for ( i=0; i < ncolors; i++ ) { | 392 |
357 aa_setpalette(AA_palette, firstcolor + i, | 393 for (i = 0; i < ncolors; i++) { |
358 colors[i].r>>2, | 394 aa_setpalette (AA_palette, firstcolor + i, |
359 colors[i].g>>2, | 395 colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); |
360 colors[i].b>>2); | 396 } |
361 } | 397 return (1); |
362 return(1); | |
363 } | 398 } |
364 | 399 |
365 /* Note: If we are terminated, this could be called in the middle of | 400 /* Note: If we are terminated, this could be called in the middle of |
366 another SDL video routine -- notably UpdateRects. | 401 another SDL video routine -- notably UpdateRects. |
367 */ | 402 */ |
368 void AA_VideoQuit(_THIS) | 403 void |
369 { | 404 AA_VideoQuit (_THIS) |
370 int i; | 405 { |
371 | 406 int i; |
372 aa_uninitkbd(AA_context); | 407 |
373 aa_uninitmouse(AA_context); | 408 aa_uninitkbd (AA_context); |
374 | 409 aa_uninitmouse (AA_context); |
375 /* Free video mode lists */ | 410 |
376 for ( i=0; i<SDL_NUMMODES; ++i ) { | 411 /* Free video mode lists */ |
377 if ( SDL_modelist[i] != NULL ) { | 412 for (i = 0; i < SDL_NUMMODES; ++i) { |
378 SDL_free(SDL_modelist[i]); | 413 if (SDL_modelist[i] != NULL) { |
379 SDL_modelist[i] = NULL; | 414 SDL_free (SDL_modelist[i]); |
380 } | 415 SDL_modelist[i] = NULL; |
381 } | 416 } |
382 | 417 } |
383 aa_close(AA_context); | 418 |
384 | 419 aa_close (AA_context); |
385 SDL_DestroyMutex(AA_mutex); | 420 |
386 | 421 SDL_DestroyMutex (AA_mutex); |
387 this->screen->pixels = NULL; | 422 |
388 } | 423 this->screen->pixels = NULL; |
424 } | |
425 | |
426 /* vi: set ts=4 sw=4 expandtab: */ |