annotate src/video/fbcon/SDL_fb3dfx.c @ 4072:6930cd5ab933 SDL-1.2

Final fix for bug #373 ------- Comment #13 From Christian Walther 2007-07-15 10:04:56 [reply] ------- Created an attachment (id=229) [details] patch to reinstate the SDL cursor after an NSApplicationActivatedEvent Oops, you're right. My testcursor.c has diverged so far from the original that I missed that. In fact, now that I think about it, that issue isn't even addressed by the cursor rectangle patch - it is only concerned with windowed mode (and fixes the problem there as a side effect). The problem in fullscreen is still the same as before. How about the attachment for a fix? (I can confirm that [NSCursor set] doesn't seem to have any effect when called from QZ_DoActivate().)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Jul 2007 17:22:39 +0000
parents f903dc168217
children a1b03ba2fcd0
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
2 SDL - Simple DirectMedia Layer
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
5 This library is free software; you can redistribute it and/or
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
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
7 License as published by the Free Software Foundation; either
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
10 This library is distributed in the hope that it will be useful,
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
19 Sam Lantinga
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
20 slouken@libsdl.org
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
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_blit.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include "SDL_fb3dfx.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "3dfx_mmio.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 /* Wait for vertical retrace */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 static void WaitVBL(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 /* find start of retrace */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 tdfx_waitidle();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 ;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 /* wait until we're past the start */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0 )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 ;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 }
106
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
41 static void WaitIdle(_THIS)
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
42 {
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
43 tdfx_waitidle();
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
44 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 /* Sets video mem colorkey and accelerated blit function */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 int bpp;
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
55 Uint32 dst_base;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 Uint32 format;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 int dstX, dstY;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
59 /* Don't blit to the display surface when switched away */
1780
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
60 if ( switched_away ) {
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
61 return -2; /* no hardware access */
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
62 }
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
63 if ( dst == this->screen ) {
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
64 SDL_mutexP(hw_lock);
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
65 }
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
66
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 /* Set the destination pixel format */
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
68 dst_base = ((char *)dst->pixels - mapped_mem);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 bpp = dst->format->BitsPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 /* Calculate source and destination base coordinates */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 dstX = rect->x;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 dstY = rect->y;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 /* Execute the fill command */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 tdfx_wait(6);
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
78 tdfx_out32(DSTBASE, dst_base);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 tdfx_out32(DSTFORMAT, format);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 tdfx_out32(COLORFORE, color);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 tdfx_out32(DSTSIZE, rect->w | (rect->h << 16));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 tdfx_out32(LAUNCH_2D, dstX | (dstY << 16));
106
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
84
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
85 FB_AddBusySurface(dst);
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
86
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
87 if ( dst == this->screen ) {
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
88 SDL_mutexV(hw_lock);
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
89 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 SDL_Surface *dst, SDL_Rect *dstrect)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 {
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
96 SDL_VideoDevice *this = current_video;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 int bpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 Uint32 src_format;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 Uint32 dst_format;
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
100 Uint32 src_base;
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
101 Uint32 dst_base;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 int srcX, srcY;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 int dstX, dstY;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 Uint32 blitop;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 Uint32 use_colorkey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
107 /* Don't blit to the display surface when switched away */
1780
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
108 if ( switched_away ) {
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
109 return -2; /* no hardware access */
7a36f01acf71 Fixed bug #49
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
110 }
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
111 if ( dst == this->screen ) {
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
112 SDL_mutexP(hw_lock);
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
113 }
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
114
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 /* Set the source and destination pixel format */
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
116 src_base = ((char *)src->pixels - mapped_mem);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 bpp = src->format->BitsPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
3989
f903dc168217 Fixed 64-bit compile issues
Sam Lantinga <slouken@libsdl.org>
parents: 1780
diff changeset
119 dst_base = ((char *)dst->pixels - mapped_mem);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 bpp = dst->format->BitsPerPixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 dst_format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 srcX = srcrect->x;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 srcY = srcrect->y;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 dstX = dstrect->x;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 dstY = dstrect->y;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 /* Assemble the blit operation */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 blitop = COMMAND_2D_BITBLT | (0xCC << 24);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 if ( srcX <= dstX ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 blitop |= BIT(14);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 srcX += (dstrect->w - 1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 dstX += (dstrect->w - 1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 if ( srcY <= dstY ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 blitop |= BIT(15);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 srcY += (dstrect->h - 1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 dstY += (dstrect->h - 1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 /* Perform the blit! */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 tdfx_wait(3);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 tdfx_out32(ROP_2D, 0xAA00);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 use_colorkey = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 use_colorkey = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 tdfx_wait(9);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 tdfx_out32(SRCBASE, (Uint32)src_base);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 tdfx_out32(SRCFORMAT, src_format);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 tdfx_out32(DSTBASE, (Uint32)dst_base);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 tdfx_out32(DSTFORMAT, src_format);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 tdfx_out32(COMMAND_2D, blitop);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 tdfx_out32(COMMANDEXTRA_2D, use_colorkey);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 tdfx_out32(DSTXY, dstX | (dstY << 16));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 tdfx_out32(LAUNCH_2D, srcX | (srcY << 16));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161
106
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
162 FB_AddBusySurface(src);
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
163 FB_AddBusySurface(dst);
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
164
109
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
165 if ( dst == this->screen ) {
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
166 SDL_mutexV(hw_lock);
5a9c36a45db1 Fixed switching away from the SDL at the framebuffer console
Sam Lantinga <slouken@lokigames.com>
parents: 106
diff changeset
167 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 int accelerated;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 /* Set initial acceleration on */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 src->flags |= SDL_HWACCEL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 /* Set the surface attributes */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 if ( ! this->info.blit_hw_A ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 src->flags &= ~SDL_HWACCEL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 if ( ! this->info.blit_hw_CC ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 src->flags &= ~SDL_HWACCEL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 /* Check to see if final surface blit is accelerated */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 accelerated = !!(src->flags & SDL_HWACCEL);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 if ( accelerated ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 src->map->hw_blit = HWAccelBlit;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 return(accelerated);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 void FB_3DfxAccel(_THIS, __u32 card)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 /* We have hardware accelerated surface functions */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 this->CheckHWBlit = CheckHWBlit;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 wait_vbl = WaitVBL;
106
63ec24e0575f Merged DGA video surface handling improvements, unified locking code.
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
203 wait_idle = WaitIdle;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 /* Reset the 3Dfx controller */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 tdfx_out32(BRESERROR0, 0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 tdfx_out32(BRESERROR1, 0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 /* The 3Dfx has an accelerated color fill */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 this->info.blit_fill = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 this->FillHWRect = FillHWRect;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 /* The 3Dfx has accelerated normal and colorkey blits */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 this->info.blit_hw = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 this->info.blit_hw_CC = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 this->SetHWColorKey = SetHWColorKey;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 }