2012-09-08 21:43:33 +10:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2012-09-09 21:15:09 +10:00
|
|
|
#include "graphics/palette.h"
|
2012-09-09 19:55:05 +10:00
|
|
|
#include "common/file.h"
|
2012-09-09 00:12:27 +10:00
|
|
|
#include "common/rect.h"
|
2012-09-08 23:43:35 +10:00
|
|
|
#include "engines/util.h"
|
2012-09-08 21:43:33 +10:00
|
|
|
#include "hopkins/files.h"
|
|
|
|
#include "hopkins/globals.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
GraphicsManager::GraphicsManager() {
|
2012-09-13 21:08:54 +10:00
|
|
|
_lockCtr = 0;
|
2012-09-09 19:55:05 +10:00
|
|
|
SDL_MODEYES = false;
|
2012-09-09 20:10:32 +10:00
|
|
|
SDL_ECHELLE = 0;
|
|
|
|
XSCREEN = YSCREEN = 0;
|
|
|
|
WinScan = 0;
|
|
|
|
Winbpp = 0;
|
|
|
|
PAL_PIXELS = NULL;
|
|
|
|
nbrligne = 0;
|
|
|
|
Linear = false;
|
|
|
|
VideoPtr = NULL;
|
|
|
|
start_x = 0;
|
|
|
|
ofscroll = 0;
|
|
|
|
SCROLL = 0;
|
|
|
|
PCX_L = PCX_H = 0;
|
|
|
|
DOUBLE_ECRAN = false;
|
|
|
|
OLD_SCROLL = 0;
|
2012-09-09 19:55:05 +10:00
|
|
|
MANU_SCROLL = 1;
|
|
|
|
SPEED_SCROLL = 16;
|
2012-09-09 20:10:32 +10:00
|
|
|
nbrligne2 = 0;
|
2012-09-09 19:55:05 +10:00
|
|
|
Agr_x = Agr_y = 0;
|
|
|
|
Agr_Flag_x = Agr_Flag_y = 0;
|
2012-09-10 20:26:24 +10:00
|
|
|
FADESPD = 15;
|
2012-09-15 10:27:15 +10:00
|
|
|
FADE_LINUX = 0;
|
|
|
|
NOLOCK = false;
|
2012-09-13 21:08:54 +10:00
|
|
|
|
|
|
|
Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0);
|
|
|
|
Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_SIZE], 0);
|
|
|
|
Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
|
|
|
|
Common::fill(&Palette[0], &Palette[PALETTE_BLOCK_SIZE], 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsManager::~GraphicsManager() {
|
2012-09-15 10:27:15 +10:00
|
|
|
GLOBALS.dos_free2(VESA_SCREEN);
|
|
|
|
GLOBALS.dos_free2(VESA_BUFFER);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::SET_MODE(int width, int height) {
|
|
|
|
if (!SDL_MODEYES) {
|
|
|
|
SDL_ECHELLE = 0;
|
|
|
|
|
|
|
|
if (GLOBALS.XSETMODE == 1)
|
|
|
|
SDL_ECHELLE = 0;
|
|
|
|
if (GLOBALS.XSETMODE == 2)
|
|
|
|
SDL_ECHELLE = 25;
|
|
|
|
if (GLOBALS.XSETMODE == 3)
|
|
|
|
SDL_ECHELLE = 50;
|
|
|
|
if (GLOBALS.XSETMODE == 4)
|
|
|
|
SDL_ECHELLE = 75;
|
|
|
|
if (GLOBALS.XSETMODE == 5)
|
|
|
|
SDL_ECHELLE = GLOBALS.XZOOM;
|
|
|
|
|
|
|
|
int bpp = 8;
|
|
|
|
if (GLOBALS.XFORCE8 == 1)
|
|
|
|
bpp = 8;
|
|
|
|
if (GLOBALS.XFORCE16 == 1)
|
|
|
|
bpp = 16;
|
|
|
|
|
|
|
|
if (SDL_ECHELLE) {
|
|
|
|
error("TODO: Implement zooming support");
|
|
|
|
//width = Reel_Zoom(width, SDL_ECHELLE);
|
|
|
|
//height = Reel_Zoom(height, SDL_ECHELLE);
|
|
|
|
}
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
//Graphics::PixelFormat pixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0);
|
|
|
|
Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
2012-09-09 20:28:04 +10:00
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
if (bpp == 8) {
|
|
|
|
initGraphics(width, height, true);
|
|
|
|
} else {
|
2012-09-09 20:28:04 +10:00
|
|
|
initGraphics(width, height, true, &pixelFormat16);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
// Init surfaces
|
2012-09-15 10:27:15 +10:00
|
|
|
VESA_SCREEN = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
|
|
|
VESA_BUFFER = GLOBALS.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
VideoPtr = NULL;
|
|
|
|
XSCREEN = width;
|
|
|
|
YSCREEN = height;
|
|
|
|
|
|
|
|
Linear = true;
|
2012-09-13 21:08:54 +10:00
|
|
|
Winbpp = bpp / 8;
|
|
|
|
WinScan = width * Winbpp;
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
PAL_PIXELS = SD_PIXELS;
|
|
|
|
nbrligne = width;
|
|
|
|
|
2012-09-09 21:15:09 +10:00
|
|
|
Common::fill(&cmap[0], &cmap[256 * 3], 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
SDL_MODEYES = true;
|
|
|
|
} else {
|
|
|
|
error("Called SET_MODE multiple times");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_Lock() {
|
2012-09-15 10:27:15 +10:00
|
|
|
if (!NOLOCK) {
|
|
|
|
if (_lockCtr++ == 0)
|
|
|
|
VideoPtr = g_system->lockScreen();
|
|
|
|
}
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_Unlock() {
|
2012-09-09 20:10:32 +10:00
|
|
|
assert(VideoPtr);
|
2012-09-13 21:08:54 +10:00
|
|
|
if (--_lockCtr == 0) {
|
|
|
|
g_system->unlockScreen();
|
|
|
|
VideoPtr = NULL;
|
|
|
|
}
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Cls_Video() {
|
|
|
|
assert(VideoPtr);
|
|
|
|
|
|
|
|
VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::LOAD_IMAGE(const Common::String &file) {
|
2012-09-09 20:28:04 +10:00
|
|
|
Common::String filename = Common::String::format("%s.PCX", file.c_str());
|
2012-09-09 19:55:05 +10:00
|
|
|
CHARGE_ECRAN(filename);
|
|
|
|
GraphicsManager::INIT_TABLE(165, 170, Palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::CHARGE_ECRAN(const Common::String &file) {
|
2012-09-09 21:15:09 +10:00
|
|
|
bool flag;
|
2012-09-09 19:55:05 +10:00
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
FileManager::DMESS1();
|
|
|
|
|
2012-09-09 21:15:09 +10:00
|
|
|
flag = true;
|
2012-09-09 19:55:05 +10:00
|
|
|
if (FileManager::RECHERCHE_CAT(file, 6)) {
|
|
|
|
FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file);
|
|
|
|
if (!f.open(GLOBALS.NFICHIER))
|
|
|
|
error("CHARGE_ECRAN - %s", file.c_str());
|
|
|
|
|
|
|
|
f.seek(0, SEEK_END);
|
|
|
|
f.close();
|
2012-09-09 21:15:09 +10:00
|
|
|
flag = false;
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
SCROLL_ECRAN(0);
|
2012-09-15 10:27:15 +10:00
|
|
|
A_PCX640_480((byte *)VESA_SCREEN, file, Palette, flag);
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
SCROLL = 0;
|
|
|
|
OLD_SCROLL = 0;
|
|
|
|
Cls_Pal();
|
|
|
|
|
|
|
|
if (!DOUBLE_ECRAN) {
|
|
|
|
souris_max();
|
|
|
|
SCANLINE(SCREEN_WIDTH);
|
|
|
|
GLOBALS.max_x = SCREEN_WIDTH;
|
|
|
|
DD_Lock();
|
|
|
|
Cls_Video();
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
else
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
} else if (Winbpp == 1) {
|
|
|
|
if (!SDL_ECHELLE)
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
else
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
2012-09-09 21:15:09 +10:00
|
|
|
|
|
|
|
DD_Unlock();
|
2012-09-09 19:55:05 +10:00
|
|
|
} else {
|
2012-09-13 21:08:54 +10:00
|
|
|
SCANLINE(SCREEN_WIDTH * 2);
|
2012-09-09 19:55:05 +10:00
|
|
|
GLOBALS.max_x = SCREEN_WIDTH * 2;
|
|
|
|
DD_Lock();
|
|
|
|
Cls_Video();
|
|
|
|
DD_Unlock();
|
|
|
|
|
|
|
|
if (MANU_SCROLL == 1) {
|
|
|
|
DD_Lock();
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll16A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
else
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll16((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
if (Winbpp == 1) {
|
|
|
|
if (!SDL_ECHELLE)
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll2((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
else
|
2012-09-15 10:27:15 +10:00
|
|
|
m_scroll2A((byte *)VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
DD_Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-15 10:27:15 +10:00
|
|
|
memcpy((byte *)VESA_BUFFER, (byte *)VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) {
|
2012-09-09 19:55:05 +10:00
|
|
|
for (int idx = 0; idx < 256; ++idx)
|
|
|
|
TABLE_COUL[idx] = idx;
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
Trans_bloc(TABLE_COUL, palette, 256, a1, a2);
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 256; ++idx) {
|
|
|
|
byte v = TABLE_COUL[idx];
|
|
|
|
if (v > 27)
|
|
|
|
TABLE_COUL[idx] = 0;
|
|
|
|
if (!v)
|
|
|
|
TABLE_COUL[idx] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TABLE_COUL[0] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GraphicsManager::SCROLL_ECRAN(int amount) {
|
|
|
|
int result = CLIP(amount, 0, SCREEN_WIDTH);
|
|
|
|
start_x = result;
|
|
|
|
ofscroll = result;
|
|
|
|
SCROLL = result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Trans_bloc(byte *destP, byte *srcP, int count, int param1, int param2) {
|
|
|
|
byte *v5;
|
|
|
|
int v6;
|
|
|
|
int v7;
|
|
|
|
int v8;
|
|
|
|
unsigned int v11;
|
|
|
|
int v12;
|
|
|
|
int v13;
|
|
|
|
int v14;
|
|
|
|
int v15;
|
|
|
|
int v16;
|
|
|
|
int v17;
|
|
|
|
unsigned int v18;
|
|
|
|
char v19;
|
|
|
|
int v20;
|
|
|
|
bool breakFlag;
|
|
|
|
|
|
|
|
v5 = destP;
|
|
|
|
v6 = count - 1;
|
|
|
|
do {
|
|
|
|
breakFlag = v6;
|
|
|
|
v7 = *(byte *)v5++;
|
|
|
|
v8 = (unsigned int)(3 * v7);
|
|
|
|
|
|
|
|
// TODO: Ensure this is the right calculation
|
|
|
|
v11 = *(byte *)(v8 + srcP) + *(byte *)(v8 + srcP + 1)
|
|
|
|
+ *(byte *)(v8 + srcP + 2);
|
|
|
|
|
|
|
|
v12 = 0;
|
|
|
|
for (;;) {
|
|
|
|
v13 = v12 + 1;
|
|
|
|
if ( v13 == 38 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
v20 = v13;
|
|
|
|
v8 = 3 * v8;
|
|
|
|
v14 = *(byte *)(v8 + srcP);
|
|
|
|
v15 = v14;
|
|
|
|
v14 = *(byte *)(v8 + srcP + 1);
|
|
|
|
v16 = v14 + v15;
|
|
|
|
v14 = *(byte *)(v8 + srcP + 2);
|
|
|
|
v17 = v14 + v16;
|
|
|
|
v12 = v20;
|
|
|
|
v18 = param1 + v17;
|
|
|
|
if (v18 >= v11 && (unsigned int)(v18 - param2) <= v11) {
|
|
|
|
v19 = v20;
|
|
|
|
if (!v20)
|
|
|
|
v19 = 1;
|
|
|
|
*(byte *)(v5 - 1) = v19;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
v6 = breakFlag - 1;
|
|
|
|
} while ( !breakFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder
|
2012-09-13 21:08:54 +10:00
|
|
|
void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) {
|
2012-09-09 19:55:05 +10:00
|
|
|
int filesize;
|
|
|
|
signed __int16 v6;
|
|
|
|
int v7;
|
|
|
|
__int16 v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
int v11;
|
|
|
|
unsigned __int8 v12;
|
|
|
|
int v13;
|
|
|
|
int v14;
|
|
|
|
char v15;
|
|
|
|
int v18;
|
|
|
|
int v19;
|
|
|
|
int v20;
|
|
|
|
unsigned int v21;
|
|
|
|
int v22;
|
|
|
|
int32 v23;
|
|
|
|
byte *ptr;
|
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
// Clear the passed surface
|
|
|
|
memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
|
|
|
|
|
|
|
if (typeFlag) {
|
|
|
|
FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, "PIC.RES");
|
|
|
|
if (!f.open(GLOBALS.NFICHIER))
|
|
|
|
error("(nom)Erreur en cours de lecture.");
|
|
|
|
f.seek(GLOBALS.CAT_POSI);
|
|
|
|
|
|
|
|
v7 = GLOBALS.CAT_TAILLE - 896;
|
|
|
|
v8 = f.read(HEADER_PCX, 128);
|
|
|
|
|
|
|
|
v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1;
|
|
|
|
v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1;
|
|
|
|
if ((READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) {
|
|
|
|
DOUBLE_ECRAN = false;
|
|
|
|
} else {
|
|
|
|
v6 = SCREEN_WIDTH * 2;
|
|
|
|
DOUBLE_ECRAN = true;
|
|
|
|
}
|
|
|
|
if (v20 > SCREEN_HEIGHT)
|
|
|
|
v20 = SCREEN_HEIGHT;
|
|
|
|
PCX_L = v6;
|
|
|
|
PCX_H = v20;
|
|
|
|
if (v8 == -1)
|
|
|
|
error("Erreur en cours de lecture.");
|
|
|
|
} else {
|
|
|
|
FileManager::CONSTRUIT_FICHIER(GLOBALS.HOPIMAGE, file);
|
|
|
|
if (!f.open(GLOBALS.NFICHIER))
|
|
|
|
error("(nom)Erreur en cours de lecture.");
|
|
|
|
|
|
|
|
filesize = f.size();
|
|
|
|
int bytesRead = f.read(HEADER_PCX, 128);
|
|
|
|
if (bytesRead < 128)
|
|
|
|
error("Erreur en cours de lecture.");
|
|
|
|
|
|
|
|
v6 = READ_LE_UINT16(&HEADER_PCX[8]) + 1;
|
|
|
|
v20 = READ_LE_UINT16(&HEADER_PCX[10]) + 1;
|
|
|
|
if (v6 <= SCREEN_WIDTH) {
|
|
|
|
DOUBLE_ECRAN = false;
|
|
|
|
} else {
|
|
|
|
v6 = SCREEN_WIDTH * 2;
|
|
|
|
DOUBLE_ECRAN = true;
|
|
|
|
}
|
|
|
|
if (v20 > SCREEN_HEIGHT)
|
|
|
|
v20 = SCREEN_HEIGHT;
|
|
|
|
PCX_L = v6;
|
|
|
|
PCX_H = v20;
|
|
|
|
v7 = filesize - 896;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = GLOBALS.dos_malloc2(0xEE60u);
|
|
|
|
if (v7 >= 60000) {
|
|
|
|
v21 = v7 / 60000 + 1;
|
|
|
|
v23 = 60000 * (v7 / 60000) - v7;
|
|
|
|
|
|
|
|
if (((uint32)v23 & 0x80000000u) != 0)
|
|
|
|
v23 = -v23;
|
|
|
|
f.read(ptr, 60000);
|
|
|
|
v7 = 60000;
|
|
|
|
} else {
|
|
|
|
v21 = 1;
|
|
|
|
v23 = v7;
|
|
|
|
f.read(ptr, v7);
|
|
|
|
}
|
|
|
|
v22 = v21 - 1;
|
|
|
|
v18 = 0;
|
|
|
|
v9 = 0;
|
|
|
|
v10 = 0;
|
|
|
|
v19 = v6;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (v9 == v7) {
|
|
|
|
v9 = 0;
|
|
|
|
--v22;
|
|
|
|
v7 = 60000;
|
|
|
|
if ( !v22 )
|
|
|
|
v7 = v23;
|
|
|
|
v11 = v10;
|
|
|
|
f.read(ptr, v7);
|
|
|
|
v10 = v11;
|
|
|
|
}
|
|
|
|
|
|
|
|
v12 = *((byte *)ptr + v9++);
|
|
|
|
if (v12 > 0xC0u) {
|
|
|
|
v13 = v12 - 192;
|
|
|
|
if (v9 == v7) {
|
|
|
|
v9 = 0;
|
|
|
|
--v22;
|
|
|
|
v7 = 60000;
|
|
|
|
if ( v22 == 1 )
|
|
|
|
v7 = v23;
|
|
|
|
v14 = v10;
|
|
|
|
f.read(ptr, v7);
|
|
|
|
v10 = v14;
|
|
|
|
}
|
|
|
|
v15 = *((byte *)ptr + v9++);
|
|
|
|
|
|
|
|
do {
|
|
|
|
*((byte *)surface + v10++) = v15;
|
|
|
|
++v18;
|
|
|
|
--v13;
|
|
|
|
} while (v13);
|
|
|
|
} else {
|
|
|
|
*((byte *)surface + v10++) = v12;
|
|
|
|
++v18;
|
|
|
|
}
|
|
|
|
} while (v18 < v19 * v20);
|
|
|
|
|
|
|
|
if (typeFlag) {
|
|
|
|
f.seek(GLOBALS.CAT_TAILLE + GLOBALS.CAT_POSI - 768);
|
|
|
|
} else {
|
|
|
|
filesize = f.size();
|
|
|
|
f.seek(filesize - 768);
|
|
|
|
}
|
|
|
|
|
2012-09-10 20:26:24 +10:00
|
|
|
if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE))
|
2012-09-13 21:08:54 +10:00
|
|
|
error("A_PCX640_480");
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
f.close();
|
|
|
|
GLOBALS.dos_free2(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Cls_Pal() {
|
2012-09-13 21:08:54 +10:00
|
|
|
Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
|
|
|
|
SD_PIXELS[0] = 0;
|
2012-09-09 21:15:09 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
if (Winbpp == 1) {
|
2012-09-09 21:15:09 +10:00
|
|
|
g_system->getPaletteManager()->setPalette(cmap, 0, 256);
|
|
|
|
}
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
2012-09-09 21:15:09 +10:00
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
void GraphicsManager::souris_max() {
|
2012-09-13 21:08:54 +10:00
|
|
|
// Original has no implementation
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
void GraphicsManager::SCANLINE(int pitch) {
|
|
|
|
nbrligne = nbrligne2 = pitch;
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
byte *v11;
|
|
|
|
const byte *v12;
|
|
|
|
unsigned int v13;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = xs + nbrligne2 * ys + surface;
|
|
|
|
v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels;
|
|
|
|
v9 = height;
|
|
|
|
do {
|
|
|
|
v10 = v9;
|
|
|
|
memcpy((byte *)v8, (const byte *)v7, 4 * (width >> 2));
|
|
|
|
v12 = (const byte *)(v7 + 4 * (width >> 2));
|
|
|
|
v11 = (byte *)(v8 + 4 * (width >> 2));
|
|
|
|
v13 = width - 4 * (width >> 2);
|
|
|
|
memcpy(v11, v12, v13);
|
|
|
|
v8 = ((byte *)v11 + v13 + WinScan - width);
|
|
|
|
v7 = ((byte *)v12 + v13 + nbrligne2 - width);
|
|
|
|
v9 = v10 - 1;
|
|
|
|
} while (v10 != 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
int v11;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = (const byte *)(xs + nbrligne2 * ys + surface);
|
|
|
|
v8 = (byte *)(destX + WinScan * destY + (byte *)VideoPtr->pixels);
|
|
|
|
v9 = WinScan - SCREEN_WIDTH;
|
|
|
|
v10 = nbrligne2 - SCREEN_WIDTH;
|
|
|
|
v11 = height;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(v8, v7, SCREEN_WIDTH);
|
|
|
|
v8 = (byte *)v8 + v9 + SCREEN_WIDTH;
|
|
|
|
v7 = (const byte *)v7 + v10 + SCREEN_WIDTH;
|
|
|
|
--v11;
|
|
|
|
} while (v11);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
const byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
byte v11;
|
|
|
|
const byte *v12;
|
|
|
|
const byte *v13;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = xs + nbrligne2 * ys + surface;
|
|
|
|
v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels;
|
|
|
|
v9 = height;
|
|
|
|
Agr_x = 0;
|
|
|
|
Agr_y = 0;
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
do {
|
|
|
|
for (;;) {
|
|
|
|
v13 = v8;
|
|
|
|
v12 = v7;
|
|
|
|
v10 = width;
|
|
|
|
Agr_x = 0;
|
|
|
|
do {
|
|
|
|
v11 = *(byte *)v7;
|
|
|
|
*(byte *)v8++ = *(byte *)v7++;
|
|
|
|
Agr_x += SDL_ECHELLE;
|
|
|
|
if ((unsigned int)Agr_x >= 100) {
|
|
|
|
Agr_x -= 100;
|
|
|
|
*(byte *)v8++ = v11;
|
|
|
|
}
|
|
|
|
--v10;
|
|
|
|
} while ( v10 );
|
|
|
|
|
|
|
|
v7 = v12;
|
|
|
|
v8 = WinScan + v13;
|
|
|
|
if (Agr_Flag_y)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Agr_y += SDL_ECHELLE;
|
|
|
|
if ((unsigned int)Agr_y < 100)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Agr_y -= 100;
|
|
|
|
Agr_Flag_y = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
v7 = nbrligne2 + v12;
|
|
|
|
--v9;
|
|
|
|
} while (v9);
|
|
|
|
}
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
/**
|
|
|
|
* Copies data from a 8-bit palette surface into the 16-bit screen
|
|
|
|
*/
|
2012-09-09 19:55:05 +10:00
|
|
|
void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
2012-09-13 21:08:54 +10:00
|
|
|
DD_Lock();
|
2012-09-09 19:55:05 +10:00
|
|
|
|
|
|
|
assert(VideoPtr);
|
2012-09-13 21:08:54 +10:00
|
|
|
const byte *srcP = xs + nbrligne2 * ys + surface;
|
|
|
|
uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destX * 2 + WinScan * destY);
|
2012-09-09 19:55:05 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
for (int yp = 0; yp < height; ++yp) {
|
|
|
|
// Copy over the line, using the source pixels as lookups into the pixels palette
|
|
|
|
const byte *lineSrcP = srcP;
|
|
|
|
uint16 *lineDestP = destP;
|
|
|
|
|
|
|
|
for (int xp = 0; xp < width; ++xp)
|
2012-09-13 22:55:50 +10:00
|
|
|
*lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2];
|
2012-09-13 21:08:54 +10:00
|
|
|
|
|
|
|
// Move to the start of the next line
|
|
|
|
srcP += nbrligne2;
|
|
|
|
destP += WinScan / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
DD_Unlock();
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
const byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
const byte *v11;
|
|
|
|
int v12;
|
|
|
|
int v13;
|
|
|
|
const byte *v14;
|
|
|
|
const byte *v15;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = xs + nbrligne2 * ys + surface;
|
|
|
|
v8 = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels;
|
|
|
|
v9 = height;
|
|
|
|
Agr_x = 0;
|
|
|
|
Agr_y = 0;
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
for (;;) {
|
|
|
|
v15 = v8;
|
|
|
|
v14 = v7;
|
|
|
|
v10 = width;
|
|
|
|
v13 = v9;
|
|
|
|
v11 = PAL_PIXELS;
|
|
|
|
Agr_x = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v12 = *(uint16 *)(v11 + 2 * *(byte *)v7);
|
|
|
|
*(uint16 *)v8 = v12;
|
|
|
|
++v7;
|
|
|
|
v8 += 2;
|
|
|
|
Agr_x += SDL_ECHELLE;
|
|
|
|
if ((unsigned int)Agr_x >= 100) {
|
|
|
|
Agr_x -= 100;
|
|
|
|
*(uint16 *)v8 = v12;
|
|
|
|
v8 += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
--v10;
|
|
|
|
} while (v10);
|
|
|
|
|
|
|
|
v9 = v13;
|
|
|
|
v7 = v14;
|
|
|
|
v8 = WinScan + v15;
|
|
|
|
if (Agr_Flag_y == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Agr_y += SDL_ECHELLE;
|
|
|
|
|
|
|
|
if ((unsigned int)Agr_y < 100)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Agr_y -= 100;
|
|
|
|
Agr_Flag_y = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
v7 = nbrligne2 + v14;
|
|
|
|
v9 = v13 - 1;
|
|
|
|
} while (v13 != 1);
|
|
|
|
}
|
|
|
|
|
2012-09-10 20:26:24 +10:00
|
|
|
void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) {
|
2012-09-13 21:08:54 +10:00
|
|
|
uint16 palData1[PALETTE_BLOCK_SIZE * 2];
|
|
|
|
byte palData2[PALETTE_BLOCK_SIZE];
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
// Initialise temporary palettes
|
|
|
|
Common::fill(&palData1[0], &palData1[PALETTE_BLOCK_SIZE], 0);
|
|
|
|
Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
// Set current palette to black
|
|
|
|
setpal_vga256(palData2);
|
|
|
|
|
|
|
|
// Loop through fading in the palette
|
|
|
|
uint16 *pTemp1 = &palData1[2];
|
|
|
|
for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) {
|
|
|
|
uint16 *pTemp2 = &palData1[4];
|
|
|
|
|
|
|
|
for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) {
|
|
|
|
if (palData2[palOffset] < palette[palOffset]) {
|
|
|
|
uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD;
|
|
|
|
palData1[palOffset] = v;
|
|
|
|
palData2[palOffset] = (v >> 8) & 0xff;
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
if (palData2[palOffset + 1] < palette[palOffset + 1]) {
|
|
|
|
uint16 *pDest = &pTemp1[palOffset];
|
|
|
|
uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
|
|
|
|
*pDest = v;
|
|
|
|
palData2[palOffset + 1] = (v >> 8) & 0xff;
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
if (palData2[palOffset + 1] < palette[palOffset + 1]) {
|
|
|
|
uint16 *pDest = &pTemp2[palOffset];
|
|
|
|
uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
|
|
|
|
*pDest = v;
|
|
|
|
palData2[palOffset + 1] = (v >> 8) & 0xff;
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
2012-09-13 21:08:54 +10:00
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
setpal_vga256(palData2);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
|
|
|
m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
else
|
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
DD_VBL();
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
// Set the final palette
|
2012-09-10 20:26:24 +10:00
|
|
|
setpal_vga256(palette);
|
2012-09-13 21:08:54 +10:00
|
|
|
|
|
|
|
// Refresh the screen
|
2012-09-10 20:26:24 +10:00
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
else
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) {
|
|
|
|
__int16 v3;
|
|
|
|
__int16 v4;
|
|
|
|
int v5;
|
|
|
|
signed __int16 v6;
|
|
|
|
__int16 v7;
|
|
|
|
int v8;
|
|
|
|
__int16 v9;
|
|
|
|
__int16 v10;
|
|
|
|
__int16 v12;
|
|
|
|
unsigned __int16 v13;
|
|
|
|
byte palData[PALETTE_BLOCK_SIZE];
|
|
|
|
__int16 v15[PALETTE_BLOCK_SIZE];
|
|
|
|
|
|
|
|
v13 = v3 = FADESPD;
|
|
|
|
if (palette) {
|
|
|
|
v4 = 0;
|
|
|
|
do {
|
|
|
|
v5 = v4;
|
|
|
|
v3 = *(byte *)(v4 + palette);
|
|
|
|
v3 <<= 8;
|
|
|
|
v15[v5] = v3;
|
|
|
|
palData[v5] = *(byte *)(v4++ + palette);
|
|
|
|
} while (v4 < PALETTE_BLOCK_SIZE);
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
else
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
v6 = 0;
|
|
|
|
if ((signed __int16)v13 > 0) {
|
|
|
|
do {
|
|
|
|
v7 = 0;
|
|
|
|
do {
|
|
|
|
v8 = v7;
|
|
|
|
v9 = v15[v7] - ((unsigned int)*(byte *)(v7 + palette) << 8) / (signed __int16)v13;
|
|
|
|
v15[v8] = v9;
|
|
|
|
palData[v8] = (v9 >> 8) & 0xff;
|
|
|
|
++v7;
|
|
|
|
} while (v7 < (PALETTE_BLOCK_SIZE));
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
else
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
|
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
++v6;
|
|
|
|
} while ((signed __int16)v13 > v6);
|
|
|
|
}
|
|
|
|
|
|
|
|
v10 = 0;
|
|
|
|
do {
|
|
|
|
palData[v10++] = 0;
|
|
|
|
} while (v10 < (PALETTE_BLOCK_SIZE));
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (!SDL_ECHELLE) {
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
return DD_VBL();
|
|
|
|
}
|
|
|
|
goto LABEL_28;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
v12 = 0;
|
|
|
|
do {
|
|
|
|
palData[v12++] = 0;
|
|
|
|
} while (v12 < (PALETTE_BLOCK_SIZE));
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (!SDL_ECHELLE) {
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
return DD_VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
LABEL_28:
|
2012-09-13 21:08:54 +10:00
|
|
|
m_scroll16A(surface, start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 20:26:24 +10:00
|
|
|
return DD_VBL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INS() {
|
|
|
|
FADESPD = 1;
|
2012-09-15 10:27:15 +10:00
|
|
|
fade_in(Palette, 1, (const byte *)VESA_BUFFER);
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTS() {
|
|
|
|
FADESPD = 1;
|
2012-09-15 10:27:15 +10:00
|
|
|
fade_out(Palette, 1, (const byte *)VESA_BUFFER);
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INW() {
|
|
|
|
FADESPD = 15;
|
2012-09-15 10:27:15 +10:00
|
|
|
fade_in(Palette, 20, (const byte *)VESA_BUFFER);
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTW() {
|
|
|
|
FADESPD = 15;
|
2012-09-15 10:27:15 +10:00
|
|
|
fade_out(Palette, 20, (const byte *)VESA_BUFFER);
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::setpal_vga256(const byte *palette) {
|
|
|
|
CHANGE_PALETTE(palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::CHANGE_PALETTE(const byte *palette) {
|
2012-09-13 21:08:54 +10:00
|
|
|
// Copy the palette into the PALPCX block
|
|
|
|
// TODO: Likely either one or both of the destination arrays can be removed,
|
|
|
|
// since PALPCX is only used in SAVE_IMAGE, and cmap in the original was a RGBA
|
|
|
|
// array specifically intended just for passing to the SDL palette setter
|
|
|
|
Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &PALPCX[0]);
|
|
|
|
Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &cmap[0]);
|
|
|
|
|
|
|
|
const byte *srcP = &palette[0];
|
|
|
|
for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) {
|
|
|
|
// TODO: Validate pixel encoding is correct
|
|
|
|
*(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2));
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
if (Winbpp == 1)
|
|
|
|
g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE);
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) {
|
|
|
|
if (Winbpp == 1) {
|
|
|
|
error("TODO: Support in 8-bit graphics mode");
|
|
|
|
} else {
|
|
|
|
Graphics::PixelFormat format = g_system->getScreenFormat();
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-13 21:08:54 +10:00
|
|
|
return (r >> format.rLoss) << format.rShift
|
|
|
|
| (g >> format.gLoss) << format.gShift
|
|
|
|
| (b >> format.bLoss) << format.bShift;
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_VBL() {
|
|
|
|
// TODO: Is this okay here?
|
|
|
|
g_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
2012-09-15 10:27:15 +10:00
|
|
|
void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) {
|
|
|
|
warning("TODO: FADE_OUTW_LINUX");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSurface) {
|
|
|
|
warning("TODO: Copy_WinScan_Vbe3");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_Video_Vbe3(const byte *surface) {
|
|
|
|
warning("TODO: Copy_Video_Vbe3");
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_Video_Vbe16(const byte *surface) {
|
|
|
|
warning("TODO: Copy_Video_Vbe3");
|
|
|
|
}
|
2012-09-10 20:26:24 +10:00
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2012-09-08 23:43:35 +10:00
|
|
|
byte *ObjectManager::CHANGE_OBJET(int objIndex) {
|
|
|
|
byte *result = ObjectManager::CAPTURE_OBJET(objIndex, 1);
|
|
|
|
GLOBALS.Bufferobjet = result;
|
|
|
|
GLOBALS.Nouv_objet = 1;
|
|
|
|
GLOBALS.OBJET_EN_COURS = objIndex;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) {
|
|
|
|
byte *result = NULL;
|
|
|
|
byte *dataP;
|
|
|
|
|
|
|
|
dataP = 0;
|
2012-09-09 19:55:05 +10:00
|
|
|
int val1 = GLOBALS.ObjetW[objIndex].field0;
|
|
|
|
int val2 = GLOBALS.ObjetW[objIndex].field1;
|
2012-09-08 23:43:35 +10:00
|
|
|
|
|
|
|
if (mode == 1)
|
2012-09-09 19:55:05 +10:00
|
|
|
++val2;
|
|
|
|
if (val1 != GLOBALS.NUM_FICHIER_OBJ) {
|
2012-09-08 23:43:35 +10:00
|
|
|
if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL)
|
|
|
|
ObjectManager::DEL_FICHIER_OBJ();
|
2012-09-09 19:55:05 +10:00
|
|
|
if (val1 == 1) {
|
2012-09-08 23:43:35 +10:00
|
|
|
FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR");
|
|
|
|
GLOBALS.ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(GLOBALS.NFICHIER);
|
|
|
|
}
|
2012-09-09 19:55:05 +10:00
|
|
|
GLOBALS.NUM_FICHIER_OBJ = val1;
|
2012-09-08 23:43:35 +10:00
|
|
|
}
|
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, val2);
|
|
|
|
int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, val2);
|
2012-09-08 23:43:35 +10:00
|
|
|
GLOBALS.OBJL = width;
|
|
|
|
GLOBALS.OBJH = height;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
|
|
|
dataP = GLOBALS.dos_malloc2(height * width);
|
|
|
|
if (dataP == PTRNUL)
|
|
|
|
error("CAPTURE_OBJET");
|
|
|
|
|
2012-09-09 19:55:05 +10:00
|
|
|
ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, val2);
|
2012-09-08 23:43:35 +10:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2012-09-09 19:55:05 +10:00
|
|
|
ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, val2);
|
2012-09-08 23:43:35 +10:00
|
|
|
result = GLOBALS.Bufferobjet;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2012-09-09 19:55:05 +10:00
|
|
|
ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, val2);
|
2012-09-08 23:43:35 +10:00
|
|
|
result = GLOBALS.INVENTAIRE_OBJET;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
result = dataP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-09-08 21:43:33 +10:00
|
|
|
int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) {
|
|
|
|
const byte *objP = objectData + 3;
|
2012-09-08 23:43:35 +10:00
|
|
|
for (int i = objIndex; i; --i)
|
2012-09-08 21:43:33 +10:00
|
|
|
objP += READ_LE_UINT32(objP) + 16;
|
|
|
|
|
|
|
|
return READ_LE_UINT16(objP + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ObjectManager::Get_Hauteur(const byte *objectData, int objIndex) {
|
|
|
|
const byte *objP = objectData + 3;
|
|
|
|
for (int i = objIndex; i; --i)
|
|
|
|
objP += READ_LE_UINT32(objP) + 16;
|
|
|
|
|
|
|
|
return READ_LE_UINT16(objP + 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ObjectManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) {
|
|
|
|
const byte *objP = objectData + 3;
|
|
|
|
for (int i = objIndex; i; --i) {
|
|
|
|
objP += READ_LE_UINT32(objP) + 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
objP += 4;
|
|
|
|
int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2);
|
|
|
|
|
|
|
|
memcpy(sprite + 3, objP - 4, result + 16);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *ObjectManager::DEL_FICHIER_OBJ() {
|
|
|
|
GLOBALS.NUM_FICHIER_OBJ = 0;
|
|
|
|
if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL)
|
|
|
|
GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ);
|
|
|
|
|
|
|
|
byte *result = PTRNUL;
|
|
|
|
GLOBALS.ADR_FICHIER_OBJ = PTRNUL;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte *ObjectManager::CHARGE_SPRITE(const Common::String &file) {
|
|
|
|
FileManager::DMESS1();
|
|
|
|
return FileManager::CHARGE_FICHIER(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) {
|
|
|
|
const byte *objP = objectData + 3;
|
|
|
|
for (int i = objIndex; i; --i) {
|
|
|
|
objP += READ_LE_UINT32(objP) + 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
objP += 4;
|
|
|
|
int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2);
|
|
|
|
|
|
|
|
memcpy(sprite, objP + 12, result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-09-08 23:43:35 +10:00
|
|
|
int ObjectManager::AJOUTE_OBJET(int objIndex) {
|
|
|
|
bool flag = false;
|
|
|
|
int arrIndex = 0;
|
|
|
|
do {
|
|
|
|
++arrIndex;
|
|
|
|
if (!GLOBALS.INVENTAIRE[arrIndex])
|
|
|
|
flag = true;
|
|
|
|
if (arrIndex == 32)
|
|
|
|
flag = true;
|
|
|
|
} while (!flag);
|
|
|
|
|
|
|
|
GLOBALS.INVENTAIRE[arrIndex] = objIndex;
|
|
|
|
return arrIndex;
|
|
|
|
}
|
|
|
|
|
2012-09-08 21:43:33 +10:00
|
|
|
} // End of namespace Hopkins
|