Mercurial > sdl-ios-xcode
comparison src/video/cybergfx/SDL_cgximage.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 |
---|---|
31 #ifdef USE_CGX_WRITELUTPIXEL | 31 #ifdef USE_CGX_WRITELUTPIXEL |
32 #if defined(__SASC) || defined(__PPC__) | 32 #if defined(__SASC) || defined(__PPC__) |
33 #define WLUT WriteLUTPixelArray | 33 #define WLUT WriteLUTPixelArray |
34 #else | 34 #else |
35 void | 35 void |
36 WLUT (APTR a, UWORD b, UWORD c, UWORD d, struct RastPort *e, APTR f, UWORD g, | 36 WLUT(APTR a, UWORD b, UWORD c, UWORD d, struct RastPort *e, APTR f, UWORD g, |
37 UWORD h, UWORD i, UWORD l, UBYTE m) | 37 UWORD h, UWORD i, UWORD l, UBYTE m) |
38 { | 38 { |
39 WriteLUTPixelArray (a, b, c, d, e, f, g, h, i, l, m); | 39 WriteLUTPixelArray(a, b, c, d, e, f, g, h, i, l, m); |
40 } | 40 } |
41 #endif | 41 #endif |
42 | 42 |
43 #endif | 43 #endif |
44 | 44 |
45 /* Various screen update functions available */ | 45 /* Various screen update functions available */ |
46 static void CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects); | 46 static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); |
47 static void CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects); | 47 static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects); |
48 | 48 |
49 BOOL SafeDisp = TRUE, SafeChange = TRUE; | 49 BOOL SafeDisp = TRUE, SafeChange = TRUE; |
50 struct MsgPort *safeport = NULL, *dispport = NULL; | 50 struct MsgPort *safeport = NULL, *dispport = NULL; |
51 ULONG safe_sigbit, disp_sigbit; | 51 ULONG safe_sigbit, disp_sigbit; |
52 int use_picasso96 = 1; | 52 int use_picasso96 = 1; |
53 | 53 |
54 int | 54 int |
55 CGX_SetupImage (_THIS, SDL_Surface * screen) | 55 CGX_SetupImage(_THIS, SDL_Surface * screen) |
56 { | 56 { |
57 SDL_Ximage = NULL; | 57 SDL_Ximage = NULL; |
58 | 58 |
59 if (screen->flags & SDL_HWSURFACE) { | 59 if (screen->flags & SDL_HWSURFACE) { |
60 ULONG pitch; | 60 ULONG pitch; |
61 | 61 |
62 if (!screen->hwdata) { | 62 if (!screen->hwdata) { |
63 if (! | 63 if (!(screen->hwdata = SDL_malloc(sizeof(struct private_hwdata)))) |
64 (screen->hwdata = | |
65 SDL_malloc (sizeof (struct private_hwdata)))) | |
66 return -1; | 64 return -1; |
67 | 65 |
68 D (bug ("Creating system accel struct\n")); | 66 D(bug("Creating system accel struct\n")); |
69 } | 67 } |
70 screen->hwdata->lock = NULL; | 68 screen->hwdata->lock = NULL; |
71 screen->hwdata->allocated = 0; | 69 screen->hwdata->allocated = 0; |
72 screen->hwdata->mask = NULL; | 70 screen->hwdata->mask = NULL; |
73 screen->hwdata->bmap = SDL_RastPort->BitMap; | 71 screen->hwdata->bmap = SDL_RastPort->BitMap; |
74 screen->hwdata->videodata = this; | 72 screen->hwdata->videodata = this; |
75 | 73 |
76 if (!(screen->hwdata->lock = LockBitMapTags (screen->hwdata->bmap, | 74 if (!(screen->hwdata->lock = LockBitMapTags(screen->hwdata->bmap, |
77 LBMI_BASEADDRESS, | 75 LBMI_BASEADDRESS, |
78 (ULONG) & screen-> | 76 (ULONG) & screen-> |
79 pixels, | 77 pixels, |
80 LBMI_BYTESPERROW, | 78 LBMI_BYTESPERROW, |
81 (ULONG) & pitch, | 79 (ULONG) & pitch, |
82 TAG_DONE))) { | 80 TAG_DONE))) { |
83 SDL_free (screen->hwdata); | 81 SDL_free(screen->hwdata); |
84 screen->hwdata = NULL; | 82 screen->hwdata = NULL; |
85 return -1; | 83 return -1; |
86 } else { | 84 } else { |
87 UnLockBitMap (screen->hwdata->lock); | 85 UnLockBitMap(screen->hwdata->lock); |
88 screen->hwdata->lock = NULL; | 86 screen->hwdata->lock = NULL; |
89 } | 87 } |
90 | 88 |
91 screen->pitch = pitch; | 89 screen->pitch = pitch; |
92 | 90 |
93 this->UpdateRects = CGX_FakeUpdate; | 91 this->UpdateRects = CGX_FakeUpdate; |
94 | 92 |
95 D (bug | 93 D(bug |
96 ("Accel video image configured (%lx, pitch %ld).\n", | 94 ("Accel video image configured (%lx, pitch %ld).\n", |
97 screen->pixels, screen->pitch)); | 95 screen->pixels, screen->pitch)); |
98 return 0; | 96 return 0; |
99 } | 97 } |
100 | 98 |
101 screen->pixels = SDL_malloc (screen->h * screen->pitch); | 99 screen->pixels = SDL_malloc(screen->h * screen->pitch); |
102 | 100 |
103 if (screen->pixels == NULL) { | 101 if (screen->pixels == NULL) { |
104 SDL_OutOfMemory (); | 102 SDL_OutOfMemory(); |
105 return (-1); | 103 return (-1); |
106 } | 104 } |
107 | 105 |
108 SDL_Ximage = screen->pixels; | 106 SDL_Ximage = screen->pixels; |
109 | 107 |
110 if (SDL_Ximage == NULL) { | 108 if (SDL_Ximage == NULL) { |
111 SDL_SetError ("Couldn't create XImage"); | 109 SDL_SetError("Couldn't create XImage"); |
112 return (-1); | 110 return (-1); |
113 } | 111 } |
114 | 112 |
115 this->UpdateRects = CGX_NormalUpdate; | 113 this->UpdateRects = CGX_NormalUpdate; |
116 | 114 |
117 return (0); | 115 return (0); |
118 } | 116 } |
119 | 117 |
120 void | 118 void |
121 CGX_DestroyImage (_THIS, SDL_Surface * screen) | 119 CGX_DestroyImage(_THIS, SDL_Surface * screen) |
122 { | 120 { |
123 if (SDL_Ximage) { | 121 if (SDL_Ximage) { |
124 SDL_free (SDL_Ximage); | 122 SDL_free(SDL_Ximage); |
125 SDL_Ximage = NULL; | 123 SDL_Ximage = NULL; |
126 } | 124 } |
127 if (screen) { | 125 if (screen) { |
128 screen->pixels = NULL; | 126 screen->pixels = NULL; |
129 | 127 |
130 if (screen->hwdata) { | 128 if (screen->hwdata) { |
131 SDL_free (screen->hwdata); | 129 SDL_free(screen->hwdata); |
132 screen->hwdata = NULL; | 130 screen->hwdata = NULL; |
133 } | 131 } |
134 } | 132 } |
135 } | 133 } |
136 | 134 |
137 /* This is a hack to see whether this system has more than 1 CPU */ | 135 /* This is a hack to see whether this system has more than 1 CPU */ |
138 static int | 136 static int |
139 num_CPU (void) | 137 num_CPU(void) |
140 { | 138 { |
141 return 1; | 139 return 1; |
142 } | 140 } |
143 | 141 |
144 int | 142 int |
145 CGX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) | 143 CGX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags) |
146 { | 144 { |
147 int retval; | 145 int retval; |
148 | 146 |
149 D (bug ("Calling ResizeImage()\n")); | 147 D(bug("Calling ResizeImage()\n")); |
150 | 148 |
151 CGX_DestroyImage (this, screen); | 149 CGX_DestroyImage(this, screen); |
152 | 150 |
153 if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */ | 151 if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */ |
154 retval = 0; | 152 retval = 0; |
155 } else { | 153 } else { |
156 retval = CGX_SetupImage (this, screen); | 154 retval = CGX_SetupImage(this, screen); |
157 /* We support asynchronous blitting on the display */ | 155 /* We support asynchronous blitting on the display */ |
158 if (flags & SDL_ASYNCBLIT) { | 156 if (flags & SDL_ASYNCBLIT) { |
159 if (num_CPU () > 1) { | 157 if (num_CPU() > 1) { |
160 screen->flags |= SDL_ASYNCBLIT; | 158 screen->flags |= SDL_ASYNCBLIT; |
161 } | 159 } |
162 } | 160 } |
163 } | 161 } |
164 return (retval); | 162 return (retval); |
165 } | 163 } |
166 | 164 |
167 int | 165 int |
168 CGX_AllocHWSurface (_THIS, SDL_Surface * surface) | 166 CGX_AllocHWSurface(_THIS, SDL_Surface * surface) |
169 { | 167 { |
170 D (bug | 168 D(bug |
171 ("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h, | 169 ("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h, |
172 this->hidden->depth)); | 170 this->hidden->depth)); |
173 | 171 |
174 if (surface == SDL_VideoSurface) { | 172 if (surface == SDL_VideoSurface) { |
175 D (bug ("Allocation skipped, it's system one!\n")); | 173 D(bug("Allocation skipped, it's system one!\n")); |
176 return 0; | 174 return 0; |
177 } | 175 } |
178 | 176 |
179 if (!surface->hwdata) { | 177 if (!surface->hwdata) { |
180 if (!(surface->hwdata = SDL_malloc (sizeof (struct private_hwdata)))) | 178 if (!(surface->hwdata = SDL_malloc(sizeof(struct private_hwdata)))) |
181 return -1; | 179 return -1; |
182 } | 180 } |
183 | 181 |
184 surface->hwdata->mask = NULL; | 182 surface->hwdata->mask = NULL; |
185 surface->hwdata->lock = NULL; | 183 surface->hwdata->lock = NULL; |
186 surface->hwdata->videodata = this; | 184 surface->hwdata->videodata = this; |
187 surface->hwdata->allocated = 0; | 185 surface->hwdata->allocated = 0; |
188 | 186 |
189 if (surface->hwdata->bmap = | 187 if (surface->hwdata->bmap = |
190 AllocBitMap (surface->w, surface->h, this->hidden->depth, | 188 AllocBitMap(surface->w, surface->h, this->hidden->depth, |
191 BMF_MINPLANES, SDL_Display->RastPort.BitMap)) { | 189 BMF_MINPLANES, SDL_Display->RastPort.BitMap)) { |
192 surface->hwdata->allocated = 1; | 190 surface->hwdata->allocated = 1; |
193 surface->flags |= SDL_HWSURFACE; | 191 surface->flags |= SDL_HWSURFACE; |
194 D (bug ("...OK\n")); | 192 D(bug("...OK\n")); |
195 return 0; | 193 return 0; |
196 } else { | 194 } else { |
197 SDL_free (surface->hwdata); | 195 SDL_free(surface->hwdata); |
198 surface->hwdata = NULL; | 196 surface->hwdata = NULL; |
199 } | 197 } |
200 | 198 |
201 return (-1); | 199 return (-1); |
202 } | 200 } |
203 | 201 |
204 void | 202 void |
205 CGX_FreeHWSurface (_THIS, SDL_Surface * surface) | 203 CGX_FreeHWSurface(_THIS, SDL_Surface * surface) |
206 { | 204 { |
207 if (surface && surface != SDL_VideoSurface && surface->hwdata) { | 205 if (surface && surface != SDL_VideoSurface && surface->hwdata) { |
208 D (bug ("Free hw surface.\n")); | 206 D(bug("Free hw surface.\n")); |
209 | 207 |
210 if (surface->hwdata->mask) | 208 if (surface->hwdata->mask) |
211 SDL_free (surface->hwdata->mask); | 209 SDL_free(surface->hwdata->mask); |
212 | 210 |
213 if (surface->hwdata->bmap && surface->hwdata->allocated) | 211 if (surface->hwdata->bmap && surface->hwdata->allocated) |
214 FreeBitMap (surface->hwdata->bmap); | 212 FreeBitMap(surface->hwdata->bmap); |
215 | 213 |
216 SDL_free (surface->hwdata); | 214 SDL_free(surface->hwdata); |
217 surface->hwdata = NULL; | 215 surface->hwdata = NULL; |
218 surface->pixels = NULL; | 216 surface->pixels = NULL; |
219 D (bug ("end of free hw surface\n")); | 217 D(bug("end of free hw surface\n")); |
220 } | 218 } |
221 return; | 219 return; |
222 } | 220 } |
223 | 221 |
224 int | 222 int |
225 CGX_LockHWSurface (_THIS, SDL_Surface * surface) | 223 CGX_LockHWSurface(_THIS, SDL_Surface * surface) |
226 { | 224 { |
227 if (surface->hwdata) { | 225 if (surface->hwdata) { |
228 // D(bug("Locking a bitmap...\n")); | 226 // D(bug("Locking a bitmap...\n")); |
229 if (!surface->hwdata->lock) { | 227 if (!surface->hwdata->lock) { |
230 Uint32 pitch; | 228 Uint32 pitch; |
231 | 229 |
232 if (! | 230 if (! |
233 (surface->hwdata->lock = | 231 (surface->hwdata->lock = |
234 LockBitMapTags (surface->hwdata->bmap, LBMI_BASEADDRESS, | 232 LockBitMapTags(surface->hwdata->bmap, LBMI_BASEADDRESS, |
235 (ULONG) & surface->pixels, | 233 (ULONG) & surface->pixels, |
236 LBMI_BYTESPERROW, (ULONG) & pitch, | 234 LBMI_BYTESPERROW, (ULONG) & pitch, TAG_DONE))) |
237 TAG_DONE))) | |
238 return -1; | 235 return -1; |
239 | 236 |
240 // surface->pitch e' a 16bit! | 237 // surface->pitch e' a 16bit! |
241 | 238 |
242 surface->pitch = pitch; | 239 surface->pitch = pitch; |
247 (surface->pitch * | 244 (surface->pitch * |
248 (SDL_Window->BorderTop + SDL_Window->TopEdge) + | 245 (SDL_Window->BorderTop + SDL_Window->TopEdge) + |
249 surface->format->BytesPerPixel * | 246 surface->format->BytesPerPixel * |
250 (SDL_Window->BorderLeft + SDL_Window->LeftEdge)); | 247 (SDL_Window->BorderLeft + SDL_Window->LeftEdge)); |
251 } | 248 } |
252 D ( | 249 D( |
253 else | 250 else |
254 bug ("Already locked!!!\n")); | 251 bug("Already locked!!!\n")); |
255 } | 252 } |
256 return (0); | 253 return (0); |
257 } | 254 } |
258 | 255 |
259 void | 256 void |
260 CGX_UnlockHWSurface (_THIS, SDL_Surface * surface) | 257 CGX_UnlockHWSurface(_THIS, SDL_Surface * surface) |
261 { | 258 { |
262 if (surface->hwdata && surface->hwdata->lock) { | 259 if (surface->hwdata && surface->hwdata->lock) { |
263 UnLockBitMap (surface->hwdata->lock); | 260 UnLockBitMap(surface->hwdata->lock); |
264 surface->hwdata->lock = NULL; | 261 surface->hwdata->lock = NULL; |
265 // surface->pixels=NULL; | 262 // surface->pixels=NULL; |
266 } | 263 } |
267 } | 264 } |
268 | 265 |
269 int | 266 int |
270 CGX_FlipHWSurface (_THIS, SDL_Surface * surface) | 267 CGX_FlipHWSurface(_THIS, SDL_Surface * surface) |
271 { | 268 { |
272 static int current = 0; | 269 static int current = 0; |
273 | 270 |
274 if (this->hidden->dbuffer) { | 271 if (this->hidden->dbuffer) { |
275 if (!SafeChange) { | 272 if (!SafeChange) { |
276 Wait (disp_sigbit); | 273 Wait(disp_sigbit); |
277 // Non faccio nulla, vuoto solo la porta | 274 // Non faccio nulla, vuoto solo la porta |
278 while (GetMsg (dispport) != NULL); | 275 while (GetMsg(dispport) != NULL); |
279 SafeChange = TRUE; | 276 SafeChange = TRUE; |
280 } | 277 } |
281 | 278 |
282 if (ChangeScreenBuffer (SDL_Display, this->hidden->SB[current ^ 1])) { | 279 if (ChangeScreenBuffer(SDL_Display, this->hidden->SB[current ^ 1])) { |
283 surface->hwdata->bmap = SDL_RastPort->BitMap = | 280 surface->hwdata->bmap = SDL_RastPort->BitMap = |
284 this->hidden->SB[current]->sb_BitMap; | 281 this->hidden->SB[current]->sb_BitMap; |
285 SafeChange = FALSE; | 282 SafeChange = FALSE; |
286 SafeDisp = FALSE; | 283 SafeDisp = FALSE; |
287 current ^= 1; | 284 current ^= 1; |
288 } | 285 } |
289 | 286 |
290 if (!SafeDisp) { | 287 if (!SafeDisp) { |
291 Wait (safe_sigbit); | 288 Wait(safe_sigbit); |
292 while (GetMsg (safeport) != NULL); | 289 while (GetMsg(safeport) != NULL); |
293 SafeDisp = TRUE; | 290 SafeDisp = TRUE; |
294 } | 291 } |
295 | 292 |
296 } | 293 } |
297 return (0); | 294 return (0); |
298 } | 295 } |
299 | 296 |
300 /* Byte-swap the pixels in the display image */ | 297 /* Byte-swap the pixels in the display image */ |
301 static void | 298 static void |
302 CGX_SwapAllPixels (SDL_Surface * screen) | 299 CGX_SwapAllPixels(SDL_Surface * screen) |
303 { | 300 { |
304 int x, y; | 301 int x, y; |
305 | 302 |
306 switch (screen->format->BytesPerPixel) { | 303 switch (screen->format->BytesPerPixel) { |
307 case 2: | 304 case 2: |
309 Uint16 *spot; | 306 Uint16 *spot; |
310 for (y = 0; y < screen->h; ++y) { | 307 for (y = 0; y < screen->h; ++y) { |
311 spot = (Uint16 *) ((Uint8 *) screen->pixels + | 308 spot = (Uint16 *) ((Uint8 *) screen->pixels + |
312 y * screen->pitch); | 309 y * screen->pitch); |
313 for (x = 0; x < screen->w; ++x, ++spot) { | 310 for (x = 0; x < screen->w; ++x, ++spot) { |
314 *spot = SDL_Swap16 (*spot); | 311 *spot = SDL_Swap16(*spot); |
315 } | 312 } |
316 } | 313 } |
317 } | 314 } |
318 break; | 315 break; |
319 | 316 |
322 Uint32 *spot; | 319 Uint32 *spot; |
323 for (y = 0; y < screen->h; ++y) { | 320 for (y = 0; y < screen->h; ++y) { |
324 spot = (Uint32 *) ((Uint8 *) screen->pixels + | 321 spot = (Uint32 *) ((Uint8 *) screen->pixels + |
325 y * screen->pitch); | 322 y * screen->pitch); |
326 for (x = 0; x < screen->w; ++x, ++spot) { | 323 for (x = 0; x < screen->w; ++x, ++spot) { |
327 *spot = SDL_Swap32 (*spot); | 324 *spot = SDL_Swap32(*spot); |
328 } | 325 } |
329 } | 326 } |
330 } | 327 } |
331 break; | 328 break; |
332 | 329 |
334 /* should never get here */ | 331 /* should never get here */ |
335 break; | 332 break; |
336 } | 333 } |
337 } | 334 } |
338 static void | 335 static void |
339 CGX_SwapPixels (SDL_Surface * screen, int numrects, SDL_Rect * rects) | 336 CGX_SwapPixels(SDL_Surface * screen, int numrects, SDL_Rect * rects) |
340 { | 337 { |
341 int i; | 338 int i; |
342 int x, minx, maxx; | 339 int x, minx, maxx; |
343 int y, miny, maxy; | 340 int y, miny, maxy; |
344 | 341 |
353 maxy = rects[i].y + rects[i].h; | 350 maxy = rects[i].y + rects[i].h; |
354 for (y = miny; y < maxy; ++y) { | 351 for (y = miny; y < maxy; ++y) { |
355 spot = (Uint16 *) ((Uint8 *) screen->pixels + | 352 spot = (Uint16 *) ((Uint8 *) screen->pixels + |
356 y * screen->pitch + minx * 2); | 353 y * screen->pitch + minx * 2); |
357 for (x = minx; x < maxx; ++x, ++spot) { | 354 for (x = minx; x < maxx; ++x, ++spot) { |
358 *spot = SDL_Swap16 (*spot); | 355 *spot = SDL_Swap16(*spot); |
359 } | 356 } |
360 } | 357 } |
361 } | 358 } |
362 } | 359 } |
363 break; | 360 break; |
372 maxy = rects[i].y + rects[i].h; | 369 maxy = rects[i].y + rects[i].h; |
373 for (y = miny; y < maxy; ++y) { | 370 for (y = miny; y < maxy; ++y) { |
374 spot = (Uint32 *) ((Uint8 *) screen->pixels + | 371 spot = (Uint32 *) ((Uint8 *) screen->pixels + |
375 y * screen->pitch + minx * 4); | 372 y * screen->pitch + minx * 4); |
376 for (x = minx; x < maxx; ++x, ++spot) { | 373 for (x = minx; x < maxx; ++x, ++spot) { |
377 *spot = SDL_Swap32 (*spot); | 374 *spot = SDL_Swap32(*spot); |
378 } | 375 } |
379 } | 376 } |
380 } | 377 } |
381 } | 378 } |
382 break; | 379 break; |
391 | 388 |
392 #define USE_WPA WritePixelArray | 389 #define USE_WPA WritePixelArray |
393 #else | 390 #else |
394 | 391 |
395 void | 392 void |
396 USE_WPA (char *a, int b, int c, int d, struct RastPort *e, int f, int g, | 393 USE_WPA(char *a, int b, int c, int d, struct RastPort *e, int f, int g, |
397 int h, int i, Uint32 l) | 394 int h, int i, Uint32 l) |
398 { | 395 { |
399 WritePixelArray (a, b, c, d, e, f, g, h, i, l); | 396 WritePixelArray(a, b, c, d, e, f, g, h, i, l); |
400 } | 397 } |
401 | 398 |
402 #endif | 399 #endif |
403 | 400 |
404 static void | 401 static void |
405 CGX_FakeUpdate (_THIS, int numrects, SDL_Rect * rects) | 402 CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects) |
406 { | 403 { |
407 } | 404 } |
408 | 405 |
409 static void | 406 static void |
410 CGX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) | 407 CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) |
411 { | 408 { |
412 int i, format, customroutine = 0; | 409 int i, format, customroutine = 0; |
413 #ifndef USE_CGX_WRITELUTPIXEL | 410 #ifndef USE_CGX_WRITELUTPIXEL |
414 int bpp; | 411 int bpp; |
415 #endif | 412 #endif |
445 // format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray. | 442 // format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray. |
446 } else | 443 } else |
447 customroutine = 1; | 444 customroutine = 1; |
448 break; | 445 break; |
449 default: | 446 default: |
450 D (bug ("Unable to blit this surface!\n")); | 447 D(bug("Unable to blit this surface!\n")); |
451 return; | 448 return; |
452 } | 449 } |
453 | 450 |
454 /* Check for endian-swapped X server, swap if necessary (VERY slow!) */ | 451 /* Check for endian-swapped X server, swap if necessary (VERY slow!) */ |
455 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { | 452 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { |
456 D (bug ("Software Swapping! SLOOOW!\n")); | 453 D(bug("Software Swapping! SLOOOW!\n")); |
457 CGX_SwapPixels (this->screen, numrects, rects); | 454 CGX_SwapPixels(this->screen, numrects, rects); |
458 for (i = 0; i < numrects; ++i) { | 455 for (i = 0; i < numrects; ++i) { |
459 if (!rects[i].w) { /* Clipped? */ | 456 if (!rects[i].w) { /* Clipped? */ |
460 continue; | 457 continue; |
461 } | 458 } |
462 USE_WPA (this->screen->pixels, rects[i].x, rects[i].y, | 459 USE_WPA(this->screen->pixels, rects[i].x, rects[i].y, |
463 this->screen->pitch, SDL_RastPort, | 460 this->screen->pitch, SDL_RastPort, |
464 SDL_Window->BorderLeft + rects[i].x, | 461 SDL_Window->BorderLeft + rects[i].x, |
465 SDL_Window->BorderTop + rects[i].y, rects[i].w, | 462 SDL_Window->BorderTop + rects[i].y, rects[i].w, |
466 rects[i].h, format); | 463 rects[i].h, format); |
467 } | 464 } |
468 CGX_SwapPixels (this->screen, numrects, rects); | 465 CGX_SwapPixels(this->screen, numrects, rects); |
469 } else if (customroutine == 2) { | 466 } else if (customroutine == 2) { |
470 #ifdef USE_CGX_WRITELUTPIXEL | 467 #ifdef USE_CGX_WRITELUTPIXEL |
471 for (i = 0; i < numrects; ++i) { | 468 for (i = 0; i < numrects; ++i) { |
472 if (!rects[i].w) { /* Clipped? */ | 469 if (!rects[i].w) { /* Clipped? */ |
473 continue; | 470 continue; |
474 } | 471 } |
475 | 472 |
476 WLUT (this->screen->pixels, rects[i].x, rects[i].y, | 473 WLUT(this->screen->pixels, rects[i].x, rects[i].y, |
477 this->screen->pitch, SDL_RastPort, SDL_XPixels, | 474 this->screen->pitch, SDL_RastPort, SDL_XPixels, |
478 SDL_Window->BorderLeft + rects[i].x, | 475 SDL_Window->BorderLeft + rects[i].x, |
479 SDL_Window->BorderTop + rects[i].y, rects[i].w, | 476 SDL_Window->BorderTop + rects[i].y, rects[i].w, |
480 rects[i].h, CTABFMT_XRGB8); | 477 rects[i].h, CTABFMT_XRGB8); |
481 } | 478 } |
482 #else | 479 #else |
483 unsigned char *bm_address; | 480 unsigned char *bm_address; |
484 Uint32 destpitch; | 481 Uint32 destpitch; |
485 APTR handle; | 482 APTR handle; |
486 | 483 |
487 if (handle = | 484 if (handle = |
488 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 485 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
489 &bm_address, LBMI_BYTESPERROW, &destpitch, | 486 &bm_address, LBMI_BYTESPERROW, &destpitch, |
490 TAG_DONE)) { | 487 TAG_DONE)) { |
491 int srcwidth; | 488 int srcwidth; |
492 unsigned char *destbase; | 489 unsigned char *destbase; |
493 register int j, k, t; | 490 register int j, k, t; |
494 register unsigned char *mask, *dst; | 491 register unsigned char *mask, *dst; |
495 register unsigned char *src, *dest; | 492 register unsigned char *src, *dest; |
528 } | 525 } |
529 src += this->screen->pitch; | 526 src += this->screen->pitch; |
530 dest += destpitch; | 527 dest += destpitch; |
531 } | 528 } |
532 } | 529 } |
533 UnLockBitMap (handle); | 530 UnLockBitMap(handle); |
534 } | 531 } |
535 } else if (customroutine == 3) { | 532 } else if (customroutine == 3) { |
536 unsigned char *bm_address; | 533 unsigned char *bm_address; |
537 Uint32 destpitch; | 534 Uint32 destpitch; |
538 APTR handle; | 535 APTR handle; |
539 | 536 |
540 if (handle = | 537 if (handle = |
541 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 538 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
542 &bm_address, LBMI_BYTESPERROW, &destpitch, | 539 &bm_address, LBMI_BYTESPERROW, &destpitch, |
543 TAG_DONE)) { | 540 TAG_DONE)) { |
544 int srcwidth; | 541 int srcwidth; |
545 unsigned char *destbase; | 542 unsigned char *destbase; |
546 register int j, k; | 543 register int j, k; |
547 register unsigned char *src, *dest; | 544 register unsigned char *src, *dest; |
548 register Uint16 *destl, *srcl; | 545 register Uint16 *destl, *srcl; |
580 } | 577 } |
581 src += this->screen->pitch; | 578 src += this->screen->pitch; |
582 dest += destpitch; | 579 dest += destpitch; |
583 } | 580 } |
584 } | 581 } |
585 UnLockBitMap (handle); | 582 UnLockBitMap(handle); |
586 } | 583 } |
587 } else if (customroutine == 4) { | 584 } else if (customroutine == 4) { |
588 unsigned char *bm_address; | 585 unsigned char *bm_address; |
589 Uint32 destpitch; | 586 Uint32 destpitch; |
590 APTR handle; | 587 APTR handle; |
591 | 588 |
592 if (handle = | 589 if (handle = |
593 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 590 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
594 &bm_address, LBMI_BYTESPERROW, &destpitch, | 591 &bm_address, LBMI_BYTESPERROW, &destpitch, |
595 TAG_DONE)) { | 592 TAG_DONE)) { |
596 int srcwidth; | 593 int srcwidth; |
597 unsigned char *destbase; | 594 unsigned char *destbase; |
598 register int j, k; | 595 register int j, k; |
599 register unsigned char *src, *dest; | 596 register unsigned char *src, *dest; |
600 register Uint32 *destl, *srcl; | 597 register Uint32 *destl, *srcl; |
632 } | 629 } |
633 src += this->screen->pitch; | 630 src += this->screen->pitch; |
634 dest += destpitch; | 631 dest += destpitch; |
635 } | 632 } |
636 } | 633 } |
637 UnLockBitMap (handle); | 634 UnLockBitMap(handle); |
638 } | 635 } |
639 #endif | 636 #endif |
640 } else if (customroutine) { | 637 } else if (customroutine) { |
641 unsigned char *bm_address; | 638 unsigned char *bm_address; |
642 Uint32 destpitch; | 639 Uint32 destpitch; |
643 APTR handle; | 640 APTR handle; |
644 | 641 |
645 // D(bug("Using customroutine!\n")); | 642 // D(bug("Using customroutine!\n")); |
646 | 643 |
647 if (handle = | 644 if (handle = |
648 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 645 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
649 (ULONG) & bm_address, LBMI_BYTESPERROW, | 646 (ULONG) & bm_address, LBMI_BYTESPERROW, |
650 (ULONG) & destpitch, TAG_DONE)) { | 647 (ULONG) & destpitch, TAG_DONE)) { |
651 unsigned char *destbase; | 648 unsigned char *destbase; |
652 register int j, srcwidth; | 649 register int j, srcwidth; |
653 register unsigned char *src, *dest; | 650 register unsigned char *src, *dest; |
654 | 651 |
655 // Aggiungo il bordo della finestra se sono fullscreen. | 652 // Aggiungo il bordo della finestra se sono fullscreen. |
682 srcwidth *= this->screen->format->BytesPerPixel; | 679 srcwidth *= this->screen->format->BytesPerPixel; |
683 | 680 |
684 // D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest)); | 681 // D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest)); |
685 | 682 |
686 for (j = rects[i].h; j; --j) { | 683 for (j = rects[i].h; j; --j) { |
687 SDL_memcpy (dest, src, srcwidth); | 684 SDL_memcpy(dest, src, srcwidth); |
688 src += this->screen->pitch; | 685 src += this->screen->pitch; |
689 dest += destpitch; | 686 dest += destpitch; |
690 } | 687 } |
691 } | 688 } |
692 UnLockBitMap (handle); | 689 UnLockBitMap(handle); |
693 // D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch)); | 690 // D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch)); |
694 } | 691 } |
695 } else { | 692 } else { |
696 for (i = 0; i < numrects; ++i) { | 693 for (i = 0; i < numrects; ++i) { |
697 if (!rects[i].w) { /* Clipped? */ | 694 if (!rects[i].w) { /* Clipped? */ |
698 continue; | 695 continue; |
699 } | 696 } |
700 USE_WPA (this->screen->pixels, rects[i].x, rects[i].y, | 697 USE_WPA(this->screen->pixels, rects[i].x, rects[i].y, |
701 this->screen->pitch, SDL_RastPort, | 698 this->screen->pitch, SDL_RastPort, |
702 SDL_Window->BorderLeft + rects[i].x, | 699 SDL_Window->BorderLeft + rects[i].x, |
703 SDL_Window->BorderTop + rects[i].y, rects[i].w, | 700 SDL_Window->BorderTop + rects[i].y, rects[i].w, |
704 rects[i].h, format); | 701 rects[i].h, format); |
705 } | 702 } |
706 } | 703 } |
707 } | 704 } |
708 | 705 |
709 void | 706 void |
710 CGX_RefreshDisplay (_THIS) | 707 CGX_RefreshDisplay(_THIS) |
711 { | 708 { |
712 int format, customroutine = 0; | 709 int format, customroutine = 0; |
713 #ifndef USE_CGX_WRITELUTPIXEL | 710 #ifndef USE_CGX_WRITELUTPIXEL |
714 int bpp; | 711 int bpp; |
715 #endif | 712 #endif |
753 | 750 |
754 } | 751 } |
755 | 752 |
756 /* Check for endian-swapped X server, swap if necessary */ | 753 /* Check for endian-swapped X server, swap if necessary */ |
757 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { | 754 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) { |
758 CGX_SwapAllPixels (this->screen); | 755 CGX_SwapAllPixels(this->screen); |
759 USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch, | 756 USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, |
760 SDL_RastPort, SDL_Window->BorderLeft, | 757 SDL_RastPort, SDL_Window->BorderLeft, |
761 SDL_Window->BorderTop, this->screen->w, this->screen->h, | 758 SDL_Window->BorderTop, this->screen->w, this->screen->h, |
762 format); | 759 format); |
763 CGX_SwapAllPixels (this->screen); | 760 CGX_SwapAllPixels(this->screen); |
764 } else if (customroutine == 2) { | 761 } else if (customroutine == 2) { |
765 #ifdef USE_CGX_WRITELUTPIXEL | 762 #ifdef USE_CGX_WRITELUTPIXEL |
766 WLUT (this->screen->pixels, 0, 0, this->screen->pitch, | 763 WLUT(this->screen->pixels, 0, 0, this->screen->pitch, |
767 SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft, | 764 SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft, |
768 SDL_Window->BorderTop, this->screen->w, this->screen->h, | 765 SDL_Window->BorderTop, this->screen->w, this->screen->h, |
769 CTABFMT_XRGB8); | 766 CTABFMT_XRGB8); |
770 #else | 767 #else |
771 unsigned char *bm_address; | 768 unsigned char *bm_address; |
772 Uint32 destpitch; | 769 Uint32 destpitch; |
773 APTR handle; | 770 APTR handle; |
774 | 771 |
775 if (handle = | 772 if (handle = |
776 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 773 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
777 (ULONG) & bm_address, LBMI_BYTESPERROW, | 774 (ULONG) & bm_address, LBMI_BYTESPERROW, |
778 (ULONG) & destpitch, TAG_DONE)) { | 775 (ULONG) & destpitch, TAG_DONE)) { |
779 register int j, k, t; | 776 register int j, k, t; |
780 register unsigned char *mask, *dst; | 777 register unsigned char *mask, *dst; |
781 register unsigned char *src, *dest; | 778 register unsigned char *src, *dest; |
782 | 779 |
783 // Aggiungo il bordo della finestra se sono fullscreen. | 780 // Aggiungo il bordo della finestra se sono fullscreen. |
803 dst += bpp; | 800 dst += bpp; |
804 } | 801 } |
805 src += this->screen->pitch; | 802 src += this->screen->pitch; |
806 dest += destpitch; | 803 dest += destpitch; |
807 } | 804 } |
808 UnLockBitMap (handle); | 805 UnLockBitMap(handle); |
809 } | 806 } |
810 } else if (customroutine == 3) { | 807 } else if (customroutine == 3) { |
811 unsigned char *bm_address; | 808 unsigned char *bm_address; |
812 Uint32 destpitch; | 809 Uint32 destpitch; |
813 APTR handle; | 810 APTR handle; |
814 | 811 |
815 if (handle = | 812 if (handle = |
816 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 813 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
817 (ULONG) & bm_address, LBMI_BYTESPERROW, | 814 (ULONG) & bm_address, LBMI_BYTESPERROW, |
818 (ULONG) & destpitch, TAG_DONE)) { | 815 (ULONG) & destpitch, TAG_DONE)) { |
819 register int j, k; | 816 register int j, k; |
820 register unsigned char *src, *dest; | 817 register unsigned char *src, *dest; |
821 register Uint16 *destl, *srcl; | 818 register Uint16 *destl, *srcl; |
822 | 819 |
823 if (!currently_fullscreen) | 820 if (!currently_fullscreen) |
842 destl++; | 839 destl++; |
843 } | 840 } |
844 src += this->screen->pitch; | 841 src += this->screen->pitch; |
845 dest += destpitch; | 842 dest += destpitch; |
846 } | 843 } |
847 UnLockBitMap (handle); | 844 UnLockBitMap(handle); |
848 } | 845 } |
849 } else if (customroutine == 4) { | 846 } else if (customroutine == 4) { |
850 unsigned char *bm_address; | 847 unsigned char *bm_address; |
851 Uint32 destpitch; | 848 Uint32 destpitch; |
852 APTR handle; | 849 APTR handle; |
853 | 850 |
854 if (handle = | 851 if (handle = |
855 LockBitMapTags (SDL_RastPort->BitMap, LBMI_BASEADDRESS, | 852 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, |
856 (ULONG) & bm_address, LBMI_BYTESPERROW, | 853 (ULONG) & bm_address, LBMI_BYTESPERROW, |
857 (ULONG) & destpitch, TAG_DONE)) { | 854 (ULONG) & destpitch, TAG_DONE)) { |
858 register int j, k; | 855 register int j, k; |
859 register unsigned char *src, *dest; | 856 register unsigned char *src, *dest; |
860 register Uint32 *destl, *srcl; | 857 register Uint32 *destl, *srcl; |
861 | 858 |
862 if (!currently_fullscreen) | 859 if (!currently_fullscreen) |
881 destl++; | 878 destl++; |
882 } | 879 } |
883 src += this->screen->pitch; | 880 src += this->screen->pitch; |
884 dest += destpitch; | 881 dest += destpitch; |
885 } | 882 } |
886 UnLockBitMap (handle); | 883 UnLockBitMap(handle); |
887 } | 884 } |
888 #endif | 885 #endif |
889 } else if (customroutine) { | 886 } else if (customroutine) { |
890 unsigned char *bm_address; | 887 unsigned char *bm_address; |
891 Uint32 destpitch; | 888 Uint32 destpitch; |
892 APTR handle; | 889 APTR handle; |
893 | 890 |
894 if (handle = LockBitMapTags (SDL_RastPort->BitMap, | 891 if (handle = LockBitMapTags(SDL_RastPort->BitMap, |
895 LBMI_BASEADDRESS, (ULONG) & bm_address, | 892 LBMI_BASEADDRESS, (ULONG) & bm_address, |
896 LBMI_BYTESPERROW, (ULONG) & destpitch, | 893 LBMI_BYTESPERROW, (ULONG) & destpitch, |
897 TAG_DONE)) { | 894 TAG_DONE)) { |
898 register int j; | 895 register int j; |
899 register unsigned char *src, *dest; | 896 register unsigned char *src, *dest; |
900 | 897 |
901 if (!currently_fullscreen) | 898 if (!currently_fullscreen) |
902 dest = | 899 dest = |
911 src = this->screen->pixels; | 908 src = this->screen->pixels; |
912 | 909 |
913 // D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch)); | 910 // D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch)); |
914 | 911 |
915 if (this->screen->pitch == destpitch) { | 912 if (this->screen->pitch == destpitch) { |
916 SDL_memcpy (dest, src, this->screen->pitch * this->screen->h); | 913 SDL_memcpy(dest, src, this->screen->pitch * this->screen->h); |
917 } else { | 914 } else { |
918 for (j = this->screen->h; j; --j) { | 915 for (j = this->screen->h; j; --j) { |
919 SDL_memcpy (dest, src, this->screen->pitch); | 916 SDL_memcpy(dest, src, this->screen->pitch); |
920 src += this->screen->pitch; | 917 src += this->screen->pitch; |
921 dest += destpitch; | 918 dest += destpitch; |
922 } | 919 } |
923 } | 920 } |
924 | 921 |
925 UnLockBitMap (handle); | 922 UnLockBitMap(handle); |
926 } | 923 } |
927 } else { | 924 } else { |
928 USE_WPA (this->screen->pixels, 0, 0, this->screen->pitch, | 925 USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, |
929 SDL_RastPort, SDL_Window->BorderLeft, | 926 SDL_RastPort, SDL_Window->BorderLeft, |
930 SDL_Window->BorderTop, this->screen->w, this->screen->h, | 927 SDL_Window->BorderTop, this->screen->w, this->screen->h, |
931 format); | 928 format); |
932 } | 929 } |
933 | 930 |
934 } | 931 } |
935 | 932 |
936 /* vi: set ts=4 sw=4 expandtab: */ | 933 /* vi: set ts=4 sw=4 expandtab: */ |