aboutsummaryrefslogtreecommitdiff
path: root/engines/lure
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/lure
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/lure')
-rw-r--r--engines/lure/decode.cpp323
-rw-r--r--engines/lure/detection.cpp20
-rw-r--r--engines/lure/hotspots.cpp1
-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.cpp10
7 files changed, 190 insertions, 170 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 081625863d..ab7615c265 100644
--- a/engines/lure/detection.cpp
+++ b/engines/lure/detection.cpp
@@ -63,8 +63,6 @@ static const PlainGameDescriptor lureGames[] = {
namespace Lure {
-using Common::GUIO_NONE;
-
static const LureGameDescription gameDescriptions[] = {
{
{
@@ -74,7 +72,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -87,7 +85,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY | GF_EGA,
},
@@ -100,7 +98,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -113,7 +111,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY | GF_EGA,
},
@@ -126,7 +124,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -139,7 +137,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -152,7 +150,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -165,7 +163,7 @@ static const LureGameDescription gameDescriptions[] = {
Common::ES_ESP,
Common::kPlatformPC,
ADGF_NO_FLAGS,
- GUIO_NONE
+ GUIO0()
},
GF_FLOPPY,
},
@@ -184,7 +182,7 @@ public:
// Use kADFlagUseExtraAsHint to distinguish between EGA and VGA versions
// of italian Lure when their datafiles sit in the same directory.
_flags = kADFlagUseExtraAsHint;
- _guioptions = Common::GUIO_NOSPEECH;
+ _guioptions = GUIO1(GUIO_NOSPEECH);
}
virtual const char *getName() const {
diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp
index 96e5e088ab..207c125a0c 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;
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..0aecae22ec 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);