From cc43cc88a37a06fc73a0a0423ce8b692d3c3b1b1 Mon Sep 17 00:00:00 2001 From: Alex Bevilacqua Date: Fri, 4 Dec 2009 03:14:07 +0000 Subject: [PATCH] ASYLUM: Major overhaul of data casting. Converted all uint32 member variables and fields to int32 (and uint16 to int16) and update the associated reads. There may be regressions as a result, but so far everything seems to be working as expected. Also combed through the source and silenced 99% of the warnings that GCC was generating. git-svn-id: http://asylumengine.googlecode.com/svn/trunk@404 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c --- engines/asylum/actionlist.cpp | 30 +-- engines/asylum/actionlist.h | 266 +++++++++---------- engines/asylum/actor.cpp | 68 ++--- engines/asylum/actor.h | 122 ++++----- engines/asylum/asylum.cpp | 4 +- engines/asylum/asylum.h | 4 +- engines/asylum/barrier.cpp | 14 +- engines/asylum/barrier.h | 58 ++--- engines/asylum/blowuppuzzle.cpp | 12 +- engines/asylum/blowuppuzzle.h | 8 +- engines/asylum/console.cpp | 20 +- engines/asylum/console.h | 12 +- engines/asylum/cursor.cpp | 10 +- engines/asylum/cursor.h | 20 +- engines/asylum/encounters.cpp | 30 +-- engines/asylum/encounters.h | 34 +-- engines/asylum/graphics.cpp | 28 +- engines/asylum/graphics.h | 28 +- engines/asylum/menu.cpp | 28 +- engines/asylum/menu.h | 8 +- engines/asylum/polygons.cpp | 32 +-- engines/asylum/polygons.h | 8 +- engines/asylum/respack.cpp | 2 +- engines/asylum/respack.h | 2 +- engines/asylum/scene.cpp | 88 +++---- engines/asylum/scene.h | 14 +- engines/asylum/screen.cpp | 44 ++-- engines/asylum/screen.h | 32 +-- engines/asylum/sound.cpp | 54 ++-- engines/asylum/sound.h | 74 +++--- engines/asylum/speech.cpp | 14 +- engines/asylum/speech.h | 12 +- engines/asylum/text.cpp | 36 +-- engines/asylum/text.h | 34 +-- engines/asylum/video.cpp | 40 +-- engines/asylum/video.h | 8 +- engines/asylum/worldstats.cpp | 436 ++++++++++++++++---------------- engines/asylum/worldstats.h | 178 ++++++------- 38 files changed, 955 insertions(+), 957 deletions(-) diff --git a/engines/asylum/actionlist.cpp b/engines/asylum/actionlist.cpp index d6540272a73..bcee2512422 100644 --- a/engines/asylum/actionlist.cpp +++ b/engines/asylum/actionlist.cpp @@ -336,7 +336,7 @@ int ActionList::process() { ScriptEntry *currentCommand = &_currentScript->commands[currentLine]; - uint32 opcode = currentCommand->opcode; + int32 opcode = currentCommand->opcode; debugC(kDebugLevelScripts, "[0x%02d] %s(%d, %d, %d, %d, %d, %d, %d, %d, %d)", @@ -397,19 +397,19 @@ int ActionList::process() { } void ActionList::load(Common::SeekableReadStream *stream) { - size = stream->readUint32LE(); - numEntries = stream->readUint32LE(); + size = stream->readSint32LE(); + numEntries = stream->readSint32LE(); - for (uint32 a = 0; a < numEntries; a++) { + for (int32 a = 0; a < numEntries; a++) { Script action; memset(&action, 0, sizeof(Script)); - for (uint32 c = 0; c < MAX_ACTION_COMMANDS; c++) { + for (int32 c = 0; c < MAX_ACTION_COMMANDS; c++) { ScriptEntry command; memset(&command, 0, sizeof(ScriptEntry)); - command.numLines = stream->readUint32LE(); - command.opcode = stream->readUint32LE(); + command.numLines = stream->readSint32LE(); + command.opcode = stream->readSint32LE(); command.param1 = stream->readSint32LE(); command.param2 = stream->readSint32LE(); command.param3 = stream->readSint32LE(); @@ -423,9 +423,9 @@ void ActionList::load(Common::SeekableReadStream *stream) { action.commands[c] = command; } - action.field_1BAC = stream->readUint32LE(); - action.field_1BB0 = stream->readUint32LE(); - action.counter = stream->readUint32LE(); + action.field_1BAC = stream->readSint32LE(); + action.field_1BB0 = stream->readSint32LE(); + action.counter = stream->readSint32LE(); entries.push_back(action); } @@ -674,8 +674,8 @@ int kEnableActor(Script *script, ScriptEntry *cmd, Scene *scn) { int kEnableBarriers(Script *script, ScriptEntry *cmd, Scene *scn) { int barIdx = scn->worldstats()->getBarrierIndexById(cmd->param1); - uint32 sndIdx = cmd->param3; - uint32 v59 = cmd->param2; + int32 sndIdx = cmd->param3; + int32 v59 = cmd->param2; if (!script->counter && scn->getSceneIndex() != 13 && sndIdx != 0) { // FIXME: I really don't understand what (sndIdx != 0) & 5 is supposed to be doing here, @@ -957,7 +957,7 @@ int kWaitUntilFramePlayed(Script *script, ScriptEntry *cmd, Scene *scn) { Barrier *barrier = scn->worldstats()->getBarrierById(cmd->param1); if (barrier) { - uint32 frameNum = cmd->param2; + int32 frameNum = cmd->param2; if (cmd->param2 == -1) frameNum = barrier->frameCount - 1; @@ -997,11 +997,11 @@ int k_unk40_SOUND(Script *script, ScriptEntry *cmd, Scene *scn) { int kPlaySpeech(Script *script, ScriptEntry *cmd, Scene *scn) { //TODO - Add support for other param options - uint32 sndIdx = cmd->param1; + int32 sndIdx = cmd->param1; if ((int)sndIdx >= 0) { if (cmd->param4 != 2) { - uint32 resIdx = scn->speech()->play(sndIdx); + int32 resIdx = scn->speech()->play(sndIdx); cmd->param5 = resIdx; if (cmd->param2) { diff --git a/engines/asylum/actionlist.h b/engines/asylum/actionlist.h index bb1f9fde4eb..f0029beda3d 100644 --- a/engines/asylum/actionlist.h +++ b/engines/asylum/actionlist.h @@ -39,41 +39,41 @@ namespace Asylum { class Scene; typedef struct ScriptEntry { - uint32 numLines; // Only set on the first line of each script - uint32 opcode; - int param1; - int param2; - int param3; - int param4; - int param5; - int param6; - int param7; - int param8; - int param9; + int32 numLines; // Only set on the first line of each script + int32 opcode; + int32 param1; + int32 param2; + int32 param3; + int32 param4; + int32 param5; + int32 param6; + int32 param7; + int32 param8; + int32 param9; } ScriptEntry; typedef struct Script { ScriptEntry commands[MAX_ACTION_COMMANDS]; - uint32 field_1BAC; - uint32 field_1BB0; - uint32 counter; + int32 field_1BAC; + int32 field_1BB0; + int32 counter; } Script; typedef struct ScriptQueueEntry { - int actionListIndex; - //int actionListItemIndex; - int actorIndex; - //int field_C; - //int field_10; + int32 actionListIndex; + //int32 actionListItemIndex; + int32 actorIndex; + //int32 field_C; + //int32 field_10; } ScriptQueueEntry; /* typedef struct ScriptQueue { ScriptQueueEntry entries[10]; - int count; - int field_CC; + int32 count; + int32 field_CC; } ScriptQueue; */ @@ -83,8 +83,8 @@ public: ActionList(Common::SeekableReadStream *stream, Scene *scene); virtual ~ActionList(); - uint32 size; - uint32 numEntries; + int32 size; + int32 numEntries; Common::Array