1 /*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2004 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
SDL_XBIOS_CentscreenInit(_THIS)35 int SDL_XBIOS_CentscreenInit(_THIS)
36 {
37 centscreen_mode_t curmode, listedmode;
38 unsigned long result;
39 int cur_handle; /* Current Centscreen mode handle */
40
41 /* Reset current mode list */
42 if (XBIOS_modelist) {
43 SDL_free(XBIOS_modelist);
44 XBIOS_nummodes = 0;
45 XBIOS_modelist = NULL;
46 }
47
48 /* Add Centscreen modes */
49 Vread(&curmode);
50 cur_handle = curmode.handle;
51 curmode.mode = curmode.physx = curmode.physy = curmode.plan =
52 curmode.logx = curmode.logy = -1;
53
54 result = Vfirst(&curmode, &listedmode);
55 if (result==0) {
56 while (result==0) {
57 /* Don't add modes with virtual screen */
58 if ((listedmode.mode & CSCREEN_VIRTUAL)==0) {
59 /* Don't add modes with bpp<8 */
60 if (listedmode.plan>=8) {
61 SDL_XBIOS_AddMode(this, listedmode.mode, listedmode.physx,
62 listedmode.physy, listedmode.plan, SDL_FALSE
63 );
64 }
65 }
66 SDL_memcpy(&curmode, &listedmode, sizeof(centscreen_mode_t));
67 curmode.mode = curmode.physx = curmode.physy = curmode.plan =
68 curmode.logx = curmode.logy = -1;
69 result = Vnext(&curmode, &listedmode);
70 }
71 } else {
72 fprintf(stderr, "No suitable Centscreen modes\n");
73 }
74
75 return cur_handle;
76 }
77
SDL_XBIOS_CentscreenSetmode(_THIS,int width,int height,int planes)78 void SDL_XBIOS_CentscreenSetmode(_THIS, int width, int height, int planes)
79 {
80 centscreen_mode_t newmode, curmode;
81
82 newmode.handle = newmode.mode = newmode.logx = newmode.logy = -1;
83 newmode.physx = width;
84 newmode.physy = height;
85 newmode.plan = planes;
86 Vwrite(0, &newmode, &curmode);
87
88 /* Disable screensaver */
89 Vread(&newmode);
90 newmode.mode &= ~(CSCREEN_SAVER|CSCREEN_ENERGYSTAR);
91 Vwrite(0, &newmode, &curmode);
92 }
93
SDL_XBIOS_CentscreenRestore(_THIS,int prev_handle)94 void SDL_XBIOS_CentscreenRestore(_THIS, int prev_handle)
95 {
96 centscreen_mode_t newmode, curmode;
97
98 /* Restore old video mode */
99 newmode.handle = prev_handle;
100 newmode.mode = newmode.physx = newmode.physy = newmode.plan =
101 newmode.logx = newmode.logy = -1;
102 Vwrite(0, &newmode, &curmode);
103 }
104