[Scummvm-cvs-logs] SF.net SVN: scummvm: [26252] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Tue Mar 20 15:51:59 CET 2007
Revision: 26252
http://scummvm.svn.sourceforge.net/scummvm/?rev=26252&view=rev
Author: drmccoy
Date: 2007-03-20 07:51:57 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Major clean-up, including:
- Cutting down the code-dup
- Plucking leaks
- Removing dead/unused code
- Properly naming "word_2342F"-style variables and functions (removing the warnings alongside)
- Fleshing out the "stubby" functions
- Moving functions and variables to more appropriate/logical places
- Re-ordering functions and variables
- Re-structuring functions
- Moving the IMD stuff into a new "Imd" class in the new imd.cpp/.h (still to be completely implemented and cleaned up)
- Formatting
- Getting rid off the classes "Anim", "Pack" and "Timer", along with their files
Modified Paths:
--------------
scummvm/trunk/engines/gob/cdrom.cpp
scummvm/trunk/engines/gob/cdrom.h
scummvm/trunk/engines/gob/dataio.cpp
scummvm/trunk/engines/gob/dataio.h
scummvm/trunk/engines/gob/detection.cpp
scummvm/trunk/engines/gob/draw.cpp
scummvm/trunk/engines/gob/draw.h
scummvm/trunk/engines/gob/draw_bargon.cpp
scummvm/trunk/engines/gob/draw_v1.cpp
scummvm/trunk/engines/gob/draw_v2.cpp
scummvm/trunk/engines/gob/driver_vga.cpp
scummvm/trunk/engines/gob/driver_vga.h
scummvm/trunk/engines/gob/game.cpp
scummvm/trunk/engines/gob/game.h
scummvm/trunk/engines/gob/game_v1.cpp
scummvm/trunk/engines/gob/game_v2.cpp
scummvm/trunk/engines/gob/global.cpp
scummvm/trunk/engines/gob/global.h
scummvm/trunk/engines/gob/gob.cpp
scummvm/trunk/engines/gob/gob.h
scummvm/trunk/engines/gob/goblin.cpp
scummvm/trunk/engines/gob/goblin.h
scummvm/trunk/engines/gob/goblin_v1.cpp
scummvm/trunk/engines/gob/goblin_v2.cpp
scummvm/trunk/engines/gob/init.cpp
scummvm/trunk/engines/gob/init.h
scummvm/trunk/engines/gob/init_v1.cpp
scummvm/trunk/engines/gob/init_v2.cpp
scummvm/trunk/engines/gob/inter.cpp
scummvm/trunk/engines/gob/inter.h
scummvm/trunk/engines/gob/inter_bargon.cpp
scummvm/trunk/engines/gob/inter_v1.cpp
scummvm/trunk/engines/gob/inter_v2.cpp
scummvm/trunk/engines/gob/map.cpp
scummvm/trunk/engines/gob/map.h
scummvm/trunk/engines/gob/map_v1.cpp
scummvm/trunk/engines/gob/map_v2.cpp
scummvm/trunk/engines/gob/module.mk
scummvm/trunk/engines/gob/mult.cpp
scummvm/trunk/engines/gob/mult.h
scummvm/trunk/engines/gob/mult_v1.cpp
scummvm/trunk/engines/gob/mult_v2.cpp
scummvm/trunk/engines/gob/music.cpp
scummvm/trunk/engines/gob/music.h
scummvm/trunk/engines/gob/palanim.cpp
scummvm/trunk/engines/gob/palanim.h
scummvm/trunk/engines/gob/parse.cpp
scummvm/trunk/engines/gob/parse.h
scummvm/trunk/engines/gob/parse_v1.cpp
scummvm/trunk/engines/gob/parse_v2.cpp
scummvm/trunk/engines/gob/scenery.cpp
scummvm/trunk/engines/gob/scenery.h
scummvm/trunk/engines/gob/scenery_v1.cpp
scummvm/trunk/engines/gob/scenery_v2.cpp
scummvm/trunk/engines/gob/sound.cpp
scummvm/trunk/engines/gob/sound.h
scummvm/trunk/engines/gob/util.cpp
scummvm/trunk/engines/gob/util.h
scummvm/trunk/engines/gob/video.cpp
scummvm/trunk/engines/gob/video.h
scummvm/trunk/engines/gob/video_v1.cpp
scummvm/trunk/engines/gob/video_v2.cpp
Added Paths:
-----------
scummvm/trunk/engines/gob/imd.cpp
scummvm/trunk/engines/gob/imd.h
Removed Paths:
-------------
scummvm/trunk/engines/gob/anim.cpp
scummvm/trunk/engines/gob/anim.h
scummvm/trunk/engines/gob/pack.cpp
scummvm/trunk/engines/gob/pack.h
scummvm/trunk/engines/gob/timer.cpp
scummvm/trunk/engines/gob/timer.h
Deleted: scummvm/trunk/engines/gob/anim.cpp
===================================================================
--- scummvm/trunk/engines/gob/anim.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/anim.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -1,37 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 Ivan Dubrov
- * Copyright (C) 2004-2006 The ScummVM project
- *
- * 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.
- *
- * $URL$
- * $Id$
- *
- */
-#include "gob/gob.h"
-#include "gob/video.h"
-#include "gob/anim.h"
-
-namespace Gob {
-
-Anim::Anim() {
- _areaLeft = 0;
- _areaTop = 0;
- _areaWidth = 0;
- _areaHeight = 0;
- _animSurf = 0;
-}
-
-} // End of namespace Gob
Deleted: scummvm/trunk/engines/gob/anim.h
===================================================================
--- scummvm/trunk/engines/gob/anim.h 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/anim.h 2007-03-20 14:51:57 UTC (rev 26252)
@@ -1,43 +0,0 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2004 Ivan Dubrov
- * Copyright (C) 2004-2006 The ScummVM project
- *
- * 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.
- *
- * $URL$
- * $Id$
- *
- */
-#ifndef GOB_ANIM_H
-#define GOB_ANIM_H
-
-#include "gob/video.h"
-
-namespace Gob {
-
-class Anim {
-public:
- int16 _areaLeft;
- int16 _areaTop;
- int16 _areaWidth;
- int16 _areaHeight;
- Video::SurfaceDesc *_animSurf;
-
- Anim();
-};
-
-} // End of namespace Gob
-
-#endif
Modified: scummvm/trunk/engines/gob/cdrom.cpp
===================================================================
--- scummvm/trunk/engines/gob/cdrom.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/cdrom.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -22,19 +22,20 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "sound/audiocd.h"
#include "gob/gob.h"
#include "gob/cdrom.h"
-#include "gob/dataio.h"
-#include "gob/game.h"
#include "gob/global.h"
#include "gob/util.h"
-#include "sound/audiocd.h"
+#include "gob/dataio.h"
+#include "gob/game.h"
namespace Gob {
CDROM::CDROM(GobEngine *vm) : _vm(vm) {
_cdPlaying = false;
+
_LICbuffer = 0;
for (int i = 0; i < 16; i++)
_curTrack[i] = 0;
@@ -54,50 +55,48 @@
strcpy(tmp, fname);
- handle = _vm->_dataio->openData(tmp);
+ handle = _vm->_dataIO->openData(tmp);
if (handle == -1)
return;
- _vm->_dataio->closeData(handle);
+ _vm->_dataIO->closeData(handle);
- _vm->_dataio->getUnpackedData(tmp);
+ _vm->_dataIO->getUnpackedData(tmp);
- handle = _vm->_dataio->openData(tmp);
+ handle = _vm->_dataIO->openData(tmp);
- _vm->_dataio->readData(handle, (char *)&version, 2);
+ _vm->_dataIO->readData(handle, (char *)&version, 2);
version = READ_LE_UINT16(&version);
- _vm->_dataio->readData(handle, (char *)&startChunk, 2);
+ _vm->_dataIO->readData(handle, (char *)&startChunk, 2);
startChunk = READ_LE_UINT16(&startChunk);
- _vm->_dataio->readData(handle, (char *)&_numTracks, 2);
+ _vm->_dataIO->readData(handle, (char *)&_numTracks, 2);
_numTracks = READ_LE_UINT16(&_numTracks);
- if (version != 3) {
- error("Wrong file %s (%d)", fname, version);
- return;
- }
+ if (version != 3)
+ error("%s: Unknown version %d", fname, version);
- _vm->_dataio->seekData(handle, 50, SEEK_SET);
+ _vm->_dataIO->seekData(handle, 50, SEEK_SET);
for (int i = 0; i < startChunk; i++) {
- _vm->_dataio->readData(handle, (char *)&pos, 2);
+ _vm->_dataIO->readData(handle, (char *)&pos, 2);
pos = READ_LE_UINT16(&pos);
if (!pos)
break;
- _vm->_dataio->seekData(handle, pos, SEEK_CUR);
+ _vm->_dataIO->seekData(handle, pos, SEEK_CUR);
}
_LICbuffer = new byte[_numTracks * 22];
- _vm->_dataio->readData(handle, (char *)_LICbuffer, _numTracks * 22);
+ _vm->_dataIO->readData(handle, (char *)_LICbuffer, _numTracks * 22);
- _vm->_dataio->closeData(handle);
+ _vm->_dataIO->closeData(handle);
}
-void CDROM::freeLICbuffer(void) {
+void CDROM::freeLICbuffer() {
delete[] _LICbuffer;
_LICbuffer = 0;
}
@@ -208,7 +207,7 @@
_cdPlaying = true;
}
-int32 CDROM::getTrackPos(void) {
+int32 CDROM::getTrackPos() {
uint32 curPos = _vm->_util->getTimeKey() - _startTime;
if (_cdPlaying && (_vm->_util->getTimeKey() < _trackStop))
@@ -217,17 +216,17 @@
return -1;
}
-const char *CDROM::getCurTrack(void) {
+const char *CDROM::getCurTrack() {
return _curTrack;
}
-void CDROM::stopPlaying(void) {
+void CDROM::stopPlaying() {
stop();
while (getTrackPos() != -1);
}
-void CDROM::stop(void) {
+void CDROM::stop() {
debugC(1, kDebugMusic, "CDROM::stop()");
AudioCD.stop();
Modified: scummvm/trunk/engines/gob/cdrom.h
===================================================================
--- scummvm/trunk/engines/gob/cdrom.h 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/cdrom.h 2007-03-20 14:51:57 UTC (rev 26252)
@@ -23,8 +23,6 @@
#ifndef GOB_CDROM_H
#define GOB_CDROM_H
-#include "gob/gob.h"
-
namespace Gob {
class CDROM {
@@ -32,16 +30,16 @@
bool _cdPlaying;
void readLIC(const char *fname);
- void freeLICbuffer(void);
+ void freeLICbuffer();
void startTrack(const char *s);
void playBgMusic();
void playMultMusic();
void play(uint32 from, uint32 to);
- int32 getTrackPos(void);
- const char *getCurTrack(void);
- void stopPlaying(void);
- void stop(void);
+ int32 getTrackPos();
+ const char *getCurTrack();
+ void stopPlaying();
+ void stop();
void testCD(int trySubst, const char *label);
CDROM(GobEngine *vm);
@@ -57,4 +55,4 @@
} // End of namespace Gob
-#endif
+#endif // GOB_CDROM_H
Modified: scummvm/trunk/engines/gob/dataio.cpp
===================================================================
--- scummvm/trunk/engines/gob/dataio.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/dataio.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -20,16 +20,89 @@
* $Id$
*
*/
+
+#include "common/stdafx.h"
+#include "common/endian.h"
+
#include "gob/gob.h"
+#include "gob/dataio.h"
#include "gob/global.h"
-#include "gob/dataio.h"
-#include "gob/pack.h"
namespace Gob {
DataIO::DataIO(GobEngine *vm) : _vm(vm) {
+ for (int i = 0; i < MAX_DATA_FILES; i++) {
+ _dataFiles[i] = 0;
+ _numDataChunks[i] = 0;
+ _dataFileHandles[i] = -1;
+ }
+ _packedSize = 0;
}
+int32 DataIO::unpackData(char *sourceBuf, char *destBuf) {
+ uint32 realSize;
+ uint32 counter;
+ uint16 cmd;
+ byte *src;
+ byte *dest;
+ byte *tmpBuf;
+ int16 off;
+ byte len;
+ uint16 tmpIndex;
+
+ tmpBuf = new byte[4114];
+ assert(tmpBuf);
+
+ counter = realSize = READ_LE_UINT32(sourceBuf);
+
+ for (int i = 0; i < 4078; i++)
+ tmpBuf[i] = 0x20;
+ tmpIndex = 4078;
+
+ src = (byte *) (sourceBuf + 4);
+ dest = (byte *) destBuf;
+
+ cmd = 0;
+ while (1) {
+ cmd >>= 1;
+ if ((cmd & 0x0100) == 0) {
+ cmd = *src | 0xFF00;
+ src++;
+ }
+ if ((cmd & 1) != 0) { /* copy */
+ *dest++ = *src;
+ tmpBuf[tmpIndex] = *src;
+ src++;
+ tmpIndex++;
+ tmpIndex %= 4096;
+ counter--;
+ if (counter == 0)
+ break;
+ } else { /* copy string */
+
+ off = *src++;
+ off |= (*src & 0xF0) << 4;
+ len = (*src & 0x0F) + 3;
+ src++;
+
+ for (int i = 0; i < len; i++) {
+ *dest++ = tmpBuf[(off + i) % 4096];
+ counter--;
+ if (counter == 0) {
+ delete[] tmpBuf;
+ return realSize;
+ }
+ tmpBuf[tmpIndex] = tmpBuf[(off + i) % 4096];
+ tmpIndex++;
+ tmpIndex %= 4096;
+ }
+
+ }
+ }
+ delete[] tmpBuf;
+ return realSize;
+}
+
Common::File *DataIO::file_getHandle(int16 handle) {
return &_vm->_global->_filesHandles[handle];
}
@@ -53,34 +126,29 @@
}
int16 DataIO::getChunk(const char *chunkName) {
- int16 file;
int16 slot;
- int16 chunk;
struct ChunkDesc *dataDesc;
- for (file = 0; file < MAX_DATA_FILES; file++) {
- if (_vm->_global->_dataFiles[file] == 0)
+ for (int16 file = 0; file < MAX_DATA_FILES; file++) {
+ if (_dataFiles[file] == 0)
return -1;
for (slot = 0; slot < MAX_SLOT_COUNT; slot++)
- if (_vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] == -1)
+ if (_chunkPos[file * MAX_SLOT_COUNT + slot] == -1)
break;
if (slot == MAX_SLOT_COUNT)
return -1;
- dataDesc = _vm->_global->_dataFiles[file];
- for (chunk = 0; chunk < _vm->_global->_numDataChunks[file];
- chunk++, dataDesc++) {
+ dataDesc = _dataFiles[file];
+ for (int16 chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
if (scumm_stricmp(chunkName, dataDesc->chunkName) != 0)
continue;
- _vm->_global->_isCurrentSlot[file * MAX_SLOT_COUNT + slot] = 0;
- _vm->_global->_chunkSize[file * MAX_SLOT_COUNT + slot] =
- dataDesc->size;
- _vm->_global->_chunkOffset[file * MAX_SLOT_COUNT + slot] =
- dataDesc->offset;
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] = 0;
+ _isCurrentSlot[file * MAX_SLOT_COUNT + slot] = false;
+ _chunkSize[file * MAX_SLOT_COUNT + slot] = dataDesc->size;
+ _chunkOffset[file * MAX_SLOT_COUNT + slot] = dataDesc->offset;
+ _chunkPos[file * MAX_SLOT_COUNT + slot] = 0;
return file * 10 + slot + 50;
}
}
@@ -88,45 +156,47 @@
}
char DataIO::freeChunk(int16 handle) {
- if (handle >= 50 && handle < 100) {
+ if ((handle >= 50) && (handle < 100)) {
handle -= 50;
- _vm->_global->_chunkPos[(handle / 10) * MAX_SLOT_COUNT + (handle % 10)] = -1;
+ _chunkPos[(handle / 10) * MAX_SLOT_COUNT + (handle % 10)] = -1;
return 0;
}
return 1;
}
-int32 DataIO::readChunk(int16 handle, char *buf, int16 size) {
+int32 DataIO::readChunk(int16 handle, char *buf, uint16 size) {
int16 file;
int16 slot;
int16 i;
int32 offset;
- if (handle < 50 || handle >= 100)
+ if ((handle < 50) || (handle >= 100))
return -2;
file = (handle - 50) / 10;
slot = (handle - 50) % 10;
- if (_vm->_global->_isCurrentSlot[file * MAX_SLOT_COUNT + slot] == 0) {
+ if (!_isCurrentSlot[file * MAX_SLOT_COUNT + slot]) {
for (i = 0; i < MAX_SLOT_COUNT; i++)
- _vm->_global->_isCurrentSlot[file * MAX_SLOT_COUNT + i] = 0;
+ _isCurrentSlot[file * MAX_SLOT_COUNT + i] = false;
- offset =
- _vm->_global->_chunkOffset[file * MAX_SLOT_COUNT + slot] +
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot];
- debugC(7, kDebugFileIO, "seek: %d, %d", _vm->_global->_chunkOffset[file * MAX_SLOT_COUNT + slot], _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot]);
- file_getHandle(_vm->_global->_dataFileHandles[file])->seek(offset, SEEK_SET);
+ offset = _chunkOffset[file * MAX_SLOT_COUNT + slot] +
+ _chunkPos[file * MAX_SLOT_COUNT + slot];
+
+ debugC(7, kDebugFileIO, "seek: %d, %d",
+ _chunkOffset[file * MAX_SLOT_COUNT + slot],
+ _chunkPos[file * MAX_SLOT_COUNT + slot]);
+
+ file_getHandle(_dataFileHandles[file])->seek(offset, SEEK_SET);
}
- _vm->_global->_isCurrentSlot[file * MAX_SLOT_COUNT + slot] = 1;
- if (_vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] + size >
- _vm->_global->_chunkSize[file * MAX_SLOT_COUNT + slot])
- size =
- _vm->_global->_chunkSize[file * MAX_SLOT_COUNT + slot] -
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot];
+ _isCurrentSlot[file * MAX_SLOT_COUNT + slot] = true;
+ if ((_chunkPos[file * MAX_SLOT_COUNT + slot] + size) >
+ (_chunkSize[file * MAX_SLOT_COUNT + slot]))
+ size = _chunkSize[file * MAX_SLOT_COUNT + slot] -
+ _chunkPos[file * MAX_SLOT_COUNT + slot];
- file_getHandle(_vm->_global->_dataFileHandles[file])->read(buf, size);
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] += size;
+ file_getHandle(_dataFileHandles[file])->read(buf, size);
+ _chunkPos[file * MAX_SLOT_COUNT + slot] += size;
return size;
}
@@ -134,18 +204,18 @@
int16 file;
int16 slot;
- if (handle < 50 || handle >= 100)
+ if ((handle < 50) || (handle >= 100))
return -1;
file = (handle - 50) / 10;
slot = (handle - 50) % 10;
- _vm->_global->_isCurrentSlot[file * MAX_SLOT_COUNT + slot] = 0;
+ _isCurrentSlot[file * MAX_SLOT_COUNT + slot] = false;
if (from == SEEK_SET)
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] = pos;
+ _chunkPos[file * MAX_SLOT_COUNT + slot] = pos;
else
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot] += pos;
+ _chunkPos[file * MAX_SLOT_COUNT + slot] += pos;
- return _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + slot];
+ return _chunkPos[file * MAX_SLOT_COUNT + slot];
}
int32 DataIO::getChunkSize(const char *chunkName) {
@@ -156,83 +226,80 @@
int32 realSize;
for (file = 0; file < MAX_DATA_FILES; file++) {
- if (_vm->_global->_dataFiles[file] == 0)
+ if (_dataFiles[file] == 0)
return -1;
- dataDesc = _vm->_global->_dataFiles[file];
- for (chunk = 0; chunk < _vm->_global->_numDataChunks[file];
- chunk++, dataDesc++) {
+ dataDesc = _dataFiles[file];
+ for (chunk = 0; chunk < _numDataChunks[file]; chunk++, dataDesc++) {
if (scumm_stricmp(chunkName, dataDesc->chunkName) != 0)
continue;
if (dataDesc->packed == 0) {
- _vm->_global->_packedSize = -1;
+ _packedSize = -1;
return dataDesc->size;
}
for (slot = 0; slot < MAX_SLOT_COUNT; slot++)
- _vm->_global->_isCurrentSlot[slot] = 0;
+ _isCurrentSlot[slot] = false;
- file_getHandle(_vm->_global->_dataFileHandles[file])->seek(dataDesc->offset, SEEK_SET);
- realSize = file_getHandle(_vm->_global->_dataFileHandles[file])->readUint32LE();
- _vm->_global->_packedSize = dataDesc->size;
+ file_getHandle(_dataFileHandles[file])->seek(dataDesc->offset, SEEK_SET);
+ realSize = file_getHandle(_dataFileHandles[file])->readUint32LE();
+ _packedSize = dataDesc->size;
return realSize;
}
}
return -1;
}
-void DataIO::openDataFile(const char *src) {
+void DataIO::openDataFile(const char *src, bool itk) {
+ ChunkDesc *dataDesc;
char path[128];
- int16 i;
int16 file;
- ChunkDesc *dataDesc;
strcpy(path, src);
- for (i = 0; path[i] != '.' && path[i] != 0; i++);
- if (path[i] == 0)
+ if (!strchr(path, '.'))
strcat(path, ".stk");
for (file = 0; file < MAX_DATA_FILES; file++)
- if (_vm->_global->_dataFiles[file] == 0)
+ if (_dataFiles[file] == 0)
break;
if (file == MAX_DATA_FILES)
- error("dataFileOpen: Data file slots are full\n");
- _vm->_global->_dataFileHandles[file] = file_open(path);
+ error("openDataFile: Data file slots are full");
- if (_vm->_global->_dataFileHandles[file] == -1)
- error("dataFileOpen: Can't open %s data file\n", path);
+ _dataFileHandles[file] = file_open(path);
- _vm->_global->_numDataChunks[file] = file_getHandle(_vm->_global->_dataFileHandles[file])->readUint16LE();
+ if (_dataFileHandles[file] == -1)
+ error("openDataFile: Can't open %s data file", path);
- debugC(7, kDebugFileIO, "DataChunks: %d [for %s]", _vm->_global->_numDataChunks[file], path);
+ _dataFileItk[file] = itk;
+ _numDataChunks[file] = file_getHandle(_dataFileHandles[file])->readUint16LE();
- dataDesc = new ChunkDesc[_vm->_global->_numDataChunks[file]];
- _vm->_global->_dataFiles[file] = dataDesc;
+ debugC(7, kDebugFileIO, "DataChunks: %d [for %s]", _numDataChunks[file], path);
- for (i = 0; i < _vm->_global->_numDataChunks[file]; i++) {
- file_getHandle(_vm->_global->_dataFileHandles[file])->read(dataDesc[i].chunkName, 13);
- dataDesc[i].size = file_getHandle(_vm->_global->_dataFileHandles[file])->readUint32LE();
- dataDesc[i].offset = file_getHandle(_vm->_global->_dataFileHandles[file])->readUint32LE();
- dataDesc[i].packed = file_getHandle(_vm->_global->_dataFileHandles[file])->readByte();
+ dataDesc = new ChunkDesc[_numDataChunks[file]];
+ _dataFiles[file] = dataDesc;
+
+ for (int i = 0; i < _numDataChunks[file]; i++) {
+ file_getHandle(_dataFileHandles[file])->read(dataDesc[i].chunkName, 13);
+ dataDesc[i].size = file_getHandle(_dataFileHandles[file])->readUint32LE();
+ dataDesc[i].offset = file_getHandle(_dataFileHandles[file])->readUint32LE();
+ dataDesc[i].packed = file_getHandle(_dataFileHandles[file])->readByte();
}
- for (i = 0; i < _vm->_global->_numDataChunks[file]; i++)
+ for (int i = 0; i < _numDataChunks[file]; i++)
debugC(7, kDebugFileIO, "%d: %s %d", i, dataDesc[i].chunkName, dataDesc[i].size);
- for (i = 0; i < MAX_SLOT_COUNT; i++)
- _vm->_global->_chunkPos[file * MAX_SLOT_COUNT + i] = -1;
-
+ for (int i = 0; i < MAX_SLOT_COUNT; i++)
+ _chunkPos[file * MAX_SLOT_COUNT + i] = -1;
}
-void DataIO::closeDataFile() {
- int16 file;
- for (file = MAX_DATA_FILES - 1; file >= 0; file--) {
- if (_vm->_global->_dataFiles[file] != 0) {
- delete[] _vm->_global->_dataFiles[file];
- _vm->_global->_dataFiles[file] = 0;
- file_getHandle(_vm->_global->_dataFileHandles[file])->close();
+void DataIO::closeDataFile(bool itk) {
+ for (int file = MAX_DATA_FILES - 1; file >= 0; file--) {
+ if (_dataFiles[file] && (_dataFileItk[file] == itk)) {
+ delete[] _dataFiles[file];
+ _dataFiles[file] = 0;
+ file_getHandle(_dataFileHandles[file])->close();
return;
}
}
@@ -247,7 +314,7 @@
int32 sizeLeft;
realSize = getChunkSize(name);
- if (_vm->_global->_packedSize == -1 || realSize == -1)
+ if ((_packedSize == -1) || (realSize == -1))
return 0;
chunk = getChunk(name);
@@ -255,16 +322,12 @@
return 0;
unpackBuf = new char[realSize];
- if (unpackBuf == 0)
- return 0;
+ assert(unpackBuf);
- packBuf = new char[_vm->_global->_packedSize];
- if (packBuf == 0) {
- delete[] unpackBuf;
- return 0;
- }
+ packBuf = new char[_packedSize];
+ assert(packBuf);
- sizeLeft = _vm->_global->_packedSize;
+ sizeLeft = _packedSize;
ptr = packBuf;
while (sizeLeft > 0x4000) {
readChunk(chunk, ptr, 0x4000);
@@ -273,7 +336,7 @@
}
readChunk(chunk, ptr, sizeLeft);
freeChunk(chunk);
- _vm->_pack->unpackData(packBuf, unpackBuf);
+ unpackData(packBuf, unpackBuf);
delete[] packBuf;
return unpackBuf;
@@ -297,7 +360,7 @@
return file_open(path, mode);
}
-int32 DataIO::readData(int16 handle, char *buf, int16 size) {
+int32 DataIO::readData(int16 handle, char *buf, uint16 size) {
int32 res;
res = readChunk(handle, buf, size);
@@ -307,6 +370,10 @@
return file_getHandle(handle)->read(buf, size);
}
+int32 DataIO::writeData(int16 handle, char *buf, uint16 size) {
+ return file_getHandle(handle)->write(buf, size);
+}
+
void DataIO::seekData(int16 handle, int32 pos, int16 from) {
int32 resPos;
@@ -347,13 +414,12 @@
int16 handle;
data = getUnpackedData(path);
- if (data != 0)
+ if (data)
return data;
size = getDataSize(path);
data = new char[size];
- if (data == 0)
- return 0;
+ assert(data);
handle = openData(path);
@@ -368,4 +434,4 @@
return data;
}
-} // End of namespace Gob
+} // End of namespace Gob
Modified: scummvm/trunk/engines/gob/dataio.h
===================================================================
--- scummvm/trunk/engines/gob/dataio.h 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/dataio.h 2007-03-20 14:51:57 UTC (rev 26252)
@@ -20,11 +20,11 @@
* $Id$
*
*/
+
#ifndef GOB_DATAIO_H
#define GOB_DATAIO_H
#include "common/file.h"
-#include "gob/gob.h"
namespace Gob {
@@ -41,31 +41,47 @@
ChunkDesc() : size(0), offset(0), packed(0) { chunkName[0] = 0; }
};
- int16 file_open(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode);
- Common::File *file_getHandle(int16 handle);
- int16 getChunk(const char *chunkName);
- char freeChunk(int16 handle);
- int32 readChunk(int16 handle, char *buf, int16 size);
- int16 seekChunk(int16 handle, int32 pos, int16 from);
- int32 getChunkSize(const char *chunkName);
- void openDataFile(const char *src);
- void closeDataFile(void);
+ int32 unpackData(char *source, char *dest);
+
+ void openDataFile(const char *src, bool itk = 0);
+ void closeDataFile(bool itk = 0);
char *getUnpackedData(const char *name);
void closeData(int16 handle);
- int16 openData(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode);
- int32 readData(int16 handle, char *buf, int16 size);
+ int16 openData(const char *path,
+ Common::File::AccessMode mode = Common::File::kFileReadMode);
+ int32 readData(int16 handle, char *buf, uint16 size);
+ int32 writeData(int16 handle, char *buf, uint16 size);
void seekData(int16 handle, int32 pos, int16 from);
int32 getPos(int16 handle);
int32 getDataSize(const char *name);
char *getData(const char *path);
- char *getSmallData(const char *path);
DataIO(class GobEngine *vm);
protected:
+ struct ChunkDesc *_dataFiles[MAX_DATA_FILES];
+ int16 _numDataChunks[MAX_DATA_FILES];
+ int16 _dataFileHandles[MAX_DATA_FILES];
+ bool _dataFileItk[MAX_DATA_FILES];
+ int32 _chunkPos[MAX_SLOT_COUNT * MAX_DATA_FILES];
+ int32 _chunkOffset[MAX_SLOT_COUNT * MAX_DATA_FILES];
+ int32 _chunkSize[MAX_SLOT_COUNT * MAX_DATA_FILES];
+ bool _isCurrentSlot[MAX_SLOT_COUNT * MAX_DATA_FILES];
+ int32 _packedSize;
+
class GobEngine *_vm;
+
+ int16 file_open(const char *path,
+ Common::File::AccessMode mode = Common::File::kFileReadMode);
+ Common::File *file_getHandle(int16 handle);
+
+ int16 getChunk(const char *chunkName);
+ char freeChunk(int16 handle);
+ int32 readChunk(int16 handle, char *buf, uint16 size);
+ int16 seekChunk(int16 handle, int32 pos, int16 from);
+ int32 getChunkSize(const char *chunkName);
};
-} // End of namespace Gob
+} // End of namespace Gob
-#endif
+#endif // GOB_DATAIO_H
Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/detection.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -21,9 +21,7 @@
*/
#include "common/stdafx.h"
-
#include "base/plugins.h"
-
#include "common/advancedDetector.h"
#include "gob/gob.h"
Modified: scummvm/trunk/engines/gob/draw.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/draw.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -27,19 +27,15 @@
#include "gob/gob.h"
#include "gob/draw.h"
#include "gob/global.h"
-#include "gob/video.h"
-#include "gob/game.h"
#include "gob/util.h"
-#include "gob/scenery.h"
+#include "gob/game.h"
#include "gob/inter.h"
#include "gob/video.h"
-#include "gob/palanim.h"
-#include "gob/cdrom.h"
namespace Gob {
Draw::Draw(GobEngine *vm) : _vm(vm) {
- int i;
+ _renderFlags = 0;
_fontIndex = 0;
_spriteLeft = 0;
@@ -50,74 +46,78 @@
_destSpriteY = 0;
_backColor = 0;
_frontColor = 0;
- _letterToPrint = 0;
+ _transparency = 0;
- _destSurface = 0;
_sourceSurface = 0;
- _renderFlags = 0;
+ _destSurface = 0;
+
+ _letterToPrint = 0;
+ _textToPrint = 0;
+
_backDeltaX = 0;
_backDeltaY = 0;
- for (i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
_fonts[i] = 0;
- _textToPrint = 0;
- _transparency = 0;
-
- for (i = 0; i < 50; i++)
+ for (int i = 0; i < SPRITES_COUNT; i++)
_spritesArray[i] = 0;
_invalidatedCount = 0;
- for (i = 0; i < 30; i++) {
+ for (int i = 0; i < 30; i++) {
_invalidatedTops[i] = 0;
_invalidatedLefts[i] = 0;
_invalidatedRights[i] = 0;
_invalidatedBottoms[i] = 0;
}
- _noInvalidated = 0;
- _applyPal = 0;
- _paletteCleared = 0;
+ _noInvalidated = false;
+ _noInvalidated57 = false;
+ _paletteCleared = false;
+ _applyPal = false;
_backSurface = 0;
_frontSurface = 0;
- for (i = 0; i < 18; i++)
+ for (int i = 0; i < 18; i++)
_unusedPalette1[i] = 0;
- for (i = 0; i < 16; i++)
+ for (int i = 0; i < 16; i++)
_unusedPalette2[i] = 0;
- for (i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
_vgaPalette[i].red = 0;
_vgaPalette[i].blue = 0;
_vgaPalette[i].green = 0;
}
- for (i = 0; i < 16; i++) {
+ for (int i = 0; i < 16; i++) {
_vgaSmallPalette[i].red = 0;
_vgaSmallPalette[i].blue = 0;
_vgaSmallPalette[i].green = 0;
}
+ _showCursor = 0;
+ _cursorIndex = 0;
+ _transparentCursor = 0;
+ _cursorTimeKey = 0;
+
_cursorX = 0;
_cursorY = 0;
_cursorWidth = 0;
_cursorHeight = 0;
- _cursorXDeltaVar = -1;
- _cursorYDeltaVar = -1;
+ _cursorHotspotXVar = -1;
+ _cursorHotspotYVar = -1;
- for (i = 0; i < 40; i++) {
+ _cursorSprites = 0;
+ _cursorSpritesBack = 0;
+ _scummvmCursor = 0;
+
+ _cursorAnim = 0;
+ for (int i = 0; i < 40; i++) {
_cursorAnimLow[i] = 0;
_cursorAnimHigh[i] = 0;
_cursorAnimDelays[i] = 0;
}
- _showCursor = 0;
- _cursorIndex = 0;
- _transparentCursor = 0;
- _cursorSprites = 0;
- _scummvmCursor = 0;
- _cursorAnim = 0;
-
_palLoadData1[0] = 0;
_palLoadData1[1] = 17;
_palLoadData1[2] = 34;
@@ -127,42 +127,25 @@
_palLoadData2[2] = 136;
_palLoadData2[3] = 204;
- _cursorTimeKey = 0;
-
+ _needAdjust = 2;
_scrollOffsetX = 0;
_scrollOffsetY = 0;
-
- warning("GOB2 Stub! _word_2E8E2, _word_2E51F, _off_2E51B, _off_2E517");
- _word_2E8E2 = 2;
- _word_2E51F = 0;
- _off_2E51B = 0;
- _off_2E517 = 0;
}
void Draw::invalidateRect(int16 left, int16 top, int16 right, int16 bottom) {
- int16 temp;
- int16 rect;
- int16 i;
-
if (_renderFlags & RENDERFLAG_NOINVALIDATE)
return;
- if (left > right) {
- temp = left;
- left = right;
- right = temp;
- }
- if (top > bottom) {
- temp = top;
- top = bottom;
- bottom = temp;
- }
+ if (left > right)
+ SWAP(left, right);
+ if (top > bottom)
+ SWAP(top, bottom);
if ((left > (_vm->_video->_surfWidth - 1)) || (right < 0) ||
- (top > (_vm->_video->_surfHeight - 1)) || (bottom < 0))
+ (top > (_vm->_video->_surfHeight - 1)) || (bottom < 0))
return;
- _noInvalidated = 0;
+ _noInvalidated = false;
if (_invalidatedCount >= 30) {
_invalidatedLefts[0] = 0;
@@ -185,22 +168,18 @@
if (bottom > (_vm->_video->_surfHeight - 1))
bottom = _vm->_video->_surfHeight - 1;
- left &= 0xfff0;
- right |= 0x000f;
+ left &= 0xFFF0;
+ right |= 0x000F;
- for (rect = 0; rect < _invalidatedCount; rect++) {
+ for (int rect = 0; rect < _invalidatedCount; rect++) {
if (_invalidatedTops[rect] > top) {
if (_invalidatedTops[rect] > bottom) {
- for (i = _invalidatedCount; i > rect; i--) {
- _invalidatedLefts[i] =
- _invalidatedLefts[i - 1];
- _invalidatedTops[i] =
- _invalidatedTops[i - 1];
- _invalidatedRights[i] =
- _invalidatedRights[i - 1];
- _invalidatedBottoms[i] =
- _invalidatedBottoms[i - 1];
+ for (int i = _invalidatedCount; i > rect; i--) {
+ _invalidatedLefts[i] = _invalidatedLefts[i - 1];
+ _invalidatedTops[i] = _invalidatedTops[i - 1];
+ _invalidatedRights[i] = _invalidatedRights[i - 1];
+ _invalidatedBottoms[i] = _invalidatedBottoms[i - 1];
}
_invalidatedLefts[rect] = left;
_invalidatedTops[rect] = top;
@@ -242,25 +221,25 @@
_invalidatedRights[_invalidatedCount] = right;
_invalidatedBottoms[_invalidatedCount] = bottom;
_invalidatedCount++;
- return;
}
-void Draw::blitInvalidated(void) {
- int16 i;
+void Draw::blitInvalidated() {
+ if (_noInvalidated57 &&
+ ((_vm->_global->_videoMode == 5) || (_vm->_global->_videoMode == 7)))
+ return;
-
if (_cursorIndex == 4)
blitCursor();
if (_vm->_inter->_terminate)
return;
- if (_noInvalidated && _applyPal == 0)
+ if (_noInvalidated && !_applyPal)
return;
if (_noInvalidated) {
setPalette();
- _applyPal = 0;
+ _applyPal = false;
return;
}
@@ -268,86 +247,89 @@
if (_applyPal) {
clearPalette();
- _vm->_video->drawSprite(_backSurface, _frontSurface, 0, 0,
- _vm->_video->_surfWidth - 1, _vm->_video->_surfHeight - 1, 0, 0, 0);
+ _vm->_video->drawSprite(_backSurface, _frontSurface,
+ 0, 0, _vm->_video->_surfWidth - 1,
+ _vm->_video->_surfHeight - 1, 0, 0, 0);
setPalette();
_invalidatedCount = 0;
- _noInvalidated = 1;
- _applyPal = 0;
+ _noInvalidated = true;
+ _applyPal = false;
return;
}
- _vm->_global->_doRangeClamp = 0;
- for (i = 0; i < _invalidatedCount; i++) {
+ _vm->_video->_doRangeClamp = false;
+ for (int i = 0; i < _invalidatedCount; i++) {
_vm->_video->drawSprite(_backSurface, _frontSurface,
_invalidatedLefts[i], _invalidatedTops[i],
_invalidatedRights[i], _invalidatedBottoms[i],
_invalidatedLefts[i], _invalidatedTops[i], 0);
}
- _vm->_global->_doRangeClamp = 1;
+ _vm->_video->_doRangeClamp = true;
_invalidatedCount = 0;
- _noInvalidated = 1;
- _applyPal = 0;
+ _noInvalidated = true;
+ _applyPal = false;
}
-void Draw::setPalette(void) {
- if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
- error("setPalette: Video mode 0x%x is not supported!\n",
- _vm->_global->_videoMode);
+void Draw::setPalette() {
+ _vm->validateVideoMode(_vm->_global->_videoMode);
_vm->_global->_pPaletteDesc->unused1 = _unusedPalette1;
_vm->_global->_pPaletteDesc->unused2 = _unusedPalette2;
_vm->_global->_pPaletteDesc->vgaPal = _vgaPalette;
_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
- _paletteCleared = 0;
+ _paletteCleared = false;
}
-void Draw::clearPalette(void) {
- if (_paletteCleared == 0) {
- _paletteCleared = 1;
+void Draw::clearPalette() {
+ if (!_paletteCleared) {
_vm->_util->clearPalette();
+ _paletteCleared = true;
}
}
-void Draw::freeSprite(int16 index) {
- if (_spritesArray[index] == 0)
- return;
+void Draw::initSpriteSurf(int16 index, int16 width, int16 height,
+ int16 flags) {
- _vm->_video->freeSurfDesc(_spritesArray[index]);
-
- _spritesArray[index] = 0;
+ _spritesArray[index] =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags);
+ _vm->_video->clearSurf(_spritesArray[index]);
}
void Draw::adjustCoords(char adjust, int16 *coord1, int16 *coord2) {
- if (_word_2E8E2 == 2)
+ if (_needAdjust == 2)
return;
- if (adjust == 0) {
- if (coord2 != 0)
- *coord2 *= 2;
- if (coord1 != 0)
- *coord2 *= 2;
+ switch (adjust) {
+ case 0:
+ if (coord2)
+ *coord2 *= 2;
+ if (coord1)
+ *coord2 *= 2;
+ break;
+
+ case 1:
+ if (coord2)
+ *coord2 = (signed) ((unsigned) (*coord2 + 1) / 2);
+ if (coord1)
+ *coord1 = (signed) ((unsigned) (*coord1 + 1) / 2);
+ break;
+
+ case 2:
+ if (coord2)
+ *coord2 = *coord2 * 2 + 1;
+ if (coord1)
+ *coord1 = *coord1 * 2 + 1;
+ break;
}
- else if (adjust == 1) {
- if (coord2 != 0)
- *coord2 = (signed) ((unsigned) (*coord2 + 1) / 2);
- if (coord1 != 0)
- *coord1 = (signed) ((unsigned) (*coord1 + 1) / 2);
- }
- else if (adjust == 2) {
- if (coord2 != 0)
- *coord2 = *coord2 * 2 + 1;
- if (coord1 != 0)
- *coord1 = *coord1 * 2 + 1;
- }
}
void Draw::drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
- int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font) {
+ int16 transp, SurfaceDesc *dest, Video::FontDesc *font) {
+
while (*str != '\0') {
_vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest);
- if (font->extraData == 0)
+ if (!font->extraData)
x += font->itemWidth;
else
x += *(((char *)font->extraData) + (*str - font->startItem));
@@ -355,25 +337,21 @@
}
}
-void Draw::printTextCentered(int16 arg_0, int16 left, int16 top, int16 right,
+void Draw::printTextCentered(int16 id, int16 left, int16 top, int16 right,
int16 bottom, char *str, int16 fontIndex, int16 color) {
- char *storedIP;
- int i;
- int length;
- int16 width;
-
+
adjustCoords(1, &left, &top);
adjustCoords(1, &right, &bottom);
if (READ_LE_UINT16(_vm->_game->_totFileData + 0x7E) != 0) {
- storedIP = _vm->_global->_inter_execPtr;
+ char *storedIP = _vm->_global->_inter_execPtr;
_vm->_global->_inter_execPtr = _vm->_game->_totFileData +
READ_LE_UINT16(_vm->_game->_totFileData + 0x7E);
- WRITE_VAR(17, (uint32) arg_0);
+ WRITE_VAR(17, (uint32) id);
WRITE_VAR(18, (uint32) left);
WRITE_VAR(19, (uint32) top);
- WRITE_VAR(20, (uint32) right-left+1);
- WRITE_VAR(21, (uint32) bottom-top+1);
+ WRITE_VAR(20, (uint32) (right - left + 1));
+ WRITE_VAR(21, (uint32) (bottom - top + 1));
_vm->_inter->funcBlock(0);
_vm->_global->_inter_execPtr = storedIP;
}
@@ -381,21 +359,23 @@
if (str[0] == '\0')
return;
+ int16 width = 0;
+
_transparency = 1;
_destSpriteX = left;
_destSpriteY = top;
_fontIndex = fontIndex;
_frontColor = color;
_textToPrint = str;
- width = 0;
- if (_fonts[fontIndex]->extraData == 0)
- width = strlen(str) * _fonts[fontIndex]->itemWidth;
- else {
- length = strlen(str);
- for (i = 0; i < length; i++)
- width +=
- *(((char*)_fonts[fontIndex]->extraData) + (str[i] - _fonts[_fontIndex]->startItem));
+ if (_fonts[fontIndex]->extraData != 0) {
+ char *data = (char *) _fonts[fontIndex]->extraData;
+ int length = strlen(str);
+
+ for (int i = 0; i < length; i++)
+ width += *(data + (str[i] - _fonts[_fontIndex]->startItem));
}
+ else
+ width = strlen(str) * _fonts[fontIndex]->itemWidth;
adjustCoords(1, &width, 0);
_destSpriteX += (right - left + 1 - width) / 2;
@@ -404,19 +384,10 @@
}
int32 Draw::getSpriteRectSize(int16 index) {
- if (_spritesArray[index] == 0)
+ if (!_spritesArray[index])
return 0;
- return _vm->_video->getRectSize(_spritesArray[index]->width, _spritesArray[index]->height,
- 0, _vm->_global->_videoMode);
+ return _spritesArray[index]->getWidth() * _spritesArray[index]->getHeight();
}
-void Draw::initSpriteSurf(int16 index, int16 vidMode, int16 width, int16 height, int16 flags) {
- if (index != 22)
- _vm->_video->freeSurfDesc(_spritesArray[index]);
-
- _spritesArray[index] =
- _vm->_video->initSurfDesc(vidMode, width, height, flags);
-}
-
} // End of namespace Gob
Modified: scummvm/trunk/engines/gob/draw.h
===================================================================
--- scummvm/trunk/engines/gob/draw.h 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/draw.h 2007-03-20 14:51:57 UTC (rev 26252)
@@ -20,19 +20,24 @@
* $Id$
*
*/
+
#ifndef GOB_DRAW_H
#define GOB_DRAW_H
#include "gob/video.h"
-#include "gob/global.h"
namespace Gob {
-#define RENDERFLAG_NOINVALIDATE 1
-#define RENDERFLAG_CAPTUREPUSH 2
-#define RENDERFLAG_CAPTUREPOP 8
-#define RENDERFLAG_USEDELTAS 0x10
+#define SPRITES_COUNT 50
+#define RENDERFLAG_NOINVALIDATE 0x001
+#define RENDERFLAG_CAPTUREPUSH 0x002
+#define RENDERFLAG_COLLISIONS 0x004
+#define RENDERFLAG_CAPTUREPOP 0x008
+#define RENDERFLAG_USEDELTAS 0x010
+#define RENDERFLAG_NOBLITINVALIDATED 0x200
+#define RENDERFLAG_SKIPOPTIONALTEXT 0x400
+
class Draw {
public:
struct FontToSprite {
@@ -40,9 +45,11 @@
int8 base;
int8 width;
int8 height;
- FontToSprite() : sprite(0), base(0), width(0), height() {}
+ FontToSprite() : sprite(0), base(0), width(0), height(0) {}
};
+ int16 _renderFlags;
+
int16 _fontIndex;
int16 _spriteLeft;
int16 _spriteTop;
@@ -52,35 +59,37 @@
int16 _destSpriteY;
int16 _backColor;
int16 _frontColor;
+ int16 _transparency;
+
+ int16 _sourceSurface;
+ int16 _destSurface;
+
char _letterToPrint;
- FontToSprite _fontToSprite[4];
- int16 _destSurface;
- int16 _sourceSurface;
- int16 _renderFlags;
+ char *_textToPrint;
+
int16 _backDeltaX;
int16 _backDeltaY;
+
+ FontToSprite _fontToSprite[4];
Video::FontDesc *_fonts[8];
- char *_textToPrint;
- int16 _transparency;
- Video::SurfaceDesc *_spritesArray[50];
+ SurfaceDesc::Ptr _spritesArray[SPRITES_COUNT];
+
int16 _invalidatedCount;
int16 _invalidatedTops[30];
int16 _invalidatedLefts[30];
int16 _invalidatedRights[30];
int16 _invalidatedBottoms[30];
- int8 _noInvalidated;
-// int8 doFullFlip; // Never used?!?
- int8 _paletteCleared;
+ bool _noInvalidated;
+ // Don't blit invalidated rects when in video mode 5 or 7
+ bool _noInvalidated57;
+ bool _paletteCleared;
+ bool _applyPal;
- int16 _cursorIndex;
- int16 _transparentCursor;
- uint32 _cursorTimeKey;
+ SurfaceDesc::Ptr _backSurface;
+ SurfaceDesc::Ptr _frontSurface;
- Video::SurfaceDesc *_backSurface;
- Video::SurfaceDesc *_frontSurface;
-
int16 _unusedPalette1[18];
int16 _unusedPalette2[16];
Video::Color _vgaPalette[256];
@@ -91,56 +100,57 @@
// 2 (10b): Cursor would be on _frontSurface
// 3 (11b): Cursor would be on _backSurface and _frontSurface
uint8 _showCursor;
+ int16 _cursorIndex;
+ int16 _transparentCursor;
+ uint32 _cursorTimeKey;
int16 _cursorX;
int16 _cursorY;
int16 _cursorWidth;
int16 _cursorHeight;
- int16 _cursorXDeltaVar;
- int16 _cursorYDeltaVar;
+ int16 _cursorHotspotXVar;
+ int16 _cursorHotspotYVar;
- Video::SurfaceDesc *_cursorSprites;
- Video::SurfaceDesc *_cursorSpritesBack;
- Video::SurfaceDesc *_scummvmCursor;
+ SurfaceDesc::Ptr _cursorSprites;
+ SurfaceDesc::Ptr _cursorSpritesBack;
+ SurfaceDesc::Ptr _scummvmCursor;
int16 _cursorAnim;
int8 _cursorAnimLow[40];
int8 _cursorAnimHigh[40];
int8 _cursorAnimDelays[40];
- int8 _applyPal;
int16 _palLoadData1[4];
int16 _palLoadData2[4];
-
- int16 _word_2E8E2;
+
+ int16 _needAdjust;
int16 _scrollOffsetY;
int16 _scrollOffsetX;
- int16 _word_2E51F;
- Video::SurfaceDesc *_off_2E51B;
- Video::SurfaceDesc *_off_2E517;
void invalidateRect(int16 left, int16 top, int16 right, int16 bottom);
- void blitInvalidated(void);
- void setPalette(void);
- void clearPalette(void);
+ void blitInvalidated();
+ void setPalette();
+ void clearPalette();
- void freeSprite(int16 index);
+ void initSpriteSurf(int16 index, int16 width, int16 height, int16 flags);
+ void freeSprite(int16 index) {
+ assert(index < SPRITES_COUNT);
+ _spritesArray[index] = 0;
+ }
void adjustCoords(char adjust, int16 *coord1, int16 *coord2);
void drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
- int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font);
- void printTextCentered(int16 arg_0, int16 left, int16 top, int16 right,
+ int16 transp, SurfaceDesc *dest, Video::FontDesc *font);
+ void printTextCentered(int16 id, int16 left, int16 top, int16 right,
int16 bottom, char *str, int16 fontIndex, int16 color);
int32 getSpriteRectSize(int16 index);
- void initSpriteSurf(int16 index, int16 vidMode, int16 width, int16 height, int16 flags);
- virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) = 0;
- virtual void printText(void) = 0;
+ virtual void initScreen() = 0;
+ virtual void closeScreen() = 0;
+ virtual void blitCursor() = 0;
+ virtual void animateCursor(int16 cursor) = 0;
+ virtual void printTotText(int16 id) = 0;
virtual void spriteOperation(int16 operation) = 0;
- virtual void blitCursor(void) = 0;
- virtual void animateCursor(int16 cursor) = 0;
- virtual void initScreen(void) = 0;
- virtual void closeScreen(void) = 0;
Draw(GobEngine *vm);
virtual ~Draw() {};
@@ -151,16 +161,12 @@
class Draw_v1 : public Draw {
public:
- virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
- _vm->_draw->_spritesArray[index] =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags);
- }
- virtual void printText(void);
+ virtual void initScreen();
+ virtual void closeScreen();
+ virtual void blitCursor();
+ virtual void animateCursor(int16 cursor);
+ virtual void printTotText(int16 id);
virtual void spriteOperation(int16 operation);
- virtual void blitCursor(void);
- virtual void animateCursor(int16 cursor);
- virtual void initScreen(void);
- virtual void closeScreen(void);
Draw_v1(GobEngine *vm);
virtual ~Draw_v1() {};
@@ -168,18 +174,12 @@
class Draw_v2 : public Draw_v1 {
public:
- virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) {
- // This would init big surfaces in pieces, to avoid breaking page bounds.
- // This isn't necessary anymore, so we don't do it.
- initSpriteSurf(index, _vm->_global->_videoMode, width, height, flags);
- _vm->_video->clearSurf(_spritesArray[index]);
- }
- virtual void printText(void);
+ virtual void initScreen();
+ virtual void closeScreen();
+ virtual void blitCursor();
+ virtual void animateCursor(int16 cursor);
+ virtual void printTotText(int16 id);
virtual void spriteOperation(int16 operation);
- virtual void blitCursor(void);
- virtual void animateCursor(int16 cursor);
- virtual void initScreen(void);
- virtual void closeScreen(void);
Draw_v2(GobEngine *vm);
virtual ~Draw_v2() {};
@@ -187,7 +187,7 @@
class Draw_Bargon: public Draw_v2 {
public:
- virtual void initScreen(void);
+ virtual void initScreen();
Draw_Bargon(GobEngine *vm);
virtual ~Draw_Bargon() {};
@@ -207,6 +207,6 @@
#define DRAW_FILLRECTABS 9
#define DRAW_DRAWLETTER 10
-} // End of namespace Gob
+} // End of namespace Gob
-#endif /* __DRAW_H */
+#endif // GOB_DRAW_H
Modified: scummvm/trunk/engines/gob/draw_bargon.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_bargon.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/draw_bargon.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -21,10 +21,6 @@
*
*/
-#include "common/stdafx.h"
-#include "common/endian.h"
-#include "graphics/cursorman.h"
-
#include "gob/gob.h"
#include "gob/draw.h"
#include "gob/global.h"
Modified: scummvm/trunk/engines/gob/draw_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v1.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/draw_v1.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -28,103 +28,221 @@
#include "gob/gob.h"
#include "gob/draw.h"
#include "gob/global.h"
-#include "gob/game.h"
#include "gob/util.h"
-#include "gob/scenery.h"
-#include "gob/inter.h"
#include "gob/cdrom.h"
+#include "gob/game.h"
+#include "gob/scenery.h"
namespace Gob {
Draw_v1::Draw_v1(GobEngine *vm) : Draw(vm) {
}
-void Draw_v1::printText(void) {
- int16 savedFlags;
- int16 ldestSpriteX;
- char *dataPtr;
- char *ptr;
- char *ptr2;
- int16 index;
- int16 destX;
- int16 destY;
- char cmd;
+void Draw_v1::initScreen() {
+ _backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0);
+}
+
+void Draw_v1::closeScreen() {
+}
+
+void Draw_v1::blitCursor() {
+ if (_cursorIndex == -1)
+ return;
+
+ if (_showCursor == 2)
+ _showCursor = 0;
+}
+
+void Draw_v1::animateCursor(int16 cursor) {
+ Game::Collision *ptr;
+ int16 cursorIndex = cursor;
+ int16 newX = 0, newY = 0;
+ uint16 hotspotX = 0, hotspotY = 0;
+
+ _showCursor = 2;
+
+ if (cursorIndex == -1) {
+ cursorIndex = 0;
+ for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) {
+ if (ptr->flags & 0xFFF0)
+ continue;
+
+ if (ptr->left > _vm->_global->_inter_mouseX)
+ continue;
+
+ if (ptr->right < _vm->_global->_inter_mouseX)
+ continue;
+
+ if (ptr->top > _vm->_global->_inter_mouseY)
+ continue;
+
+ if (ptr->bottom < _vm->_global->_inter_mouseY)
+ continue;
+
+ if ((ptr->flags & 0xF) < 3)
+ cursorIndex = 1;
+ else
+ cursorIndex = 3;
+ break;
+ }
+ if (_cursorAnimLow[cursorIndex] == -1)
+ cursorIndex = 1;
+ }
+
+ if (_cursorAnimLow[cursorIndex] != -1) {
+ if (cursorIndex == _cursorIndex) {
+ if (_cursorAnimDelays[_cursorIndex] != 0 &&
+ _cursorAnimDelays[_cursorIndex] * 10 +
+ _cursorTimeKey <= _vm->_util->getTimeKey()) {
+ _cursorAnim++;
+ _cursorTimeKey = _vm->_util->getTimeKey();
+ } else {
+ if (_noInvalidated && (_vm->_global->_inter_mouseX == _cursorX) &&
+ (_vm->_global->_inter_mouseY == _cursorY)) {
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ return;
+ }
+ }
+ } else {
+ _cursorIndex = cursorIndex;
+ if (_cursorAnimDelays[_cursorIndex] != 0) {
+ _cursorAnim =
+ _cursorAnimLow[_cursorIndex];
+ _cursorTimeKey = _vm->_util->getTimeKey();
+ } else {
+ _cursorAnim = _cursorIndex;
+ }
+ }
+
+ if (_cursorAnimDelays[_cursorIndex] != 0 &&
+ (_cursorAnimHigh[_cursorIndex] < _cursorAnim ||
+ _cursorAnimLow[_cursorIndex] >
+ _cursorAnim)) {
+ _cursorAnim = _cursorAnimLow[_cursorIndex];
+ }
+
+ newX = _vm->_global->_inter_mouseX;
+ newY = _vm->_global->_inter_mouseY;
+ if (_cursorHotspotXVar != -1) {
+ newX -= hotspotX = (uint16) VAR(_cursorIndex + _cursorHotspotXVar);
+ newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
+ }
+
+ _vm->_video->clearSurf(_scummvmCursor);
+ _vm->_video->drawSprite(_cursorSprites, _scummvmCursor,
+ cursorIndex * _cursorWidth, 0,
+ (cursorIndex + 1) * _cursorWidth - 1,
+ _cursorHeight - 1, 0, 0, 0);
+ CursorMan.replaceCursor(_scummvmCursor->getVidMem(),
+ _cursorWidth, _cursorHeight, hotspotX, hotspotY, 0);
+
+ if (_frontSurface != _backSurface) {
+ _showCursor = 3;
+ if (!_noInvalidated) {
+ int16 tmp = _cursorIndex;
+ _cursorIndex = -1;
+ blitInvalidated();
+ _cursorIndex = tmp;
+ } else {
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ if (MIN(newY, _cursorY) < 50)
+ _vm->_util->delay(5);
+ _showCursor = 0;
+ }
+ }
+ } else
+ blitCursor();
+
+ _cursorX = newX;
+ _cursorY = newY;
+}
+
+void Draw_v1::printTotText(int16 id) {
+ byte *dataPtr;
+ byte *ptr, *ptrEnd;
+ byte cmd;
+ int16 destX, destY;
int16 val;
+ int16 savedFlags;
+ int16 destSpriteX;
+ int16 spriteRight, spriteBottom;
char buf[20];
- index = _vm->_inter->load16();
-
_vm->_cdrom->playMultMusic();
- dataPtr = _vm->_game->_totTextData->dataPtr + _vm->_game->_totTextData->items[index].offset;
+ if (!_vm->_game->_totTextData || !_vm->_game->_totTextData->dataPtr)
+ return;
+
+ dataPtr = ((byte *) _vm->_game->_totTextData->dataPtr) +
+ _vm->_game->_totTextData->items[id].offset;
ptr = dataPtr;
+ destX = READ_LE_UINT16(ptr) & 0x7FFF;
+ destY = READ_LE_UINT16(ptr + 2);
+ spriteRight = READ_LE_UINT16(ptr + 4);
+ spriteBottom = READ_LE_UINT16(ptr + 6);
+ ptr += 8;
+
if (_renderFlags & RENDERFLAG_CAPTUREPUSH) {
- _destSpriteX = READ_LE_UINT16(ptr);
- _destSpriteY = READ_LE_UINT16(ptr + 2);
- _spriteRight = READ_LE_UINT16(ptr + 4) - _destSpriteX + 1;
- _spriteBottom = READ_LE_UINT16(ptr + 6) - _destSpriteY + 1;
- _vm->_game->capturePush(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _vm->_game->capturePush(destX, destY,
+ spriteRight - destX + 1, spriteBottom - destY + 1);
(*_vm->_scenery->_pCaptureCounter)++;
}
- _destSpriteX = READ_LE_UINT16(ptr);
- destX = _destSpriteX;
- _destSpriteY = READ_LE_UINT16(ptr + 2);
- destY = _destSpriteY;
-
- _spriteRight = READ_LE_UINT16(ptr + 4);
- _spriteBottom = READ_LE_UINT16(ptr + 6);
+ _destSpriteX = destX;
+ _destSpriteY = destY;
+ _spriteRight = spriteRight;
+ _spriteBottom = spriteBottom;
_destSurface = 21;
- ptr += 8;
-
_backColor = *ptr++;
_transparency = 1;
spriteOperation(DRAW_CLEARRECT);
_backColor = 0;
savedFlags = _renderFlags;
-
_renderFlags &= ~RENDERFLAG_NOINVALIDATE;
- for (; (_destSpriteX = READ_LE_UINT16(ptr)) != -1; ptr++) {
+
+ while ((_destSpriteX = READ_LE_UINT16(ptr)) != -1) {
_destSpriteX += destX;
_destSpriteY = READ_LE_UINT16(ptr + 2) + destY;
_spriteRight = READ_LE_UINT16(ptr + 4) + destX;
_spriteBottom = READ_LE_UINT16(ptr + 6) + destY;
ptr += 8;
- cmd = (*ptr & 0xf0) >> 4;
- if (cmd == 0) {
- _frontColor = *ptr & 0xf;
+ cmd = *ptr++;
+ switch ((cmd & 0xF0) >> 4) {
+ case 0:
+ _frontColor = cmd & 0xF;
spriteOperation(DRAW_DRAWLINE);
- } else if (cmd == 1) {
- _frontColor = *ptr & 0xf;
+ break;
+ case 1:
+ _frontColor = cmd & 0xF;
spriteOperation(DRAW_DRAWBAR);
- } else if (cmd == 2) {
- _backColor = *ptr & 0xf;
+ break;
+ case 2:
+ _backColor = cmd & 0xF;
spriteOperation(DRAW_FILLRECTABS);
+ break;
}
}
ptr += 2;
- for (ptr2 = ptr; *ptr2 != 1; ptr2++) {
- if (*ptr2 == 3)
- ptr2++;
+ for (ptrEnd = ptr; *ptrEnd != 1; ptrEnd++) {
+ if (*ptrEnd == 3)
+ ptrEnd++;
- if (*ptr2 == 2)
- ptr2 += 4;
+ if (*ptrEnd == 2)
+ ptrEnd += 4;
}
+ ptrEnd++;
- ptr2++;
-
while (*ptr != 1) {
cmd = *ptr;
if (cmd == 3) {
ptr++;
- _fontIndex = (*ptr & 0xf0) >> 4;
- _frontColor = *ptr & 0xf;
+ _fontIndex = (*ptr & 0xF0) >> 4;
+ _frontColor = *ptr & 0xF;
ptr++;
continue;
} else if (cmd == 2) {
@@ -135,42 +253,42 @@
continue;
}
- if ((byte)*ptr != 0xba) {
- _letterToPrint = *ptr;
+ if (*ptr != 0xBA) {
+ _letterToPrint = (char) *ptr;
spriteOperation(DRAW_DRAWLETTER);
_destSpriteX +=
_fonts[_fontIndex]->itemWidth;
ptr++;
} else {
- cmd = ptr2[17] & 0x7f;
+ cmd = ptrEnd[17] & 0x7F;
if (cmd == 0) {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
- sprintf(buf, "%d", VAR_OFFSET(val));
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
+ sprintf(buf, "%d", VAR_OFFSET(val));
} else if (cmd == 1) {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
strcpy(buf, GET_VARO_STR(val));
} else {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
- sprintf(buf, "%d", VAR_OFFSET(val));
+ sprintf(buf, "%d", VAR_OFFSET(val));
if (buf[0] == '-') {
- while (strlen(buf) - 1 < (uint32)ptr2[17]) {
+ while (strlen(buf) - 1 < (uint32)ptrEnd[17]) {
_vm->_util->insertStr("0", buf, 1);
}
} else {
- while (strlen(buf) - 1 < (uint32)ptr2[17]) {
+ while (strlen(buf) - 1 < (uint32)ptrEnd[17]) {
_vm->_util->insertStr("0", buf, 0);
}
}
- _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]);
+ _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptrEnd[17]);
}
_textToPrint = buf;
- ldestSpriteX = _destSpriteX;
+ destSpriteX = _destSpriteX;
spriteOperation(DRAW_PRINTTEXT);
- if (ptr2[17] & 0x80) {
+ if (ptrEnd[17] & 0x80) {
if (ptr[1] == ' ') {
_destSpriteX += _fonts[_fontIndex]->itemWidth;
while (ptr[1] == ' ')
@@ -184,29 +302,16 @@
_destSpriteX += _fonts[_fontIndex]->itemWidth;
}
} else {
- _destSpriteX = ldestSpriteX + _fonts[_fontIndex]->itemWidth;
+ _destSpriteX = destSpriteX + _fonts[_fontIndex]->itemWidth;
}
- ptr2 += 23;
+ ptrEnd += 23;
ptr++;
}
}
_renderFlags = savedFlags;
- if (_renderFlags & 4) {
- warning("printText: Input not supported");
-// xor ax, ax
-// loc_436_1391:
-// xor dx, dx
-// push ax
-// push dx
-// push ax
-// push dx
-// push ax
-// mov al, 0
-// push ax
-// call sub_9FF_1E71
-// add sp, 0Ch
- }
+ if (_renderFlags & RENDERFLAG_COLLISIONS)
+ _vm->_game->checkCollisions(0, 0, 0, 0);
if ((_renderFlags & RENDERFLAG_CAPTUREPOP) && *_vm->_scenery->_pCaptureCounter != 0) {
(*_vm->_scenery->_pCaptureCounter)--;
@@ -220,14 +325,11 @@
Game::TotResItem *itemPtr;
int32 offset;
int16 len;
- int16 i;
- int16 x;
- int16 y;
+ int16 x, y;
int16 perLine;
if (_sourceSurface >= 100)
_sourceSurface -= 80;
-
if (_destSurface >= 100)
_destSurface -= 80;
@@ -240,9 +342,9 @@
if (_destSurface == 21) {
_destSpriteX += _backDeltaX;
_destSpriteY += _backDeltaY;
- if (operation == DRAW_DRAWLINE ||
- (operation >= DRAW_DRAWBAR
- && operation <= DRAW_FILLRECTABS)) {
+ if ((operation == DRAW_DRAWLINE) ||
+ ((operation >= DRAW_DRAWBAR) &&
+ (operation <= DRAW_FILLRECTABS))) {
_spriteRight += _backDeltaX;
_spriteBottom += _backDeltaY;
}
@@ -260,8 +362,8 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
@@ -270,7 +372,7 @@
_frontColor, _spritesArray[_destSurface]);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX, _destSpriteY);
+ _destSpriteX, _destSpriteY);
}
break;
@@ -282,8 +384,8 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
@@ -294,15 +396,16 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
case DRAW_INVALIDATE:
if (_destSurface == 21) {
- invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !!
- _destSpriteX + _spriteRight,
- _destSpriteY + _spriteBottom);
+ invalidateRect(_destSpriteX - _spriteRight,
+ _destSpriteY - _spriteBottom,
+ _destSpriteX + _spriteRight,
+ _destSpriteY + _spriteBottom);
}
break;
@@ -310,17 +413,15 @@
id = _spriteLeft;
if (id >= 30000) {
dataBuf =
- _vm->_game->loadExtData(id, &_spriteRight,
- &_spriteBottom);
- _vm->_video->drawPackedSprite((byte *)dataBuf, _spriteRight,
- _spriteBottom, _destSpriteX,
- _destSpriteY, _transparency,
- _spritesArray[_destSurface]);
+ _vm->_game->loadExtData(id, &_spriteRight, &_spriteBottom);
+ _vm->_video->drawPackedSprite((byte *) dataBuf,
+ _spriteRight, _spriteBottom,
+ _destSpriteX, _destSpriteY,
+ _transparency, _spritesArray[_destSurface]);
if (_destSurface == 21) {
- invalidateRect(_destSpriteX,
- _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ invalidateRect(_destSpriteX, _destSpriteY,
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
delete[] dataBuf;
break;
@@ -333,27 +434,25 @@
itemPtr = &_vm->_game->_totResourceTable->items[id];
offset = itemPtr->offset;
if (offset >= 0) {
- dataBuf =
- _vm->_game->_totResourceTable->dataPtr +
+ dataBuf = _vm->_game->_totResourceTable->dataPtr +
szGame_TotResTable + szGame_TotResItem *
_vm->_game->_totResourceTable->itemsCount + offset;
} else {
- dataBuf =
- _vm->_game->_imFileData +
- (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]);
+ dataBuf = _vm->_game->_imFileData +
+ (int32) READ_LE_UINT32(&((int32 *) _vm->_game->_imFileData)[-offset - 1]);
}
_spriteRight = itemPtr->width;
_spriteBottom = itemPtr->height;
- _vm->_video->drawPackedSprite((byte *)dataBuf,
+ _vm->_video->drawPackedSprite((byte *) dataBuf,
_spriteRight, _spriteBottom,
_destSpriteX, _destSpriteY,
_transparency, _spritesArray[_destSurface]);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
@@ -361,13 +460,11 @@
len = strlen(_textToPrint);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX +
- len * _fonts[_fontIndex]->itemWidth - 1,
- _destSpriteY +
- _fonts[_fontIndex]->itemHeight - 1);
+ _destSpriteX + len * _fonts[_fontIndex]->itemWidth - 1,
+ _destSpriteY + _fonts[_fontIndex]->itemHeight - 1);
}
- for (i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
_vm->_video->drawLetter(_textToPrint[i],
_destSpriteX, _destSpriteY,
_fonts[_fontIndex],
@@ -398,7 +495,7 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -411,7 +508,7 @@
}
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -422,7 +519,7 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -431,11 +528,8 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX,
_destSpriteY,
- _destSpriteX +
- _fonts[_fontIndex]->itemWidth - 1,
- _destSpriteY +
- _fonts[_fontIndex]->itemHeight -
- 1);
+ _destSpriteX + _fonts[_fontIndex]->itemWidth - 1,
+ _destSpriteY + _fonts[_fontIndex]->itemHeight - 1);
}
_vm->_video->drawLetter(_letterToPrint,
_destSpriteX, _destSpriteY,
@@ -447,27 +541,22 @@
}
perLine =
- _spritesArray[(int16)_fontToSprite[_fontIndex].
- sprite]->width / _fontToSprite[_fontIndex].width;
+ _spritesArray[(int16)_fontToSprite[_fontIndex].sprite]->getWidth() /
+ _fontToSprite[_fontIndex].width;
- y = (_letterToPrint -
- _fontToSprite[_fontIndex].base) / perLine *
- _fontToSprite[_fontIndex].height;
+ y = (_letterToPrint - _fontToSprite[_fontIndex].base) / perLine *
+ _fontToSprite[_fontIndex].height;
- x = (_letterToPrint -
- _fontToSprite[_fontIndex].base) % perLine *
- _fontToSprite[_fontIndex].width;
+ x = (_letterToPrint - _fontToSprite[_fontIndex].base) % perLine *
+ _fontToSprite[_fontIndex].width;
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX +
- _fontToSprite[_fontIndex].width,
- _destSpriteY +
- _fontToSprite[_fontIndex].height);
+ _destSpriteX + _fontToSprite[_fontIndex].width,
+ _destSpriteY + _fontToSprite[_fontIndex].height);
}
- _vm->_video->drawSprite(_spritesArray[(int16)_fontToSprite
- [_fontIndex].sprite],
+ _vm->_video->drawSprite(_spritesArray[(int16)_fontToSprite[_fontIndex].sprite],
_spritesArray[_destSurface], x, y,
x + _fontToSprite[_fontIndex].width,
y + _fontToSprite[_fontIndex].height,
@@ -489,129 +578,4 @@
}
}
-void Draw_v1::blitCursor(void) {
- if (_cursorIndex == -1)
- return;
-
- if (_showCursor == 2)
- _showCursor = 0;
-}
-
-void Draw_v1::animateCursor(int16 cursor) {
- int16 newX = 0;
- int16 newY = 0;
- Game::Collision *ptr;
- int16 minX;
- int16 minY;
- int16 maxX;
- int16 maxY;
- int16 cursorIndex;
-
- _showCursor = 2;
- cursorIndex = cursor;
-
- if (cursorIndex == -1) {
- cursorIndex = 0;
- for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) {
- if (ptr->flags & 0xfff0)
- continue;
-
- if (ptr->left > _vm->_global->_inter_mouseX)
- continue;
-
- if (ptr->right < _vm->_global->_inter_mouseX)
- continue;
-
- if (ptr->top > _vm->_global->_inter_mouseY)
- continue;
-
- if (ptr->bottom < _vm->_global->_inter_mouseY)
- continue;
-
- if ((ptr->flags & 0xf) < 3)
- cursorIndex = 1;
- else
- cursorIndex = 3;
- break;
- }
- if (_cursorAnimLow[cursorIndex] == -1)
- cursorIndex = 1;
- }
-
- if (_cursorAnimLow[cursorIndex] != -1) {
- if (cursorIndex == _cursorIndex) {
- if (_cursorAnimDelays[_cursorIndex] != 0 &&
- _cursorAnimDelays[_cursorIndex] * 10 +
- _cursorTimeKey <= _vm->_util->getTimeKey()) {
- _cursorAnim++;
- _cursorTimeKey = _vm->_util->getTimeKey();
- } else {
- if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
- (_vm->_global->_inter_mouseY == _cursorY)) {
- _vm->_video->waitRetrace(_vm->_global->_videoMode);
- return;
- }
- }
- } else {
- _cursorIndex = cursorIndex;
- if (_cursorAnimDelays[_cursorIndex] != 0) {
- _cursorAnim =
- _cursorAnimLow[_cursorIndex];
- _cursorTimeKey = _vm->_util->getTimeKey();
- } else {
- _cursorAnim = _cursorIndex;
- }
- }
-
- if (_cursorAnimDelays[_cursorIndex] != 0 &&
- (_cursorAnimHigh[_cursorIndex] < _cursorAnim ||
- _cursorAnimLow[_cursorIndex] >
- _cursorAnim)) {
- _cursorAnim = _cursorAnimLow[_cursorIndex];
- }
-
- newX = _vm->_global->_inter_mouseX;
- newY = _vm->_global->_inter_mouseY;
- if (_cursorXDeltaVar != -1) {
- newX -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorXDeltaVar / 4) * 4);
- newY -= (uint16)VAR_OFFSET(_cursorIndex * 4 + (_cursorYDeltaVar / 4) * 4);
- }
-
- minX = MIN(newX, _cursorX);
- minY = MIN(newY, _cursorY);
- maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
- maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
-
- _vm->_video->drawSprite(_cursorSprites, _scummvmCursor, _cursorWidth * _cursorAnim,
- 0, _cursorWidth * (_cursorAnim + 1) - 1, _cursorHeight - 1, 0, 0, 0);
- CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight, 0, 0, 0);
-
- if (_frontSurface != _backSurface) {
- _showCursor = 3;
- if (_noInvalidated == 0) {
- int16 tmp = _cursorIndex;
- _cursorIndex = -1;
- blitInvalidated();
- _cursorIndex = tmp;
- } else {
- _vm->_video->waitRetrace(_vm->_global->_videoMode);
- if (minY < 50)
- _vm->_util->delay(5);
- _showCursor = 0;
- }
- }
- } else
- blitCursor();
-
- _cursorX = newX;
- _cursorY = newY;
-}
-
-void Draw_v1::initScreen(void) {
- _backSurface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0);
-}
-
-void Draw_v1::closeScreen(void) {
-}
-
} // End of namespace Gob
Modified: scummvm/trunk/engines/gob/draw_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v2.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/draw_v2.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -28,69 +28,184 @@
#include "gob/gob.h"
#include "gob/draw.h"
#include "gob/global.h"
-#include "gob/game.h"
#include "gob/util.h"
+#include "gob/game.h"
#include "gob/scenery.h"
-#include "gob/inter.h"
-#include "gob/cdrom.h"
+#include "gob/video.h"
namespace Gob {
Draw_v2::Draw_v2(GobEngine *vm) : Draw_v1(vm) {
}
-void Draw_v2::printText(void) {
- int i;
+void Draw_v2::initScreen() {
+ _scrollOffsetX = 0;
+ _scrollOffsetY = 0;
+
+ initSpriteSurf(21, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0);
+ _backSurface = _spritesArray[21];
+ _vm->_video->clearSurf(_backSurface);
+
+ initSpriteSurf(23, 32, 16, 2);
+ _cursorSpritesBack = _spritesArray[23];
+ _cursorSprites = _cursorSpritesBack;
+ _scummvmCursor =
+ _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
+
+ _spritesArray[20] = _frontSurface;
+ _spritesArray[21] = _backSurface;
+}
+
+void Draw_v2::closeScreen() {
+ freeSprite(23);
+ _cursorSprites = 0;
+ _cursorSpritesBack = 0;
+ _scummvmCursor = 0;
+ freeSprite(21);
+}
+
+void Draw_v2::blitCursor() {
+ if (_cursorIndex == -1)
+ return;
+
+ _showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
+}
+
+void Draw_v2::animateCursor(int16 cursor) {
+ Game::Collision *ptr;
+ int16 cursorIndex = cursor;
+ int16 newX = 0, newY = 0;
+ uint16 hotspotX = 0, hotspotY = 0;
+
+ _showCursor |= 1;
+
+ // .-- _draw_animateCursorSUB1 ---
+ if (cursorIndex == -1) {
+ cursorIndex = 0;
+ for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) {
+ if ((ptr->flags & 0xF00) || (ptr->id & 0x4000))
+ continue;
+
+ if (ptr->left > _vm->_global->_inter_mouseX)
+ continue;
+
+ if (ptr->right < _vm->_global->_inter_mouseX)
+ continue;
+
+ if (ptr->top > _vm->_global->_inter_mouseY)
+ continue;
+
+ if (ptr->bottom < _vm->_global->_inter_mouseY)
+ continue;
+
+ if ((ptr->flags & 0xF000) == 0) {
+ if ((ptr->flags & 0xF) >= 3) {
+ cursorIndex = 3;
+ break;
+ } else if (((ptr->flags & 0xF0) != 0x10) && (cursorIndex == 0))
+ cursorIndex = 1;
+ } else if (cursorIndex == 0)
+ cursorIndex = (ptr->flags >> 12) & 0xF;
+ }
+ if (_cursorAnimLow[cursorIndex] == -1)
+ cursorIndex = 1;
+ }
+ // '------
+
+ if (_cursorAnimLow[cursorIndex] != -1) {
+ // .-- _draw_animateCursorSUB2 ---
+ if (cursorIndex == _cursorIndex) {
+ if ((_cursorAnimDelays[_cursorIndex] != 0) &&
+ ((_cursorTimeKey + (_cursorAnimDelays[_cursorIndex] * 10)) <=
+ _vm->_util->getTimeKey())) {
+ _cursorAnim++;
+ if ((_cursorAnimHigh[_cursorIndex] < _cursorAnim) ||
+ (_cursorAnimLow[_cursorIndex] > _cursorAnim))
+ _cursorAnim = _cursorAnimLow[_cursorIndex];
+ _cursorTimeKey = _vm->_util->getTimeKey();
+ } else {
+ if (_noInvalidated && (_vm->_global->_inter_mouseX == _cursorX) &&
+ (_vm->_global->_inter_mouseY == _cursorY)) {
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ return;
+ }
+ }
+ } else {
+ _cursorIndex = cursorIndex;
+ if (_cursorAnimDelays[cursorIndex] != 0) {
+ _cursorAnim = _cursorAnimLow[cursorIndex];
+ _cursorTimeKey = _vm->_util->getTimeKey();
+ }
+ }
+
+ if (_cursorAnimDelays[_cursorIndex] != 0) {
+ if ((_cursorAnimHigh[_cursorIndex] < _cursorAnim) ||
+ (_cursorAnimLow[_cursorIndex] > _cursorAnim))
+ _cursorAnim = _cursorAnimLow[_cursorIndex];
+
+ cursorIndex = _cursorAnim;
+ }
+ // '------
+
+ newX = _vm->_global->_inter_mouseX;
+ newY = _vm->_global->_inter_mouseY;
+ if (_cursorHotspotXVar != -1) {
+ newX -= hotspotX = (uint16) VAR(_cursorIndex + _cursorHotspotXVar);
+ newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar);
+ }
+
+ _vm->_video->clearSurf(_scummvmCursor);
+ _vm->_video->drawSprite(_cursorSprites, _scummvmCursor,
+ cursorIndex * _cursorWidth, 0,
+ (cursorIndex + 1) * _cursorWidth - 1,
+ _cursorHeight - 1, 0, 0, 0);
+ CursorMan.replaceCursor(_scummvmCursor->getVidMem(),
+ _cursorWidth, _cursorHeight, hotspotX, hotspotY, 0);
+
+ if (_frontSurface != _backSurface) {
+ if (!_noInvalidated) {
+ int16 tmp = _cursorIndex;
+ _cursorIndex = -1;
+ blitInvalidated();
+ _cursorIndex = tmp;
+ } else {
+ _showCursor = 3;
+ _vm->_video->waitRetrace(_vm->_global->_videoMode);
+ if (MIN(newY, _cursorY) < 50)
+ _vm->_util->delay(5);
+ }
+ }
+ } else
+ blitCursor();
+
+ _showCursor &= ~1;
+
+ _cursorX = newX;
+ _cursorY = newY;
+}
+
+void Draw_v2::printTotText(int16 id) {
byte *dataPtr;
- byte *ptr;
- byte *ptr2;
- char mask[80];
- char str[80];
- char buf[50];
- char cmd;
+ byte *ptr, *ptrEnd;
+ byte cmd;
int16 savedFlags;
- int16 destX;
- int16 destY;
- int16 spriteRight;
- int16 spriteBottom;
+ int16 destX, destY;
+ int16 spriteRight, spriteBottom;
int16 val;
- int16 index;
- int16 rectLeft;
- int16 rectTop;
- int16 rectRight;
- int16 rectBottom;
- int16 fontIndex;
- int16 strPos; // si
- int16 frontColor;
- int16 colId;
- int16 strPos2;
- int16 offX;
- int16 offY;
- int16 extraCmd;
- int16 strPosBak;
- int16 maskChar;
- int16 width;
+ int16 rectLeft, rectTop, rectRight, rectBottom;
int16 size;
- index = _vm->_inter->load16();
-
- _vm->_cdrom->playMultMusic();
-
- if ((_vm->_game->_totTextData == 0) || (_vm->_game->_totTextData->dataPtr == 0))
+ if (!_vm->_game->_totTextData || !_vm->_game->_totTextData->dataPtr)
return;
- if (_vm->_global->_languageWanted != _vm->_global->_language) {
- warning("Your game version doesn't support the requested language, "
- "using the first one available (%d)", _vm->_global->_language);
- _vm->_global->_languageWanted = _vm->_global->_language;
- }
+ _vm->validateLanguage();
- size = _vm->_game->_totTextData->items[index].size;
+ size = _vm->_game->_totTextData->items[id].size;
dataPtr = ((byte *) _vm->_game->_totTextData->dataPtr) +
- _vm->_game->_totTextData->items[index].offset;
+ _vm->_game->_totTextData->items[id].offset;
ptr = dataPtr;
- if ((_renderFlags & 0x400) && (ptr[1] & 0x80))
+ if ((_renderFlags & RENDERFLAG_SKIPOPTIONALTEXT) && (ptr[1] & 0x80))
return;
destX = READ_LE_UINT16(ptr) & 0x7FFF;
@@ -117,92 +232,94 @@
spriteOperation(DRAW_CLEARRECT);
_backColor = 0;
-
savedFlags = _renderFlags;
_renderFlags &= ~RENDERFLAG_NOINVALIDATE;
- for (; (_destSpriteX = READ_LE_UINT16(ptr)) != -1; ptr++) {
+ while ((_destSpriteX = READ_LE_UINT16(ptr)) != -1) {
_destSpriteX += destX;
_destSpriteY = READ_LE_UINT16(ptr + 2) + destY;
_spriteRight = READ_LE_UINT16(ptr + 4) + destX;
_spriteBottom = READ_LE_UINT16(ptr + 6) + destY;
ptr += 8;
- cmd = (*ptr & 0xf0) >> 4;
- if (cmd == 0) {
- _frontColor = *ptr & 0xf;
+ cmd = *ptr++;
+ switch ((cmd & 0xF0) >> 4) {
+ case 0:
+ _frontColor = cmd & 0xF;
spriteOperation(DRAW_DRAWLINE);
- } else if (cmd == 1) {
- _frontColor = *ptr & 0xf;
+ break;
+ case 1:
+ _frontColor = cmd & 0xF;
spriteOperation(DRAW_DRAWBAR);
- } else if (cmd == 2) {
- _backColor = *ptr & 0xf;
+ break;
+ case 2:
+ _backColor = cmd & 0xF;
spriteOperation(DRAW_FILLRECTABS);
+ break;
}
}
ptr += 2;
- // Adding the boundary check *shouldn't* pose any problems, since access behind
- // that point should be forbidden anyway.
- for (i = 0, ptr2 = ptr; ((ptr2 - dataPtr) < size) && (*ptr2 != 1); i++) {
- if ((_vm->_game->_totFileData[0x29] < 0x32) && (*ptr2 > 3) && (*ptr2 < 32))
- *ptr2 = 32;
+ ptrEnd = ptr;
+ while (((ptrEnd - dataPtr) < size) && (*ptrEnd != 1)) {
+ // Converting to unknown commands/characters to spaces
+ if ((_vm->_game->_totFileData[0x29] < 0x32) && (*ptrEnd > 3) && (*ptrEnd < 32))
+ *ptrEnd = 32;
- switch (*ptr2) {
+ switch (*ptrEnd) {
case 1:
break;
case 2:
case 5:
- ptr2 += 5;
+ ptrEnd += 5;
break;
case 3:
case 4:
- ptr2 += 2;
+ ptrEnd += 2;
break;
case 6:
- ptr2++;
- switch (*ptr2 & 0xC0) {
+ ptrEnd++;
+ switch (*ptrEnd & 0xC0) {
case 0x40:
- ptr2 += 9;
+ ptrEnd += 9;
break;
case 0x80:
- ptr2 += 3;
+ ptrEnd += 3;
break;
case 0xC0:
- ptr2 += 11;
+ ptrEnd += 11;
break;
default:
- ptr2++;
+ ptrEnd++;
break;
}
break;
case 10:
- ptr2 += (ptr2[1] * 2) + 2;
+ ptrEnd += (ptrEnd[1] * 2) + 2;
break;
default:
- ptr2++;
+ ptrEnd++;
break;
}
}
+ ptrEnd++;
- ptr2++;
+ int16 fontIndex = 0, frontColor = 0;
+ int16 strPos = 0, strPos2 = -1, strPosBak;
+ int16 offX = 0, offY = 0;
+ int16 colId = 0;
+ int16 colCmd = 0;
+ int16 width;
+ int16 maskChar = 0;
+ char mask[80], str[80], buf[50];
- fontIndex = 0;
- strPos = 0;
- extraCmd = 0;
- frontColor = 0;
- colId = 0;
- offX = 0;
- offY = 0;
- strPos2 = -1;
memset(mask, 0, 80);
memset(str, ' ', 80);
- maskChar = 0;
_backColor = 0;
_transparency = 1;
@@ -212,7 +329,8 @@
strPosBak = strPos;
width = strlen(str) * _fonts[fontIndex]->itemWidth;
adjustCoords(1, &width, 0);
- if (extraCmd & 0x0F) {
+
+ if (colCmd & 0x0F) {
rectLeft = offX - 2;
rectTop = offY - 2;
rectRight = offX + width + 1;
@@ -221,36 +339,42 @@
rectBottom += offY + 1;
adjustCoords(0, &rectLeft, &rectTop);
adjustCoords(2, &rectRight, &rectBottom);
+
if (colId != -1)
_vm->_game->addNewCollision(colId + 0xD000, rectLeft, rectTop,
rectRight, rectBottom, 2, 0, 0, 0);
- if (_word_2E8E2 != 2)
- printTextCentered(extraCmd & 0x0F, rectLeft + 4, rectTop + 4,
+
+ if (_needAdjust != 2)
+ printTextCentered(colCmd & 0x0F, rectLeft + 4, rectTop + 4,
rectRight - 4, rectBottom - 4, str, fontIndex, frontColor);
else
- printTextCentered(extraCmd & 0x0F, rectLeft + 2, rectTop + 2,
+ printTextCentered(colCmd & 0x0F, rectLeft + 2, rectTop + 2,
rectRight - 2, rectBottom - 2, str, fontIndex, frontColor);
+
} else {
_destSpriteX = offX;
_destSpriteY = offY;
_fontIndex = fontIndex;
_frontColor = frontColor;
_textToPrint = str;
- if (_word_2E8E2 != 2) {
- if ((_destSpriteX >= destX) && (_destSpriteY >= destY)) {
- if (((_fonts[_fontIndex]->itemHeight / 2) + _destSpriteY - 1) <= spriteBottom) {
- while (((_destSpriteX + width - 1) > spriteRight) && (width > 0)) {
- width -= _fonts[_fontIndex]->itemWidth / 2;
- str[strlen(str) - 1] = '\0';
- }
- spriteOperation(DRAW_PRINTTEXT);
+
+ if (_needAdjust != 2) {
+ if ((_destSpriteX >= destX) && (_destSpriteY >= destY) &&
+ (((_fonts[_fontIndex]->itemHeight / 2) + _destSpriteY - 1) <= spriteBottom)) {
+ while (((_destSpriteX + width - 1) > spriteRight) && (width > 0)) {
+ width -= _fonts[_fontIndex]->itemWidth / 2;
+ str[strlen(str) - 1] = '\0';
}
+ spriteOperation(DRAW_PRINTTEXT);
}
} else
spriteOperation(DRAW_PRINTTEXT);
+
width = strlen(str);
for (strPos = 0; strPos < width; strPos++) {
- if (mask[strPos] == '\0') continue;
+ if (mask[strPos] == '\0')
+ continue;
+
rectLeft = _fonts[fontIndex]->itemWidth;
rectTop = _fonts[fontIndex]->itemHeight;
adjustCoords(1, &rectLeft, &rectTop);
@@ -261,6 +385,7 @@
spriteOperation(DRAW_DRAWLINE);
}
}
+
rectLeft = _fonts[_fontIndex]->itemWidth;
adjustCoords(1, &rectLeft, 0);
offX += strPosBak * rectLeft;
@@ -297,13 +422,13 @@
case 6:
ptr++;
- extraCmd = *ptr++;
+ colCmd = *ptr++;
colId = -1;
- if (extraCmd & 0x80) {
+ if (colCmd & 0x80) {
colId = (int16)READ_LE_UINT16(ptr);
ptr += 2;
}
- if (extraCmd & 0x40) {
+ if (colCmd & 0x40) {
rectLeft = destX + (int16)READ_LE_UINT16(ptr);
rectRight = destX + (int16)READ_LE_UINT16(ptr + 2);
rectTop = destY + (int16)READ_LE_UINT16(ptr + 4);
@@ -318,7 +443,7 @@
case 7:
ptr++;
- extraCmd = 0;
+ colCmd = 0;
break;
case 8:
@@ -332,61 +457,61 @@
break;
case 10:
- // loc_12C93
- str[0] = (char)255;
- WRITE_LE_UINT16((uint16*)(str+1), ((char *) ptr) - _vm->_game->_totTextData->dataPtr);
+ str[0] = (char) 255;
+ WRITE_LE_UINT16((uint16 *) (str + 1),
+ ((char *) ptr) - _vm->_game->_totTextData->dataPtr);
str[3] = 0;
ptr++;
- i = *ptr++;
- for (i = *ptr++; i > 0; i--) {
+ for (int i = *ptr++; i > 0; i--) {
mask[strPos++] = maskChar;
ptr += 2;
}
break;
default:
- str[strPos] = cmd;
+ str[strPos] = (char) cmd;
case 32:
mask[strPos++] = maskChar;
ptr++;
break;
case 186:
- cmd = ptr2[17] & 0x7f;
+ cmd = ptrEnd[17] & 0x7F;
if (cmd == 0) {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
sprintf(buf, "%d", VAR_OFFSET(val));
} else if (cmd == 1) {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
strcpy(buf, GET_VARO_STR(val));
} else {
- val = READ_LE_UINT16(ptr2 + 18) * 4;
+ val = READ_LE_UINT16(ptrEnd + 18) * 4;
sprintf(buf, "%d", VAR_OFFSET(val));
if (buf[0] == '-') {
- while (strlen(buf) - 1 < (uint32)ptr2[17]) {
+ while (strlen(buf) - 1 < (uint32)ptrEnd[17]) {
_vm->_util->insertStr("0", buf, 1);
}
} else {
- while (strlen(buf) - 1 < (uint32)ptr2[17]) {
+ while (strlen(buf) - 1 < (uint32)ptrEnd[17]) {
_vm->_util->insertStr("0", buf, 0);
}
}
if (_vm->_global->_language == 2)
- _vm->_util->insertStr(".", buf, strlen(buf) + 1 - ptr2[17]);
+ _vm->_util->insertStr(".", buf, strlen(buf) + 1 - ptrEnd[17]);
else
- _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptr2[17]);
+ _vm->_util->insertStr(",", buf, strlen(buf) + 1 - ptrEnd[17]);
}
memcpy(str + strPos, buf, strlen(buf));
memset(mask, maskChar, strlen(buf));
- if (ptr2[17] & 0x80) {
+ if (ptrEnd[17] & 0x80) {
strPos2 = strPos + strlen(buf);
strPos++;
- ptr2 += 23;
+ ptrEnd += 23;
ptr++;
} else {
strPos += strlen(buf);
if (ptr[1] != ' ') {
- if ((ptr[1] == 2) && (((int16)READ_LE_UINT16(ptr + 4)) == _destSpriteY)) {
+ if ((ptr[1] == 2) &&
+ (((int16)READ_LE_UINT16(ptr + 4)) == _destSpriteY)) {
ptr += 5;
str[strPos] = ' ';
mask[strPos++] = maskChar;
@@ -396,10 +521,11 @@
mask[strPos++] = maskChar;
while (ptr[1] == ' ')
ptr++;
- if ((ptr[1] == 2) && (((int16)READ_LE_UINT16(ptr + 4)) == _destSpriteY))
+ if ((ptr[1] == 2) &&
+ (((int16)READ_LE_UINT16(ptr + 4)) == _destSpriteY))
ptr += 5;
}
- ptr2 += 23;
+ ptrEnd += 23;
ptr++;
}
break;
@@ -407,7 +533,7 @@
}
_renderFlags = savedFlags;
- if (!(_renderFlags & 4))
+ if (!(_renderFlags & RENDERFLAG_COLLISIONS))
return;
_vm->_game->checkCollisions(0, 0, 0, 0);
@@ -416,8 +542,6 @@
(*_vm->_scenery->_pCaptureCounter)--;
_vm->_game->capturePop(1);
}
-
- return;
}
void Draw_v2::spriteOperation(int16 operation) {
@@ -426,35 +550,19 @@
Game::TotResItem *itemPtr;
int32 offset;
int16 len;
- int16 i;
- int16 x;
- int16 y;
- Video::SurfaceDesc *sourceSurf;
- Video::SurfaceDesc *destSurf;
+ int16 x, y;
+ SurfaceDesc *sourceSurf, *destSurf;
bool deltaVeto;
int16 left;
int16 ratio;
- int16 spriteLeft;
- int16 spriteTop;
- int16 spriteRight;
- int16 spriteBottom;
- int16 destSpriteX;
- int16 destSpriteY;
- int16 destSurface;
- int16 sourceSurface;
-// .---
- int8 word_2F2D2 = -1;
-// '---
+ // Some handle, but always assigned to -1 in Game::loadTotFile()
+ int16 word_2F2D2 = -1;
- if (operation & 0x10) {
- deltaVeto = true;
- operation &= 0x0F;
- } else
- deltaVeto = false;
+ deltaVeto = (bool) (operation & 0x10);
+ operation &= 0x0F;
if (_sourceSurface >= 100)
_sourceSurface -= 80;
-
if (_destSurface >= 100)
_destSurface -= 80;
@@ -467,63 +575,44 @@
if (_destSurface == 21) {
_destSpriteX += _backDeltaX;
_destSpriteY += _backDeltaY;
- if (operation == DRAW_DRAWLINE ||
- (operation >= DRAW_DRAWBAR
- && operation <= DRAW_FILLRECTABS)) {
+ if ((operation == DRAW_DRAWLINE) ||
+ ((operation >= DRAW_DRAWBAR) &&
+ (operation <= DRAW_FILLRECTABS))) {
_spriteRight += _backDeltaX;
_spriteBottom += _backDeltaY;
}
}
}
- spriteLeft = _spriteLeft;
- spriteTop = _spriteTop;
- spriteRight = _spriteRight;
- spriteBottom = _spriteLeft;
- destSpriteX = _destSpriteX;
- destSpriteY = _destSpriteY;
- destSurface = _destSurface;
- sourceSurface = _sourceSurface;
+ int16 spriteLeft = _spriteLeft;
+ int16 spriteTop = _spriteTop;
+ int16 spriteRight = _spriteRight;
+ int16 spriteBottom = _spriteLeft;
+ int16 destSpriteX = _destSpriteX;
+ int16 destSpriteY = _destSpriteY;
+ int16 destSurface = _destSurface;
+ int16 sourceSurface = _sourceSurface;
-// warning("GOB2 Stub! _off_2E51B");
- if (_off_2E51B != 0) {
- if ((_frontSurface->height <= _destSpriteY) &&
- ((_destSurface == 20) || (_destSurface == 21))) {
- _destSpriteY -= _frontSurface->height;
- if (operation == DRAW_DRAWLINE ||
- (operation >= DRAW_DRAWBAR
- && operation <= DRAW_FILLRECTABS)) {
- _spriteBottom -= _frontSurface->height;
- }
- if (_destSurface == 21)
- invalidateRect(0, _frontSurface->height, _vm->_video->_surfWidth - 1,
- _frontSurface->height + _off_2E51B->height - 1);
- destSurface += 4;
- }
- if ((_frontSurface->height <= _spriteTop) && (operation == DRAW_BLITSURF)
- && ((_destSurface == 20) || (_destSurface == 21))) {
- _spriteTop -= _frontSurface->height;
- _sourceSurface += 4;
- }
- }
-
adjustCoords(0, &_destSpriteX, &_destSpriteY);
- if ((operation != DRAW_LOADSPRITE) && (_word_2E8E2 != 2)) {
+ if ((operation != DRAW_LOADSPRITE) && (_needAdjust != 2)) {
adjustCoords(0, &_spriteRight, &_spriteBottom);
adjustCoords(0, &_spriteLeft, &_spriteTop);
- if (operation == DRAW_DRAWLETTER)
+
+ if (operation == DRAW_DRAWLINE) {
+ if ((_spriteRight == _destSpriteX) || (_spriteBottom == _destSpriteY)) {
+ operation = DRAW_FILLRECTABS;
+ _backColor = _frontColor;
+ }
+ } else if (operation == DRAW_DRAWLETTER)
operation = DRAW_BLITSURF;
- if ((operation == DRAW_DRAWLINE) &&
- ((_spriteRight == _destSpriteX) || (_spriteBottom == _destSpriteY))) {
- operation = DRAW_FILLRECTABS;
- _backColor = _frontColor;
- }
+
if (operation == DRAW_DRAWLINE) {
if (_spriteBottom < _destSpriteY) {
SWAP(_spriteBottom, _destSpriteY);
SWAP(_spriteRight, _destSpriteX);
}
- } else if ((operation == DRAW_LOADSPRITE) || (operation > DRAW_PRINTTEXT)) {
+ } else if ((operation == DRAW_LOADSPRITE) ||
+ (operation > DRAW_PRINTTEXT)) {
if (_spriteBottom < _destSpriteY)
SWAP(_spriteBottom, _destSpriteY);
if (_spriteRight < _destSpriteX)
@@ -539,7 +628,7 @@
switch (operation) {
case DRAW_BLITSURF:
case DRAW_DRAWLETTER:
- if ((sourceSurf == 0) || (destSurf == 0))
+ if (!sourceSurf || !destSurf)
break;
_vm->_video->drawSprite(_spritesArray[_sourceSurface],
@@ -551,17 +640,17 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
case DRAW_PUTPIXEL:
- _vm->_video->putPixel(_destSpriteX, _destSpriteY,
- _frontColor, _spritesArray[_destSurface]);
+ _vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor,
+ _spritesArray[_destSurface]);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX, _destSpriteY);
+ _destSpriteX, _destSpriteY);
}
break;
@@ -572,8 +661,8 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
@@ -584,7 +673,7 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -592,9 +681,10 @@
_vm->_video->drawCircle(_spritesArray[_destSurface], _destSpriteX,
_destSpriteY, _spriteRight, _frontColor);
if (_destSurface == 21) {
- invalidateRect(_destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, // !!
- _destSpriteX + _spriteRight,
- _destSpriteY + _spriteBottom);
+ invalidateRect(_destSpriteX - _spriteRight,
+ _destSpriteY - _spriteBottom,
+ _destSpriteX + _spriteRight,
+ _destSpriteY + _spriteBottom);
}
break;
@@ -602,17 +692,14 @@
id = _spriteLeft;
if (id >= 30000) {
dataBuf =
- _vm->_game->loadExtData(id, &_spriteRight,
- &_spriteBottom);
- _vm->_video->drawPackedSprite((byte *)dataBuf, _spriteRight,
- _spriteBottom, _destSpriteX,
- _destSpriteY, _transparency,
- _spritesArray[_destSurface]);
+ _vm->_game->loadExtData(id, &_spriteRight, &_spriteBottom);
+ _vm->_video->drawPackedSprite((byte *) dataBuf,
+ _spriteRight, _spriteBottom, _destSpriteX, _destSpriteY,
+ _transparency, _spritesArray[_destSurface]);
if (_destSurface == 21) {
- invalidateRect(_destSpriteX,
- _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ invalidateRect(_destSpriteX, _destSpriteY,
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
delete[] dataBuf;
break;
@@ -621,49 +708,44 @@
itemPtr = &_vm->_game->_totResourceTable->items[id];
offset = itemPtr->offset;
if (offset >= 0) {
- dataBuf =
- _vm->_game->_totResourceTable->dataPtr +
- szGame_TotResTable + szGame_TotResItem *
- _vm->_game->_totResourceTable->itemsCount + offset;
+ dataBuf = _vm->_game->_totResourceTable->dataPtr +
+ szGame_TotResTable + szGame_TotResItem *
+ _vm->_game->_totResourceTable->itemsCount + offset;
} else {
- dataBuf =
- _vm->_game->_imFileData +
- (int32)READ_LE_UINT32(&((int32 *)_vm->_game->_imFileData)[-offset - 1]);
+ dataBuf = _vm->_game->_imFileData +
+ (int32) READ_LE_UINT32(&((int32 *) _vm->_game->_imFileData)[-offset - 1]);
}
_spriteRight = itemPtr->width;
_spriteBottom = itemPtr->height;
- _vm->_video->drawPackedSprite((byte *)dataBuf,
+ _vm->_video->drawPackedSprite((byte *) dataBuf,
_spriteRight, _spriteBottom,
_destSpriteX, _destSpriteY,
_transparency, _spritesArray[_destSurface]);
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _destSpriteX + _spriteRight - 1,
- _destSpriteY + _spriteBottom - 1);
+ _destSpriteX + _spriteRight - 1,
+ _destSpriteY + _spriteBottom - 1);
}
break;
case DRAW_PRINTTEXT:
len = strlen(_textToPrint);
left = _destSpriteX;
+
if ((_fontIndex >= 4) || (_fontToSprite[_fontIndex].sprite == -1)) {
- if (_fonts[_fontIndex]->extraData == 0) {
+
+ if (!_fonts[_fontIndex]->extraData) {
if (((int8) _textToPrint[0]) == -1) {
- if (_vm->_global->_languageWanted != _vm->_global->_language) {
- warning("Your game version doesn't support the requested language, "
- "using the first one available (%d)",
- _vm->_global->_language);
- _vm->_global->_languageWanted = _vm->_global->_language;
- }
+ _vm->validateLanguage();
+
dataBuf = _vm->_game->_totTextData->dataPtr + _textToPrint[1] + 1;
len = *dataBuf++;
- for (i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++, dataBuf += 2) {
_vm->_video->drawLetter(READ_LE_UINT16(dataBuf), _destSpriteX,
_destSpriteY, _fonts[_fontIndex], _transparency, _frontColor,
_backColor, _spritesArray[_destSurface]);
- dataBuf += 2;
}
} else {
drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor,
@@ -672,40 +754,25 @@
_destSpriteX += len * _fonts[_fontIndex]->itemWidth;
}
} else {
- if (word_2F2D2 >= 0) {
- for (i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
+ if ((word_2F2D2 < 0) || (_textToPrint[i] != ' ')) {
_vm->_video->drawLetter(_textToPrint[i], _destSpriteX,
_destSpriteY, _fonts[_fontIndex], _transparency,
_frontColor, _backColor, _spritesArray[_destSurface]);
_destSpriteX += *(((char*)_fonts[_fontIndex]->extraData) +
(_textToPrint[i] - _fonts[_fontIndex]->startItem));
}
- } else { // loc_DBE9
- warning("Untested, does that work?");
- // Does something different for each character depending on whether it's a space
- // That *should* be it...
- for (i = 0; i < len; i++) {
- if (_textToPrint[i] == ' ')
- _destSpriteX += _fonts[_fontIndex]->itemWidth;
- else {
- _vm->_video->drawLetter(_textToPrint[i],
- _destSpriteX, _destSpriteY,
- _fonts[_fontIndex],
- _transparency,
- _frontColor, _backColor,
- _spritesArray[_destSurface]);
- _destSpriteX +=
- *(((char*)_fonts[_fontIndex]->extraData) + (_textToPrint[i] - _fonts[_fontIndex]->startItem));
- }
- }
+ else
+ _destSpriteX += _fonts[_fontIndex]->itemWidth;
}
}
+
} else {
sourceSurf = _spritesArray[_fontToSprite[_fontIndex].sprite];
ratio = ((sourceSurf == _frontSurface) || (sourceSurf == _backSurface)) ?
- 320 : sourceSurf->width;
+ 320 : sourceSurf->getWidth();
ratio /= _fontToSprite[_fontIndex].width;
- for (i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
y = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) / ratio)
* _fontToSprite[_fontIndex].height;
x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio)
@@ -721,13 +788,13 @@
if (_destSurface == 21) {
invalidateRect(left, _destSpriteY,
- _destSpriteX - 1,
- _destSpriteY + _fonts[_fontIndex]->itemHeight - 1);
+ _destSpriteX - 1,
+ _destSpriteY + _fonts[_fontIndex]->itemHeight - 1);
}
break;
case DRAW_DRAWBAR:
- if (_word_2E8E2 != 2) {
+ if (_needAdjust != 2) {
_vm->_video->fillRect(_spritesArray[_destSurface],
_destSpriteX, _spriteBottom - 1,
_spriteRight, _spriteBottom, _frontColor);
@@ -762,7 +829,7 @@
}
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -775,7 +842,7 @@
}
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
@@ -786,7 +853,7 @@
if (_destSurface == 21) {
invalidateRect(_destSpriteX, _destSpriteY,
- _spriteRight, _spriteBottom);
+ _spriteRight, _spriteBottom);
}
break;
}
@@ -819,191 +886,4 @@
}
}
-void Draw_v2::blitCursor(void) {
- if (_cursorIndex == -1)
- return;
-
- _showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
-}
-
-void Draw_v2::animateCursor(int16 cursor) {
- int16 newX = 0;
- int16 newY = 0;
- Game::Collision *ptr;
- int16 minX;
- int16 minY;
- int16 maxX;
- int16 maxY;
- int16 cursorIndex;
- uint16 hotspotX = 0;
- uint16 hotspotY = 0;
-
- _showCursor |= 1;
-
- // .-- _draw_animateCursorSUB1 ---
- cursorIndex = cursor;
- if (cursorIndex == -1) {
- cursorIndex = 0;
- for (ptr = _vm->_game->_collisionAreas; ptr->left != -1; ptr++) {
- if ((ptr->flags & 0xF00) || (ptr->id & 0x4000))
- continue;
-
- if (ptr->left > _vm->_global->_inter_mouseX)
- continue;
-
- if (ptr->right < _vm->_global->_inter_mouseX)
- continue;
-
- if (ptr->top > _vm->_global->_inter_mouseY)
- continue;
-
- if (ptr->bottom < _vm->_global->_inter_mouseY)
- continue;
-
- if ((ptr->flags & 0xF000) == 0) {
- if ((ptr->flags & 0xF) >= 3) {
- cursorIndex = 3;
- break;
- } else if (((ptr->flags & 0xF0) != 0x10) && (cursorIndex == 0))
- cursorIndex = 1;
- } else if (cursorIndex == 0)
- cursorIndex = (ptr->flags >> 12) & 0xF;
- }
- if (_cursorAnimLow[cursorIndex] == -1)
- cursorIndex = 1;
- }
- // '------
-
- if (_cursorAnimLow[cursorIndex] != -1) {
- // .-- _draw_animateCursorSUB2 ---
- if (cursorIndex == _cursorIndex) {
- if ((_cursorAnimDelays[_cursorIndex] != 0) &&
- ((_cursorTimeKey + (_cursorAnimDelays[_cursorIndex] * 10)) <=
- _vm->_util->getTimeKey())) {
- _cursorAnim++;
- if ((_cursorAnimHigh[_cursorIndex] < _cursorAnim) ||
- (_cursorAnimLow[_cursorIndex] > _cursorAnim))
- _cursorAnim = _cursorAnimLow[_cursorIndex];
- _cursorTimeKey = _vm->_util->getTimeKey();
- } else {
- if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
- (_vm->_global->_inter_mouseY == _cursorY)) {
- _vm->_video->waitRetrace(_vm->_global->_videoMode);
- return;
- }
- }
- } else {
- _cursorIndex = cursorIndex;
- if (_cursorAnimDelays[cursorIndex] != 0) {
- _cursorAnim = _cursorAnimLow[cursorIndex];
- _cursorTimeKey = _vm->_util->getTimeKey();
- }
- }
-
- if (_cursorAnimDelays[_cursorIndex] != 0) {
- if ((_cursorAnimHigh[_cursorIndex] < _cursorAnim) ||
- (_cursorAnimLow[_cursorIndex] > _cursorAnim))
- _cursorAnim = _cursorAnimLow[_cursorIndex];
-
- cursorIndex = _cursorAnim;
- }
- // '------
-
- newX = _vm->_global->_inter_mouseX;
- newY = _vm->_global->_inter_mouseY;
- if (_cursorXDeltaVar != -1) {
- newX -= hotspotX = (uint16) VAR(_cursorIndex + _cursorXDeltaVar);
- newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorYDeltaVar);
- }
-
- minX = MIN(newX, _cursorX);
- minY = MIN(newY, _cursorY);
- maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
- maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
-
- _vm->_video->clearSurf(_scummvmCursor);
- _vm->_video->drawSprite(_cursorSprites, _scummvmCursor, cursorIndex * _cursorWidth,
- 0, (cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1, 0, 0, 0);
- CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight,
- hotspotX, hotspotY, 0);
-
- if (_frontSurface != _backSurface) {
- if (_noInvalidated == 0) {
- int16 tmp = _cursorIndex;
- _cursorIndex = -1;
- blitInvalidated();
- _cursorIndex = tmp;
- } else {
- _showCursor = 3;
- _vm->_video->waitRetrace(_vm->_global->_videoMode);
- if (minY < 50)
- _vm->_util->delay(5);
- }
- }
- } else
- blitCursor();
-
- _showCursor &= ~1;
-
- _cursorX = newX;
- _cursorY = newY;
-}
-
-void Draw_v2::initScreen(void) {
- _scrollOffsetX = 0;
- _scrollOffsetY = 0;
-
- if (_word_2E51F != 0) {
- _off_2E51B = new Video::SurfaceDesc;
- memcpy(_off_2E51B, _frontSurface, sizeof(Video::SurfaceDesc));
- _off_2E51B->height = _vm->_global->_primaryHeight - _word_2E51F;
- _frontSurface->height -= _off_2E51B->height;
- _frontSurface->vidPtr =
- _off_2E51B->vidPtr + ((_off_2E51B->width * _off_2E51B->height) / 4);
-
- _off_2E517 = new Video::SurfaceDesc;
- memcpy(_off_2E517, _off_2E51B, sizeof(Video::SurfaceDesc));
- _off_2E517->width = _vm->_global->_primaryWidth;
- _off_2E517->vidPtr = _frontSurface->vidPtr +
- ((_frontSurface->width * _frontSurface->height ) / 4);
- }
- initBigSprite(21, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0);
- _backSurface = _spritesArray[21];
- _vm->_video->clearSurf(_backSurface);
-
- initBigSprite(23, 32, 16, 2);
- _cursorSpritesBack = _spritesArray[23];
- _cursorSprites = _cursorSpritesBack;
- _scummvmCursor =
- _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
-
- _spritesArray[20] = _frontSurface;
- _spritesArray[21] = _backSurface;
-
-/* if (_word_2E51F != 0) {
- dword_2F92D = _off_2E51B;
- dword_2F931 = _off_2E517;
- }*/
-}
-
-void Draw_v2::closeScreen(void) {
- freeSprite(23);
- _cursorSprites = 0;
- _cursorSpritesBack = 0;
- _vm->_video->freeSurfDesc(_scummvmCursor);
- _scummvmCursor = 0;
- if (_off_2E51B != 0) {
- memcpy(_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc));
- _frontSurface->width = _vm->_video->_surfWidth;
- _frontSurface->height = _vm->_video->_surfHeight;
- delete _off_2E51B;
- delete _off_2E517;
- _off_2E51B = 0;
- _off_2E517 = 0;
- }
- if (_frontSurface != _backSurface)
- freeSprite(21);
- _spritesArray[21] = 0;
-}
-
} // End of namespace Gob
Modified: scummvm/trunk/engines/gob/driver_vga.cpp
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.cpp 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/driver_vga.cpp 2007-03-20 14:51:57 UTC (rev 26252)
@@ -23,105 +23,115 @@
#include "common/stdafx.h"
#include "common/endian.h"
+#include "graphics/primitives.h"
#include "gob/driver_vga.h"
-#include "graphics/primitives.h"
-#if defined (_MSC_VER) || defined (__WINS__)
-#define STUB_FUNC printf("STUB:")
-#else
-#define STUB_FUNC printf("STUB: %s\n", __PRETTY_FUNCTION__)
-#endif
-
namespace Gob {
-void VGAVideoDriver::drawSprite(Video::SurfaceDesc *source, Video::SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) {
- if (x >= 0 && x < dest->width && y >= 0 && y < dest->height) {
- int16 width = (right - left) + 1;
- int16 height = (bottom - top) + 1;
+static void plotPixel(int x, int y, int color, void *data) {
+ SurfaceDesc *dest = (SurfaceDesc *)data;
- byte *srcPos = source->vidPtr + (top * source->width) + left;
- byte *destPos = dest->vidPtr + (y * dest->width) + x;
- while (height--) {
- if (transp) {
- for (int16 i = 0; i < width; ++i) {
- if (srcPos[i])
- destPos[i] = srcPos[i];
- }
- } else {
- for (int16 i = 0; i < width; ++i)
- destPos[i] = srcPos[i];
- }
+ if ((x >= 0) && (x < dest->getWidth()) &&
+ (y >= 0) && (y < dest->getHeight()))
+ dest->getVidMem()[(y * dest->getWidth()) + x] = color;
+}
- srcPos += source->width; //width ?
- destPos += dest->width;
- }
- }
+void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest) {
+ if ((x >= 0) && (x < dest->getWidth()) &&
+ (y >= 0) && (y < dest->getHeight()))
+ dest->getVidMem()[(y * dest->getWidth()) + x] = color;
}
-void VGAVideoDriver::fillRect(Video::SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, byte color) {
- if (left < dest->width && right < dest->width && top < dest->height && bottom < dest->height) {
- byte *pos = dest->vidPtr + (top * dest->width) + left;
- int16 width = (right - left) + 1;
- int16 height = (bottom - top) + 1;
- while (height--) {
- for (int16 i = 0; i < width; ++i) {
- pos[i] = color;
- }
+void VGAVideoDriver::drawLine(SurfaceDesc *dest, int16 x0, int16 y0, int16 x1,
+ int16 y1, byte color) {
- pos += dest->width;
- }
- }
+ Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, dest);
}
-void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, Video::SurfaceDesc *dest) {
- if (x >= 0 && x < dest->width && y >= 0 && y < dest->height)
- dest->vidPtr[(y * dest->width) + x] = color;
+void VGAVideoDriver::fillRect(SurfaceDesc *dest, int16 left, int16 top,
+ int16 right, int16 bottom, byte color) {
+
+ if ((left >= dest->getWidth()) || (right >= dest->getWidth()) ||
+ (top >= dest->getHeight()) || (bottom >= dest->getHeight()))
+ return;
+
+ byte *pos = dest->getVidMem() + (top * dest->getWidth()) + left;
+ int16 width = (right - left) + 1;
+ int16 height = (bottom - top) + 1;
+
+ while (height--) {
+ for (int16 i = 0; i < width; ++i)
+ pos[i] = color;
+
+ pos += dest->getWidth();
+ }
}
-void VGAVideoDriver::drawLetter(unsigned char item, int16 x, int16 y, Video::FontDesc *fontDesc, byte color1, byte color2, byte transp, Video::SurfaceDesc *dest) {
+void VGAVideoDriver::drawLetter(unsigned char item, int16 x, int16 y,
+ Video::FontDesc *fontDesc, byte color1, byte color2,
+ byte transp, SurfaceDesc *dest) {
byte *src, *dst;
uint16 data;
- int i, j;
- src = (byte *)fontDesc->dataPtr + (item - fontDesc->startItem) * (fontDesc->itemSize & 0xff);
- dst = dest->vidPtr + x + dest->width * y;
+ src = ((byte *) fontDesc->dataPtr) +
+ (item - fontDesc->startItem) * (fontDesc->itemSize & 0xFF);
+ dst = dest->getVidMem() + x + dest->getWidth() * y;
- for (i = 0; i < fontDesc->itemHeight; i++) {
+ for (int i = 0; i < fontDesc->itemHeight; i++) {
data = READ_BE_UINT16(src);
src += 2;
if (fontDesc->itemSize <= 8)
src--;
- for (j = 0; j < fontDesc->itemWidth; j++) {
- if (data & 0x8000) {
+ for (int j = 0; j < fontDesc->itemWidth; j++) {
+ if (data & 0x8000)
*dst = color2;
- } else {
- if (color1 == 0)
- *dst = transp;
- }
+ else if (color1 == 0)
+ *dst = transp;
+
dst++;
data <<= 1;
}
- dst += dest->width - fontDesc->itemWidth;
+ dst += dest->getWidth() - fontDesc->itemWidth;
}
}
-static void plotPixel(int x, int y, int color, void *data) {
- Video::SurfaceDesc *dest = (Video::SurfaceDesc *)data;
- if (x >= 0 && x < dest->width && y >= 0 && y < dest->height)
- dest->vidPtr[(y * dest->width) + x] = color;
-}
+void VGAVideoDriver::drawSprite(SurfaceDesc *source, SurfaceDesc *dest,
+ int16 left, int16 top, int16 right, int16 bottom,
+ int16 x, int16 y, int16 transp) {
-void VGAVideoDriver::drawLine(Video::SurfaceDesc *dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color) {
- Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, dest);
+ if ((x >= dest->getWidth()) || (x < 0) ||
+ (y >= dest->getHeight()) || (y < 0))
+ return;
+
+ int16 width = (right - left) + 1;
+ int16 height = (bottom - top) + 1;
+
+ byte *srcPos = source->getVidMem() + (top * source->getWidth()) + left;
+ byte *destPos = dest->getVidMem() + (y * dest->getWidth()) + x;
+
+ while (height--) {
+ if (transp) {
+ for (int16 i = 0; i < width; ++i) {
+ if (srcPos[i])
+ destPos[i] = srcPos[i];
+ }
+ } else
+ for (int16 i = 0; i < width; ++i)
+ destPos[i] = srcPos[i];
+
+ srcPos += source->getWidth();
+ destPos += dest->getWidth();
+ }
}
-void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Video::SurfaceDesc *dest) {
+void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height,
+ int16 x, int16 y, byte transp, SurfaceDesc *dest) {
int destRight = x + width;
int destBottom = y + height;
- byte* dst = dest->vidPtr + x + dest->width * y;
+ byte *dst = dest->getVidMem() + x + dest->getWidth() * y;
int curx = x;
int cury = y;
@@ -130,6 +140,7 @@
uint8 val = *sprBuf++;
unsigned int repeat = val & 7;
val &= 0xF8;
+
if (!(val & 8)) {
repeat <<= 8;
repeat |= *sprBuf++;
@@ -138,20 +149,21 @@
val >>= 4;
for (unsigned int i = 0; i < repeat; ++i) {
- if (curx < dest->width && cury < dest->height)
+ if (curx < dest->getWidth() && cury < dest->getHeight())
if (!transp || val)
*dst = val;
dst++;
curx++;
if (curx == destRight) {
- dst += dest->width + x - curx;
+ dst += dest->getWidth() + x - curx;
curx = x;
cury++;
if (cury == destBottom)
return;
}
}
+
}
}
Modified: scummvm/trunk/engines/gob/driver_vga.h
===================================================================
--- scummvm/trunk/engines/gob/driver_vga.h 2007-03-19 22:38:00 UTC (rev 26251)
+++ scummvm/trunk/engines/gob/driver_vga.h 2007-03-20 14:51:57 UTC (rev 26252)
@@ -20,6 +20,7 @@
* $Id$
*
*/
+
#ifndef GOB_DRIVER_VGA_H
#define GOB_DRIVER_VGA_H
@@ -31,14 +32,21 @@
public:
VGAVideoDriver() {}
virtual ~VGAVideoDriver() {}
- void drawSprite(Video::SurfaceDesc *source, Video::SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
- void fillRect(Video::SurfaceDesc *dest, int16 left, int16 top, int16 right, int16 bottom, byte color);
- void putPixel(int16 x, int16 y, byte color, Video::SurfaceDesc *dest);
- void drawLetter(unsigned char item, int16 x, int16 y, Video::FontDesc *fontDesc, byte color1, byte color2, byte transp, Video::SurfaceDesc *dest);
- void drawLine(Video::SurfaceDesc *dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color);
- void drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Video::SurfaceDesc *dest);
+
+ void putPixel(int16 x, int16 y, byte color, SurfaceDesc *dest);
+ void drawLine(SurfaceDesc *dest, int16 x0, int16 y0,
+ int16 x1, int16 y1, byte color);
+ void fillRect(SurfaceDesc *dest, int16 left, int16 top,
+ int16 right, int16 bottom, byte color);
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list