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