aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-10-17 16:28:29 +0000
committerMax Horn2003-10-17 16:28:29 +0000
commit012450de73cbac232be2f779b14e64e28cbdfb92 (patch)
treedad1ec783716679551148c5024d3fe1094dd64f5 /scumm
parentae6e6a4885e7364d9f96251ca55769dcc84fb237 (diff)
downloadscummvm-rg350-012450de73cbac232be2f779b14e64e28cbdfb92.tar.gz
scummvm-rg350-012450de73cbac232be2f779b14e64e28cbdfb92.tar.bz2
scummvm-rg350-012450de73cbac232be2f779b14e64e28cbdfb92.zip
added tag2str helper function
svn-id: r10866
Diffstat (limited to 'scumm')
-rw-r--r--scumm/resource.cpp27
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/scummvm.cpp10
3 files changed, 18 insertions, 21 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index d42041f991..b3be071cee 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -426,11 +426,7 @@ void ScummEngine::readIndexFile() {
break;
default:
- error("Bad ID %c%c%c%c found in directory!",
- (byte)blocktype,
- (byte)(blocktype >> 8),
- (byte)(blocktype >> 16),
- (byte)(blocktype >> 24));
+ error("Bad ID '%s' found in directory!", tag2str(blocktype));
return;
}
}
@@ -712,10 +708,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
basetag = fileReadDword();
total_size = _fileHandle.readUint32BE();
- debug(8, " basetag: %c%c%c%c, total_size=%d",
- (char)((basetag >> 24) & 0xff),
- (char)((basetag >> 16) & 0xff),
- (char)((basetag >> 8) & 0xff), (char)(basetag & 0xff), total_size);
+ debug(8, " basetag: %s, total_size=%d", tag2str(TO_BE_32(basetag)), total_size);
if (basetag == MKID('MIDI') || basetag == MKID('iMUS')) {
if (_midiDriver != MD_PCSPK && _midiDriver != MD_PCJR) {
@@ -768,9 +761,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
if ((_midiDriver == MD_PCSPK || _midiDriver == MD_PCJR) && pri != 11)
pri = -1;
- debug(8, " tag: %c%c%c%c, total_size=%d, pri=%d",
- (char)((tag >> 24) & 0xff),
- (char)((tag >> 16) & 0xff), (char)((tag >> 8) & 0xff), (char)(tag & 0xff), size, pri);
+ debug(8, " tag: %s, total_size=%d, pri=%d", tag2str(TO_BE_32(tag)), size, pri);
if (pri > best_pri) {
@@ -1034,11 +1025,7 @@ static inline byte Mac0ToGMInstrument(uint32 type, int &transpose) {
case MKID('BONG'): return 115;
case MKID('BASS'): transpose = -24; return 35;
default:
- error("Unknown Mac0 instrument %c%c%c%c found",
- (byte)type,
- (byte)(type >> 8),
- (byte)(type >> 16),
- (byte)(type >> 24));
+ error("Unknown Mac0 instrument %s found", tag2str(type));
}
}
@@ -2311,8 +2298,7 @@ const byte *findResource(uint32 tag, const byte *searchin) {
size = READ_BE_UINT32(searchin + 4);
if ((int32)size <= 0) {
- error("(%c%c%c%c) Not found in %d... illegal block len %d",
- tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
+ error("(%s) Not found in %d... illegal block len %d", tag2str(tag), 0, size);
return NULL;
}
@@ -2344,8 +2330,7 @@ const byte *findResourceSmall(uint32 tag, const byte *searchin) {
return searchin;
if ((int32)size <= 0) {
- error("(%c%c%c%c) Not found in %d... illegal block len %d",
- tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
+ error("(%s) Not found in %d... illegal block len %d", tag2str(tag), 0, size);
return NULL;
}
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 4b233e5ea9..a4aacd9a9b 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -1210,6 +1210,8 @@ int toSimpleDir(int dirtype, int dir);
void checkRange(int max, int min, int no, const char *str);
+const char *tag2str(uint32 tag);
+
} // End of namespace Scumm
#endif
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index f7e322fbee..e647512b35 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -2625,6 +2625,16 @@ int normalizeAngle(int angle) {
return toSimpleDir(1, temp) * 45;
}
+const char *tag2str(uint32 tag) {
+ static char str[5];
+ str[0] = (char)(tag >> 24);
+ str[1] = (char)(tag >> 16);
+ str[2] = (char)(tag >> 8);
+ str[3] = (char)tag;
+ str[4] = '\0';
+ return str;
+}
+
} // End of namespace Scumm
using namespace Scumm;