Mercurial > sdl-ios-xcode
annotate src/video/svga/SDL_svgavideo.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 |
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:
226
diff
changeset
|
20 slouken@libsdl.org |
0 | 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 | 23 |
24 /* SVGAlib based SDL video driver implementation. | |
25 */ | |
26 | |
27 #include <unistd.h> | |
28 #include <sys/stat.h> | |
67
3647c809813d
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
29 #include <sys/types.h> |
3647c809813d
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
30 #include <sys/ioctl.h> |
3647c809813d
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
31 #include <fcntl.h> |
0 | 32 |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
33 #if defined(__LINUX__) |
0 | 34 #include <linux/vt.h> |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
35 #elif defined(__FREEBSD__) |
0 | 36 #include <sys/consio.h> |
37 #else | |
38 #error You must choose your operating system here | |
39 #endif | |
40 #include <vga.h> | |
41 #include <vgamouse.h> | |
42 #include <vgakeyboard.h> | |
43 | |
44 #include "SDL_video.h" | |
45 #include "SDL_mouse.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
46 #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
|
47 #include "../SDL_pixels_c.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
48 #include "../../events/SDL_events_c.h" |
0 | 49 #include "SDL_svgavideo.h" |
50 #include "SDL_svgaevents_c.h" | |
51 #include "SDL_svgamouse_c.h" | |
52 | |
53 /* Initialization/Query functions */ | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
54 static int SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
55 static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat * format, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
56 Uint32 flags); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
57 static SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface * current, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
58 int width, int height, int bpp, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
59 Uint32 flags); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
60 static int SVGA_SetColors(_THIS, int firstcolor, int ncolors, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
61 SDL_Color * colors); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
62 static void SVGA_VideoQuit(_THIS); |
0 | 63 |
64 /* Hardware surface functions */ | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
65 static int SVGA_AllocHWSurface(_THIS, SDL_Surface * surface); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
66 static int SVGA_LockHWSurface(_THIS, SDL_Surface * surface); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
67 static int SVGA_FlipHWSurface(_THIS, SDL_Surface * surface); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
68 static void SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
69 static void SVGA_FreeHWSurface(_THIS, SDL_Surface * surface); |
0 | 70 |
71 /* SVGAlib driver bootstrap functions */ | |
72 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
73 static int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
74 SVGA_Available(void) |
0 | 75 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
76 /* Check to see if we are root and stdin is a virtual console */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
77 int console; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
78 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
79 /* SVGALib 1.9.x+ doesn't require root (via /dev/svga) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
80 int svgalib2 = -1; |
0 | 81 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
82 /* See if we are connected to a virtual terminal */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
83 console = STDIN_FILENO; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
84 #if 0 /* This is no longer needed, SVGAlib can switch consoles for us */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
85 if (console >= 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
86 struct stat sb; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
87 struct vt_mode dummy; |
0 | 88 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
89 if ((fstat(console, &sb) < 0) || |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
90 (ioctl(console, VT_GETMODE, &dummy) < 0)) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
91 console = -1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
92 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
93 } |
226
bb72c418a1f9
Disabled virtual terminal check for SVGAlib video
Sam Lantinga <slouken@libsdl.org>
parents:
205
diff
changeset
|
94 #endif /* 0 */ |
67
3647c809813d
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
95 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
96 /* See if SVGAlib 2.0 is available */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
97 svgalib2 = open("/dev/svga", O_RDONLY); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
98 if (svgalib2 != -1) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
99 close(svgalib2); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
100 } |
67
3647c809813d
Support for SVGALib 2.0, thanks to Benjamin Joel Stover
Sam Lantinga <slouken@lokigames.com>
parents:
1
diff
changeset
|
101 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
102 return (((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0)); |
0 | 103 } |
104 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
105 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
106 SVGA_DeleteDevice(SDL_VideoDevice * device) |
0 | 107 { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
108 SDL_free(device->hidden); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
109 SDL_free(device); |
0 | 110 } |
111 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
112 static SDL_VideoDevice * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
113 SVGA_CreateDevice(int devindex) |
0 | 114 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
115 SDL_VideoDevice *device; |
0 | 116 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
117 /* Initialize all variables that we clean on shutdown */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
118 device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
119 if (device) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
120 SDL_memset(device, 0, (sizeof *device)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
121 device->hidden = (struct SDL_PrivateVideoData *) |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
122 SDL_malloc((sizeof *device->hidden)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
123 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
124 if ((device == NULL) || (device->hidden == NULL)) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
125 SDL_OutOfMemory(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
126 if (device) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
127 SDL_free(device); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
128 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
129 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
130 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
131 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); |
0 | 132 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
133 /* Set the function pointers */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
134 device->VideoInit = SVGA_VideoInit; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
135 device->ListModes = SVGA_ListModes; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
136 device->SetVideoMode = SVGA_SetVideoMode; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
137 device->SetColors = SVGA_SetColors; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
138 device->UpdateRects = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
139 device->VideoQuit = SVGA_VideoQuit; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
140 device->AllocHWSurface = SVGA_AllocHWSurface; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
141 device->CheckHWBlit = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
142 device->FillHWRect = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
143 device->SetHWColorKey = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
144 device->SetHWAlpha = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
145 device->LockHWSurface = SVGA_LockHWSurface; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
146 device->UnlockHWSurface = SVGA_UnlockHWSurface; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
147 device->FlipHWSurface = SVGA_FlipHWSurface; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
148 device->FreeHWSurface = SVGA_FreeHWSurface; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
149 device->SetCaption = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
150 device->SetIcon = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
151 device->IconifyWindow = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
152 device->GrabInput = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
153 device->GetWMInfo = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
154 device->InitOSKeymap = SVGA_InitOSKeymap; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
155 device->PumpEvents = SVGA_PumpEvents; |
0 | 156 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
157 device->free = SVGA_DeleteDevice; |
0 | 158 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
159 return device; |
0 | 160 } |
161 | |
162 VideoBootStrap SVGALIB_bootstrap = { | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
163 "svgalib", "SVGAlib", |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
164 SVGA_Available, SVGA_CreateDevice |
0 | 165 }; |
166 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
167 static int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
168 SVGA_AddMode(_THIS, int mode, int actually_add) |
0 | 169 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
170 int i, j; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
171 vga_modeinfo *modeinfo; |
0 | 172 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
173 modeinfo = vga_getmodeinfo(mode); |
0 | 174 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
175 i = modeinfo->bytesperpixel - 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
176 if (i < 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
177 return 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
178 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
179 if (actually_add) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
180 SDL_Rect saved_rect[2]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
181 int saved_mode[2]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
182 int b; |
0 | 183 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
184 /* Add the mode, sorted largest to smallest */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
185 b = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
186 j = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
187 while ((SDL_modelist[i][j]->w > modeinfo->width) || |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
188 (SDL_modelist[i][j]->h > modeinfo->height)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
189 ++j; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
190 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
191 /* Skip modes that are already in our list */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
192 if ((SDL_modelist[i][j]->w == modeinfo->width) && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
193 (SDL_modelist[i][j]->h == modeinfo->height)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
194 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
195 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
196 /* Insert the new mode */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
197 saved_rect[b] = *SDL_modelist[i][j]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
198 saved_mode[b] = SDL_vgamode[i][j]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
199 SDL_modelist[i][j]->w = modeinfo->width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
200 SDL_modelist[i][j]->h = modeinfo->height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
201 SDL_vgamode[i][j] = mode; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
202 /* Everybody scoot down! */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
203 if (saved_rect[b].w && saved_rect[b].h) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
204 for (++j; SDL_modelist[i][j]->w; ++j) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
205 saved_rect[!b] = *SDL_modelist[i][j]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
206 saved_mode[!b] = SDL_vgamode[i][j]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
207 *SDL_modelist[i][j] = saved_rect[b]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
208 SDL_vgamode[i][j] = saved_mode[b]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
209 b = !b; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
210 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
211 *SDL_modelist[i][j] = saved_rect[b]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
212 SDL_vgamode[i][j] = saved_mode[b]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
213 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
214 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
215 ++SDL_nummodes[i]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
216 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
217 return (1); |
0 | 218 } |
219 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
220 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
221 SVGA_UpdateVideoInfo(_THIS) |
0 | 222 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
223 vga_modeinfo *modeinfo; |
0 | 224 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
225 this->info.wm_available = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
226 this->info.hw_available = (banked ? 0 : 1); |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
227 modeinfo = vga_getmodeinfo(vga_getcurrentmode()); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
228 this->info.video_mem = modeinfo->memory; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
229 /* FIXME: Add hardware accelerated blit information */ |
226
bb72c418a1f9
Disabled virtual terminal check for SVGAlib video
Sam Lantinga <slouken@libsdl.org>
parents:
205
diff
changeset
|
230 #ifdef SVGALIB_DEBUG |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
231 printf("Hardware accelerated blit: %savailable\n", |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
232 modeinfo->haveblit ? "" : "not "); |
0 | 233 #endif |
234 } | |
235 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
236 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
237 SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat) |
0 | 238 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
239 int keyboard; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
240 int i, j; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
241 int mode, total_modes; |
0 | 242 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
243 /* Initialize all variables that we clean on shutdown */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
244 for (i = 0; i < NUM_MODELISTS; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
245 SDL_nummodes[i] = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
246 SDL_modelist[i] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
247 SDL_vgamode[i] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
248 } |
0 | 249 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
250 /* Initialize the library */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
251 vga_disabledriverreport(); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
252 if (vga_init() < 0) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
253 SDL_SetError("Unable to initialize SVGAlib"); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
254 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
255 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
256 vga_setmode(TEXT); |
0 | 257 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
258 /* Enable mouse and keyboard support */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
259 vga_setmousesupport(1); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
260 keyboard = keyboard_init_return_fd(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
261 if (keyboard < 0) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
262 SDL_SetError("Unable to initialize keyboard"); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
263 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
264 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
265 if (SVGA_initkeymaps(keyboard) < 0) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
266 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
267 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
268 keyboard_seteventhandler(SVGA_keyboardcallback); |
0 | 269 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
270 /* Determine the current screen size */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
271 this->info.current_w = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
272 this->info.current_h = 0; |
1545
8d9bb0cf2c2a
Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
273 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
274 /* Determine the screen depth (use default 8-bit depth) */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
275 vformat->BitsPerPixel = 8; |
0 | 276 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
277 /* Enumerate the available fullscreen modes */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
278 total_modes = 0; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
279 for (mode = vga_lastmodenumber(); mode; --mode) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
280 if (vga_hasmode(mode)) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
281 if (SVGA_AddMode(this, mode, 0)) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
282 ++total_modes; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
283 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
284 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
285 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
286 if (SVGA_AddMode(this, G320x200x256, 0)) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
287 ++total_modes; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
288 if (total_modes == 0) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
289 SDL_SetError("No linear video modes available"); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
290 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
291 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
292 for (i = 0; i < NUM_MODELISTS; ++i) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
293 SDL_vgamode[i] = (int *) SDL_malloc(SDL_nummodes[i] * sizeof(int)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
294 if (SDL_vgamode[i] == NULL) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
295 SDL_OutOfMemory(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
296 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
297 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
298 SDL_modelist[i] = (SDL_Rect **) |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
299 SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
300 if (SDL_modelist[i] == NULL) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
301 SDL_OutOfMemory(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
302 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
303 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
304 for (j = 0; j < SDL_nummodes[i]; ++j) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
305 SDL_modelist[i][j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
306 if (SDL_modelist[i][j] == NULL) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
307 SDL_OutOfMemory(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
308 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
309 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
310 SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
311 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
312 SDL_modelist[i][j] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
313 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
314 for (mode = vga_lastmodenumber(); mode; --mode) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
315 if (vga_hasmode(mode)) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
316 SVGA_AddMode(this, mode, 1); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
317 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
318 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
319 SVGA_AddMode(this, G320x200x256, 1); |
0 | 320 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
321 /* Free extra (duplicated) modes */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
322 for (i = 0; i < NUM_MODELISTS; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
323 j = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
324 while (SDL_modelist[i][j] && SDL_modelist[i][j]->w) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
325 j++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
326 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
327 while (SDL_modelist[i][j]) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
328 SDL_free(SDL_modelist[i][j]); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
329 SDL_modelist[i][j] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
330 j++; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
331 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
332 } |
0 | 333 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
334 /* Fill in our hardware acceleration capabilities */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
335 SVGA_UpdateVideoInfo(this); |
0 | 336 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
337 /* We're done! */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
338 return (0); |
0 | 339 } |
340 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
341 SDL_Rect ** |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
342 SVGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) |
0 | 343 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
344 return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); |
0 | 345 } |
346 | |
347 /* Various screen update functions available */ | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
348 static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
349 static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects); |
0 | 350 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
351 SDL_Surface * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
352 SVGA_SetVideoMode(_THIS, SDL_Surface * current, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
353 int width, int height, int bpp, Uint32 flags) |
0 | 354 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
355 int mode; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
356 int vgamode; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
357 vga_modeinfo *modeinfo; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
358 int screenpage_len; |
0 | 359 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
360 /* Free old pixels if we were in banked mode */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
361 if (banked && current->pixels) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
362 free(current->pixels); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
363 current->pixels = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
364 } |
1554 | 365 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
366 /* Try to set the requested linear video mode */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
367 bpp = (bpp + 7) / 8 - 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
368 for (mode = 0; SDL_modelist[bpp][mode]; ++mode) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
369 if ((SDL_modelist[bpp][mode]->w == width) && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
370 (SDL_modelist[bpp][mode]->h == height)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
371 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
372 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
373 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
374 if (SDL_modelist[bpp][mode] == NULL) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
375 SDL_SetError("Couldn't find requested mode in list"); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
376 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
377 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
378 vgamode = SDL_vgamode[bpp][mode]; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
379 vga_setmode(vgamode); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
380 vga_setpage(0); |
0 | 381 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
382 if ((vga_setlinearaddressing() < 0) && (vgamode != G320x200x256)) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
383 banked = 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
384 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
385 banked = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
386 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
387 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
388 modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]); |
0 | 389 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
390 /* Update hardware acceleration info */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
391 SVGA_UpdateVideoInfo(this); |
0 | 392 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
393 /* Allocate the new pixel format for the screen */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
394 bpp = (bpp + 1) * 8; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
395 if ((bpp == 16) && (modeinfo->colors == 32768)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
396 bpp = 15; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
397 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
398 if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
399 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
400 } |
0 | 401 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
402 /* Set up the new mode framebuffer */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
403 current->flags = SDL_FULLSCREEN; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
404 if (!banked) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
405 current->flags |= SDL_HWSURFACE; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
406 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
407 if (bpp == 8) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
408 /* FIXME: What about DirectColor? */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
409 current->flags |= SDL_HWPALETTE; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
410 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
411 current->w = width; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
412 current->h = height; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
413 current->pitch = modeinfo->linewidth; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
414 if (banked) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
415 current->pixels = SDL_malloc(current->h * current->pitch); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
416 if (!current->pixels) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
417 SDL_OutOfMemory(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
418 return (NULL); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
419 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
420 } else { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
421 current->pixels = vga_getgraphmem(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
422 } |
0 | 423 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
424 /* set double-buffering */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
425 if ((flags & SDL_DOUBLEBUF) && !banked) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
426 /* length of one screen page in bytes */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
427 screenpage_len = current->h * modeinfo->linewidth; |
205
13161d3d349d
Added double-buffering support for SVGAlib (thanks Kutak!)
Sam Lantinga <slouken@libsdl.org>
parents:
67
diff
changeset
|
428 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
429 /* if start address should be aligned */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
430 if (modeinfo->linewidth_unit) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
431 if (screenpage_len % modeinfo->linewidth_unit) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
432 screenpage_len += |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
433 modeinfo->linewidth_unit - |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
434 (screenpage_len % modeinfo->linewidth_unit); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
435 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
436 } |
205
13161d3d349d
Added double-buffering support for SVGAlib (thanks Kutak!)
Sam Lantinga <slouken@libsdl.org>
parents:
67
diff
changeset
|
437 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
438 /* if we heve enough videomemory = ak je dost videopamete */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
439 if (modeinfo->memory > (screenpage_len * 2 / 1024)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
440 current->flags |= SDL_DOUBLEBUF; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
441 flip_page = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
442 flip_offset[0] = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
443 flip_offset[1] = screenpage_len; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
444 flip_address[0] = vga_getgraphmem(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
445 flip_address[1] = flip_address[0] + screenpage_len; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
446 SVGA_FlipHWSurface(this, current); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
447 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
448 } |
205
13161d3d349d
Added double-buffering support for SVGAlib (thanks Kutak!)
Sam Lantinga <slouken@libsdl.org>
parents:
67
diff
changeset
|
449 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
450 /* Set the blit function */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
451 if (banked) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
452 this->UpdateRects = SVGA_BankedUpdate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
453 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
454 this->UpdateRects = SVGA_DirectUpdate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
455 } |
0 | 456 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
457 /* Set up the mouse handler again (buggy SVGAlib 1.40) */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
458 mouse_seteventhandler(SVGA_mousecallback); |
0 | 459 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
460 /* We're done */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
461 return (current); |
0 | 462 } |
463 | |
464 /* We don't actually allow hardware surfaces other than the main one */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
465 static int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
466 SVGA_AllocHWSurface(_THIS, SDL_Surface * surface) |
0 | 467 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
468 return (-1); |
0 | 469 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
470 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
471 SVGA_FreeHWSurface(_THIS, SDL_Surface * surface) |
0 | 472 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
473 return; |
0 | 474 } |
475 | |
476 /* We need to wait for vertical retrace on page flipped displays */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
477 static int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
478 SVGA_LockHWSurface(_THIS, SDL_Surface * surface) |
0 | 479 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
480 /* The waiting is done in SVGA_FlipHWSurface() */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
481 return (0); |
0 | 482 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
483 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
484 SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface) |
0 | 485 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
486 return; |
0 | 487 } |
488 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
489 static int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
490 SVGA_FlipHWSurface(_THIS, SDL_Surface * surface) |
0 | 491 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
492 if (!banked) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
493 vga_setdisplaystart(flip_offset[flip_page]); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
494 flip_page = !flip_page; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
495 surface->pixels = flip_address[flip_page]; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
496 vga_waitretrace(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
497 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
498 return (0); |
0 | 499 } |
500 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
501 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
502 SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) |
0 | 503 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
504 return; |
0 | 505 } |
506 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
507 static void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
508 SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects) |
0 | 509 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
510 int i, j; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
511 SDL_Rect *rect; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
512 int page, vp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
513 int x, y, w, h; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
514 unsigned char *src; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
515 unsigned char *dst; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
516 int bpp = this->screen->format->BytesPerPixel; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
517 int pitch = this->screen->pitch; |
1554 | 518 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
519 dst = vga_getgraphmem(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
520 for (i = 0; i < numrects; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
521 rect = &rects[i]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
522 x = rect->x; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
523 y = rect->y; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
524 w = rect->w * bpp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
525 h = rect->h; |
1556 | 526 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
527 vp = y * pitch + x * bpp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
528 src = (unsigned char *) this->screen->pixels + vp; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
529 page = vp >> 16; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
530 vp &= 0xffff; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
531 vga_setpage(page); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
532 for (j = 0; j < h; j++) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
533 if (vp + w > 0x10000) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
534 if (vp >= 0x10000) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
535 page++; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
536 vga_setpage(page); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
537 vp &= 0xffff; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
538 } else { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
539 SDL_memcpy(dst + vp, src, 0x10000 - vp); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
540 page++; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
541 vga_setpage(page); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
542 SDL_memcpy(dst, src + 0x10000 - vp, (vp + w) & 0xffff); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
543 vp = (vp + pitch) & 0xffff; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
544 src += pitch; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
545 continue; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
546 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
547 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
548 SDL_memcpy(dst + vp, src, w); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
549 src += pitch; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
550 vp += pitch; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
551 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
552 } |
0 | 553 } |
554 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
555 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
556 SVGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
0 | 557 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
558 int i; |
0 | 559 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
560 for (i = 0; i < ncolors; i++) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
561 vga_setpalette(firstcolor + i, |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
562 colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
563 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
564 return (1); |
0 | 565 } |
566 | |
567 /* Note: If we are terminated, this could be called in the middle of | |
568 another SDL video routine -- notably UpdateRects. | |
569 */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
570 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
571 SVGA_VideoQuit(_THIS) |
0 | 572 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
573 int i, j; |
0 | 574 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
575 /* Reset the console video mode */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
576 if (this->screen && (this->screen->w && this->screen->h)) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
577 vga_setmode(TEXT); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
578 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
579 keyboard_close(); |
0 | 580 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
581 /* Free video mode lists */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
582 for (i = 0; i < NUM_MODELISTS; ++i) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
583 if (SDL_modelist[i] != NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
584 for (j = 0; SDL_modelist[i][j]; ++j) |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
585 SDL_free(SDL_modelist[i][j]); |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
586 SDL_free(SDL_modelist[i]); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
587 SDL_modelist[i] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
588 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
589 if (SDL_vgamode[i] != NULL) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
590 SDL_free(SDL_vgamode[i]); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
591 SDL_vgamode[i] = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
592 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
593 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
594 if (this->screen) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
595 if (banked && this->screen->pixels) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
596 SDL_free(this->screen->pixels); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
597 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
598 this->screen->pixels = NULL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
599 } |
0 | 600 } |
205
13161d3d349d
Added double-buffering support for SVGAlib (thanks Kutak!)
Sam Lantinga <slouken@libsdl.org>
parents:
67
diff
changeset
|
601 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1556
diff
changeset
|
602 /* vi: set ts=4 sw=4 expandtab: */ |