Commit 46da5465 authored by Patrice Mandin's avatar Patrice Mandin

Save/restore current video mode and palette

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402233
parent d5cf1663
......@@ -174,7 +174,7 @@ XBIOS_VideoInit(_THIS)
{
/* Save screensaver settings */
/* Init video mode list */
/* Init video mode list, save current video mode settings */
SDL_XBIOS_InitModes(_this);
return (0);
......@@ -187,5 +187,6 @@ XBIOS_VideoQuit(_THIS)
/* Restore screensaver settings */
/* Restore previous video mode settings */
SDL_XBIOS_QuitModes(_this);
}
......@@ -29,7 +29,12 @@
typedef struct SDL_VideoData
{
long cookie_vdo;
long cookie_vdo; /* _VDO cookie */
Uint16 old_modecode; /* Current video mode */
void *old_vbase; /* Current pointer to video RAM */
int old_numcol; /* Number of colors in saved palette */
Uint32 old_palette[256]; /* Buffer to save current palette */
#if 0
int old_video_mode; /* Old video mode before entering SDL */
......
......@@ -105,11 +105,146 @@ SDL_XBIOS_AddMode(_THIS, int width, int height, int bpp, Uint16 modecode,
SDL_AddVideoDisplay(&display);
}
/* Current video mode save/restore */
static void
SDL_XBIOS_ModeSave(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
data->old_vbase = Physbase();
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
data->old_modecode = Getrez();
break;
case VDO_TT:
data->old_modecode = EgetShift();
break;
case VDO_F30:
data->old_modecode = VsetMode(-1);
break;
}
}
static void
SDL_XBIOS_ModeRestore(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
Setscreen(-1, data->old_vbase, data->old_modecode);
break;
case VDO_TT:
Setscreen(-1, data->old_vbase, -1);
EsetShift(data->old_modecode);
break;
case VDO_F30:
Setscreen(-1, data->old_vbase, -1);
VsetMode(data->old_modecode);
break;
}
}
/* Current palette save/restore */
static void
SDL_XBIOS_PaletteSave(_THIS)
{
int i;
Uint16 *palette;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
data->old_numcol = 0;
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
switch (data->old_modecode << 8) {
case ST_LOW:
data->old_numcol = 16;
break;
case ST_MED:
data->old_numcol = 4;
break;
case ST_HIGH:
data->old_numcol = 2;
break;
}
palette = (Uint16 *) data->old_palette;
for (i = 0; i < data->old_numcol; i++) {
*palette++ = Setcolor(i, -1);
}
break;
case VDO_TT:
switch (data->old_modecode & ES_MODE) {
case TT_LOW:
data->old_numcol = 256;
break;
case ST_LOW:
case TT_MED:
data->old_numcol = 16;
break;
case ST_MED:
data->old_numcol = 4;
break;
case ST_HIGH:
case TT_HIGH:
data->old_numcol = 2;
break;
}
if (data->old_numcol) {
EgetPalette(0, data->old_numcol, data->old_palette);
}
break;
case VDO_F30:
data->old_numcol = 1 << (1 << (data->old_modecode & NUMCOLS));
if (data->old_numcol > 256) {
data->old_numcol = 0;
} else {
VgetRGB(0, data->old_numcol, data->old_palette);
}
break;
}
}
static void
SDL_XBIOS_PaletteRestore(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
if (data->old_numcol == 0) {
return;
}
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
Setpalette(data->old_palette);
break;
case VDO_TT:
EsetPalette(0, data->old_numcol, data->old_palette);
break;
case VDO_F30:
VsetRGB(0, data->old_numcol, data->old_palette);
break;
}
}
/* Public functions for use by the driver */
void
SDL_XBIOS_InitModes(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_XBIOS_PaletteSave(_this);
SDL_XBIOS_ModeSave(_this);
switch (data->cookie_vdo >> 16) {
case VDO_ST:
case VDO_STE:
......@@ -126,7 +261,7 @@ SDL_XBIOS_InitModes(_THIS)
break;
case VDO_F30:
{
Uint16 modecodemask = VsetMode(-1) & (VGA | PAL);
Uint16 modecodemask = data->old_modecode & (VGA | PAL);
int i;
switch (VgetMonitor()) {
......@@ -172,6 +307,9 @@ SDL_XBIOS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
void
SDL_XBIOS_QuitModes(_THIS)
{
SDL_XBIOS_ModeRestore(_this);
SDL_XBIOS_PaletteRestore(_this);
Vsync();
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_xbiosmodes_h
#define _SDL_xbiosmodes_h
typedef struct
{
Uint16 modecode;
SDL_bool doubleline;
SDL_bool c2p4;
} SDL_DisplayData;
extern void SDL_XBIOS_InitModes(_THIS);
extern void SDL_XBIOS_GetDisplayModes(_THIS);
extern int SDL_XBIOS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void SDL_XBIOS_QuitModes(_THIS);
#endif /* _SDL_xbiosmodes_h */
/* vi: set ts=4 sw=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment