2024-04-20 15:57:49 +00:00
|
|
|
/*
|
|
|
|
* Descent 3
|
|
|
|
* Copyright (C) 2024 Parallax Software
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2024-05-06 15:12:44 +00:00
|
|
|
--- HISTORICAL COMMENTS FOLLOW ---
|
|
|
|
|
2024-04-16 03:43:29 +00:00
|
|
|
* Video library.
|
2024-04-16 18:56:40 +00:00
|
|
|
*
|
2024-04-16 03:43:29 +00:00
|
|
|
* $NoKeywords: $
|
|
|
|
*/
|
|
|
|
|
2024-05-18 23:48:26 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2024-04-16 03:43:29 +00:00
|
|
|
#include "ddvid.h"
|
|
|
|
#include "application.h"
|
2024-05-18 23:48:26 +00:00
|
|
|
#include "lnxapp.h"
|
|
|
|
|
2024-05-30 07:35:17 +00:00
|
|
|
struct tinfo {
|
2024-04-16 18:56:40 +00:00
|
|
|
int width, height, bytesperpixel, linewidth;
|
2024-05-30 07:35:17 +00:00
|
|
|
};
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-05-30 07:35:17 +00:00
|
|
|
struct tDDVideoInfo {
|
2024-04-16 03:43:29 +00:00
|
|
|
oeLnxApplication *app;
|
2024-04-16 18:56:40 +00:00
|
|
|
// vga_modeinfo *info;
|
2024-04-16 03:43:29 +00:00
|
|
|
tinfo *info;
|
|
|
|
bool paged;
|
2024-05-30 07:35:17 +00:00
|
|
|
};
|
2024-04-16 03:43:29 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Variables
|
|
|
|
|
|
|
|
tDDVideoInfo DDVideo_info;
|
|
|
|
static bool DDVideo_init = false;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Prototypes
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Functions
|
|
|
|
|
|
|
|
// called first to allow fullscreen video access
|
2024-04-16 18:56:40 +00:00
|
|
|
bool ddvid_Init(oeApplication *app, char *driver) {
|
2024-04-16 03:43:29 +00:00
|
|
|
int subsys_id;
|
|
|
|
|
|
|
|
// preinitialize system.
|
|
|
|
if (!DDVideo_init) {
|
|
|
|
DDVideo_info.app = NULL;
|
|
|
|
DDVideo_info.info = NULL;
|
|
|
|
atexit(ddvid_Close);
|
2024-04-16 18:56:40 +00:00
|
|
|
} else {
|
2024-04-16 03:43:29 +00:00
|
|
|
ddvid_Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
DDVideo_init = true;
|
|
|
|
|
|
|
|
DDVideo_info.app = (oeLnxApplication *)app;
|
2024-04-16 18:56:40 +00:00
|
|
|
|
|
|
|
// vga_init();
|
2024-04-16 03:43:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// closes ddvid system manually.
|
2024-04-16 18:56:40 +00:00
|
|
|
void ddvid_Close() {
|
|
|
|
if (!DDVideo_init)
|
2024-04-16 03:43:29 +00:00
|
|
|
return;
|
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
/*
|
|
|
|
if(vga_getcurrentmode()!=TEXT)
|
|
|
|
vga_setmode(TEXT);
|
|
|
|
*/
|
2024-04-16 03:43:29 +00:00
|
|
|
DDVideo_init = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sets the appropriate video mode.
|
2024-04-16 18:56:40 +00:00
|
|
|
bool ddvid_SetVideoMode(int w, int h, int color_depth, bool paged) {
|
|
|
|
/*
|
|
|
|
ASSERT(DDVideo_init);
|
|
|
|
|
|
|
|
int mode = -1;
|
|
|
|
|
|
|
|
if( (w==640) && (h==480) ){
|
|
|
|
switch(color_depth){
|
|
|
|
case BPP_8:
|
|
|
|
mode = G640x480x256;
|
|
|
|
break;
|
|
|
|
case BPP_16:
|
|
|
|
mode = G640x480x32K;
|
|
|
|
break;
|
|
|
|
case BPP_24:
|
|
|
|
mode = G640x480x64K;
|
|
|
|
break;
|
|
|
|
case BPP_32:
|
|
|
|
mode = G640x480x16M;
|
|
|
|
break;
|
2024-04-16 03:43:29 +00:00
|
|
|
}
|
2024-04-16 18:56:40 +00:00
|
|
|
}else
|
|
|
|
if( (w==512) && (h==384) ){
|
|
|
|
mode = -1;
|
|
|
|
}else
|
|
|
|
if( (w==800) && (h==600) ){
|
|
|
|
switch(color_depth){
|
|
|
|
case BPP_8:
|
|
|
|
mode = G800x600x256;
|
|
|
|
break;
|
|
|
|
case BPP_16:
|
|
|
|
mode = G800x600x32K;
|
|
|
|
break;
|
|
|
|
case BPP_24:
|
|
|
|
mode = G800x600x64K;
|
|
|
|
break;
|
|
|
|
case BPP_32:
|
|
|
|
mode = G800x600x16M;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mode==-1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!vga_hasmode(mode))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
DDVideo_info.info = vga_getmodeinfo(mode);
|
|
|
|
|
|
|
|
DDVideo_info.paged = (bool)(DDVideo_info.info->flags&HAVE_RWPAGE);
|
|
|
|
|
|
|
|
if( (paged) && (!(DDVideo_info.paged)) ){
|
|
|
|
DDVideo_info.info = NULL;
|
|
|
|
Error("Pages not supported by mode %d\n",mode);
|
|
|
|
return false;
|
|
|
|
}
|
2024-04-16 03:43:29 +00:00
|
|
|
|
2024-04-16 18:56:40 +00:00
|
|
|
vga_setmode(mode);
|
|
|
|
*/
|
2024-04-16 03:43:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// sets screen handle
|
2024-04-16 18:56:40 +00:00
|
|
|
void ddvid_SetVideoHandle(unsigned handle) {}
|