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	ScreenBlaster 3 functions
26
27	Patrice Mandin
28*/
29
30/*--- Includes ---*/
31
32#include "SDL_stdinc.h"
33#include "SDL_xbios.h"
34#include "SDL_xbios_sb3.h"
35
36/*--- Defines ---*/
37
38const int SDL_XBIOS_scpn_planes_device[]={
39	SCPN_DEV_1BPP,
40	SCPN_DEV_4BPP,
41	SCPN_DEV_8BPP,
42	SCPN_DEV_16BPP,
43	SCPN_DEV_2BPP,
44	SCPN_DEV_4BPP,
45	SCPN_DEV_1BPP
46};
47
48/*--- Functions ---*/
49
50int SDL_XBIOS_SB3Usable(scpn_cookie_t *cookie_scpn)
51{
52	scpn_screeninfo_t *scrinfo;
53	int bpp;
54
55	/* Check if current SB3 mode is usable, i.e. 8 or 16bpp */
56	scrinfo = cookie_scpn->screen_info;
57	bpp = 1<<(SDL_XBIOS_scpn_planes_device[scrinfo->device]);
58
59	if ((bpp==8) || (bpp==16)) {
60		return 1;
61	}
62
63	return 0;
64}
65
66void SDL_XBIOS_SB3Init(_THIS, scpn_cookie_t *cookie_scpn)
67{
68	scpn_screeninfo_t *scrinfo;
69
70	/* SB3 prevent changing video modes, we can only use current one */
71	if (XBIOS_modelist) {
72		SDL_free(XBIOS_modelist);
73		XBIOS_nummodes = 0;
74		XBIOS_modelist = NULL;
75	}
76
77	scrinfo = cookie_scpn->screen_info;
78	scrinfo->h_pos = scrinfo->v_pos = 0;
79
80	SDL_XBIOS_AddMode(this,
81		-1,
82		scrinfo->virtual_width, scrinfo->virtual_height,
83		1<<(SDL_XBIOS_scpn_planes_device[scrinfo->device]),
84		SDL_FALSE
85	);
86}
87