2012-09-08 11:43:33 +00: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 11:15:09 +00:00
|
|
|
#include "graphics/palette.h"
|
2012-09-09 09:55:05 +00:00
|
|
|
#include "common/file.h"
|
2012-09-08 14:12:27 +00:00
|
|
|
#include "common/rect.h"
|
2012-09-08 13:43:35 +00:00
|
|
|
#include "engines/util.h"
|
2012-09-08 11:43:33 +00:00
|
|
|
#include "hopkins/files.h"
|
|
|
|
#include "hopkins/globals.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
GraphicsManager::GraphicsManager() {
|
2012-09-13 11:08:54 +00:00
|
|
|
_lockCtr = 0;
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_MODEYES = false;
|
2012-09-09 10:10:32 +00:00
|
|
|
SDL_ECHELLE = 0;
|
|
|
|
XSCREEN = YSCREEN = 0;
|
|
|
|
WinScan = 0;
|
|
|
|
Winbpp = 0;
|
|
|
|
PAL_PIXELS = NULL;
|
|
|
|
nbrligne = 0;
|
|
|
|
Linear = false;
|
|
|
|
VideoPtr = NULL;
|
|
|
|
ofscroll = 0;
|
|
|
|
SCROLL = 0;
|
|
|
|
PCX_L = PCX_H = 0;
|
|
|
|
DOUBLE_ECRAN = false;
|
|
|
|
OLD_SCROLL = 0;
|
2012-09-09 09:55:05 +00:00
|
|
|
MANU_SCROLL = 1;
|
|
|
|
SPEED_SCROLL = 16;
|
2012-09-09 10:10:32 +00:00
|
|
|
nbrligne2 = 0;
|
2012-09-09 09:55:05 +00:00
|
|
|
Agr_x = Agr_y = 0;
|
|
|
|
Agr_Flag_x = Agr_Flag_y = 0;
|
2012-09-10 10:26:24 +00:00
|
|
|
FADESPD = 15;
|
2012-09-15 00:27:15 +00:00
|
|
|
FADE_LINUX = 0;
|
|
|
|
NOLOCK = false;
|
2012-09-15 03:23:46 +00:00
|
|
|
no_scroll = 0;
|
2012-09-19 11:34:23 +00:00
|
|
|
REDRAW = false;
|
2012-09-20 10:54:03 +00:00
|
|
|
min_x = 0;
|
|
|
|
min_y = 20;
|
|
|
|
max_x = SCREEN_WIDTH * 2;
|
|
|
|
max_y = SCREEN_HEIGHT - 20 * 2;
|
|
|
|
clip_x = clip_y = 0;
|
|
|
|
clip_x1 = clip_y1 = 0;
|
|
|
|
clip_flag = false;
|
2012-09-20 13:30:28 +00:00
|
|
|
SDL_NBLOCS = 0;
|
2012-09-21 10:54:26 +00:00
|
|
|
Red_x = Red_y = 0;
|
|
|
|
Red = 0;
|
|
|
|
Largeur = 0;
|
|
|
|
Compteur_y = 0;
|
|
|
|
spec_largeur = 0;
|
2012-09-13 11:08:54 +00: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 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsManager::~GraphicsManager() {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_globals.dos_free2(VESA_SCREEN);
|
|
|
|
_vm->_globals.dos_free2(VESA_BUFFER);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 11:34:23 +00:00
|
|
|
void GraphicsManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
void GraphicsManager::SET_MODE(int width, int height) {
|
|
|
|
if (!SDL_MODEYES) {
|
|
|
|
SDL_ECHELLE = 0;
|
|
|
|
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XSETMODE == 1)
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_ECHELLE = 0;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XSETMODE == 2)
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_ECHELLE = 25;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XSETMODE == 3)
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_ECHELLE = 50;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XSETMODE == 4)
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_ECHELLE = 75;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XSETMODE == 5)
|
|
|
|
SDL_ECHELLE = _vm->_globals.XZOOM;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
int bpp = 8;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XFORCE8 == 1)
|
2012-09-09 09:55:05 +00:00
|
|
|
bpp = 8;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_globals.XFORCE16 == 1)
|
2012-09-09 09:55:05 +00:00
|
|
|
bpp = 16;
|
|
|
|
|
|
|
|
if (SDL_ECHELLE) {
|
2012-09-20 10:54:03 +00:00
|
|
|
width = Reel_Zoom(width, SDL_ECHELLE);
|
|
|
|
height = Reel_Zoom(height, SDL_ECHELLE);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
2012-09-09 10:28:04 +00:00
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
if (bpp == 8) {
|
|
|
|
initGraphics(width, height, true);
|
|
|
|
} else {
|
2012-09-09 10:28:04 +00:00
|
|
|
initGraphics(width, height, true, &pixelFormat16);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Init surfaces
|
2012-10-06 13:21:10 +00:00
|
|
|
VESA_SCREEN = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
|
|
|
VESA_BUFFER = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
VideoPtr = NULL;
|
|
|
|
XSCREEN = width;
|
|
|
|
YSCREEN = height;
|
|
|
|
|
|
|
|
Linear = true;
|
2012-09-13 11:08:54 +00:00
|
|
|
Winbpp = bpp / 8;
|
|
|
|
WinScan = width * Winbpp;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
PAL_PIXELS = SD_PIXELS;
|
|
|
|
nbrligne = width;
|
|
|
|
|
2012-09-09 11:15:09 +00:00
|
|
|
Common::fill(&cmap[0], &cmap[256 * 3], 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_MODEYES = true;
|
|
|
|
} else {
|
|
|
|
error("Called SET_MODE multiple times");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_Lock() {
|
2012-09-15 00:27:15 +00:00
|
|
|
if (!NOLOCK) {
|
|
|
|
if (_lockCtr++ == 0)
|
|
|
|
VideoPtr = g_system->lockScreen();
|
|
|
|
}
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_Unlock() {
|
2012-09-09 10:10:32 +00:00
|
|
|
assert(VideoPtr);
|
2012-09-13 11:08:54 +00:00
|
|
|
if (--_lockCtr == 0) {
|
|
|
|
g_system->unlockScreen();
|
|
|
|
VideoPtr = NULL;
|
|
|
|
}
|
2012-09-09 09:55:05 +00: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 10:28:04 +00:00
|
|
|
Common::String filename = Common::String::format("%s.PCX", file.c_str());
|
2012-09-09 09:55:05 +00:00
|
|
|
CHARGE_ECRAN(filename);
|
2012-09-21 21:48:21 +00:00
|
|
|
INIT_TABLE(165, 170, Palette);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::CHARGE_ECRAN(const Common::String &file) {
|
2012-09-09 11:15:09 +00:00
|
|
|
bool flag;
|
2012-09-09 09:55:05 +00:00
|
|
|
Common::File f;
|
|
|
|
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.DMESS1();
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-09-09 11:15:09 +00:00
|
|
|
flag = true;
|
2012-10-06 13:21:10 +00:00
|
|
|
if (_vm->_fileManager.RECHERCHE_CAT(file, 6)) {
|
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file);
|
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-09-09 09:55:05 +00:00
|
|
|
error("CHARGE_ECRAN - %s", file.c_str());
|
|
|
|
|
|
|
|
f.seek(0, SEEK_END);
|
|
|
|
f.close();
|
2012-09-09 11:15:09 +00:00
|
|
|
flag = false;
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SCROLL_ECRAN(0);
|
2012-09-15 00:27:15 +00:00
|
|
|
A_PCX640_480((byte *)VESA_SCREEN, file, Palette, flag);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
SCROLL = 0;
|
|
|
|
OLD_SCROLL = 0;
|
|
|
|
Cls_Pal();
|
|
|
|
|
|
|
|
if (!DOUBLE_ECRAN) {
|
|
|
|
souris_max();
|
|
|
|
SCANLINE(SCREEN_WIDTH);
|
2012-09-21 11:20:07 +00:00
|
|
|
max_x = SCREEN_WIDTH;
|
2012-09-09 09:55:05 +00:00
|
|
|
DD_Lock();
|
|
|
|
Cls_Video();
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
else
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
} else if (Winbpp == 1) {
|
|
|
|
if (!SDL_ECHELLE)
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
else
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
2012-09-09 11:15:09 +00:00
|
|
|
|
|
|
|
DD_Unlock();
|
2012-09-09 09:55:05 +00:00
|
|
|
} else {
|
2012-09-13 11:08:54 +00:00
|
|
|
SCANLINE(SCREEN_WIDTH * 2);
|
2012-09-21 11:20:07 +00:00
|
|
|
max_x = SCREEN_WIDTH * 2;
|
2012-09-09 09:55:05 +00:00
|
|
|
DD_Lock();
|
|
|
|
Cls_Video();
|
|
|
|
DD_Unlock();
|
|
|
|
|
|
|
|
if (MANU_SCROLL == 1) {
|
|
|
|
DD_Lock();
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
else
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
if (Winbpp == 1) {
|
|
|
|
if (!SDL_ECHELLE)
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
else
|
2012-09-20 10:54:03 +00:00
|
|
|
m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DD_Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
memcpy(VESA_BUFFER, VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
void GraphicsManager::INIT_TABLE(int a1, int a2, byte *palette) {
|
2012-09-09 09:55:05 +00:00
|
|
|
for (int idx = 0; idx < 256; ++idx)
|
|
|
|
TABLE_COUL[idx] = idx;
|
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
Trans_bloc(TABLE_COUL, palette, 256, a1, a2);
|
2012-09-09 09:55:05 +00: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);
|
2012-09-28 12:15:59 +00:00
|
|
|
_vm->_eventsManager.start_x = result;
|
2012-09-09 09:55:05 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) {
|
2012-09-30 11:02:39 +00:00
|
|
|
byte *dataP;
|
|
|
|
int count;
|
|
|
|
byte dataVal;
|
|
|
|
|
|
|
|
dataP = surface;
|
|
|
|
count = size - 1;
|
|
|
|
do {
|
|
|
|
dataVal = *dataP++;
|
|
|
|
*(dataP - 1) = *(dataVal + col);
|
|
|
|
--count;
|
|
|
|
} while (count);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
// TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder
|
2012-09-13 11:08:54 +00:00
|
|
|
void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) {
|
2012-09-09 09:55:05 +00:00
|
|
|
int filesize;
|
2012-09-30 11:21:09 +00:00
|
|
|
int v6;
|
2012-09-09 09:55:05 +00:00
|
|
|
int v7;
|
2012-09-30 11:21:09 +00:00
|
|
|
int v8;
|
2012-09-09 09:55:05 +00:00
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
int v11;
|
2012-09-30 11:21:09 +00:00
|
|
|
byte v12;
|
2012-09-09 09:55:05 +00:00
|
|
|
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) {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES");
|
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-09-09 09:55:05 +00:00
|
|
|
error("(nom)Erreur en cours de lecture.");
|
2012-10-06 13:21:10 +00:00
|
|
|
f.seek(_vm->_globals.CAT_POSI);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-10-06 13:21:10 +00:00
|
|
|
v7 = _vm->_globals.CAT_TAILLE - 896;
|
2012-09-09 09:55:05 +00:00
|
|
|
v8 = f.read(HEADER_PCX, 128);
|
|
|
|
|
2012-10-11 11:58:04 +00:00
|
|
|
v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
|
|
|
|
v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
|
|
|
|
if (((int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) {
|
2012-09-09 09:55:05 +00:00
|
|
|
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 {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file);
|
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-09-09 09:55:05 +00:00
|
|
|
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.");
|
|
|
|
|
2012-10-11 11:58:04 +00:00
|
|
|
v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
|
|
|
|
v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
|
2012-09-09 09:55:05 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-10-06 13:21:10 +00:00
|
|
|
ptr = _vm->_globals.dos_malloc2(0xEE60u);
|
2012-09-09 09:55:05 +00:00
|
|
|
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) {
|
2012-10-06 13:21:10 +00:00
|
|
|
f.seek(_vm->_globals.CAT_TAILLE + _vm->_globals.CAT_POSI - 768);
|
2012-09-09 09:55:05 +00:00
|
|
|
} else {
|
|
|
|
filesize = f.size();
|
|
|
|
f.seek(filesize - 768);
|
|
|
|
}
|
|
|
|
|
2012-09-10 10:26:24 +00:00
|
|
|
if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE))
|
2012-09-13 11:08:54 +00:00
|
|
|
error("A_PCX640_480");
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
f.close();
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_globals.dos_free2(ptr);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Cls_Pal() {
|
2012-09-13 11:08:54 +00:00
|
|
|
Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
|
|
|
|
SD_PIXELS[0] = 0;
|
2012-09-09 11:15:09 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
if (Winbpp == 1) {
|
2012-09-09 11:15:09 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(cmap, 0, 256);
|
|
|
|
}
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
2012-09-09 11:15:09 +00:00
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
void GraphicsManager::souris_max() {
|
2012-09-13 11:08:54 +00:00
|
|
|
// Original has no implementation
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
void GraphicsManager::SCANLINE(int pitch) {
|
|
|
|
nbrligne = nbrligne2 = pitch;
|
2012-09-09 09:55:05 +00: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);
|
2012-09-30 11:33:00 +00:00
|
|
|
v8 = v11 + v13 + WinScan - width;
|
|
|
|
v7 = v12 + v13 + nbrligne2 - width;
|
2012-09-09 09:55:05 +00:00
|
|
|
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);
|
2012-09-30 11:33:00 +00:00
|
|
|
v7 = xs + nbrligne2 * ys + surface;
|
|
|
|
v8 = destX + WinScan * destY + (byte *)VideoPtr->pixels;
|
2012-09-09 09:55:05 +00:00
|
|
|
v9 = WinScan - SCREEN_WIDTH;
|
|
|
|
v10 = nbrligne2 - SCREEN_WIDTH;
|
|
|
|
v11 = height;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(v8, v7, SCREEN_WIDTH);
|
2012-09-30 11:33:00 +00:00
|
|
|
v8 = v8 + v9 + SCREEN_WIDTH;
|
|
|
|
v7 = v7 + v10 + SCREEN_WIDTH;
|
2012-09-09 09:55:05 +00:00
|
|
|
--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;
|
2012-09-30 11:33:00 +00:00
|
|
|
byte *v8;
|
2012-09-09 09:55:05 +00:00
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
byte v11;
|
|
|
|
const byte *v12;
|
2012-09-30 11:33:00 +00:00
|
|
|
byte *v13;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
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 {
|
2012-09-30 11:33:00 +00:00
|
|
|
v11 = *v7;
|
|
|
|
*v8++ = *v7++;
|
2012-09-09 09:55:05 +00:00
|
|
|
Agr_x += SDL_ECHELLE;
|
|
|
|
if ((unsigned int)Agr_x >= 100) {
|
|
|
|
Agr_x -= 100;
|
2012-09-30 11:33:00 +00:00
|
|
|
*v8++ = v11;
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
--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 11:08:54 +00:00
|
|
|
/**
|
|
|
|
* Copies data from a 8-bit palette surface into the 16-bit screen
|
|
|
|
*/
|
2012-09-09 09:55:05 +00:00
|
|
|
void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
|
2012-09-13 11:08:54 +00:00
|
|
|
DD_Lock();
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
assert(VideoPtr);
|
2012-09-13 11:08:54 +00:00
|
|
|
const byte *srcP = xs + nbrligne2 * ys + surface;
|
|
|
|
uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destX * 2 + WinScan * destY);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 12:55:50 +00:00
|
|
|
*lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2];
|
2012-09-13 11:08:54 +00:00
|
|
|
|
|
|
|
// Move to the start of the next line
|
|
|
|
srcP += nbrligne2;
|
|
|
|
destP += WinScan / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
DD_Unlock();
|
2012-09-09 09:55:05 +00: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 {
|
2012-09-30 11:41:47 +00:00
|
|
|
v12 = *(uint16 *)(v11 + 2 * *v7);
|
2012-09-09 09:55:05 +00:00
|
|
|
*(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-20 13:30:28 +00:00
|
|
|
void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
byte v11;
|
|
|
|
byte *v12;
|
|
|
|
byte *v13;
|
|
|
|
byte *v14;
|
|
|
|
byte *v15;
|
|
|
|
const byte *v16;
|
|
|
|
int v17;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = xp + 320 * yp + surface;
|
|
|
|
v8 = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels;
|
|
|
|
v9 = height;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v17 = v9;
|
|
|
|
v10 = width;
|
|
|
|
v16 = v7;
|
|
|
|
v15 = v8;
|
|
|
|
do {
|
|
|
|
v11 = *v7;
|
|
|
|
*v8 = *v7;
|
|
|
|
v12 = WinScan + v8;
|
|
|
|
*v12 = v11;
|
|
|
|
v13 = v12 - WinScan + 1;
|
|
|
|
*v13 = v11;
|
|
|
|
v14 = WinScan + v13;
|
|
|
|
*v14 = v11;
|
|
|
|
++v7;
|
|
|
|
v8 = v14 - WinScan + 1;
|
|
|
|
--v10;
|
|
|
|
} while (v10);
|
|
|
|
|
|
|
|
v8 = WinScan + WinScan + v15;
|
|
|
|
v7 = v16 + 320;
|
|
|
|
v9 = v17 - 1;
|
|
|
|
} while (v17 != 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) {
|
|
|
|
const byte *v7;
|
|
|
|
uint16 *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
int v11;
|
|
|
|
const byte *v12;
|
|
|
|
uint16 *v13;
|
|
|
|
uint16 v14;
|
|
|
|
uint16 *v15;
|
|
|
|
int v16;
|
|
|
|
uint16 *v17;
|
|
|
|
const byte *v18;
|
|
|
|
int v19;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v7 = xp + 320 * yp + surface;
|
|
|
|
v8 = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels);
|
|
|
|
v9 = height;
|
|
|
|
v10 = width;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v19 = v9;
|
|
|
|
v11 = v10;
|
|
|
|
v18 = v7;
|
|
|
|
v17 = v8;
|
|
|
|
v16 = v10;
|
|
|
|
v12 = PAL_PIXELS;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v13 = (uint16 *)(v12 + 2 * *v7);
|
|
|
|
v14 = *v13;
|
|
|
|
*v8 = *v13;
|
|
|
|
*(v8 + 1) = v14;
|
|
|
|
|
|
|
|
v15 = (uint16 *)((byte *)v8 + WinScan);
|
|
|
|
*v15 = v14;
|
|
|
|
*(v15 + 1) = v14;
|
|
|
|
++v7;
|
|
|
|
v8 = (uint16 *)((byte *)v15 - WinScan + 4);
|
|
|
|
--v11;
|
|
|
|
} while (v11);
|
|
|
|
|
|
|
|
v10 = v16;
|
|
|
|
v8 = (uint16 *)((byte *)v17 + WinScan * 2);
|
|
|
|
v7 = v18 + 320;
|
|
|
|
v9 = v19 - 1;
|
|
|
|
} while (v19 != 1);
|
|
|
|
}
|
|
|
|
|
2012-09-10 10:26:24 +00:00
|
|
|
void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) {
|
2012-09-13 11:08:54 +00:00
|
|
|
uint16 palData1[PALETTE_BLOCK_SIZE * 2];
|
|
|
|
byte palData2[PALETTE_BLOCK_SIZE];
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 10:26:24 +00:00
|
|
|
}
|
2012-09-13 11:08:54 +00:00
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
setpal_vga256(palData2);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-13 11:08:54 +00:00
|
|
|
else
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-13 11:08:54 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
// Set the final palette
|
2012-09-10 10:26:24 +00:00
|
|
|
setpal_vga256(palette);
|
2012-09-13 11:08:54 +00:00
|
|
|
|
|
|
|
// Refresh the screen
|
2012-09-10 10:26:24 +00:00
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
else
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) {
|
2012-09-30 11:21:09 +00:00
|
|
|
int v3;
|
|
|
|
int v4;
|
2012-09-10 10:26:24 +00:00
|
|
|
int v5;
|
2012-09-30 11:21:09 +00:00
|
|
|
int v6;
|
|
|
|
int v7;
|
2012-09-10 10:26:24 +00:00
|
|
|
int v8;
|
2012-09-30 11:21:09 +00:00
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
int v12;
|
2012-09-20 10:54:03 +00:00
|
|
|
uint16 v13;
|
2012-09-10 10:26:24 +00:00
|
|
|
byte palData[PALETTE_BLOCK_SIZE];
|
2012-09-30 11:21:09 +00:00
|
|
|
int v15[PALETTE_BLOCK_SIZE];
|
2012-09-10 10:26:24 +00:00
|
|
|
|
|
|
|
v13 = v3 = FADESPD;
|
|
|
|
if (palette) {
|
|
|
|
v4 = 0;
|
|
|
|
do {
|
|
|
|
v5 = v4;
|
2012-09-30 11:33:00 +00:00
|
|
|
v3 = *(v4 + palette);
|
2012-09-10 10:26:24 +00:00
|
|
|
v3 <<= 8;
|
|
|
|
v15[v5] = v3;
|
2012-09-30 11:33:00 +00:00
|
|
|
palData[v5] = *(v4++ + palette);
|
2012-09-10 10:26:24 +00:00
|
|
|
} while (v4 < PALETTE_BLOCK_SIZE);
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
else
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
v6 = 0;
|
2012-09-30 11:21:09 +00:00
|
|
|
if ((int)v13 > 0) {
|
2012-09-10 10:26:24 +00:00
|
|
|
do {
|
|
|
|
v7 = 0;
|
|
|
|
do {
|
|
|
|
v8 = v7;
|
2012-09-30 11:33:00 +00:00
|
|
|
v9 = v15[v7] - (*(v7 + palette) << 8) / v13;
|
2012-09-10 10:26:24 +00:00
|
|
|
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-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
else
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
|
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
++v6;
|
2012-09-30 11:21:09 +00:00
|
|
|
} while ((int)v13 > v6);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v10 = 0;
|
|
|
|
do {
|
|
|
|
palData[v10++] = 0;
|
|
|
|
} while (v10 < (PALETTE_BLOCK_SIZE));
|
|
|
|
|
|
|
|
setpal_vga256(palData);
|
|
|
|
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (!SDL_ECHELLE) {
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00: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-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
return DD_VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
LABEL_28:
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
return DD_VBL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INS() {
|
|
|
|
FADESPD = 1;
|
2012-09-15 00:27:15 +00:00
|
|
|
fade_in(Palette, 1, (const byte *)VESA_BUFFER);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTS() {
|
|
|
|
FADESPD = 1;
|
2012-09-15 00:27:15 +00:00
|
|
|
fade_out(Palette, 1, (const byte *)VESA_BUFFER);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INW() {
|
|
|
|
FADESPD = 15;
|
2012-09-15 00:27:15 +00:00
|
|
|
fade_in(Palette, 20, (const byte *)VESA_BUFFER);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTW() {
|
|
|
|
FADESPD = 15;
|
2012-09-15 00:27:15 +00:00
|
|
|
fade_out(Palette, 20, (const byte *)VESA_BUFFER);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::setpal_vga256(const byte *palette) {
|
|
|
|
CHANGE_PALETTE(palette);
|
|
|
|
}
|
|
|
|
|
2012-09-15 03:23:46 +00:00
|
|
|
void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) {
|
2012-09-20 10:54:03 +00:00
|
|
|
CHANGE_PALETTE(palette);
|
|
|
|
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-20 10:54:03 +00:00
|
|
|
else
|
2012-09-28 12:15:59 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-20 10:54:03 +00:00
|
|
|
|
|
|
|
DD_VBL();
|
|
|
|
}
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 23:33:42 +00:00
|
|
|
void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) {
|
|
|
|
_vm->_graphicsManager.Palette[palIndex * 3] = 255 * r / 100;
|
|
|
|
_vm->_graphicsManager.Palette[palIndex * 3 + 1] = 255 * g / 100;
|
|
|
|
_vm->_graphicsManager.Palette[palIndex * 3 + 2] = 255 * b / 100;
|
|
|
|
|
|
|
|
setpal_vga256(Palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::SETCOLOR2(int palIndex, int r, int g, int b) {
|
|
|
|
return SETCOLOR(palIndex, r, g, b);
|
|
|
|
}
|
|
|
|
|
2012-09-15 03:23:46 +00:00
|
|
|
void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) {
|
2012-09-28 23:33:42 +00:00
|
|
|
Palette[palIndex * 3] = 255 * r / 100;
|
|
|
|
Palette[palIndex * 3 + 1] = 255 * g / 100;
|
|
|
|
Palette[palIndex * 3 + 2] = 255 * b / 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) {
|
|
|
|
int rv, gv, bv;
|
|
|
|
int palOffset;
|
|
|
|
int v8;
|
|
|
|
|
|
|
|
rv = 255 * r / 100;
|
|
|
|
gv = 255 * g / 100;
|
|
|
|
bv = 255 * b / 100;
|
|
|
|
palOffset = 3 * palIndex;
|
|
|
|
Palette[palOffset] = 255 * r / 100;
|
|
|
|
Palette[palOffset + 1] = gv;
|
|
|
|
Palette[palOffset + 2] = bv;
|
|
|
|
|
|
|
|
v8 = 4 * palIndex;
|
|
|
|
cmap[v8] = rv;
|
|
|
|
cmap[v8 + 1] = gv;
|
|
|
|
cmap[v8 + 2] = bv;
|
|
|
|
|
|
|
|
WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv));
|
2012-10-10 11:33:44 +00:00
|
|
|
|
|
|
|
if (Winbpp == 1)
|
|
|
|
g_system->getPaletteManager()->setPalette(cmap, palIndex, 1);
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 10:26:24 +00:00
|
|
|
void GraphicsManager::CHANGE_PALETTE(const byte *palette) {
|
2012-09-13 11:08:54 +00: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) {
|
|
|
|
*(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2));
|
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
if (Winbpp == 1)
|
|
|
|
g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE);
|
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00: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 10:26:24 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
return (r >> format.rLoss) << format.rShift
|
|
|
|
| (g >> format.gLoss) << format.gShift
|
|
|
|
| (b >> format.bLoss) << format.bShift;
|
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::DD_VBL() {
|
|
|
|
// TODO: Is this okay here?
|
|
|
|
g_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
2012-09-15 00:27:15 +00:00
|
|
|
void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) {
|
2012-09-20 10:54:03 +00:00
|
|
|
fade_out(Palette, FADESPD, surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INW_LINUX(const byte *surface) {
|
|
|
|
return fade_in(Palette, FADESPD, surface);
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_WinScan_Vbe3(const byte *sourceSurface, byte *destSurface) {
|
2012-09-20 10:54:03 +00:00
|
|
|
int result;
|
|
|
|
int v3;
|
|
|
|
int v4;
|
|
|
|
const byte *v5;
|
|
|
|
uint8 v6;
|
|
|
|
int v7;
|
|
|
|
unsigned int v8;
|
|
|
|
byte *v9;
|
|
|
|
int v10;
|
|
|
|
unsigned int v11;
|
|
|
|
byte *v12;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
v3 = 0;
|
|
|
|
v4 = 0;
|
|
|
|
v5 = sourceSurface;
|
|
|
|
for (;;) {
|
|
|
|
v6 = *v5;
|
2012-09-30 11:33:00 +00:00
|
|
|
if (*v5 < 222)
|
2012-09-20 10:54:03 +00:00
|
|
|
goto Video_Cont3_wVbe;
|
|
|
|
|
|
|
|
if (v6 == 252)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (v6 < 251) {
|
2012-09-30 11:33:00 +00:00
|
|
|
v3 += *v5 + 35;
|
2012-09-20 10:54:03 +00:00
|
|
|
v6 = *(v5++ + 1);
|
|
|
|
} else if (v6 == 253) {
|
|
|
|
v3 += *(v5 + 1);
|
|
|
|
v6 = *(v5 + 2);
|
|
|
|
v5 += 2;
|
|
|
|
} else if (v6 == 254) {
|
2012-10-11 11:58:04 +00:00
|
|
|
v3 += (int16)READ_LE_UINT16(v5 + 1);
|
2012-09-20 10:54:03 +00:00
|
|
|
v6 = *(v5 + 3);
|
|
|
|
v5 += 3;
|
|
|
|
} else {
|
|
|
|
v3 += READ_LE_UINT32(v5 + 1);
|
|
|
|
v6 = *(v5 + 5);
|
|
|
|
v5 += 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
Video_Cont3_wVbe:
|
|
|
|
if (v6 > 210) {
|
|
|
|
if (v6 == 211) {
|
|
|
|
v7 = v4;
|
|
|
|
v8 = *(v5 + 1);
|
|
|
|
result = *(v5 + 2);
|
|
|
|
v9 = v3 + destSurface;
|
|
|
|
v3 += v8;
|
|
|
|
memset(v9, result, v8);
|
|
|
|
v5 += 3;
|
|
|
|
v4 = v7;
|
|
|
|
} else {
|
|
|
|
v10 = v4;
|
|
|
|
v11 = *v5 + 45;
|
|
|
|
result = *(v5 + 1);
|
|
|
|
v12 = v3 + destSurface;
|
|
|
|
v3 += v11;
|
|
|
|
memset(v12, result, v11);
|
|
|
|
v5 += 2;
|
|
|
|
v4 = v10;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*(v3 + destSurface) = v6;
|
|
|
|
++v5;
|
|
|
|
++v3;
|
|
|
|
}
|
|
|
|
}
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 02:04:05 +00:00
|
|
|
void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) {
|
2012-09-20 12:23:07 +00:00
|
|
|
int result;
|
|
|
|
int v2;
|
|
|
|
int v3;
|
|
|
|
const byte *v4;
|
|
|
|
uint8 v5;
|
|
|
|
int v6;
|
|
|
|
unsigned int v7;
|
|
|
|
byte *v8;
|
|
|
|
int v9;
|
|
|
|
unsigned int v10;
|
|
|
|
byte *v11;
|
2012-09-20 10:54:03 +00:00
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
result = 0;
|
|
|
|
v2 = 0;
|
|
|
|
v3 = 0;
|
2012-10-13 02:04:05 +00:00
|
|
|
v4 = srcData;
|
2012-09-20 10:54:03 +00:00
|
|
|
for (;;) {
|
|
|
|
v5 = *v4;
|
|
|
|
if (*v4 < 222)
|
|
|
|
goto Video_Cont3_Vbe;
|
|
|
|
|
|
|
|
if (v5 == 252)
|
|
|
|
return;
|
|
|
|
if (v5 < 251) {
|
2012-09-30 11:33:00 +00:00
|
|
|
v2 += *v4 + 35;
|
2012-09-20 10:54:03 +00:00
|
|
|
v5 = *(v4++ + 1);
|
2012-09-30 11:41:47 +00:00
|
|
|
} else if (v5 == (byte)-3) {
|
2012-09-20 10:54:03 +00:00
|
|
|
v2 += *(v4 + 1);
|
|
|
|
v5 = *(v4 + 2);
|
|
|
|
v4 += 2;
|
2012-09-30 11:41:47 +00:00
|
|
|
} else if (v5 == (byte)-2) {
|
2012-10-13 02:04:05 +00:00
|
|
|
v2 += READ_LE_UINT16(v4 + 1);
|
2012-09-20 10:54:03 +00:00
|
|
|
v5 = *(v4 + 3);
|
|
|
|
v4 += 3;
|
|
|
|
} else {
|
|
|
|
v2 += READ_LE_UINT32(v4 + 1);
|
|
|
|
v5 = *(v4 + 5);
|
|
|
|
v4 += 5;
|
|
|
|
}
|
|
|
|
Video_Cont3_Vbe:
|
|
|
|
if (v5 > 210) {
|
|
|
|
if (v5 == 211) {
|
|
|
|
v6 = v3;
|
|
|
|
v7 = *(v4 + 1);
|
|
|
|
result = *(v4 + 2);
|
|
|
|
v8 = v2 + (byte *)VideoPtr->pixels;
|
|
|
|
v2 += v7;
|
|
|
|
memset(v8, result, v7);
|
|
|
|
v4 += 3;
|
|
|
|
v3 = v6;
|
|
|
|
} else {
|
|
|
|
v9 = v3;
|
2012-09-30 11:21:09 +00:00
|
|
|
v10 = (byte)(*v4 + 45);
|
2012-09-20 10:54:03 +00:00
|
|
|
result = *(v4 + 1);
|
|
|
|
v11 = (byte *)(v2 + (byte *)VideoPtr->pixels);
|
|
|
|
v2 += v10;
|
|
|
|
memset(v11, result, v10);
|
|
|
|
v4 += 2;
|
|
|
|
v3 = v9;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*(v2 + (byte *)VideoPtr->pixels) = v5;
|
|
|
|
++v4;
|
|
|
|
++v2;
|
|
|
|
}
|
|
|
|
}
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-13 02:04:05 +00:00
|
|
|
void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) {
|
|
|
|
const byte *srcP = srcData;
|
2012-09-15 11:42:20 +00:00
|
|
|
int destOffset = 0;
|
|
|
|
assert(VideoPtr);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
byte srcByte = *srcP;
|
|
|
|
if (srcByte >= 222) {
|
|
|
|
if (srcByte == 252)
|
|
|
|
return;
|
|
|
|
if (srcByte < 251) {
|
|
|
|
destOffset += srcByte - 221;
|
|
|
|
srcByte = *++srcP;
|
|
|
|
} else if (srcByte == 253) {
|
|
|
|
destOffset += *(const byte *)(srcP + 1);
|
|
|
|
srcByte = *(const byte *)(srcP + 2);
|
|
|
|
srcP += 2;
|
|
|
|
} else if (srcByte == 254) {
|
2012-10-13 02:04:05 +00:00
|
|
|
destOffset += READ_LE_UINT16(srcP + 1);
|
2012-09-15 11:42:20 +00:00
|
|
|
srcByte = *(const byte *)(srcP + 3);
|
|
|
|
srcP += 3;
|
|
|
|
} else {
|
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
srcByte = *(const byte *)(srcP + 5);
|
|
|
|
srcP += 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (srcByte > 210) {
|
|
|
|
if (srcByte == 211) {
|
|
|
|
int pixelCount = *(srcP + 1);
|
|
|
|
int pixelIndex = *(srcP + 2);
|
|
|
|
uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2);
|
|
|
|
uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
|
|
|
|
destOffset += pixelCount;
|
|
|
|
|
|
|
|
while (pixelCount--)
|
|
|
|
*destP++ = pixelValue;
|
|
|
|
|
|
|
|
srcP += 3;
|
|
|
|
} else {
|
|
|
|
int pixelCount = srcByte - 211;
|
|
|
|
int pixelIndex = *(srcP + 1);
|
|
|
|
uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2);
|
|
|
|
uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
|
|
|
|
destOffset += pixelCount;
|
|
|
|
|
|
|
|
while (pixelCount--)
|
|
|
|
*destP++ = pixelValue;
|
|
|
|
|
|
|
|
srcP += 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
*((uint16 *)VideoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte);
|
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
|
|
|
}
|
|
|
|
}
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-10-13 02:04:05 +00:00
|
|
|
void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) {
|
2012-10-04 22:09:09 +00:00
|
|
|
int v2;
|
|
|
|
const byte *v3;
|
|
|
|
unsigned __int8 v4;
|
|
|
|
|
|
|
|
v2 = 0;
|
2012-10-13 02:04:05 +00:00
|
|
|
v3 = srcData;
|
2012-10-04 22:09:09 +00:00
|
|
|
for (;;) {
|
|
|
|
v4 = *v3;
|
|
|
|
if (*v3 < 0xFCu)
|
|
|
|
goto Video_Cont_Vbe16a;
|
|
|
|
if (v4 == -4)
|
|
|
|
return;
|
|
|
|
if (v4 == -3) {
|
|
|
|
v2 += *(v3 + 1);
|
|
|
|
v4 = *(v3 + 2);
|
|
|
|
v3 += 2;
|
|
|
|
} else if (v4 == -2) {
|
2012-10-13 02:04:05 +00:00
|
|
|
v2 += READ_LE_UINT16(v3 + 1);
|
2012-10-04 22:09:09 +00:00
|
|
|
v4 = *(v3 + 3);
|
|
|
|
v3 += 3;
|
|
|
|
} else {
|
|
|
|
v2 += READ_LE_UINT32(v3 + 1);
|
|
|
|
v4 = *(v3 + 5);
|
|
|
|
v3 += 5;
|
|
|
|
}
|
|
|
|
Video_Cont_Vbe16a:
|
2012-10-13 02:04:05 +00:00
|
|
|
WRITE_LE_UINT16(v2 + v2 + VideoPtr, READ_LE_UINT16(PAL_PIXELS + 2 * v4));
|
2012-10-04 22:09:09 +00:00
|
|
|
++v3;
|
|
|
|
++v2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, unsigned int width, int height) {
|
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
|
|
|
int yCtr;
|
|
|
|
unsigned int i;
|
|
|
|
int yTemp;
|
|
|
|
|
|
|
|
srcP = srcSurface + xs + nbrligne2 * ys;
|
|
|
|
destP = destSurface;
|
|
|
|
|
|
|
|
yCtr = height;
|
|
|
|
do {
|
|
|
|
yTemp = yCtr;
|
|
|
|
if (width & 1) {
|
|
|
|
memcpy(destP, srcP, width);
|
|
|
|
srcP += width;
|
|
|
|
destP += width;
|
|
|
|
} else if (width & 2) {
|
|
|
|
for (i = width >> 1; i; --i) {
|
|
|
|
*(uint16 *)destP = *(uint16 *)srcP;
|
|
|
|
srcP += 2;
|
|
|
|
destP = (byte *)destP + 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memcpy(destP, srcP, 4 * (width >> 2));
|
|
|
|
srcP += 4 * (width >> 2);
|
|
|
|
destP = (byte *)destP + 4 * (width >> 2);
|
|
|
|
}
|
|
|
|
srcP = nbrligne2 + srcP - width;
|
|
|
|
yCtr = yTemp - 1;
|
|
|
|
} while (yTemp != 1);
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 21:48:21 +00:00
|
|
|
void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) {
|
|
|
|
// Get a pointer to the start of the desired sprite
|
|
|
|
const byte *spriteP = spriteData + 3;
|
|
|
|
for (int i = spriteIndex; i; --i)
|
|
|
|
spriteP += READ_LE_UINT32(spriteP) + 16;
|
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
clip_x = 0;
|
|
|
|
clip_y = 0;
|
|
|
|
clip_flag = false;
|
2012-09-21 21:48:21 +00:00
|
|
|
|
|
|
|
spriteP += 4;
|
2012-10-13 02:04:05 +00:00
|
|
|
int width = READ_LE_UINT16(spriteP);
|
2012-09-21 21:48:21 +00:00
|
|
|
spriteP += 2;
|
2012-10-13 02:04:05 +00:00
|
|
|
int height = READ_LE_UINT16(spriteP);
|
2012-09-21 21:48:21 +00:00
|
|
|
|
|
|
|
// Clip X
|
|
|
|
clip_x1 = width;
|
|
|
|
if ((xp + width) <= (min_x + 300))
|
|
|
|
return;
|
|
|
|
if (xp < (min_x + 300)) {
|
|
|
|
clip_x = min_x + 300 - xp;
|
|
|
|
clip_flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clip Y
|
|
|
|
// TODO: This is weird, but it's that way in the original. Original game bug?
|
|
|
|
if ((yp + height) <= height)
|
|
|
|
return;
|
|
|
|
if (yp < (min_y + 300)) {
|
|
|
|
clip_y = min_y + 300 - yp;
|
|
|
|
clip_flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clip X1
|
|
|
|
if (xp >= (max_x + 300))
|
|
|
|
return;
|
|
|
|
if ((xp + width) > (max_x + 300)) {
|
|
|
|
int xAmount = width + 10 - (xp + width - (max_x + 300));
|
|
|
|
if (xAmount <= 10)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clip_x1 = xAmount - 10;
|
|
|
|
clip_flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clip Y1
|
|
|
|
if (yp >= (max_y + 300))
|
|
|
|
return;
|
|
|
|
if ((yp + height) > (max_y + 300)) {
|
|
|
|
int yAmount = height + 10 - (yp + height - (max_y + 300));
|
|
|
|
if (yAmount <= 10)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clip_y1 = yAmount - 10;
|
|
|
|
clip_flag = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sprite display
|
|
|
|
|
|
|
|
// Set up source
|
|
|
|
spriteP += 6;
|
2012-10-13 02:04:05 +00:00
|
|
|
int srcOffset = READ_LE_UINT16(spriteP);
|
2012-09-21 21:48:21 +00:00
|
|
|
spriteP += 4;
|
|
|
|
const byte *srcP = spriteP;
|
|
|
|
spriteP += srcOffset;
|
|
|
|
|
|
|
|
// Set up surface destination
|
|
|
|
byte *destP = surface + (yp - 300) * nbrligne2 + (xp - 300);
|
|
|
|
|
|
|
|
// Handling for clipped versus non-clipped
|
|
|
|
if (clip_flag) {
|
|
|
|
// Clipped version
|
|
|
|
for (int yc = 0; yc < height; ++yc, destP += nbrligne2) {
|
|
|
|
byte *tempDestP = destP;
|
|
|
|
byte byteVal;
|
|
|
|
int xc = 0;
|
|
|
|
|
|
|
|
while ((byteVal = *srcP) != 253) {
|
|
|
|
++srcP;
|
2012-10-13 02:04:05 +00:00
|
|
|
width = READ_LE_UINT16(srcP);
|
2012-09-23 01:25:21 +00:00
|
|
|
srcP += 2;
|
2012-09-21 21:48:21 +00:00
|
|
|
|
2012-09-23 01:25:21 +00:00
|
|
|
if (byteVal == 254) {
|
|
|
|
// Copy pixel range
|
|
|
|
for (int xv = 0; xv < width; ++xv, ++xc, ++spriteP, ++tempDestP) {
|
2012-09-21 21:48:21 +00:00
|
|
|
if (clip_y == 0 && xc >= clip_x && xc < clip_x1)
|
2012-09-23 01:25:21 +00:00
|
|
|
*tempDestP = *spriteP;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-09-23 01:25:21 +00:00
|
|
|
} else {
|
|
|
|
// Skip over bytes
|
|
|
|
tempDestP += width;
|
|
|
|
xc += width;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-09-21 21:48:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (clip_y > 0)
|
|
|
|
--clip_y;
|
|
|
|
srcP += 3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Non-clipped
|
|
|
|
for (int yc = 0; yc < height; ++yc, destP += nbrligne2) {
|
|
|
|
byte *tempDestP = destP;
|
|
|
|
byte byteVal;
|
|
|
|
|
|
|
|
while ((byteVal = *srcP) != 253) {
|
|
|
|
++srcP;
|
2012-10-13 02:04:05 +00:00
|
|
|
width = READ_LE_UINT16(srcP);
|
2012-09-21 21:48:21 +00:00
|
|
|
srcP += 2;
|
|
|
|
|
|
|
|
if (byteVal == 254) {
|
|
|
|
// Copy pixel range
|
|
|
|
Common::copy(spriteP, spriteP + width, tempDestP);
|
|
|
|
spriteP += width;
|
|
|
|
}
|
|
|
|
|
|
|
|
tempDestP += width;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-09-21 21:48:21 +00:00
|
|
|
|
|
|
|
// Skip over control byte and width
|
|
|
|
srcP += 3;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-15 03:23:46 +00:00
|
|
|
void GraphicsManager::FIN_VISU() {
|
2012-09-20 12:02:55 +00:00
|
|
|
for (int idx = 1; idx <= 20; ++idx) {
|
|
|
|
if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
|
|
|
|
_vm->_objectsManager.BOB_OFF(idx);
|
|
|
|
}
|
|
|
|
|
2012-09-23 00:59:52 +00:00
|
|
|
_vm->_eventsManager.VBL();
|
|
|
|
_vm->_eventsManager.VBL();
|
2012-09-20 12:02:55 +00:00
|
|
|
|
|
|
|
for (int idx = 1; idx <= 20; ++idx) {
|
|
|
|
if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
|
|
|
|
_vm->_objectsManager.BOB_ZERO(idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 1; idx <= 29; ++idx) {
|
|
|
|
_vm->_globals.BL_ANIM[idx].v1 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 1; idx <= 20; ++idx) {
|
|
|
|
_vm->_globals.Bqe_Anim[idx].field4 = 0;
|
|
|
|
}
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::VISU_ALL() {
|
2012-09-20 12:02:55 +00:00
|
|
|
for (int idx = 1; idx <= 20; ++idx) {
|
|
|
|
if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
|
|
|
|
_vm->_objectsManager.BOB_VISU(idx);
|
|
|
|
}
|
2012-09-15 03:23:46 +00:00
|
|
|
}
|
|
|
|
|
2012-09-17 06:53:21 +00:00
|
|
|
void GraphicsManager::RESET_SEGMENT_VESA() {
|
2012-09-20 12:23:07 +00:00
|
|
|
int v1;
|
|
|
|
int v2;
|
|
|
|
|
|
|
|
if (_vm->_globals.NBBLOC > 0) {
|
|
|
|
v1 = 0;
|
|
|
|
v2 = _vm->_globals.NBBLOC;
|
|
|
|
do {
|
|
|
|
_vm->_globals.BLOC[v1++].field0 = 0;
|
|
|
|
} while (v1 != v2);
|
|
|
|
|
|
|
|
_vm->_globals.NBBLOC = 0;
|
|
|
|
}
|
2012-09-17 06:53:21 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 12:23:07 +00:00
|
|
|
void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) {
|
|
|
|
int v4;
|
|
|
|
int v5;
|
|
|
|
int16 v6;
|
|
|
|
int16 v10;
|
|
|
|
|
|
|
|
v4 = x1;
|
|
|
|
v10 = 1;
|
|
|
|
if (x2 > max_x)
|
|
|
|
x2 = max_x;
|
|
|
|
if (y2 > max_y)
|
|
|
|
y2 = max_y;
|
|
|
|
if (x1 < min_x)
|
|
|
|
v4 = min_x;
|
|
|
|
if (y1 < min_y)
|
|
|
|
y1 = min_y;
|
|
|
|
|
|
|
|
v5 = _vm->_globals.NBBLOC;
|
|
|
|
if (_vm->_globals.NBBLOC > 1) {
|
|
|
|
|
|
|
|
v6 = 0;
|
|
|
|
do {
|
|
|
|
BlocItem &bloc = _vm->_globals.BLOC[v6];
|
|
|
|
|
|
|
|
if (bloc.field0 == 1
|
|
|
|
&& v4 >= bloc.x1 && x2 <= bloc.x2
|
|
|
|
&& y1 >= bloc.y1 && y2 <= bloc.y2)
|
|
|
|
v10 = 0;
|
|
|
|
++v6;
|
|
|
|
v5 = v6;
|
|
|
|
} while (_vm->_globals.NBBLOC + 1 != v6);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v10 == 1) {
|
|
|
|
BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC];
|
|
|
|
|
|
|
|
bloc.field0 = 1;
|
|
|
|
bloc.x1 = v4;
|
|
|
|
bloc.x2 = x2;
|
|
|
|
bloc.y1 = y1;
|
|
|
|
bloc.y2 = y2;
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int GraphicsManager::Magic_Number(signed int v) {
|
|
|
|
int result = v;
|
|
|
|
|
|
|
|
if (!v)
|
|
|
|
result = 4;
|
|
|
|
if (result & 1)
|
|
|
|
++result;
|
|
|
|
if (result & 2)
|
|
|
|
result += 2;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Affiche_Segment_Vesa() {
|
2012-09-20 13:30:28 +00:00
|
|
|
if (_vm->_globals.NBBLOC == 0)
|
|
|
|
return;
|
|
|
|
|
2012-09-21 11:20:07 +00:00
|
|
|
SDL_NBLOCS = _vm->_globals.NBBLOC;
|
2012-09-20 13:30:28 +00:00
|
|
|
|
|
|
|
for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) {
|
|
|
|
BlocItem &bloc = _vm->_globals.BLOC[idx];
|
|
|
|
Common::Rect &dstRect = dstrect[idx - 1];
|
|
|
|
if (bloc.field0 != 1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (_vm->_eventsManager.CASSE != 0) {
|
|
|
|
if (Winbpp == 1) {
|
|
|
|
Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1);
|
|
|
|
} else if (Winbpp == 2) {
|
|
|
|
Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
dstRect.left = bloc.x1 * 2;
|
|
|
|
dstRect.top = bloc.y1 * 2 + 30;
|
|
|
|
dstRect.setWidth((bloc.x2 - bloc.x1) * 2);
|
|
|
|
dstRect.setHeight((bloc.y2 - bloc.y1) * 2);
|
2012-09-28 12:15:59 +00:00
|
|
|
} else if (bloc.x2 > _vm->_eventsManager.start_x && bloc.x1 < (_vm->_eventsManager.start_x + SCREEN_WIDTH)) {
|
|
|
|
if (bloc.x1 < _vm->_eventsManager.start_x)
|
|
|
|
bloc.x1 = _vm->_eventsManager.start_x;
|
|
|
|
if (bloc.x2 > (_vm->_eventsManager.start_x + SCREEN_WIDTH))
|
|
|
|
bloc.x2 = _vm->_eventsManager.start_x + SCREEN_WIDTH;
|
2012-09-20 13:30:28 +00:00
|
|
|
|
|
|
|
if (!SDL_ECHELLE) {
|
|
|
|
// Calculate the bounds
|
|
|
|
int xp = Magic_Number(bloc.x1) - 4;
|
2012-09-28 12:15:59 +00:00
|
|
|
if (xp < _vm->_eventsManager.start_x)
|
|
|
|
xp = _vm->_eventsManager.start_x;
|
2012-09-20 13:30:28 +00:00
|
|
|
int yp = Magic_Number(bloc.y1) - 4;
|
|
|
|
if (yp < 0)
|
|
|
|
yp = 0;
|
|
|
|
int width = Magic_Number(bloc.x2) + 4 - xp;
|
|
|
|
if (width < 4)
|
|
|
|
width = 4;
|
|
|
|
int height = Magic_Number(bloc.y2) + 4 - yp;
|
|
|
|
if (height < 4)
|
|
|
|
height = 4;
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
if ((xp - _vm->_eventsManager.start_x + width) > SCREEN_WIDTH)
|
2012-09-20 13:30:28 +00:00
|
|
|
xp -= 4;
|
|
|
|
if ((height - yp) > (SCREEN_HEIGHT - 40))
|
|
|
|
yp -= 4;
|
|
|
|
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
m_scroll16A(VESA_BUFFER, xp, yp, width, height,
|
2012-09-28 12:15:59 +00:00
|
|
|
Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
|
2012-09-20 13:30:28 +00:00
|
|
|
} else {
|
|
|
|
m_scroll2A(VESA_BUFFER, xp, yp, width, height,
|
2012-09-28 12:15:59 +00:00
|
|
|
Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
|
2012-09-20 13:30:28 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
dstRect.left = Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE);
|
2012-09-20 13:30:28 +00:00
|
|
|
dstRect.top = Reel_Zoom(yp, SDL_ECHELLE);
|
|
|
|
dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE));
|
|
|
|
dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE));
|
|
|
|
} else {
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1,
|
2012-09-28 12:15:59 +00:00
|
|
|
bloc.x1 - _vm->_eventsManager.start_x, bloc.y1);
|
2012-09-20 13:30:28 +00:00
|
|
|
} else {
|
|
|
|
m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1,
|
2012-09-28 12:15:59 +00:00
|
|
|
bloc.x1 - _vm->_eventsManager.start_x, bloc.y1);
|
2012-09-20 13:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->_globals.BLOC[idx].field0 = 0;
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::CopyAsm(const byte *surface) {
|
2012-09-20 10:54:03 +00:00
|
|
|
const byte *v1;
|
|
|
|
byte srcByte;
|
|
|
|
byte *v3;
|
|
|
|
signed int v4;
|
|
|
|
signed int v5;
|
|
|
|
byte *v6;
|
|
|
|
byte *v7;
|
|
|
|
byte *v8;
|
|
|
|
byte *v9;
|
|
|
|
const byte *v10;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
v1 = surface;
|
|
|
|
srcByte = 30 * WinScan;
|
|
|
|
v3 = (byte *)VideoPtr->pixels + 30 * WinScan;
|
|
|
|
v4 = 200;
|
|
|
|
do {
|
|
|
|
v10 = v1;
|
|
|
|
v9 = v3;
|
|
|
|
v5 = 320;
|
|
|
|
|
|
|
|
do {
|
2012-09-30 11:33:00 +00:00
|
|
|
srcByte = *v1;
|
|
|
|
*v3 = *v1;
|
2012-09-20 10:54:03 +00:00
|
|
|
v6 = WinScan + v3;
|
2012-09-30 11:33:00 +00:00
|
|
|
*v6 = srcByte;
|
2012-09-20 10:54:03 +00:00
|
|
|
v7 = v6 - WinScan + 1;
|
2012-09-30 11:33:00 +00:00
|
|
|
*v7 = srcByte;
|
2012-09-20 10:54:03 +00:00
|
|
|
v8 = WinScan + v7;
|
2012-09-30 11:33:00 +00:00
|
|
|
*v8 = srcByte;
|
2012-09-20 10:54:03 +00:00
|
|
|
v3 = v8 - WinScan + 1;
|
|
|
|
++v1;
|
|
|
|
--v5;
|
|
|
|
} while (v5);
|
|
|
|
|
|
|
|
v1 = v10 + 320;
|
|
|
|
v3 = WinScan + WinScan + v9;
|
|
|
|
--v4;
|
|
|
|
} while (v4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Restore_Mem(byte *a1, const byte *a2, int a3, int a4, unsigned int a5, int a6) {
|
|
|
|
byte *v6;
|
|
|
|
int v7;
|
|
|
|
const byte *v8;
|
|
|
|
unsigned int i;
|
|
|
|
int v10;
|
|
|
|
|
|
|
|
v6 = a3 + nbrligne2 * a4 + a1;
|
|
|
|
v7 = a6;
|
|
|
|
v8 = a2;
|
|
|
|
do {
|
|
|
|
v10 = v7;
|
|
|
|
if (a5 & 1) {
|
|
|
|
memcpy(v6, v8, a5);
|
|
|
|
v8 += a5;
|
|
|
|
v6 += a5;
|
|
|
|
} else if (a5 & 2) {
|
|
|
|
for (i = a5 >> 1; i; --i) {
|
|
|
|
*(uint16 *)v6 = *(uint16 *)v8;
|
|
|
|
v8 += 2;
|
|
|
|
v6 += 2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memcpy(v6, v8, 4 * (a5 >> 2));
|
|
|
|
v8 += 4 * (a5 >> 2);
|
|
|
|
v6 += 4 * (a5 >> 2);
|
|
|
|
}
|
|
|
|
v6 = nbrligne2 + v6 - a5;
|
|
|
|
v7 = v10 - 1;
|
|
|
|
} while (v10 != 1);
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
int GraphicsManager::Reel_Zoom(int v, int percentage) {
|
|
|
|
return Asm_Zoom(v, percentage);
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
int GraphicsManager::Asm_Zoom(int v, int percentage) {
|
|
|
|
if (v)
|
|
|
|
v += percentage * (long int)v / 100;
|
|
|
|
|
|
|
|
return v;
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 10:54:26 +00:00
|
|
|
int GraphicsManager::Reel_Reduc(int v, int percentage) {
|
|
|
|
return Asm_Reduc(v, percentage);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GraphicsManager::Asm_Reduc(int v, int percentage) {
|
|
|
|
if (v)
|
|
|
|
v -= percentage * (long int)v / 100;
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2012-10-12 23:23:33 +00:00
|
|
|
void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int spriteIndex, int a6, int a7, int a8) {
|
2012-09-21 10:54:26 +00:00
|
|
|
const byte *v8;
|
|
|
|
int i;
|
2012-10-12 23:23:33 +00:00
|
|
|
const byte *v10;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v11;
|
|
|
|
int v12;
|
|
|
|
const byte *v13;
|
|
|
|
byte *v14;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v15;
|
2012-09-21 10:54:26 +00:00
|
|
|
byte *v16;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v17;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v18;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v19;
|
|
|
|
int v20;
|
|
|
|
int v21 = 0;
|
|
|
|
int v22;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v23;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v24;
|
|
|
|
int v25;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v26;
|
|
|
|
int v27;
|
|
|
|
int v28;
|
|
|
|
byte *v29;
|
|
|
|
int v30;
|
|
|
|
int v31;
|
|
|
|
int v32;
|
|
|
|
int v33;
|
|
|
|
int v34;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v35;
|
|
|
|
int v36;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v37;
|
|
|
|
int v38;
|
2012-10-12 23:23:33 +00:00
|
|
|
uint16 v39;
|
2012-09-21 10:54:26 +00:00
|
|
|
byte *v40;
|
|
|
|
int v41;
|
2012-10-12 23:23:33 +00:00
|
|
|
uint16 v42;
|
|
|
|
const byte *v43;
|
|
|
|
const byte *v44;
|
|
|
|
const byte *v45;
|
|
|
|
const byte *v46;
|
|
|
|
byte *v47;
|
|
|
|
byte *v48;
|
2012-09-21 10:54:26 +00:00
|
|
|
int v49;
|
|
|
|
int v50;
|
|
|
|
byte *v51;
|
2012-10-12 23:23:33 +00:00
|
|
|
int v52;
|
|
|
|
byte *v53;
|
|
|
|
byte *v54;
|
|
|
|
byte *v55;
|
|
|
|
int v56;
|
|
|
|
int v57;
|
|
|
|
int v58;
|
|
|
|
int v59;
|
|
|
|
int v60;
|
|
|
|
int v61;
|
|
|
|
int v62;
|
|
|
|
int v63;
|
|
|
|
int v64;
|
|
|
|
int v65;
|
2012-09-21 10:54:26 +00:00
|
|
|
|
|
|
|
v8 = srcData + 3;
|
2012-10-12 23:23:33 +00:00
|
|
|
for (i = spriteIndex; i; --i)
|
2012-09-21 10:54:26 +00:00
|
|
|
v8 += READ_LE_UINT32(v8) + 16;
|
2012-10-12 23:23:33 +00:00
|
|
|
|
2012-09-21 10:54:26 +00:00
|
|
|
v11 = 0;
|
|
|
|
v12 = 0;
|
|
|
|
v10 = v8 + 4;
|
2012-10-12 23:23:33 +00:00
|
|
|
v11 = (int16)READ_LE_UINT16(v10);
|
2012-09-21 10:54:26 +00:00
|
|
|
v10 += 2;
|
2012-10-12 23:23:33 +00:00
|
|
|
v12 = v36 = (int16)READ_LE_UINT16(v10);
|
2012-09-21 10:54:26 +00:00
|
|
|
v13 = v10 + 10;
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_x = 0;
|
|
|
|
clip_y = 0;
|
|
|
|
clip_x1 = 0;
|
|
|
|
clip_y1 = 0;
|
|
|
|
if ((unsigned __int16)xp300 > min_x) {
|
|
|
|
if ((unsigned __int16)xp300 < (unsigned __int16)(min_x + 300))
|
|
|
|
clip_x = min_x + 300 - xp300;
|
|
|
|
if ((unsigned __int16)yp300 > min_y) {
|
|
|
|
if ((unsigned __int16)yp300 < (unsigned __int16)(min_y + 300))
|
|
|
|
clip_y = min_y + 300 - yp300;
|
|
|
|
if ((unsigned __int16)xp300 < (unsigned __int16)(max_x + 300)) {
|
|
|
|
clip_x1 = max_x + 300 - xp300;
|
|
|
|
if ((unsigned __int16)yp300 < (unsigned __int16)(max_y + 300)) {
|
|
|
|
clip_y1 = max_y + 300 - yp300;
|
|
|
|
v14 = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface;
|
|
|
|
if (a7) {
|
|
|
|
Compteur_y = 0;
|
|
|
|
Agr_x = 0;
|
|
|
|
Agr_y = 0;
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
Agr_Flag_x = 0;
|
|
|
|
Largeur = v11;
|
|
|
|
v20 = Asm_Zoom(v11, a7);
|
|
|
|
v22 = Asm_Zoom(v21, a7);
|
|
|
|
if (a8) {
|
|
|
|
v29 = v20 + v14;
|
|
|
|
if (clip_y) {
|
|
|
|
if ((unsigned __int16)clip_y >= v22)
|
2012-09-21 10:54:26 +00:00
|
|
|
return;
|
2012-10-12 23:23:33 +00:00
|
|
|
v61 = v22;
|
|
|
|
v52 = v20;
|
|
|
|
v30 = 0;
|
|
|
|
v31 = (unsigned __int16)clip_y;
|
|
|
|
while (Asm_Zoom(v30 + 1, a7) < v31)
|
|
|
|
;
|
|
|
|
v20 = v52;
|
|
|
|
v13 += Largeur * v30;
|
|
|
|
v29 += nbrligne2 * (unsigned __int16)clip_y;
|
|
|
|
v22 = v61 - (unsigned __int16)clip_y;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
if (v22 > (unsigned __int16)clip_y1)
|
|
|
|
v22 = (unsigned __int16)clip_y1;
|
|
|
|
if (clip_x) {
|
|
|
|
if ((unsigned __int16)clip_x >= v20)
|
2012-09-21 10:54:26 +00:00
|
|
|
return;
|
2012-10-12 23:23:33 +00:00
|
|
|
v20 -= (unsigned __int16)clip_x;
|
|
|
|
}
|
|
|
|
if (v20 > (unsigned __int16)clip_x1) {
|
|
|
|
v32 = v20 - (unsigned __int16)clip_x1;
|
|
|
|
v29 -= v32;
|
|
|
|
v62 = v22;
|
|
|
|
v33 = 0;
|
|
|
|
while (Asm_Zoom(v33 + 1, a7) < v32)
|
|
|
|
;
|
|
|
|
v34 = v33;
|
|
|
|
v22 = v62;
|
|
|
|
v13 += v34;
|
|
|
|
v20 = (unsigned __int16)clip_x1;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
|
|
|
do {
|
2012-10-12 23:23:33 +00:00
|
|
|
while (1) {
|
|
|
|
v63 = v22;
|
|
|
|
v53 = v29;
|
|
|
|
v46 = v13;
|
|
|
|
Agr_Flag_x = 0;
|
|
|
|
Agr_x = 0;
|
|
|
|
v35 = v20;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-10-12 23:23:33 +00:00
|
|
|
while (1) {
|
|
|
|
if (*v13)
|
|
|
|
*v29 = *v13;
|
|
|
|
--v29;
|
2012-09-21 10:54:26 +00:00
|
|
|
++v13;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (!Agr_Flag_x)
|
|
|
|
Agr_x = a7 + Agr_x;
|
|
|
|
if ((unsigned __int16)Agr_x < 0x64u)
|
|
|
|
break;
|
|
|
|
Agr_x = Agr_x - 100;
|
|
|
|
--v13;
|
|
|
|
Agr_Flag_x = 1;
|
|
|
|
--v35;
|
|
|
|
if (!v35)
|
|
|
|
goto R_Aff_Zoom_Larg_Cont1;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_x = 0;
|
|
|
|
--v35;
|
|
|
|
} while (v35);
|
|
|
|
R_Aff_Zoom_Larg_Cont1:
|
|
|
|
v13 = Largeur + v46;
|
|
|
|
v29 = nbrligne2 + v53;
|
|
|
|
++Compteur_y;
|
|
|
|
if (!Agr_Flag_y)
|
|
|
|
Agr_y = a7 + Agr_y;
|
|
|
|
if ((unsigned __int16)Agr_y < 0x64u)
|
|
|
|
break;
|
|
|
|
Agr_y = Agr_y - 100;
|
|
|
|
v13 = v46;
|
|
|
|
Agr_Flag_y = 1;
|
|
|
|
v22 = v63 - 1;
|
|
|
|
if (v63 == 1)
|
|
|
|
return;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_y = 0;
|
|
|
|
v22 = v63 - 1;
|
|
|
|
} while (v63 != 1);
|
2012-09-21 10:54:26 +00:00
|
|
|
} else {
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_y) {
|
|
|
|
if ((unsigned __int16)clip_y >= v22)
|
|
|
|
return;
|
|
|
|
v58 = v22;
|
|
|
|
v49 = v20;
|
|
|
|
v23 = 0;
|
|
|
|
v24 = (unsigned __int16)clip_y;
|
|
|
|
while (Asm_Zoom(v23 + 1, a7) < v24)
|
|
|
|
;
|
|
|
|
v20 = v49;
|
|
|
|
v13 += Largeur * v23;
|
|
|
|
v14 += nbrligne2 * (unsigned __int16)clip_y;
|
|
|
|
v22 = v58 - (unsigned __int16)clip_y;
|
|
|
|
}
|
|
|
|
if (v22 > (unsigned __int16)clip_y1)
|
|
|
|
v22 = (unsigned __int16)clip_y1;
|
|
|
|
if (clip_x) {
|
|
|
|
if ((unsigned __int16)clip_x >= v20)
|
|
|
|
return;
|
|
|
|
v59 = v22;
|
|
|
|
v50 = v20;
|
|
|
|
v25 = (unsigned __int16)clip_x;
|
|
|
|
v26 = 0;
|
|
|
|
while (Asm_Zoom(v26 + 1, a7) < v25)
|
|
|
|
;
|
|
|
|
v27 = v26;
|
|
|
|
v22 = v59;
|
|
|
|
v13 += v27;
|
|
|
|
v14 += (unsigned __int16)clip_x;
|
|
|
|
v20 = v50 - (unsigned __int16)clip_x;
|
|
|
|
}
|
|
|
|
if (v20 > (unsigned __int16)clip_x1)
|
|
|
|
v20 = (unsigned __int16)clip_x1;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-10-12 23:23:33 +00:00
|
|
|
while (1) {
|
|
|
|
v60 = v22;
|
|
|
|
v51 = v14;
|
|
|
|
v45 = v13;
|
|
|
|
v28 = v20;
|
|
|
|
Agr_Flag_x = 0;
|
|
|
|
Agr_x = 0;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-10-12 23:23:33 +00:00
|
|
|
while (1) {
|
|
|
|
if (*v13)
|
2012-09-21 10:54:26 +00:00
|
|
|
*v14 = *v13;
|
|
|
|
++v14;
|
|
|
|
++v13;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (!Agr_Flag_x)
|
|
|
|
Agr_x = a7 + Agr_x;
|
|
|
|
if ((unsigned __int16)Agr_x < 0x64u)
|
|
|
|
break;
|
|
|
|
Agr_x = Agr_x - 100;
|
|
|
|
--v13;
|
|
|
|
Agr_Flag_x = 1;
|
|
|
|
--v28;
|
|
|
|
if (!v28)
|
|
|
|
goto Aff_Zoom_Larg_Cont1;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_x = 0;
|
|
|
|
--v28;
|
|
|
|
} while (v28);
|
|
|
|
Aff_Zoom_Larg_Cont1:
|
|
|
|
v13 = Largeur + v45;
|
|
|
|
v14 = nbrligne2 + v51;
|
|
|
|
if (!Agr_Flag_y)
|
|
|
|
Agr_y = a7 + Agr_y;
|
|
|
|
if ((unsigned __int16)Agr_y < 0x64u)
|
|
|
|
break;
|
|
|
|
Agr_y = Agr_y - 100;
|
|
|
|
v13 = v45;
|
|
|
|
Agr_Flag_y = 1;
|
|
|
|
v22 = v60 - 1;
|
|
|
|
if (v60 == 1)
|
|
|
|
return;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_y = 0;
|
|
|
|
v22 = v60 - 1;
|
|
|
|
} while (v60 != 1);
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
} else if (a6) {
|
|
|
|
Compteur_y = 0;
|
|
|
|
Red_x = 0;
|
|
|
|
Red_y = 0;
|
|
|
|
Largeur = v11;
|
|
|
|
Red = a6;
|
|
|
|
if (a6 < 100) {
|
|
|
|
v37 = Asm_Reduc(v11, Red);
|
|
|
|
if (a8) {
|
|
|
|
v40 = v37 + v14;
|
|
|
|
do {
|
|
|
|
v65 = v36;
|
|
|
|
v55 = v40;
|
|
|
|
Red_y = Red + Red_y;
|
|
|
|
if ((unsigned __int16)Red_y < 0x64u) {
|
|
|
|
Red_x = 0;
|
|
|
|
v41 = Largeur;
|
|
|
|
v42 = v37;
|
|
|
|
do {
|
|
|
|
Red_x = Red + Red_x;
|
|
|
|
if ((unsigned __int16)Red_x < 0x64u) {
|
|
|
|
if (v42 >= clip_x && v42 < clip_x1 && *v13)
|
|
|
|
*v40 = *v13;
|
|
|
|
--v40;
|
|
|
|
++v13;
|
|
|
|
--v42;
|
|
|
|
} else {
|
|
|
|
Red_x = Red_x - 100;
|
|
|
|
++v13;
|
|
|
|
}
|
|
|
|
--v41;
|
|
|
|
} while (v41);
|
|
|
|
v36 = v65;
|
|
|
|
v40 = nbrligne2 + v55;
|
|
|
|
} else {
|
|
|
|
Red_y = Red_y - 100;
|
|
|
|
v13 += Largeur;
|
|
|
|
}
|
|
|
|
--v36;
|
|
|
|
} while (v36);
|
|
|
|
} else {
|
|
|
|
do {
|
|
|
|
v64 = v36;
|
|
|
|
v54 = v14;
|
|
|
|
Red_y = Red + Red_y;
|
|
|
|
if ((unsigned __int16)Red_y < 0x64u) {
|
|
|
|
Red_x = 0;
|
|
|
|
v38 = Largeur;
|
|
|
|
v39 = 0;
|
|
|
|
do {
|
|
|
|
Red_x = Red + Red_x;
|
|
|
|
if ((unsigned __int16)Red_x < 0x64u) {
|
|
|
|
if (v39 >= clip_x && v39 < clip_x1 && *v13)
|
|
|
|
*v14 = *v13;
|
|
|
|
++v14;
|
|
|
|
++v13;
|
|
|
|
++v39;
|
|
|
|
} else {
|
|
|
|
Red_x = Red_x - 100;
|
|
|
|
++v13;
|
|
|
|
}
|
|
|
|
--v38;
|
|
|
|
} while (v38);
|
|
|
|
v36 = v64;
|
|
|
|
v14 = nbrligne2 + v54;
|
|
|
|
} else {
|
|
|
|
Red_y = Red_y - 100;
|
|
|
|
v13 += Largeur;
|
|
|
|
}
|
|
|
|
--v36;
|
|
|
|
} while (v36);
|
|
|
|
}
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-12 23:23:33 +00:00
|
|
|
Largeur = v11;
|
|
|
|
Compteur_y = 0;
|
|
|
|
if (a8) {
|
|
|
|
v16 = v11 + v14;
|
|
|
|
spec_largeur = v11;
|
|
|
|
if (clip_y) {
|
|
|
|
if ((unsigned __int16)clip_y >= (unsigned int)v12)
|
|
|
|
return;
|
|
|
|
v13 += v11 * (unsigned __int16)clip_y;
|
|
|
|
v16 += nbrligne2 * (unsigned __int16)clip_y;
|
|
|
|
v12 -= (unsigned __int16)clip_y;
|
|
|
|
}
|
|
|
|
v17 = (unsigned __int16)clip_y1;
|
|
|
|
if (v12 > clip_y1)
|
|
|
|
v12 = clip_y1;
|
|
|
|
v17 = clip_x;
|
|
|
|
if (clip_x) {
|
|
|
|
if (v17 >= v11)
|
|
|
|
return;
|
|
|
|
v11 -= v17;
|
|
|
|
}
|
|
|
|
if (v11 > (unsigned __int16)clip_x1) {
|
|
|
|
v18 = v11 - (unsigned __int16)clip_x1;
|
|
|
|
v13 += v18;
|
|
|
|
v16 -= v18;
|
|
|
|
v11 = (unsigned __int16)clip_x1;
|
|
|
|
}
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-10-12 23:23:33 +00:00
|
|
|
v57 = v12;
|
|
|
|
v48 = v16;
|
|
|
|
v44 = v13;
|
|
|
|
v19 = v11;
|
|
|
|
do {
|
|
|
|
if (*v13)
|
|
|
|
*v16 = *v13;
|
|
|
|
++v13;
|
|
|
|
--v16;
|
|
|
|
--v19;
|
|
|
|
} while (v19);
|
|
|
|
v13 = spec_largeur + v44;
|
|
|
|
v16 = nbrligne2 + v48;
|
|
|
|
v12 = v57 - 1;
|
|
|
|
} while (v57 != 1);
|
|
|
|
} else {
|
|
|
|
spec_largeur = v11;
|
|
|
|
if (clip_y) {
|
|
|
|
if ((unsigned __int16)clip_y >= (unsigned int)v12)
|
|
|
|
return;
|
|
|
|
v13 += v11 * (unsigned __int16)clip_y;
|
|
|
|
v14 += nbrligne2 * (unsigned __int16)clip_y;
|
|
|
|
v12 -= (unsigned __int16)clip_y;
|
|
|
|
}
|
|
|
|
if (v12 > clip_y1)
|
|
|
|
v12 = clip_y1;
|
|
|
|
if (clip_x) {
|
|
|
|
if ((unsigned __int16)clip_x >= v11)
|
|
|
|
return;
|
|
|
|
v13 += (unsigned __int16)clip_x;
|
|
|
|
v14 += (unsigned __int16)clip_x;
|
|
|
|
v11 -= (unsigned __int16)clip_x;
|
|
|
|
}
|
|
|
|
if (v11 > (unsigned __int16)clip_x1)
|
|
|
|
v11 = (unsigned __int16)clip_x1;
|
|
|
|
do {
|
|
|
|
v56 = v12;
|
|
|
|
v47 = v14;
|
|
|
|
v43 = v13;
|
|
|
|
v15 = v11;
|
|
|
|
do {
|
|
|
|
if (*v13)
|
|
|
|
*v14 = *v13;
|
|
|
|
++v14;
|
|
|
|
++v13;
|
|
|
|
--v15;
|
|
|
|
} while (v15);
|
|
|
|
v13 = spec_largeur + v43;
|
|
|
|
v14 = nbrligne2 + v47;
|
|
|
|
v12 = v56 - 1;
|
|
|
|
} while (v56 != 1);
|
|
|
|
}
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-09-22 00:36:18 +00:00
|
|
|
void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) {
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
width = _vm->_objectsManager.Get_Largeur(spriteData, spriteIndex);
|
|
|
|
height = _vm->_objectsManager.Get_Hauteur(spriteData, spriteIndex);
|
|
|
|
if (*spriteData == 78) {
|
|
|
|
Affiche_Perfect(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
|
|
|
|
Affiche_Perfect(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
|
|
|
|
} else {
|
|
|
|
Sprite_Vesa(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex);
|
|
|
|
Sprite_Vesa(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex);
|
|
|
|
}
|
|
|
|
if (!_vm->_globals.NO_VISU)
|
|
|
|
Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height);
|
|
|
|
}
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) {
|
2012-09-23 00:59:52 +00:00
|
|
|
int top;
|
2012-09-28 12:15:59 +00:00
|
|
|
int croppedWidth;
|
|
|
|
int croppedHeight;
|
2012-09-23 00:59:52 +00:00
|
|
|
int v11;
|
|
|
|
int height2;
|
|
|
|
int top2;
|
|
|
|
int left;
|
|
|
|
|
|
|
|
left = x1;
|
|
|
|
top = y1;
|
2012-09-28 12:15:59 +00:00
|
|
|
croppedWidth = width;
|
|
|
|
croppedHeight = height;
|
2012-09-23 00:59:52 +00:00
|
|
|
|
|
|
|
if (x1 < min_x) {
|
2012-09-28 12:15:59 +00:00
|
|
|
croppedWidth = width - (min_x - x1);
|
2012-09-23 00:59:52 +00:00
|
|
|
left = min_x;
|
|
|
|
}
|
|
|
|
if (y1 < min_y) {
|
2012-09-28 12:15:59 +00:00
|
|
|
croppedHeight = height - (min_y - y1);
|
2012-09-23 00:59:52 +00:00
|
|
|
top = min_y;
|
|
|
|
}
|
|
|
|
top2 = top;
|
2012-09-28 12:15:59 +00:00
|
|
|
if (top + croppedHeight > max_y)
|
|
|
|
croppedHeight = max_y - top;
|
|
|
|
v11 = left + croppedWidth;
|
2012-09-23 00:59:52 +00:00
|
|
|
if (v11 > max_x)
|
2012-09-28 12:15:59 +00:00
|
|
|
croppedWidth = max_x - left;
|
2012-09-23 00:59:52 +00:00
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
if (croppedWidth > 0 && croppedHeight > 0) {
|
|
|
|
height2 = croppedHeight;
|
|
|
|
Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY);
|
|
|
|
Ajoute_Segment_Vesa(left, top2, left + croppedWidth, top2 + height2);
|
2012-09-23 00:59:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY) {
|
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
|
|
|
int yp;
|
|
|
|
int yCurrent;
|
|
|
|
byte *dest2P;
|
|
|
|
const byte *src2P;
|
|
|
|
unsigned int pitch;
|
|
|
|
|
|
|
|
srcP = x1 + nbrligne2 * y1 + srcSurface;
|
|
|
|
destP = destX + nbrligne2 * destY + destSurface;
|
|
|
|
yp = height;
|
|
|
|
do {
|
|
|
|
yCurrent = yp;
|
|
|
|
memcpy(destP, srcP, 4 * (width >> 2));
|
|
|
|
src2P = (srcP + 4 * (width >> 2));
|
|
|
|
dest2P = (destP + 4 * (width >> 2));
|
|
|
|
pitch = width - 4 * (width >> 2);
|
|
|
|
memcpy(dest2P, src2P, pitch);
|
|
|
|
destP = (dest2P + pitch + nbrligne2 - width);
|
|
|
|
srcP = (src2P + pitch + nbrligne2 - width);
|
|
|
|
yp = yCurrent - 1;
|
|
|
|
} while (yCurrent != 1);
|
|
|
|
}
|
|
|
|
|
2012-09-26 12:13:15 +00:00
|
|
|
void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp,
|
|
|
|
int characterIndex, int transColour) {
|
|
|
|
const byte *v6;
|
|
|
|
int i;
|
|
|
|
const byte *v8;
|
|
|
|
int v9;
|
|
|
|
int v10;
|
|
|
|
const byte *v11;
|
|
|
|
byte *destP;
|
|
|
|
int v13;
|
|
|
|
byte v14;
|
|
|
|
byte *destLineP;
|
|
|
|
int v16;
|
|
|
|
|
|
|
|
v6 = spriteData + 3;
|
|
|
|
for (i = characterIndex; i; --i)
|
|
|
|
v6 += READ_LE_UINT32(v6) + 16;
|
|
|
|
|
|
|
|
v9 = 0;
|
|
|
|
v10 = 0;
|
|
|
|
v8 = v6 + 4;
|
2012-10-11 11:58:04 +00:00
|
|
|
v9 = (int16)READ_LE_UINT16(v8);
|
2012-09-26 12:13:15 +00:00
|
|
|
v8 += 2;
|
2012-10-11 11:58:04 +00:00
|
|
|
v10 = (int16)READ_LE_UINT16(v8);
|
2012-09-26 12:13:15 +00:00
|
|
|
v11 = v8 + 10;
|
|
|
|
destP = surface + xp + nbrligne2 * yp;
|
|
|
|
Largeur = v9;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v16 = v10;
|
|
|
|
destLineP = destP;
|
|
|
|
v13 = v9;
|
|
|
|
do {
|
|
|
|
v14 = *v11;
|
|
|
|
if (*v11) {
|
|
|
|
if (v14 == (byte)-4)
|
|
|
|
v14 = transColour;
|
|
|
|
*destP = v14;
|
|
|
|
}
|
|
|
|
|
|
|
|
++destP;
|
|
|
|
++v11;
|
|
|
|
--v13;
|
|
|
|
} while (v13);
|
|
|
|
destP = nbrligne2 + destLineP;
|
|
|
|
v10 = v16 - 1;
|
|
|
|
} while (v16 != 1);
|
|
|
|
}
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
void GraphicsManager::INI_ECRAN(const Common::String &file) {
|
2012-09-30 11:02:39 +00:00
|
|
|
OPTI_INI(file, 0);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::INI_ECRAN2(const Common::String &file) {
|
2012-09-30 11:02:39 +00:00
|
|
|
OPTI_INI(file, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::OPTI_INI(const Common::String &file, int a2) {
|
|
|
|
int v2;
|
|
|
|
unsigned int v3;
|
|
|
|
int v6;
|
|
|
|
unsigned int v9;
|
|
|
|
signed int v11;
|
|
|
|
byte *ptr;
|
|
|
|
Common::String v13;
|
|
|
|
|
|
|
|
v2 = 1;
|
|
|
|
v3 = 0;
|
|
|
|
v9 = 0;
|
|
|
|
|
2012-09-30 12:18:50 +00:00
|
|
|
v13 = file + ".ini";
|
2012-10-06 13:21:10 +00:00
|
|
|
ptr = _vm->_fileManager.RECHERCHE_CAT(v13, 1);
|
2012-10-10 11:33:44 +00:00
|
|
|
if (ptr == g_PTRNUL) {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13);
|
|
|
|
ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
|
|
|
if (!a2) {
|
2012-09-30 12:18:50 +00:00
|
|
|
v13 = file + ".spr";
|
2012-10-10 10:03:29 +00:00
|
|
|
if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN)
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN);
|
2012-09-30 11:02:39 +00:00
|
|
|
if (!_vm->_globals.NOSPRECRAN) {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(v13, 8);
|
2012-09-30 11:02:39 +00:00
|
|
|
if (_vm->_globals.SPRITE_ECRAN) {
|
|
|
|
_vm->_globals.CAT_FLAG = 0;
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13);
|
2012-09-30 11:02:39 +00:00
|
|
|
} else {
|
|
|
|
_vm->_globals.CAT_FLAG = 1;
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES");
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
_vm->_globals.CAT_FLAG = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-09-30 12:18:50 +00:00
|
|
|
if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') {
|
|
|
|
error("Error, file not ini");
|
2012-09-30 11:02:39 +00:00
|
|
|
} else {
|
|
|
|
v11 = 0;
|
|
|
|
do {
|
|
|
|
v6 = _vm->_objectsManager.Traduction(ptr + 20 * v2);
|
|
|
|
if (v6 == 2)
|
|
|
|
v2 = _vm->_objectsManager.Control_Goto((ptr + 20 * v2));
|
|
|
|
if (v6 == 3)
|
|
|
|
v2 = _vm->_objectsManager.Control_If(ptr, v2);
|
|
|
|
if (v2 == -1)
|
2012-09-30 12:18:50 +00:00
|
|
|
error("Error, defective IFF");
|
2012-09-30 11:02:39 +00:00
|
|
|
if (v6 == 1 || v6 == 4)
|
|
|
|
++v2;
|
|
|
|
if (!v6 || v6 == 5)
|
|
|
|
v11 = 1;
|
|
|
|
} while (v11 != 1);
|
|
|
|
}
|
|
|
|
_vm->_globals.dos_free2(ptr);
|
|
|
|
if (a2 != 1) {
|
2012-10-10 10:03:29 +00:00
|
|
|
if (g_PTRNUL != _vm->_globals.COUCOU)
|
2012-09-30 11:02:39 +00:00
|
|
|
_vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU);
|
|
|
|
|
2012-09-30 12:18:50 +00:00
|
|
|
v13 = file + ".rep";
|
2012-10-06 13:21:10 +00:00
|
|
|
byte *dataP = _vm->_fileManager.RECHERCHE_CAT(v13, 2);
|
2012-09-30 11:02:39 +00:00
|
|
|
_vm->_globals.COUCOU = dataP;
|
2012-10-10 10:03:29 +00:00
|
|
|
if (g_PTRNUL == dataP) {
|
2012-10-06 13:21:10 +00:00
|
|
|
_vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, v13);
|
|
|
|
dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
_vm->_globals.COUCOU = dataP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_vm->_objectsManager.FORCEZONE = 1;
|
|
|
|
_vm->_objectsManager.CHANGEVERBE = 0;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::NB_SCREEN() {
|
|
|
|
byte *v0;
|
|
|
|
const byte *v1;
|
|
|
|
|
|
|
|
if (!_vm->_globals.NECESSAIRE)
|
|
|
|
INIT_TABLE(50, 65, Palette);
|
|
|
|
if (nbrligne == SCREEN_WIDTH)
|
|
|
|
Trans_bloc2(VESA_BUFFER, TABLE_COUL, 307200);
|
|
|
|
if (nbrligne == 1280)
|
|
|
|
Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400);
|
|
|
|
_vm->_graphicsManager.DD_Lock();
|
|
|
|
if (Winbpp == 2) {
|
|
|
|
if (SDL_ECHELLE)
|
|
|
|
m_scroll16A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
else
|
|
|
|
m_scroll16(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
}
|
|
|
|
if (Winbpp == 1) {
|
|
|
|
if (SDL_ECHELLE)
|
|
|
|
m_scroll2A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
else
|
|
|
|
m_scroll2(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
}
|
|
|
|
_vm->_graphicsManager.DD_Unlock();
|
|
|
|
|
|
|
|
v0 = VESA_SCREEN;
|
|
|
|
v1 = VESA_BUFFER;
|
|
|
|
memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu);
|
|
|
|
v1 = v1 + 614396;
|
|
|
|
v0 = v0 + 614396;
|
|
|
|
*v0 = *v1;
|
|
|
|
*(v0 + 2) = *(v1 + 2);
|
|
|
|
DD_VBL();
|
|
|
|
}
|
2012-09-30 12:41:10 +00:00
|
|
|
|
2012-10-03 12:15:39 +00:00
|
|
|
void GraphicsManager::SHOW_PALETTE() {
|
2012-10-03 21:27:34 +00:00
|
|
|
setpal_vga256(Palette);
|
2012-10-03 12:15:39 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 14:55:25 +00:00
|
|
|
void GraphicsManager::videkey() {
|
|
|
|
// Empty in original
|
|
|
|
}
|
|
|
|
|
2012-10-04 22:09:09 +00:00
|
|
|
void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) {
|
|
|
|
int result;
|
|
|
|
int destOffset;
|
|
|
|
const byte *srcPtr;
|
|
|
|
byte byteVal;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
destOffset = 0;
|
|
|
|
srcPtr = src;
|
|
|
|
while (1) {
|
|
|
|
byteVal = *srcPtr;
|
|
|
|
if (*srcPtr < 0xFCu)
|
|
|
|
goto Video_Cont_wVbe;
|
|
|
|
if (byteVal == (byte)-4)
|
|
|
|
return;
|
|
|
|
if (byteVal == (byte)-3) {
|
|
|
|
destOffset += *(srcPtr + 1);
|
|
|
|
byteVal = *(srcPtr + 2);
|
|
|
|
srcPtr += 2;
|
|
|
|
} else if (byteVal == (byte)-2) {
|
2012-10-11 11:58:04 +00:00
|
|
|
destOffset += (int16)READ_LE_UINT16(srcPtr + 1);
|
2012-10-04 22:09:09 +00:00
|
|
|
byteVal = *(srcPtr + 3);
|
|
|
|
srcPtr += 3;
|
|
|
|
} else {
|
|
|
|
destOffset += READ_LE_UINT32(srcPtr + 1);
|
|
|
|
byteVal = *(srcPtr + 5);
|
|
|
|
srcPtr += 5;
|
|
|
|
}
|
|
|
|
Video_Cont_wVbe:
|
|
|
|
*(dest + destOffset) = byteVal;
|
|
|
|
++srcPtr;
|
|
|
|
++destOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Copy_Video_Vbe(const byte *src) {
|
|
|
|
int destOffset;
|
|
|
|
const byte *srcP;
|
|
|
|
byte byteVal;
|
|
|
|
|
|
|
|
assert(VideoPtr);
|
|
|
|
destOffset = 0;
|
|
|
|
srcP = src;
|
|
|
|
while (1) {
|
|
|
|
byteVal = *srcP;
|
|
|
|
if (*srcP < 0xFCu)
|
|
|
|
goto Video_Cont_Vbe;
|
|
|
|
if (byteVal == -4)
|
|
|
|
return;
|
|
|
|
if (byteVal == -3) {
|
|
|
|
destOffset += *(srcP + 1);
|
|
|
|
byteVal = *(srcP + 2);
|
|
|
|
srcP += 2;
|
|
|
|
} else if (byteVal == -2) {
|
2012-10-11 11:58:04 +00:00
|
|
|
destOffset += (int16)READ_LE_UINT16(srcP + 1);
|
2012-10-04 22:09:09 +00:00
|
|
|
byteVal = *(srcP + 3);
|
|
|
|
srcP += 3;
|
|
|
|
} else {
|
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
byteVal = *(srcP + 5);
|
|
|
|
srcP += 5;
|
|
|
|
}
|
|
|
|
Video_Cont_Vbe:
|
|
|
|
*((byte *)VideoPtr->pixels + destOffset) = byteVal;
|
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-05 14:45:07 +00:00
|
|
|
// TODO: Check that v9 doesn't get set anywhere (apart from the current init to zero)
|
|
|
|
void GraphicsManager::Reduc_Ecran(byte *a1, byte *a2, int a3, int a4, int a5, int a6, int a7) {
|
|
|
|
byte *v7;
|
|
|
|
byte *v8;
|
|
|
|
int v9 = 0;
|
|
|
|
int v10 = 0;
|
|
|
|
int v11;
|
|
|
|
int v12;
|
|
|
|
byte *v13;
|
|
|
|
int v14;
|
|
|
|
|
|
|
|
v7 = a3 + nbrligne2 * a4 + a1;
|
|
|
|
v8 = a2;
|
|
|
|
Red = a7;
|
|
|
|
Largeur = a5;
|
|
|
|
Red_x = 0;
|
|
|
|
Red_y = 0;
|
|
|
|
if (a7 < 100) {
|
|
|
|
Reduc_Ecran_L = Asm_Reduc(a5, Red);
|
|
|
|
Reduc_Ecran_H = Asm_Reduc(v9, Red);
|
|
|
|
v11 = Red;
|
|
|
|
do {
|
|
|
|
v14 = v10;
|
|
|
|
v13 = v7;
|
|
|
|
Red_y += v11;
|
|
|
|
if ((uint16)Red_y < 0x64u) {
|
|
|
|
Red_x = 0;
|
|
|
|
v12 = Largeur;
|
|
|
|
do {
|
|
|
|
Red_x += v11;
|
|
|
|
if ((uint16)Red_x < 0x64u) {
|
|
|
|
*v8++ = *v7++;
|
|
|
|
} else {
|
|
|
|
Red_x = Red_x - 100;
|
|
|
|
++v7;
|
|
|
|
}
|
|
|
|
--v12;
|
|
|
|
} while (v12);
|
|
|
|
v10 = v14;
|
|
|
|
v7 = nbrligne2 + v13;
|
|
|
|
} else {
|
|
|
|
Red_y = Red_y - 100;
|
|
|
|
v7 += nbrligne2;
|
|
|
|
}
|
|
|
|
--v10;
|
|
|
|
} while (v10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-11 11:53:59 +00:00
|
|
|
void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int width, byte col) {
|
|
|
|
memset(surface + xp + nbrligne2 * yp, col, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, char col) {
|
|
|
|
byte *v5;
|
|
|
|
int v6;
|
|
|
|
|
|
|
|
v5 = surface + xp + nbrligne2 * yp;
|
|
|
|
v6 = height;
|
|
|
|
do {
|
|
|
|
*v5 = col;
|
|
|
|
v5 += nbrligne2;
|
|
|
|
--v6;
|
|
|
|
} while (v6);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-08 11:43:33 +00:00
|
|
|
} // End of namespace Hopkins
|