aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.cpp37
-rw-r--r--engines/agi/detection.cpp36
-rw-r--r--engines/agi/predictive.cpp6
-rw-r--r--engines/agi/sound.cpp2
-rw-r--r--engines/agi/sound_2gs.cpp12
-rw-r--r--engines/agi/sound_2gs.h4
-rw-r--r--engines/agi/sound_midi.cpp10
-rw-r--r--engines/agi/sound_pcjr.cpp5
-rw-r--r--engines/agi/sound_pcjr.h4
-rw-r--r--engines/agi/sound_sarien.cpp4
-rw-r--r--engines/agi/text.cpp5
-rw-r--r--engines/agi/wagparser.cpp4
12 files changed, 66 insertions, 63 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 78316588b0..0eefbab04d 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -131,46 +131,65 @@ void AgiEngine::processEvents() {
switch (key = event.kbd.keycode) {
case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP4)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_LEFT;
break;
case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP6)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_RIGHT;
break;
case Common::KEYCODE_UP:
case Common::KEYCODE_KP8:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP8)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_UP;
break;
case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP2)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN;
break;
case Common::KEYCODE_PAGEUP:
case Common::KEYCODE_KP9:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP9)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_UP_RIGHT;
break;
case Common::KEYCODE_PAGEDOWN:
case Common::KEYCODE_KP3:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP3)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN_RIGHT;
break;
case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP7)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_UP_LEFT;
break;
case Common::KEYCODE_END:
case Common::KEYCODE_KP1:
- if (_allowSynthetic || !event.synthetic)
+ if (_predictiveDialogRunning && key == Common::KEYCODE_KP1)
+ key = event.kbd.ascii;
+ else if (_allowSynthetic || !event.synthetic)
key = KEY_DOWN_LEFT;
break;
case Common::KEYCODE_KP5:
- key = KEY_STATIONARY;
+ if (_predictiveDialogRunning)
+ key = event.kbd.ascii;
+ else
+ key = KEY_STATIONARY;
break;
case Common::KEYCODE_PLUS:
key = '+';
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 22d8adf92d..a0736d0cc3 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -129,31 +129,6 @@ static const PlainGameDescriptor agiGames[] = {
#include "agi/detection_tables.h"
-static const ADParams detectionParams = {
- // Pointer to ADGameDescription or its superset structure
- (const byte *)Agi::gameDescriptions,
- // Size of that superset structure
- sizeof(Agi::AGIGameDescription),
- // Number of bytes to compute MD5 sum for
- 5000,
- // List of all engine targets
- agiGames,
- // Structure for autoupgrading obsolete targets
- 0,
- // Name of single gameid (optional)
- "agi",
- // List of files for file-based fallback detection (optional)
- 0,
- // Flags
- 0,
- // Additional GUI options (for every game}
- Common::GUIO_NOSPEECH,
- // Maximum directory depth
- 1,
- // List of directory globs
- 0
-};
-
using namespace Agi;
class AgiMetaEngine : public AdvancedMetaEngine {
@@ -161,7 +136,10 @@ class AgiMetaEngine : public AdvancedMetaEngine {
mutable Common::String _extra;
public:
- AgiMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+ AgiMetaEngine() : AdvancedMetaEngine(Agi::gameDescriptions, sizeof(Agi::AGIGameDescription), agiGames) {
+ _singleid = "agi";
+ _guioptions = Common::GUIO_NOSPEECH;
+ }
virtual const char *getName() const {
return "AGI preAGI + v2 + v3";
@@ -177,7 +155,7 @@ public:
virtual void removeSaveState(const char *target, int slot) const;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
- const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
+ const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const;
};
bool AgiMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -315,7 +293,7 @@ SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int sl
return SaveStateDescriptor();
}
-const ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
+const ADGameDescription *AgiMetaEngine::fallbackDetect(const FileMap &allFilesXXX, const Common::FSList &fslist) const {
typedef Common::HashMap<Common::String, int32> IntMap;
IntMap allFiles;
bool matchedUsingFilenames = false;
@@ -495,7 +473,7 @@ bool AgiBase::canLoadGameStateCurrently() {
bool AgiBase::canSaveGameStateCurrently() {
if (getGameID() == GID_BC) // Technically in Black Cauldron we may save anytime
return true;
-
+
return (!(getGameType() == GType_PreAGI) && getflag(fMenusWork) && !_noSaveLoadAllowed && _game.inputEnabled);
}
diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp
index 80e89f410b..edfe83b1cb 100644
--- a/engines/agi/predictive.cpp
+++ b/engines/agi/predictive.cpp
@@ -190,7 +190,7 @@ bool AgiEngine::predictiveDialog() {
bool needRefresh = true;
- for (;;) {
+ while (!shouldQuit()) {
if (needRefresh) {
for (int i = 0; buttons[i]; i++) {
int color1 = colors[i * 2];
@@ -573,8 +573,10 @@ bool AgiEngine::matchWord() {
hi = line - 1;
else if (cmpVal < 0)
lo = line + 1;
- else
+ else {
hi = line;
+ break;
+ }
}
_currentWord.clear();
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index aa338db0f2..f2d7af32da 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -144,7 +144,7 @@ void SoundMgr::stopSound() {
// not be any harm doing it, so do it anyway.
if (_endflag != -1)
_vm->setflag(_endflag, true);
-
+
_endflag = -1;
}
diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index 3c8a3dfc8d..38e256aa4b 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -167,12 +167,12 @@ uint SoundGen2GS::generateOutput() {
g->seg++;
}
}
-
+
// TODO: Advance vibrato here. The Apple IIGS uses a LFO with
// triangle wave to modulate the frequency of both oscillators.
// In Apple IIGS the vibrato and the envelope are updated at the
// same time, so the vibrato speed depends on ENVELOPE_COEF.
-
+
// Advance oscillators
int s0 = 0;
int s1 = 0;
@@ -202,12 +202,12 @@ uint SoundGen2GS::generateOutput() {
}
}
}
-
+
// Take envelope and MIDI volume information into account.
// Also amplify.
s0 *= vol * g->vel / 127 * 80 / 256;
s1 *= vol * g->vel / 127 * 80 / 256;
-
+
// Select output channel.
if (g->osc[0].chn)
outl += s0;
@@ -375,7 +375,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
IIgsGenerator* g = allocateGenerator();
g->ins = _channels[channel].getInstrument();
const IIgsInstrumentHeader* i = g->ins;
-
+
// Pass information from the MIDI channel to the generator. Take
// velocity into account, although simplistically.
velocity *= 5 / 3;
@@ -385,7 +385,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
g->key = note;
g->vel = velocity * _channels[channel].getVolume() / 127;
g->chn = channel;
-
+
// Instruments can define different samples to be used based on
// what the key is. Find the correct samples for our key.
int wa = 0;
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 1a225300ae..9123e18415 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -33,7 +33,7 @@ namespace Agi {
// Apple IIGS to halt the corresponding oscillator immediately. We preprocess
// the sample data by converting it to signed values and the instruments by
// detecting prematurely stopping samples beforehand.
-//
+//
// Note: None of the tested SIERRASTANDARD files have zeroes in them. So in
// practice there is no need to check for them. However, they still do exist
// in the sample resources.
@@ -263,7 +263,7 @@ private:
uint _ticks; ///< MIDI ticks (60Hz)
int16 *_out; ///< Output buffer
uint _outSize; ///< Output buffer size
-
+
static const int kSfxMidiChannel = 15; ///< MIDI channel used for playing sample resources
};
diff --git a/engines/agi/sound_midi.cpp b/engines/agi/sound_midi.cpp
index d2c99171e2..0cbaa4af86 100644
--- a/engines/agi/sound_midi.cpp
+++ b/engines/agi/sound_midi.cpp
@@ -33,7 +33,7 @@
// Timing is not perfect, yet. It plays correct, when I use the
// Gravis-Midiplayer, but the songs are too fast when I use playmidi on
// Linux.
-//
+//
// Original program developed by Jens. Christian Restemeier
//
@@ -114,7 +114,7 @@ void SoundGenMIDI::endOfTrack() {
void SoundGenMIDI::play(int resnum) {
MIDISound *track;
-
+
stop();
_isGM = true;
@@ -153,7 +153,7 @@ unsigned char instr[] = {50, 51, 19};
static void writeDelta(Common::MemoryWriteStreamDynamic *st, int32 delta) {
int32 i;
- i = delta >> 21; if (i > 0) st->writeByte((i & 127) | 128);
+ i = delta >> 21; if (i > 0) st->writeByte((i & 127) | 128);
i = delta >> 14; if (i > 0) st->writeByte((i & 127) | 128);
i = delta >> 7; if (i > 0) st->writeByte((i & 127) | 128);
st->writeByte(delta & 127);
@@ -196,7 +196,7 @@ static uint32 convertSND2MIDI(byte *snddata, byte **data) {
int note;
/* I don't know, what frequency equals midi note 0 ... */
/* This moves the song 4 octaves down: */
- fr = (log10(111860.0 / (double)freq) / ll) - 48;
+ fr = (log10(111860.0 / (double)freq) / ll) - 48;
note = (int)floor(fr + 0.5);
if (note < 0) note = 0;
if (note > 127) note = 127;
@@ -222,7 +222,7 @@ static uint32 convertSND2MIDI(byte *snddata, byte **data) {
st.writeByte(0);
st.writeByte(0);
}
- }
+ }
writeDelta(&st, 0);
st.writeByte(0xff);
st.writeByte(0x2f);
diff --git a/engines/agi/sound_pcjr.cpp b/engines/agi/sound_pcjr.cpp
index 319b7049ed..fdebf16b1a 100644
--- a/engines/agi/sound_pcjr.cpp
+++ b/engines/agi/sound_pcjr.cpp
@@ -219,6 +219,7 @@ int SoundGenPCJr::volumeCalc(SndGenChan *chan) {
// return 0 if it's passing more data
// return -1 if it's passing nothing (end of data)
int SoundGenPCJr::getNextNote(int ch, Tone *tone) {
+ ToneChan *tpcm;
SndGenChan *chan;
const byte *data;
@@ -228,6 +229,7 @@ int SoundGenPCJr::getNextNote(int ch, Tone *tone) {
if (!_vm->getflag(fSoundOn))
return -1;
+ tpcm = &_tchannel[ch];
chan = &_channel[ch];
if (!chan->avail)
return -1;
@@ -241,6 +243,9 @@ int SoundGenPCJr::getNextNote(int ch, Tone *tone) {
// if it's 0 then it's not going to be played
// if it's 0xFFFF then the channel data has finished.
if ((chan->duration != 0) && (chan->duration != 0xFFFF)) {
+ tpcm->genTypePrev = -1;
+ tpcm->freqCountPrev = -1;
+
// only tone channels dissolve
if ((ch != 3) && (_dissolveMethod != 0)) // != noise??
chan->dissolveCount = 0;
diff --git a/engines/agi/sound_pcjr.h b/engines/agi/sound_pcjr.h
index f50fd0aa82..4317e86516 100644
--- a/engines/agi/sound_pcjr.h
+++ b/engines/agi/sound_pcjr.h
@@ -45,9 +45,9 @@ struct SndGenChan {
uint16 dissolveCount;
byte attenuation;
byte attenuationCopy;
-
+
GenType genType;
-
+
// for the sample mixer
int freqCount;
};
diff --git a/engines/agi/sound_sarien.cpp b/engines/agi/sound_sarien.cpp
index fc9a57791c..9ea8569b81 100644
--- a/engines/agi/sound_sarien.cpp
+++ b/engines/agi/sound_sarien.cpp
@@ -105,7 +105,7 @@ SoundGenSarien::~SoundGenSarien() {
int SoundGenSarien::readBuffer(int16 *buffer, const int numSamples) {
fillAudio(buffer, numSamples / 2);
-
+
return numSamples;
}
@@ -124,7 +124,7 @@ void SoundGenSarien::play(int resnum) {
for (int i = 0; i < NUM_CHANNELS; i++) {
_chn[i].type = type;
_chn[i].flags = AGI_SOUND_LOOP;
-
+
if (_env) {
_chn[i].flags |= AGI_SOUND_ENVELOPE;
_chn[i].adsr = AGI_SOUND_ENV_ATTACK;
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index fedfd29362..82a2340ad6 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -504,17 +504,16 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
*
*/
void AgiEngine::printStatus(const char *message, ...) {
- char x[42];
va_list args;
va_start(args, message);
- vsprintf(x, message, args);
+ Common::String x = Common::String::vformat(message, args);
va_end(args);
debugC(4, kDebugLevelText, "fg=%d, bg=%d", STATUS_FG, STATUS_BG);
- printText(x, 0, 0, _game.lineStatus, 40, STATUS_FG, STATUS_BG);
+ printText(x.c_str(), 0, 0, _game.lineStatus, 40, STATUS_FG, STATUS_BG);
}
static void safeStrcat(Common::String &p, const char *t) {
diff --git a/engines/agi/wagparser.cpp b/engines/agi/wagparser.cpp
index 14159c0147..39f9e0dd92 100644
--- a/engines/agi/wagparser.cpp
+++ b/engines/agi/wagparser.cpp
@@ -112,11 +112,11 @@ WagFileParser::~WagFileParser() {
bool WagFileParser::checkAgiVersionProperty(const WagProperty &version) const {
if (version.getCode() == WagProperty::PC_INTVERSION && // Must be AGI interpreter version property
version.getSize() >= 3 && // Need at least three characters for a version number like "X.Y"
- isdigit(version.getData()[0]) && // And the first character must be a digit
+ isdigit(static_cast<unsigned char>(version.getData()[0])) && // And the first character must be a digit
(version.getData()[1] == ',' || version.getData()[1] == '.')) { // And the second a comma or a period
for (int i = 2; i < version.getSize(); i++) // And the rest must all be digits
- if (!isdigit(version.getData()[i]))
+ if (!isdigit(static_cast<unsigned char>(version.getData()[i])))
return false; // Bail out if found a non-digit after the decimal point
return true;