Added new debug category for string handling

svn-id: r29772
This commit is contained in:
Paul Gilbert 2007-12-09 05:57:08 +00:00
parent 3980bd73ea
commit a39ddab09a
6 changed files with 34 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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';
}

View File

@ -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);

View File

@ -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();

View File

@ -135,6 +135,8 @@ public:
bool show();
};
extern int numFontChars;
} // End of namespace Lure
#endif