[Scummvm-cvs-logs] SF.net SVN: scummvm: [31572] scummvm/trunk/engines/kyra
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sat Apr 19 16:31:10 CEST 2008
Revision: 31572
http://scummvm.svn.sourceforge.net/scummvm/?rev=31572&view=rev
Author: lordhoto
Date: 2008-04-19 07:31:10 -0700 (Sat, 19 Apr 2008)
Log Message:
-----------
- some minor renaming in TIM code
- added exists function to Resource
- started to add checks via exists to assure that important files are present
Modified Paths:
--------------
scummvm/trunk/engines/kyra/resource.cpp
scummvm/trunk/engines/kyra/resource.h
scummvm/trunk/engines/kyra/scene_v1.cpp
scummvm/trunk/engines/kyra/scene_v2.cpp
scummvm/trunk/engines/kyra/scene_v3.cpp
scummvm/trunk/engines/kyra/script_tim.cpp
scummvm/trunk/engines/kyra/script_tim.h
scummvm/trunk/engines/kyra/sprites.cpp
Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/resource.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -277,13 +277,29 @@
return buffer;
}
+bool Resource::exists(const char *file, bool errorOutOnFail) {
+ if (Common::File::exists(file))
+ return true;
+ else if (isAccessable(file))
+ return true;
+ else if (errorOutOnFail)
+ error("File '%s' can't be found", file);
+ return false;
+}
+
uint32 Resource::getFileSize(const char *file) {
- if (!isAccessable(file))
- return 0;
+ if (Common::File::exists(file)) {
+ Common::File f;
+ if (f.open(file))
+ return f.size();
+ } else {
+ if (!isAccessable(file))
+ return 0;
- ResFileMap::const_iterator iter = _map.find(file);
- if (iter != _map.end())
- return iter->_value.size;
+ ResFileMap::const_iterator iter = _map.find(file);
+ if (iter != _map.end())
+ return iter->_value.size;
+ }
return 0;
}
@@ -299,18 +315,22 @@
}
Common::SeekableReadStream *Resource::getFileStream(const Common::String &file) {
- if (!isAccessable(file))
- return 0;
+ if (Common::File::exists(file)) {
+ Common::File *stream = new Common::File();
+ if (!stream->open(file)) {
+ delete stream;
+ stream = 0;
+ error("Couldn't open file '%s'", file.c_str());
+ }
+ return stream;
+ } else {
+ if (!isAccessable(file))
+ return 0;
- ResFileMap::const_iterator iter = _map.find(file);
- if (iter == _map.end())
- return 0;
+ ResFileMap::const_iterator iter = _map.find(file);
+ if (iter == _map.end())
+ return 0;
- Common::File *stream = new Common::File();
- if (stream->open(file)) {
- return stream;
- } else {
- delete stream;
if (!iter->_value.parent.empty()) {
Common::SeekableReadStream *parent = getFileStream(iter->_value.parent);
assert(parent);
@@ -321,8 +341,7 @@
return loader->loadFileFromArchive(file, parent, iter->_value);
} else {
- warning("Couldn't open file '%s'", file.c_str());
- return 0;
+ error("Couldn't open file '%s'", file.c_str());
}
}
Modified: scummvm/trunk/engines/kyra/resource.h
===================================================================
--- scummvm/trunk/engines/kyra/resource.h 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/resource.h 2008-04-19 14:31:10 UTC (rev 31572)
@@ -102,6 +102,7 @@
// This unloads *all* pakfiles, even kyra.dat and protected ones
void unloadAllPakFiles();
+ bool exists(const char *file, bool errorOutOnFail=false);
uint32 getFileSize(const char *file);
uint8* fileData(const char *file, uint32 *size);
Common::SeekableReadStream *getFileStream(const Common::String &file);
Modified: scummvm/trunk/engines/kyra/scene_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v1.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/scene_v1.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -400,6 +400,7 @@
strcpy(fileNameBuffer, _roomFilenameTable[tableId]);
strcat(fileNameBuffer, ".MSC");
_screen->fillRect(0, 0, 319, 199, 0, 5);
+ _res->exists(fileNameBuffer, true);
_screen->loadBitmap(fileNameBuffer, 3, 5, 0);
}
@@ -412,6 +413,7 @@
strcpy(fileNameBuffer, _roomFilenameTable[tableId]);
strcat(fileNameBuffer, ".CPS");
_screen->clearPage(3);
+ _res->exists(fileNameBuffer, true);
// FIXME: check this hack for amiga version
_screen->loadBitmap(fileNameBuffer, 3, 3, (_flags.platform == Common::kPlatformAmiga ? _screen->getPalette(0) : 0));
_sprites->loadSceneShapes();
@@ -425,6 +427,7 @@
_scriptInterpreter->initScript(_scriptClick, _scriptClickData);
strcpy(fileNameBuffer, _roomFilenameTable[tableId]);
strcat(fileNameBuffer, ".EMC");
+ _res->exists(fileNameBuffer, true);
_scriptInterpreter->unloadScript(_scriptClickData);
_scriptInterpreter->loadScript(fileNameBuffer, _scriptClickData, &_opcodes);
_scriptInterpreter->startScript(_scriptClick, 0);
Modified: scummvm/trunk/engines/kyra/scene_v2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v2.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/scene_v2.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -452,7 +452,7 @@
strcat(filename, ".");
strcat(filename, _scriptLangExt[(_flags.platform == Common::kPlatformPC && !_flags.isTalkie) ? 0 : _lang]);
- assert(_res->getFileSize(filename));
+ _res->exists(filename, true);
_scriptInterpreter->loadScript(filename, &_sceneScriptData, &_opcodes);
runSceneScript7();
Modified: scummvm/trunk/engines/kyra/scene_v3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_v3.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/scene_v3.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -347,6 +347,7 @@
strcpy(filename, _sceneList[_mainCharacter.sceneId].filename1);
strcat(filename, ".MSC");
+ _res->exists(filename, true);
Common::SeekableReadStream *stream = _res->getFileStream(filename);
assert(stream);
int16 minY = 0, height = 0;
@@ -381,6 +382,7 @@
strcpy(filename, scene.filename1);
strcat(filename, ".DAT");
+ _res->exists(filename, true);
Common::SeekableReadStream *stream = _res->getFileStream(filename);
assert(stream);
stream->seek(2, SEEK_CUR);
@@ -436,6 +438,7 @@
strcpy(filename, scene.filename2);
strcat(filename, ".EMC");
musicUpdate(0);
+ _res->exists(filename, true);
_scriptInterpreter->loadScript(filename, &_sceneScriptData, &_opcodes);
strcpy(filename, scene.filename1);
Modified: scummvm/trunk/engines/kyra/script_tim.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_tim.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/script_tim.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -25,6 +25,7 @@
#include "kyra/script_tim.h"
#include "kyra/script.h"
+#include "kyra/resource.h"
#include "common/endian.h"
@@ -35,7 +36,7 @@
#define COMMAND_UNIMPL() { 0, 0 }
static CommandEntry commandProcs[] = {
// 0x00
- COMMAND(cmd_initFunc0Now),
+ COMMAND(cmd_initFunc0),
COMMAND(cmd_stopCurFunc),
COMMAND_UNIMPL(),
COMMAND_UNIMPL(),
@@ -63,7 +64,7 @@
COMMAND_UNIMPL(),
COMMAND_UNIMPL(),
COMMAND_UNIMPL(),
- COMMAND(cmd_resetAllNextTime),
+ COMMAND(cmd_resetAllRuntimes),
// 0x18
COMMAND(cmd_return<1>),
COMMAND(cmd_execOpcode),
@@ -80,20 +81,19 @@
}
TIM *TIMInterpreter::load(const char *filename, const Common::Array<const TIMOpcode*> *opcodes) {
+ if (!_vm->resource()->exists(filename))
+ return 0;
+
ScriptFileParser file(filename, _vm->resource());
if (!file)
error("Couldn't open TIM file '%s'", filename);
uint32 formBlockSize = file.getFORMBlockSize();
- if (formBlockSize == 0xFFFFFFFF) {
- warning("No FORM chunk found in TIM file '%s'", filename);
- return 0;
- }
+ if (formBlockSize == 0xFFFFFFFF)
+ error("No FORM chunk found in TIM file '%s'", filename);
- if (formBlockSize < 20) {
- warning("TIM file '%s' FORM chunk size smaller than 20", filename);
- return 0;
- }
+ if (formBlockSize < 20)
+ error("TIM file '%s' FORM chunk size smaller than 20", filename);
TIM *tim = new TIM;
assert(tim);
@@ -149,7 +149,7 @@
TIM::Function &cur = _currentTim->func[_currentFunc];
if (_currentTim->procFunc != -1)
- execCommand(28, &_currentTim->unkFlag);
+ execCommand(28, &_currentTim->procParam);
bool running = true;
while (cur.ip && cur.nextTime <= _system->getMillis() && running) {
@@ -199,7 +199,7 @@
return (this->*_commands[cmd].proc)(param);
}
-int TIMInterpreter::cmd_initFunc0Now(const uint16 *param) {
+int TIMInterpreter::cmd_initFunc0(const uint16 *param) {
_currentTim->func[0].ip = _currentTim->func[0].avtl;
_currentTim->func[0].lastTime = _system->getMillis();
return 1;
@@ -230,7 +230,7 @@
return 1;
}
-int TIMInterpreter::cmd_resetAllNextTime(const uint16 *param) {
+int TIMInterpreter::cmd_resetAllRuntimes(const uint16 *param) {
for (int i = 0; i < 10; ++i) {
if (_currentTim->func[i].ip)
_currentTim->func[i].nextTime = _system->getMillis();
@@ -246,7 +246,7 @@
uint16 opcode = *param++;
if (opcode > _currentTim->opcodes->size()) {
- warning("calling unimplemented opcode(0x%.02X/%d)", opcode, opcode);
+ warning("Calling unimplemented TIM opcode(0x%.02X/%d)", opcode, opcode);
return 0;
}
Modified: scummvm/trunk/engines/kyra/script_tim.h
===================================================================
--- scummvm/trunk/engines/kyra/script_tim.h 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/script_tim.h 2008-04-19 14:31:10 UTC (rev 31572)
@@ -35,7 +35,7 @@
struct TIM {
int16 procFunc;
- uint16 unkFlag;
+ uint16 procParam;
struct Function {
const uint16 *ip;
@@ -86,11 +86,11 @@
const CommandEntry *_commands;
int _commandsSize;
- int cmd_initFunc0Now(const uint16 *param);
+ int cmd_initFunc0(const uint16 *param);
int cmd_stopCurFunc(const uint16 *param);
int cmd_initFunc(const uint16 *param);
int cmd_stopFunc(const uint16 *param);
- int cmd_resetAllNextTime(const uint16 *param);
+ int cmd_resetAllRuntimes(const uint16 *param);
int cmd_execOpcode(const uint16 *param);
int cmd_initFuncNow(const uint16 *param);
int cmd_stopFuncNow(const uint16 *param);
Modified: scummvm/trunk/engines/kyra/sprites.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites.cpp 2008-04-19 14:00:14 UTC (rev 31571)
+++ scummvm/trunk/engines/kyra/sprites.cpp 2008-04-19 14:31:10 UTC (rev 31572)
@@ -408,6 +408,7 @@
delete[] _dat;
_spriteDefStart = 0;
+ _res->exists(filename, true);
_dat = _res->fileData(filename, &fileSize);
memset(_anims, 0, sizeof(_anims));
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