aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2007-12-09 05:57:08 +0000
committerPaul Gilbert2007-12-09 05:57:08 +0000
commita39ddab09a3738199984f1e286b19fe83b7b4a05 (patch)
tree23e5e6c93102b236447a3756cc086fd3a7364910
parent3980bd73ea7a00de469ae64d90485dcd197689fa (diff)
downloadscummvm-rg350-a39ddab09a3738199984f1e286b19fe83b7b4a05.tar.gz
scummvm-rg350-a39ddab09a3738199984f1e286b19fe83b7b4a05.tar.bz2
scummvm-rg350-a39ddab09a3738199984f1e286b19fe83b7b4a05.zip
Added new debug category for string handling
svn-id: r29772
-rw-r--r--engines/lure/lure.cpp1
-rw-r--r--engines/lure/luredefs.h3
-rw-r--r--engines/lure/strings.cpp32
-rw-r--r--engines/lure/strings.h1
-rw-r--r--engines/lure/surface.cpp5
-rw-r--r--engines/lure/surface.h2
6 files changed, 34 insertions, 10 deletions
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index 92954d6e31..e65855420b 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -47,6 +47,7 @@ LureEngine::LureEngine(OSystem *system, const LureGameDescription *gameDesc): En
Common::addSpecialDebugLevel(kLureDebugHotspots, "hotspots", "Hotspots debugging");
Common::addSpecialDebugLevel(kLureDebugFights, "fights", "Fights debugging");
Common::addSpecialDebugLevel(kLureDebugSounds, "sounds", "Sounds debugging");
+ Common::addSpecialDebugLevel(kLureDebugStrings, "strings", "Strings debugging");
// Setup mixer
diff --git a/engines/lure/luredefs.h b/engines/lure/luredefs.h
index b6ae2dafa8..876984e817 100644
--- a/engines/lure/luredefs.h
+++ b/engines/lure/luredefs.h
@@ -47,7 +47,8 @@ enum {
kLureDebugAnimations = 1 << 1,
kLureDebugHotspots = 1 << 2,
kLureDebugFights = 1 << 3,
- kLureDebugSounds = 1 << 4
+ kLureDebugSounds = 1 << 4,
+ kLureDebugStrings = 1 << 5
};
#define ERROR_BASIC 1
diff --git a/engines/lure/strings.cpp b/engines/lure/strings.cpp
index 1436b92fb8..294c48159b 100644
--- a/engines/lure/strings.cpp
+++ b/engines/lure/strings.cpp
@@ -103,7 +103,6 @@ byte StringData::readBit() {
bool StringData::initPosition(uint16 stringId) {
uint16 roomNumber = Room::getReference().roomNumber();
- byte *stringTable;
if ((roomNumber >= 0x2A) && (stringId >= STRING_ID_RANGE) && (stringId < STRING_ID_UPPER))
stringId = 0x76;
@@ -111,16 +110,16 @@ bool StringData::initPosition(uint16 stringId) {
stringId = 0x76;
if (stringId < STRING_ID_RANGE)
- stringTable = _strings[0]->data();
+ _stringTable = _strings[0]->data();
else if (stringId < STRING_ID_RANGE*2) {
stringId -= STRING_ID_RANGE;
- stringTable = _strings[1]->data();
+ _stringTable = _strings[1]->data();
} else {
stringId -= STRING_ID_RANGE * 2;
- stringTable = _strings[2]->data();
+ _stringTable = _strings[2]->data();
}
- _srcPos = stringTable + 4;
+ _srcPos = _stringTable + 4;
uint32 total = 0;
int numLoops = stringId >> 5;
@@ -131,7 +130,7 @@ bool StringData::initPosition(uint16 stringId) {
numLoops = stringId & 0x1f;
if (numLoops!= 0) {
- byte *tempPtr = stringTable + (stringId & 0xffe0) + READ_LE_UINT16(stringTable);
+ byte *tempPtr = _stringTable + (stringId & 0xffe0) + READ_LE_UINT16(_stringTable);
for (int ctr = 0; ctr < numLoops; ++ctr) {
byte v = *tempPtr++;
@@ -148,7 +147,7 @@ bool StringData::initPosition(uint16 stringId) {
if ((total & 3) != 0)
_bitMask >>= (total & 3) * 2;
- _srcPos = stringTable + (total >> 2) + READ_LE_UINT16(stringTable + 2);
+ _srcPos = _stringTable + (total >> 2) + READ_LE_UINT16(_stringTable + 2);
// Final positioning to start of string
for (;;) {
@@ -172,7 +171,7 @@ char StringData::readCharacter() {
// Scan through list for a match
for (int index = 0; _chars[index] != NULL; ++index) {
if ((_chars[index]->_numBits == numBits) &&
- (_chars[index]->_sequence == searchValue))
+ (_chars[index]->_sequence == searchValue))
return _chars[index]->_ascii;
}
}
@@ -184,6 +183,9 @@ char StringData::readCharacter() {
void StringData::getString(uint16 stringId, char *dest, const char *hotspotName,
const char *characterName, int hotspotArticle, int characterArticle) {
+ debugC(ERROR_INTERMEDIATE, kLureDebugStrings,
+ "StringData::getString stringId=%xh hotspot=%d,%s character=%d,%s",
+ stringId, hotspotArticle, hotspotName, characterArticle, characterName);
StringList &stringList = Resources::getReference().stringList();
char ch;
strcpy(dest, "");
@@ -192,8 +194,11 @@ void StringData::getString(uint16 stringId, char *dest, const char *hotspotName,
if (stringId == 0) return;
bool includeArticles = initPosition(stringId);
+ uint32 charOffset = _srcPos - _stringTable;
+ uint8 charBitMask = _bitMask;
ch = readCharacter();
+
while (ch != '\0') {
if (ch == '%') {
// Copy over hotspot or action
@@ -209,18 +214,29 @@ void StringData::getString(uint16 stringId, char *dest, const char *hotspotName,
strcpy(destPos, p);
}
destPos += strlen(destPos);
+
+ debugC(ERROR_DETAILED, kLureDebugStrings, "String data %xh/%.2xh val=%.2xh name=%s",
+ charOffset, charBitMask, ch, p);
}
} else if ((uint8) ch >= 0xa0) {
const char *p = getName((uint8) ch - 0xa0);
strcpy(destPos, p);
destPos += strlen(p);
+ debugC(ERROR_DETAILED, kLureDebugStrings, "String data %xh/%.2xh val=%.2xh sequence='%s'",
+ charOffset, charBitMask, (uint8)ch, p);
} else {
*destPos++ = ch;
+ debugC(ERROR_DETAILED, kLureDebugStrings, "String data %xh/%.2xh val=%.2xh char=%c",
+ charOffset, charBitMask, ch, ch);
}
+ charOffset = _srcPos - _stringTable;
+ charBitMask = _bitMask;
ch = readCharacter();
}
+ debugC(ERROR_DETAILED, kLureDebugStrings, "String data %xh/%.2xh val=%.2xh EOS",
+ charOffset, charBitMask, ch);
*destPos = '\0';
}
diff --git a/engines/lure/strings.h b/engines/lure/strings.h
index 554a665dc0..1d6203995d 100644
--- a/engines/lure/strings.h
+++ b/engines/lure/strings.h
@@ -50,6 +50,7 @@ private:
CharacterEntry *_chars[MAX_NUM_CHARS];
uint8 _numChars;
byte *_srcPos;
+ byte *_stringTable;
byte _bitMask;
void add(const char *sequence, char ascii);
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 81ed955e5b..7bde6bb217 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -42,7 +42,7 @@ namespace Lure {
static MemoryBlock *int_font = NULL;
static MemoryBlock *int_dialog_frame = NULL;
static uint8 fontSize[256];
-static int numFontChars;
+int numFontChars;
void Surface::initialise() {
int_font = Disk::getReference().getEntry(FONT_RESOURCE_ID);
@@ -486,6 +486,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool
/*--------------------------------------------------------------------------*/
void Dialog::show(const char *text) {
+ debugC(ERROR_BASIC, kLureDebugStrings, "Dialog::show text=%s", text);
Screen &screen = Screen::getReference();
Mouse &mouse = Mouse::getReference();
Room &room = Room::getReference();
@@ -505,6 +506,8 @@ void Dialog::show(const char *text) {
}
void Dialog::show(uint16 stringId, const char *hotspotName, const char *characterName) {
+ debugC(ERROR_BASIC, kLureDebugStrings, "Hotspot::showMessage stringId=%xh hotspot=%s, character=%s",
+ stringId, hotspotName, characterName);
char buffer[MAX_DESC_SIZE];
StringData &sl = StringData::getReference();
diff --git a/engines/lure/surface.h b/engines/lure/surface.h
index 5bbd21054a..e8066de4a1 100644
--- a/engines/lure/surface.h
+++ b/engines/lure/surface.h
@@ -135,6 +135,8 @@ public:
bool show();
};
+extern int numFontChars;
+
} // End of namespace Lure
#endif