Mercurial > sdl-ios-xcode
comparison src/video/fbcon/SDL_fb3dfx.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
27 #include "3dfx_mmio.h" | 27 #include "3dfx_mmio.h" |
28 | 28 |
29 | 29 |
30 /* Wait for vertical retrace */ | 30 /* Wait for vertical retrace */ |
31 static void | 31 static void |
32 WaitVBL (_THIS) | 32 WaitVBL(_THIS) |
33 { | 33 { |
34 /* find start of retrace */ | 34 /* find start of retrace */ |
35 tdfx_waitidle (); | 35 tdfx_waitidle(); |
36 while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE); | 36 while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE); |
37 /* wait until we're past the start */ | 37 /* wait until we're past the start */ |
38 while ((tdfx_in32 (TDFX_STATUS) & STATUS_RETRACE) == 0); | 38 while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0); |
39 } | 39 } |
40 static void | 40 static void |
41 WaitIdle (_THIS) | 41 WaitIdle(_THIS) |
42 { | 42 { |
43 tdfx_waitidle (); | 43 tdfx_waitidle(); |
44 } | 44 } |
45 | 45 |
46 /* Sets video mem colorkey and accelerated blit function */ | 46 /* Sets video mem colorkey and accelerated blit function */ |
47 static int | 47 static int |
48 SetHWColorKey (_THIS, SDL_Surface * surface, Uint32 key) | 48 SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) |
49 { | 49 { |
50 return (0); | 50 return (0); |
51 } | 51 } |
52 | 52 |
53 static int | 53 static int |
54 FillHWRect (_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) | 54 FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) |
55 { | 55 { |
56 int bpp; | 56 int bpp; |
57 char *dst_base; | 57 char *dst_base; |
58 Uint32 format; | 58 Uint32 format; |
59 int dstX, dstY; | 59 int dstX, dstY; |
61 /* Don't blit to the display surface when switched away */ | 61 /* Don't blit to the display surface when switched away */ |
62 if (switched_away) { | 62 if (switched_away) { |
63 return -2; /* no hardware access */ | 63 return -2; /* no hardware access */ |
64 } | 64 } |
65 if (dst == this->screen) { | 65 if (dst == this->screen) { |
66 SDL_mutexP (hw_lock); | 66 SDL_mutexP(hw_lock); |
67 } | 67 } |
68 | 68 |
69 /* Set the destination pixel format */ | 69 /* Set the destination pixel format */ |
70 dst_base = (char *) ((char *) dst->pixels - mapped_mem); | 70 dst_base = (char *) ((char *) dst->pixels - mapped_mem); |
71 bpp = dst->format->BitsPerPixel; | 71 bpp = dst->format->BitsPerPixel; |
74 /* Calculate source and destination base coordinates */ | 74 /* Calculate source and destination base coordinates */ |
75 dstX = rect->x; | 75 dstX = rect->x; |
76 dstY = rect->y; | 76 dstY = rect->y; |
77 | 77 |
78 /* Execute the fill command */ | 78 /* Execute the fill command */ |
79 tdfx_wait (6); | 79 tdfx_wait(6); |
80 tdfx_out32 (DSTBASE, (Uint32) dst_base); | 80 tdfx_out32(DSTBASE, (Uint32) dst_base); |
81 tdfx_out32 (DSTFORMAT, format); | 81 tdfx_out32(DSTFORMAT, format); |
82 tdfx_out32 (COLORFORE, color); | 82 tdfx_out32(COLORFORE, color); |
83 tdfx_out32 (COMMAND_2D, COMMAND_2D_FILLRECT); | 83 tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT); |
84 tdfx_out32 (DSTSIZE, rect->w | (rect->h << 16)); | 84 tdfx_out32(DSTSIZE, rect->w | (rect->h << 16)); |
85 tdfx_out32 (LAUNCH_2D, dstX | (dstY << 16)); | 85 tdfx_out32(LAUNCH_2D, dstX | (dstY << 16)); |
86 | 86 |
87 FB_AddBusySurface (dst); | 87 FB_AddBusySurface(dst); |
88 | 88 |
89 if (dst == this->screen) { | 89 if (dst == this->screen) { |
90 SDL_mutexV (hw_lock); | 90 SDL_mutexV(hw_lock); |
91 } | 91 } |
92 return (0); | 92 return (0); |
93 } | 93 } |
94 | 94 |
95 static int | 95 static int |
96 HWAccelBlit (SDL_Surface * src, SDL_Rect * srcrect, | 96 HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, |
97 SDL_Surface * dst, SDL_Rect * dstrect) | 97 SDL_Surface * dst, SDL_Rect * dstrect) |
98 { | 98 { |
99 SDL_VideoDevice *this = current_video; | 99 SDL_VideoDevice *this = current_video; |
100 int bpp; | 100 int bpp; |
101 Uint32 src_format; | 101 Uint32 src_format; |
102 Uint32 dst_format; | 102 Uint32 dst_format; |
110 /* Don't blit to the display surface when switched away */ | 110 /* Don't blit to the display surface when switched away */ |
111 if (switched_away) { | 111 if (switched_away) { |
112 return -2; /* no hardware access */ | 112 return -2; /* no hardware access */ |
113 } | 113 } |
114 if (dst == this->screen) { | 114 if (dst == this->screen) { |
115 SDL_mutexP (hw_lock); | 115 SDL_mutexP(hw_lock); |
116 } | 116 } |
117 | 117 |
118 /* Set the source and destination pixel format */ | 118 /* Set the source and destination pixel format */ |
119 src_base = (char *) ((char *) src->pixels - mapped_mem); | 119 src_base = (char *) ((char *) src->pixels - mapped_mem); |
120 bpp = src->format->BitsPerPixel; | 120 bpp = src->format->BitsPerPixel; |
129 dstY = dstrect->y; | 129 dstY = dstrect->y; |
130 | 130 |
131 /* Assemble the blit operation */ | 131 /* Assemble the blit operation */ |
132 blitop = COMMAND_2D_BITBLT | (0xCC << 24); | 132 blitop = COMMAND_2D_BITBLT | (0xCC << 24); |
133 if (srcX <= dstX) { | 133 if (srcX <= dstX) { |
134 blitop |= BIT (14); | 134 blitop |= BIT(14); |
135 srcX += (dstrect->w - 1); | 135 srcX += (dstrect->w - 1); |
136 dstX += (dstrect->w - 1); | 136 dstX += (dstrect->w - 1); |
137 } | 137 } |
138 if (srcY <= dstY) { | 138 if (srcY <= dstY) { |
139 blitop |= BIT (15); | 139 blitop |= BIT(15); |
140 srcY += (dstrect->h - 1); | 140 srcY += (dstrect->h - 1); |
141 dstY += (dstrect->h - 1); | 141 dstY += (dstrect->h - 1); |
142 } | 142 } |
143 | 143 |
144 /* Perform the blit! */ | 144 /* Perform the blit! */ |
145 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { | 145 if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { |
146 tdfx_wait (3); | 146 tdfx_wait(3); |
147 tdfx_out32 (SRCCOLORKEYMIN, src->format->colorkey); | 147 tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey); |
148 tdfx_out32 (SRCCOLORKEYMAX, src->format->colorkey); | 148 tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey); |
149 tdfx_out32 (ROP_2D, 0xAA00); | 149 tdfx_out32(ROP_2D, 0xAA00); |
150 use_colorkey = 1; | 150 use_colorkey = 1; |
151 } else { | 151 } else { |
152 use_colorkey = 0; | 152 use_colorkey = 0; |
153 } | 153 } |
154 tdfx_wait (9); | 154 tdfx_wait(9); |
155 tdfx_out32 (SRCBASE, (Uint32) src_base); | 155 tdfx_out32(SRCBASE, (Uint32) src_base); |
156 tdfx_out32 (SRCFORMAT, src_format); | 156 tdfx_out32(SRCFORMAT, src_format); |
157 tdfx_out32 (DSTBASE, (Uint32) dst_base); | 157 tdfx_out32(DSTBASE, (Uint32) dst_base); |
158 tdfx_out32 (DSTFORMAT, src_format); | 158 tdfx_out32(DSTFORMAT, src_format); |
159 tdfx_out32 (COMMAND_2D, blitop); | 159 tdfx_out32(COMMAND_2D, blitop); |
160 tdfx_out32 (COMMANDEXTRA_2D, use_colorkey); | 160 tdfx_out32(COMMANDEXTRA_2D, use_colorkey); |
161 tdfx_out32 (DSTSIZE, dstrect->w | (dstrect->h << 16)); | 161 tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16)); |
162 tdfx_out32 (DSTXY, dstX | (dstY << 16)); | 162 tdfx_out32(DSTXY, dstX | (dstY << 16)); |
163 tdfx_out32 (LAUNCH_2D, srcX | (srcY << 16)); | 163 tdfx_out32(LAUNCH_2D, srcX | (srcY << 16)); |
164 | 164 |
165 FB_AddBusySurface (src); | 165 FB_AddBusySurface(src); |
166 FB_AddBusySurface (dst); | 166 FB_AddBusySurface(dst); |
167 | 167 |
168 if (dst == this->screen) { | 168 if (dst == this->screen) { |
169 SDL_mutexV (hw_lock); | 169 SDL_mutexV(hw_lock); |
170 } | 170 } |
171 return (0); | 171 return (0); |
172 } | 172 } |
173 | 173 |
174 static int | 174 static int |
175 CheckHWBlit (_THIS, SDL_Surface * src, SDL_Surface * dst) | 175 CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) |
176 { | 176 { |
177 int accelerated; | 177 int accelerated; |
178 | 178 |
179 /* Set initial acceleration on */ | 179 /* Set initial acceleration on */ |
180 src->flags |= SDL_HWACCEL; | 180 src->flags |= SDL_HWACCEL; |
198 } | 198 } |
199 return (accelerated); | 199 return (accelerated); |
200 } | 200 } |
201 | 201 |
202 void | 202 void |
203 FB_3DfxAccel (_THIS, __u32 card) | 203 FB_3DfxAccel(_THIS, __u32 card) |
204 { | 204 { |
205 /* We have hardware accelerated surface functions */ | 205 /* We have hardware accelerated surface functions */ |
206 this->CheckHWBlit = CheckHWBlit; | 206 this->CheckHWBlit = CheckHWBlit; |
207 wait_vbl = WaitVBL; | 207 wait_vbl = WaitVBL; |
208 wait_idle = WaitIdle; | 208 wait_idle = WaitIdle; |
209 | 209 |
210 /* Reset the 3Dfx controller */ | 210 /* Reset the 3Dfx controller */ |
211 tdfx_out32 (BRESERROR0, 0); | 211 tdfx_out32(BRESERROR0, 0); |
212 tdfx_out32 (BRESERROR1, 0); | 212 tdfx_out32(BRESERROR1, 0); |
213 | 213 |
214 /* The 3Dfx has an accelerated color fill */ | 214 /* The 3Dfx has an accelerated color fill */ |
215 this->info.blit_fill = 1; | 215 this->info.blit_fill = 1; |
216 this->FillHWRect = FillHWRect; | 216 this->FillHWRect = FillHWRect; |
217 | 217 |