aboutsummaryrefslogtreecommitdiff
path: root/engines/agos
diff options
context:
space:
mode:
authorDavid Corrales2007-08-05 19:34:20 +0000
committerDavid Corrales2007-08-05 19:34:20 +0000
commit6856535010bd2fa4449bcfde1c88dc06cd46e26f (patch)
treeb81a2234c2beff0312c93e039d6cafda4babeca6 /engines/agos
parent1400d28bfb37fc94f3c44dec0a4d0cef65fb8fb7 (diff)
parentec1803f838d5efc7decf75c05a1fb4a9633751e5 (diff)
downloadscummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.gz
scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.bz2
scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.zip
Merged fsnode with trunk: r27971:28460
svn-id: r28462
Diffstat (limited to 'engines/agos')
-rw-r--r--engines/agos/agos.cpp18
-rw-r--r--engines/agos/agos.h5
-rw-r--r--engines/agos/detection_tables.h26
-rw-r--r--engines/agos/input.cpp2
-rw-r--r--engines/agos/items.cpp28
-rw-r--r--engines/agos/res_snd.cpp55
-rw-r--r--engines/agos/saveload.cpp10
-rw-r--r--engines/agos/sound.cpp12
-rw-r--r--engines/agos/zones.cpp27
9 files changed, 144 insertions, 39 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index ae7f692c3f..76e4378982 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -148,10 +148,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
_itemArraySize = 0;
_itemArrayInited = 0;
- _itemHeapPtr = 0;
- _itemHeapCurPos = 0;
- _itemHeapSize = 0;
-
_iconFilePtr = 0;
_codePtr = 0;
@@ -824,7 +820,7 @@ void AGOSEngine_Waxworks::setupGame() {
_numTextBoxes = 10;
_numVars = 255;
- _numMusic = 9;
+ _numMusic = 26;
AGOSEngine::setupGame();
}
@@ -920,7 +916,11 @@ AGOSEngine::~AGOSEngine() {
_midi.close();
- free(_itemHeapPtr - _itemHeapCurPos);
+ for (uint i = 0; i < _itemHeap.size(); i++) {
+ delete [] _itemHeap[i];
+ }
+ _itemHeap.clear();
+
free(_tablesHeapPtr - _tablesHeapCurPos);
free(_gameOffsetsPtr);
@@ -1054,7 +1054,11 @@ void AGOSEngine::shutdown() {
_midi.close();
- free(_itemHeapPtr - _itemHeapCurPos);
+ for (uint i = 0; i < _itemHeap.size(); i++) {
+ delete [] _itemHeap[i];
+ }
+ _itemHeap.clear();
+
free(_tablesHeapPtr - _tablesHeapCurPos);
free(_gameOffsetsPtr);
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index d233d0bfeb..bf64a3bf84 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -28,6 +28,7 @@
#include "engines/engine.h"
+#include "common/array.h"
#include "common/keyboard.h"
#include "common/rect.h"
#include "common/util.h"
@@ -231,9 +232,7 @@ protected:
uint _itemArraySize;
uint _itemArrayInited;
- byte *_itemHeapPtr;
- uint _itemHeapCurPos;
- uint _itemHeapSize;
+ Common::Array<byte *> _itemHeap;
byte *_iconFilePtr;
diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h
index 5efcaa3b86..988de6729b 100644
--- a/engines/agos/detection_tables.h
+++ b/engines/agos/detection_tables.h
@@ -542,6 +542,32 @@ static const AGOSGameDescription gameDescriptions[] = {
GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR
},
+ // Waxworks - German Amiga Floppy
+ {
+ {
+ "waxworks",
+ "Floppy",
+
+ {
+ { "gameamiga", GAME_BASEFILE, "2938a17103de603c4c6f05e6a433b365", -1},
+ { "icon.pkd", GAME_ICONFILE, "4822a91c18b1b2005ac17fc617f7dcbe", -1},
+ { "menus.dat", GAME_MENUFILE, "3409eeb8ca8b46fc04da99de67573f5e", -1},
+ { "start", GAME_RESTFILE, "b575b336e741dde1725edd4079d5ab67", -1},
+ { "stripped.txt", GAME_STRFILE, "6faaebff2786216900061eeb978f10af", -1},
+ { "tbllist", GAME_TBLFILE, "95c44bfc380770a6b6dd0dfcc69e80a0", -1},
+ { "xtbllist", GAME_XTBLFILE, "6c7b3db345d46349a5226f695c03e20f", -1},
+ { NULL, 0, NULL, 0}
+ },
+ Common::DE_DEU,
+ Common::kPlatformAmiga,
+ Common::ADGF_NO_FLAGS
+ },
+
+ GType_WW,
+ GID_WAXWORKS,
+ GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR
+ },
+
// Waxworks - English DOS Floppy Demo
{
{
diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp
index 0f1c234b79..a86cad9b94 100644
--- a/engines/agos/input.cpp
+++ b/engines/agos/input.cpp
@@ -196,7 +196,7 @@ void AGOSEngine::waitForInput() {
for (;;) {
if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) &&
- _keyPressed.keycode == Common::KEYCODE_HASH)
+ _keyPressed.keycode == Common::KEYCODE_F10)
displayBoxStars();
if (processSpecialKeys()) {
if ((getGameType() == GType_PP && getGameId() != GID_DIMP) ||
diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp
index 9a46b6e8ac..b2e722d681 100644
--- a/engines/agos/items.cpp
+++ b/engines/agos/items.cpp
@@ -42,24 +42,15 @@ Child *AGOSEngine::allocateChildBlock(Item *i, uint type, uint size) {
}
byte *AGOSEngine::allocateItem(uint size) {
- byte *org = _itemHeapPtr;
- size = (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
+ byte *item = new byte[size];
- _itemHeapPtr += size;
- _itemHeapCurPos += size;
-
- if (_itemHeapCurPos > _itemHeapSize)
- error("allocateItem: Itemheap overflow");
-
- return org;
+ memset(item, 0, size);
+ _itemHeap.push_back(item);
+ return item;
}
void AGOSEngine::allocItemHeap() {
- _itemHeapSize = _itemMemSize;
- _itemHeapCurPos = 0;
- _itemHeapPtr = (byte *)calloc(_itemMemSize, 1);
- if (!_itemHeapPtr)
- error("Out Of Memory - Items");
+ _itemHeap.clear();
}
bool AGOSEngine::hasIcon(Item *item) {
@@ -391,8 +382,13 @@ int AGOSEngine::wordMatch(Item *item, int16 a, int16 n) {
}
Item *AGOSEngine::derefItem(uint item) {
- if (item >= _itemArraySize)
- error("derefItem: invalid item %d", item);
+ // Occurs when loading item store from restart state in
+ // Elvira 2 (Amiga/AtariST) and Waxworks (Amiga).
+ if (item >= _itemArraySize) {
+ debug(0, "derefItem: invalid item %d", item);
+ return NULL;
+ }
+
return _itemArrayPtr[item];
}
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index 779ed67e58..beea0de473 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -139,9 +139,56 @@ void AGOSEngine::loadMusic(uint16 music) {
_nextMusicToPlay = -1;
}
+struct ModuleOffs {
+ uint8 tune;
+ uint8 fileNum;
+ uint32 offs;
+};
+
+static const ModuleOffs amigaWaxworksOffs[20] = {
+ // Pyramid
+ {2, 2, 0, },
+ {3, 2, 50980},
+ {4, 2, 56160},
+ {5, 2, 62364},
+ {6, 2, 73688},
+
+ // Zombie
+ {8, 8, 0},
+ {11, 8, 51156},
+ {12, 8, 56336},
+ {13, 8, 65612},
+ {14, 8, 68744},
+
+ // Mine
+ {9, 9, 0},
+ {15, 9, 47244},
+ {16, 9, 52424},
+ {17, 9, 59652},
+ {18, 9, 62784},
+
+ // Jack
+ {10, 10, 0},
+ {19, 10, 42054},
+ {20, 10, 47234},
+ {21, 10, 49342},
+ {22, 10, 51450},
+};
+
void AGOSEngine::playModule(uint16 music) {
char filename[15];
File f;
+ uint32 offs = 0;
+
+ if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW) {
+ // Multiple tunes are stored in music files for main locations
+ for (uint i = 0; i < 20; i++) {
+ if (amigaWaxworksOffs[i].tune == music) {
+ music = amigaWaxworksOffs[i].fileNum;
+ offs = amigaWaxworksOffs[i].offs;
+ }
+ }
+ }
if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO)
sprintf(filename, "elvira2");
@@ -159,21 +206,21 @@ void AGOSEngine::playModule(uint16 music) {
if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) &&
getFeatures() & GF_CRUNCHED) {
- uint srcSize = f.size();
+ uint32 srcSize = f.size();
byte *srcBuf = (byte *)malloc(srcSize);
if (f.read(srcBuf, srcSize) != srcSize)
error("playModule: Read failed");
- uint dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
+ uint32 dstSize = READ_BE_UINT32(srcBuf + srcSize - 4);
byte *dstBuf = (byte *)malloc(dstSize);
decrunchFile(srcBuf, dstBuf, srcSize);
free(srcBuf);
Common::MemoryReadStream stream(dstBuf, dstSize);
- audioStream = Audio::makeProtrackerStream(&stream, _mixer->getOutputRate());
+ audioStream = Audio::makeProtrackerStream(&stream, offs);
free(dstBuf);
} else {
- audioStream = Audio::makeProtrackerStream(&f, _mixer->getOutputRate());
+ audioStream = Audio::makeProtrackerStream(&f);
}
_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_modHandle, audioStream);
diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp
index 61c640d7c5..f7c2d4846f 100644
--- a/engines/agos/saveload.cpp
+++ b/engines/agos/saveload.cpp
@@ -1190,7 +1190,7 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) {
addTimeEvent(timeout, subroutine_id);
}
- if (getGameType() == GType_WW) {
+ if (getGameType() == GType_WW && getPlatform() == Common::kPlatformPC) {
// TODO Load room state data
for (uint s = 0; s <= _numRoomStates; s++) {
f->readUint16BE();
@@ -1202,7 +1202,8 @@ bool AGOSEngine_Elvira2::loadGame(const char *filename, bool restartMode) {
for (num = _itemArrayInited - 1; num; num--) {
Item *item = _itemArrayPtr[item_index++], *parent_item;
- if (getGameType() == GType_ELVIRA2) {
+ if ((getGameType() == GType_WW && getPlatform() == Common::kPlatformAmiga) ||
+ getGameType() == GType_ELVIRA2) {
parent_item = derefItem(readItemID(f));
setItemParent(item, parent_item);
} else {
@@ -1342,7 +1343,7 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) {
f->writeUint16BE(te->subroutine_id);
}
- if (getGameType() == GType_WW) {
+ if (getGameType() == GType_WW && getPlatform() == Common::kPlatformPC) {
// TODO Save room state data
for (uint s = 0; s <= _numRoomStates; s++) {
f->writeUint16BE(0);
@@ -1354,7 +1355,8 @@ bool AGOSEngine_Elvira2::saveGame(uint slot, const char *caption) {
for (num_item = _itemArrayInited - 1; num_item; num_item--) {
Item *item = _itemArrayPtr[item_index++];
- if (getGameType() == GType_ELVIRA2) {
+ if ((getGameType() == GType_WW && getPlatform() == Common::kPlatformAmiga) ||
+ getGameType() == GType_ELVIRA2) {
writeItemID(f, item->parent);
} else {
f->writeUint16BE(item->parent);
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp
index 7165e3cbff..a735f54c29 100644
--- a/engines/agos/sound.cpp
+++ b/engines/agos/sound.cpp
@@ -292,7 +292,9 @@ Audio::AudioStream *MP3Sound::makeAudioStream(uint sound) {
uint32 size = _offsets[sound + i] - _offsets[sound];
- return Audio::makeMP3Stream(_file, size);
+ Common::MemoryReadStream *tmp = _file->readStream(size);
+ assert(tmp);
+ return Audio::makeMP3Stream(tmp, true);
}
void MP3Sound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) {
@@ -321,7 +323,9 @@ Audio::AudioStream *VorbisSound::makeAudioStream(uint sound) {
uint32 size = _offsets[sound + i] - _offsets[sound];
- return Audio::makeVorbisStream(_file, size);
+ Common::MemoryReadStream *tmp = _file->readStream(size);
+ assert(tmp);
+ return Audio::makeVorbisStream(tmp, true);
}
void VorbisSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) {
@@ -350,7 +354,9 @@ Audio::AudioStream *FlacSound::makeAudioStream(uint sound) {
uint32 size = _offsets[sound + i] - _offsets[sound];
- return Audio::makeFlacStream(_file, size);
+ Common::MemoryReadStream *tmp = _file->readStream(size);
+ assert(tmp);
+ return Audio::makeFlacStream(tmp, true);
}
void FlacSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol) {
diff --git a/engines/agos/zones.cpp b/engines/agos/zones.cpp
index a1de03e66c..d40e1da1de 100644
--- a/engines/agos/zones.cpp
+++ b/engines/agos/zones.cpp
@@ -44,6 +44,25 @@ void AGOSEngine::unfreezeBottom() {
_vgaFrozenBase = _vgaRealBase;
}
+static const uint8 zoneTable[160] = {
+ 0, 0, 2, 2, 2, 2, 0, 2, 2, 2,
+ 3, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+ 3, 3, 3, 1, 3, 0, 0, 0, 1, 0,
+ 2, 0, 3, 0, 3, 3, 0, 1, 1, 0,
+ 1, 2, 2, 2, 0, 2, 2, 2, 0, 2,
+ 1, 2, 2, 2, 0, 2, 2, 2, 2, 2,
+ 2, 2, 2, 1, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 0, 2, 0, 3, 2, 2, 2, 3,
+ 2, 3, 3, 3, 1, 3, 3, 1, 1, 0,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 0, 0, 2, 2, 0,
+ 0, 2, 0, 2, 2, 2, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
+ 2, 0, 2, 0, 0, 2, 2, 0, 2, 2,
+ 2, 2, 2, 2, 2, 0, 0, 0, 0, 0,
+};
+
void AGOSEngine::loadZone(uint16 zoneNum) {
VgaPointersEntry *vpe;
@@ -56,7 +75,13 @@ void AGOSEngine::loadZone(uint16 zoneNum) {
// Loading order is important
// due to resource managment
- loadVGAVideoFile(zoneNum, 2);
+ if (getPlatform() == Common::kPlatformAmiga && getGameType() == GType_WW &&
+ zoneTable[zoneNum] == 3) {
+ uint8 num = (zoneNum >= 85) ? 94 : 18;
+ loadVGAVideoFile(num, 2);
+ } else {
+ loadVGAVideoFile(zoneNum, 2);
+ }
vpe->vgaFile2 = _block;
vpe->vgaFile2End = _blockEnd;