comparison src/video/cybergfx/SDL_cgximage.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
28 #include <kstat.h> 28 #include <kstat.h>
29 #endif 29 #endif
30 30
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 WLUT(APTR a,UWORD b,UWORD c,UWORD d,struct RastPort *e,APTR f,UWORD g,UWORD h,UWORD i,UWORD l,UBYTE m) 35 void
36 { WriteLUTPixelArray(a,b,c,d,e,f,g,h,i,l,m); } 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)
38 {
39 WriteLUTPixelArray(a, b, c, d, e, f, g, h, i, l, m);
40 }
37 #endif 41 #endif
38 42
39 #endif 43 #endif
40 44
41 /* Various screen update functions available */ 45 /* Various screen update functions available */
42 static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); 46 static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects);
43 static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects); 47 static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects);
44 48
45 BOOL SafeDisp=TRUE,SafeChange=TRUE; 49 BOOL SafeDisp = TRUE, SafeChange = TRUE;
46 struct MsgPort *safeport=NULL,*dispport=NULL; 50 struct MsgPort *safeport = NULL, *dispport = NULL;
47 ULONG safe_sigbit,disp_sigbit; 51 ULONG safe_sigbit, disp_sigbit;
48 int use_picasso96=1; 52 int use_picasso96 = 1;
49 53
50 int CGX_SetupImage(_THIS, SDL_Surface *screen) 54 int
51 { 55 CGX_SetupImage(_THIS, SDL_Surface * screen)
52 SDL_Ximage=NULL; 56 {
53 57 SDL_Ximage = NULL;
54 if(screen->flags&SDL_HWSURFACE) { 58
55 ULONG pitch; 59 if (screen->flags & SDL_HWSURFACE) {
56 60 ULONG pitch;
57 if(!screen->hwdata) { 61
58 if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) 62 if (!screen->hwdata) {
59 return -1; 63 if (!(screen->hwdata = SDL_malloc(sizeof(struct private_hwdata))))
60 64 return -1;
61 D(bug("Creating system accel struct\n")); 65
62 } 66 D(bug("Creating system accel struct\n"));
63 screen->hwdata->lock=NULL; 67 }
64 screen->hwdata->allocated=0; 68 screen->hwdata->lock = NULL;
65 screen->hwdata->mask=NULL; 69 screen->hwdata->allocated = 0;
66 screen->hwdata->bmap=SDL_RastPort->BitMap; 70 screen->hwdata->mask = NULL;
67 screen->hwdata->videodata=this; 71 screen->hwdata->bmap = SDL_RastPort->BitMap;
68 72 screen->hwdata->videodata = this;
69 if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap, 73
70 LBMI_BASEADDRESS,(ULONG)&screen->pixels, 74 if (!(screen->hwdata->lock = LockBitMapTags(screen->hwdata->bmap,
71 LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) { 75 LBMI_BASEADDRESS,
72 SDL_free(screen->hwdata); 76 (ULONG) & screen->
73 screen->hwdata=NULL; 77 pixels,
74 return -1; 78 LBMI_BYTESPERROW,
75 } 79 (ULONG) & pitch,
76 else { 80 TAG_DONE))) {
77 UnLockBitMap(screen->hwdata->lock); 81 SDL_free(screen->hwdata);
78 screen->hwdata->lock=NULL; 82 screen->hwdata = NULL;
79 } 83 return -1;
80 84 } else {
81 screen->pitch=pitch; 85 UnLockBitMap(screen->hwdata->lock);
82 86 screen->hwdata->lock = NULL;
83 this->UpdateRects = CGX_FakeUpdate; 87 }
84 88
85 D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch)); 89 screen->pitch = pitch;
86 return 0; 90
87 } 91 this->UpdateRects = CGX_FakeUpdate;
88 92
89 screen->pixels = SDL_malloc(screen->h*screen->pitch); 93 D(bug
90 94 ("Accel video image configured (%lx, pitch %ld).\n",
91 if ( screen->pixels == NULL ) { 95 screen->pixels, screen->pitch));
92 SDL_OutOfMemory(); 96 return 0;
93 return(-1); 97 }
94 } 98
95 99 screen->pixels = SDL_malloc(screen->h * screen->pitch);
96 SDL_Ximage=screen->pixels; 100
97 101 if (screen->pixels == NULL) {
98 if ( SDL_Ximage == NULL ) { 102 SDL_OutOfMemory();
99 SDL_SetError("Couldn't create XImage"); 103 return (-1);
100 return(-1); 104 }
101 } 105
102 106 SDL_Ximage = screen->pixels;
103 this->UpdateRects = CGX_NormalUpdate; 107
104 108 if (SDL_Ximage == NULL) {
105 return(0); 109 SDL_SetError("Couldn't create XImage");
106 } 110 return (-1);
107 111 }
108 void CGX_DestroyImage(_THIS, SDL_Surface *screen) 112
109 { 113 this->UpdateRects = CGX_NormalUpdate;
110 if ( SDL_Ximage ) { 114
111 SDL_free(SDL_Ximage); 115 return (0);
112 SDL_Ximage = NULL; 116 }
113 } 117
114 if ( screen ) { 118 void
115 screen->pixels = NULL; 119 CGX_DestroyImage(_THIS, SDL_Surface * screen)
116 120 {
117 if(screen->hwdata) { 121 if (SDL_Ximage) {
118 SDL_free(screen->hwdata); 122 SDL_free(SDL_Ximage);
119 screen->hwdata=NULL; 123 SDL_Ximage = NULL;
120 } 124 }
121 } 125 if (screen) {
126 screen->pixels = NULL;
127
128 if (screen->hwdata) {
129 SDL_free(screen->hwdata);
130 screen->hwdata = NULL;
131 }
132 }
122 } 133 }
123 134
124 /* 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 */
125 static int num_CPU(void) 136 static int
126 { 137 num_CPU(void)
127 return 1; 138 {
128 } 139 return 1;
129 140 }
130 int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) 141
131 { 142 int
132 int retval; 143 CGX_ResizeImage(_THIS, SDL_Surface * screen, Uint32 flags)
133 144 {
134 D(bug("Calling ResizeImage()\n")); 145 int retval;
135 146
136 CGX_DestroyImage(this, screen); 147 D(bug("Calling ResizeImage()\n"));
137 148
138 if ( flags & SDL_OPENGL ) { /* No image when using GL */ 149 CGX_DestroyImage(this, screen);
139 retval = 0; 150
140 } else { 151 if (flags & SDL_INTERNALOPENGL) { /* No image when using GL */
141 retval = CGX_SetupImage(this, screen); 152 retval = 0;
142 /* We support asynchronous blitting on the display */ 153 } else {
143 if ( flags & SDL_ASYNCBLIT ) { 154 retval = CGX_SetupImage(this, screen);
144 if ( num_CPU() > 1 ) { 155 /* We support asynchronous blitting on the display */
145 screen->flags |= SDL_ASYNCBLIT; 156 if (flags & SDL_ASYNCBLIT) {
146 } 157 if (num_CPU() > 1) {
147 } 158 screen->flags |= SDL_ASYNCBLIT;
148 } 159 }
149 return(retval); 160 }
150 } 161 }
151 162 return (retval);
152 int CGX_AllocHWSurface(_THIS, SDL_Surface *surface) 163 }
153 { 164
154 D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth)); 165 int
155 166 CGX_AllocHWSurface(_THIS, SDL_Surface * surface)
156 if(surface==SDL_VideoSurface) 167 {
157 { 168 D(bug
158 D(bug("Allocation skipped, it's system one!\n")); 169 ("Alloc HW surface...%ld x %ld x %ld!\n", surface->w, surface->h,
159 return 0; 170 this->hidden->depth));
160 } 171
161 172 if (surface == SDL_VideoSurface) {
162 if(!surface->hwdata) 173 D(bug("Allocation skipped, it's system one!\n"));
163 { 174 return 0;
164 if(!(surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) 175 }
165 return -1; 176
166 } 177 if (!surface->hwdata) {
167 178 if (!(surface->hwdata = SDL_malloc(sizeof(struct private_hwdata))))
168 surface->hwdata->mask=NULL; 179 return -1;
169 surface->hwdata->lock=NULL; 180 }
170 surface->hwdata->videodata=this; 181
171 surface->hwdata->allocated=0; 182 surface->hwdata->mask = NULL;
172 183 surface->hwdata->lock = NULL;
173 if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap)) 184 surface->hwdata->videodata = this;
174 { 185 surface->hwdata->allocated = 0;
175 surface->hwdata->allocated=1; 186
176 surface->flags|=SDL_HWSURFACE; 187 if (surface->hwdata->bmap =
177 D(bug("...OK\n")); 188 AllocBitMap(surface->w, surface->h, this->hidden->depth,
178 return 0; 189 BMF_MINPLANES, SDL_Display->RastPort.BitMap)) {
179 } 190 surface->hwdata->allocated = 1;
180 else 191 surface->flags |= SDL_HWSURFACE;
181 { 192 D(bug("...OK\n"));
182 SDL_free(surface->hwdata); 193 return 0;
183 surface->hwdata=NULL; 194 } else {
184 } 195 SDL_free(surface->hwdata);
185 196 surface->hwdata = NULL;
186 return(-1); 197 }
187 } 198
188 void CGX_FreeHWSurface(_THIS, SDL_Surface *surface) 199 return (-1);
189 { 200 }
190 if(surface && surface!=SDL_VideoSurface && surface->hwdata) 201
191 { 202 void
192 D(bug("Free hw surface.\n")); 203 CGX_FreeHWSurface(_THIS, SDL_Surface * surface)
193 204 {
194 if(surface->hwdata->mask) 205 if (surface && surface != SDL_VideoSurface && surface->hwdata) {
195 SDL_free(surface->hwdata->mask); 206 D(bug("Free hw surface.\n"));
196 207
197 if(surface->hwdata->bmap&&surface->hwdata->allocated) 208 if (surface->hwdata->mask)
198 FreeBitMap(surface->hwdata->bmap); 209 SDL_free(surface->hwdata->mask);
199 210
200 SDL_free(surface->hwdata); 211 if (surface->hwdata->bmap && surface->hwdata->allocated)
201 surface->hwdata=NULL; 212 FreeBitMap(surface->hwdata->bmap);
202 surface->pixels=NULL; 213
203 D(bug("end of free hw surface\n")); 214 SDL_free(surface->hwdata);
204 } 215 surface->hwdata = NULL;
205 return; 216 surface->pixels = NULL;
206 } 217 D(bug("end of free hw surface\n"));
207 218 }
208 int CGX_LockHWSurface(_THIS, SDL_Surface *surface) 219 return;
209 { 220 }
210 if (surface->hwdata) 221
211 { 222 int
212 // D(bug("Locking a bitmap...\n")); 223 CGX_LockHWSurface(_THIS, SDL_Surface * surface)
213 if(!surface->hwdata->lock) 224 {
214 { 225 if (surface->hwdata) {
215 Uint32 pitch; 226 // D(bug("Locking a bitmap...\n"));
216 227 if (!surface->hwdata->lock) {
217 if(!(surface->hwdata->lock=LockBitMapTags(surface->hwdata->bmap, 228 Uint32 pitch;
218 LBMI_BASEADDRESS,(ULONG)&surface->pixels, 229
219 LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) 230 if (!
220 return -1; 231 (surface->hwdata->lock =
232 LockBitMapTags(surface->hwdata->bmap, LBMI_BASEADDRESS,
233 (ULONG) & surface->pixels,
234 LBMI_BYTESPERROW, (ULONG) & pitch, TAG_DONE)))
235 return -1;
221 236
222 // surface->pitch e' a 16bit! 237 // surface->pitch e' a 16bit!
223 238
224 surface->pitch=pitch; 239 surface->pitch = pitch;
225 240
226 if(!currently_fullscreen&&surface==SDL_VideoSurface) 241 if (!currently_fullscreen && surface == SDL_VideoSurface)
227 surface->pixels=((char *)surface->pixels)+(surface->pitch*(SDL_Window->BorderTop+SDL_Window->TopEdge)+ 242 surface->pixels =
228 surface->format->BytesPerPixel*(SDL_Window->BorderLeft+SDL_Window->LeftEdge)); 243 ((char *) surface->pixels) +
229 } 244 (surface->pitch *
230 D(else bug("Already locked!!!\n")); 245 (SDL_Window->BorderTop + SDL_Window->TopEdge) +
231 } 246 surface->format->BytesPerPixel *
232 return(0); 247 (SDL_Window->BorderLeft + SDL_Window->LeftEdge));
233 } 248 }
234 249 D(
235 void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface) 250 else
236 { 251 bug("Already locked!!!\n"));
237 if(surface->hwdata && surface->hwdata->lock) 252 }
238 { 253 return (0);
239 UnLockBitMap(surface->hwdata->lock); 254 }
240 surface->hwdata->lock=NULL; 255
241 // surface->pixels=NULL; 256 void
242 } 257 CGX_UnlockHWSurface(_THIS, SDL_Surface * surface)
243 } 258 {
244 259 if (surface->hwdata && surface->hwdata->lock) {
245 int CGX_FlipHWSurface(_THIS, SDL_Surface *surface) 260 UnLockBitMap(surface->hwdata->lock);
246 { 261 surface->hwdata->lock = NULL;
247 static int current=0; 262 // surface->pixels=NULL;
248 263 }
249 if(this->hidden->dbuffer) 264 }
250 { 265
251 if(!SafeChange) 266 int
252 { 267 CGX_FlipHWSurface(_THIS, SDL_Surface * surface)
253 Wait(disp_sigbit); 268 {
269 static int current = 0;
270
271 if (this->hidden->dbuffer) {
272 if (!SafeChange) {
273 Wait(disp_sigbit);
254 // Non faccio nulla, vuoto solo la porta 274 // Non faccio nulla, vuoto solo la porta
255 while(GetMsg(dispport)!=NULL) 275 while (GetMsg(dispport) != NULL);
256 ; 276 SafeChange = TRUE;
257 SafeChange=TRUE; 277 }
258 } 278
259 279 if (ChangeScreenBuffer(SDL_Display, this->hidden->SB[current ^ 1])) {
260 if(ChangeScreenBuffer(SDL_Display,this->hidden->SB[current^1])) 280 surface->hwdata->bmap = SDL_RastPort->BitMap =
261 { 281 this->hidden->SB[current]->sb_BitMap;
262 surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap; 282 SafeChange = FALSE;
263 SafeChange=FALSE; 283 SafeDisp = FALSE;
264 SafeDisp=FALSE; 284 current ^= 1;
265 current^=1; 285 }
266 } 286
267 287 if (!SafeDisp) {
268 if(!SafeDisp) 288 Wait(safe_sigbit);
269 { 289 while (GetMsg(safeport) != NULL);
270 Wait(safe_sigbit); 290 SafeDisp = TRUE;
271 while(GetMsg(safeport)!=NULL) 291 }
272 ; 292
273 SafeDisp=TRUE; 293 }
274 } 294 return (0);
275
276 }
277 return(0);
278 } 295 }
279 296
280 /* Byte-swap the pixels in the display image */ 297 /* Byte-swap the pixels in the display image */
281 static void CGX_SwapAllPixels(SDL_Surface *screen) 298 static void
282 { 299 CGX_SwapAllPixels(SDL_Surface * screen)
283 int x, y; 300 {
284 301 int x, y;
285 switch (screen->format->BytesPerPixel) { 302
286 case 2: { 303 switch (screen->format->BytesPerPixel) {
287 Uint16 *spot; 304 case 2:
288 for ( y=0; y<screen->h; ++y ) { 305 {
289 spot = (Uint16 *) ((Uint8 *)screen->pixels + 306 Uint16 *spot;
290 y * screen->pitch); 307 for (y = 0; y < screen->h; ++y) {
291 for ( x=0; x<screen->w; ++x, ++spot ) { 308 spot = (Uint16 *) ((Uint8 *) screen->pixels +
292 *spot = SDL_Swap16(*spot); 309 y * screen->pitch);
293 } 310 for (x = 0; x < screen->w; ++x, ++spot) {
294 } 311 *spot = SDL_Swap16(*spot);
295 } 312 }
296 break; 313 }
297 314 }
298 case 4: { 315 break;
299 Uint32 *spot; 316
300 for ( y=0; y<screen->h; ++y ) { 317 case 4:
301 spot = (Uint32 *) ((Uint8 *)screen->pixels + 318 {
302 y * screen->pitch); 319 Uint32 *spot;
303 for ( x=0; x<screen->w; ++x, ++spot ) { 320 for (y = 0; y < screen->h; ++y) {
304 *spot = SDL_Swap32(*spot); 321 spot = (Uint32 *) ((Uint8 *) screen->pixels +
305 } 322 y * screen->pitch);
306 } 323 for (x = 0; x < screen->w; ++x, ++spot) {
307 } 324 *spot = SDL_Swap32(*spot);
308 break; 325 }
309 326 }
310 default: 327 }
311 /* should never get here */ 328 break;
312 break; 329
313 } 330 default:
314 } 331 /* should never get here */
315 static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects) 332 break;
316 { 333 }
317 int i; 334 }
318 int x, minx, maxx; 335 static void
319 int y, miny, maxy; 336 CGX_SwapPixels(SDL_Surface * screen, int numrects, SDL_Rect * rects)
320 337 {
321 switch (screen->format->BytesPerPixel) { 338 int i;
322 case 2: { 339 int x, minx, maxx;
323 Uint16 *spot; 340 int y, miny, maxy;
324 for ( i=0; i<numrects; ++i ) { 341
325 minx = rects[i].x; 342 switch (screen->format->BytesPerPixel) {
326 maxx = rects[i].x+rects[i].w; 343 case 2:
327 miny = rects[i].y; 344 {
328 maxy = rects[i].y+rects[i].h; 345 Uint16 *spot;
329 for ( y=miny; y<maxy; ++y ) { 346 for (i = 0; i < numrects; ++i) {
330 spot = (Uint16 *) ((Uint8 *)screen->pixels + 347 minx = rects[i].x;
331 y * screen->pitch + minx * 2); 348 maxx = rects[i].x + rects[i].w;
332 for ( x=minx; x<maxx; ++x, ++spot ) { 349 miny = rects[i].y;
333 *spot = SDL_Swap16(*spot); 350 maxy = rects[i].y + rects[i].h;
334 } 351 for (y = miny; y < maxy; ++y) {
335 } 352 spot = (Uint16 *) ((Uint8 *) screen->pixels +
336 } 353 y * screen->pitch + minx * 2);
337 } 354 for (x = minx; x < maxx; ++x, ++spot) {
338 break; 355 *spot = SDL_Swap16(*spot);
339 356 }
340 case 4: { 357 }
341 Uint32 *spot; 358 }
342 for ( i=0; i<numrects; ++i ) { 359 }
343 minx = rects[i].x; 360 break;
344 maxx = rects[i].x+rects[i].w; 361
345 miny = rects[i].y; 362 case 4:
346 maxy = rects[i].y+rects[i].h; 363 {
347 for ( y=miny; y<maxy; ++y ) { 364 Uint32 *spot;
348 spot = (Uint32 *) ((Uint8 *)screen->pixels + 365 for (i = 0; i < numrects; ++i) {
349 y * screen->pitch + minx * 4); 366 minx = rects[i].x;
350 for ( x=minx; x<maxx; ++x, ++spot ) { 367 maxx = rects[i].x + rects[i].w;
351 *spot = SDL_Swap32(*spot); 368 miny = rects[i].y;
352 } 369 maxy = rects[i].y + rects[i].h;
353 } 370 for (y = miny; y < maxy; ++y) {
354 } 371 spot = (Uint32 *) ((Uint8 *) screen->pixels +
355 } 372 y * screen->pitch + minx * 4);
356 break; 373 for (x = minx; x < maxx; ++x, ++spot) {
357 374 *spot = SDL_Swap32(*spot);
358 default: 375 }
359 /* should never get here */ 376 }
360 break; 377 }
361 } 378 }
379 break;
380
381 default:
382 /* should never get here */
383 break;
384 }
362 } 385 }
363 386
364 #ifdef __SASC 387 #ifdef __SASC
365 388
366 #define USE_WPA WritePixelArray 389 #define USE_WPA WritePixelArray
367 #else 390 #else
368 391
369 void USE_WPA(char *a,int b,int c,int d, struct RastPort *e,int f,int g, int h, int i, Uint32 l) 392 void
370 { 393 USE_WPA(char *a, int b, int c, int d, struct RastPort *e, int f, int g,
371 WritePixelArray(a,b,c,d,e,f,g,h,i,l); 394 int h, int i, Uint32 l)
395 {
396 WritePixelArray(a, b, c, d, e, f, g, h, i, l);
372 } 397 }
373 398
374 #endif 399 #endif
375 400
376 static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects) 401 static void
377 { 402 CGX_FakeUpdate(_THIS, int numrects, SDL_Rect * rects)
378 } 403 {
379 404 }
380 static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 405
381 { 406 static void
382 int i,format,customroutine=0; 407 CGX_NormalUpdate(_THIS, int numrects, SDL_Rect * rects)
408 {
409 int i, format, customroutine = 0;
383 #ifndef USE_CGX_WRITELUTPIXEL 410 #ifndef USE_CGX_WRITELUTPIXEL
384 int bpp; 411 int bpp;
385 #endif 412 #endif
386 if(this->hidden->same_format && !use_picasso96) 413 if (this->hidden->same_format && !use_picasso96) {
387 { 414 format = RECTFMT_RAW;
388 format=RECTFMT_RAW; 415 } else
389 } 416 switch (this->screen->format->BytesPerPixel) {
390 else switch(this->screen->format->BytesPerPixel) 417 case 4:
391 { 418 format = RECTFMT_RGBA;
392 case 4: 419 break;
393 format=RECTFMT_RGBA; 420 case 3:
394 break; 421 format = RECTFMT_RGB;
395 case 3: 422 break;
396 format=RECTFMT_RGB; 423 case 2:
397 break; 424 customroutine = 1;
398 case 2: 425 break;
399 customroutine=1; 426 case 1:
400 break; 427 // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
401 case 1: 428 if (this->hidden->depth > 8) {
402 // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
403 if(this->hidden->depth>8)
404 {
405 #ifndef USE_CGX_WRITELUTPIXEL 429 #ifndef USE_CGX_WRITELUTPIXEL
406 if(this->hidden->depth>32) 430 if (this->hidden->depth > 32)
407 customroutine=4; 431 customroutine = 4;
408 else if(this->hidden->depth>16) 432 else if (this->hidden->depth > 16) {
409 { 433 bpp = this->hidden->BytesPerPixel; // That one is the only one that needs bpp
410 bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp 434 customroutine = 2; // The slow one!
411 customroutine=2; // The slow one! 435 } else
412 } 436 customroutine = 3;
413 else
414 customroutine=3;
415 #else 437 #else
416 438
417 customroutine=2; 439 customroutine = 2;
418 #endif 440 #endif
419 441
420 // format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray. 442 // format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray.
421 } 443 } else
422 else 444 customroutine = 1;
423 customroutine=1; 445 break;
424 break; 446 default:
425 default: 447 D(bug("Unable to blit this surface!\n"));
426 D(bug("Unable to blit this surface!\n")); 448 return;
427 return; 449 }
428 } 450
429 451 /* Check for endian-swapped X server, swap if necessary (VERY slow!) */
430 /* Check for endian-swapped X server, swap if necessary (VERY slow!) */ 452 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) {
431 if ( swap_pixels && 453 D(bug("Software Swapping! SLOOOW!\n"));
432 ((this->screen->format->BytesPerPixel%2) == 0) ) { 454 CGX_SwapPixels(this->screen, numrects, rects);
433 D(bug("Software Swapping! SLOOOW!\n")); 455 for (i = 0; i < numrects; ++i) {
434 CGX_SwapPixels(this->screen, numrects, rects); 456 if (!rects[i].w) { /* Clipped? */
435 for ( i=0; i<numrects; ++i ) { 457 continue;
436 if ( ! rects[i].w ) { /* Clipped? */ 458 }
437 continue; 459 USE_WPA(this->screen->pixels, rects[i].x, rects[i].y,
438 } 460 this->screen->pitch, SDL_RastPort,
439 USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, 461 SDL_Window->BorderLeft + rects[i].x,
440 SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, 462 SDL_Window->BorderTop + rects[i].y, rects[i].w,
441 rects[i].w,rects[i].h,format); 463 rects[i].h, format);
442 } 464 }
443 CGX_SwapPixels(this->screen, numrects, rects); 465 CGX_SwapPixels(this->screen, numrects, rects);
444 } 466 } else if (customroutine == 2) {
445 else if (customroutine==2)
446 {
447 #ifdef USE_CGX_WRITELUTPIXEL 467 #ifdef USE_CGX_WRITELUTPIXEL
448 for ( i=0; i<numrects; ++i ) { 468 for (i = 0; i < numrects; ++i) {
449 if ( ! rects[i].w ) { /* Clipped? */ 469 if (!rects[i].w) { /* Clipped? */
450 continue; 470 continue;
451 } 471 }
452 472
453 WLUT(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, 473 WLUT(this->screen->pixels, rects[i].x, rects[i].y,
454 SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, 474 this->screen->pitch, SDL_RastPort, SDL_XPixels,
455 rects[i].w,rects[i].h,CTABFMT_XRGB8); 475 SDL_Window->BorderLeft + rects[i].x,
456 } 476 SDL_Window->BorderTop + rects[i].y, rects[i].w,
477 rects[i].h, CTABFMT_XRGB8);
478 }
457 #else 479 #else
458 unsigned char *bm_address; 480 unsigned char *bm_address;
459 Uint32 destpitch; 481 Uint32 destpitch;
460 APTR handle; 482 APTR handle;
461 483
462 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, 484 if (handle =
463 LBMI_BYTESPERROW,&destpitch,TAG_DONE)) 485 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
464 { 486 &bm_address, LBMI_BYTESPERROW, &destpitch,
465 int srcwidth; 487 TAG_DONE)) {
466 unsigned char *destbase; 488 int srcwidth;
467 register int j,k,t; 489 unsigned char *destbase;
468 register unsigned char *mask,*dst; 490 register int j, k, t;
469 register unsigned char *src,*dest; 491 register unsigned char *mask, *dst;
492 register unsigned char *src, *dest;
470 493
471 // Aggiungo il bordo della finestra se sono fullscreen. 494 // Aggiungo il bordo della finestra se sono fullscreen.
472 if(currently_fullscreen) 495 if (currently_fullscreen)
473 destbase=bm_address; 496 destbase = bm_address;
474 else 497 else
475 destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 498 destbase =
476 499 bm_address + (SDL_Window->TopEdge +
477 for ( i=0; i<numrects; ++i ) 500 SDL_Window->BorderTop) * destpitch +
478 { 501 (SDL_Window->BorderLeft +
479 srcwidth=rects[i].w; 502 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
480 503
481 if ( !srcwidth ) { /* Clipped? */ 504 for (i = 0; i < numrects; ++i) {
482 continue; 505 srcwidth = rects[i].w;
483 } 506
484 507 if (!srcwidth) { /* Clipped? */
485 dest=destbase+rects[i].x*this->hidden->BytesPerPixel; 508 continue;
486 dest+=(rects[i].y*destpitch); 509 }
487 src=((char *)(this->screen->pixels))+rects[i].x; 510
488 src+=(rects[i].y*this->screen->pitch); 511 dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
489 512 dest += (rects[i].y * destpitch);
490 for(j=rects[i].h;j;--j) 513 src = ((char *) (this->screen->pixels)) + rects[i].x;
491 { 514 src += (rects[i].y * this->screen->pitch);
492 dst=dest; 515
516 for (j = rects[i].h; j; --j) {
517 dst = dest;
493 // SLOW routine, used for 8->24 bit mapping 518 // SLOW routine, used for 8->24 bit mapping
494 for(k=0;k<srcwidth;k++) 519 for (k = 0; k < srcwidth; k++) {
495 { 520 mask = (unsigned char *) (&SDL_XPixels[src[k]]);
496 mask=(unsigned char *)(&SDL_XPixels[src[k]]); 521 for (t = 0; t < bpp; t++) {
497 for(t=0;t<bpp;t++) 522 dst[t] = mask[t];
498 { 523 }
499 dst[t]=mask[t]; 524 dst += bpp;
500 } 525 }
501 dst+=bpp; 526 src += this->screen->pitch;
502 } 527 dest += destpitch;
503 src+=this->screen->pitch; 528 }
504 dest+=destpitch; 529 }
505 } 530 UnLockBitMap(handle);
506 } 531 }
507 UnLockBitMap(handle); 532 } else if (customroutine == 3) {
508 } 533 unsigned char *bm_address;
509 } 534 Uint32 destpitch;
510 else if (customroutine==3) 535 APTR handle;
511 { 536
512 unsigned char *bm_address; 537 if (handle =
513 Uint32 destpitch; 538 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
514 APTR handle; 539 &bm_address, LBMI_BYTESPERROW, &destpitch,
515 540 TAG_DONE)) {
516 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, 541 int srcwidth;
517 LBMI_BYTESPERROW,&destpitch,TAG_DONE)) 542 unsigned char *destbase;
518 { 543 register int j, k;
519 int srcwidth; 544 register unsigned char *src, *dest;
520 unsigned char *destbase; 545 register Uint16 *destl, *srcl;
521 register int j,k; 546
522 register unsigned char *src,*dest; 547 if (currently_fullscreen)
523 register Uint16 *destl,*srcl; 548 destbase = bm_address;
524 549 else
525 if(currently_fullscreen) 550 destbase =
526 destbase=bm_address; 551 bm_address + (SDL_Window->TopEdge +
527 else 552 SDL_Window->BorderTop) * destpitch +
528 destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 553 (SDL_Window->BorderLeft +
529 554 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
530 for ( i=0; i<numrects; ++i ) 555
531 { 556 for (i = 0; i < numrects; ++i) {
532 srcwidth=rects[i].w; 557 srcwidth = rects[i].w;
533 558
534 if ( !srcwidth ) { /* Clipped? */ 559 if (!srcwidth) { /* Clipped? */
535 continue; 560 continue;
536 } 561 }
537 562
538 dest=destbase+rects[i].x*this->hidden->BytesPerPixel; 563 dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
539 dest+=(rects[i].y*destpitch); 564 dest += (rects[i].y * destpitch);
540 src=((char *)(this->screen->pixels))+rects[i].x; 565 src = ((char *) (this->screen->pixels)) + rects[i].x;
541 src+=(rects[i].y*this->screen->pitch); 566 src += (rects[i].y * this->screen->pitch);
542 567
543 // This is the fast, well not too slow, remapping code for 16bit displays 568 // This is the fast, well not too slow, remapping code for 16bit displays
544 569
545 for(j=rects[i].h;j;--j) 570 for (j = rects[i].h; j; --j) {
546 { 571 destl = (Uint16 *) dest;
547 destl=(Uint16 *)dest; 572
548 573 for (k = 0; k < srcwidth; k++) {
549 for(k=0;k<srcwidth;k++) 574 srcl = (Uint16 *) & SDL_XPixels[src[k]];
550 { 575 *destl = *srcl;
551 srcl=(Uint16 *)&SDL_XPixels[src[k]]; 576 destl++;
552 *destl=*srcl; 577 }
553 destl++; 578 src += this->screen->pitch;
554 } 579 dest += destpitch;
555 src+=this->screen->pitch; 580 }
556 dest+=destpitch; 581 }
557 } 582 UnLockBitMap(handle);
558 } 583 }
559 UnLockBitMap(handle); 584 } else if (customroutine == 4) {
560 } 585 unsigned char *bm_address;
561 } 586 Uint32 destpitch;
562 else if (customroutine==4) 587 APTR handle;
563 { 588
564 unsigned char *bm_address; 589 if (handle =
565 Uint32 destpitch; 590 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
566 APTR handle; 591 &bm_address, LBMI_BYTESPERROW, &destpitch,
567 592 TAG_DONE)) {
568 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address, 593 int srcwidth;
569 LBMI_BYTESPERROW,&destpitch,TAG_DONE)) 594 unsigned char *destbase;
570 { 595 register int j, k;
571 int srcwidth; 596 register unsigned char *src, *dest;
572 unsigned char *destbase; 597 register Uint32 *destl, *srcl;
573 register int j,k; 598
574 register unsigned char *src,*dest; 599 if (currently_fullscreen)
575 register Uint32 *destl,*srcl; 600 destbase = bm_address;
576 601 else
577 if(currently_fullscreen) 602 destbase =
578 destbase=bm_address; 603 bm_address + (SDL_Window->TopEdge +
579 else 604 SDL_Window->BorderTop) * destpitch +
580 destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 605 (SDL_Window->BorderLeft +
581 606 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
582 for ( i=0; i<numrects; ++i ) 607
583 { 608 for (i = 0; i < numrects; ++i) {
584 srcwidth=rects[i].w; 609 srcwidth = rects[i].w;
585 610
586 if ( !srcwidth ) { /* Clipped? */ 611 if (!srcwidth) { /* Clipped? */
587 continue; 612 continue;
588 } 613 }
589 614
590 dest=destbase+rects[i].x*this->hidden->BytesPerPixel; 615 dest = destbase + rects[i].x * this->hidden->BytesPerPixel;
591 dest+=(rects[i].y*destpitch); 616 dest += (rects[i].y * destpitch);
592 src=((char *)(this->screen->pixels))+rects[i].x; 617 src = ((char *) (this->screen->pixels)) + rects[i].x;
593 src+=(rects[i].y*this->screen->pitch); 618 src += (rects[i].y * this->screen->pitch);
594 619
595 // This is the fast, well not too slow, remapping code for 32bit displays 620 // This is the fast, well not too slow, remapping code for 32bit displays
596 621
597 for(j=rects[i].h;j;--j) 622 for (j = rects[i].h; j; --j) {
598 { 623 destl = (Uint32 *) dest;
599 destl=(Uint32 *)dest; 624
600 625 for (k = 0; k < srcwidth; k++) {
601 for(k=0;k<srcwidth;k++) 626 srcl = (Uint32 *) & SDL_XPixels[src[k]];
602 { 627 *destl = *srcl;
603 srcl=(Uint32 *)&SDL_XPixels[src[k]]; 628 destl++;
604 *destl=*srcl; 629 }
605 destl++; 630 src += this->screen->pitch;
606 } 631 dest += destpitch;
607 src+=this->screen->pitch; 632 }
608 dest+=destpitch; 633 }
609 } 634 UnLockBitMap(handle);
610 } 635 }
611 UnLockBitMap(handle);
612 }
613 #endif 636 #endif
614 } 637 } else if (customroutine) {
615 else if(customroutine) 638 unsigned char *bm_address;
616 { 639 Uint32 destpitch;
617 unsigned char *bm_address; 640 APTR handle;
618 Uint32 destpitch; 641
619 APTR handle; 642 // D(bug("Using customroutine!\n"));
620 643
621 // D(bug("Using customroutine!\n")); 644 if (handle =
622 645 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
623 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, 646 (ULONG) & bm_address, LBMI_BYTESPERROW,
624 LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) 647 (ULONG) & destpitch, TAG_DONE)) {
625 { 648 unsigned char *destbase;
626 unsigned char *destbase; 649 register int j, srcwidth;
627 register int j,srcwidth; 650 register unsigned char *src, *dest;
628 register unsigned char *src,*dest;
629 651
630 // Aggiungo il bordo della finestra se sono fullscreen. 652 // Aggiungo il bordo della finestra se sono fullscreen.
631 if(currently_fullscreen) 653 if (currently_fullscreen)
632 destbase=bm_address; 654 destbase = bm_address;
633 else 655 else
634 destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel; 656 destbase =
635 657 bm_address + (SDL_Window->TopEdge +
636 for ( i=0; i<numrects; ++i ) 658 SDL_Window->BorderTop) * destpitch +
637 { 659 (SDL_Window->BorderLeft +
638 srcwidth=rects[i].w; 660 SDL_Window->LeftEdge) *
639 661 this->screen->format->BytesPerPixel;
640 if ( !srcwidth ) { /* Clipped? */ 662
641 continue; 663 for (i = 0; i < numrects; ++i) {
642 } 664 srcwidth = rects[i].w;
643 665
644 dest=destbase+rects[i].x*this->screen->format->BytesPerPixel; 666 if (!srcwidth) { /* Clipped? */
645 dest+=(rects[i].y*destpitch); 667 continue;
646 src=((char *)(this->screen->pixels))+rects[i].x*this->screen->format->BytesPerPixel; 668 }
647 src+=(rects[i].y*this->screen->pitch); 669
648 670 dest =
649 srcwidth*=this->screen->format->BytesPerPixel; 671 destbase +
650 672 rects[i].x * this->screen->format->BytesPerPixel;
651 // 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)); 673 dest += (rects[i].y * destpitch);
652 674 src =
653 for(j=rects[i].h;j;--j) 675 ((char *) (this->screen->pixels)) +
654 { 676 rects[i].x * this->screen->format->BytesPerPixel;
655 SDL_memcpy(dest,src,srcwidth); 677 src += (rects[i].y * this->screen->pitch);
656 src+=this->screen->pitch; 678
657 dest+=destpitch; 679 srcwidth *= this->screen->format->BytesPerPixel;
658 } 680
659 } 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));
660 UnLockBitMap(handle); 682
661 // D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch)); 683 for (j = rects[i].h; j; --j) {
662 } 684 SDL_memcpy(dest, src, srcwidth);
663 } 685 src += this->screen->pitch;
664 else 686 dest += destpitch;
665 { 687 }
666 for ( i=0; i<numrects; ++i ) { 688 }
667 if ( ! rects[i].w ) { /* Clipped? */ 689 UnLockBitMap(handle);
668 continue; 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));
669 } 691 }
670 USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch, 692 } else {
671 SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y, 693 for (i = 0; i < numrects; ++i) {
672 rects[i].w,rects[i].h,format); 694 if (!rects[i].w) { /* Clipped? */
673 } 695 continue;
674 } 696 }
675 } 697 USE_WPA(this->screen->pixels, rects[i].x, rects[i].y,
676 698 this->screen->pitch, SDL_RastPort,
677 void CGX_RefreshDisplay(_THIS) 699 SDL_Window->BorderLeft + rects[i].x,
678 { 700 SDL_Window->BorderTop + rects[i].y, rects[i].w,
679 int format,customroutine=0; 701 rects[i].h, format);
702 }
703 }
704 }
705
706 void
707 CGX_RefreshDisplay(_THIS)
708 {
709 int format, customroutine = 0;
680 #ifndef USE_CGX_WRITELUTPIXEL 710 #ifndef USE_CGX_WRITELUTPIXEL
681 int bpp; 711 int bpp;
682 #endif 712 #endif
683 /* Don't refresh a display that doesn't have an image (like GL) */ 713 /* Don't refresh a display that doesn't have an image (like GL) */
684 if ( ! SDL_Ximage ) { 714 if (!SDL_Ximage) {
685 return; 715 return;
686 } 716 }
687 717
688 if(this->hidden->same_format && !use_picasso96) 718 if (this->hidden->same_format && !use_picasso96) {
689 { 719 format = RECTFMT_RAW;
690 format=RECTFMT_RAW; 720 } else
691 } 721 switch (this->screen->format->BytesPerPixel) {
692 else switch(this->screen->format->BytesPerPixel) 722 case 4:
693 { 723 format = RECTFMT_RGBA;
694 case 4: 724 break;
695 format=RECTFMT_RGBA; 725 case 3:
696 break; 726 format = RECTFMT_RGB;
697 case 3: 727 break;
698 format=RECTFMT_RGB; 728 case 2:
699 break; 729 customroutine = 1;
700 case 2: 730 break;
701 customroutine=1; 731 case 1:
702 break; 732 // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
703 case 1: 733 if (this->hidden->depth > 8) {
704 // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
705 if(this->hidden->depth>8)
706 {
707 #ifndef USE_CGX_WRITELUTPIXEL 734 #ifndef USE_CGX_WRITELUTPIXEL
708 if(this->hidden->depth>32) 735 if (this->hidden->depth > 32)
709 customroutine=4; 736 customroutine = 4;
710 else if(this->hidden->depth>16) 737 else if (this->hidden->depth > 16) {
711 { 738 bpp = this->hidden->BytesPerPixel; // That one is the only one that needs bpp
712 bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp 739 customroutine = 2; // The slow one!
713 customroutine=2; // The slow one! 740 } else
714 } 741 customroutine = 3;
715 else
716 customroutine=3;
717 #else 742 #else
718 743
719 customroutine=2; 744 customroutine = 2;
720 #endif 745 #endif
721 // format=RECTFMT_LUT8; 746 // format=RECTFMT_LUT8;
722 } 747 } else
723 else 748 customroutine = 1;
724 customroutine=1; 749 break;
725 break; 750
726 751 }
727 } 752
728 753 /* Check for endian-swapped X server, swap if necessary */
729 /* Check for endian-swapped X server, swap if necessary */ 754 if (swap_pixels && ((this->screen->format->BytesPerPixel % 2) == 0)) {
730 if ( swap_pixels && 755 CGX_SwapAllPixels(this->screen);
731 ((this->screen->format->BytesPerPixel%2) == 0) ) { 756 USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch,
732 CGX_SwapAllPixels(this->screen); 757 SDL_RastPort, SDL_Window->BorderLeft,
733 USE_WPA(this->screen->pixels,0,0,this->screen->pitch, 758 SDL_Window->BorderTop, this->screen->w, this->screen->h,
734 SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop, 759 format);
735 this->screen->w,this->screen->h,format); 760 CGX_SwapAllPixels(this->screen);
736 CGX_SwapAllPixels(this->screen); 761 } else if (customroutine == 2) {
737 }
738 else if (customroutine==2)
739 {
740 #ifdef USE_CGX_WRITELUTPIXEL 762 #ifdef USE_CGX_WRITELUTPIXEL
741 WLUT(this->screen->pixels,0,0,this->screen->pitch, 763 WLUT(this->screen->pixels, 0, 0, this->screen->pitch,
742 SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft,SDL_Window->BorderTop, 764 SDL_RastPort, SDL_XPixels, SDL_Window->BorderLeft,
743 this->screen->w,this->screen->h,CTABFMT_XRGB8); 765 SDL_Window->BorderTop, this->screen->w, this->screen->h,
766 CTABFMT_XRGB8);
744 #else 767 #else
745 unsigned char *bm_address; 768 unsigned char *bm_address;
746 Uint32 destpitch; 769 Uint32 destpitch;
747 APTR handle; 770 APTR handle;
748 771
749 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, 772 if (handle =
750 LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) 773 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
751 { 774 (ULONG) & bm_address, LBMI_BYTESPERROW,
752 register int j,k,t; 775 (ULONG) & destpitch, TAG_DONE)) {
753 register unsigned char *mask,*dst; 776 register int j, k, t;
754 register unsigned char *src,*dest; 777 register unsigned char *mask, *dst;
778 register unsigned char *src, *dest;
755 779
756 // Aggiungo il bordo della finestra se sono fullscreen. 780 // Aggiungo il bordo della finestra se sono fullscreen.
757 if(!currently_fullscreen) 781 if (!currently_fullscreen)
758 dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 782 dest =
759 else 783 bm_address + (SDL_Window->TopEdge +
760 dest=bm_address; 784 SDL_Window->BorderTop) * destpitch +
761 785 (SDL_Window->BorderLeft +
762 src=this->screen->pixels; 786 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
763 787 else
764 for(j=this->screen->h;j;--j) 788 dest = bm_address;
765 { 789
766 dst=dest; 790 src = this->screen->pixels;
791
792 for (j = this->screen->h; j; --j) {
793 dst = dest;
767 // SLOW routine, used for 8->24 bit mapping 794 // SLOW routine, used for 8->24 bit mapping
768 for(k=0;k<this->screen->w;k++) 795 for (k = 0; k < this->screen->w; k++) {
769 { 796 mask = (unsigned char *) (&SDL_XPixels[src[k]]);
770 mask=(unsigned char *)(&SDL_XPixels[src[k]]); 797 for (t = 0; t < bpp; t++) {
771 for(t=0;t<bpp;t++) 798 dst[t] = mask[t];
772 { 799 }
773 dst[t]=mask[t]; 800 dst += bpp;
774 } 801 }
775 dst+=bpp; 802 src += this->screen->pitch;
776 } 803 dest += destpitch;
777 src+=this->screen->pitch; 804 }
778 dest+=destpitch; 805 UnLockBitMap(handle);
779 } 806 }
780 UnLockBitMap(handle); 807 } else if (customroutine == 3) {
781 } 808 unsigned char *bm_address;
782 } 809 Uint32 destpitch;
783 else if (customroutine==3) 810 APTR handle;
784 { 811
785 unsigned char *bm_address; 812 if (handle =
786 Uint32 destpitch; 813 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
787 APTR handle; 814 (ULONG) & bm_address, LBMI_BYTESPERROW,
788 815 (ULONG) & destpitch, TAG_DONE)) {
789 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, 816 register int j, k;
790 LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) 817 register unsigned char *src, *dest;
791 { 818 register Uint16 *destl, *srcl;
792 register int j,k; 819
793 register unsigned char *src,*dest; 820 if (!currently_fullscreen)
794 register Uint16 *destl,*srcl; 821 dest =
795 822 bm_address + (SDL_Window->TopEdge +
796 if(!currently_fullscreen) 823 SDL_Window->BorderTop) * destpitch +
797 dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 824 (SDL_Window->BorderLeft +
798 else 825 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
799 dest=bm_address; 826 else
800 827 dest = bm_address;
801 src=this->screen->pixels; 828
802 829 src = this->screen->pixels;
830
803 // This is the fast, well not too slow, remapping code for 16bit displays 831 // This is the fast, well not too slow, remapping code for 16bit displays
804 832
805 for(j=this->screen->h;j;--j) 833 for (j = this->screen->h; j; --j) {
806 { 834 destl = (Uint16 *) dest;
807 destl=(Uint16 *)dest; 835
808 836 for (k = 0; k < this->screen->w; k++) {
809 for(k=0;k<this->screen->w;k++) 837 srcl = (Uint16 *) & SDL_XPixels[src[k]];
810 { 838 *destl = *srcl;
811 srcl=(Uint16 *)&SDL_XPixels[src[k]]; 839 destl++;
812 *destl=*srcl; 840 }
813 destl++; 841 src += this->screen->pitch;
814 } 842 dest += destpitch;
815 src+=this->screen->pitch; 843 }
816 dest+=destpitch; 844 UnLockBitMap(handle);
817 } 845 }
818 UnLockBitMap(handle); 846 } else if (customroutine == 4) {
819 } 847 unsigned char *bm_address;
820 } 848 Uint32 destpitch;
821 else if (customroutine==4) 849 APTR handle;
822 { 850
823 unsigned char *bm_address; 851 if (handle =
824 Uint32 destpitch; 852 LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS,
825 APTR handle; 853 (ULONG) & bm_address, LBMI_BYTESPERROW,
826 854 (ULONG) & destpitch, TAG_DONE)) {
827 if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address, 855 register int j, k;
828 LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) 856 register unsigned char *src, *dest;
829 { 857 register Uint32 *destl, *srcl;
830 register int j,k; 858
831 register unsigned char *src,*dest; 859 if (!currently_fullscreen)
832 register Uint32 *destl,*srcl; 860 dest =
833 861 bm_address + (SDL_Window->TopEdge +
834 if(!currently_fullscreen) 862 SDL_Window->BorderTop) * destpitch +
835 dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; 863 (SDL_Window->BorderLeft +
836 else 864 SDL_Window->LeftEdge) * this->hidden->BytesPerPixel;
837 dest=bm_address; 865 else
838 866 dest = bm_address;
839 src=this->screen->pixels; 867
840 868 src = this->screen->pixels;
869
841 // This is the fast, well not too slow, remapping code for 32bit displays 870 // This is the fast, well not too slow, remapping code for 32bit displays
842 871
843 for(j=this->screen->h;j;--j) 872 for (j = this->screen->h; j; --j) {
844 { 873 destl = (Uint32 *) dest;
845 destl=(Uint32 *)dest; 874
846 875 for (k = 0; k < this->screen->w; k++) {
847 for(k=0;k<this->screen->w;k++) 876 srcl = (Uint32 *) & SDL_XPixels[src[k]];
848 { 877 *destl = *srcl;
849 srcl=(Uint32 *)&SDL_XPixels[src[k]]; 878 destl++;
850 *destl=*srcl; 879 }
851 destl++; 880 src += this->screen->pitch;
852 } 881 dest += destpitch;
853 src+=this->screen->pitch; 882 }
854 dest+=destpitch; 883 UnLockBitMap(handle);
855 } 884 }
856 UnLockBitMap(handle);
857 }
858 #endif 885 #endif
859 } 886 } else if (customroutine) {
860 else if(customroutine) 887 unsigned char *bm_address;
861 { 888 Uint32 destpitch;
862 unsigned char *bm_address; 889 APTR handle;
863 Uint32 destpitch; 890
864 APTR handle; 891 if (handle = LockBitMapTags(SDL_RastPort->BitMap,
865 892 LBMI_BASEADDRESS, (ULONG) & bm_address,
866 if(handle=LockBitMapTags(SDL_RastPort->BitMap, 893 LBMI_BYTESPERROW, (ULONG) & destpitch,
867 LBMI_BASEADDRESS,(ULONG)&bm_address, 894 TAG_DONE)) {
868 LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) 895 register int j;
869 { 896 register unsigned char *src, *dest;
870 register int j; 897
871 register unsigned char *src,*dest; 898 if (!currently_fullscreen)
872 899 dest =
873 if(!currently_fullscreen) 900 bm_address + (SDL_Window->TopEdge +
874 dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel; 901 SDL_Window->BorderTop) * destpitch +
875 else 902 (SDL_Window->BorderLeft +
876 dest=bm_address; 903 SDL_Window->LeftEdge) *
877 904 this->screen->format->BytesPerPixel;
878 src=this->screen->pixels; 905 else
879 906 dest = bm_address;
880 // D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch)); 907
881 908 src = this->screen->pixels;
882 if(this->screen->pitch==destpitch) 909
883 { 910 // D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch));
884 SDL_memcpy(dest,src,this->screen->pitch*this->screen->h); 911
885 } 912 if (this->screen->pitch == destpitch) {
886 else 913 SDL_memcpy(dest, src, this->screen->pitch * this->screen->h);
887 { 914 } else {
888 for(j=this->screen->h;j;--j) 915 for (j = this->screen->h; j; --j) {
889 { 916 SDL_memcpy(dest, src, this->screen->pitch);
890 SDL_memcpy(dest,src,this->screen->pitch); 917 src += this->screen->pitch;
891 src+=this->screen->pitch; 918 dest += destpitch;
892 dest+=destpitch; 919 }
893 } 920 }
894 } 921
895 922 UnLockBitMap(handle);
896 UnLockBitMap(handle); 923 }
897 } 924 } else {
898 } 925 USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch,
899 else 926 SDL_RastPort, SDL_Window->BorderLeft,
900 { 927 SDL_Window->BorderTop, this->screen->w, this->screen->h,
901 USE_WPA(this->screen->pixels,0,0,this->screen->pitch, 928 format);
902 SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop, 929 }
903 this->screen->w,this->screen->h,format); 930
904 } 931 }
905 932
906 } 933 /* vi: set ts=4 sw=4 expandtab: */