Mercurial > sdl-ios-xcode
annotate src/video/ps2gs/SDL_gsvideo.c @ 1312:c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
I batch edited these files, so please let me know if I've accidentally removed anybody's
credit here.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 01 Feb 2006 06:32:25 +0000 |
parents | e8157fcb3114 |
children | 3692456e7b0f |
rev | line source |
---|---|
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 /* |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
4 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
9 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
13 Lesser General Public License for more details. |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
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:
252
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:
252
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
18 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
19 Sam Lantinga |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
20 slouken@libsdl.org |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
21 */ |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
22 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
23 /* Framebuffer console based SDL video driver implementation. |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
24 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
25 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 #include <stdlib.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
27 #include <stdio.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
28 #include <fcntl.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
29 #include <unistd.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
30 #include <sys/ioctl.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
31 #include <sys/mman.h> |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
32 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
33 #include "SDL.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
34 #include "SDL_error.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
35 #include "SDL_video.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
36 #include "SDL_mouse.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
37 #include "SDL_sysvideo.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
38 #include "SDL_pixels_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
39 #include "SDL_events_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
40 #include "SDL_cursor_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
41 #include "SDL_gsvideo.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
42 #include "SDL_gsmouse_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
43 #include "SDL_gsevents_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
44 #include "SDL_gsyuv_c.h" |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
45 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
46 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
47 /* Initialization/Query functions */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
48 static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
49 static SDL_Rect **GS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
50 static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
51 static int GS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
52 static void GS_VideoQuit(_THIS); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
53 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
54 /* Hardware surface functions */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
55 static int GS_AllocHWSurface(_THIS, SDL_Surface *surface); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
56 static int GS_LockHWSurface(_THIS, SDL_Surface *surface); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
57 static void GS_UnlockHWSurface(_THIS, SDL_Surface *surface); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
58 static void GS_FreeHWSurface(_THIS, SDL_Surface *surface); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
59 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
60 /* GS driver bootstrap functions */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
61 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
62 static int GS_Available(void) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
63 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
64 int console, memory; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
65 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
66 console = open(PS2_DEV_GS, O_RDWR, 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
67 if ( console >= 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
68 close(console); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
69 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
70 memory = open(PS2_DEV_MEM, O_RDWR, 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
71 if ( memory >= 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
72 close(memory); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
73 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
74 return((console >= 0) && (memory >= 0)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
75 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
76 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
77 static void GS_DeleteDevice(SDL_VideoDevice *device) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
78 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
79 free(device->hidden); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
80 free(device); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
81 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
82 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
83 static SDL_VideoDevice *GS_CreateDevice(int devindex) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
84 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
85 SDL_VideoDevice *this; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
86 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
87 /* Initialize all variables that we clean on shutdown */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
88 this = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
89 if ( this ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
90 memset(this, 0, (sizeof *this)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
91 this->hidden = (struct SDL_PrivateVideoData *) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
92 malloc((sizeof *this->hidden)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
93 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
94 if ( (this == NULL) || (this->hidden == NULL) ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
95 SDL_OutOfMemory(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
96 if ( this ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
97 free(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
98 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
99 return(0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
100 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
101 memset(this->hidden, 0, (sizeof *this->hidden)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
102 mouse_fd = -1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
103 keyboard_fd = -1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
104 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
105 /* Set the function pointers */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
106 this->VideoInit = GS_VideoInit; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
107 this->ListModes = GS_ListModes; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
108 this->SetVideoMode = GS_SetVideoMode; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
109 this->CreateYUVOverlay = GS_CreateYUVOverlay; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
110 this->SetColors = GS_SetColors; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
111 this->UpdateRects = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
112 this->VideoQuit = GS_VideoQuit; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
113 this->AllocHWSurface = GS_AllocHWSurface; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
114 this->CheckHWBlit = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
115 this->FillHWRect = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
116 this->SetHWColorKey = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
117 this->SetHWAlpha = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
118 this->LockHWSurface = GS_LockHWSurface; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
119 this->UnlockHWSurface = GS_UnlockHWSurface; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
120 this->FlipHWSurface = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
121 this->FreeHWSurface = GS_FreeHWSurface; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
122 this->SetIcon = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
123 this->SetCaption = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
124 this->GetWMInfo = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
125 this->FreeWMCursor = GS_FreeWMCursor; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
126 this->CreateWMCursor = GS_CreateWMCursor; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
127 this->ShowWMCursor = GS_ShowWMCursor; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
128 this->MoveWMCursor = GS_MoveWMCursor; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
129 this->InitOSKeymap = GS_InitOSKeymap; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
130 this->PumpEvents = GS_PumpEvents; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
131 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
132 this->free = GS_DeleteDevice; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
133 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
134 return this; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
135 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
136 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
137 VideoBootStrap PS2GS_bootstrap = { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
138 "ps2gs", "PlayStation 2 Graphics Synthesizer", |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
139 GS_Available, GS_CreateDevice |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
140 }; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
141 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
142 /* These are the pixel formats for the 32, 24, and 16 bit video modes */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
143 static struct { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
144 int bpp; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
145 Uint32 r; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
146 Uint32 g; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
147 Uint32 b; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
148 } GS_pixelmasks[] = { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
149 { 32, 0x000000FF, /* RGB little-endian */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
150 0x0000FF00, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
151 0x00FF0000 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
152 { 24, 0x000000FF, /* RGB little-endian */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
153 0x0000FF00, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
154 0x00FF0000 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
155 { 16, 0x0000001f, /* RGB little-endian */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
156 0x000003e0, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
157 0x00007c00 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
158 }; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
159 /* This is a mapping from SDL bytes-per-pixel to GS pixel format */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
160 static int GS_formatmap[] = { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
161 -1, /* 0 bpp, not a legal value */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
162 -1, /* 8 bpp, not supported (yet?) */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
163 PS2_GS_PSMCT16, /* 16 bpp */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
164 PS2_GS_PSMCT24, /* 24 bpp */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
165 PS2_GS_PSMCT32 /* 32 bpp */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
166 }; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
167 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
168 static unsigned long long head_tags[] __attribute__((aligned(16))) = { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
169 4 | (1LL << 60), /* GIFtag */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
170 0x0e, /* A+D */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
171 0, /* 2 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
172 PS2_GS_BITBLTBUF, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
173 0, /* 4 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
174 PS2_GS_TRXPOS, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
175 0, /* 6 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
176 PS2_GS_TRXREG, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
177 0, /* 8 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
178 PS2_GS_TRXDIR |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
179 }; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
180 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
181 #define MAXIMG (32767 * 16) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
182 #define MAXTAGS 8 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
183 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
184 static inline int loadimage_nonblock(int fd, struct ps2_image *image, int size, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
185 unsigned long long *hm, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
186 unsigned long long *im) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
187 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
188 struct ps2_plist plist; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
189 struct ps2_packet packet[1 + MAXTAGS * 2]; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
190 int isize; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
191 int pnum, it, eop; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
192 char *data; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
193 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
194 /* initialize the variables */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
195 data = (char *)image->ptr; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
196 pnum = it = eop = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
197 plist.packet = packet; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
198 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
199 /* make BITBLT packet */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
200 packet[pnum].ptr = hm; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
201 packet[pnum].len = sizeof(head_tags); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
202 pnum++; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
203 hm[2] = ((unsigned long long)image->fbp << 32) | |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
204 ((unsigned long long)image->fbw << 48) | |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
205 ((unsigned long long)image->psm << 56); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
206 hm[4] = ((unsigned long long)image->x << 32) | |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
207 ((unsigned long long)image->y << 48); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
208 hm[6] = (unsigned long long)image->w | |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
209 ((unsigned long long)image->h << 32); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
210 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
211 /* make image mode tags */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
212 while (!eop) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
213 isize = size > MAXIMG ? MAXIMG : size; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
214 size -= isize; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
215 eop = (size == 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
216 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
217 packet[pnum].ptr = &im[it]; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
218 packet[pnum].len = sizeof(unsigned long long) * 2; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
219 pnum++; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
220 im[it++] = (isize >> 4) | (eop ? (1 << 15) : 0) | (2LL << 58); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
221 im[it++] = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
222 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
223 packet[pnum].ptr = (void *)data; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
224 packet[pnum].len = isize; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
225 pnum++; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
226 data += isize; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
227 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
228 plist.num = pnum; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
229 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
230 return ioctl(fd, PS2IOC_SENDL, &plist); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
231 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
232 |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
233 static unsigned long long tex_tags[] __attribute__((aligned(16))) = { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
234 3 | (1LL << 60), /* GIFtag */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
235 0x0e, /* A+D */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
236 0, /* 2 */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
237 PS2_GS_TEX0_1, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
238 (1 << 5) + (1 << 6), |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
239 PS2_GS_TEX1_1, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
240 0, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
241 PS2_GS_TEXFLUSH |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
242 }; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
243 static unsigned long long scale_tags[] __attribute__((aligned(16))) = { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
244 5 | (1LL << 60), /* GIFtag */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
245 0x0e, /* A+D */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
246 6 + (1 << 4) + (1 << 8), |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
247 PS2_GS_PRIM, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
248 ((unsigned long long)0 * 16) + (((unsigned long long)0 * 16) << 16), |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
249 PS2_GS_UV, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
250 ((unsigned long long)0 * 16) + (((unsigned long long)0 * 16) << 16), |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
251 PS2_GS_XYZ2, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
252 0, /* 8 */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
253 PS2_GS_UV, |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
254 0, /* 10 */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
255 PS2_GS_XYZ2 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
256 }; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
257 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
258 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
259 int scaleimage_nonblock(int fd, unsigned long long *tm, unsigned long long *sm) |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
260 { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
261 struct ps2_plist plist; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
262 struct ps2_packet packet[2]; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
263 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
264 /* initialize the variables */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
265 plist.num = 2; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
266 plist.packet = packet; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
267 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
268 packet[0].ptr = tm; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
269 packet[0].len = sizeof(tex_tags); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
270 packet[1].ptr = sm; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
271 packet[1].len = sizeof(scale_tags); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
272 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
273 return ioctl(fd, PS2IOC_SENDL, &plist); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
274 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
275 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
276 static int power_of_2(int value) |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
277 { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
278 int shift; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
279 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
280 for ( shift = 0; (1<<shift) < value; ++shift ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
281 /* Keep looking */ ; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
282 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
283 return(shift); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
284 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
285 |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
286 static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
287 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
288 struct ps2_screeninfo vinfo; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
289 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
290 /* Initialize the library */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
291 console_fd = open(PS2_DEV_GS, O_RDWR, 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
292 if ( console_fd < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
293 SDL_SetError("Unable to open %s", PS2_DEV_GS); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
294 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
295 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
296 memory_fd = open(PS2_DEV_MEM, O_RDWR, 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
297 if ( memory_fd < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
298 close(console_fd); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
299 console_fd = -1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
300 SDL_SetError("Unable to open %s", PS2_DEV_MEM); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
301 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
302 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
303 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
304 /* Determine the current screen depth */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
305 if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
306 close(memory_fd); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
307 close(console_fd); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
308 console_fd = -1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
309 SDL_SetError("Couldn't get console pixel format"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
310 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
311 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
312 switch (vinfo.psm) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
313 /* Supported pixel formats */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
314 case PS2_GS_PSMCT32: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
315 case PS2_GS_PSMCT24: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
316 case PS2_GS_PSMCT16: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
317 break; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
318 default: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
319 GS_VideoQuit(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
320 SDL_SetError("Unknown console pixel format: %d", vinfo.psm); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
321 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
322 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
323 vformat->BitsPerPixel = GS_pixelmasks[vinfo.psm].bpp; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
324 vformat->Rmask = GS_pixelmasks[vinfo.psm].r; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
325 vformat->Gmask = GS_pixelmasks[vinfo.psm].g; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
326 vformat->Bmask = GS_pixelmasks[vinfo.psm].b; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
327 saved_vinfo = vinfo; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
328 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
329 /* Enable mouse and keyboard support */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
330 if ( GS_OpenKeyboard(this) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
331 GS_VideoQuit(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
332 SDL_SetError("Unable to open keyboard"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
333 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
334 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
335 if ( GS_OpenMouse(this) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
336 const char *sdl_nomouse; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
337 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
338 sdl_nomouse = getenv("SDL_NOMOUSE"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
339 if ( ! sdl_nomouse ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
340 GS_VideoQuit(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
341 SDL_SetError("Unable to open mouse"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
342 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
343 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
344 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
345 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
346 /* We're done! */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
347 return(0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
348 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
349 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
350 static SDL_Rect **GS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
351 { |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
352 static SDL_Rect GS_vesa_mode_list[] = { |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
353 { 0, 0, 1280, 1024 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
354 { 0, 0, 1024, 768 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
355 { 0, 0, 800, 600 }, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
356 { 0, 0, 640, 480 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
357 }; |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
358 static SDL_Rect *GS_vesa_modes[] = { |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
359 &GS_vesa_mode_list[0], |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
360 &GS_vesa_mode_list[1], |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
361 &GS_vesa_mode_list[2], |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
362 &GS_vesa_mode_list[3], |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
363 NULL |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
364 }; |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
365 static SDL_Rect GS_tvout_stretch; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
366 static SDL_Rect GS_tvout_mode; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
367 static SDL_Rect *GS_tvout_modes[3]; |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
368 SDL_Rect **modes = NULL; |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
369 |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
370 switch (format->BitsPerPixel) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
371 case 16: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
372 case 24: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
373 case 32: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
374 if ( saved_vinfo.mode == PS2_GS_VESA ) { |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
375 modes = GS_vesa_modes; |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
376 } else { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
377 int i, j = 0; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
378 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
379 // FIXME - what's wrong with the stretch code at 16 bpp? |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
380 if ( format->BitsPerPixel != 32 ) break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
381 /* Add a mode that we could possibly stretch to */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
382 for ( i=0; GS_vesa_modes[i]; ++i ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
383 if ( (GS_vesa_modes[i]->w == saved_vinfo.w) && |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
384 (GS_vesa_modes[i]->h != saved_vinfo.h) ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
385 GS_tvout_stretch.w=GS_vesa_modes[i]->w; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
386 GS_tvout_stretch.h=GS_vesa_modes[i]->h; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
387 GS_tvout_modes[j++] = &GS_tvout_stretch; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
388 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
389 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
390 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
391 /* Add the current TV video mode */ |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
392 GS_tvout_mode.w = saved_vinfo.w; |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
393 GS_tvout_mode.h = saved_vinfo.h; |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
394 GS_tvout_modes[j++] = &GS_tvout_mode; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
395 GS_tvout_modes[j++] = NULL; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
396 |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
397 /* Return the created list of modes */ |
135
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
398 modes = GS_tvout_modes; |
0bfcf0d2b874
Added initial support for TV output modes
Sam Lantinga <slouken@libsdl.org>
parents:
70
diff
changeset
|
399 } |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
400 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
401 default: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
402 break; |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
403 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
404 return(modes); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
405 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
406 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
407 /* Various screen update functions available */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
408 static void GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect *rects); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
409 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
410 static SDL_Surface *GS_SetVideoMode(_THIS, SDL_Surface *current, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
411 int width, int height, int bpp, Uint32 flags) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
412 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
413 struct ps2_screeninfo vinfo; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
414 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
415 /* Set the terminal into graphics mode */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
416 if ( GS_EnterGraphicsMode(this) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
417 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
418 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
419 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
420 /* Set the video mode and get the final screen format */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
421 if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
422 SDL_SetError("Couldn't get console screen info"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
423 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
424 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
425 if ( (vinfo.w != width) || (vinfo.h != height) || |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
426 (GS_pixelmasks[vinfo.psm].bpp != bpp) ) { |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
427 /* If we're not in VESA mode, we have to scale resolution */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
428 if ( saved_vinfo.mode == PS2_GS_VESA ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
429 switch (width) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
430 case 640: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
431 vinfo.res = PS2_GS_640x480; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
432 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
433 case 800: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
434 vinfo.res = PS2_GS_800x600; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
435 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
436 case 1024: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
437 vinfo.res = PS2_GS_1024x768; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
438 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
439 case 1280: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
440 vinfo.res = PS2_GS_1280x1024; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
441 break; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
442 default: |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
443 SDL_SetError("Unsupported resolution: %dx%d\n", |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
444 width, height); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
445 return(NULL); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
446 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
447 vinfo.res |= (PS2_GS_75Hz << 8); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
448 vinfo.w = width; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
449 vinfo.h = height; |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
450 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
451 vinfo.fbp = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
452 vinfo.psm = GS_formatmap[bpp/8]; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
453 if ( vinfo.psm < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
454 SDL_SetError("Unsupported depth: %d bpp\n", bpp); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
455 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
456 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
457 if ( ioctl(console_fd, PS2IOC_SSCREENINFO, &vinfo) < 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
458 SDL_SetError("Couldn't set console screen info"); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
459 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
460 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
461 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
462 /* Unmap the previous DMA buffer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
463 if ( mapped_mem ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
464 munmap(mapped_mem, mapped_len); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
465 mapped_mem = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
466 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
467 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
468 if ( ! SDL_ReallocFormat(current, GS_pixelmasks[vinfo.psm].bpp, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
469 GS_pixelmasks[vinfo.psm].r, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
470 GS_pixelmasks[vinfo.psm].g, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
471 GS_pixelmasks[vinfo.psm].b, 0) ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
472 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
473 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
474 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
475 /* Set up the new mode framebuffer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
476 current->flags = SDL_FULLSCREEN; |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
477 current->w = width; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
478 current->h = height; |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
479 current->pitch = SDL_CalculatePitch(current); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
480 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
481 /* Memory map the DMA area for block memory transfer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
482 if ( ! mapped_mem ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
483 pixels_len = height * current->pitch; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
484 mapped_len = pixels_len + |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
485 /* Screen update DMA command area */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
486 sizeof(head_tags) + ((2 * MAXTAGS) * 16); |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
487 if ( saved_vinfo.mode != PS2_GS_VESA ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
488 mapped_len += sizeof(tex_tags) + sizeof(scale_tags); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
489 } |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
490 mapped_mem = mmap(0, mapped_len, PROT_READ|PROT_WRITE, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
491 MAP_SHARED, memory_fd, 0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
492 if ( mapped_mem == MAP_FAILED ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
493 SDL_SetError("Unable to map %d bytes for DMA", |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
494 mapped_len); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
495 mapped_mem = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
496 return(NULL); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
497 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
498 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
499 /* Set up the entire screen for DMA transfer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
500 screen_image.ptr = mapped_mem; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
501 screen_image.fbp = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
502 screen_image.fbw = (vinfo.w + 63) / 64; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
503 screen_image.psm = vinfo.psm; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
504 screen_image.x = 0; |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
505 if ( vinfo.h == height ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
506 screen_image.y = 0; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
507 } else { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
508 /* Put image offscreen and scale to screen height */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
509 screen_image.y = vinfo.h; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
510 } |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
511 screen_image.w = current->w; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
512 screen_image.h = current->h; |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
513 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
514 /* get screen image data size (qword aligned) */ |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
515 screen_image_size = (screen_image.w * screen_image.h); |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
516 switch (screen_image.psm) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
517 case PS2_GS_PSMCT32: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
518 screen_image_size *= 4; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
519 break; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
520 case PS2_GS_PSMCT24: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
521 screen_image_size *= 3; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
522 break; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
523 case PS2_GS_PSMCT16: |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
524 screen_image_size *= 2; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
525 break; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
526 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
527 screen_image_size = (screen_image_size + 15) & ~15; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
528 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
529 /* Set up the memory for screen update DMA commands */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
530 head_tags_mem = (unsigned long long *) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
531 (mapped_mem + pixels_len); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
532 image_tags_mem = (unsigned long long *) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
533 ((caddr_t)head_tags_mem + sizeof(head_tags)); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
534 memcpy(head_tags_mem, head_tags, sizeof(head_tags)); |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
535 if ( saved_vinfo.mode != PS2_GS_VESA ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
536 tex_tags_mem = (unsigned long long *) |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
537 ((caddr_t)image_tags_mem + ((2*MAXTAGS)*16)); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
538 scale_tags_mem = (unsigned long long *) |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
539 ((caddr_t)tex_tags_mem + sizeof(tex_tags)); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
540 memcpy(tex_tags_mem, tex_tags, sizeof(tex_tags)); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
541 tex_tags_mem[2] = |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
542 (vinfo.h * vinfo.w) / 64 + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
543 ((unsigned long long)screen_image.fbw << 14) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
544 ((unsigned long long)screen_image.psm << 20) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
545 ((unsigned long long)power_of_2(screen_image.w) << 26) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
546 ((unsigned long long)power_of_2(screen_image.h) << 30) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
547 ((unsigned long long)1 << 34) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
548 ((unsigned long long)1 << 35); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
549 memcpy(scale_tags_mem, scale_tags, sizeof(scale_tags)); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
550 scale_tags_mem[8] = |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
551 ((unsigned long long)screen_image.w * 16) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
552 (((unsigned long long)screen_image.h * 16) << 16); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
553 scale_tags_mem[10] = |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
554 ((unsigned long long)vinfo.w * 16) + |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
555 (((unsigned long long)vinfo.h * 16) << 16); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
556 } |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
557 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
558 current->pixels = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
559 if ( getenv("SDL_FULLSCREEN_UPDATE") ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
560 /* Correct semantics */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
561 current->flags |= SDL_ASYNCBLIT; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
562 } else { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
563 /* We lie here - the screen memory isn't really the visible |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
564 display memory and still requires an update, but this |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
565 has the desired effect for most applications. |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
566 */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
567 current->flags |= SDL_HWSURFACE; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
568 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
569 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
570 /* Set the update rectangle function */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
571 this->UpdateRects = GS_DMAFullUpdate; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
572 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
573 /* We're done */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
574 return(current); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
575 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
576 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
577 /* We don't support hardware surfaces yet */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
578 static int GS_AllocHWSurface(_THIS, SDL_Surface *surface) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
579 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
580 return(-1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
581 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
582 static void GS_FreeHWSurface(_THIS, SDL_Surface *surface) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
583 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
584 return; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
585 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
586 static int GS_LockHWSurface(_THIS, SDL_Surface *surface) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
587 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
588 if ( surface == this->screen ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
589 /* Since mouse motion affects 'pixels', lock it */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
590 SDL_LockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
591 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
592 /* Make sure any pending DMA has completed */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
593 if ( dma_pending ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
594 ioctl(console_fd, PS2IOC_SENDQCT, 1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
595 dma_pending = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
596 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
597 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
598 /* If the cursor is drawn on the DMA area, remove it */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
599 if ( cursor_drawn ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
600 surface->pixels = mapped_mem + surface->offset; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
601 SDL_EraseCursorNoLock(this->screen); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
602 cursor_drawn = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
603 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
604 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
605 /* Set the surface pixels to the base of the DMA area */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
606 surface->pixels = mapped_mem; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
607 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
608 /* We're finished! */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
609 SDL_UnlockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
610 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
611 return(0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
612 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
613 static void GS_UnlockHWSurface(_THIS, SDL_Surface *surface) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
614 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
615 if ( surface == this->screen ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
616 /* Since mouse motion affects 'pixels', lock it */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
617 SDL_LockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
618 surface->pixels = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
619 SDL_UnlockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
620 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
621 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
622 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
623 static void GS_DMAFullUpdate(_THIS, int numrects, SDL_Rect *rects) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
624 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
625 /* Lock so we aren't interrupted by a mouse update */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
626 SDL_LockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
627 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
628 /* Make sure any pending DMA has completed */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
629 if ( dma_pending ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
630 ioctl(console_fd, PS2IOC_SENDQCT, 1); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
631 dma_pending = 0; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
632 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
633 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
634 /* If the mouse is visible, draw it on the DMA area */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
635 if ( (SDL_cursorstate & CURSOR_VISIBLE) && !cursor_drawn ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
636 this->screen->pixels = mapped_mem + this->screen->offset; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
637 SDL_DrawCursorNoLock(this->screen); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
638 this->screen->pixels = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
639 cursor_drawn = 1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
640 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
641 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
642 /* Put the image onto the screen */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
643 loadimage_nonblock(console_fd, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
644 &screen_image, screen_image_size, |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
645 head_tags_mem, image_tags_mem); |
136
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
646 if ( screen_image.y > 0 ) { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
647 /* Need to scale offscreen image to TV output */ |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
648 ioctl(console_fd, PS2IOC_SENDQCT, 1); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
649 dma_pending = 0; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
650 scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem); |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
651 } else { |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
652 dma_pending = 1; |
717f739d6ec1
Added hardware stretching code to scale 640x480 to TV resolution
Sam Lantinga <slouken@libsdl.org>
parents:
135
diff
changeset
|
653 } |
70
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
654 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
655 /* We're finished! */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
656 SDL_UnlockCursor(); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
657 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
658 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
659 static int GS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
660 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
661 return(0); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
662 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
663 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
664 static void GS_VideoQuit(_THIS) |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
665 { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
666 /* Close console and input file descriptors */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
667 if ( console_fd > 0 ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
668 /* Unmap the video framebuffer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
669 if ( mapped_mem ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
670 /* Unmap the video framebuffer */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
671 munmap(mapped_mem, mapped_len); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
672 mapped_mem = NULL; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
673 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
674 close(memory_fd); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
675 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
676 /* Restore the original video mode */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
677 if ( GS_InGraphicsMode(this) ) { |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
678 ioctl(console_fd, PS2IOC_SSCREENINFO, &saved_vinfo); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
679 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
680 |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
681 /* We're all done with the graphics device */ |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
682 close(console_fd); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
683 console_fd = -1; |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
684 } |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
685 GS_CloseMouse(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
686 GS_CloseKeyboard(this); |
f590dd383b5d
Added Linux PlayStation 2 Graphics Synthesizer support
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
687 } |