aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--queen/cutaway.cpp11
-rw-r--r--queen/graphics.cpp20
-rw-r--r--queen/logic.cpp55
-rw-r--r--queen/queen.cpp2
-rw-r--r--queen/resource.cpp26
-rw-r--r--queen/resource.h2
-rw-r--r--queen/talk.cpp12
7 files changed, 47 insertions, 81 deletions
diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp
index bb12e390f6..495c41dfad 100644
--- a/queen/cutaway.cpp
+++ b/queen/cutaway.cpp
@@ -114,7 +114,7 @@ void Cutaway::load(const char *filename) {
byte *bankNamesPtr = _fileData + READ_BE_UINT16(ptr);
ptr += 2;
- //debug(6, "Bank name file offset = %08x", 20 + bankNamesPtr - _fileData);
+ debug(6, "Bank name file offset = %08x", 20 + bankNamesPtr - _fileData);
_objectData = ptr;
@@ -159,7 +159,7 @@ void Cutaway::loadStrings(byte *ptr) {
int bankNameCount = READ_BE_UINT16(ptr);
ptr += 2;
- //debug(6, "Bank name count = %i", bankNameCount);
+ debug(6, "Bank name count = %i", bankNameCount);
/*
The _bankNames zero-based array is the one-based BANK_NAMEstr array in
@@ -170,7 +170,7 @@ void Cutaway::loadStrings(byte *ptr) {
ptr = Talk::getString(ptr, _bankNames[j], MAX_FILENAME_LENGTH);
if (_bankNames[j][0]) {
- //debug(6, "Bank name %i = '%s'", j, _bankNames[j]);
+ debug(6, "Bank name %i = '%s'", j, _bankNames[j]);
j++;
}
}
@@ -272,7 +272,7 @@ byte *Cutaway::turnOnPeople(byte *ptr, CutawayObject &object) {
for (int i = 0; i < object.personCount; i++) {
object.person[i] = (int16)READ_BE_INT16(ptr);
ptr += 2;
- //debug(6, "[%i] Turn on person %i", i, object.person[i]);
+ debug(7, "[%i] Turn on person %i", i, object.person[i]);
}
return ptr;
@@ -726,13 +726,10 @@ byte *Cutaway::handleAnimation(byte *ptr, CutawayObject &object) {
}
static void findCdCut(const char *basename, int index, char *result) {
- // Function find_cd_cut, lines 5-15 in execute.c
-
strcpy(result, basename);
for (int i = strlen(basename); i < 5; i++)
result[i] = '_';
snprintf(result + 5, 3, "%02i", index);
- //debug(6, "findCdCut(\"%s\", %i, \"%s\")", basename, index, result);
}
void Cutaway::handlePersonRecord(
diff --git a/queen/graphics.cpp b/queen/graphics.cpp
index a9dcebfd6b..737ba2b850 100644
--- a/queen/graphics.cpp
+++ b/queen/graphics.cpp
@@ -190,6 +190,11 @@ void BobSlot::clear() {
box = _defaultBox;
}
+static int compareBobDrawOrder(const void *a, const void *b) {
+ const BobSlot *bob1 = *(const BobSlot * const *)a;
+ const BobSlot *bob2 = *(const BobSlot * const *)b;
+ return bob1->y - bob2->y;
+}
const Box Graphics::_gameScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, ROOM_ZONE_HEIGHT - 1);
const Box Graphics::_fullScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, GAME_SCREEN_HEIGHT - 1);
@@ -333,7 +338,6 @@ void Graphics::sortBobs() {
// animate/move the bobs
for (int32 i = 0; i < ARRAYSIZE(_bobs); ++i) {
-
BobSlot *pbs = &_bobs[i];
if (pbs->active) {
_sortedBobs[_sortedBobsCount] = pbs;
@@ -354,19 +358,7 @@ void Graphics::sortBobs() {
}
}
}
-
- // bubble sort the bobs
- for (int32 index = 0; index < _sortedBobsCount - 1; ++index) {
- int32 smallest = index;
- for (int32 compare = index + 1; compare <= _sortedBobsCount - 1; ++compare) {
- if (_sortedBobs[compare]->y < _sortedBobs[smallest]->y) {
- smallest = compare;
- }
- }
- if (index != smallest) {
- SWAP(_sortedBobs[index], _sortedBobs[smallest]);
- }
- }
+ qsort(_sortedBobs, _sortedBobsCount, sizeof(BobSlot *), compareBobDrawOrder);
}
void Graphics::drawBobs() {
diff --git a/queen/logic.cpp b/queen/logic.cpp
index ecb05f7530..9fc480d5f2 100644
--- a/queen/logic.cpp
+++ b/queen/logic.cpp
@@ -1247,7 +1247,7 @@ void Logic::handlePinnacleRoom() {
struct {
uint16 obj;
int16 song;
- } songs[] = {
+ } cmds[] = {
{ 0x2A, 3 },
{ 0x29, 16 },
{ 0x2F, 6 },
@@ -1255,9 +1255,9 @@ void Logic::handlePinnacleRoom() {
{ 0x2B, 3 },
{ 0x30, 3 }
};
- for (int i = 0; i < ARRAYSIZE(songs); ++i) {
- if (songs[i].obj == prevObj) {
- _vm->sound()->playSong(songs[i].song);
+ for (int i = 0; i < ARRAYSIZE(cmds); ++i) {
+ if (cmds[i].obj == prevObj) {
+ _vm->sound()->playSong(cmds[i].song);
}
}
@@ -1852,7 +1852,7 @@ void Logic::asmPanRightToHugh() {
_vm->input()->fastMode(true);
_vm->update();
- int i = 4, k = 160;
+ int k = 160;
// Adjust thug1 gun so it matches rest of body
bob_thugA1->x += (k / 2) * 2 - 45;
@@ -1866,32 +1866,25 @@ void Logic::asmPanRightToHugh() {
bob_thugB1->x += (k / 2) * 4 + k;
bob_thugB2->x += (k / 2) * 4 + k;
- if (i == 3) {
- bob_thugB1->x += 10;
- bob_thugB2->x += 10;
- }
-
- i *= 2;
-
int horizontalScroll = 0;
while (horizontalScroll < k && !_vm->input()->cutawayQuit()) {
- horizontalScroll = horizontalScroll + i;
+ horizontalScroll += 8;
if (horizontalScroll > k)
horizontalScroll = k;
_vm->display()->horizontalScroll(horizontalScroll);
- bob_thugA1->x -= i * 2;
- bob_thugA2->x -= i * 2;
- bob_thugA3->x -= i * 2;
+ bob_thugA1->x -= 16;
+ bob_thugA2->x -= 16;
+ bob_thugA3->x -= 16;
- bob_hugh1->x -= i * 3;
- bob_hugh2->x -= i * 3;
- bob_hugh3->x -= i * 3;
+ bob_hugh1->x -= 24;
+ bob_hugh2->x -= 24;
+ bob_hugh3->x -= 24;
- bob_thugB1->x -= i * 4;
- bob_thugB2->x -= i * 4;
+ bob_thugB1->x -= 32;
+ bob_thugB2->x -= 32;
_vm->update();
}
@@ -1921,20 +1914,19 @@ void Logic::asmPanRightToJoeAndRita() { // cdint.cut
int horizontalScroll = _vm->display()->horizontalScroll();
- int i = 1;
while (horizontalScroll < 290 && !_vm->input()->cutawayQuit()) {
- horizontalScroll = horizontalScroll + i;
+ ++horizontalScroll;
if (horizontalScroll > 290)
horizontalScroll = 290;
_vm->display()->horizontalScroll(horizontalScroll);
- bob_box ->x -= i * 2;
- bob_beam ->x -= i;
- bob_crate->x -= i * 3;
- bob_clock->x -= i * 2;
- bob_hands->x -= i * 2;
+ bob_box ->x -= 2;
+ bob_beam ->x -= 1;
+ bob_crate->x -= 3;
+ bob_clock->x -= 2;
+ bob_hands->x -= 2;
_vm->update();
}
@@ -1950,19 +1942,18 @@ void Logic::asmPanLeftToBomb() {
int horizontalScroll = _vm->display()->horizontalScroll();
- int i = 5;
while ((horizontalScroll > 0 || bob21->x < 136) && !_vm->input()->cutawayQuit()) {
- horizontalScroll -= i;
+ horizontalScroll -= 5;
if (horizontalScroll < 0)
horizontalScroll = 0;
_vm->display()->horizontalScroll(horizontalScroll);
if (horizontalScroll < 272 && bob21->x < 136)
- bob21->x += (i/2);
+ bob21->x += 2;
- bob22->x += i;
+ bob22->x += 5;
_vm->update();
}
diff --git a/queen/queen.cpp b/queen/queen.cpp
index 52462db749..2acd2bc487 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -227,7 +227,7 @@ void QueenEngine::saveGameState(uint16 slot, const char *desc) {
if (file->write(saveData, dataSize) != dataSize) {
warning("Can't write file '%s'. (Disk full?)", name);
}
- delete saveData;
+ delete[] saveData;
delete file;
} else {
warning("Can't create file '%s', game not saved", name);
diff --git a/queen/resource.cpp b/queen/resource.cpp
index 58c3ccaf7d..45897e90be 100644
--- a/queen/resource.cpp
+++ b/queen/resource.cpp
@@ -47,9 +47,9 @@ const GameVersion Resource::_gameVersions[] = {
};
static int compareResourceEntry(const void *a, const void *b) {
- const char *key = (const char *)a;
+ const char *filename = (const char *)a;
const ResourceEntry *entry = (const ResourceEntry *)b;
- return strcmp(key, entry->filename);
+ return strcmp(filename, entry->filename);
}
Resource::Resource(const Common::String &datafilePath)
@@ -84,14 +84,6 @@ ResourceEntry *Resource::resourceEntry(const char *filename) const {
re = (ResourceEntry *)bsearch(entryName, _resourceTable, _resourceEntries, sizeof(ResourceEntry), compareResourceEntry);
#else
// cyx: is that code still necessary ?
- uint32 low = 0;
- uint32 high = _resourceEntries - 1;
-
- if (!strcmp(entryName, _resourceTable[low].filename))
- return low;
- if (!strcmp(entryName, _resourceTable[high].filename))
- return high;
-
// Does work for me (????) use this instead
uint32 cur = 0;
do {
@@ -99,7 +91,7 @@ ResourceEntry *Resource::resourceEntry(const char *filename) const {
re = &_resourceTable[cur];
break;
}
- } while (cur++ <= high);
+ } while (cur++ < _resourceEntries);
#endif
debug(7, "Couldn't find file '%s'", entryName);
@@ -163,7 +155,9 @@ bool Resource::findCompressedVersion() {
}
void Resource::checkJASVersion() {
- int32 offset = resourceEntry("QUEEN.JAS")->offset;
+ ResourceEntry *re = resourceEntry("QUEEN.JAS");
+ assert(re != NULL);
+ uint32 offset = re->offset;
if (isDemo())
offset += JAS_VERSION_OFFSET_DEMO;
else if (isInterview())
@@ -200,7 +194,7 @@ Language Resource::getLanguage() const {
bool Resource::readTableFile(const GameVersion *gameVersion) {
File tableFile;
tableFile.open(_tableFilename);
- if (tableFile.isOpen() && tableFile.readUint32BE() == 'QTBL') {
+ if (tableFile.isOpen() && tableFile.readUint32BE() == MKID_BE('QTBL')) {
if (tableFile.readUint32BE() != CURRENT_TBL_VERSION)
warning("Incorrect version of queen.tbl, please update it");
tableFile.seek(gameVersion->tableOffset);
@@ -211,7 +205,7 @@ bool Resource::readTableFile(const GameVersion *gameVersion) {
}
void Resource::readTableCompResource() {
- if (_resourceFile->readUint32BE() != 'QTBL')
+ if (_resourceFile->readUint32BE() != MKID_BE('QTBL'))
error("Invalid table header");
_resourceFile->read(_versionString, 6);
@@ -247,7 +241,9 @@ const GameVersion *Resource::detectGameVersion(uint32 size) const {
File *Resource::giveCompressedSound(const char *filename) {
assert(strstr(filename, ".SB"));
- _resourceFile->seek(resourceEntry(filename)->offset);
+ ResourceEntry *re = resourceEntry(filename);
+ assert(re != NULL);
+ _resourceFile->seek(re->offset);
return _resourceFile;
}
diff --git a/queen/resource.h b/queen/resource.h
index ed304840ce..9db232f2d6 100644
--- a/queen/resource.h
+++ b/queen/resource.h
@@ -37,9 +37,7 @@ enum Version {
VER_GER_TALKIE = 5,
VER_ITA_FLOPPY = 6,
VER_ITA_TALKIE = 7,
- // VER_SPA_FLOPPY
VER_SPA_TALKIE = 8,
- // VER_HEB_FLOPPY
VER_HEB_TALKIE = 9,
VER_DEMO_PCGAMES = 10,
VER_DEMO = 11,
diff --git a/queen/talk.cpp b/queen/talk.cpp
index 1d8e2fe21e..4942ee66c0 100644
--- a/queen/talk.cpp
+++ b/queen/talk.cpp
@@ -598,8 +598,8 @@ bool Talk::speak(const char *sentence, Person *person, const char *voiceFilePref
person = &joe_person;
}
- //debug(6, "Sentence '%s' is said by person '%s' and voice files with prefix '%s' played",
- // sentence, person->name, voiceFilePrefix);
+ debug(6, "Sentence '%s' is said by person '%s' and voice files with prefix '%s' played",
+ sentence, person->name, voiceFilePrefix);
if (sentence[0] == '\0') {
goto exit;
@@ -658,7 +658,6 @@ exit:
return personWalking;
}
-// cyx : there is a similar function in Cutaway, what about merging them ?
int Talk::countSpaces(const char *segment) {
int tmp = 0;
@@ -764,7 +763,6 @@ void Talk::defaultAnimation(
int bankNum) {
// lines 1730-1823 in talk.c
-#if 0
debug(6, "Talk::defaultAnimation(\"%s\", %s, {\"%s\", %i, ...}, %i, %i)",
segment,
isJoe ? "true" : "false",
@@ -772,7 +770,6 @@ void Talk::defaultAnimation(
parameters->state,
startFrame,
bankNum);
-#endif
if (segment[0] != 0) {
@@ -859,8 +856,6 @@ void Talk::speakSegment(
const char *voiceFilePrefix,
int index)
{
- // Function SPEAK_SUB, lines 1406-1870 in talk.a
-
int i;
char segment[MAX_STRING_SIZE];
memcpy(segment, segmentStart, length);
@@ -869,9 +864,6 @@ void Talk::speakSegment(
char voiceFileName[MAX_STRING_SIZE];
snprintf(voiceFileName, sizeof(voiceFileName), "%s%1x", voiceFilePrefix, index + 1);
- // debug(6, "Sentence segment '%*s' is said by person '%s' and voice file '%s' is played",
- // length, segment, person->name, voiceFileName);
-
// FIXME - it seems the french talkie version has a useless voice file ;
// the c30e_102 file is very similar to c30e_101, so there is no need to
// play it. This voice was used in room 30 (N8) when talking to Klunk.