annotate src/video/wscons/SDL_wsconsvideo.c @ 1192:54aa9aa32327

To: sdl@libsdl.org From: Christian Walther <cwalther@gmx.ch> Date: Fri, 18 Nov 2005 23:39:02 +0100 Subject: [SDL] Mouse position bugs on Mac OS X The attached patch fixes a few bugs in SDL related to the mouse position in windowed mode on Mac OS X, reproduced using the attached minimal test program - at least here on 10.3.9, with SDL CVS from today. Could anyone test whether the bugs exist and are fixed by the patch on 10.2 and 10.4? 1. When using OpenGL, the vertical mouse positions obtained through events or SDL_GetMouseState() are off by one. 2. When using OpenGL, SDL_WarpMouse() inverts the y coordinate. 3. Clicks on the topmost pixel row of the window are not recognized. 1 and 2 do not occur in non-OpenGL mode, while 3 does. All three only occur in windowed mode, not in fullscreen. The cause for 1 and 3 is that in Cocoa, "the location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" (this is not documented, it's just what I found out here), which together with the fact that Cocoa's usual y coordinates start at the bottom and increase upwards means that the y coordinate of the mouse runs from 1 to h, not from 0 to h-1, in a window of height h. If it does work on 10.2 and 10.4 (I'll try to test it as soon as I can, but at the moment all I have at hand is 10.3.9), can this be applied to the CVS? -Christian To: sdl@libsdl.org From: Christian Walther <cwalther@gmx.ch> Date: Mon, 28 Nov 2005 10:41:51 +0100 Subject: [SDL] Re: Mouse position bugs on Mac OS X I wrote: > I'll try to test it as soon as I can, but at the moment all I have at hand is 10.3.9 So, here are the results of my tests (with patched and unpatched frameworks compiled with Xcode 1.5 (gcc 3.3) on 10.3.9): On 10.1.5, my test program doesn't run because of "Undefined symbols: SDL undefined reference to _CGMainDisplayID expected to be defined in Carbon". I guess not supporting 10.1 was a deliberate decision then and that's OK with me. On 10.2.8, 10.3.9, and 10.4.0, the bugs exist as described in my original post and are fixed by my patch. That is, there is no difference between pre/post 10.3 and the patched version works correctly in all combinations of GL/non-GL and windowed/fullscreen. I therefore recommend the patch for inclusion. -Christian
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 28 Nov 2005 13:58:26 +0000
parents 19d8949b4584
children c9b51268668f
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Library General Public License for more details.
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 static char rcsid =
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 "@(#) $Id$";
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 #endif
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <sys/time.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 #include <sys/mman.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 #include <sys/ioctl.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 #include <dev/wscons/wsdisplay_usl_io.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 #include <fcntl.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #include <unistd.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 #include <stdio.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 #include <stdlib.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 #include <string.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 #include <stdarg.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 #include <errno.h>
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 #include "SDL.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 #include "SDL_error.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 #include "SDL_video.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 #include "SDL_mouse.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 #include "SDL_sysvideo.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 #include "SDL_pixels_c.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 #include "SDL_events_c.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 #include "SDL_wsconsvideo.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 #include "SDL_wsconsevents_c.h"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 #include "SDL_wsconsmouse_c.h"
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 #define WSCONSVID_DRIVER_NAME "wscons"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 enum {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 WSCONS_ROTATE_NONE = 0,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 WSCONS_ROTATE_CCW = 90,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 WSCONS_ROTATE_UD = 180,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 WSCONS_ROTATE_CW = 270
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 #define min(a,b) ((a)<(b)?(a):(b))
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 /* Initialization/Query functions */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 static int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 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
65 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
66 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
67 static void WSCONS_VideoQuit(_THIS);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 /* Hardware surface functions */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 static int WSCONS_LockHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 static void WSCONS_FreeHWSurface(_THIS, SDL_Surface *surface);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 /* etc. */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 static WSCONS_bitBlit WSCONS_blit16;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 static WSCONS_bitBlit WSCONS_blit16blocked;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80 void WSCONS_ReportError(char *fmt, ...)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 char message[200];
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 message[199] = '\0';
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 va_list vaArgs;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 va_start(vaArgs, fmt);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 vsnprintf(message, 199, fmt, vaArgs);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89 va_end(vaArgs);
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 SDL_SetError(message);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92 fprintf(stderr, "WSCONS error: %s\n", message);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95 /* WSCONS driver bootstrap functions */
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 static int WSCONS_Available(void)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 return 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 }
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 static void WSCONS_DeleteDevice(SDL_VideoDevice *device)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 free(device->hidden);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 free(device);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 static SDL_VideoDevice *WSCONS_CreateDevice(int devindex)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 SDL_VideoDevice *device;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 /* Initialize all variables that we clean on shutdown */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 if (device == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 SDL_OutOfMemory();
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 memset(device, 0, (sizeof *device));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 device->hidden =
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 (struct SDL_PrivateVideoData *)malloc((sizeof *device->hidden));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 if (device->hidden == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 SDL_OutOfMemory();
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 free(device);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 return(0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126 memset(device->hidden, 0, (sizeof *device->hidden));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 device->hidden->fd = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 /* Set the function pointers */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 device->VideoInit = WSCONS_VideoInit;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 device->ListModes = WSCONS_ListModes;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 device->SetVideoMode = WSCONS_SetVideoMode;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 device->SetColors = WSCONS_SetColors;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 device->UpdateRects = WSCONS_UpdateRects;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 device->VideoQuit = WSCONS_VideoQuit;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 device->AllocHWSurface = WSCONS_AllocHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 device->LockHWSurface = WSCONS_LockHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138 device->UnlockHWSurface = WSCONS_UnlockHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139 device->FreeHWSurface = WSCONS_FreeHWSurface;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140 device->InitOSKeymap = WSCONS_InitOSKeymap;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 device->PumpEvents = WSCONS_PumpEvents;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 device->free = WSCONS_DeleteDevice;
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 return device;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 VideoBootStrap WSCONS_bootstrap = {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148 WSCONSVID_DRIVER_NAME,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149 "SDL wscons video driver",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 WSCONS_Available,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 WSCONS_CreateDevice
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 };
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 #define WSCONSDEV_FORMAT "/dev/ttyC%01x"
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 char devnamebuf[30];
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 char *devname;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 char *rotation;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 int wstype;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 int wsmode = WSDISPLAYIO_MODE_DUMBFB;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 size_t len, mapsize;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 int pagemask;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165 int width, height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 devname = getenv("SDL_WSCONSDEV");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 if (devname == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 int activeVT;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 if (ioctl(STDIN_FILENO, VT_GETACTIVE, &activeVT) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 WSCONS_ReportError("Unable to determine active terminal: %s",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 snprintf(devnamebuf, sizeof(devnamebuf), WSCONSDEV_FORMAT, activeVT - 1);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 devname = devnamebuf;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 private->fd = open(devname, O_RDWR | O_NONBLOCK, 0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 if (private->fd == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 WSCONS_ReportError("open %s: %s", devname, strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 if (ioctl(private->fd, WSDISPLAYIO_GINFO, &private->info) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 WSCONS_ReportError("ioctl WSDISPLAY_GINFO: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 if (ioctl(private->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 WSCONS_ReportError("ioctl WSDISPLAY_GTYPE: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 if (ioctl(private->fd, WSDISPLAYIO_LINEBYTES, &private->physlinebytes) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 WSCONS_ReportError("ioctl WSDISPLAYIO_LINEBYTES: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 if (private->info.depth > 8) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 if (wstype == WSDISPLAY_TYPE_SUN24 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 wstype == WSDISPLAY_TYPE_SUNCG12 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199 wstype == WSDISPLAY_TYPE_SUNCG14 ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200 wstype == WSDISPLAY_TYPE_SUNTCX ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 wstype == WSDISPLAY_TYPE_SUNFFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 private->redMask = 0x0000ff;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203 private->greenMask = 0x00ff00;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 private->blueMask = 0xff0000;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205 } else if (wstype == WSDISPLAY_TYPE_PXALCD) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 private->redMask = 0x1f << 11;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 private->greenMask = 0x3f << 5;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 private->blueMask = 0x1f;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 WSCONS_ReportError("Unknown video hardware");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 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
215 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218 private->rotate = WSCONS_ROTATE_NONE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219 rotation = getenv("SDL_VIDEO_WSCONS_ROTATION");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 if (rotation != NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 if (strlen(rotation) == 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222 private->shadowFB = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 private->rotate = WSCONS_ROTATE_NONE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 printf("Not rotating, no shadow\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 } else if (!strcmp(rotation, "NONE")) {
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_NONE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 printf("Not rotating, but still using shadow\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229 } else if (!strcmp(rotation, "CW")) {
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_CW;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232 printf("Rotating screen clockwise\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 } else if (!strcmp(rotation, "CCW")) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 private->rotate = WSCONS_ROTATE_CCW;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 printf("Rotating screen counter clockwise\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 } else if (!strcmp(rotation, "UD")) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 private->shadowFB = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 private->rotate = WSCONS_ROTATE_UD;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 printf("Rotating screen upside down\n");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 WSCONS_ReportError("\"%s\" is not a valid value for "
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 "SDL_VIDEO_WSCONS_ROTATION", rotation);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 switch (private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 case 1:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 case 4:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 case 8:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 case 16:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255 if (private->physlinebytes == private->info.width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 len = private->info.width * private->info.height * sizeof(short);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 if (private->rotate == WSCONS_ROTATE_NONE ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 private->rotate == WSCONS_ROTATE_UD) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 private->blitFunc = WSCONS_blit16;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 private->blitFunc = WSCONS_blit16blocked;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 case 32:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 if (private->physlinebytes == private->info.width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269 len = private->info.width * private->info.height * sizeof(int);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 len = private->physlinebytes * private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 default:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 WSCONS_ReportError("unsupported depth %d", private->info.depth);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 if (private->shadowFB && private->blitFunc == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 WSCONS_ReportError("Using software buffer, but no blitter function is "
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 "available for this %d bpp.", private->info.depth);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 WSCONS_ReportError("ioctl SMODE");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 pagemask = getpagesize() - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291 mapsize = ((int)len + pagemask) & ~pagemask;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 private->physmem = (Uint8 *)mmap(NULL, mapsize,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 PROT_READ | PROT_WRITE, MAP_SHARED,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 private->fd, (off_t)0);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 if (private->physmem == (Uint8 *)MAP_FAILED) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 private->physmem = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 WSCONS_ReportError("mmap: %s", strerror(errno));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 private->fbmem_len = len;
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 if (private->rotate == WSCONS_ROTATE_CW ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303 private->rotate == WSCONS_ROTATE_CCW) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 width = private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 height = private->info.width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 width = private->info.width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 height = private->info.height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 if (private->shadowFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 private->shadowmem = (Uint8 *)malloc(len);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 if (private->shadowmem == NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 WSCONS_ReportError("No memory for shadow");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 private->fbstart = private->shadowmem;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 private->fblinebytes = width * ((private->info.depth + 7) / 8);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 private->fbstart = private->physmem;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 private->fblinebytes = private->physlinebytes;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324 private->SDL_modelist[0] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 private->SDL_modelist[0]->w = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 private->SDL_modelist[0]->h = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328 vformat->BitsPerPixel = private->info.depth;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 vformat->BytesPerPixel = private->info.depth / 8;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331 if (WSCONS_InitKeyboard(this) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 }
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 return 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 SDL_Rect **WSCONS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
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 if (format->BitsPerPixel == private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341 return private->SDL_modelist;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 return NULL;
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 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 SDL_Surface *WSCONS_SetVideoMode(_THIS, SDL_Surface *current,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 int width, int height, int bpp, Uint32 flags)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350 if (width != private->SDL_modelist[0]->w ||
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 height != private->SDL_modelist[0]->h) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 WSCONS_ReportError("Requested video mode %dx%d not supported.",
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353 width, height);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 return NULL;
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 (bpp != private->info.depth) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 WSCONS_ReportError("Requested video depth %d bpp not supported.", bpp);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 if (!SDL_ReallocFormat(current,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362 bpp,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 private->redMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 private->greenMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365 private->blueMask,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 0)) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 WSCONS_ReportError("Couldn't allocate new pixel format");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 return NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 current->flags &= SDL_FULLSCREEN;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 if (private->shadowFB) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 current->flags |= SDL_SWSURFACE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 } else {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 current->flags |= SDL_HWSURFACE;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 current->w = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378 current->h = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 current->pitch = private->fblinebytes;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 current->pixels = private->fbstart;
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 memset(private->fbstart, 0, private->fbmem_len);
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 current;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 static int WSCONS_AllocHWSurface(_THIS, SDL_Surface *surface)
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 return -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 static void WSCONS_FreeHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 {
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 int WSCONS_LockHWSurface(_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 return 0;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 static void WSCONS_UnlockHWSurface(_THIS, SDL_Surface *surface)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 static void WSCONS_blit16(Uint8 *byte_src_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 int srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 int srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 Uint8 *byte_dst_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408 int dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409 int width,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 int height)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 int w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413 Uint16 *src_pos = (Uint16 *)byte_src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 Uint16 *dst_pos = (Uint16 *)byte_dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 while (height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417 Uint16 *src = src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 Uint16 *dst = dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419 for (w = width; w != 0; w--) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 *dst = *src;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 src += srcRightDelta;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422 dst++;
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 dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 src_pos += srcDownDelta;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426 height--;
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 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430 #define BLOCKSIZE_W 32
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 #define BLOCKSIZE_H 32
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 static void WSCONS_blit16blocked(Uint8 *byte_src_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 int srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435 int srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436 Uint8 *byte_dst_pos,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 int dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 int width,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439 int height)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441 int w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 Uint16 *src_pos = (Uint16 *)byte_src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 Uint16 *dst_pos = (Uint16 *)byte_dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 while (height > 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 Uint16 *src = src_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447 Uint16 *dst = dst_pos;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 for (w = width; w > 0; w -= BLOCKSIZE_W) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 WSCONS_blit16((Uint8 *)src,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450 srcRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451 srcDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 (Uint8 *)dst,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453 dst_linebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 min(w, BLOCKSIZE_W),
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 min(height, BLOCKSIZE_H));
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 src += srcRightDelta * BLOCKSIZE_W;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457 dst += BLOCKSIZE_W;
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 dst_pos = (Uint16 *)((Uint8 *)dst_pos + dst_linebytes * BLOCKSIZE_H);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 src_pos += srcDownDelta * BLOCKSIZE_H;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 height -= BLOCKSIZE_H;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465 static void WSCONS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
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 int width = private->SDL_modelist[0]->w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 int height = private->SDL_modelist[0]->h;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 int bytesPerPixel = (private->info.depth + 7) / 8;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470 int i;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 if (!private->shadowFB) {
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 if (private->info.depth != 16) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 WSCONS_ReportError("Shadow copy only implemented for 16 bpp");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 return;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 for (i = 0; i < numrects; i++) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 int x1, y1, x2, y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 int scr_x1, scr_y1, scr_x2, scr_y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 int sha_x1, sha_y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 int shadowRightDelta; /* Address change when moving right in dest */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486 int shadowDownDelta; /* Address change when moving down in dest */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 Uint8 *src_start;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 Uint8 *dst_start;
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 x1 = rects[i].x;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 y1 = rects[i].y;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492 x2 = x1 + rects[i].w;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 y2 = y1 + rects[i].h;
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 (x1 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 x1 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 } else if (x1 > width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 x1 = 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 (x2 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 x2 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 } else if (x2 > width) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 x2 = width;
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 (y1 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 y1 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 } else if (y1 > height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508 y1 = 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 (y2 < 0) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511 y2 = 0;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 } else if (y2 > height) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513 y2 = height;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 if (x2 <= x1 || y2 <= y1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516 continue;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
517 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 switch (private->rotate) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 case WSCONS_ROTATE_NONE:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 sha_x1 = scr_x1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 sha_y1 = scr_y1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523 scr_x2 = x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 scr_y2 = y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 shadowRightDelta = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 shadowDownDelta = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528 case WSCONS_ROTATE_CCW:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529 scr_x1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
530 scr_y1 = width - x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 scr_x2 = y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 scr_y2 = width - x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 sha_x1 = x2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 sha_y1 = y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535 shadowRightDelta = width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 shadowDownDelta = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 case WSCONS_ROTATE_UD:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 scr_x1 = width - x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 scr_y1 = height - y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 scr_x2 = width - x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 scr_y2 = height - y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 sha_x1 = x2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 sha_y1 = y2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545 shadowRightDelta = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 shadowDownDelta = -width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 case WSCONS_ROTATE_CW:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549 scr_x1 = height - y2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550 scr_y1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551 scr_x2 = height - y1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 scr_y2 = x2;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553 sha_x1 = x1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
554 sha_y1 = y2 - 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
555 shadowRightDelta = -width;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 shadowDownDelta = 1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557 break;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 default:
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559 WSCONS_ReportError("Unknown rotation");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560 return;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563 src_start = private->shadowmem + (sha_y1 * width + sha_x1) * bytesPerPixel;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564 dst_start = private->physmem + scr_y1 * private->physlinebytes +
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565 scr_x1 * bytesPerPixel;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
567 private->blitFunc(src_start,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 shadowRightDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 shadowDownDelta,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570 dst_start,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571 private->physlinebytes,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 scr_x2 - scr_x1,
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573 scr_y2 - scr_y1);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574 }
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 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
578 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 return 0;
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
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 * 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
584 * another SDL video routine -- notably UpdateRects.
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
585 */
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
586 void WSCONS_VideoQuit(_THIS)
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
587 {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 int mode = WSDISPLAYIO_MODE_EMUL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590 if (private->shadowmem != NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591 free(private->shadowmem);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592 private->shadowmem = NULL;
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 private->fbstart = NULL;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
595 if (this->screen != NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
596 this->screen->pixels = 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 (private->SDL_modelist[0] != NULL) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600 free(private->SDL_modelist[0]);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
601 private->SDL_modelist[0] = NULL;
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
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604 if (ioctl(private->fd, WSDISPLAYIO_SMODE, &mode) == -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 WSCONS_ReportError("ioctl SMODE");
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
607
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
608 WSCONS_ReleaseKeyboard(this);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610 if (private->fd != -1) {
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
611 close(private->fd);
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
612 private->fd = -1;
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
613 }
19d8949b4584 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
614 }