aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/graphics.cpp64
-rw-r--r--engines/touche/midi.cpp9
-rw-r--r--engines/touche/midi.h5
-rw-r--r--engines/touche/opcodes.cpp10
-rw-r--r--engines/touche/resource.cpp26
-rw-r--r--engines/touche/saveload.cpp12
-rw-r--r--engines/touche/staticres.cpp11
-rw-r--r--engines/touche/touche.cpp107
-rw-r--r--engines/touche/touche.h6
9 files changed, 156 insertions, 94 deletions
diff --git a/engines/touche/graphics.cpp b/engines/touche/graphics.cpp
index 51fdcbd89a..2ca11a1f95 100644
--- a/engines/touche/graphics.cpp
+++ b/engines/touche/graphics.cpp
@@ -177,34 +177,58 @@ void Graphics::drawLine(uint8 *dst, int dstPitch, int x1, int y1, int x2, int y2
}
void Graphics::copyRect(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, int flags) {
- if (w != 0 && h != 0) {
- dst += dstY * dstPitch + dstX;
- src += srcY * srcPitch + srcX;
- while (h--) {
- for (int i = 0; i < w; ++i) {
- if ((flags & kTransparent) == 0 || src[i] != 0) {
- dst[i] = src[i];
- }
+ if (dstX < 0) {
+ w += dstX;
+ dstX = 0;
+ }
+ if (w <= 0) {
+ return;
+ }
+ if (dstY < 0) {
+ h += dstY;
+ dstY = 0;
+ }
+ if (h <= 0) {
+ return;
+ }
+ dst += dstY * dstPitch + dstX;
+ src += srcY * srcPitch + srcX;
+ while (h--) {
+ for (int i = 0; i < w; ++i) {
+ if ((flags & kTransparent) == 0 || src[i] != 0) {
+ dst[i] = src[i];
}
- dst += dstPitch;
- src += srcPitch;
}
+ dst += dstPitch;
+ src += srcPitch;
}
}
void Graphics::copyMask(uint8 *dst, int dstPitch, int dstX, int dstY, const uint8 *src, int srcPitch, int srcX, int srcY, int w, int h, uint8 fillColor) {
- if (w != 0 && h != 0) {
- dst += dstY * dstPitch + dstX;
- src += srcY * srcPitch + srcX;
- while (h--) {
- for (int i = 0; i < w; ++i) {
- if (src[i] != 0) {
- dst[i] = fillColor;
- }
+ if (dstX < 0) {
+ w += dstX;
+ dstX = 0;
+ }
+ if (w <= 0) {
+ return;
+ }
+ if (dstY < 0) {
+ h += dstY;
+ dstY = 0;
+ }
+ if (h <= 0) {
+ return;
+ }
+ dst += dstY * dstPitch + dstX;
+ src += srcY * srcPitch + srcX;
+ while (h--) {
+ for (int i = 0; i < w; ++i) {
+ if (src[i] != 0) {
+ dst[i] = fillColor;
}
- dst += dstPitch;
- src += srcPitch;
}
+ dst += dstPitch;
+ src += srcPitch;
}
}
diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp
index 29e68a4562..b90d4082c5 100644
--- a/engines/touche/midi.cpp
+++ b/engines/touche/midi.cpp
@@ -32,8 +32,8 @@
namespace Touche {
-MidiPlayer::MidiPlayer(MidiDriver *driver)
- : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) {
+MidiPlayer::MidiPlayer(MidiDriver *driver, bool nativeMT32)
+ : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0), _nativeMT32(nativeMT32) {
assert(_driver);
memset(_channelsTable, 0, sizeof(_channelsTable));
memset(_channelsVolume, 0, sizeof(_channelsVolume));
@@ -129,6 +129,11 @@ void MidiPlayer::send(uint32 b) {
return;
}
break;
+ default:
+ if ((b & 0xF0) == 0xC0 && _nativeMT32) { // program change
+ b = (b & 0xFFFF00FF) | (_gmToRol[(b >> 8) & 0x7F] << 8);
+ }
+ break;
}
if (!_channelsTable[ch]) {
_channelsTable[ch] = (ch == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel();
diff --git a/engines/touche/midi.h b/engines/touche/midi.h
index 808ecfb205..3b128593db 100644
--- a/engines/touche/midi.h
+++ b/engines/touche/midi.h
@@ -46,7 +46,7 @@ public:
NUM_CHANNELS = 16
};
- MidiPlayer(MidiDriver *driver);
+ MidiPlayer(MidiDriver *driver, bool nativeMT32);
~MidiPlayer();
void play(Common::ReadStream &stream, int size, bool loop = false);
@@ -77,9 +77,12 @@ private:
bool _isLooping;
bool _isPlaying;
int _masterVolume;
+ bool _nativeMT32;
MidiChannel *_channelsTable[NUM_CHANNELS];
uint8 _channelsVolume[NUM_CHANNELS];
Common::Mutex _mutex;
+
+ static const uint8 _gmToRol[];
};
} // namespace Touche
diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp
index f0ef748fbd..2680ab0fae 100644
--- a/engines/touche/opcodes.cpp
+++ b/engines/touche/opcodes.cpp
@@ -828,10 +828,16 @@ void ToucheEngine::op_setHitBoxText() {
void ToucheEngine::op_fadePalette() {
debugC(9, kDebugOpcodes, "ToucheEngine::op_fadePalette()");
int16 fadeOut = _script.readNextWord();
+ int colorsCount = 240;
+ // Workaround for bug #1751149. Script triggers a palette fading, but some
+ // of the room graphics use palette colors >= 240.
+ if (_currentEpisodeNum == 104 && _currentRoomNum == 68) {
+ colorsCount = 256;
+ }
if (fadeOut) {
- fadePalette(0, 240, 255, -2, 128);
+ fadePalette(0, colorsCount, 255, -2, 128);
} else {
- fadePalette(0, 240, 0, 2, 128);
+ fadePalette(0, colorsCount, 0, 2, 128);
}
}
diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp
index 585e70c534..cd2124806d 100644
--- a/engines/touche/resource.cpp
+++ b/engines/touche/resource.cpp
@@ -44,7 +44,12 @@ enum {
struct CompressedSpeechFile {
const char *filename;
- Audio::AudioStream *(*makeStream)(Common::File *file, uint32 size);
+ Audio::AudioStream *(*makeStream)(
+ Common::SeekableReadStream *stream,
+ bool disposeAfterUse,
+ uint32 startTime,
+ uint32 duration,
+ uint numLoops);
};
static const CompressedSpeechFile compressedSpeechFilesTable[] = {
@@ -268,7 +273,7 @@ void ToucheEngine::res_decodeProgramData() {
ppd.x = READ_LE_UINT16(p); p += 2;
ppd.y = READ_LE_UINT16(p); p += 2;
ppd.z = READ_LE_UINT16(p); p += 2;
- ppd.priority = READ_LE_UINT16(p); p += 2;
+ ppd.order = READ_LE_UINT16(p); p += 2;
_programPointsTable.push_back(ppd);
if (ppd.x == -1) {
break;
@@ -516,19 +521,20 @@ void ToucheEngine::res_loadBackdrop() {
debugC(9, kDebugResource, "ToucheEngine::res_loadBackdrop()");
_currentBitmapWidth = _fData.readUint16LE();
_currentBitmapHeight = _fData.readUint16LE();
- uint8 *dst = _backdropBuffer;
for (int i = 0; i < _currentBitmapHeight; ++i) {
- res_decodeScanLineImageRLE(dst + _currentBitmapWidth * i, _currentBitmapWidth);
+ res_decodeScanLineImageRLE(_backdropBuffer + _currentBitmapWidth * i, _currentBitmapWidth);
}
_roomWidth = _currentBitmapWidth;
- dst = _backdropBuffer;
for (int i = 0; i < _currentBitmapWidth; ++i) {
- if (*dst == 255) {
+ if (_backdropBuffer[i] == 255) {
_roomWidth = i;
- *dst = 0;
+ _backdropBuffer[i] = 0;
break;
}
- ++dst;
+ }
+ // Workaround for bug #1751149 (original bitmap has a white pixel in its transparent area).
+ if (_currentRoomNum == 8 && _currentBitmapWidth == 860) {
+ _backdropBuffer[120 * _currentBitmapWidth + 734] = 0;
}
}
@@ -656,7 +662,9 @@ void ToucheEngine::res_loadSpeechSegment(int num) {
return;
}
_fSpeech[0].seek(offs);
- stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(&_fSpeech[0], size);
+ Common::MemoryReadStream *tmp = _fSpeech[0].readStream(size);
+ assert(tmp);
+ stream = (compressedSpeechFilesTable[_compressedSpeechData].makeStream)(tmp, true, 0, 0, 1);
}
if (stream) {
_speechPlaying = true;
diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp
index c37c06aacb..5ff749fa68 100644
--- a/engines/touche/saveload.cpp
+++ b/engines/touche/saveload.cpp
@@ -131,7 +131,7 @@ static void saveOrLoad(S &s, KeyChar &key) {
saveOrLoad(s, key.followingKeyCharPos);
saveOrLoad(s, key.sequenceDataIndex);
saveOrLoad(s, key.sequenceDataOffset);
- saveOrLoad(s, key.walkPointsListCount);
+ saveOrLoad(s, key.walkPointsListIndex);
for (uint i = 0; i < 40; ++i) {
saveOrLoad(s, key.walkPointsList[i]);
}
@@ -209,7 +209,7 @@ static void saveOrLoad(S &s, ProgramPointData &data) {
saveOrLoad(s, data.x);
saveOrLoad(s, data.y);
saveOrLoad(s, data.z);
- saveOrLoad(s, data.priority);
+ saveOrLoad(s, data.order);
}
template <class S, class A>
@@ -280,8 +280,8 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
_newMusicNum = stream->readUint16LE();
_currentRoomNum = stream->readUint16LE();
res_loadRoom(_currentRoomNum);
- int16 roomOffsX = stream->readUint16LE();
- int16 roomOffsY = stream->readUint16LE();
+ int16 roomOffsX = _flagsTable[614] = stream->readUint16LE();
+ int16 roomOffsY = _flagsTable[615] = stream->readUint16LE();
_disabledInputCounter = stream->readUint16LE();
res_loadProgram(_currentEpisodeNum);
setupEpisode(-1);
@@ -291,7 +291,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
saveOrLoadCommonArray(*stream, _programWalkTable);
saveOrLoadCommonArray(*stream, _programPointsTable);
stream->read(_updatedRoomAreasTable, 200);
- for (uint i = 1; i <= _updatedRoomAreasTable[0]; ++i) {
+ for (uint i = 1; i < _updatedRoomAreasTable[0]; ++i) {
updateRoomAreas(_updatedRoomAreasTable[i], -1);
}
saveOrLoadStaticArray(*stream, _sequenceEntryTable, NUM_SEQUENCES);
@@ -327,7 +327,9 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
Graphics::copyRect(_offscreenBuffer, kScreenWidth, 0, 0,
_backdropBuffer, _currentBitmapWidth, _flagsTable[614], _flagsTable[615],
kScreenWidth, kRoomHeight);
+ updateRoomRegions();
updateEntireScreen();
+ _roomNeedRedraw = false;
if (_flagsTable[617] != 0) {
res_loadSpeech(_flagsTable[617]);
}
diff --git a/engines/touche/staticres.cpp b/engines/touche/staticres.cpp
index 4c3ea4855f..eb3ddc15ff 100644
--- a/engines/touche/staticres.cpp
+++ b/engines/touche/staticres.cpp
@@ -27,6 +27,7 @@
#include "touche/graphics.h"
#include "touche/touche.h"
+#include "touche/midi.h"
namespace Touche {
@@ -1332,5 +1333,15 @@ int Graphics::_fontSize = Graphics::_engFontSize;
const uint8 *Graphics::_fontData = Graphics::_engFontData;
+const uint8 MidiPlayer::_gmToRol[] = {
+ 0x01, 0x02, 0x03, 0x08, 0x04, 0x05, 0x11, 0x14, 0x66, 0x66, 0x66, 0x62, 0x69, 0x68, 0x67, 0x26,
+ 0x09, 0x0A, 0x0B, 0x0E, 0x0F, 0x10, 0x10, 0x10, 0x3C, 0x3D, 0x3D, 0x3D, 0x3D, 0x3E, 0x3F, 0x3F,
+ 0x47, 0x41, 0x42, 0x48, 0x45, 0x46, 0x1D, 0x1E, 0x35, 0x36, 0x37, 0x39, 0x33, 0x34, 0x3A, 0x71,
+ 0x31, 0x32, 0x31, 0x32, 0x23, 0x23, 0x23, 0x7B, 0x59, 0x5B, 0x5F, 0x5A, 0x5D, 0x60, 0x19, 0x1A,
+ 0x4F, 0x50, 0x51, 0x52, 0x55, 0x56, 0x57, 0x53, 0x4B, 0x49, 0x4D, 0x4E, 0x6F, 0x6C, 0x6D, 0x6E,
+ 0x30, 0x19, 0x4E, 0x2B, 0x28, 0x23, 0x19, 0x30, 0x21, 0x25, 0x1C, 0x21, 0x24, 0x22, 0x21, 0x22,
+ 0x2A, 0x25, 0x24, 0x26, 0x2E, 0x22, 0x29, 0x21, 0x40, 0x40, 0x6A, 0x6A, 0x68, 0x10, 0x35, 0x10,
+ 0x7F, 0x6B, 0x69, 0x75, 0x76, 0x72, 0x74, 0x01, 0x01, 0x70, 0x01, 0x7D, 0x7C, 0x01, 0x01, 0x01
+};
} // namespace Touche
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 18d2ac5359..c67b1e9be3 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -97,8 +97,9 @@ int ToucheEngine::init() {
setupOpcodes();
int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
+ bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
- _midiPlayer = new MidiPlayer(driver);
+ _midiPlayer = new MidiPlayer(driver, native_mt32);
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume"));
@@ -642,7 +643,7 @@ void ToucheEngine::initKeyChars(int keyChar) {
key->sequenceDataOffset = 0;
key->walkDataNum = 0;
key->walkPointsList[0] = -1;
- key->walkPointsListCount = 0;
+ key->walkPointsListIndex = 0;
key->delay = 0;
key->waitingKeyChar = -1;
key->flags = 0;
@@ -869,11 +870,11 @@ void ToucheEngine::redrawRoom() {
}
}
-void ToucheEngine::fadePalette(int firstColor, int lastColor, int scale, int scaleInc, int fadingStepsCount) {
+void ToucheEngine::fadePalette(int firstColor, int colorCount, int scale, int scaleInc, int fadingStepsCount) {
for (int i = 0; i < fadingStepsCount; ++i) {
scale += scaleInc;
scale = CLIP(scale, 0, 255);
- setPalette(firstColor, lastColor, scale, scale, scale);
+ setPalette(firstColor, colorCount, scale, scale, scale);
_system->updateScreen();
_system->delayMillis(10);
}
@@ -2516,7 +2517,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) {
uint16 curPos, pos1, pos2;
if (key->pointsDataNum & 0x8000) {
const ProgramWalkData *pwd = &_programWalkTable[(key->pointsDataNum & 0x7FFF)];
- if (_programPointsTable[pwd->point1].priority < _programPointsTable[pwd->point2].priority) {
+ if (_programPointsTable[pwd->point1].order < _programPointsTable[pwd->point2].order) {
curPos = pwd->point1;
} else {
curPos = pwd->point2;
@@ -2525,7 +2526,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) {
curPos = key->pointsDataNum;
}
- int16 posNum = _programPointsTable[curPos].priority;
+ int16 posNum = _programPointsTable[curPos].order;
if (posNum == 32000) {
return;
}
@@ -2536,25 +2537,25 @@ void ToucheEngine::buildWalkPointsList(int keyChar) {
if ((_programWalkTable[i].point1 & 0x4000) == 0) {
pos1 = _programWalkTable[i].point1;
pos2 = _programWalkTable[i].point2;
- if (pos1 == curPos && posNum > _programPointsTable[pos2].priority) {
+ if (pos1 == curPos && posNum > _programPointsTable[pos2].order) {
curPos = pos2;
assert(walkPointsCount < 40);
key->walkPointsList[walkPointsCount] = curPos;
++walkPointsCount;
- posNum = _programPointsTable[pos2].priority;
+ posNum = _programPointsTable[pos2].order;
break;
}
- if (pos2 == curPos && posNum > _programPointsTable[pos1].priority) {
+ if (pos2 == curPos && posNum > _programPointsTable[pos1].order) {
curPos = pos1;
assert(walkPointsCount < 40);
key->walkPointsList[walkPointsCount] = curPos;
++walkPointsCount;
- posNum = _programPointsTable[pos1].priority;
+ posNum = _programPointsTable[pos1].order;
break;
}
}
}
- } while (_programPointsTable[curPos].priority != 0);
+ } while (_programPointsTable[curPos].order != 0);
assert(walkPointsCount < 40);
key->walkPointsList[walkPointsCount] = -1;
@@ -2562,7 +2563,7 @@ void ToucheEngine::buildWalkPointsList(int keyChar) {
key->yPosPrev = _programPointsTable[curPos].y;
key->zPosPrev = _programPointsTable[curPos].z;
key->prevWalkDataNum = findWalkDataNum(curPos, -1);
- key->walkPointsListCount = 0;
+ key->walkPointsListIndex = 0;
if (key->walkDataNum == -1) {
return;
}
@@ -2571,13 +2572,13 @@ void ToucheEngine::buildWalkPointsList(int keyChar) {
pos2 = _programWalkTable[key->walkDataNum].point2;
if (key->pointsDataNum == pos1) {
if (key->walkPointsList[1] == pos2) {
- ++key->walkPointsListCount;
+ ++key->walkPointsListIndex;
}
return;
}
if (key->pointsDataNum == pos2) {
if (key->walkPointsList[1] == pos1) {
- ++key->walkPointsListCount;
+ ++key->walkPointsListIndex;
}
return;
}
@@ -2678,7 +2679,7 @@ void ToucheEngine::unlockWalkPath(int num1, int num2) {
void ToucheEngine::resetPointsData(int num) {
debugC(9, kDebugEngine, "ToucheEngine::resetPointsData(%d)", num);
for (uint i = 1; i < _programPointsTable.size(); ++i) {
- _programPointsTable[i].priority = num;
+ _programPointsTable[i].order = num;
}
}
@@ -2689,32 +2690,33 @@ bool ToucheEngine::sortPointsData(int num1, int num2) {
if (num2 == -1) {
return false;
}
- _programPointsTable[num2].priority = 0;
+ _programPointsTable[num2].order = 0;
} else {
const int md1 = _programWalkTable[num1].point1;
- _programPointsTable[md1].priority = 0;
+ _programPointsTable[md1].order = 0;
const int md2 = _programWalkTable[num1].point2;
- _programPointsTable[md2].priority = 0;
+ _programPointsTable[md2].order = 0;
}
bool quit = false;
- int priority = 1;
+ int order = 1;
while (!quit) {
quit = true;
for (uint i = 0; i < _programWalkTable.size(); ++i) {
const int md1 = _programWalkTable[i].point1;
const int md2 = _programWalkTable[i].point2;
if ((md1 & 0x4000) == 0) {
- if (_programPointsTable[md1].priority == priority - 1 && _programPointsTable[md2].priority > priority) {
- _programPointsTable[md2].priority = priority;
+ assert((md2 & 0x4000) == 0);
+ if (_programPointsTable[md1].order == order - 1 && _programPointsTable[md2].order > order) {
+ _programPointsTable[md2].order = order;
quit = false;
}
- if (_programPointsTable[md2].priority == priority - 1 && _programPointsTable[md1].priority > priority) {
- _programPointsTable[md1].priority = priority;
+ if (_programPointsTable[md2].order == order - 1 && _programPointsTable[md1].order > order) {
+ _programPointsTable[md1].order = order;
quit = false;
}
}
}
- ++priority;
+ ++order;
}
return true;
}
@@ -2763,8 +2765,8 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16
int16 xpos, ypos, zpos, walkPoint1, walkPoint2, newDirection, incDx, incDy, incDz;
while (1) {
- walkPoint1 = key->walkPointsList[key->walkPointsListCount];
- walkPoint2 = key->walkPointsList[key->walkPointsListCount + 1];
+ walkPoint1 = key->walkPointsList[key->walkPointsListIndex];
+ walkPoint2 = key->walkPointsList[key->walkPointsListIndex + 1];
key->currentWalkBox = walkPoint1;
if (walkPoint1 == -1) {
xpos = key->xPosPrev;
@@ -2804,9 +2806,9 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16
key->pointsDataNum = walkPoint1;
if (walkPoint2 == -1) {
key->walkPointsList[0] = -1;
- key->walkPointsListCount = 0;
+ key->walkPointsListIndex = 0;
} else {
- ++key->walkPointsListCount;
+ ++key->walkPointsListIndex;
int16 walkDataNum = findWalkDataNum(walkPoint1, walkPoint2);
if (walkDataNum != -1) {
key->walkDataNum = walkDataNum;
@@ -2858,7 +2860,7 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16
}
key->prevPointsDataNum = key->pointsDataNum;
key->pointsDataNum = walkPoint1;
- ++key->walkPointsListCount;
+ ++key->walkPointsListIndex;
if (newDirection != curDirection) {
key->facingDirection = newDirection;
key->currentAnimCounter = 0;
@@ -2902,7 +2904,7 @@ void ToucheEngine::updateKeyCharWalkPath(KeyChar *key, int16 dx, int16 dy, int16
}
key->prevPointsDataNum = key->pointsDataNum;
key->pointsDataNum = walkPoint1;
- ++key->walkPointsListCount;
+ ++key->walkPointsListIndex;
if (newDirection != curDirection) {
key->facingDirection = newDirection;
key->currentAnimCounter = 0;
@@ -2941,7 +2943,7 @@ void ToucheEngine::markWalkPoints(int keyChar) {
int16 pointsDataNum = key->pointsDataNum;
resetPointsData(0);
if (pointsDataNum != -1) {
- _programPointsTable[pointsDataNum].priority = 1;
+ _programPointsTable[pointsDataNum].order = 1;
bool quit = false;
while (!quit) {
quit = true;
@@ -2949,12 +2951,13 @@ void ToucheEngine::markWalkPoints(int keyChar) {
int16 md1 = _programWalkTable[i].point1;
int16 md2 = _programWalkTable[i].point2;
if ((md1 & 0x4000) == 0) {
- if (_programPointsTable[md1].priority != 0 && _programPointsTable[md2].priority == 0) {
- _programPointsTable[md2].priority = 1;
+ assert((md2 & 0x4000) == 0);
+ if (_programPointsTable[md1].order != 0 && _programPointsTable[md2].order == 0) {
+ _programPointsTable[md2].order = 1;
quit = false;
}
- if (_programPointsTable[md2].priority != 0 && _programPointsTable[md1].priority == 0) {
- _programPointsTable[md1].priority = 1;
+ if (_programPointsTable[md2].order != 0 && _programPointsTable[md1].order == 0) {
+ _programPointsTable[md1].order = 1;
quit = false;
}
}
@@ -2973,9 +2976,9 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) {
int minDistance = 0x7D000000;
int minPointsDataNum = -1;
for (uint i = 1; i < _programPointsTable.size(); ++i) {
- if (_programPointsTable[i].priority != 0) {
- int dx = ABS<int>(_programPointsTable[i].x - dstPosX);
- int dy = ABS<int>(_programPointsTable[i].y - dstPosY);
+ if (_programPointsTable[i].order != 0) {
+ int dx = _programPointsTable[i].x - dstPosX;
+ int dy = _programPointsTable[i].y - dstPosY;
int distance = dx * dx + dy * dy;
if (distance < minDistance) {
minDistance = distance;
@@ -2992,28 +2995,28 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) {
int distance = 32000;
ProgramPointData *pts1 = &_programPointsTable[pwd->point1];
ProgramPointData *pts2 = &_programPointsTable[pwd->point2];
- if (pts1->priority != 0) {
+ if (pts1->order != 0) {
int dx = pts2->x - pts1->x;
int dy = pts2->y - pts1->y;
if (dx == 0) {
if (dstPosY > MIN(pts2->y, pts1->y) && dstPosY < MAX(pts2->y, pts1->y)) {
- distance = ABS(dstPosX - pts1->x);
- if (distance <= 100) {
- distance *= distance;
+ int d = ABS(dstPosX - pts1->x);
+ if (d <= 100) {
+ distance = d * d;
}
}
} else if (dy == 0) {
if (dstPosX > MIN(pts2->x, pts1->x) && dstPosX < MAX(pts2->x, pts1->x)) {
- distance = ABS(dstPosY - pts1->y);
- if (distance <= 100) {
- distance *= distance;
+ int d = ABS(dstPosY - pts1->y);
+ if (d <= 100) {
+ distance = d * d;
}
}
} else {
if (dstPosY > MIN(pts2->y, pts1->y) && dstPosY < MAX(pts2->y, pts1->y) &&
dstPosX > MIN(pts2->x, pts1->x) && dstPosX < MAX(pts2->x, pts1->x) ) {
- distance = (dstPosY - pts1->y) * dx - (dstPosX - pts1->x) * dy;
- distance = (dx * dx + dy * dy) / distance;
+ distance = (dstPosX - pts1->x) * dy - (dstPosY - pts1->y) * dx;
+ distance /= (dx * dx + dy * dy);
}
}
if (distance < minDistance) {
@@ -3047,13 +3050,13 @@ void ToucheEngine::buildWalkPath(int dstPosX, int dstPosY, int keyChar) {
dstPosZ = pts2->z - (pts2->x - dstPosX) * dz / dx;
dstPosY = pts2->y - (pts2->x - dstPosX) * dy / dx;
}
- if (key->walkDataNum == key->prevWalkDataNum && key->walkPointsList[1] == -1) {
- if (key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point1 || key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point2) {
- ++key->walkPointsListCount;
- }
- }
}
key->prevWalkDataNum = minWalkDataNum;
+ if (key->walkDataNum == key->prevWalkDataNum && key->walkPointsList[1] == -1) {
+ if (key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point1 || key->walkPointsList[0] == _programWalkTable[minWalkDataNum].point2) {
+ ++key->walkPointsListIndex;
+ }
+ }
key->xPosPrev = dstPosX;
key->yPosPrev = dstPosY;
key->zPosPrev = dstPosZ;
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index ce4f84b9a8..5aef0ef613 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -114,7 +114,7 @@ struct KeyChar {
int16 followingKeyCharPos;
uint16 sequenceDataIndex;
uint16 sequenceDataOffset;
- int16 walkPointsListCount;
+ int16 walkPointsListIndex;
int16 walkPointsList[40];
uint16 scriptDataStartOffset;
uint16 scriptDataOffset;
@@ -209,7 +209,7 @@ struct InventoryState {
struct ProgramPointData {
int16 x, y, z;
- int16 priority;
+ int16 order;
};
struct ProgramWalkData {
@@ -390,7 +390,7 @@ protected:
void centerScreenToKeyChar(int keyChar);
void waitForKeyCharsSet();
void redrawRoom();
- void fadePalette(int firstColor, int lastColor, int scale, int scaleInc, int fadingStepsCount);
+ void fadePalette(int firstColor, int colorCount, int scale, int scaleInc, int fadingStepsCount);
void fadePaletteFromFlags();
void moveKeyChar(uint8 *dst, int dstPitch, KeyChar *key);
void changeKeyCharFrame(KeyChar *key, int keyChar);