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