Mercurial > sdl-ios-xcode
annotate src/video/cybergfx/SDL_cgxaccel.c @ 1371:e2641c13bf33
Added a reminder on where to put libSDL.so
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 18 Feb 2006 07:21:42 +0000 |
parents | 19418e4422cb |
children | d910939febfa |
rev | line source |
---|---|
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
1 /* |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
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:
255
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
4 |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
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:
255
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
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:
255
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
9 |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
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:
255
diff
changeset
|
13 Lesser General Public License for more details. |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
255
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:
255
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:
255
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
18 |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
19 Sam Lantinga |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
20 slouken@libsdl.org |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
21 */ |
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
22 |
0 | 23 #include "SDL_endian.h" |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
24 #include "SDL_video.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
25 #include "../SDL_sysvideo.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
26 #include "../SDL_blit.h" |
0 | 27 #include "SDL_cgxvideo.h" |
28 | |
29 static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, | |
30 SDL_Surface *dst, SDL_Rect *dstrect); | |
31 | |
32 // These are needed to avoid register troubles with gcc -O2! | |
33 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
34 #if defined(__SASC) || defined(__PPC__) || defined(MORPHOS) |
0 | 35 #define BMKBRP(a,b,c,d,e,f,g,h,i,j) BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j) |
36 #define BBRP(a,b,c,d,e,f,g,h,i) BltBitMapRastPort(a,b,c,d,e,f,g,h,i) | |
37 #define BBB(a,b,c,d,e,f,g,h,i,j,k) BltBitMap(a,b,c,d,e,f,g,h,i,j,k) | |
38 #else | |
39 void BMKBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,APTR j) | |
40 {BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j);} | |
41 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
42 void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i) |
0 | 43 {BltBitMapRastPort(a,b,c,d,e,f,g,h,i);} |
44 | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
45 void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k) |
0 | 46 {BltBitMap(a,b,c,d,e,f,g,h,i,j,k);} |
47 #endif | |
48 | |
49 int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key) | |
50 { | |
51 if(surface->hwdata) | |
52 { | |
53 if(surface->hwdata->mask) | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
54 SDL_free(surface->hwdata->mask); |
0 | 55 |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
56 if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h))) |
0 | 57 { |
58 Uint32 pitch,ok=0; | |
59 APTR lock; | |
60 | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
61 SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h)); |
0 | 62 |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
63 D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel)); |
0 | 64 |
65 if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels, | |
66 LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)) | |
67 { | |
68 switch(surface->format->BytesPerPixel) | |
69 { | |
70 case 1: | |
71 { | |
72 unsigned char k=key; | |
73 register int i,j,t; | |
74 register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; | |
75 | |
76 pitch-=surface->w; | |
77 | |
78 for(i=0;i<surface->h;i++) | |
79 { | |
80 for(t=128,j=0;j<surface->w;j++) | |
81 { | |
82 if(*map==k) | |
83 *dest&=~t; | |
84 | |
85 t>>=1; | |
86 | |
87 if(t==0) | |
88 { | |
89 dest++; | |
90 t=128; | |
91 } | |
92 map++; | |
93 } | |
94 map+=pitch; | |
95 } | |
96 } | |
97 break; | |
98 case 2: | |
99 { | |
100 Uint16 k=key,*mapw; | |
101 register int i,j,t; | |
102 register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; | |
103 | |
104 for(i=surface->h;i;--i) | |
105 { | |
106 mapw=(Uint16 *)map; | |
107 | |
108 for(t=128,j=surface->w;j;--j) | |
109 { | |
110 if(*mapw==k) | |
111 *dest&=~t; | |
112 | |
113 t>>=1; | |
114 | |
115 if(t==0) | |
116 { | |
117 dest++; | |
118 t=128; | |
119 } | |
120 mapw++; | |
121 } | |
122 map+=pitch; | |
123 } | |
124 } | |
125 break; | |
126 case 4: | |
127 { | |
128 Uint32 *mapl; | |
129 register int i,j,t; | |
130 register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; | |
131 | |
132 for(i=surface->h;i;--i) | |
133 { | |
134 mapl=(Uint32 *)map; | |
135 | |
136 for(t=128,j=surface->w;j;--j) | |
137 { | |
138 if(*mapl==key) | |
139 *dest&=~t; | |
140 | |
141 t>>=1; | |
142 | |
143 if(t==0) | |
144 { | |
145 dest++; | |
146 t=128; | |
147 } | |
148 mapl++; | |
149 } | |
150 map+=pitch; | |
151 } | |
152 | |
153 } | |
154 break; | |
155 default: | |
156 D(bug("Pixel mode non supported for color key...")); | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
157 SDL_free(surface->hwdata->mask); |
0 | 158 surface->hwdata->mask=NULL; |
159 ok=-1; | |
160 } | |
161 UnLockBitMap(lock); | |
255
dcb5e869f8b5
Updated Amiga port by Gabriele Greco
Sam Lantinga <slouken@libsdl.org>
parents:
21
diff
changeset
|
162 D(bug("...Colorkey built!\n")); |
0 | 163 return ok; |
164 } | |
165 } | |
166 } | |
167 D(bug("HW colorkey not supported for this depth\n")); | |
168 | |
169 return -1; | |
170 } | |
171 | |
172 int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst) | |
173 { | |
174 // Doesn't support yet alpha blitting | |
175 | |
176 if(src->hwdata&& !(src->flags & (SDL_SRCALPHA))) | |
177 { | |
178 D(bug("CheckHW blit... OK!\n")); | |
179 | |
180 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { | |
181 if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 ) { | |
182 src->flags &= ~SDL_HWACCEL; | |
183 return -1; | |
184 } | |
185 } | |
186 | |
187 src->flags|=SDL_HWACCEL; | |
188 src->map->hw_blit = CGX_HWAccelBlit; | |
189 return 1; | |
190 } | |
191 else | |
192 src->flags &= ~SDL_HWACCEL; | |
193 | |
194 D(bug("CheckHW blit... NO!\n")); | |
195 | |
196 return 0; | |
197 } | |
198 | |
199 static int temprp_init=0; | |
200 static struct RastPort temprp; | |
201 | |
202 static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, | |
203 SDL_Surface *dst, SDL_Rect *dstrect) | |
204 { | |
205 struct SDL_VideoDevice *this=src->hwdata->videodata; | |
206 | |
207 // D(bug("Accel blit!\n")); | |
208 | |
209 if(src->flags&SDL_SRCCOLORKEY && src->hwdata->mask) | |
210 { | |
211 if(dst==SDL_VideoSurface) | |
212 { | |
213 BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y, | |
214 SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop, | |
215 srcrect->w,srcrect->h,0xc0,src->hwdata->mask); | |
216 } | |
217 else if(dst->hwdata) | |
218 { | |
219 if(!temprp_init) | |
220 { | |
221 InitRastPort(&temprp); | |
222 temprp_init=1; | |
223 } | |
224 temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; | |
225 | |
226 BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y, | |
227 &temprp,dstrect->x,dstrect->y, | |
228 srcrect->w,srcrect->h,0xc0,src->hwdata->mask); | |
229 | |
230 } | |
231 } | |
232 else if(dst==SDL_VideoSurface) | |
233 { | |
234 BBRP(src->hwdata->bmap,srcrect->x,srcrect->y,SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,srcrect->w,srcrect->h,0xc0); | |
235 } | |
236 else if(dst->hwdata) | |
237 BBB(src->hwdata->bmap,srcrect->x,srcrect->y,dst->hwdata->bmap,dstrect->x,dstrect->y,srcrect->w,srcrect->h,0xc0,0xff,NULL); | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
238 |
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
239 return 0; |
0 | 240 } |
241 | |
242 int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color) | |
243 { | |
244 if(dst==SDL_VideoSurface) | |
245 { | |
246 FillPixelArray(SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,dstrect->w,dstrect->h,color); | |
247 } | |
248 else if(dst->hwdata) | |
249 { | |
250 if(!temprp_init) | |
251 { | |
252 InitRastPort(&temprp); | |
253 temprp_init=1; | |
254 } | |
255 | |
256 temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; | |
257 | |
258 FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color); | |
259 } | |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
260 return 0; |
0 | 261 } |