e14743d1 |
1 | /* |
2 | SDL - Simple DirectMedia Layer |
3 | Copyright (C) 1997-2009 Sam Lantinga |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with this library; if not, write to the Free |
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | |
19 | Sam Lantinga |
20 | slouken@libsdl.org |
21 | */ |
22 | #include "SDL_config.h" |
23 | |
24 | /* |
25 | Centscreen extension definitions |
26 | |
27 | Patrice Mandin |
28 | */ |
29 | |
30 | #include <mint/falcon.h> |
31 | |
32 | #include "SDL_xbios.h" |
33 | #include "SDL_xbios_centscreen.h" |
34 | |
35 | int SDL_XBIOS_ListCentscreenModes(_THIS, int actually_add) |
36 | { |
37 | centscreen_mode_t curmode, listedmode; |
38 | unsigned long result; |
39 | int cur_handle; /* Current Centscreen mode handle */ |
40 | |
41 | /* Add Centscreen modes */ |
42 | Vread(&curmode); |
43 | cur_handle = curmode.handle; |
44 | curmode.mode = curmode.physx = curmode.physy = curmode.plan = |
45 | curmode.logx = curmode.logy = -1; |
46 | |
47 | result = Vfirst(&curmode, &listedmode); |
48 | if (result==0) { |
49 | while (result==0) { |
50 | /* Don't add modes with virtual screen */ |
51 | if ((listedmode.mode & CSCREEN_VIRTUAL)==0) { |
52 | /* Don't add modes with bpp<8 */ |
53 | if (listedmode.plan>=8) { |
54 | xbiosmode_t modeinfo; |
55 | |
56 | modeinfo.number = listedmode.mode; |
57 | modeinfo.width = listedmode.physx; |
58 | modeinfo.height = listedmode.physy; |
59 | modeinfo.depth = listedmode.plan; |
60 | modeinfo.flags = (modeinfo.depth == 8 ? XBIOSMODE_C2P : 0); |
61 | |
62 | SDL_XBIOS_AddMode(this, actually_add, &modeinfo); |
63 | } |
64 | } |
65 | SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t)); |
66 | curmode.mode = curmode.physx = curmode.physy = curmode.plan = |
67 | curmode.logx = curmode.logy = -1; |
68 | result = Vnext(&curmode, &listedmode); |
69 | } |
70 | } else { |
71 | fprintf(stderr, "No suitable Centscreen modes\n"); |
72 | } |
73 | |
74 | return cur_handle; |
75 | } |
76 | |
77 | void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes) |
78 | { |
79 | centscreen_mode_t newmode, curmode; |
80 | |
81 | newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1; |
82 | newmode.physx = width; |
83 | newmode.physy = height; |
84 | newmode.plan = planes; |
85 | Vwrite(0, &newmode, &curmode); |
86 | |
87 | #ifdef SDL_VIDEO_DISABLE_SCREENSAVER |
88 | /* Disable screensaver */ |
89 | Vread(&newmode); |
90 | newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR); |
91 | Vwrite(0, &newmode, &curmode); |
92 | #endif /* SDL_VIDEO_DISABLE_SCREENSAVER */ |
93 | } |
94 | |
95 | void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle) |
96 | { |
97 | centscreen_mode_t newmode, curmode; |
98 | |
99 | /* Restore old video mode */ |
100 | newmode.handle = prev_handle; |
101 | newmode.mode = newmode.physx = newmode.physy = newmode.plan = |
102 | newmode.logx = newmode.logy = -1; |
103 | Vwrite(0, &newmode, &curmode); |
104 | } |