aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorMatthew Hoops2011-12-12 15:25:28 -0500
committerMatthew Hoops2011-12-12 15:25:28 -0500
commit00279659b22cbd5db739d5351e83a9fc2a2ae408 (patch)
tree497f06f46820043cbdf1725652b8f0073223e24a /engines/agi
parentd932df79bed5aac97e17c0920a5e75cb5ce733ee (diff)
parentd1628feb761acc9f4607f64de3eb620fea53bcc9 (diff)
downloadscummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.gz
scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.bz2
scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.zip
Merge remote branch 'upstream/master' into pegasus
Conflicts: video/qt_decoder.cpp
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/cycle.cpp7
-rw-r--r--engines/agi/detection.cpp2
-rw-r--r--engines/agi/detection_tables.h20
-rw-r--r--engines/agi/graphics.cpp4
-rw-r--r--engines/agi/op_cmd.cpp6
-rw-r--r--engines/agi/opcodes.cpp4
-rw-r--r--engines/agi/saveload.cpp4
-rw-r--r--engines/agi/sound_2gs.cpp10
-rw-r--r--engines/agi/sound_2gs.h2
-rw-r--r--engines/agi/text.cpp4
-rw-r--r--engines/agi/words.cpp10
11 files changed, 41 insertions, 32 deletions
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index 9cbab1f3c4..99649fb437 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -200,10 +200,11 @@ int AgiEngine::mainCycle() {
// vars in every interpreter cycle.
//
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true) {
+ //if (getFeatures() & GF_AGIMOUSE) {
_game.vars[28] = _mouse.x / 2;
_game.vars[29] = _mouse.y;
- }
+ //}
+
if (key == KEY_PRIORITY) {
_sprites->eraseBoth();
_debug.priority = !_debug.priority;
@@ -315,7 +316,7 @@ int AgiEngine::playGame() {
_game.lineUserInput = 22;
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true)
+ //if (getFeatures() & GF_AGIMOUSE)
debug(1, "Using AGI Mouse 1.0 protocol");
if (getFeatures() & GF_AGIPAL)
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 21b1831261..982dce8405 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -150,7 +150,7 @@ class AgiMetaEngine : public AdvancedMetaEngine {
public:
AgiMetaEngine() : AdvancedMetaEngine(Agi::gameDescriptions, sizeof(Agi::AGIGameDescription), agiGames) {
_singleid = "agi";
- _guioptions = Common::GUIO_NOSPEECH;
+ _guioptions = GUIO1(GUIO_NOSPEECH);
}
virtual const char *getName() const {
diff --git a/engines/agi/detection_tables.h b/engines/agi/detection_tables.h
index f0cd422ed6..ab0e9a1fe4 100644
--- a/engines/agi/detection_tables.h
+++ b/engines/agi/detection_tables.h
@@ -22,8 +22,6 @@
namespace Agi {
-using Common::GUIO_NONE;
-
#define GAME_LVFPN(id,extra,fname,md5,size,lang,ver,features,gid,platform,interp) { \
{ \
id, \
@@ -32,7 +30,7 @@ using Common::GUIO_NONE;
lang, \
platform, \
ADGF_NO_FLAGS, \
- GUIO_NONE \
+ GUIO0() \
}, \
gid, \
interp, \
@@ -48,7 +46,7 @@ using Common::GUIO_NONE;
lang, \
platform, \
ADGF_USEEXTRAASTITLE, \
- GUIO_NONE \
+ GUIO0() \
}, \
gid, \
interp, \
@@ -132,7 +130,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -153,7 +151,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -174,7 +172,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_BC,
GType_V1,
@@ -254,7 +252,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformMacintosh,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_GOLDRUSH,
GType_V3,
@@ -572,7 +570,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformAmiga,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_SQ2,
GType_V2,
@@ -861,7 +859,7 @@ static const AGIGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_USEEXTRAASTITLE,
- GUIO_NONE
+ GUIO0()
},
GID_FANMADE,
GType_V3,
@@ -889,7 +887,7 @@ static AGIGameDescription g_fallbackDesc = {
Common::UNK_LANG,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GID_FANMADE,
GType_V2,
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp
index 074e5570d5..4bb3877f7d 100644
--- a/engines/agi/graphics.cpp
+++ b/engines/agi/graphics.cpp
@@ -1083,7 +1083,7 @@ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
// Choose the correct screen to read from. If AGI256 or AGI256-2 is used and we're not trying to show the priority information,
// then choose the 256 color screen, otherwise choose the 16 color screen (Which also has the priority information).
- p += _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? FROM_SBUF16_TO_SBUF256_OFFSET : 0;
+ p += ((_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) && !_vm->_debug.priority) ? FROM_SBUF16_TO_SBUF256_OFFSET : 0;
if (_vm->_renderMode == Common::kRenderCGA) {
for (x *= 2; n--; p++, x += 2) {
@@ -1091,7 +1091,7 @@ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = (q >> rShift) & 0x0f0f;
}
} else {
- const uint16 mask = _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? 0xffff : 0x0f0f;
+ const uint16 mask = ((_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) && !_vm->_debug.priority) ? 0xffff : 0x0f0f;
for (x *= 2; n--; p++, x += 2) {
register uint16 q = ((uint16)*p << 8) | *p;
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = (q >> rShift) & mask;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 72f60e2516..41d9cc3ac9 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1622,15 +1622,15 @@ void cmdPrintAtV(AgiGame *state, uint8 *p) {
void cmdPushScript(AgiGame *state, uint8 *p) {
// We run AGIMOUSE always as a side effect
- if (getFeatures() & GF_AGIMOUSE || true) {
+ //if (getFeatures() & GF_AGIMOUSE || true) {
state->vars[27] = state->_vm->_mouse.button;
state->vars[28] = state->_vm->_mouse.x / 2;
state->vars[29] = state->_vm->_mouse.y;
- } else {
+ /*} else {
if (getVersion() >= 0x2915) {
debug(0, "push.script");
}
- }
+ }*/
}
void cmdSetPriBase(AgiGame *state, uint8 *p) {
diff --git a/engines/agi/opcodes.cpp b/engines/agi/opcodes.cpp
index d1baab93e1..29fb860635 100644
--- a/engines/agi/opcodes.cpp
+++ b/engines/agi/opcodes.cpp
@@ -360,7 +360,7 @@ AgiInstruction insV2[] = {
void AgiEngine::setupOpcodes() {
if (getVersion() >= 0x2000) {
- for (int i = 0; i <= ARRAYSIZE(insV2Test); ++i)
+ for (int i = 0; i < ARRAYSIZE(insV2Test); ++i)
_agiCondCommands[i] = insV2Test[i].func;
for (int i = 0; i < ARRAYSIZE(insV2); ++i)
_agiCommands[i] = insV2[i].func;
@@ -368,7 +368,7 @@ void AgiEngine::setupOpcodes() {
logicNamesTest = insV2Test;
logicNamesCmd = insV2;
} else {
- for (int i = 0; i <= ARRAYSIZE(insV1Test); ++i)
+ for (int i = 0; i < ARRAYSIZE(insV1Test); ++i)
_agiCondCommands[i] = insV1Test[i].func;
for (int i = 0; i < ARRAYSIZE(insV1); ++i)
_agiCommands[i] = insV1[i].func;
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 3cebbf50c8..1bcabd507f 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -300,7 +300,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
_game.state = (State)in->readByte();
in->read(loadId, 8);
- if (strcmp(loadId, _game.id) && checkId) {
+ if (strcmp(loadId, _game.id) != 0 && checkId) {
delete in;
warning("This save seems to be from a different AGI game (save from %s, running %s), not loaded", loadId, _game.id);
return errBadFileOpen;
@@ -331,7 +331,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
warning("Since your game was only detected via the fallback detector, there is no possibility to assure the save is compatible with your game version");
debug(0, "The game used for saving is \"%s\".", md5);
- } else if (strcmp(md5, getGameMD5())) {
+ } else if (strcmp(md5, getGameMD5()) != 0) {
warning("Game was saved with different gamedata - you may encounter problems");
debug(0, "Your game is \"%s\" and save is \"%s\".", getGameMD5(), md5);
diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index c5cfa125d6..b15950f31d 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -719,7 +719,10 @@ bool SoundGen2GS::loadInstrumentHeaders(Common::String &exePath, const IIgsExeIn
}
// Read the whole executable file into memory
- Common::SharedPtr<Common::SeekableReadStream> data(file.readStream(file.size()));
+ // CHECKME: Why do we read the file into memory first? It does not seem to be
+ // kept outside of this function. Is the processing of the data too slow
+ // otherwise?
+ Common::ScopedPtr<Common::SeekableReadStream> data(file.readStream(file.size()));
file.close();
// Check that we got enough data to be able to parse the instruments
@@ -769,8 +772,11 @@ bool SoundGen2GS::loadWaveFile(Common::String &wavePath, const IIgsExeInfo &exeI
Common::File file;
// Open the wave file and read it into memory
+ // CHECKME: Why do we read the file into memory first? It does not seem to be
+ // kept outside of this function. Is the processing of the data too slow
+ // otherwise?
file.open(wavePath);
- Common::SharedPtr<Common::SeekableReadStream> uint8Wave(file.readStream(file.size()));
+ Common::ScopedPtr<Common::SeekableReadStream> uint8Wave(file.readStream(file.size()));
file.close();
// Check that we got the whole wave file
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 89ffc3fe11..404f4a47a1 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -247,7 +247,7 @@ private:
void midiNoteOff(int channel, int note, int velocity);
void midiNoteOn(int channel, int note, int velocity);
double midiKeyToFreq(int key, double finetune);
- IIgsInstrumentHeader* getInstrument(uint8 program) { return &_instruments[_progToInst->map(program)]; };
+ IIgsInstrumentHeader* getInstrument(uint8 program) { return &_instruments[_progToInst->map(program)]; }
IIgsGenerator* allocateGenerator() { IIgsGenerator* g = &_generators[_nextGen++]; _nextGen %= 16; return g; }
bool _disableMidi; ///< Disable MIDI if loading instruments fail
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 502db4bdba..3247862e32 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -224,7 +224,8 @@ void AgiEngine::printTextConsole(const char *msg, int x, int y, int len, int fg,
* Based on GBAGI implementation with permission from the author
*/
char *AgiEngine::wordWrapString(const char *s, int *len) {
- char *outStr, *msgBuf, maxWidth = *len;
+ char *outStr, *msgBuf;
+ int maxWidth = *len;
const char *pWord;
int lnLen, wLen;
@@ -239,7 +240,6 @@ char *AgiEngine::wordWrapString(const char *s, int *len) {
while (*s) {
pWord = s;
- wLen = 0;
while (*s != '\0' && *s != ' ' && *s != '\n' && *s != '\r')
s++;
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index ec6928f8ed..1001c66b20 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -120,6 +120,7 @@ void AgiEngine::unloadWords() {
*/
int AgiEngine::findWord(const char *word, int *flen) {
int c;
+ int result = -1;
debugC(2, kDebugLevelScripts, "find_word(%s)", word);
@@ -130,15 +131,18 @@ int AgiEngine::findWord(const char *word, int *flen) {
*flen = 0;
Common::Array<AgiWord*> &a = _game.words[c];
+
for (int i = 0; i < (int)a.size(); i++) {
int wlen = strlen(a[i]->word);
- if (!strncmp(a[i]->word, word, wlen) && (word[wlen] == 0 || word[wlen] == 0x20)) {
+ // Keep looking till we find the word itself, or the whole phrase.
+ // Try to find the best match (i.e. the longest matching phrase).
+ if (!strncmp(a[i]->word, word, wlen) && (word[wlen] == 0 || word[wlen] == 0x20) && wlen >= *flen) {
*flen = wlen;
- return a[i]->id;
+ result = a[i]->id;
}
}
- return -1;
+ return result;
}
void AgiEngine::dictionaryWords(char *msg) {