aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-10-13 12:56:53 +0000
committerMax Horn2003-10-13 12:56:53 +0000
commit5acafb15c295b104e280cf3edf5094cebdaa5be7 (patch)
treea5ff1b8006a7bef82c718b7c05a81d9c7dc43a0e /scumm
parent1f16d325342e129d90d4e306df5538c8e4296b18 (diff)
downloadscummvm-rg350-5acafb15c295b104e280cf3edf5094cebdaa5be7.tar.gz
scummvm-rg350-5acafb15c295b104e280cf3edf5094cebdaa5be7.tar.bz2
scummvm-rg350-5acafb15c295b104e280cf3edf5094cebdaa5be7.zip
cleanup; got rid of Gdi::_palette_mod in favor of Gdi::_roomPalette
svn-id: r10778
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp62
-rw-r--r--scumm/gfx.h6
-rw-r--r--scumm/scumm.h22
-rw-r--r--scumm/scummvm.cpp77
4 files changed, 88 insertions, 79 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index a23fa681e9..7ddc0ce128 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -191,10 +191,25 @@ static const byte default_cursor_hotspots[10] = {
};
+#pragma mark -
+
+
static inline uint colorWeight(int red, int green, int blue) {
return 3 * red * red + 6 * green * green + 2 * blue * blue;
}
+
+#pragma mark -
+
+
+Gdi::Gdi(ScummEngine *vm) {
+ memset(this, 0, sizeof(*this));
+ _vm = vm;
+ _roomPalette = vm->_roomPalette;
+ if (vm->_features & GF_AMIGA)
+ _roomPalette += 16;
+}
+
void ScummEngine::getGraphicsPerformance() {
int i;
@@ -284,7 +299,7 @@ void ScummEngine::initVirtScreen(int slot, int number, int top, int width, int h
}
if (slot != 3) {
- virtscr[slot].setDirtyRange(0, height);
+ vs->setDirtyRange(0, height);
}
}
@@ -1052,7 +1067,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi
run = data >> 4;
dither = false;
}
- color = _vm->_roomPalette[data & 0x0f];
+ color = _roomPalette[data & 0x0f];
if (run == 0) {
run = *src++;
}
@@ -1349,9 +1364,9 @@ void Gdi::drawStripC64Background(byte *dst, int stripnr, int height) {
for (int y = 0; y < height; y++) {
_C64Colors[3] = (_C64ColorMap[y + stripnr * height] & 7);
// Check for room color change in V1 zak
- if (_vm->_roomPalette[0] == 255) {
- _C64Colors[2] = _vm->_roomPalette[2];
- _C64Colors[1] = _vm->_roomPalette[1];
+ if (_roomPalette[0] == 255) {
+ _C64Colors[2] = _roomPalette[2];
+ _C64Colors[1] = _roomPalette[1];
}
charIdx = _C64PicMap[y + stripnr * height] * 8;
@@ -1451,7 +1466,7 @@ void Gdi::decodeStripEGA(byte *dst, const byte *src, int height) {
run = *src++;
}
for (z = 0; z < run; z++) {
- *(dst + y * _vm->_screenWidth + x) = (z&1) ? _vm->_roomPalette[((color & 0xf) + _palette_mod)] : _vm->_roomPalette[((color >> 4) + _palette_mod)];
+ *(dst + y * _vm->_screenWidth + x) = (z&1) ? _roomPalette[color & 0xf] : _roomPalette[color >> 4];
y++;
if (y >= height) {
@@ -1481,7 +1496,7 @@ void Gdi::decodeStripEGA(byte *dst, const byte *src, int height) {
}
for (z = 0; z < run; z++) {
- *(dst + y * _vm->_screenWidth + x) = _vm->_roomPalette[(color & 0xf) + _palette_mod];
+ *(dst + y * _vm->_screenWidth + x) = _roomPalette[color & 0xf];
y++;
if (y >= height) {
@@ -1498,11 +1513,6 @@ bool Gdi::decompressBitmap(byte *bgbak_ptr, const byte *src, int numLinesToProce
byte code = *src++;
- if (_vm->_features & GF_AMIGA)
- _palette_mod = 16;
- else
- _palette_mod = 0;
-
bool useOrDecompress = false;
_decomp_shr = code % 10;
_decomp_mask = 0xFF >> (8 - _decomp_shr);
@@ -1770,7 +1780,7 @@ void Gdi::unkDecodeA(byte *dst, const byte *src, int height) {
int x = 8;
do {
FILL_BITS;
- *dst++ = _vm->_roomPalette[color + _palette_mod];
+ *dst++ = _roomPalette[color];
againPos:
if (!READ_BIT) {
@@ -1795,7 +1805,7 @@ void Gdi::unkDecodeA(byte *dst, const byte *src, int height) {
if (!--height)
return;
}
- *dst++ = _vm->_roomPalette[color + _palette_mod];
+ *dst++ = _roomPalette[color];
} while (--reps);
bits >>= 8;
bits |= (*src++) << (cl - 8);
@@ -1819,7 +1829,7 @@ void Gdi::unkDecodeA_trans(byte *dst, const byte *src, int height) {
do {
FILL_BITS;
if (color != _transparentColor)
- *dst = _vm->_roomPalette[color + _palette_mod];
+ *dst = _roomPalette[color];
dst++;
againPos:
@@ -1846,7 +1856,7 @@ void Gdi::unkDecodeA_trans(byte *dst, const byte *src, int height) {
return;
}
if (color != _transparentColor)
- *dst = _vm->_roomPalette[color + _palette_mod];
+ *dst = _roomPalette[color];
dst++;
} while (--reps);
bits >>= 8;
@@ -1870,7 +1880,7 @@ void Gdi::unkDecodeB(byte *dst, const byte *src, int height) {
int x = 8;
do {
FILL_BITS;
- *dst++ = _vm->_roomPalette[color + _palette_mod];
+ *dst++ = _roomPalette[color];
if (!READ_BIT) {
} else if (!READ_BIT) {
FILL_BITS;
@@ -1901,7 +1911,7 @@ void Gdi::unkDecodeB_trans(byte *dst, const byte *src, int height) {
do {
FILL_BITS;
if (color != _transparentColor)
- *dst = _vm->_roomPalette[color + _palette_mod];
+ *dst = _roomPalette[color];
dst++;
if (!READ_BIT) {
} else if (!READ_BIT) {
@@ -1933,7 +1943,7 @@ void Gdi::unkDecodeC(byte *dst, const byte *src, int height) {
int h = height;
do {
FILL_BITS;
- *dst = _vm->_roomPalette[color + _palette_mod];
+ *dst = _roomPalette[color];
dst += _vm->_screenWidth;
if (!READ_BIT) {
} else if (!READ_BIT) {
@@ -1966,7 +1976,7 @@ void Gdi::unkDecodeC_trans(byte *dst, const byte *src, int height) {
do {
FILL_BITS;
if (color != _transparentColor)
- *dst = _vm->_roomPalette[color + _palette_mod];
+ *dst = _roomPalette[color];
dst += _vm->_screenWidth;
if (!READ_BIT) {
} else if (!READ_BIT) {
@@ -2043,7 +2053,7 @@ void Gdi::unkDecode8(byte *dst, const byte *src, int height) {
byte color = *src++;
do {
- *dst = _vm->_roomPalette[color];
+ *dst = _roomPalette[color];
NEXT_ROW;
} while (--run);
}
@@ -2072,7 +2082,7 @@ void Gdi::unkDecode9(byte *dst, const byte *src, int height) {
color += bits << i;
}
for (i = 0; i < ((c & 3) + 2); i++) {
- *dst = _vm->_roomPalette[run * 16 + color];
+ *dst = _roomPalette[run * 16 + color];
NEXT_ROW;
}
break;
@@ -2084,7 +2094,7 @@ void Gdi::unkDecode9(byte *dst, const byte *src, int height) {
READ_256BIT;
color += bits << j;
}
- *dst = _vm->_roomPalette[run * 16 + color];
+ *dst = _roomPalette[run * 16 + color];
NEXT_ROW;
}
break;
@@ -2113,13 +2123,13 @@ void Gdi::unkDecode10(byte *dst, const byte *src, int height) {
for (;;) {
byte color = *src++;
if (color < numcolors) {
- *dst = _vm->_roomPalette[local_palette[color]];
+ *dst = _roomPalette[local_palette[color]];
NEXT_ROW;
} else {
uint run = color - numcolors + 1;
color = *src++;
do {
- *dst = _vm->_roomPalette[color];
+ *dst = _roomPalette[color];
NEXT_ROW;
} while (--run);
}
@@ -2136,7 +2146,7 @@ void Gdi::unkDecode11(byte *dst, const byte *src, int height) {
do {
int h = height;
do {
- *dst = _vm->_roomPalette[color];
+ *dst = _roomPalette[color];
dst += _vm->_screenWidth;
for (i = 0; i < 3; i++) {
READ_256BIT;
diff --git a/scumm/gfx.h b/scumm/gfx.h
index 3e4b588962..5dc17a97f0 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -110,17 +110,19 @@ struct StripTable {
class Gdi {
friend class ScummEngine; // Mostly for the code in saveload.cpp ...
-public:
ScummEngine *_vm;
+public:
int _numZBuffer;
int _imgBufOffs[8];
int32 _numStrips;
Common::Rect _mask;
byte _C64Colors[4];
+
+ Gdi(ScummEngine *vm);
protected:
- byte _palette_mod;
+ byte *_roomPalette;
byte _decomp_shr, _decomp_mask;
byte _transparentColor;
uint32 _vertStripNextInc;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 52b4f72044..4b233e5ea9 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -267,11 +267,20 @@ public:
ObjectData *_objs;
ScummDebugger *_debugger;
+ // Core variables
+ byte _gameId;
byte _version;
-
uint32 _features; // Should only be accessed for reading (TODO enforce it compiler-wise with making it private and creating an accessor)
+
void setFeatures (uint32 newFeatures); // Changes the features set. This allows some gamewide stuff to be precalculated/prepared (ie CostumeRenderer)
+ /** Random number generator */
+ Common::RandomSource _rnd;
+
+ /** Graphics manager */
+ Gdi gdi;
+
+ /** Central resource data. */
struct {
byte mode[rtNumTypes];
uint16 num[rtNumTypes];
@@ -357,17 +366,6 @@ protected:
protected:
byte _fastMode;
-public:
- /* Random number generation */
- Common::RandomSource _rnd;
-
- /* Core variable definitions */
- byte _gameId;
-
- /* Core class/array definitions */
- Gdi gdi;
-
-protected:
Actor *_actors; // Has _numActors elements
uint16 *_inventory;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index e3ec54f1f3..8c94c25d87 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -269,14 +269,18 @@ static const GameSettings scumm_settings[] = {
};
ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
- : Engine(detector, syst), _pauseDialog(0), _optionsDialog(0), _saveLoadDialog(0) {
+ : Engine(detector, syst),
+ _targetName(detector->_targetName),
+ _gameId(detector->_game.id),
+ _version(detector->_game.version),
+ _features(detector->_game.features),
+ gdi(this), _pauseDialog(0), _optionsDialog(0), _saveLoadDialog(0) {
OSystem::Property prop;
// Init all vars - maybe now we can get rid of our custom new/delete operators?
_imuse = NULL;
_imuseDigital = NULL;
_musicEngine = NULL;
- _features = 0;
_verbs = NULL;
_objs = NULL;
_debugger = NULL;
@@ -295,8 +299,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
_confirmExitDialog = NULL;
_debuggerDialog = NULL;
_fastMode = 0;
- _gameId = 0;
- memset(&gdi, 0, sizeof(Gdi));
_actors = NULL;
_inventory = NULL;
_newNames = NULL;
@@ -587,8 +589,10 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
// Use g_scumm from error() ONLY
g_scumm = this;
+ // Create debugger
_debugger = new ScummDebugger(this);
+ // Read settings from the detector & config manager
_debugMode = detector->_debugMode;
_debugLevel = ConfMan.getInt("debuglevel");
_dumpScripts = detector->_dumpScripts;
@@ -599,16 +603,12 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
// differing from the regular version(s) of that game.
_gameName = ConfMan.hasKey("basename") ? ConfMan.get("basename") : detector->_game.gameName;
- _targetName = detector->_targetName;
- _gameId = detector->_game.id;
- _version = detector->_game.version;
- setFeatures(detector->_game.features);
+ _midiDriver = detector->_midi_driver;
_demoMode = ConfMan.getBool("demo_mode");
_noSubtitles = ConfMan.getBool("nosubtitles");
_confirmExit = ConfMan.getBool("confirm_exit");
_defaultTalkDelay = ConfMan.getInt("talkspeed");
- _midiDriver = detector->_midi_driver;
_native_mt32 = ConfMan.getBool("native_mt32");
_language = GameDetector::parseLanguage(ConfMan.get("language"));
memset(&res, 0, sizeof(res));
@@ -629,21 +629,22 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
_screenHeight = 200;
}
+ // Initialize backend
+ syst->init_size(_screenWidth, _screenHeight);
+ prop.cd_num = ConfMan.getInt("cdrom");
+ if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS))
+ syst->property(OSystem::PROP_OPEN_CD, &prop);
+
+ // Setup GDI object
gdi._numStrips = _screenWidth / 8;
_newgui = g_gui;
- _sound = new Sound(this);
+ _sound = new Sound(this);
_sound->_sound_volume_master = ConfMan.getInt("master_volume");
_sound->_sound_volume_sfx = ConfMan.getInt("sfx_volume");
_sound->_sound_volume_music = ConfMan.getInt("music_volume");
- /* Initialize backend */
- syst->init_size(_screenWidth, _screenHeight);
- prop.cd_num = ConfMan.getInt("cdrom");
- if (prop.cd_num >= 0 && (_features & GF_AUDIOTRACKS))
- syst->property(OSystem::PROP_OPEN_CD, &prop);
-
#ifndef __GP32__ //ph0x FIXME, "quick dirty hack"
/* Bind the mixer to the system => mixer will be invoked
* automatically when samples need to be generated */
@@ -751,6 +752,22 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
fp.close();
}
}
+
+ // Create the charset renderer
+ if (_version <= 2)
+ _charset = new CharsetRendererV2(this);
+ else if (_version == 3)
+ _charset = new CharsetRendererV3(this);
+ else if (_version == 8)
+ _charset = new CharsetRendererNut(this);
+ else
+ _charset = new CharsetRendererClassic(this);
+
+ // Create the costume renderer
+ if (_features & GF_NEW_COSTUMES)
+ _costumeRenderer = new AkosRenderer(this);
+ else
+ _costumeRenderer = new CostumeRenderer(this);
}
ScummEngine::~ScummEngine() {
@@ -806,7 +823,6 @@ void ScummEngine::go() {
#pragma mark -
void ScummEngine::launch() {
- gdi._vm = this;
#ifdef __PALM_OS__
// revert to old value (450000) and make ScummVM works again in some devices with same problem as below.
@@ -889,22 +905,16 @@ void ScummEngine::launch() {
_saveLoadFlag = 0;
}
-void ScummEngine::setFeatures (uint32 newFeatures) {
- bool newCostumes = (_features & GF_NEW_COSTUMES) != 0;
- bool newNewCostumes = (newFeatures & GF_NEW_COSTUMES) != 0;
+void ScummEngine::setFeatures(uint32 newFeatures) {
bool amigaPalette = (_features & GF_AMIGA) != 0;
bool newAmigaPalette = (newFeatures & GF_AMIGA) != 0;
- _features = newFeatures;
-
- if (!_costumeRenderer || newCostumes != newNewCostumes) {
- delete _costumeRenderer;
- if (newNewCostumes)
- _costumeRenderer = new AkosRenderer(this);
- else
- _costumeRenderer = new CostumeRenderer(this);
+ if ((_features ^ newFeatures) & ~GF_AMIGA) {
+ error("setFeatures may only be used to toggle GF_AMIGA flag!");
}
+ _features = newFeatures;
+
if ((_features & GF_16COLOR) && amigaPalette != newAmigaPalette) {
if (_features & GF_AMIGA)
setupAmigaPalette();
@@ -952,17 +962,6 @@ void ScummEngine::scummInit() {
_switchRoomEffect = 5;
}
- if (_version <= 2)
- _charset = new CharsetRendererV2(this);
- else if (_version == 3)
- _charset = new CharsetRendererV3(this);
- else if (_version == 8)
- _charset = new CharsetRendererNut(this);
- else
- _charset = new CharsetRendererClassic(this);
-
- memset(_charsetData, 0, sizeof(_charsetData));
-
if (!(_features & GF_SMALL_NAMES) && _version != 8)
loadCharset(1);