aboutsummaryrefslogtreecommitdiff
path: root/engines/lure
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-04-18 23:35:23 +0200
committerWillem Jan Palenstijn2013-05-08 20:40:58 +0200
commit9c2341678ef4984bf92b3878295250faf980b066 (patch)
tree2fb4805e05e16b9924e80c9947e6bad723b28c4b /engines/lure
parent8172d679df5148a4a32f46074b20cb6caf91844f (diff)
parenta5f4ff36ffc386d48f2da49387a9655ce9295a4d (diff)
downloadscummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.gz
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.bz2
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.zip
Merge branch 'master'
Diffstat (limited to 'engines/lure')
-rw-r--r--engines/lure/decode.cpp323
-rw-r--r--engines/lure/detection.cpp16
-rw-r--r--engines/lure/hotspots.cpp302
-rw-r--r--engines/lure/menu.cpp63
-rw-r--r--engines/lure/res.cpp2
-rw-r--r--engines/lure/room.cpp2
-rw-r--r--engines/lure/scripts.cpp2
-rw-r--r--engines/lure/sound.cpp12
8 files changed, 379 insertions, 343 deletions
diff --git a/engines/lure/decode.cpp b/engines/lure/decode.cpp
index 59390e6e91..1338559534 100644
--- a/engines/lure/decode.cpp
+++ b/engines/lure/decode.cpp
@@ -34,12 +34,18 @@ namespace Lure {
/* Provides the functionality for decoding screens */
/*--------------------------------------------------------------------------*/
+/**
+ * Write a single byte to the output buffer
+ */
void PictureDecoder::writeByte(MemoryBlock *dest, byte v) {
if (outputOffset == dest->size())
error("Decoded data exceeded allocated output buffer size");
dest->data()[outputOffset++] = v;
}
+/**
+ * Writes out a specified byte a given number of times to the output
+ */
void PictureDecoder::writeBytes(MemoryBlock *dest, byte v, uint16 numBytes) {
if (outputOffset + numBytes > dest->size())
error("Decoded data exceeded allocated output buffer size");
@@ -47,6 +53,9 @@ void PictureDecoder::writeBytes(MemoryBlock *dest, byte v, uint16 numBytes) {
outputOffset += numBytes;
}
+/**
+ * Gets a byte from the compressed source using the first data pointer
+ */
byte PictureDecoder::DSSI(bool incr) {
if (dataPos > dataIn->size())
error("PictureDecoder went beyond end of source data");
@@ -57,6 +66,9 @@ byte PictureDecoder::DSSI(bool incr) {
return result;
}
+/**
+ * Gets a byte from the compressed source using the second data pointer
+ */
byte PictureDecoder::ESBX(bool incr) {
if (dataPos2 >= dataIn->size())
error("PictureDecoder went beyond end of source data");
@@ -227,56 +239,61 @@ MemoryBlock *PictureDecoder::vgaDecode(MemoryBlock *src, uint32 maxOutputSize) {
CH = ESBX();
CL = 9;
-Loc754:
- AL = DSSI();
- writeByte(dest, AL);
- BP = ((uint16) AL) << 2;
-
-Loc755:
- decrCtr();
- if (shlCarry()) goto Loc761;
- decrCtr();
- if (shlCarry()) goto Loc759;
- AL = dataIn->data()[BP];
-
-Loc758:
- writeByte(dest, AL);
- BP = ((uint16) AL) << 2;
- goto Loc755;
-
-Loc759:
- AL = (byte) (BP >> 2);
- AH = DSSI();
- if (AH == 0) goto Loc768;
-
- writeBytes(dest, AL, AH);
- goto Loc755;
-
-Loc761:
- decrCtr();
- if (shlCarry()) goto Loc765;
- decrCtr();
-
- if (shlCarry()) goto Loc764;
- AL = dataIn->data()[BP+1];
- goto Loc758;
-
-Loc764:
- AL = dataIn->data()[BP+2];
- goto Loc758;
-
-Loc765:
- decrCtr();
- if (shlCarry()) goto Loc767;
- AL = dataIn->data()[BP+3];
- goto Loc758;
-
-Loc767:
- goto Loc754;
-
-Loc768:
- AL = DSSI();
- if (AL != 0) goto Loc755;
+ // Main decoding loop
+ bool loopFlag = true;
+ while (loopFlag) {
+ AL = DSSI();
+ writeByte(dest, AL);
+ BP = ((uint16) AL) << 2;
+
+ // Inner loop
+ for (;;) {
+ decrCtr();
+ if (shlCarry()) {
+ decrCtr();
+ if (shlCarry()) {
+ decrCtr();
+ if (shlCarry())
+ break;
+
+ AL = dataIn->data()[BP + 3];
+ } else {
+ decrCtr();
+ if (shlCarry())
+ AL = dataIn->data()[BP + 2];
+ else
+ AL = dataIn->data()[BP + 1];
+ }
+ } else {
+ decrCtr();
+ if (shlCarry()) {
+ AL = (byte) (BP >> 2);
+ AH = DSSI();
+ if (AH == 0) {
+ AL = DSSI();
+ if (AL == 0) {
+ // Finally done
+ loopFlag = false;
+ break;
+ } else {
+ // Keep going
+ continue;
+ }
+ } else {
+ // Write out byte sequence
+ writeBytes(dest, AL, AH);
+ continue;
+ }
+ } else {
+ AL = dataIn->data()[BP];
+ }
+ }
+
+ // Write out the next byte
+ writeByte(dest, AL);
+ BP = ((uint16) AL) << 2;
+ }
+ }
// Resize the output to be the number of outputed bytes and return it
if (outputOffset < dest->size()) dest->reallocate(outputOffset);
@@ -355,106 +372,54 @@ uint32 AnimationDecoder::decode_data(MemoryBlock *src, MemoryBlock *dest, uint32
currData <<= 4;
dx = 1;
- for (;;) {
- carry = false;
- rcl(currData, carry);
- if (--bitCtr == 0) {
- GET_BYTE;
- bitCtr = 8;
- }
- if (carry) goto loc_1441;
- tableOffset = BX_VAL(0);
-
-loc_1439:
- dx ^= 1;
- if ((dx & 1) != 0) {
- SET_HI_BYTE(dx, tableOffset << 4);
- *pDest = dx >> 8;
- } else {
- *pDest++ |= tableOffset;
- }
- continue;
-
-loc_1441:
- rcl(currData, carry);
- if (--bitCtr == 0) {
- GET_BYTE;
- bitCtr = 8;
- }
- if (!carry) {
+ // Main loop
+ bool loopFlag = true;
+ while (loopFlag) {
+ for (;;) {
+ carry = false;
rcl(currData, carry);
if (--bitCtr == 0) {
GET_BYTE;
bitCtr = 8;
}
-
if (!carry) {
- tableOffset = BX_VAL(0x10);
- } else {
- tableOffset = BX_VAL(0x20);
+ tableOffset = BX_VAL(0);
+ break;
}
- goto loc_1439;
- }
-
- rcl(currData, carry);
- if (--bitCtr == 0) {
- GET_BYTE;
- bitCtr = 8;
- }
- if (!carry) {
- tableOffset = BX_VAL(0x30);
- goto loc_1439;
- }
- SET_HI_BYTE(dx, currData >> 12);
- carry = false;
- for (int ctr = 0; ctr < 4; ++ctr) {
rcl(currData, carry);
if (--bitCtr == 0) {
GET_BYTE;
bitCtr = 8;
}
- }
-
- byte dxHigh = dx >> 8;
- if (dxHigh == BX_VAL(0)) {
- tempReg1 = bitCtr;
- tempReg2 = dx;
- decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
-
- SET_LO_BYTE(dx, dx >> 8);
- decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
- SET_HI_BYTE(bitCtr, dx & 0xff);
- SET_LO_BYTE(bitCtr, dx >> 8);
- dx = tempReg2;
-
- if (bitCtr == 0)
- // Exit out of infinite loop
- break;
-
- } else if (dxHigh == BX_VAL(0x10)) {
- tempReg1 = bitCtr;
- decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
- bitCtr = dx >> 8;
-
- } else if (dxHigh == BX_VAL(0x20)) {
- SET_HI_BYTE(dx, currData >> 10);
-
- for (v = 0; v < 6; ++v) {
+ if (!carry) {
rcl(currData, carry);
if (--bitCtr == 0) {
GET_BYTE;
bitCtr = 8;
}
- }
- tempReg1 = bitCtr;
- bitCtr = dx >> 8;
+ if (!carry) {
+ tableOffset = BX_VAL(0x10);
+ } else {
+ tableOffset = BX_VAL(0x20);
+ }
+ break;
+ }
- } else if (dxHigh == BX_VAL(0x30)) {
- SET_HI_BYTE(dx, currData >> 11);
+ rcl(currData, carry);
+ if (--bitCtr == 0) {
+ GET_BYTE;
+ bitCtr = 8;
+ }
+ if (!carry) {
+ tableOffset = BX_VAL(0x30);
+ break;
+ }
- for (v = 0; v < 5; ++v) {
+ SET_HI_BYTE(dx, currData >> 12);
+ carry = false;
+ for (int ctr = 0; ctr < 4; ++ctr) {
rcl(currData, carry);
if (--bitCtr == 0) {
GET_BYTE;
@@ -462,34 +427,92 @@ loc_1441:
}
}
- tempReg1 = bitCtr;
- bitCtr = dx >> 8;
+ byte dxHigh = dx >> 8;
+ if (dxHigh == BX_VAL(0)) {
+ tempReg1 = bitCtr;
+ tempReg2 = dx;
+ decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
+
+ SET_LO_BYTE(dx, dx >> 8);
+ decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
+ SET_HI_BYTE(bitCtr, dx & 0xff);
+ SET_LO_BYTE(bitCtr, dx >> 8);
+ dx = tempReg2;
+
+ if (bitCtr == 0) {
+ // End of decompression
+ loopFlag = false;
+ break;
+ }
+ } else if (dxHigh == BX_VAL(0x10)) {
+ tempReg1 = bitCtr;
+ decode_data_2(src, pSrc, currData, bitCtr, dx, carry);
+ bitCtr = dx >> 8;
+
+ } else if (dxHigh == BX_VAL(0x20)) {
+ SET_HI_BYTE(dx, currData >> 10);
+
+ for (v = 0; v < 6; ++v) {
+ rcl(currData, carry);
+ if (--bitCtr == 0) {
+ GET_BYTE;
+ bitCtr = 8;
+ }
+ }
+
+ tempReg1 = bitCtr;
+ bitCtr = dx >> 8;
- } else {
- tableOffset = dx >> 8;
- goto loc_1439;
- }
+ } else if (dxHigh == BX_VAL(0x30)) {
+ SET_HI_BYTE(dx, currData >> 11);
- if ((dx & 1) == 1) {
- *pDest++ |= tableOffset;
- --bitCtr;
- dx &= 0xfffe;
- }
+ for (v = 0; v < 5; ++v) {
+ rcl(currData, carry);
+ if (--bitCtr == 0) {
+ GET_BYTE;
+ bitCtr = 8;
+ }
+ }
- SET_HI_BYTE(dx, tableOffset << 4);
- tableOffset |= dx >> 8;
+ tempReg1 = bitCtr;
+ bitCtr = dx >> 8;
- v = bitCtr >> 1;
- while (v-- > 0) *pDest++ = tableOffset;
+ } else {
+ tableOffset = dx >> 8;
+ break;
+ }
- bitCtr &= 1;
- if (bitCtr != 0) {
- *pDest = tableOffset & 0xf0;
- dx |= 1; //dx.l
+ if ((dx & 1) == 1) {
+ *pDest++ |= tableOffset;
+ --bitCtr;
+ dx &= 0xfffe;
+ }
+
+ SET_HI_BYTE(dx, tableOffset << 4);
+ tableOffset |= dx >> 8;
+
+ v = bitCtr >> 1;
+ while (v-- > 0) *pDest++ = tableOffset;
+
+ bitCtr &= 1;
+ if (bitCtr != 0) {
+ *pDest = tableOffset & 0xf0;
+ dx |= 1; //dx.l
+ }
+
+ bitCtr = tempReg1;
+ tableOffset &= 0x0f;
}
- bitCtr = tempReg1;
- tableOffset &= 0x0f;
+ if (loopFlag) {
+ dx ^= 1;
+ if ((dx & 1) != 0) {
+ SET_HI_BYTE(dx, tableOffset << 4);
+ *pDest = dx >> 8;
+ } else {
+ *pDest++ |= tableOffset;
+ }
+ }
}
// Return number of bytes written
diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp
index 276b2d77af..ab7615c265 100644
--- a/engines/lure/detection.cpp
+++ b/engines/lure/detection.cpp
@@ -72,7 +72,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
@@ -85,7 +85,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY | GF_EGA,
},
@@ -98,7 +98,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
@@ -111,7 +111,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY | GF_EGA,
},
@@ -124,7 +124,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
@@ -137,7 +137,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
@@ -150,7 +150,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
@@ -163,7 +163,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::ES_ESP,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
+ GUIO0()
},
GF_FLOPPY,
},
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index 96e5e088ab..c7e7e81900 100644
--- a/engines/lure/hotspots.cpp
+++ b/engines/lure/hotspots.cpp
@@ -179,7 +179,6 @@ Hotspot::Hotspot(): _pathFinder(NULL) {
_walkFlag = false;
_skipFlag = false;
_roomNumber = 0;
- _destHotspotId = 0;
_startX = 0;
_startY = 0;
_destX = 0;
@@ -2335,9 +2334,11 @@ void Hotspot::saveToStream(Common::WriteStream *stream) {
void Hotspot::loadFromStream(Common::ReadStream *stream) {
if (_data)
_data->npcSchedule.loadFromStream(stream);
- else
+ else {
// Dummy read of terminator for empty actions list
- assert(stream->readByte() == 0xff);
+ byte dummy = stream->readByte();
+ assert(dummy == 0xff);
+ }
_pathFinder.loadFromStream(stream);
@@ -4165,6 +4166,7 @@ PathFinderResult PathFinder::process() {
bool altFlag;
uint16 *pCurrent;
PathFinderResult result = PF_UNFINISHED;
+ bool skipToFinalStep = false;
if (!_inProgress) {
// Following code only done during first call to method
@@ -4187,188 +4189,190 @@ PathFinderResult PathFinder::process() {
_inProgress = false;
result = PF_OK;
- goto final_step;
- }
-
- // Path finding
+ skipToFinalStep = true;
+ } else {
+ // Path finding
- _destX >>= 3;
- _destY >>= 3;
- _pSrc = &_layer[(_yCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xCurrent];
- _pDest = &_layer[(_yDestCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xDestCurrent];
+ _destX >>= 3;
+ _destY >>= 3;
+ _pSrc = &_layer[(_yCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xCurrent];
+ _pDest = &_layer[(_yDestCurrent + 1) * DECODED_PATHS_WIDTH + 1 + _xDestCurrent];
- // Flag starting/ending cells
- *_pSrc = 1;
- _destOccupied = *_pDest != 0;
- result = _destOccupied ? PF_DEST_OCCUPIED : PF_OK;
- *_pDest = 0;
+ // Flag starting/ending cells
+ *_pSrc = 1;
+ _destOccupied = *_pDest != 0;
+ result = _destOccupied ? PF_DEST_OCCUPIED : PF_OK;
+ *_pDest = 0;
- // Set up the current pointer, adjusting away from edges if necessary
+ // Set up the current pointer, adjusting away from edges if necessary
- if (_xCurrent >= _xDestCurrent) {
- _xChangeInc = -1;
- _xChangeStart = ROOM_PATHS_WIDTH;
- } else {
- _xChangeInc = 1;
- _xChangeStart = 1;
- }
+ if (_xCurrent >= _xDestCurrent) {
+ _xChangeInc = -1;
+ _xChangeStart = ROOM_PATHS_WIDTH;
+ } else {
+ _xChangeInc = 1;
+ _xChangeStart = 1;
+ }
- if (_yCurrent >= _yDestCurrent) {
- _yChangeInc = -1;
- _yChangeStart = ROOM_PATHS_HEIGHT;
- } else {
- _yChangeInc = 1;
- _yChangeStart = 1;
+ if (_yCurrent >= _yDestCurrent) {
+ _yChangeInc = -1;
+ _yChangeStart = ROOM_PATHS_HEIGHT;
+ } else {
+ _yChangeInc = 1;
+ _yChangeStart = 1;
+ }
}
}
- // Major loop to populate data
- _cellPopulated = false;
-
- while (1) {
- // Loop through to process cells in the given area
- if (!returnFlag) _yCtr = 0;
- while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) {
- if (!returnFlag) _xCtr = 0;
+ if (!skipToFinalStep) {
+ // Major loop to populate data
+ _cellPopulated = false;
- while (returnFlag || (_xCtr < ROOM_PATHS_WIDTH)) {
- if (!returnFlag) {
- processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH +
- (_xChangeStart + _xCtr * _xChangeInc)]);
- if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED;
- } else {
- returnFlag = false;
+ while (1) {
+ // Loop through to process cells in the given area
+ if (!returnFlag) _yCtr = 0;
+ while (returnFlag || (_yCtr < ROOM_PATHS_HEIGHT)) {
+ if (!returnFlag) _xCtr = 0;
+
+ while (returnFlag || (_xCtr < ROOM_PATHS_WIDTH)) {
+ if (!returnFlag) {
+ processCell(&_layer[(_yChangeStart + _yCtr * _yChangeInc) * DECODED_PATHS_WIDTH +
+ (_xChangeStart + _xCtr * _xChangeInc)]);
+ if (breakFlag && (_countdownCtr <= 0)) return PF_UNFINISHED;
+ } else {
+ returnFlag = false;
+ }
+ ++_xCtr;
}
- ++_xCtr;
+ ++_yCtr;
}
- ++_yCtr;
- }
- // If the destination cell has been filled in, then break out of loop
- if (*_pDest != 0) break;
+ // If the destination cell has been filled in, then break out of loop
+ if (*_pDest != 0) break;
- if (_cellPopulated) {
- // At least one cell populated, so go repeat loop
- _cellPopulated = false;
- } else {
- result = PF_PART_PATH;
- scanFlag = true;
- break;
+ if (_cellPopulated) {
+ // At least one cell populated, so go repeat loop
+ _cellPopulated = false;
+ } else {
+ result = PF_PART_PATH;
+ scanFlag = true;
+ break;
+ }
}
- }
- _inProgress = false;
+ _inProgress = false;
- if (scanFlag || _destOccupied) {
- // Adjust the end point if necessary to stop character walking into occupied area
+ if (scanFlag || _destOccupied) {
+ // Adjust the end point if necessary to stop character walking into occupied area
- // Restore destination's occupied state if necessary
- if (_destOccupied) {
- *_pDest = 0xffff;
- _destOccupied = false;
- }
+ // Restore destination's occupied state if necessary
+ if (_destOccupied) {
+ *_pDest = 0xffff;
+ _destOccupied = false;
+ }
- // Scan through lines
- v = 0xff;
- pTemp = _pDest;
- scanLine(_destX, -1, pTemp, v);
- scanLine(ROOM_PATHS_WIDTH - _destX, 1, pTemp, v);
- scanLine(_destY, -DECODED_PATHS_WIDTH, pTemp, v);
- scanLine(ROOM_PATHS_HEIGHT - _destY, DECODED_PATHS_WIDTH, pTemp, v);
+ // Scan through lines
+ v = 0xff;
+ pTemp = _pDest;
+ scanLine(_destX, -1, pTemp, v);
+ scanLine(ROOM_PATHS_WIDTH - _destX, 1, pTemp, v);
+ scanLine(_destY, -DECODED_PATHS_WIDTH, pTemp, v);
+ scanLine(ROOM_PATHS_HEIGHT - _destY, DECODED_PATHS_WIDTH, pTemp, v);
+
+ if (pTemp == _pDest) {
+ clear();
+ return PF_NO_WALK;
+ }
- if (pTemp == _pDest) {
- clear();
- return PF_NO_WALK;
+ _pDest = pTemp;
}
- _pDest = pTemp;
- }
-
- // ****DEBUG****
- if (_hotspot->hotspotId() == PLAYER_ID) {
- for (int ctr = 0; ctr < DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT; ++ctr)
- Room::getReference().tempLayer[ctr] = _layer[ctr];
- }
+ // ****DEBUG****
+ if (_hotspot->hotspotId() == PLAYER_ID) {
+ for (int ctr = 0; ctr < DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT; ++ctr)
+ Room::getReference().tempLayer[ctr] = _layer[ctr];
+ }
- // Determine the walk path by working backwards from the destination, adding in the
- // walking steps in reverse order until source is reached
- int stageCtr;
- for (stageCtr = 0; stageCtr < 3; ++stageCtr) {
- // Clear out any previously determined directions
- clear();
+ // Determine the walk path by working backwards from the destination, adding in the
+ // walking steps in reverse order until source is reached
+ int stageCtr;
+ for (stageCtr = 0; stageCtr < 3; ++stageCtr) {
+ // Clear out any previously determined directions
+ clear();
- altFlag = stageCtr == 1;
- pCurrent = _pDest;
+ altFlag = stageCtr == 1;
+ pCurrent = _pDest;
+
+ numSteps = 0;
+ currDirection = NO_DIRECTION;
+ while (1) {
+ v = *pCurrent - 1;
+ if (v == 0) break;
+
+ newDirection = NO_DIRECTION;
+ if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) {
+ // Standard order direction checking
+ if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
+ else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
+ else if (*(pCurrent + 1) == v) newDirection = LEFT;
+ else if (*(pCurrent - 1) == v) newDirection = RIGHT;
+ } else {
+ // Alternate order direction checking
+ if (*(pCurrent + 1) == v) newDirection = LEFT;
+ else if (*(pCurrent - 1) == v) newDirection = RIGHT;
+ else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
+ else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
+ }
+ if (newDirection == NO_DIRECTION)
+ error("Path finding process failed");
- numSteps = 0;
- currDirection = NO_DIRECTION;
- while (1) {
- v = *pCurrent - 1;
- if (v == 0) break;
-
- newDirection = NO_DIRECTION;
- if (!altFlag && (currDirection != LEFT) && (currDirection != RIGHT)) {
- // Standard order direction checking
- if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
- else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
- else if (*(pCurrent + 1) == v) newDirection = LEFT;
- else if (*(pCurrent - 1) == v) newDirection = RIGHT;
- } else {
- // Alternate order direction checking
- if (*(pCurrent + 1) == v) newDirection = LEFT;
- else if (*(pCurrent - 1) == v) newDirection = RIGHT;
- else if (*(pCurrent - DECODED_PATHS_WIDTH) == v) newDirection = DOWN;
- else if (*(pCurrent + DECODED_PATHS_WIDTH) == v) newDirection = UP;
- }
- if (newDirection == NO_DIRECTION)
- error("Path finding process failed");
+ // Process for the specified direction
+ if (newDirection != currDirection) add(newDirection, 0);
- // Process for the specified direction
- if (newDirection != currDirection) add(newDirection, 0);
+ switch (newDirection) {
+ case UP:
+ pCurrent += DECODED_PATHS_WIDTH;
+ break;
- switch (newDirection) {
- case UP:
- pCurrent += DECODED_PATHS_WIDTH;
- break;
+ case DOWN:
+ pCurrent -= DECODED_PATHS_WIDTH;
+ break;
- case DOWN:
- pCurrent -= DECODED_PATHS_WIDTH;
- break;
+ case LEFT:
+ ++pCurrent;
+ break;
- case LEFT:
- ++pCurrent;
- break;
+ case RIGHT:
+ --pCurrent;
+ break;
- case RIGHT:
- --pCurrent;
- break;
+ default:
+ break;
+ }
- default:
- break;
+ ++numSteps;
+ top().rawSteps() += 8;
+ currDirection = newDirection;
}
- ++numSteps;
- top().rawSteps() += 8;
- currDirection = newDirection;
+ if (stageCtr == 0)
+ // Save the number of steps needed
+ savedSteps = numSteps;
+ if ((stageCtr == 1) && (numSteps <= savedSteps))
+ // Less steps were needed, so break out
+ break;
}
- if (stageCtr == 0)
- // Save the number of steps needed
- savedSteps = numSteps;
- if ((stageCtr == 1) && (numSteps <= savedSteps))
- // Less steps were needed, so break out
- break;
- }
-
- // Add final movement if necessary
+ // Add final movement if necessary
- if (result == PF_OK) {
- if (_xDestPos < 0)
- addBack(LEFT, -_xDestPos);
- else if (_xDestPos > 0)
- addBack(RIGHT, _xDestPos);
+ if (result == PF_OK) {
+ if (_xDestPos < 0)
+ addBack(LEFT, -_xDestPos);
+ else if (_xDestPos > 0)
+ addBack(RIGHT, _xDestPos);
+ }
}
-final_step:
+ // Final Step
if (_xPos < 0) add(RIGHT, -_xPos);
else if (_xPos > 0) add(LEFT, _xPos);
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 9919471c76..61de2bf165 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -515,7 +515,9 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
r.top = Surface::textY();
r.bottom = s->height() - Surface::textY() + 1;
- for (;;) {
+ bool bailOut = false;
+
+ while (!bailOut) {
if (refreshFlag) {
// Set up the contents of the menu
s->fillRect(r, bgColor);
@@ -546,8 +548,8 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
while (e.pollEvent()) {
if (engine.shouldQuit()) {
selectedIndex = 0xffff;
- goto bail_out;
-
+ bailOut = true;
+ break;
} else if (e.type() == Common::EVENT_WHEELUP) {
// Scroll upwards
if (selectedIndex > 0) {
@@ -571,10 +573,12 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
++selectedIndex;
refreshFlag = true;
} else if ((keycode == Common::KEYCODE_RETURN) || (keycode == Common::KEYCODE_KP_ENTER)) {
- goto bail_out;
+ bailOut = true;
+ break;
} else if (keycode == Common::KEYCODE_ESCAPE) {
selectedIndex = 0xffff;
- goto bail_out;
+ bailOut = true;
+ break;
}
#ifdef LURE_CLICKABLE_MENUS
@@ -586,46 +590,51 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
if (r.contains(x, y)) {
selectedIndex = (y - r.top) / FONT_HEIGHT;
if (e.type() == Common::EVENT_LBUTTONDOWN)
- goto bail_out;
+ bailOut = true;
+ break;
}
#else
} else if ((e.type() == Common::EVENT_LBUTTONDOWN) ||
(e.type() == Common::EVENT_MBUTTONDOWN)) {
//mouse.waitForRelease();
- goto bail_out;
+ bailOut = true;
+ break;
#endif
} else if (e.type() == Common::EVENT_RBUTTONDOWN) {
mouse.waitForRelease();
selectedIndex = 0xffff;
- goto bail_out;
+ bailOut = true;
+ break;
}
}
+ if (!bailOut) {
#ifndef LURE_CLICKABLE_MENUS
- // Warping the mouse to "neutral" even if the top/bottom menu
- // entry has been reached has both pros and cons. It makes the
- // menu behave a bit more sensibly, but it also makes it harder
- // to move the mouse pointer out of the ScummVM window.
-
- if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) {
- if (selectedIndex > 0) {
- --selectedIndex;
- refreshFlag = true;
- }
- mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
- } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) {
- if (selectedIndex < numEntries - 1) {
- ++selectedIndex;
- refreshFlag = true;
+ // Warping the mouse to "neutral" even if the top/bottom menu
+ // entry has been reached has both pros and cons. It makes the
+ // menu behave a bit more sensibly, but it also makes it harder
+ // to move the mouse pointer out of the ScummVM window.
+
+ if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) {
+ if (selectedIndex > 0) {
+ --selectedIndex;
+ refreshFlag = true;
+ }
+ mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
+ } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) {
+ if (selectedIndex < numEntries - 1) {
+ ++selectedIndex;
+ refreshFlag = true;
+ }
+ mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
}
- mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle);
- }
#endif
- system.delayMillis(20);
+ system.delayMillis(20);
+ }
}
-bail_out:
+ // bailOut
delete s;
#ifndef LURE_CLICKABLE_MENUS
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp
index fbf9f33b87..6328301233 100644
--- a/engines/lure/res.cpp
+++ b/engines/lure/res.cpp
@@ -408,7 +408,7 @@ byte *Resources::getCursor(uint8 cursorNum) {
if (!LureEngine::getReference().isEGA())
return _cursors->data() + (cursorNum * CURSOR_SIZE);
- Common::set_to(&_cursor[0], &_cursor[0] + CURSOR_SIZE, 0);
+ Common::fill(&_cursor[0], &_cursor[0] + CURSOR_SIZE, 0);
byte *pSrc = _cursors->data() + (cursorNum * 64);
byte *pDest = &_cursor[0];
diff --git a/engines/lure/room.cpp b/engines/lure/room.cpp
index 2cb871d73f..219ed0263d 100644
--- a/engines/lure/room.cpp
+++ b/engines/lure/room.cpp
@@ -43,7 +43,7 @@ RoomLayer::RoomLayer(uint16 screenId, bool backgroundLayer):
int cellIndex = 0;
// Reset all the cells to unused
- Common::set_to((uint8 *) _cells, (uint8 *) _cells + GRID_SIZE, 0xff);
+ Common::fill((uint8 *) _cells, (uint8 *) _cells + GRID_SIZE, 0xff);
// Load up the screen data
MemoryBlock *rawData = disk.getEntry(screenId);
diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp
index 22656dd3fe..df2f06df96 100644
--- a/engines/lure/scripts.cpp
+++ b/engines/lure/scripts.cpp
@@ -499,7 +499,7 @@ void Script::fixGoewin(uint16 v1, uint16 v2, uint16 v3) {
hotspot->currentActions().clear();
hotspot->currentActions().addFront(DISPATCH_ACTION, entry, hotspot->roomNumber());
- hotspot->setActions(hotspot->resource()->actions & !(1 << (TELL - 1)));
+ hotspot->setActions(hotspot->resource()->actions & ~(1 << (TELL - 1)));
hotspot->setActionCtr(0);
hotspot->setDelayCtr(0);
hotspot->setCharacterMode(CHARMODE_NONE);
diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 85b86a8400..bf0abdea07 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -53,7 +53,7 @@ SoundManager::SoundManager() {
_isRoland = MidiDriver::getMusicType(dev) != MT_ADLIB;
_nativeMT32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32"));
- Common::set_to(_channelsInUse, _channelsInUse + NUM_CHANNELS, false);
+ Common::fill(_channelsInUse, _channelsInUse + NUM_CHANNELS, false);
_driver = MidiDriver::createMidi(dev);
int statusCode = _driver->open();
@@ -182,7 +182,7 @@ void SoundManager::killSounds() {
// Clear the active sounds
_activeSounds.clear();
- Common::set_to(_channelsInUse, _channelsInUse + NUM_CHANNELS, false);
+ Common::fill(_channelsInUse, _channelsInUse + NUM_CHANNELS, false);
}
void SoundManager::addSound(uint8 soundIndex, bool tidyFlag) {
@@ -221,7 +221,7 @@ void SoundManager::addSound(uint8 soundIndex, bool tidyFlag) {
}
// Mark the found channels as in use
- Common::set_to(_channelsInUse+channelCtr, _channelsInUse+channelCtr + numChannels, true);
+ Common::fill(_channelsInUse+channelCtr, _channelsInUse+channelCtr + numChannels, true);
SoundDescResource *newEntry = new SoundDescResource();
newEntry->soundNumber = rec.soundNumber;
@@ -342,7 +342,7 @@ void SoundManager::tidySounds() {
++i;
else {
// Mark the channels that it used as now being free
- Common::set_to(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, false);
+ Common::fill(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, false);
i = _activeSounds.erase(i);
}
@@ -373,7 +373,7 @@ void SoundManager::restoreSounds() {
SoundDescResource *rec = (*i).get();
if ((rec->numChannels != 0) && ((rec->flags & SF_RESTORE) != 0)) {
- Common::set_to(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, true);
+ Common::fill(_channelsInUse+rec->channel, _channelsInUse+rec->channel+rec->numChannels, true);
musicInterface_Play(rec->soundNumber, rec->channel, rec->numChannels);
musicInterface_SetVolume(rec->channel, rec->volume);
@@ -635,7 +635,7 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
for (uint i = 0; i < packedSize; i++)
#if defined(SCUMM_NEED_ALIGNMENT)
- memcpy(dataDest++, (byte*)((byte*)data + *(idx + i) * sizeof(uint16)), sizeof(uint16));
+ memcpy(dataDest++, (byte *)((byte *)data + *(idx + i) * sizeof(uint16)), sizeof(uint16));
#else
*dataDest++ = data[*(idx + i)];
#endif