annotate src/video/wscons/SDL_wsconsvideo.c @ 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. SDL_SetVideoMode() now accepts 0 for width or height and will use the current video mode (or the desktop mode if no mode has been set.)
author Sam Lantinga <slouken@libsdl.org>
date Wed, 15 Mar 2006 17:46:41 +0000
parents d910939febfa
children 56f952883795
rev   line source
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1187
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1187
diff changeset
6 modify it under the terms of the GNU Lesser General Public
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1187
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1187
diff changeset
13 Lesser General Public License for more details.
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1187
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: 1187
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: 1187
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1383
diff changeset
22 #include "SDL_config.h"
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 #include <sys/time.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 #include <sys/mman.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 #include <sys/ioctl.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 #include <dev/wscons/wsdisplay_usl_io.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <fcntl.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 #include <unistd.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 #include <errno.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 #include "SDL_video.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #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
34 #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
35 #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
36 #include "../../events/SDL_events_c.h"
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 #include "SDL_wsconsvideo.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 #include "SDL_wsconsevents_c.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 #include "SDL_wsconsmouse_c.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 #define WSCONSVID_DRIVER_NAME "wscons"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 enum {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 WSCONS_ROTATE_NONE = 0,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 WSCONS_ROTATE_CCW = 90,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 WSCONS_ROTATE_UD = 180,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 WSCONS_ROTATE_CW = 270
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 };
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 #define min(a,b) ((a)<(b)?(a):(b))
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 /* Initialization/Query functions */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 static int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 static SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 static SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 static int WSCONS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 static void WSCONS_VideoQuit(_THIS);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 /* Hardware surface functions */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 static int WSCONS_LockHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 static void WSCONS_FreeHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 /* etc. */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 static WSCONS_bitBlit WSCONS_blit16;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67 static WSCONS_bitBlit WSCONS_blit16blocked;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 void WSCONS_ReportError(char *fmt, ...)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 char message[200];
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 message[199] = '\0';
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 va_list vaArgs;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 va_start(vaArgs, fmt);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 vsnprintf(message, 199, fmt, vaArgs);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79 va_end(vaArgs);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 SDL_SetError(message);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 fprintf(stderr, "WSCONS error: %s\n", message);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85 /* WSCONS driver bootstrap functions */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 static int WSCONS_Available(void)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89 return 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92 static void WSCONS_DeleteDevice(SDL_VideoDevice *device)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
94 SDL_free(device->hidden);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
95 SDL_free(device);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 static SDL_VideoDevice *WSCONS_CreateDevice(int devindex)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 SDL_VideoDevice *device;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 /* Initialize all variables that we clean on shutdown */
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
103 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 if (device == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 SDL_OutOfMemory();
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
108 SDL_memset(device, 0, (sizeof *device));
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 device->hidden =
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
110 (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden));
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111 if (device->hidden == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 SDL_OutOfMemory();
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
113 SDL_free(device);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 return(0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
116 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 device->hidden->fd = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 /* Set the function pointers */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 device->VideoInit = WSCONS_VideoInit;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 device->ListModes = WSCONS_ListModes;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 device->SetVideoMode = WSCONS_SetVideoMode;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 device->SetColors = WSCONS_SetColors;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 device->UpdateRects = WSCONS_UpdateRects;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 device->VideoQuit = WSCONS_VideoQuit;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126 device->AllocHWSurface = WSCONS_AllocHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 device->LockHWSurface = WSCONS_LockHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 device->UnlockHWSurface = WSCONS_UnlockHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 device->FreeHWSurface = WSCONS_FreeHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 device->InitOSKeymap = WSCONS_InitOSKeymap;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 device->PumpEvents = WSCONS_PumpEvents;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 device->free = WSCONS_DeleteDevice;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 return device;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 VideoBootStrap WSCONS_bootstrap = {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138 WSCONSVID_DRIVER_NAME,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139 "SDL wscons video driver",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 WSCONS_Available,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 WSCONS_CreateDevice
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 };
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 #define WSCONSDEV_FORMAT "/dev/ttyC%01x"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 char devnamebuf[30];
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 char *devname;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 char *rotation;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 int wstype;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 int wsmode = WSDISPLAYIO_MODE_DUMBFB;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 size_t len, mapsize;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 int pagemask;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 int width, height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
157 devname = SDL_getenv("SDL_WSCONSDEV");
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 if (devname == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 int activeVT;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 WSCONS_ReportError("Unable to determine active terminal: %s",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
165 SDL_snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 devname = devnamebuf;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 private->fd = open(devname, O_RDWR | O_NONBLOCK, 0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 if (private->fd == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 WSCONS_ReportError("open %s: %s", devname, strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 if (ioctl(private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 WSCONS_ReportError("ioctl WSDISPLAY_GINFO: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 if (ioctl(private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 WSCONS_ReportError("ioctl WSDISPLAY_GTYPE: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182 if (ioctl(private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 WSCONS_ReportError("ioctl WSDISPLAYIO_LINEBYTES: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 if (private->info.depth > 8) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 if (wstype == WSDISPLAY_TYPE_SUN24 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 wstype == WSDISPLAY_TYPE_SUNCG12 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 wstype == WSDISPLAY_TYPE_SUNCG14 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190 wstype == WSDISPLAY_TYPE_SUNTCX ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191 wstype == WSDISPLAY_TYPE_SUNFFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 private->redMask = 0x0000ff;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 private->greenMask = 0x00ff00;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 private->blueMask = 0xff0000;
1383
1736c5e2173f NetBSD support
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
195 #ifdef WSDISPLAY_TYPE_PXALCD
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 } else if (wstype == WSDISPLAY_TYPE_PXALCD) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 private->redMask = 0x1f << 11;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 private->greenMask = 0x3f << 5;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 private->blueMask = 0x1f;
1383
1736c5e2173f NetBSD support
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
200 #endif
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 WSCONS_ReportError("Unknown video hardware");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 WSCONS_ReportError("Displays with 8 bpp or less are not supported");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 private->rotate = WSCONS_ROTATE_NONE;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
211 rotation = SDL_getenv("SDL_VIDEO_WSCONS_ROTATION");
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 if (rotation != NULL) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
213 if (SDL_strlen(rotation) == 0) {
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 private->shadowFB = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
215 private->rotate = WSCONS_ROTATE_NONE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 printf("Not rotating, no shadow\n");
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
217 } else if (!SDL_strcmp(rotation, "NONE")) {
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219 private->rotate = WSCONS_ROTATE_NONE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 printf("Not rotating, but still using shadow\n");
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
221 } else if (!SDL_strcmp(rotation, "CW")) {
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 private->rotate = WSCONS_ROTATE_CW;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 printf("Rotating screen clockwise\n");
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
225 } else if (!SDL_strcmp(rotation, "CCW")) {
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227 private->rotate = WSCONS_ROTATE_CCW;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 printf("Rotating screen counter clockwise\n");
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
229 } else if (!SDL_strcmp(rotation, "UD")) {
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 private->rotate = WSCONS_ROTATE_UD;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 printf("Rotating screen upside down\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 WSCONS_ReportError("\"%s\" is not a valid value for "
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 "SDL_VIDEO_WSCONS_ROTATION", rotation);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 switch (private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 case 1:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 case 4:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 case 8:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 case 16:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 if (private->physlinebytes == private->info.width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 len = private->info.width * private->info.height * sizeof(short);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 if (private->rotate == WSCONS_ROTATE_NONE ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 private->rotate == WSCONS_ROTATE_UD) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 private->blitFunc = WSCONS_blit16;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 private->blitFunc = WSCONS_blit16blocked;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 case 32:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 if (private->physlinebytes == private->info.width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 len = private->info.width * private->info.height * sizeof(int);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266 default:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 WSCONS_ReportError("unsupported depth %d", private->info.depth);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 if (private->shadowFB && private->blitFunc == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 WSCONS_ReportError("Using software buffer, but no blitter function is "
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 "available for this %d bpp.", private->info.depth);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278 WSCONS_ReportError("ioctl SMODE");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 pagemask = getpagesize() - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 mapsize = ((int)len + pagemask) & ~pagemask;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 private->physmem = (Uint8 *)mmap(NULL, mapsize,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 PROT_READ | PROT_WRITE, MAP_SHARED,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 private->fd, (off_t)0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 if (private->physmem == (Uint8 *)MAP_FAILED) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 private->physmem = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 WSCONS_ReportError("mmap: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 private->fbmem_len = len;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 if (private->rotate == WSCONS_ROTATE_CW ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 private->rotate == WSCONS_ROTATE_CCW) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 width = private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 height = private->info.width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 width = private->info.width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 height = private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302
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
303 this->info.current_w = width;
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
304 this->info.current_h = height;
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
305
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 if (private->shadowFB) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
307 private->shadowmem = (Uint8 *)SDL_malloc(len);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 if (private->shadowmem == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 WSCONS_ReportError("No memory for shadow");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 private->fbstart = private->shadowmem;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 private->fblinebytes = width * ((private->info.depth + 7) / 8);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 private->fbstart = private->physmem;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 private->fblinebytes = private->physlinebytes;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
319 private->SDL_modelist[0] = (SDL_Rect *)SDL_malloc(sizeof(SDL_Rect));
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 private->SDL_modelist[0]->w = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 private->SDL_modelist[0]->h = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 vformat->BitsPerPixel = private->info.depth;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324 vformat->BytesPerPixel = private->info.depth / 8;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 if (WSCONS_InitKeyboard(this) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 if (format->BitsPerPixel == private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 return private->SDL_modelist;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface *current,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 int width, int height, int bpp, Uint32 flags)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
345 if (width != private->SDL_modelist[0]->w ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346 height != private->SDL_modelist[0]->h) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 WSCONS_ReportError("Requested video mode %dx%d not supported.",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 width, height);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 if (bpp != private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 WSCONS_ReportError("Requested video depth %d bpp not supported.", bpp);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356 if (!SDL_ReallocFormat(current,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 bpp,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 private->redMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359 private->greenMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360 private->blueMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 0)) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362 WSCONS_ReportError("Couldn't allocate new pixel format");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 current->flags &= SDL_FULLSCREEN;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 if (private->shadowFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 current->flags |= SDL_SWSURFACE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 current->flags |= SDL_HWSURFACE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 current->w = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 current->h = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 current->pitch = private->fblinebytes;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 current->pixels = private->fbstart;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
377 SDL_memset(private->fbstart, 0, private->fbmem_len);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 return current;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386 static void WSCONS_FreeHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 static int WSCONS_LockHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399 static void WSCONS_blit16(Uint8 *byte_src_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 int srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 int srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 Uint8 *byte_dst_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 int dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 int width,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 int height)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 int w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 Uint16 *src_pos = (Uint16 *)byte_src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409 Uint16 *dst_pos = (Uint16 *)byte_dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 while (height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 Uint16 *src = src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413 Uint16 *dst = dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 for (w = width; w != 0; w--) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415 *dst = *src;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 src += srcRightDelta;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 dst++;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419 dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 src_pos += srcDownDelta;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 height--;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 #define BLOCKSIZE_W 32
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426 #define BLOCKSIZE_H 32
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
427
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 static void WSCONS_blit16blocked(Uint8 *byte_src_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 int srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430 int srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 Uint8 *byte_dst_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432 int dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 int width,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 int height)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436 int w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 Uint16 *src_pos = (Uint16 *)byte_src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 Uint16 *dst_pos = (Uint16 *)byte_dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 while (height > 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441 Uint16 *src = src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 Uint16 *dst = dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 for (w = width; w > 0; w -= BLOCKSIZE_W) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444 WSCONS_blit16((Uint8 *)src,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447 (Uint8 *)dst,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 min(w, BLOCKSIZE_W),
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450 min(height, BLOCKSIZE_H));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451 src += srcRightDelta * BLOCKSIZE_W;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 dst += BLOCKSIZE_W;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes * BLOCKSIZE_H);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 src_pos += srcDownDelta * BLOCKSIZE_H;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 height -= BLOCKSIZE_H;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 int width = private->SDL_modelist[0]->w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463 int height = private->SDL_modelist[0]->h;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464 int bytesPerPixel = (private->info.depth + 7) / 8;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465 int i;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
466
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
467 if (!private->shadowFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 return;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471 if (private->info.depth != 16) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 WSCONS_ReportError("Shadow copy only implemented for 16 bpp");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
473 return;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
475
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476 for (i = 0; i < numrects; i++) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 int x1, y1, x2, y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 int scr_x1, scr_y1, scr_x2, scr_y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 int sha_x1, sha_y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 int shadowRightDelta; /* Address change when moving right in dest */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 int shadowDownDelta; /* Address change when moving down in dest */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 Uint8 *src_start;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 Uint8 *dst_start;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 x1 = rects[i].x;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486 y1 = rects[i].y;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 x2 = x1 + rects[i].w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 y2 = y1 + rects[i].h;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 if (x1 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 x1 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492 } else if (x1 > width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 x1 = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 if (x2 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 x2 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 } else if (x2 > width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 x2 = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 if (y1 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 y1 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 } else if (y1 > height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 y1 = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 if (y2 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 y2 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 } else if (y2 > height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508 y2 = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 if (x2 <= x1 || y2 <= y1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511 continue;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 switch (private->rotate) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 case WSCONS_ROTATE_NONE:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516 sha_x1 = scr_x1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
517 sha_y1 = scr_y1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518 scr_x2 = x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 scr_y2 = y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 shadowRightDelta = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 shadowDownDelta = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523 case WSCONS_ROTATE_CCW:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 scr_x1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 scr_y1 = width - x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 scr_x2 = y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 scr_y2 = width - x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528 sha_x1 = x2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529 sha_y1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
530 shadowRightDelta = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 shadowDownDelta = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 case WSCONS_ROTATE_UD:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 scr_x1 = width - x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535 scr_y1 = height - y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 scr_x2 = width - x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 scr_y2 = height - y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 sha_x1 = x2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 sha_y1 = y2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 shadowRightDelta = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 shadowDownDelta = -width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 case WSCONS_ROTATE_CW:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 scr_x1 = height - y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 scr_y1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 scr_x2 = height - y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 scr_y2 = x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 sha_x1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549 sha_y1 = y2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550 shadowRightDelta = -width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551 shadowDownDelta = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553 default:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
554 WSCONS_ReportError("Unknown rotation");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
555 return;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 src_start = private->shadowmem + (sha_y1 * width + sha_x1) * bytesPerPixel;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559 dst_start = private->physmem + scr_y1 * private->physlinebytes +
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560 scr_x1 * bytesPerPixel;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562 private->blitFunc(src_start,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563 shadowRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564 shadowDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565 dst_start,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566 private->physlinebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
567 scr_x2 - scr_x1,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 scr_y2 - scr_y1);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 int WSCONS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577 /*
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578 * Note: If we are terminated, this could be called in the middle of
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 * another SDL video routine -- notably UpdateRects.
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580 */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
581 void WSCONS_VideoQuit(_THIS)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
582 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
583 int mode = WSDISPLAYIO_MODE_EMUL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
584
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
585 if (private->shadowmem != NULL) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
586 SDL_free(private->shadowmem);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
587 private->shadowmem = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589 private->fbstart = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590 if (this->screen != NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591 this->screen->pixels = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
593
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
594 if (private->SDL_modelist[0] != NULL) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
595 SDL_free(private->SDL_modelist[0]);
1187
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
596 private->SDL_modelist[0] = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
597 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
598
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
599 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600 WSCONS_ReportError("ioctl SMODE");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
601 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
602
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
603 WSCONS_ReleaseKeyboard(this);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 if (private->fd != -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606 close(private->fd);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
607 private->fd = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
608 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609 }