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-11-11 10:33:17 +00:00
|
|
|
#include "graphics/decoders/pcx.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-12-19 01:15:32 +00:00
|
|
|
_lockCounter = 0;
|
2012-09-09 09:55:05 +00:00
|
|
|
SDL_MODEYES = false;
|
2012-09-09 10:10:32 +00:00
|
|
|
XSCREEN = YSCREEN = 0;
|
|
|
|
WinScan = 0;
|
|
|
|
PAL_PIXELS = NULL;
|
2012-12-19 07:00:22 +00:00
|
|
|
_lineNbr = 0;
|
2012-09-09 10:10:32 +00:00
|
|
|
Linear = false;
|
2012-12-19 01:15:32 +00:00
|
|
|
_videoPtr = NULL;
|
2012-09-09 10:10:32 +00:00
|
|
|
ofscroll = 0;
|
|
|
|
SCROLL = 0;
|
|
|
|
PCX_L = PCX_H = 0;
|
|
|
|
DOUBLE_ECRAN = false;
|
|
|
|
OLD_SCROLL = 0;
|
2012-11-08 09:28:07 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
_lineNbr2 = 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;
|
2012-12-19 01:15:32 +00:00
|
|
|
_skipVideoLockFl = 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;
|
2012-10-21 07:48:03 +00:00
|
|
|
max_y = SCREEN_HEIGHT - 20;
|
2012-09-20 10:54:03 +00:00
|
|
|
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;
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = 0;
|
2012-09-21 10:54:26 +00:00
|
|
|
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);
|
2012-10-23 20:09:12 +00:00
|
|
|
Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_EXT_BLOCK_SIZE], 0);
|
2012-09-13 11:08:54 +00:00
|
|
|
Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
|
2012-10-22 21:57:16 +00:00
|
|
|
Common::fill(&Palette[0], &Palette[PALETTE_EXT_BLOCK_SIZE], 0);
|
|
|
|
Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsManager::~GraphicsManager() {
|
2012-12-19 01:15:32 +00:00
|
|
|
_vm->_globals.freeMemory(_vesaScreen);
|
|
|
|
_vm->_globals.freeMemory(_vesaBuffer);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-19 11:34:23 +00:00
|
|
|
void GraphicsManager::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
2012-11-08 09:28:07 +00:00
|
|
|
|
|
|
|
if (_vm->getIsDemo()) {
|
2012-12-02 09:42:04 +00:00
|
|
|
if (_vm->getPlatform() == Common::kPlatformLinux)
|
2012-11-08 09:28:07 +00:00
|
|
|
// CHECKME: Should be 0?
|
2012-12-19 01:15:32 +00:00
|
|
|
MANU_SCROLL = true;
|
2012-12-14 00:49:22 +00:00
|
|
|
else
|
2012-12-19 01:15:32 +00:00
|
|
|
MANU_SCROLL = false;
|
2012-11-08 09:28:07 +00:00
|
|
|
SPEED_SCROLL = 16;
|
|
|
|
} else {
|
2012-12-19 01:15:32 +00:00
|
|
|
MANU_SCROLL = false;
|
2012-11-08 09:28:07 +00:00
|
|
|
SPEED_SCROLL = 32;
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
void GraphicsManager::setGraphicalMode(int width, int height) {
|
2012-09-09 09:55:05 +00:00
|
|
|
if (!SDL_MODEYES) {
|
2012-09-13 11:08:54 +00:00
|
|
|
Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
2012-12-15 22:28:58 +00:00
|
|
|
initGraphics(width, height, true, &pixelFormat16);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
// Init surfaces
|
2012-12-19 01:15:32 +00:00
|
|
|
_vesaScreen = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
|
|
|
_vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
_videoPtr = NULL;
|
2012-09-09 09:55:05 +00:00
|
|
|
XSCREEN = width;
|
|
|
|
YSCREEN = height;
|
|
|
|
|
|
|
|
Linear = true;
|
2012-12-15 22:28:58 +00:00
|
|
|
WinScan = width * 2; // Refactor me
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
PAL_PIXELS = SD_PIXELS;
|
2012-12-19 07:00:22 +00:00
|
|
|
_lineNbr = width;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* (try to) Lock Screen
|
|
|
|
*/
|
|
|
|
void GraphicsManager::lockScreen() {
|
|
|
|
if (!_skipVideoLockFl) {
|
|
|
|
if (_lockCounter++ == 0)
|
|
|
|
_videoPtr = g_system->lockScreen();
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* (try to) Unlock Screen
|
|
|
|
*/
|
|
|
|
void GraphicsManager::unlockScreen() {
|
|
|
|
assert(_videoPtr);
|
|
|
|
if (--_lockCounter == 0) {
|
2012-09-13 11:08:54 +00:00
|
|
|
g_system->unlockScreen();
|
2012-12-19 01:15:32 +00:00
|
|
|
_videoPtr = NULL;
|
2012-09-13 11:08:54 +00:00
|
|
|
}
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* Clear Screen
|
|
|
|
*/
|
|
|
|
void GraphicsManager::clearScreen() {
|
|
|
|
assert(_videoPtr);
|
|
|
|
_videoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* Load Image
|
|
|
|
*/
|
|
|
|
void GraphicsManager::loadImage(const Common::String &file) {
|
2012-09-09 10:28:04 +00:00
|
|
|
Common::String filename = Common::String::format("%s.PCX", file.c_str());
|
2012-12-19 01:15:32 +00:00
|
|
|
loadScreen(filename);
|
2012-09-21 21:48:21 +00:00
|
|
|
INIT_TABLE(165, 170, Palette);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* Load VGA Image
|
|
|
|
*/
|
|
|
|
void GraphicsManager::loadVgaImage(const Common::String &file) {
|
2012-11-17 09:49:07 +00:00
|
|
|
SCANLINE(SCREEN_WIDTH);
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
clearScreen();
|
|
|
|
unlockScreen();
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file);
|
2012-12-19 01:15:32 +00:00
|
|
|
A_PCX320(_vesaScreen, _vm->_globals.NFICHIER, Palette);
|
2012-12-21 00:26:11 +00:00
|
|
|
memcpy(_vesaBuffer, _vesaScreen, 64000);
|
2012-11-17 09:49:07 +00:00
|
|
|
SCANLINE(320);
|
|
|
|
max_x = 320;
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
CopyAsm16(_vesaBuffer);
|
|
|
|
unlockScreen();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-11-17 09:49:07 +00:00
|
|
|
FADE_IN_CASSE();
|
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* Load Screen
|
|
|
|
*/
|
|
|
|
void GraphicsManager::loadScreen(const Common::String &file) {
|
2012-09-09 09:55:05 +00:00
|
|
|
Common::File f;
|
|
|
|
|
2012-12-09 19:22:12 +00:00
|
|
|
bool flag = true;
|
|
|
|
if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) {
|
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file);
|
2012-10-06 13:21:10 +00:00
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-12-19 01:15:32 +00:00
|
|
|
error("loadScreen - %s", file.c_str());
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
scrollScreen(0);
|
|
|
|
A_PCX640_480((byte *)_vesaScreen, file, Palette, flag);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
SCROLL = 0;
|
|
|
|
OLD_SCROLL = 0;
|
|
|
|
Cls_Pal();
|
|
|
|
|
|
|
|
if (!DOUBLE_ECRAN) {
|
|
|
|
SCANLINE(SCREEN_WIDTH);
|
2012-09-21 11:20:07 +00:00
|
|
|
max_x = SCREEN_WIDTH;
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
clearScreen();
|
|
|
|
m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
unlockScreen();
|
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-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
clearScreen();
|
|
|
|
unlockScreen();
|
|
|
|
|
|
|
|
if (MANU_SCROLL) {
|
|
|
|
lockScreen();
|
|
|
|
m_scroll16(_vesaScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
unlockScreen();
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-10-29 22:08:25 +00:00
|
|
|
void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) {
|
2012-09-09 09:55:05 +00:00
|
|
|
for (int idx = 0; idx < 256; ++idx)
|
|
|
|
TABLE_COUL[idx] = idx;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-29 22:08:25 +00:00
|
|
|
Trans_bloc(TABLE_COUL, palette, 256, minIndex, maxIndex);
|
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;
|
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
/**
|
|
|
|
* Scroll Screen
|
|
|
|
*/
|
|
|
|
void GraphicsManager::scrollScreen(int amount) {
|
2012-09-09 09:55:05 +00:00
|
|
|
int result = CLIP(amount, 0, SCREEN_WIDTH);
|
2012-12-11 00:53:50 +00:00
|
|
|
_vm->_eventsManager._startPos.x = result;
|
2012-09-09 09:55:05 +00:00
|
|
|
ofscroll = result;
|
|
|
|
SCROLL = result;
|
|
|
|
}
|
|
|
|
|
2012-10-23 20:09:12 +00:00
|
|
|
void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) {
|
|
|
|
byte *destPosP;
|
|
|
|
int palIndex;
|
|
|
|
int srcOffset;
|
|
|
|
int col1, col2;
|
|
|
|
|
|
|
|
destPosP = destP;
|
|
|
|
for (int idx = 0; idx < count; ++idx) {
|
|
|
|
palIndex = *(byte *)destPosP++;
|
|
|
|
srcOffset = 3 * palIndex;
|
|
|
|
col1 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2);
|
|
|
|
|
|
|
|
for (int idx2 = 0; idx2 < 38; ++idx2) {
|
|
|
|
srcOffset = 3 * idx2;
|
|
|
|
col2 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2);
|
|
|
|
|
|
|
|
col2 += minThreshold;
|
|
|
|
if (col2 < col1)
|
|
|
|
continue;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-23 20:09:12 +00:00
|
|
|
col2 -= maxThreshold;
|
|
|
|
if (col2 > col1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*(destPosP - 1) = (idx2 == 0) ? 1 : idx2;
|
|
|
|
break;
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
2012-10-23 20:09:12 +00:00
|
|
|
}
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 12:15:59 +00:00
|
|
|
void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) {
|
2012-12-14 00:49:22 +00:00
|
|
|
byte dataVal;
|
2012-09-30 11:02:39 +00:00
|
|
|
|
2012-12-17 23:37:52 +00:00
|
|
|
byte *dataP = surface;
|
|
|
|
for (int count = size - 1; count; count--){
|
2012-09-30 11:02:39 +00:00
|
|
|
dataVal = *dataP++;
|
|
|
|
*(dataP - 1) = *(dataVal + col);
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
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
|
|
|
Common::File f;
|
2012-11-11 10:33:17 +00:00
|
|
|
Graphics::PCXDecoder pcxDecoder;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
// Clear the passed surface
|
|
|
|
memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
|
|
|
|
|
|
|
|
if (typeFlag) {
|
2012-11-11 10:33:17 +00:00
|
|
|
// Load PCX from within the PIC resource
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES");
|
2012-10-06 13:21:10 +00:00
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-09-09 09:55:05 +00:00
|
|
|
error("(nom)Erreur en cours de lecture.");
|
2012-12-19 07:00:22 +00:00
|
|
|
f.seek(_vm->_globals._catalogPos);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
|
|
|
} else {
|
2012-11-11 10:33:17 +00:00
|
|
|
// Load stand alone PCX file
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file);
|
2012-10-06 13:21:10 +00:00
|
|
|
if (!f.open(_vm->_globals.NFICHIER))
|
2012-09-09 09:55:05 +00:00
|
|
|
error("(nom)Erreur en cours de lecture.");
|
|
|
|
}
|
|
|
|
|
2012-11-11 10:33:17 +00:00
|
|
|
// Decode the PCX
|
|
|
|
if (!pcxDecoder.loadStream(f))
|
2012-11-17 22:09:16 +00:00
|
|
|
error("Error decoding PCX %s", file.c_str());
|
2012-11-11 10:33:17 +00:00
|
|
|
|
|
|
|
const Graphics::Surface *s = pcxDecoder.getSurface();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-11-11 10:33:17 +00:00
|
|
|
// Copy out the dimensions and pixels of the decoded surface
|
|
|
|
DOUBLE_ECRAN = s->w > SCREEN_WIDTH;
|
|
|
|
PCX_L = s->w;
|
|
|
|
PCX_H = s->h;
|
|
|
|
Common::copy((byte *)s->pixels, (byte *)s->pixels + (s->pitch * s->h), surface);
|
|
|
|
|
|
|
|
// Copy out the palette
|
|
|
|
const byte *palSrc = pcxDecoder.getPalette();
|
2012-11-13 09:25:55 +00:00
|
|
|
Common::copy((const byte *)palSrc, (const byte *)palSrc + PALETTE_BLOCK_SIZE, palette);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
|
2012-11-17 09:49:07 +00:00
|
|
|
void GraphicsManager::A_PCX320(byte *surface, const Common::String &file, byte *palette) {
|
2012-12-14 00:49:22 +00:00
|
|
|
size_t filesize;
|
|
|
|
int v4;
|
|
|
|
size_t v5;
|
|
|
|
size_t v7;
|
|
|
|
byte v9;
|
|
|
|
int v10;
|
|
|
|
char v12;
|
|
|
|
int v15;
|
|
|
|
int v16;
|
|
|
|
int32 v17;
|
|
|
|
byte *ptr;
|
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
if (!f.open(file))
|
2012-11-17 09:49:07 +00:00
|
|
|
error("File not found - %s", file.c_str());
|
|
|
|
|
|
|
|
filesize = f.size();
|
|
|
|
|
2012-12-21 00:26:11 +00:00
|
|
|
f.read(surface, 128);
|
2012-11-17 09:49:07 +00:00
|
|
|
v4 = filesize - 896;
|
2012-12-21 00:26:11 +00:00
|
|
|
ptr = _vm->_globals.allocMemory(65024);
|
|
|
|
if (v4 >= 64000) {
|
|
|
|
v15 = v4 / 64000 + 1;
|
|
|
|
v17 = 64000 * (v4 / 64000) - v4;
|
|
|
|
if (v17 < 0)
|
2012-11-17 09:49:07 +00:00
|
|
|
v17 = -v17;
|
2012-12-21 00:26:11 +00:00
|
|
|
f.read(ptr, 64000);
|
2012-11-17 09:49:07 +00:00
|
|
|
v5 = 64000;
|
|
|
|
} else {
|
|
|
|
v15 = 1;
|
|
|
|
v17 = v4;
|
|
|
|
f.read(ptr, v4);
|
|
|
|
v5 = v4;
|
|
|
|
}
|
|
|
|
v16 = v15 - 1;
|
|
|
|
v7 = 0;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int i = 0; i < 64000; i++) {
|
2012-11-17 09:49:07 +00:00
|
|
|
if (v7 == v5) {
|
|
|
|
v7 = 0;
|
|
|
|
--v16;
|
|
|
|
v5 = 64000;
|
|
|
|
if (!v16)
|
|
|
|
v5 = v17;
|
2012-12-17 23:37:52 +00:00
|
|
|
// v8 = i;
|
2012-11-17 09:49:07 +00:00
|
|
|
f.read(ptr, v5);
|
2012-12-17 23:37:52 +00:00
|
|
|
// i = v8;
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
v9 = *(ptr + v7++);
|
2012-12-21 00:26:11 +00:00
|
|
|
if (v9 > 192) {
|
2012-11-17 09:49:07 +00:00
|
|
|
v10 = v9 - 192;
|
|
|
|
if (v7 == v5) {
|
|
|
|
v7 = 0;
|
|
|
|
--v16;
|
|
|
|
v5 = 64000;
|
|
|
|
if (v16 == 1)
|
|
|
|
v5 = v17;
|
2012-12-17 23:37:52 +00:00
|
|
|
// v11 = i;
|
2012-11-17 09:49:07 +00:00
|
|
|
f.read(ptr, v5);
|
2012-12-17 23:37:52 +00:00
|
|
|
// i = v11;
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
v12 = *(ptr + v7++);
|
|
|
|
do {
|
2012-12-17 23:37:52 +00:00
|
|
|
*(surface + i++) = v12;
|
2012-11-17 09:49:07 +00:00
|
|
|
--v10;
|
|
|
|
} while (v10);
|
|
|
|
} else {
|
2012-12-17 23:37:52 +00:00
|
|
|
*(surface + i++) = v9;
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-11-17 09:49:07 +00:00
|
|
|
|
|
|
|
f.seek(filesize - 768);
|
2012-12-17 23:37:52 +00:00
|
|
|
f.read(palette, 768);
|
2012-11-17 09:49:07 +00:00
|
|
|
f.close();
|
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.freeMemory(ptr);
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Clear Palette
|
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 09:55:05 +00:00
|
|
|
}
|
2012-09-09 11:15:09 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
void GraphicsManager::SCANLINE(int pitch) {
|
2012-12-19 07:00:22 +00:00
|
|
|
_lineNbr = _lineNbr2 = 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) {
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
|
|
|
int yNext;
|
|
|
|
int yCtr;
|
|
|
|
byte *dest2P;
|
|
|
|
const byte *src2P;
|
|
|
|
unsigned int widthRemaining;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = xs + _lineNbr2 * ys + surface;
|
2012-12-19 01:15:32 +00:00
|
|
|
destP = destX + WinScan * destY + (byte *)_videoPtr->pixels;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = height;
|
2012-09-09 09:55:05 +00:00
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
yCtr = yNext;
|
|
|
|
memcpy((byte *)destP, (const byte *)srcP, 4 * (width >> 2));
|
|
|
|
src2P = (const byte *)(srcP + 4 * (width >> 2));
|
|
|
|
dest2P = (byte *)(destP + 4 * (width >> 2));
|
|
|
|
widthRemaining = width - 4 * (width >> 2);
|
|
|
|
memcpy(dest2P, src2P, widthRemaining);
|
|
|
|
destP = dest2P + widthRemaining + WinScan - width;
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = src2P + widthRemaining + _lineNbr2 - width;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = yCtr - 1;
|
|
|
|
} while (yCtr != 1);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
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-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-12-19 07:00:22 +00:00
|
|
|
const byte *srcP = xs + _lineNbr2 * ys + surface;
|
2012-12-19 01:15:32 +00:00
|
|
|
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
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP += _lineNbr2;
|
2012-09-13 11:08:54 +00:00
|
|
|
destP += WinScan / 2;
|
|
|
|
}
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
unlockScreen();
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
// TODO: See if PAL_PIXELS can be converted to a uint16 array
|
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) {
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *srcP;
|
|
|
|
const byte *destP;
|
|
|
|
int yNext;
|
|
|
|
int xCtr;
|
|
|
|
const byte *palette;
|
|
|
|
int pixelWord;
|
|
|
|
int yCtr;
|
|
|
|
const byte *srcCopyP;
|
|
|
|
const byte *destCopyP;
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = xs + _lineNbr2 * ys + surface;
|
2012-12-19 01:15:32 +00:00
|
|
|
destP = destX + destX + WinScan * destY + (byte *)_videoPtr->pixels;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = height;
|
2012-09-09 09:55:05 +00:00
|
|
|
Agr_x = 0;
|
|
|
|
Agr_y = 0;
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
for (;;) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destCopyP = destP;
|
|
|
|
srcCopyP = srcP;
|
|
|
|
xCtr = width;
|
|
|
|
yCtr = yNext;
|
|
|
|
palette = PAL_PIXELS;
|
2012-09-09 09:55:05 +00:00
|
|
|
Agr_x = 0;
|
|
|
|
|
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
pixelWord = *(uint16 *)(palette + 2 * *srcP);
|
|
|
|
*(uint16 *)destP = pixelWord;
|
|
|
|
++srcP;
|
|
|
|
destP += 2;
|
2012-09-09 09:55:05 +00:00
|
|
|
if ((unsigned int)Agr_x >= 100) {
|
|
|
|
Agr_x -= 100;
|
2012-10-30 11:48:41 +00:00
|
|
|
*(uint16 *)destP = pixelWord;
|
|
|
|
destP += 2;
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
--xCtr;
|
|
|
|
} while (xCtr);
|
2012-09-09 09:55:05 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = yCtr;
|
|
|
|
srcP = srcCopyP;
|
|
|
|
destP = WinScan + destCopyP;
|
2012-09-09 09:55:05 +00:00
|
|
|
if (Agr_Flag_y == 1)
|
|
|
|
break;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
if ((unsigned int)Agr_y < 100)
|
|
|
|
break;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-09 09:55:05 +00:00
|
|
|
Agr_y -= 100;
|
|
|
|
Agr_Flag_y = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Agr_Flag_y = 0;
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = _lineNbr2 + srcCopyP;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = yCtr - 1;
|
|
|
|
} while (yCtr != 1);
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 13:30:28 +00:00
|
|
|
void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) {
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *srcP;
|
|
|
|
uint16 *destP;
|
|
|
|
int yCount;
|
2012-10-30 11:48:41 +00:00
|
|
|
int xCount;
|
|
|
|
int xCtr;
|
|
|
|
const byte *palette;
|
|
|
|
uint16 *tempSrcP;
|
|
|
|
uint16 srcByte;
|
|
|
|
uint16 *tempDestP;
|
|
|
|
int savedXCount;
|
|
|
|
uint16 *loopDestP;
|
|
|
|
const byte *loopSrcP;
|
|
|
|
int yCtr;
|
2012-09-20 13:30:28 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-10-30 11:48:41 +00:00
|
|
|
srcP = xp + 320 * yp + surface;
|
2012-12-19 01:15:32 +00:00
|
|
|
destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)_videoPtr->pixels);
|
2012-10-30 11:48:41 +00:00
|
|
|
yCount = height;
|
|
|
|
xCount = width;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-20 13:30:28 +00:00
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
yCtr = yCount;
|
|
|
|
xCtr = xCount;
|
|
|
|
loopSrcP = srcP;
|
|
|
|
loopDestP = destP;
|
|
|
|
savedXCount = xCount;
|
|
|
|
palette = PAL_PIXELS;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-20 13:30:28 +00:00
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
tempSrcP = (uint16 *)(palette + 2 * *srcP);
|
|
|
|
srcByte = *tempSrcP;
|
|
|
|
*destP = *tempSrcP;
|
|
|
|
*(destP + 1) = srcByte;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
tempDestP = (uint16 *)((byte *)destP + WinScan);
|
|
|
|
*tempDestP = srcByte;
|
|
|
|
*(tempDestP + 1) = srcByte;
|
|
|
|
++srcP;
|
|
|
|
destP = (uint16 *)((byte *)tempDestP - WinScan + 4);
|
|
|
|
--xCtr;
|
|
|
|
} while (xCtr);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
xCount = savedXCount;
|
|
|
|
destP = (uint16 *)((byte *)loopDestP + WinScan * 2);
|
|
|
|
srcP = loopSrcP + 320;
|
|
|
|
yCount = yCtr - 1;
|
|
|
|
} while (yCtr != 1);
|
2012-09-20 13:30:28 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-13 11:08:54 +00:00
|
|
|
// Loop through fading in the palette
|
2012-10-22 21:57:16 +00:00
|
|
|
uint16 *pTemp1 = &palData1[1];
|
2012-09-13 11:08:54 +00:00
|
|
|
for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) {
|
2012-10-22 21:57:16 +00:00
|
|
|
uint16 *pTemp2 = &palData1[2];
|
2012-09-13 11:08:54 +00:00
|
|
|
|
|
|
|
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];
|
2012-12-14 00:49:22 +00:00
|
|
|
uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
|
2012-09-13 11:08:54 +00:00
|
|
|
*pDest = v;
|
|
|
|
palData2[palOffset + 1] = (v >> 8) & 0xff;
|
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-10-22 21:57:16 +00:00
|
|
|
if (palData2[palOffset + 2] < palette[palOffset + 2]) {
|
2012-09-13 11:08:54 +00:00
|
|
|
uint16 *pDest = &pTemp2[palOffset];
|
2012-12-14 00:49:22 +00:00
|
|
|
uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
|
2012-09-13 11:08:54 +00:00
|
|
|
*pDest = v;
|
2012-10-22 21:57:16 +00:00
|
|
|
palData2[palOffset + 2] = (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);
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-09-10 10:26:24 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
2012-12-15 22:28:58 +00:00
|
|
|
|
|
|
|
// Set the final palette
|
|
|
|
setpal_vga256(palette);
|
|
|
|
|
|
|
|
// Refresh the screen
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-12-15 22:28:58 +00:00
|
|
|
DD_VBL();
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) {
|
2012-10-30 11:48:41 +00:00
|
|
|
int palByte;
|
|
|
|
uint16 palMax;
|
2012-09-10 10:26:24 +00:00
|
|
|
byte palData[PALETTE_BLOCK_SIZE];
|
2012-10-30 11:48:41 +00:00
|
|
|
int tempPalette[PALETTE_BLOCK_SIZE];
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
palMax = palByte = FADESPD;
|
2012-09-10 10:26:24 +00:00
|
|
|
if (palette) {
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int palIndex = 0; palIndex < PALETTE_BLOCK_SIZE; palIndex++) {
|
2012-11-23 23:16:44 +00:00
|
|
|
int palDataIndex = palIndex;
|
2012-12-17 23:37:52 +00:00
|
|
|
palByte = palette[palIndex];
|
2012-10-30 11:48:41 +00:00
|
|
|
palByte <<= 8;
|
|
|
|
tempPalette[palDataIndex] = palByte;
|
2012-12-17 23:37:52 +00:00
|
|
|
palData[palDataIndex] = palette[palIndex];
|
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-10 10:26:24 +00:00
|
|
|
setpal_vga256(palData);
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-12-15 22:28:58 +00:00
|
|
|
DD_VBL();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
if (palMax > 0) {
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) {
|
|
|
|
for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) {
|
2012-11-23 23:16:44 +00:00
|
|
|
int palCtr5 = palCtr4;
|
2012-12-17 23:37:52 +00:00
|
|
|
int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax;
|
2012-10-30 11:48:41 +00:00
|
|
|
tempPalette[palCtr5] = palValue;
|
|
|
|
palData[palCtr5] = (palValue >> 8) & 0xff;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-10 10:26:24 +00:00
|
|
|
setpal_vga256(palData);
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-12-15 22:28:58 +00:00
|
|
|
DD_VBL();
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-23 23:16:44 +00:00
|
|
|
for (int i = 0; i < PALETTE_BLOCK_SIZE; i++)
|
|
|
|
palData[i] = 0;
|
2012-09-10 10:26:24 +00:00
|
|
|
|
|
|
|
setpal_vga256(palData);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
return DD_VBL();
|
2012-09-10 10:26:24 +00:00
|
|
|
} else {
|
2012-11-23 23:16:44 +00:00
|
|
|
for (int i = 0; i < PALETTE_BLOCK_SIZE; i++)
|
|
|
|
palData[i] = 0;
|
2012-09-10 10:26:24 +00:00
|
|
|
|
|
|
|
setpal_vga256(palData);
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-12-15 22:28:58 +00:00
|
|
|
return DD_VBL();
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INS() {
|
|
|
|
FADESPD = 1;
|
2012-12-19 01:15:32 +00:00
|
|
|
fade_in(Palette, 1, (const byte *)_vesaBuffer);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTS() {
|
|
|
|
FADESPD = 1;
|
2012-12-19 01:15:32 +00:00
|
|
|
fade_out(Palette, 1, (const byte *)_vesaBuffer);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INW() {
|
|
|
|
FADESPD = 15;
|
2012-12-19 01:15:32 +00:00
|
|
|
fade_in(Palette, 20, (const byte *)_vesaBuffer);
|
2012-09-10 10:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUTW() {
|
|
|
|
FADESPD = 15;
|
2012-12-19 01:15:32 +00:00
|
|
|
fade_out(Palette, 20, (const byte *)_vesaBuffer);
|
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);
|
2012-12-15 23:26:54 +00:00
|
|
|
m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
2012-12-15 22:28:58 +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) {
|
2012-11-17 09:49:07 +00:00
|
|
|
Palette[palIndex * 3] = 255 * r / 100;
|
|
|
|
Palette[palIndex * 3 + 1] = 255 * g / 100;
|
|
|
|
Palette[palIndex * 3 + 2] = 255 * b / 100;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-28 23:33:42 +00:00
|
|
|
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;
|
2012-12-14 00:49:22 +00:00
|
|
|
int palOffset;
|
|
|
|
int v8;
|
2012-09-28 23:33:42 +00:00
|
|
|
|
|
|
|
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;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-28 23:33:42 +00:00
|
|
|
WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv));
|
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
|
|
|
uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) {
|
2012-12-15 22:28:58 +00:00
|
|
|
Graphics::PixelFormat format = g_system->getScreenFormat();
|
2012-09-10 10:26:24 +00:00
|
|
|
|
2012-12-15 22:28:58 +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-10-13 05:41:51 +00:00
|
|
|
assert(surface);
|
2012-09-20 10:54:03 +00:00
|
|
|
fade_out(Palette, FADESPD, surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_INW_LINUX(const byte *surface) {
|
2012-10-13 05:41:51 +00:00
|
|
|
assert(surface);
|
|
|
|
fade_in(Palette, FADESPD, surface);
|
2012-09-15 00:27:15 +00:00
|
|
|
}
|
|
|
|
|
2012-11-17 09:49:07 +00:00
|
|
|
void GraphicsManager::FADE_IN_CASSE() {
|
|
|
|
setpal_vga256(Palette);
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
CopyAsm16(_vesaBuffer);
|
|
|
|
unlockScreen();
|
2012-11-17 09:49:07 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::FADE_OUT_CASSE() {
|
|
|
|
byte palette[PALETTE_EXT_BLOCK_SIZE];
|
|
|
|
|
|
|
|
memset(palette, 0, PALETTE_EXT_BLOCK_SIZE);
|
|
|
|
setpal_vga256(palette);
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
CopyAsm16(_vesaBuffer);
|
|
|
|
unlockScreen();
|
2012-11-17 09:49:07 +00:00
|
|
|
DD_VBL();
|
|
|
|
}
|
|
|
|
|
2012-10-13 05:41:51 +00:00
|
|
|
void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) {
|
2012-10-30 11:48:41 +00:00
|
|
|
int rleValue;
|
2012-12-14 00:49:22 +00:00
|
|
|
int destOffset;
|
|
|
|
const byte *srcP;
|
2012-10-30 11:48:41 +00:00
|
|
|
byte srcByte;
|
|
|
|
byte destLen1;
|
2012-12-14 00:49:22 +00:00
|
|
|
byte *destSlice1P;
|
|
|
|
byte destLen2;
|
|
|
|
byte *destSlice2P;
|
2012-10-30 11:48:41 +00:00
|
|
|
|
|
|
|
rleValue = 0;
|
|
|
|
destOffset = 0;
|
|
|
|
srcP = srcData;
|
2012-09-20 10:54:03 +00:00
|
|
|
for (;;) {
|
2012-10-30 11:48:41 +00:00
|
|
|
srcByte = *srcP;
|
2012-12-21 00:26:11 +00:00
|
|
|
if (*srcP < 222)
|
2012-09-20 10:54:03 +00:00
|
|
|
goto Video_Cont3_wVbe;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte == kByteStop)
|
2012-09-20 10:54:03 +00:00
|
|
|
return;
|
2012-10-13 05:51:44 +00:00
|
|
|
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte < kSetOffset) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += (byte)(*srcP + 35);
|
|
|
|
srcByte = *(srcP++ + 1);
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k8bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += *(srcP + 1);
|
|
|
|
srcByte = *(srcP + 2);
|
|
|
|
srcP += 2;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k16bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT16(srcP + 1);
|
|
|
|
srcByte = *(srcP + 3);
|
|
|
|
srcP += 3;
|
2012-09-20 10:54:03 +00:00
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
srcByte = *(srcP + 5);
|
|
|
|
srcP += 5;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
Video_Cont3_wVbe:
|
2012-12-21 00:26:11 +00:00
|
|
|
if (srcByte > 210) {
|
2012-10-30 11:48:41 +00:00
|
|
|
if (srcByte == (byte)-45) {
|
|
|
|
destLen1 = *(srcP + 1);
|
|
|
|
rleValue = *(srcP + 2);
|
|
|
|
destSlice1P = destOffset + destSurface;
|
|
|
|
destOffset += destLen1;
|
|
|
|
memset(destSlice1P, rleValue, destLen1);
|
|
|
|
srcP += 3;
|
2012-09-20 10:54:03 +00:00
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
destLen2 = (byte)(*srcP + 45);
|
|
|
|
rleValue = *(srcP + 1);
|
|
|
|
destSlice2P = destOffset + destSurface;
|
|
|
|
destOffset += destLen2;
|
|
|
|
memset(destSlice2P, rleValue, destLen2);
|
|
|
|
srcP += 2;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
*(destOffset + destSurface) = srcByte;
|
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-10-13 05:51:44 +00:00
|
|
|
}}
|
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-10-30 11:48:41 +00:00
|
|
|
int rleValue;
|
|
|
|
int destOffset;
|
|
|
|
const byte *srcP;
|
|
|
|
uint8 srcByte;
|
|
|
|
int destLen1;
|
|
|
|
byte *destSlice1P;
|
|
|
|
int destLen2;
|
|
|
|
byte *destSlice2P;
|
2012-09-20 10:54:03 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-10-30 11:48:41 +00:00
|
|
|
rleValue = 0;
|
|
|
|
destOffset = 0;
|
|
|
|
srcP = srcData;
|
2012-09-20 10:54:03 +00:00
|
|
|
for (;;) {
|
2012-10-30 11:48:41 +00:00
|
|
|
srcByte = *srcP;
|
|
|
|
if (*srcP < 222)
|
2012-09-20 10:54:03 +00:00
|
|
|
goto Video_Cont3_Vbe;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte == kByteStop)
|
2012-09-20 10:54:03 +00:00
|
|
|
return;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte < kSetOffset) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += *srcP + 35;
|
|
|
|
srcByte = *(srcP++ + 1);
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k8bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += *(srcP + 1);
|
|
|
|
srcByte = *(srcP + 2);
|
|
|
|
srcP += 2;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k16bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT16(srcP + 1);
|
|
|
|
srcByte = *(srcP + 3);
|
|
|
|
srcP += 3;
|
2012-09-20 10:54:03 +00:00
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
srcByte = *(srcP + 5);
|
|
|
|
srcP += 5;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
Video_Cont3_Vbe:
|
2012-10-30 11:48:41 +00:00
|
|
|
if (srcByte > 210) {
|
|
|
|
if (srcByte == 211) {
|
|
|
|
destLen1 = *(srcP + 1);
|
|
|
|
rleValue = *(srcP + 2);
|
2012-12-19 01:15:32 +00:00
|
|
|
destSlice1P = destOffset + (byte *)_videoPtr->pixels;
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += destLen1;
|
|
|
|
memset(destSlice1P, rleValue, destLen1);
|
|
|
|
srcP += 3;
|
2012-09-20 10:54:03 +00:00
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
destLen2 = (byte)(*srcP + 45);
|
|
|
|
rleValue = *(srcP + 1);
|
2012-12-19 01:15:32 +00:00
|
|
|
destSlice2P = (byte *)(destOffset + (byte *)_videoPtr->pixels);
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += destLen2;
|
|
|
|
memset(destSlice2P, rleValue, destLen2);
|
|
|
|
srcP += 2;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-12-19 01:15:32 +00:00
|
|
|
*(destOffset + (byte *)_videoPtr->pixels) = srcByte;
|
2012-10-30 11:48:41 +00:00
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
}
|
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;
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-09-15 11:42:20 +00:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
byte srcByte = *srcP;
|
|
|
|
if (srcByte >= 222) {
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte == kByteStop)
|
2012-09-15 11:42:20 +00:00
|
|
|
return;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (srcByte < kSetOffset) {
|
2012-09-15 11:42:20 +00:00
|
|
|
destOffset += srcByte - 221;
|
|
|
|
srcByte = *++srcP;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k8bVal) {
|
2012-09-15 11:42:20 +00:00
|
|
|
destOffset += *(const byte *)(srcP + 1);
|
|
|
|
srcByte = *(const byte *)(srcP + 2);
|
|
|
|
srcP += 2;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (srcByte == k16bVal) {
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-25 10:25:14 +00:00
|
|
|
if (destOffset > SCREEN_WIDTH * SCREEN_HEIGHT) {
|
2012-11-16 07:32:40 +00:00
|
|
|
warning("HACK: Stopping anim, out of bounds - 0x%x %d", srcByte, destOffset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-15 11:42:20 +00:00
|
|
|
if (srcByte > 210) {
|
|
|
|
if (srcByte == 211) {
|
|
|
|
int pixelCount = *(srcP + 1);
|
|
|
|
int pixelIndex = *(srcP + 2);
|
2012-12-19 01:15:32 +00:00
|
|
|
uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2);
|
2012-09-15 11:42:20 +00:00
|
|
|
uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
|
|
|
|
destOffset += pixelCount;
|
|
|
|
|
|
|
|
while (pixelCount--)
|
|
|
|
*destP++ = pixelValue;
|
|
|
|
|
|
|
|
srcP += 3;
|
|
|
|
} else {
|
|
|
|
int pixelCount = srcByte - 211;
|
|
|
|
int pixelIndex = *(srcP + 1);
|
2012-12-19 01:15:32 +00:00
|
|
|
uint16 *destP = (uint16 *)((byte *)_videoPtr->pixels + destOffset * 2);
|
2012-09-15 11:42:20 +00:00
|
|
|
uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
|
|
|
|
destOffset += pixelCount;
|
|
|
|
|
|
|
|
while (pixelCount--)
|
|
|
|
*destP++ = pixelValue;
|
|
|
|
|
|
|
|
srcP += 2;
|
|
|
|
}
|
|
|
|
} else {
|
2012-12-19 01:15:32 +00:00
|
|
|
*((uint16 *)_videoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte);
|
2012-09-15 11:42:20 +00:00
|
|
|
++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-12-14 00:49:22 +00:00
|
|
|
int destOffset;
|
|
|
|
const byte *srcP;
|
|
|
|
byte pixelIndex;
|
2012-10-04 22:09:09 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset = 0;
|
|
|
|
srcP = srcData;
|
2012-10-04 22:09:09 +00:00
|
|
|
for (;;) {
|
2012-10-30 11:48:41 +00:00
|
|
|
pixelIndex = *srcP;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (*srcP < kByteStop)
|
2012-10-04 22:09:09 +00:00
|
|
|
goto Video_Cont_Vbe16a;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (pixelIndex == kByteStop)
|
2012-10-04 22:09:09 +00:00
|
|
|
return;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (pixelIndex == k8bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += *(srcP + 1);
|
|
|
|
pixelIndex = *(srcP + 2);
|
|
|
|
srcP += 2;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (pixelIndex == k16bVal) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT16(srcP + 1);
|
|
|
|
pixelIndex = *(srcP + 3);
|
|
|
|
srcP += 3;
|
2012-10-04 22:09:09 +00:00
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
pixelIndex = *(srcP + 5);
|
|
|
|
srcP += 5;
|
2012-10-04 22:09:09 +00:00
|
|
|
}
|
|
|
|
Video_Cont_Vbe16a:
|
2012-12-19 01:15:32 +00:00
|
|
|
WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex));
|
2012-10-30 11:48:41 +00:00
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
2012-10-04 22:09:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-29 22:08:25 +00:00
|
|
|
void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) {
|
2012-09-20 10:54:03 +00:00
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
2012-12-14 00:49:22 +00:00
|
|
|
int rowCount;
|
2012-10-30 11:48:41 +00:00
|
|
|
int i;
|
2012-12-14 00:49:22 +00:00
|
|
|
int rowCount2;
|
2012-09-20 10:54:03 +00:00
|
|
|
|
2012-10-13 08:38:53 +00:00
|
|
|
// TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within
|
|
|
|
// the screen, and so thus can read areas outside of the allocated surface buffer
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = xs + _lineNbr2 * ys + srcSurface;
|
2012-09-20 10:54:03 +00:00
|
|
|
destP = destSurface;
|
2012-10-13 07:27:14 +00:00
|
|
|
rowCount = height;
|
2012-09-20 10:54:03 +00:00
|
|
|
do {
|
2012-10-13 07:27:14 +00:00
|
|
|
rowCount2 = rowCount;
|
2012-09-20 10:54:03 +00:00
|
|
|
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;
|
2012-10-13 07:27:14 +00:00
|
|
|
destP += 2;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memcpy(destP, srcP, 4 * (width >> 2));
|
|
|
|
srcP += 4 * (width >> 2);
|
2012-10-13 07:27:14 +00:00
|
|
|
destP += 4 * (width >> 2);
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = _lineNbr2 + srcP - width;
|
2012-10-13 07:27:14 +00:00
|
|
|
rowCount = rowCount2 - 1;
|
|
|
|
} while (rowCount2 != 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-12-14 00:49:22 +00:00
|
|
|
|
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
|
2012-12-19 07:00:22 +00:00
|
|
|
byte *destP = surface + (yp - 300) * _lineNbr2 + (xp - 300);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-21 21:48:21 +00:00
|
|
|
// Handling for clipped versus non-clipped
|
|
|
|
if (clip_flag) {
|
|
|
|
// Clipped version
|
2012-12-19 07:00:22 +00:00
|
|
|
for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) {
|
2012-09-21 21:48:21 +00:00
|
|
|
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
|
2012-12-19 07:00:22 +00:00
|
|
|
for (int yc = 0; yc < height; ++yc, destP += _lineNbr2) {
|
2012-09-21 21:48:21 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-21 21:48:21 +00:00
|
|
|
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
|
|
|
if (_vm->_globals.NBBLOC > 0) {
|
2012-11-23 23:16:44 +00:00
|
|
|
for (int idx = 0; idx != _vm->_globals.NBBLOC; idx++)
|
2012-12-16 23:16:49 +00:00
|
|
|
_vm->_globals.BLOC[idx]._activeFl = false;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-20 12:23:07 +00:00
|
|
|
_vm->_globals.NBBLOC = 0;
|
|
|
|
}
|
2012-09-17 06:53:21 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Add VESA Segment
|
2012-09-20 12:23:07 +00:00
|
|
|
void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) {
|
2012-10-30 11:48:41 +00:00
|
|
|
int tempX;
|
|
|
|
int blocCount;
|
|
|
|
bool addFlag;
|
2012-09-20 12:23:07 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
tempX = x1;
|
|
|
|
addFlag = true;
|
2012-09-20 12:23:07 +00:00
|
|
|
if (x2 > max_x)
|
|
|
|
x2 = max_x;
|
|
|
|
if (y2 > max_y)
|
|
|
|
y2 = max_y;
|
|
|
|
if (x1 < min_x)
|
2012-10-30 11:48:41 +00:00
|
|
|
tempX = min_x;
|
2012-09-20 12:23:07 +00:00
|
|
|
if (y1 < min_y)
|
|
|
|
y1 = min_y;
|
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
blocCount = _vm->_globals.NBBLOC;
|
2012-09-20 12:23:07 +00:00
|
|
|
if (_vm->_globals.NBBLOC > 1) {
|
|
|
|
|
2012-11-23 23:16:44 +00:00
|
|
|
int16 blocIndex = 0;
|
2012-09-20 12:23:07 +00:00
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
BlocItem &bloc = _vm->_globals.BLOC[blocIndex];
|
2012-09-20 12:23:07 +00:00
|
|
|
|
2012-12-16 23:16:49 +00:00
|
|
|
if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2
|
|
|
|
&& y1 >= bloc._y1 && y2 <= bloc._y2)
|
2012-10-30 11:48:41 +00:00
|
|
|
addFlag = false;
|
|
|
|
++blocIndex;
|
|
|
|
blocCount = blocIndex;
|
|
|
|
} while (_vm->_globals.NBBLOC + 1 != blocIndex);
|
2012-09-20 12:23:07 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
if (addFlag) {
|
2012-11-18 09:28:03 +00:00
|
|
|
assert(_vm->_globals.NBBLOC < 250);
|
2012-09-20 12:23:07 +00:00
|
|
|
BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC];
|
|
|
|
|
2012-12-16 23:16:49 +00:00
|
|
|
bloc._activeFl = true;
|
|
|
|
bloc._x1 = tempX;
|
|
|
|
bloc._x2 = x2;
|
|
|
|
bloc._y1 = y1;
|
|
|
|
bloc._y2 = y2;
|
2012-09-20 12:23:07 +00:00
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Display VESA Segment
|
2012-09-19 11:34:23 +00:00
|
|
|
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-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
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];
|
2012-12-16 23:16:49 +00:00
|
|
|
if (!bloc._activeFl)
|
2012-09-20 13:30:28 +00:00
|
|
|
continue;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-11 00:53:50 +00:00
|
|
|
if (_vm->_eventsManager._breakoutFl) {
|
2012-12-19 01:15:32 +00:00
|
|
|
Copy_Vga16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1);
|
2012-12-16 23:16:49 +00:00
|
|
|
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);
|
|
|
|
} else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < (_vm->_eventsManager._startPos.x + SCREEN_WIDTH)) {
|
|
|
|
if (bloc._x1 < _vm->_eventsManager._startPos.x)
|
|
|
|
bloc._x1 = _vm->_eventsManager._startPos.x;
|
|
|
|
if (bloc._x2 > (_vm->_eventsManager._startPos.x + SCREEN_WIDTH))
|
|
|
|
bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-15 23:26:54 +00:00
|
|
|
// WORKAROUND: Original didn't lock the screen for access
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
m_scroll16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1);
|
2012-10-13 07:27:14 +00:00
|
|
|
|
2012-12-16 23:16:49 +00:00
|
|
|
dstRect.left = bloc._x1 - _vm->_eventsManager._startPos.x;
|
|
|
|
dstRect.top = bloc._y1;
|
|
|
|
dstRect.setWidth(bloc._x2 - bloc._x1);
|
|
|
|
dstRect.setHeight(bloc._y2 - bloc._y1);
|
2012-10-13 07:27:14 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
unlockScreen();
|
2012-09-20 13:30:28 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-16 23:16:49 +00:00
|
|
|
_vm->_globals.BLOC[idx]._activeFl = false;
|
2012-09-20 13:30:28 +00:00
|
|
|
}
|
2012-10-13 07:27:14 +00:00
|
|
|
|
|
|
|
_vm->_globals.NBBLOC = 0;
|
2012-12-19 01:15:32 +00:00
|
|
|
unlockScreen();
|
2012-10-13 07:27:14 +00:00
|
|
|
if (!_vm->_globals.BPP_NOAFF) {
|
|
|
|
// SDL_UpdateRects(LinuxScr, SDL_NBLOCS, dstrect);
|
|
|
|
}
|
|
|
|
SDL_NBLOCS = 0;
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-11-17 09:49:07 +00:00
|
|
|
void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx) {
|
|
|
|
int height, width;
|
|
|
|
|
2012-12-10 06:54:03 +00:00
|
|
|
width = _vm->_objectsManager.getWidth(objectData, idx);
|
|
|
|
height = _vm->_objectsManager.getHeight(objectData, idx);
|
2012-11-17 09:49:07 +00:00
|
|
|
if (*objectData == 78) {
|
2012-12-19 01:15:32 +00:00
|
|
|
Affiche_Perfect(_vesaScreen, objectData, xp + 300, yp + 300, idx, 0, 0, 0);
|
|
|
|
Affiche_Perfect(_vesaBuffer, objectData, xp + 300, yp + 300, idx, 0, 0, 0);
|
2012-11-17 09:49:07 +00:00
|
|
|
} else {
|
2012-12-19 01:15:32 +00:00
|
|
|
Sprite_Vesa(_vesaBuffer, objectData, xp + 300, yp + 300, idx);
|
|
|
|
Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx);
|
2012-11-17 09:49:07 +00:00
|
|
|
}
|
|
|
|
if (!_vm->_globals.NO_VISU)
|
|
|
|
Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height);
|
|
|
|
}
|
|
|
|
|
2012-09-19 11:34:23 +00:00
|
|
|
void GraphicsManager::CopyAsm(const byte *surface) {
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *srcP;
|
2012-09-20 10:54:03 +00:00
|
|
|
byte srcByte;
|
2012-12-14 00:49:22 +00:00
|
|
|
byte *destP;
|
|
|
|
byte *dest1P;
|
|
|
|
byte *dest2P;
|
|
|
|
byte *dest3P;
|
|
|
|
byte *destPitch;
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *srcPitch;
|
2012-09-20 10:54:03 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-10-30 11:48:41 +00:00
|
|
|
srcP = surface;
|
2012-09-20 10:54:03 +00:00
|
|
|
srcByte = 30 * WinScan;
|
2012-12-19 01:15:32 +00:00
|
|
|
destP = (byte *)_videoPtr->pixels + 30 * WinScan;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int yCtr = 200; yCtr != 0; yCtr--) {
|
2012-10-30 11:48:41 +00:00
|
|
|
srcPitch = srcP;
|
|
|
|
destPitch = destP;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int xCtr = 320; xCtr != 0; xCtr--) {
|
2012-10-30 11:48:41 +00:00
|
|
|
srcByte = *srcP;
|
|
|
|
*destP = *srcP;
|
|
|
|
dest1P = WinScan + destP;
|
|
|
|
*dest1P = srcByte;
|
|
|
|
dest2P = dest1P - WinScan + 1;
|
|
|
|
*dest2P = srcByte;
|
|
|
|
dest3P = WinScan + dest2P;
|
|
|
|
*dest3P = srcByte;
|
|
|
|
destP = dest3P - WinScan + 1;
|
|
|
|
++srcP;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
srcP = srcPitch + 320;
|
|
|
|
destP = WinScan + WinScan + destPitch;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
|
2012-11-17 09:49:07 +00:00
|
|
|
void GraphicsManager::CopyAsm16(const byte *surface) {
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *v1;
|
|
|
|
byte *v2;
|
|
|
|
int v3;
|
|
|
|
byte *v5;
|
|
|
|
uint16 *v6;
|
|
|
|
int v;
|
|
|
|
uint16 *v8;
|
|
|
|
int v9;
|
|
|
|
byte *v10;
|
|
|
|
const byte *v11;
|
2012-11-17 09:49:07 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-11-17 09:49:07 +00:00
|
|
|
v1 = surface;
|
2012-12-19 01:15:32 +00:00
|
|
|
v2 = 30 * WinScan + (byte *)_videoPtr->pixels;
|
2012-11-17 09:49:07 +00:00
|
|
|
v3 = 200;
|
|
|
|
do {
|
|
|
|
v11 = v1;
|
|
|
|
v10 = v2;
|
|
|
|
v9 = v3;
|
|
|
|
v5 = PAL_PIXELS;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int v4 = 320; v4; v4--) {
|
2012-11-17 09:49:07 +00:00
|
|
|
v = 2 * *v1;
|
|
|
|
v6 = (uint16 *)(v5 + 2 * *v1);
|
|
|
|
v = *v6;
|
|
|
|
*v2 = *v6;
|
|
|
|
*(v2 + 1) = v;
|
|
|
|
v8 = (uint16 *)(WinScan + v2);
|
|
|
|
*v8 = v;
|
|
|
|
*(v8 + 1) = v;
|
|
|
|
++v1;
|
|
|
|
v2 = (byte *)v8 - WinScan + 4;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-11-17 09:49:07 +00:00
|
|
|
v1 = v11 + 320;
|
|
|
|
v2 = WinScan * 2 + v10;
|
|
|
|
v3 = v9 - 1;
|
|
|
|
} while (v9 != 1);
|
|
|
|
}
|
|
|
|
|
2012-10-24 23:43:31 +00:00
|
|
|
void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) {
|
2012-10-30 11:48:41 +00:00
|
|
|
byte *destP;
|
|
|
|
int yNext;
|
2012-10-24 23:43:31 +00:00
|
|
|
const byte *srcP;
|
2012-10-30 11:48:41 +00:00
|
|
|
int i;
|
2012-10-24 23:43:31 +00:00
|
|
|
int yCtr;
|
2012-09-20 10:54:03 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
destP = xp + _lineNbr2 * yp + destSurface;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = height;
|
2012-10-24 23:43:31 +00:00
|
|
|
srcP = src;
|
2012-09-20 10:54:03 +00:00
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
yCtr = yNext;
|
2012-10-24 23:43:31 +00:00
|
|
|
if (width & 1) {
|
2012-10-30 11:48:41 +00:00
|
|
|
memcpy(destP, srcP, width);
|
2012-10-24 23:43:31 +00:00
|
|
|
srcP += width;
|
2012-10-30 11:48:41 +00:00
|
|
|
destP += width;
|
2012-10-24 23:43:31 +00:00
|
|
|
} else if (width & 2) {
|
|
|
|
for (i = width >> 1; i; --i) {
|
2012-10-30 11:48:41 +00:00
|
|
|
*(uint16 *)destP = *(uint16 *)srcP;
|
2012-10-24 23:43:31 +00:00
|
|
|
srcP += 2;
|
2012-10-30 11:48:41 +00:00
|
|
|
destP += 2;
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-10-30 11:48:41 +00:00
|
|
|
memcpy(destP, srcP, 4 * (width >> 2));
|
2012-10-24 23:43:31 +00:00
|
|
|
srcP += 4 * (width >> 2);
|
2012-10-30 11:48:41 +00:00
|
|
|
destP += 4 * (width >> 2);
|
2012-09-20 10:54:03 +00:00
|
|
|
}
|
2012-12-19 07:00:22 +00:00
|
|
|
destP = _lineNbr2 + destP - width;
|
2012-10-30 11:48:41 +00:00
|
|
|
yNext = yCtr - 1;
|
2012-10-24 23:43:31 +00:00
|
|
|
} while (yCtr != 1);
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 21:46:09 +00:00
|
|
|
/**
|
|
|
|
* Compute the value of a parameter plus a given percentage
|
|
|
|
*/
|
|
|
|
int GraphicsManager::zoomIn( int v, int percentage ) {
|
2012-09-20 10:54:03 +00:00
|
|
|
if (v)
|
|
|
|
v += percentage * (long int)v / 100;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-20 10:54:03 +00:00
|
|
|
return v;
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 21:46:09 +00:00
|
|
|
/**
|
|
|
|
* Compute the value of a parameter minus a given percentage
|
|
|
|
*/
|
|
|
|
int GraphicsManager::zoomOut(int v, int percentage) {
|
2012-09-21 10:54:26 +00:00
|
|
|
if (v)
|
|
|
|
v -= percentage * (long int)v / 100;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-21 10:54:26 +00:00
|
|
|
return v;
|
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
|
|
|
// Display 'Perfect?'
|
2012-11-01 11:35:33 +00:00
|
|
|
void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, int modeFlag) {
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *spriteStartP;
|
|
|
|
int i;
|
2012-10-30 22:04:29 +00:00
|
|
|
const byte *spriteSizeP;
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *spritePixelsP;
|
|
|
|
byte *dest1P;
|
|
|
|
byte *dest2P;
|
|
|
|
byte *v29;
|
|
|
|
byte *v40;
|
|
|
|
const byte *v45;
|
|
|
|
const byte *v46;
|
2012-09-21 10:54:26 +00:00
|
|
|
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteStartP = srcData + 3;
|
2012-10-22 11:31:46 +00:00
|
|
|
for (i = frameIndex; i; --i)
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteStartP += READ_LE_UINT32(spriteStartP) + 16;
|
|
|
|
|
|
|
|
spriteSizeP = spriteStartP + 4;
|
2012-11-23 23:16:44 +00:00
|
|
|
int spriteWidth = (int16)READ_LE_UINT16(spriteSizeP);
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteSizeP += 2;
|
2012-11-23 23:16:44 +00:00
|
|
|
int spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP);
|
|
|
|
int spriteHeight1 = spriteHeight2;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP = spriteSizeP + 10;
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_x = 0;
|
|
|
|
clip_y = 0;
|
|
|
|
clip_x1 = 0;
|
|
|
|
clip_y1 = 0;
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)xp300 > min_x) {
|
|
|
|
if ((uint16)xp300 < (uint16)(min_x + 300))
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_x = min_x + 300 - xp300;
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)yp300 > min_y) {
|
|
|
|
if ((uint16)yp300 < (uint16)(min_y + 300))
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_y = min_y + 300 - yp300;
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)xp300 < (uint16)(max_x + 300)) {
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_x1 = max_x + 300 - xp300;
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)yp300 < (uint16)(max_y + 300)) {
|
2012-10-12 23:23:33 +00:00
|
|
|
clip_y1 = max_y + 300 - yp300;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P = xp300 + _lineNbr2 * (yp300 - 300) - 300 + surface;
|
2012-11-01 11:35:33 +00:00
|
|
|
if (zoom2) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Compteur_y = 0;
|
|
|
|
Agr_x = 0;
|
|
|
|
Agr_y = 0;
|
|
|
|
Agr_Flag_y = 0;
|
|
|
|
Agr_Flag_x = 0;
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = spriteWidth;
|
2012-12-15 21:46:09 +00:00
|
|
|
int v20 = zoomIn(spriteWidth, zoom2);
|
|
|
|
int v22 = zoomIn(spriteHeight1, zoom2);
|
2012-11-01 11:35:33 +00:00
|
|
|
if (modeFlag) {
|
2012-10-30 22:04:29 +00:00
|
|
|
v29 = v20 + dest1P;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_y) {
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)clip_y >= v22)
|
2012-09-21 10:54:26 +00:00
|
|
|
return;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v61 = v22;
|
|
|
|
int v52 = v20;
|
|
|
|
int v30 = 0;
|
|
|
|
int v31 = (uint16)clip_y;
|
2012-12-15 21:46:09 +00:00
|
|
|
while (zoomIn(v30 + 1, zoom2) < v31)
|
2012-10-12 23:23:33 +00:00
|
|
|
;
|
|
|
|
v20 = v52;
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP += _width * v30;
|
2012-12-19 07:00:22 +00:00
|
|
|
v29 += _lineNbr2 * (uint16)clip_y;
|
2012-10-22 12:26:40 +00:00
|
|
|
v22 = v61 - (uint16)clip_y;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-10-22 12:26:40 +00:00
|
|
|
if (v22 > (uint16)clip_y1)
|
|
|
|
v22 = (uint16)clip_y1;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_x) {
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)clip_x >= v20)
|
2012-09-21 10:54:26 +00:00
|
|
|
return;
|
2012-10-22 12:26:40 +00:00
|
|
|
v20 -= (uint16)clip_x;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-22 12:26:40 +00:00
|
|
|
if (v20 > (uint16)clip_x1) {
|
2012-11-23 23:16:44 +00:00
|
|
|
int v32 = v20 - (uint16)clip_x1;
|
2012-10-12 23:23:33 +00:00
|
|
|
v29 -= v32;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v62 = v22;
|
|
|
|
int v33 = 0;
|
2012-12-15 21:46:09 +00:00
|
|
|
while (zoomIn(v33 + 1, zoom2) < v32)
|
2012-10-12 23:23:33 +00:00
|
|
|
;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v34 = v33;
|
2012-10-12 23:23:33 +00:00
|
|
|
v22 = v62;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += v34;
|
2012-10-22 12:26:40 +00:00
|
|
|
v20 = (uint16)clip_x1;
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
2012-11-23 23:16:44 +00:00
|
|
|
int v63;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-12 23:23:33 +00:00
|
|
|
v63 = v22;
|
2012-11-23 23:16:44 +00:00
|
|
|
byte *v53 = v29;
|
2012-10-30 22:04:29 +00:00
|
|
|
v46 = spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_x = 0;
|
|
|
|
Agr_x = 0;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int v35 = v20; v35; v35--) {
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (*spritePixelsP)
|
|
|
|
*v29 = *spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
--v29;
|
2012-10-30 22:04:29 +00:00
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (!Agr_Flag_x)
|
2012-11-01 11:35:33 +00:00
|
|
|
Agr_x = zoom2 + Agr_x;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Agr_x < 100)
|
2012-10-12 23:23:33 +00:00
|
|
|
break;
|
|
|
|
Agr_x = Agr_x - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
--spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
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;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-10-12 23:23:33 +00:00
|
|
|
R_Aff_Zoom_Larg_Cont1:
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP = _width + v46;
|
2012-12-19 07:00:22 +00:00
|
|
|
v29 = _lineNbr2 + v53;
|
2012-10-12 23:23:33 +00:00
|
|
|
++Compteur_y;
|
|
|
|
if (!Agr_Flag_y)
|
2012-11-01 11:35:33 +00:00
|
|
|
Agr_y = zoom2 + Agr_y;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Agr_y < 100)
|
2012-10-12 23:23:33 +00:00
|
|
|
break;
|
|
|
|
Agr_y = Agr_y - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP = v46;
|
2012-10-12 23:23:33 +00:00
|
|
|
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) {
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)clip_y >= v22)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v58 = v22;
|
|
|
|
int v49 = v20;
|
|
|
|
int v23 = 0;
|
|
|
|
int v24 = (uint16)clip_y;
|
2012-12-15 21:46:09 +00:00
|
|
|
while (zoomIn(v23 + 1, zoom2) < v24)
|
2012-10-12 23:23:33 +00:00
|
|
|
;
|
|
|
|
v20 = v49;
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP += _width * v23;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P += _lineNbr2 * (uint16)clip_y;
|
2012-10-22 12:26:40 +00:00
|
|
|
v22 = v58 - (uint16)clip_y;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-22 12:26:40 +00:00
|
|
|
if (v22 > (uint16)clip_y1)
|
|
|
|
v22 = (uint16)clip_y1;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_x) {
|
2012-10-22 12:26:40 +00:00
|
|
|
if ((uint16)clip_x >= v20)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v59 = v22;
|
|
|
|
int v50 = v20;
|
|
|
|
int v25 = (uint16)clip_x;
|
|
|
|
int v26 = 0;
|
2012-12-15 21:46:09 +00:00
|
|
|
while (zoomIn(v26 + 1, zoom2) < v25)
|
2012-10-12 23:23:33 +00:00
|
|
|
;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v27 = v26;
|
2012-10-12 23:23:33 +00:00
|
|
|
v22 = v59;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += v27;
|
|
|
|
dest1P += (uint16)clip_x;
|
2012-10-22 12:26:40 +00:00
|
|
|
v20 = v50 - (uint16)clip_x;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-22 12:26:40 +00:00
|
|
|
if (v20 > (uint16)clip_x1)
|
|
|
|
v20 = (uint16)clip_x1;
|
2012-11-18 04:21:16 +00:00
|
|
|
|
2012-11-23 23:16:44 +00:00
|
|
|
int v60;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-12 23:23:33 +00:00
|
|
|
v60 = v22;
|
2012-11-23 23:16:44 +00:00
|
|
|
byte *v51 = dest1P;
|
2012-10-30 22:04:29 +00:00
|
|
|
v45 = spritePixelsP;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v28 = v20;
|
2012-10-12 23:23:33 +00:00
|
|
|
Agr_Flag_x = 0;
|
|
|
|
Agr_x = 0;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (*spritePixelsP)
|
|
|
|
*dest1P = *spritePixelsP;
|
|
|
|
++dest1P;
|
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (!Agr_Flag_x)
|
2012-11-01 11:35:33 +00:00
|
|
|
Agr_x = zoom2 + Agr_x;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Agr_x < 100)
|
2012-10-12 23:23:33 +00:00
|
|
|
break;
|
|
|
|
Agr_x = Agr_x - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
--spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
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:
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP = _width + v45;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P = _lineNbr2 + v51;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (!Agr_Flag_y)
|
2012-11-01 11:35:33 +00:00
|
|
|
Agr_y = zoom2 + Agr_y;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Agr_y < 100)
|
2012-10-12 23:23:33 +00:00
|
|
|
break;
|
|
|
|
Agr_y = Agr_y - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP = v45;
|
2012-10-12 23:23:33 +00:00
|
|
|
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-11-01 11:35:33 +00:00
|
|
|
} else if (zoom1) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Compteur_y = 0;
|
|
|
|
Red_x = 0;
|
|
|
|
Red_y = 0;
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = spriteWidth;
|
2012-11-01 11:35:33 +00:00
|
|
|
Red = zoom1;
|
|
|
|
if (zoom1 < 100) {
|
2012-12-15 21:46:09 +00:00
|
|
|
int v37 = zoomOut(spriteWidth, Red);
|
2012-11-01 11:35:33 +00:00
|
|
|
if (modeFlag) {
|
2012-10-30 22:04:29 +00:00
|
|
|
v40 = v37 + dest1P;
|
2012-10-12 23:23:33 +00:00
|
|
|
do {
|
2012-11-23 23:16:44 +00:00
|
|
|
int v65 = spriteHeight2;
|
|
|
|
byte *v55 = v40;
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_y = Red + Red_y;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Red_y < 100) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_x = 0;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v42 = v37;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int v41 = _width; v41; v41--) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_x = Red + Red_x;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Red_x < 100) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP)
|
|
|
|
*v40 = *spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
--v40;
|
2012-10-30 22:04:29 +00:00
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
--v42;
|
|
|
|
} else {
|
|
|
|
Red_x = Red_x - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight2 = v65;
|
2012-12-19 07:00:22 +00:00
|
|
|
v40 = _lineNbr2 + v55;
|
2012-10-12 23:23:33 +00:00
|
|
|
} else {
|
|
|
|
Red_y = Red_y - 100;
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP += _width;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
--spriteHeight2;
|
|
|
|
} while (spriteHeight2);
|
2012-10-12 23:23:33 +00:00
|
|
|
} else {
|
|
|
|
do {
|
2012-11-23 23:16:44 +00:00
|
|
|
int v64 = spriteHeight2;
|
|
|
|
byte *v54 = dest1P;
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_y = Red + Red_y;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Red_y < 100) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_x = 0;
|
2012-11-23 23:16:44 +00:00
|
|
|
int v39 = 0;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int v38 = _width; v38; v38--) {
|
2012-10-12 23:23:33 +00:00
|
|
|
Red_x = Red + Red_x;
|
2012-12-21 00:26:11 +00:00
|
|
|
if ((uint16)Red_x < 100) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP)
|
|
|
|
*dest1P = *spritePixelsP;
|
|
|
|
++dest1P;
|
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
++v39;
|
|
|
|
} else {
|
|
|
|
Red_x = Red_x - 100;
|
2012-10-30 22:04:29 +00:00
|
|
|
++spritePixelsP;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight2 = v64;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P = _lineNbr2 + v54;
|
2012-10-12 23:23:33 +00:00
|
|
|
} else {
|
|
|
|
Red_y = Red_y - 100;
|
2012-12-17 23:37:52 +00:00
|
|
|
spritePixelsP += _width;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
--spriteHeight2;
|
|
|
|
} while (spriteHeight2);
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = spriteWidth;
|
2012-10-12 23:23:33 +00:00
|
|
|
Compteur_y = 0;
|
2012-11-01 11:35:33 +00:00
|
|
|
if (modeFlag) {
|
2012-10-30 22:04:29 +00:00
|
|
|
dest2P = spriteWidth + dest1P;
|
|
|
|
spec_largeur = spriteWidth;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_y) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if ((uint16)clip_y >= (unsigned int)spriteHeight1)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += spriteWidth * (uint16)clip_y;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest2P += _lineNbr2 * (uint16)clip_y;
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight1 -= (uint16)clip_y;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-11-23 23:16:44 +00:00
|
|
|
int xLeft = (uint16)clip_y1;
|
2012-10-30 22:04:29 +00:00
|
|
|
if (spriteHeight1 > clip_y1)
|
|
|
|
spriteHeight1 = clip_y1;
|
|
|
|
xLeft = clip_x;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_x) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (xLeft >= spriteWidth)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteWidth -= xLeft;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
if (spriteWidth > (uint16)clip_x1) {
|
2012-11-23 23:16:44 +00:00
|
|
|
int clippedWidth = spriteWidth - (uint16)clip_x1;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += clippedWidth;
|
|
|
|
dest2P -= clippedWidth;
|
|
|
|
spriteWidth = (uint16)clip_x1;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-11-23 23:16:44 +00:00
|
|
|
int yCtr2;
|
2012-09-21 10:54:26 +00:00
|
|
|
do {
|
2012-10-30 22:04:29 +00:00
|
|
|
yCtr2 = spriteHeight1;
|
2012-11-23 23:16:44 +00:00
|
|
|
byte *destCopy2P = dest2P;
|
|
|
|
const byte *spritePixelsCopy2P = spritePixelsP;
|
|
|
|
for (int xCtr2 = spriteWidth; xCtr2; xCtr2--) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (*spritePixelsP)
|
|
|
|
*dest2P = *spritePixelsP;
|
|
|
|
++spritePixelsP;
|
|
|
|
--dest2P;
|
2012-11-23 23:16:44 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP = spec_largeur + spritePixelsCopy2P;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest2P = _lineNbr2 + destCopy2P;
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight1 = yCtr2 - 1;
|
|
|
|
} while (yCtr2 != 1);
|
2012-10-12 23:23:33 +00:00
|
|
|
} else {
|
2012-10-30 22:04:29 +00:00
|
|
|
spec_largeur = spriteWidth;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_y) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if ((uint16)clip_y >= (unsigned int)spriteHeight1)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += spriteWidth * (uint16)clip_y;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P += _lineNbr2 * (uint16)clip_y;
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight1 -= (uint16)clip_y;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
if (spriteHeight1 > clip_y1)
|
|
|
|
spriteHeight1 = clip_y1;
|
2012-10-12 23:23:33 +00:00
|
|
|
if (clip_x) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if ((uint16)clip_x >= spriteWidth)
|
2012-10-12 23:23:33 +00:00
|
|
|
return;
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP += (uint16)clip_x;
|
|
|
|
dest1P += (uint16)clip_x;
|
|
|
|
spriteWidth -= (uint16)clip_x;
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
if (spriteWidth > (uint16)clip_x1)
|
|
|
|
spriteWidth = (uint16)clip_x1;
|
2012-11-23 23:16:44 +00:00
|
|
|
int yCtr1;
|
2012-10-12 23:23:33 +00:00
|
|
|
do {
|
2012-10-30 22:04:29 +00:00
|
|
|
yCtr1 = spriteHeight1;
|
2012-11-23 23:16:44 +00:00
|
|
|
byte *dest1CopyP = dest1P;
|
|
|
|
const byte *spritePixelsCopyP = spritePixelsP;
|
|
|
|
for (int xCtr1 = spriteWidth; xCtr1; xCtr1--) {
|
2012-10-30 22:04:29 +00:00
|
|
|
if (*spritePixelsP)
|
|
|
|
*dest1P = *spritePixelsP;
|
|
|
|
++dest1P;
|
|
|
|
++spritePixelsP;
|
2012-11-23 23:16:44 +00:00
|
|
|
}
|
2012-10-30 22:04:29 +00:00
|
|
|
spritePixelsP = spec_largeur + spritePixelsCopyP;
|
2012-12-19 07:00:22 +00:00
|
|
|
dest1P = _lineNbr2 + dest1CopyP;
|
2012-10-30 22:04:29 +00:00
|
|
|
spriteHeight1 = yCtr1 - 1;
|
|
|
|
} while (yCtr1 != 1);
|
2012-10-12 23:23:33 +00:00
|
|
|
}
|
2012-09-21 10:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-19 11:34:23 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Display Speed
|
2012-09-22 00:36:18 +00:00
|
|
|
void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) {
|
|
|
|
int width, height;
|
|
|
|
|
2012-12-10 06:54:03 +00:00
|
|
|
width = _vm->_objectsManager.getWidth(spriteData, spriteIndex);
|
|
|
|
height = _vm->_objectsManager.getHeight(spriteData, spriteIndex);
|
2012-09-22 00:36:18 +00:00
|
|
|
if (*spriteData == 78) {
|
2012-12-19 01:15:32 +00:00
|
|
|
Affiche_Perfect(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
|
|
|
|
Affiche_Perfect(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
|
2012-09-22 00:36:18 +00:00
|
|
|
} else {
|
2012-12-19 01:15:32 +00:00
|
|
|
Sprite_Vesa(_vesaBuffer, spriteData, xp + 300, yp + 300, spriteIndex);
|
|
|
|
Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex);
|
2012-09-22 00:36:18 +00:00
|
|
|
}
|
|
|
|
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-12-14 00:49:22 +00:00
|
|
|
int top;
|
|
|
|
int croppedWidth;
|
2012-09-28 12:15:59 +00:00
|
|
|
int croppedHeight;
|
2012-12-14 00:49:22 +00:00
|
|
|
int xRight;
|
|
|
|
int top2;
|
2012-09-23 00:59:52 +00:00
|
|
|
int left;
|
|
|
|
|
|
|
|
left = x1;
|
|
|
|
top = y1;
|
2012-09-28 12:15:59 +00:00
|
|
|
croppedWidth = width;
|
|
|
|
croppedHeight = height;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
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;
|
2012-10-30 11:48:41 +00:00
|
|
|
xRight = left + croppedWidth;
|
|
|
|
if (xRight > 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) {
|
2012-11-23 23:16:44 +00:00
|
|
|
int height2 = croppedHeight;
|
2012-09-28 12:15:59 +00:00
|
|
|
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) {
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
2012-09-23 00:59:52 +00:00
|
|
|
int yp;
|
|
|
|
int yCurrent;
|
|
|
|
byte *dest2P;
|
|
|
|
const byte *src2P;
|
2012-12-14 00:49:22 +00:00
|
|
|
unsigned int pitch;
|
2012-09-23 00:59:52 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = x1 + _lineNbr2 * y1 + srcSurface;
|
|
|
|
destP = destX + _lineNbr2 * destY + destSurface;
|
2012-09-23 00:59:52 +00:00
|
|
|
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);
|
2012-12-19 07:00:22 +00:00
|
|
|
destP = (dest2P + pitch + _lineNbr2 - width);
|
|
|
|
srcP = (src2P + pitch + _lineNbr2 - width);
|
2012-09-23 00:59:52 +00:00
|
|
|
yp = yCurrent - 1;
|
|
|
|
} while (yCurrent != 1);
|
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Display Font
|
2012-12-14 00:49:22 +00:00
|
|
|
void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp,
|
2012-10-15 09:49:17 +00:00
|
|
|
int characterIndex, int colour) {
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *spriteDataP;
|
2012-12-14 00:49:22 +00:00
|
|
|
int i;
|
|
|
|
const byte *spriteSizeP;
|
|
|
|
int spriteWidth;
|
2012-10-30 11:48:41 +00:00
|
|
|
int spriteHeight;
|
|
|
|
const byte *spritePixelsP;
|
2012-09-26 12:13:15 +00:00
|
|
|
byte *destP;
|
2012-10-30 11:48:41 +00:00
|
|
|
byte destByte;
|
2012-09-26 12:13:15 +00:00
|
|
|
byte *destLineP;
|
2012-10-30 11:48:41 +00:00
|
|
|
int yCtr;
|
2012-09-26 12:13:15 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
spriteDataP = spriteData + 3;
|
2012-09-26 12:13:15 +00:00
|
|
|
for (i = characterIndex; i; --i)
|
2012-10-30 11:48:41 +00:00
|
|
|
spriteDataP += READ_LE_UINT32(spriteDataP) + 16;
|
|
|
|
|
|
|
|
spriteWidth = 0;
|
|
|
|
spriteHeight = 0;
|
|
|
|
spriteSizeP = spriteDataP + 4;
|
|
|
|
spriteWidth = (int16)READ_LE_UINT16(spriteSizeP);
|
|
|
|
spriteSizeP += 2;
|
|
|
|
spriteHeight = (int16)READ_LE_UINT16(spriteSizeP);
|
|
|
|
spritePixelsP = spriteSizeP + 10;
|
2012-12-19 07:00:22 +00:00
|
|
|
destP = surface + xp + _lineNbr2 * yp;
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = spriteWidth;
|
2012-09-26 12:13:15 +00:00
|
|
|
|
|
|
|
do {
|
2012-10-30 11:48:41 +00:00
|
|
|
yCtr = spriteHeight;
|
2012-09-26 12:13:15 +00:00
|
|
|
destLineP = destP;
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int xCtr = spriteWidth; xCtr; xCtr--) {
|
2012-10-30 11:48:41 +00:00
|
|
|
destByte = *spritePixelsP;
|
|
|
|
if (*spritePixelsP) {
|
|
|
|
if (destByte == (byte)-4)
|
|
|
|
destByte = colour;
|
|
|
|
*destP = destByte;
|
2012-09-26 12:13:15 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-26 12:13:15 +00:00
|
|
|
++destP;
|
2012-10-30 11:48:41 +00:00
|
|
|
++spritePixelsP;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-12-19 07:00:22 +00:00
|
|
|
destP = _lineNbr2 + destLineP;
|
2012-10-30 11:48:41 +00:00
|
|
|
spriteHeight = yCtr - 1;
|
|
|
|
} while (yCtr != 1);
|
2012-09-26 12:13:15 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Init Screen
|
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
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Init Screen 2
|
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);
|
|
|
|
}
|
|
|
|
|
2012-10-29 22:08:25 +00:00
|
|
|
void GraphicsManager::OPTI_INI(const Common::String &file, int mode) {
|
2012-11-23 23:16:44 +00:00
|
|
|
Common::String filename = file + ".ini";
|
2012-12-09 19:22:12 +00:00
|
|
|
byte *ptr = _vm->_fileManager.searchCat(filename, 1);
|
2012-09-30 11:02:39 +00:00
|
|
|
|
2012-10-10 11:33:44 +00:00
|
|
|
if (ptr == g_PTRNUL) {
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename);
|
|
|
|
ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
2012-10-29 22:08:25 +00:00
|
|
|
if (!mode) {
|
2012-10-30 11:48:41 +00:00
|
|
|
filename = file + ".spr";
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_globals.freeMemory(_vm->_globals.SPRITE_ECRAN);
|
2012-09-30 11:02:39 +00:00
|
|
|
if (!_vm->_globals.NOSPRECRAN) {
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8);
|
2012-09-30 11:02:39 +00:00
|
|
|
if (_vm->_globals.SPRITE_ECRAN) {
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename);
|
2012-09-30 11:02:39 +00:00
|
|
|
} else {
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES");
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
|
|
|
}
|
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 {
|
2012-11-23 23:16:44 +00:00
|
|
|
bool doneFlag = false;
|
2012-11-24 14:32:56 +00:00
|
|
|
int dataOffset = 1;
|
|
|
|
|
2012-09-30 11:02:39 +00:00
|
|
|
do {
|
2012-11-23 23:16:44 +00:00
|
|
|
int dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset);
|
2012-10-28 13:00:18 +00:00
|
|
|
if (_vm->shouldQuit())
|
|
|
|
return;
|
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
if (dataVal1 == 2)
|
|
|
|
dataOffset = _vm->_scriptManager.Control_Goto((ptr + 20 * dataOffset));
|
|
|
|
if (dataVal1 == 3)
|
|
|
|
dataOffset = _vm->_scriptManager.Control_If(ptr, dataOffset);
|
|
|
|
if (dataOffset == -1)
|
2012-09-30 12:18:50 +00:00
|
|
|
error("Error, defective IFF");
|
2012-10-30 11:48:41 +00:00
|
|
|
if (dataVal1 == 1 || dataVal1 == 4)
|
|
|
|
++dataOffset;
|
|
|
|
if (!dataVal1 || dataVal1 == 5)
|
|
|
|
doneFlag = true;
|
|
|
|
} while (!doneFlag);
|
2012-09-30 11:02:39 +00:00
|
|
|
}
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.freeMemory(ptr);
|
2012-10-29 22:08:25 +00:00
|
|
|
if (mode != 1) {
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_globals.COUCOU = _vm->_globals.freeMemory(_vm->_globals.COUCOU);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-30 11:48:41 +00:00
|
|
|
filename = file + ".rep";
|
2012-12-09 19:22:12 +00:00
|
|
|
byte *dataP = _vm->_fileManager.searchCat(filename, 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-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename);
|
|
|
|
dataP = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER);
|
2012-09-30 11:02:39 +00:00
|
|
|
_vm->_globals.COUCOU = dataP;
|
|
|
|
}
|
|
|
|
}
|
2012-12-16 08:56:50 +00:00
|
|
|
_vm->_objectsManager._forceZoneFl = true;
|
|
|
|
_vm->_objectsManager._changeVerbFl = false;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GraphicsManager::NB_SCREEN() {
|
2012-12-14 00:49:22 +00:00
|
|
|
byte *destP;
|
2012-10-30 11:48:41 +00:00
|
|
|
const byte *srcP;
|
2012-09-28 12:15:59 +00:00
|
|
|
|
|
|
|
if (!_vm->_globals.NECESSAIRE)
|
|
|
|
INIT_TABLE(50, 65, Palette);
|
2012-12-21 00:26:11 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
if (_lineNbr == SCREEN_WIDTH)
|
2012-12-21 00:26:11 +00:00
|
|
|
Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT);
|
2012-12-19 07:00:22 +00:00
|
|
|
else if (_lineNbr == (SCREEN_WIDTH * 2))
|
2012-12-21 00:26:11 +00:00
|
|
|
Trans_bloc2(_vesaBuffer, TABLE_COUL, SCREEN_WIDTH * SCREEN_HEIGHT * 2);
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
lockScreen();
|
|
|
|
m_scroll16(_vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
|
|
unlockScreen();
|
|
|
|
|
|
|
|
destP = _vesaScreen;
|
|
|
|
srcP = _vesaBuffer;
|
2012-12-21 00:26:11 +00:00
|
|
|
memcpy(_vesaScreen, _vesaBuffer, 614396);
|
2012-10-30 11:48:41 +00:00
|
|
|
srcP = srcP + 614396;
|
|
|
|
destP = destP + 614396;
|
|
|
|
*destP = *srcP;
|
|
|
|
*(destP + 2) = *(srcP + 2);
|
2012-09-28 12:15:59 +00:00
|
|
|
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) {
|
2012-12-14 00:49:22 +00:00
|
|
|
int result;
|
|
|
|
int destOffset;
|
|
|
|
const byte *srcPtr;
|
|
|
|
byte byteVal;
|
2012-10-04 22:09:09 +00:00
|
|
|
|
|
|
|
result = 0;
|
|
|
|
destOffset = 0;
|
|
|
|
srcPtr = src;
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-04 22:09:09 +00:00
|
|
|
byteVal = *srcPtr;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (*srcPtr < kByteStop)
|
2012-10-04 22:09:09 +00:00
|
|
|
goto Video_Cont_wVbe;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (byteVal == kByteStop)
|
2012-10-04 22:09:09 +00:00
|
|
|
return;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (byteVal == k8bVal) {
|
2012-10-04 22:09:09 +00:00
|
|
|
destOffset += *(srcPtr + 1);
|
|
|
|
byteVal = *(srcPtr + 2);
|
|
|
|
srcPtr += 2;
|
2012-11-16 07:32:40 +00:00
|
|
|
} else if (byteVal == k16bVal) {
|
2012-10-28 11:10:14 +00:00
|
|
|
destOffset += 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) {
|
2012-12-14 00:49:22 +00:00
|
|
|
int destOffset;
|
|
|
|
const byte *srcP;
|
|
|
|
byte byteVal;
|
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
assert(_videoPtr);
|
2012-10-04 22:09:09 +00:00
|
|
|
destOffset = 0;
|
|
|
|
srcP = src;
|
2012-12-04 20:36:53 +00:00
|
|
|
for (;;) {
|
2012-10-04 22:09:09 +00:00
|
|
|
byteVal = *srcP;
|
2012-11-16 07:32:40 +00:00
|
|
|
if (*srcP < kByteStop)
|
2012-12-19 07:00:22 +00:00
|
|
|
break;
|
|
|
|
else {
|
|
|
|
if (byteVal == kByteStop)
|
|
|
|
return;
|
|
|
|
if (byteVal == k8bVal) {
|
|
|
|
destOffset += *(srcP + 1);
|
|
|
|
byteVal = *(srcP + 2);
|
|
|
|
srcP += 2;
|
|
|
|
} else if (byteVal == k16bVal) {
|
|
|
|
destOffset += READ_LE_UINT16(srcP + 1);
|
|
|
|
byteVal = *(srcP + 3);
|
|
|
|
srcP += 3;
|
|
|
|
} else {
|
|
|
|
destOffset += READ_LE_UINT32(srcP + 1);
|
|
|
|
byteVal = *(srcP + 5);
|
|
|
|
srcP += 5;
|
|
|
|
}
|
2012-10-04 22:09:09 +00:00
|
|
|
}
|
2012-12-19 07:00:22 +00:00
|
|
|
|
2012-12-19 01:15:32 +00:00
|
|
|
*((byte *)_videoPtr->pixels + destOffset) = byteVal;
|
2012-10-04 22:09:09 +00:00
|
|
|
++srcP;
|
|
|
|
++destOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Reduce Screen
|
2012-10-24 10:54:54 +00:00
|
|
|
void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) {
|
2012-12-14 00:49:22 +00:00
|
|
|
const byte *srcP;
|
|
|
|
byte *destP;
|
2012-10-05 14:45:07 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
srcP = xp + _lineNbr2 * yp + srcSurface;
|
2012-10-24 10:54:54 +00:00
|
|
|
destP = destSurface;
|
|
|
|
Red = zoom;
|
2012-12-17 23:37:52 +00:00
|
|
|
_width = width;
|
2012-10-05 14:45:07 +00:00
|
|
|
Red_x = 0;
|
|
|
|
Red_y = 0;
|
2012-10-24 10:54:54 +00:00
|
|
|
if (zoom < 100) {
|
2012-12-15 21:46:09 +00:00
|
|
|
Reduc_Ecran_L = zoomOut(width, Red);
|
|
|
|
Reduc_Ecran_H = zoomOut(height, Red);
|
2012-10-24 10:54:54 +00:00
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
for (int yCtr = 0; yCtr < height; ++yCtr, srcP += _lineNbr2) {
|
2012-10-24 10:54:54 +00:00
|
|
|
Red_y += Red;
|
|
|
|
if (Red_y < 100) {
|
2012-10-05 14:45:07 +00:00
|
|
|
Red_x = 0;
|
2012-11-23 23:16:44 +00:00
|
|
|
const byte *lineSrcP = srcP;
|
2012-10-24 10:54:54 +00:00
|
|
|
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int xCtr = 0; xCtr < _width; ++xCtr) {
|
2012-10-24 10:54:54 +00:00
|
|
|
Red_x += Red;
|
|
|
|
if (Red_x < 100) {
|
|
|
|
*destP++ = *lineSrcP++;
|
2012-10-05 14:45:07 +00:00
|
|
|
} else {
|
2012-10-24 10:54:54 +00:00
|
|
|
Red_x -= 100;
|
|
|
|
++lineSrcP;
|
2012-10-05 14:45:07 +00:00
|
|
|
}
|
2012-10-24 10:54:54 +00:00
|
|
|
}
|
2012-10-27 23:43:08 +00:00
|
|
|
} else {
|
|
|
|
Red_y -= 100;
|
2012-10-05 14:45:07 +00:00
|
|
|
}
|
2012-10-24 10:54:54 +00:00
|
|
|
}
|
2012-10-05 14:45:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-17 23:37:52 +00:00
|
|
|
/**
|
|
|
|
* Draw horizontal line
|
|
|
|
*/
|
|
|
|
void GraphicsManager::drawHorizontalLine(byte *surface, int xp, int yp, unsigned int width, byte col) {
|
2012-12-19 07:00:22 +00:00
|
|
|
memset(surface + xp + _lineNbr2 * yp, col, width);
|
2012-10-11 11:53:59 +00:00
|
|
|
}
|
|
|
|
|
2012-12-17 23:37:52 +00:00
|
|
|
/**
|
|
|
|
* Draw vertical line
|
|
|
|
*/
|
|
|
|
void GraphicsManager::drawVerticalLine(byte *surface, int xp, int yp, int height, byte col) {
|
2012-12-19 07:00:22 +00:00
|
|
|
byte *destP = surface + xp + _lineNbr2 * yp;
|
2012-10-11 11:53:59 +00:00
|
|
|
|
2012-12-17 23:37:52 +00:00
|
|
|
for (int yCtr = height; yCtr; yCtr--) {
|
2012-10-30 11:48:41 +00:00
|
|
|
*destP = col;
|
2012-12-19 07:00:22 +00:00
|
|
|
destP += _lineNbr2;
|
2012-12-17 23:37:52 +00:00
|
|
|
}
|
2012-10-11 11:53:59 +00:00
|
|
|
}
|
|
|
|
|
2012-12-19 07:00:22 +00:00
|
|
|
void GraphicsManager::setModeVesa() {
|
2012-12-19 01:15:32 +00:00
|
|
|
setGraphicalMode(640, 480);
|
2012-12-04 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
2012-09-08 11:43:33 +00:00
|
|
|
} // End of namespace Hopkins
|