diff options
Diffstat (limited to 'engines/scumm')
37 files changed, 597 insertions, 565 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 39db47b102..13581c4b45 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -1853,8 +1853,8 @@ void Actor::animateLimb(int limb, int f) { byte *akos = _vm->getResourceAddress(rtCostume, _costume); assert(akos); - aksq = _vm->findResourceData(MKID_BE('AKSQ'), akos); - akfo = _vm->findResourceData(MKID_BE('AKFO'), akos); + aksq = _vm->findResourceData(MKTAG('A','K','S','Q'), akos); + akfo = _vm->findResourceData(MKTAG('A','K','F','O'), akos); size = _vm->getResourceDataSize(akfo) / 2; @@ -2374,7 +2374,7 @@ void Actor::remapActorPaletteColor(int color, int new_color) { return; } - akpl = _vm->findResourceData(MKID_BE('AKPL'), akos); + akpl = _vm->findResourceData(MKTAG('A','K','P','L'), akos); if (!akpl) { debugC(DEBUG_ACTORS, "Actor::remapActorPaletteColor: Can't remap actor %d, costume %d doesn't contain an AKPL block", _number, _costume); return; @@ -2409,7 +2409,7 @@ void Actor::remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold) return; } - akpl = _vm->findResourceData(MKID_BE('AKPL'), akos); + akpl = _vm->findResourceData(MKTAG('A','K','P','L'), akos); if (!akpl) { debugC(DEBUG_ACTORS, "Actor::remapActorPalette: Can't remap actor %d, costume %d doesn't contain an AKPL block", _number, _costume); return; @@ -2418,7 +2418,7 @@ void Actor::remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold) // Get the number palette entries akpl_size = _vm->getResourceDataSize(akpl); - rgbs = _vm->findResourceData(MKID_BE('RGBS'), akos); + rgbs = _vm->findResourceData(MKTAG('R','G','B','S'), akos); if (!rgbs) { debugC(DEBUG_ACTORS, "Actor::remapActorPalette: Can't remap actor %d costume %d doesn't contain an RGB block", _number, _costume); @@ -2535,19 +2535,19 @@ void ScummEngine_v71he::postProcessAuxQueue() { if (_game.heversion >= 72) dy -= a->getElevation(); - const uint8 *akax = findResource(MKID_BE('AKAX'), cost); + const uint8 *akax = findResource(MKTAG('A','K','A','X'), cost); assert(akax); const uint8 *auxd = findPalInPals(akax, ae->subIndex) - _resourceHeaderSize; assert(auxd); - const uint8 *frel = findResourceData(MKID_BE('FREL'), auxd); + const uint8 *frel = findResourceData(MKTAG('F','R','E','L'), auxd); if (frel) { error("unhandled FREL block"); } - const uint8 *disp = findResourceData(MKID_BE('DISP'), auxd); + const uint8 *disp = findResourceData(MKTAG('D','I','S','P'), auxd); if (disp) { error("unhandled DISP block"); } - const uint8 *axfd = findResourceData(MKID_BE('AXFD'), auxd); + const uint8 *axfd = findResourceData(MKTAG('A','X','F','D'), auxd); assert(axfd); uint16 comp = READ_LE_UINT16(axfd); @@ -2567,7 +2567,7 @@ void ScummEngine_v71he::postProcessAuxQueue() { error("unimplemented compression type %d", comp); } } - const uint8 *axur = findResourceData(MKID_BE('AXUR'), auxd); + const uint8 *axur = findResourceData(MKTAG('A','X','U','R'), auxd); if (axur) { uint16 n = READ_LE_UINT16(axur); axur += 2; while (n--) { @@ -2579,7 +2579,7 @@ void ScummEngine_v71he::postProcessAuxQueue() { axur += 8; } } - const uint8 *axer = findResourceData(MKID_BE('AXER'), auxd); + const uint8 *axer = findResourceData(MKTAG('A','X','E','R'), auxd); if (axer) { a->_auxBlock.visible = true; a->_auxBlock.r.left = (int16)READ_LE_UINT16(axer + 0) + dx; diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp index 354a1d4491..8acbb8058e 100644 --- a/engines/scumm/akos.cpp +++ b/engines/scumm/akos.cpp @@ -146,7 +146,7 @@ void AkosCostumeLoader::loadCostume(int id) { bool AkosCostumeLoader::hasManyDirections() { const AkosHeader *akhd; - akhd = (const AkosHeader *)_vm->findResourceData(MKID_BE('AKHD'), _akos); + akhd = (const AkosHeader *)_vm->findResourceData(MKTAG('A','K','H','D'), _akos); return (akhd->flags & 2) != 0; } @@ -170,12 +170,12 @@ void AkosCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) { else anim = newDirToOldDir(a->getFacing()) + frame * 4; - akhd = (const AkosHeader *)_vm->findResourceData(MKID_BE('AKHD'), _akos); + akhd = (const AkosHeader *)_vm->findResourceData(MKTAG('A','K','H','D'), _akos); if (anim >= READ_LE_UINT16(&akhd->num_anims)) return; - r = _vm->findResourceData(MKID_BE('AKCH'), _akos); + r = _vm->findResourceData(MKTAG('A','K','C','H'), _akos); assert(r); offs = READ_LE_UINT16(r + anim * sizeof(uint16)); @@ -183,8 +183,8 @@ void AkosCostumeLoader::costumeDecodeData(Actor *a, int frame, uint usemask) { return; r += offs; - const uint8 *akstPtr = _vm->findResourceData(MKID_BE('AKST'), _akos); - const uint8 *aksfPtr = _vm->findResourceData(MKID_BE('AKSF'), _akos); + const uint8 *akstPtr = _vm->findResourceData(MKTAG('A','K','S','T'), _akos); + const uint8 *aksfPtr = _vm->findResourceData(MKTAG('A','K','S','F'), _akos); i = 0; mask = READ_LE_UINT16(r); r += 2; @@ -341,21 +341,21 @@ void AkosRenderer::setCostume(int costume, int shadow) { const byte *akos = _vm->getResourceAddress(rtCostume, costume); assert(akos); - akhd = (const AkosHeader *) _vm->findResourceData(MKID_BE('AKHD'), akos); - akof = (const AkosOffset *) _vm->findResourceData(MKID_BE('AKOF'), akos); - akci = _vm->findResourceData(MKID_BE('AKCI'), akos); - aksq = _vm->findResourceData(MKID_BE('AKSQ'), akos); - akcd = _vm->findResourceData(MKID_BE('AKCD'), akos); - akpl = _vm->findResourceData(MKID_BE('AKPL'), akos); + akhd = (const AkosHeader *) _vm->findResourceData(MKTAG('A','K','H','D'), akos); + akof = (const AkosOffset *) _vm->findResourceData(MKTAG('A','K','O','F'), akos); + akci = _vm->findResourceData(MKTAG('A','K','C','I'), akos); + aksq = _vm->findResourceData(MKTAG('A','K','S','Q'), akos); + akcd = _vm->findResourceData(MKTAG('A','K','C','D'), akos); + akpl = _vm->findResourceData(MKTAG('A','K','P','L'), akos); _codec = READ_LE_UINT16(&akhd->codec); - akct = _vm->findResourceData(MKID_BE('AKCT'), akos); - rgbs = _vm->findResourceData(MKID_BE('RGBS'), akos); + akct = _vm->findResourceData(MKTAG('A','K','C','T'), akos); + rgbs = _vm->findResourceData(MKTAG('R','G','B','S'), akos); xmap = 0; if (shadow) { const uint8 *xmapPtr = _vm->getResourceAddress(rtImage, shadow); assert(xmapPtr); - xmap = _vm->findResourceData(MKID_BE('XMAP'), xmapPtr); + xmap = _vm->findResourceData(MKTAG('X','M','A','P'), xmapPtr); assert(xmap); } } @@ -1384,8 +1384,8 @@ bool ScummEngine_v6::akos_increaseAnims(const byte *akos, Actor *a) { uint size; bool result; - aksq = findResourceData(MKID_BE('AKSQ'), akos); - akfo = findResourceData(MKID_BE('AKFO'), akos); + aksq = findResourceData(MKTAG('A','K','S','Q'), akos); + akfo = findResourceData(MKTAG('A','K','F','O'), akos); size = getResourceDataSize(akfo) / 2; diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index f49635d10f..bb3c4bcc02 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -240,7 +240,7 @@ void ScummEngine_v6::setCursorFromImg(uint img, uint room, uint imgindex) { room = getObjectRoom(img); findObjectInRoom(&foir, foCodeHeader | foImageHeader | foCheckAlreadyLoaded, img, room); - imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), foir.obim); + imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), foir.obim); if (_game.version == 8) { setCursorHotspot(READ_LE_UINT32(&imhd->v8.hotspot[0].x), @@ -270,7 +270,7 @@ void ScummEngine_v6::setCursorFromImg(uint img, uint room, uint imgindex) { if (size > sizeof(_grabbedCursor)) error("setCursorFromImg: Cursor image too large"); - bomp = findResource(MKID_BE('BOMP'), dataptr); + bomp = findResource(MKTAG('B','O','M','P'), dataptr); } if (bomp != NULL) diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 0db77a1b7d..a6a97ec426 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -283,7 +283,7 @@ void Gdi::loadTiles(byte *roomptr) { #ifdef USE_RGB_COLOR void GdiPCEngine::loadTiles(byte *roomptr) { - decodePCEngineTileData(_vm->findResourceData(MKID_BE('TILE'), roomptr)); + decodePCEngineTileData(_vm->findResourceData(MKTAG('T','I','L','E'), roomptr)); } #endif @@ -858,7 +858,7 @@ void ScummEngine::initBGBuffers(int height) { _gdi->_numZBuffer = 2; } else if (_game.features & GF_SMALL_HEADER) { int off; - ptr = findResourceData(MKID_BE('SMAP'), room); + ptr = findResourceData(MKTAG('S','M','A','P'), room); _gdi->_numZBuffer = 0; if (_game.features & GF_16COLOR) @@ -873,13 +873,13 @@ void ScummEngine::initBGBuffers(int height) { } } else if (_game.version == 8) { // in V8 there is no RMIH and num z buffers is in RMHD - ptr = findResource(MKID_BE('RMHD'), room); + ptr = findResource(MKTAG('R','M','H','D'), room); _gdi->_numZBuffer = READ_LE_UINT32(ptr + 24) + 1; } else if (_game.heversion >= 70) { - ptr = findResource(MKID_BE('RMIH'), room); + ptr = findResource(MKTAG('R','M','I','H'), room); _gdi->_numZBuffer = READ_LE_UINT16(ptr + 8) + 1; } else { - ptr = findResource(MKID_BE('RMIH'), findResource(MKID_BE('RMIM'), room)); + ptr = findResource(MKTAG('R','M','I','H'), findResource(MKTAG('R','M','I','M'), room)); _gdi->_numZBuffer = READ_LE_UINT16(ptr + 8) + 1; } assert(_gdi->_numZBuffer >= 1 && _gdi->_numZBuffer <= 8); @@ -1647,9 +1647,9 @@ int Gdi::getZPlanes(const byte *ptr, const byte *zplane_list[9], bool bmapImage) if ((_vm->_game.features & GF_SMALL_HEADER) || _vm->_game.version == 8) zplane_list[0] = ptr; else if (bmapImage) - zplane_list[0] = _vm->findResource(MKID_BE('BMAP'), ptr); + zplane_list[0] = _vm->findResource(MKTAG('B','M','A','P'), ptr); else - zplane_list[0] = _vm->findResource(MKID_BE('SMAP'), ptr); + zplane_list[0] = _vm->findResource(MKTAG('S','M','A','P'), ptr); if (_zbufferDisabled) numzbuf = 0; @@ -1692,11 +1692,11 @@ int Gdi::getZPlanes(const byte *ptr, const byte *zplane_list[9], bool bmapImage) } } else { const uint32 zplane_tags[] = { - MKID_BE('ZP00'), - MKID_BE('ZP01'), - MKID_BE('ZP02'), - MKID_BE('ZP03'), - MKID_BE('ZP04') + MKTAG('Z','P','0','0'), + MKTAG('Z','P','0','1'), + MKTAG('Z','P','0','2'), + MKTAG('Z','P','0','3'), + MKTAG('Z','P','0','4') }; for (i = 1; i < numzbuf; i++) { @@ -1733,7 +1733,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const // Skip to the BSTR->WRAP->OFFS chunk smap_ptr = ptr + 24; } else { - smap_ptr = _vm->findResource(MKID_BE('SMAP'), ptr); + smap_ptr = _vm->findResource(MKTAG('S','M','A','P'), ptr); assert(smap_ptr); } @@ -1741,7 +1741,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, const int y, const const byte *tmsk_ptr = NULL; if (_vm->_game.heversion >= 72) { - tmsk_ptr = _vm->findResource(MKID_BE('TMSK'), ptr); + tmsk_ptr = _vm->findResource(MKTAG('T','M','S','K'), ptr); } if (y + height > vs->h) { @@ -2011,7 +2011,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { byte *mask_ptr; const byte *zplane_list[9]; - const byte *bmap_ptr = _vm->findResourceData(MKID_BE('BMAP'), ptr); + const byte *bmap_ptr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr); assert(bmap_ptr); byte code = *bmap_ptr++; @@ -2091,7 +2091,7 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs) { } void Gdi::drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h) { - const byte *bmap_ptr = _vm->findResourceData(MKID_BE('BMAP'), ptr); + const byte *bmap_ptr = _vm->findResourceData(MKTAG('B','M','A','P'), ptr); assert(bmap_ptr); byte code = *bmap_ptr++; @@ -2828,10 +2828,10 @@ void GdiPCEngine::decodeStrip(const byte *ptr, uint16 *tiles, byte *colors, uint void GdiPCEngine::decodePCEngineGfx(const byte *room) { uint16* stripOffsets; - decodePCEngineTileData(_vm->findResourceData(MKID_BE('TILE'), room)); - decodePCEngineMaskData(_vm->findResourceData(MKID_BE('ZP00'), room)); + decodePCEngineTileData(_vm->findResourceData(MKTAG('T','I','L','E'), room)); + decodePCEngineMaskData(_vm->findResourceData(MKTAG('Z','P','0','0'), room)); - const byte* smap_ptr = _vm->findResourceData(MKID_BE('IM00'), room); + const byte* smap_ptr = _vm->findResourceData(MKTAG('I','M','0','0'), room); smap_ptr++; // roomID int numStrips = *smap_ptr++; int numRows = *smap_ptr++; diff --git a/engines/scumm/he/animation_he.cpp b/engines/scumm/he/animation_he.cpp index 7840b9df20..e3e25c161c 100644 --- a/engines/scumm/he/animation_he.cpp +++ b/engines/scumm/he/animation_he.cpp @@ -112,7 +112,7 @@ void MoviePlayer::handleNextFrame() { if (_flags & 2) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, _wizResNum); assert(dstPtr); - uint8 *dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); + uint8 *dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0); assert(dst); copyFrameToBuffer(dst, kDstResource, 0, 0, _vm->_screenWidth * _vm->_bytesPerPixel); } else if (_flags & 1) { diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp index 79bb47aafc..a16af73135 100644 --- a/engines/scumm/he/cup_player_he.cpp +++ b/engines/scumm/he/cup_player_he.cpp @@ -47,7 +47,7 @@ bool CUP_Player::open(const char *filename) { if (_fileStream.open(filename)) { uint32 tag = _fileStream.readUint32BE(); _fileStream.readUint32BE(); - if (tag == MKID_BE('BEAN')) { + if (tag == MKTAG('B','E','A','N')) { _playbackRate = kDefaultPlaybackRate; _width = kDefaultVideoWidth; _height = kDefaultVideoHeight; @@ -168,7 +168,7 @@ void CUP_Player::updateSfx() { assert(sfxIndex >= 0 && sfxIndex < _sfxCount); uint32 offset = READ_LE_UINT32(_sfxBuffer + sfxIndex * 4) - 8; uint8 *soundData = _sfxBuffer + offset; - if (READ_BE_UINT32(soundData) == MKID_BE('DATA')) { + if (READ_BE_UINT32(soundData) == MKTAG('D','A','T','A')) { uint32 soundSize = READ_BE_UINT32(soundData + 4); _mixer->playStream(Audio::Mixer::kSFXSoundType, &sfxChannel->handle, Audio::makeLoopingAudioStream( @@ -208,19 +208,19 @@ bool CUP_Player::parseNextHeaderTag(Common::SeekableReadStream &dataStream) { uint32 next = dataStream.pos() + size; debug(1, "New header tag %s %d dataSize %d", tag2str(tag), size, _dataSize); switch (tag) { - case MKID_BE('HEAD'): + case MKTAG('H','E','A','D'): handleHEAD(dataStream, size); break; - case MKID_BE('SFXB'): + case MKTAG('S','F','X','B'): handleSFXB(dataStream, size); break; - case MKID_BE('RGBS'): + case MKTAG('R','G','B','S'): handleRGBS(dataStream, size); break; - case MKID_BE('DATA'): + case MKTAG('D','A','T','A'): _dataSize = size; return false; - case MKID_BE('GFXB'): + case MKTAG('G','F','X','B'): // this is never triggered default: warning("Unhandled tag %s", tag2str(tag)); @@ -236,34 +236,34 @@ bool CUP_Player::parseNextBlockTag(Common::SeekableReadStream &dataStream) { uint32 next = dataStream.pos() + size; debug(1, "New block tag %s %d dataSize %d", tag2str(tag), size, _dataSize); switch (tag) { - case MKID_BE('FRAM'): + case MKTAG('F','R','A','M'): handleFRAM(dataStream, size); break; - case MKID_BE('LZSS'): + case MKTAG('L','Z','S','S'): if (handleLZSS(dataStream, size) && _outLzssBufSize != 0) { Common::MemoryReadStream memoryStream(_outLzssBufData, _outLzssBufSize); parseNextBlockTag(memoryStream); } break; - case MKID_BE('RATE'): + case MKTAG('R','A','T','E'): handleRATE(dataStream, size); break; - case MKID_BE('RGBS'): + case MKTAG('R','G','B','S'): handleRGBS(dataStream, size); break; - case MKID_BE('SNDE'): + case MKTAG('S','N','D','E'): handleSNDE(dataStream, size); break; - case MKID_BE('TOIL'): + case MKTAG('T','O','I','L'): handleTOIL(dataStream, size); break; - case MKID_BE('SRLE'): + case MKTAG('S','R','L','E'): handleSRLE(dataStream, size); break; - case MKID_BE('BLOK'): + case MKTAG('B','L','O','K'): _dataSize -= size + 8; return false; - case MKID_BE('WRLE'): + case MKTAG('W','R','L','E'): // this is never triggered default: warning("Unhandled tag %s", tag2str(tag)); @@ -283,10 +283,10 @@ void CUP_Player::handleSFXB(Common::SeekableReadStream &dataStream, uint32 dataS if (dataSize > 16) { // WRAP and OFFS chunks uint32 tag = dataStream.readUint32BE(); uint32 size = dataStream.readUint32BE(); - if (tag == MKID_BE('WRAP')) { + if (tag == MKTAG('W','R','A','P')) { tag = dataStream.readUint32BE(); size = dataStream.readUint32BE(); - if (tag == MKID_BE('OFFS')) { + if (tag == MKTAG('O','F','F','S')) { _sfxCount = (size - 8) / 4; _sfxBuffer = (uint8 *)malloc(dataSize - 16); if (_sfxBuffer) { @@ -439,12 +439,12 @@ static void decodeLZSS(uint8 *dst, const uint8 *src1, const uint8 *src2, const u bool CUP_Player::handleLZSS(Common::SeekableReadStream &dataStream, uint32 dataSize) { uint32 tag = dataStream.readUint32BE(); uint32 size = dataStream.readUint32BE(); - if (tag == MKID_BE('LZHD')) { + if (tag == MKTAG('L','Z','H','D')) { uint32 compressionType = dataStream.readUint32LE(); uint32 compressionSize = dataStream.readUint32LE(); tag = dataStream.readUint32BE(); size = dataStream.readUint32BE(); - if (tag == MKID_BE('DATA') && compressionType == 0x2000) { + if (tag == MKTAG('D','A','T','A') && compressionType == 0x2000) { if (_inLzssBufSize < size - 16) { free(_inLzssBufData); _inLzssBufSize = size - 16; diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp index 491b91c17e..026a848828 100644 --- a/engines/scumm/he/floodfill_he.cpp +++ b/engines/scumm/he/floodfill_he.cpp @@ -240,7 +240,7 @@ void Wiz::fillWizFlood(const WizParameters *params) { if (params->processFlags & kWPFNewState) { state = params->img.state; } - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); @@ -258,7 +258,7 @@ void Wiz::fillWizFlood(const WizParameters *params) { color = params->fillColor; } if (imageRect.contains(px, py)) { - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); FloodFillState *ffs = new FloodFillState; diff --git a/engines/scumm/he/palette_he.cpp b/engines/scumm/he/palette_he.cpp index b42d6e97e2..7f517c56ed 100644 --- a/engines/scumm/he/palette_he.cpp +++ b/engines/scumm/he/palette_he.cpp @@ -192,7 +192,7 @@ void ScummEngine_v90he::setHEPaletteFromCostume(int palSlot, int resId) { assertRange(1, palSlot, _numPalettes, "palette"); const uint8 *data = getResourceAddress(rtCostume, resId); assert(data); - const uint8 *rgbs = findResourceData(MKID_BE('RGBS'), data); + const uint8 *rgbs = findResourceData(MKTAG('R','G','B','S'), data); assert(rgbs); setHEPaletteFromPtr(palSlot, rgbs); } @@ -202,7 +202,7 @@ void ScummEngine_v90he::setHEPaletteFromImage(int palSlot, int resId, int state) assertRange(1, palSlot, _numPalettes, "palette"); uint8 *data = getResourceAddress(rtImage, resId); assert(data); - const uint8 *rgbs = findWrappedBlock(MKID_BE('RGBS'), data, state, 0); + const uint8 *rgbs = findWrappedBlock(MKTAG('R','G','B','S'), data, state, 0); if (rgbs) setHEPaletteFromPtr(palSlot, rgbs); } @@ -212,7 +212,7 @@ void ScummEngine_v90he::setHEPaletteFromRoom(int palSlot, int resId, int state) assertRange(1, palSlot, _numPalettes, "palette"); const uint8 *data = getResourceAddress(rtRoom, resId); assert(data); - const uint8 *pals = findResourceData(MKID_BE('PALS'), data); + const uint8 *pals = findResourceData(MKTAG('P','A','L','S'), data); assert(pals); const uint8 *rgbs = findPalInPals(pals, state); assert(rgbs); diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index 9349e70eb9..ecb094f29b 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -332,7 +332,7 @@ int ScummEngine_v72he::getSoundResourceSize(int id) { if (!ptr) return 0; - if (READ_BE_UINT32(ptr) == MKID_BE('RIFF')) { + if (READ_BE_UINT32(ptr) == MKTAG('R','I','F','F')) { byte flags; int rate; @@ -344,11 +344,11 @@ int ScummEngine_v72he::getSoundResourceSize(int id) { } } else { ptr += 8 + READ_BE_UINT32(ptr + 12); - if (READ_BE_UINT32(ptr) == MKID_BE('SBNG')) { + if (READ_BE_UINT32(ptr) == MKTAG('S','B','N','G')) { ptr += READ_BE_UINT32(ptr + 4); } - assert(READ_BE_UINT32(ptr) == MKID_BE('SDAT')); + assert(READ_BE_UINT32(ptr) == MKTAG('S','D','A','T')); size = READ_BE_UINT32(ptr + 4) - 8; } } diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp index ca4a65ac74..69063a1837 100644 --- a/engines/scumm/he/script_v100he.cpp +++ b/engines/scumm/he/script_v100he.cpp @@ -2999,7 +2999,7 @@ void ScummEngine_v100he::decodeParseString(int m, int n) { case 78: { byte *dataPtr = getResourceAddress(rtTalkie, pop()); - byte *text = findWrappedBlock(MKID_BE('TEXT'), dataPtr, 0, 0); + byte *text = findWrappedBlock(MKTAG('T','E','X','T'), dataPtr, 0, 0); size = getResourceDataSize(text); memcpy(name, text, size); printString(m, name); diff --git a/engines/scumm/he/script_v71he.cpp b/engines/scumm/he/script_v71he.cpp index 46a8868949..a800a7d85c 100644 --- a/engines/scumm/he/script_v71he.cpp +++ b/engines/scumm/he/script_v71he.cpp @@ -88,15 +88,15 @@ byte *ScummEngine_v71he::heFindResource(uint32 tag, byte *searchin) { } byte *ScummEngine_v71he::findWrappedBlock(uint32 tag, byte *ptr, int state, bool errorFlag) { - if (READ_BE_UINT32(ptr) == MKID_BE('MULT')) { + if (READ_BE_UINT32(ptr) == MKTAG('M','U','L','T')) { byte *offs, *wrap; uint32 size; - wrap = heFindResource(MKID_BE('WRAP'), ptr); + wrap = heFindResource(MKTAG('W','R','A','P'), ptr); if (wrap == NULL) return NULL; - offs = heFindResourceData(MKID_BE('OFFS'), wrap); + offs = heFindResourceData(MKTAG('O','F','F','S'), wrap); if (offs == NULL) return NULL; @@ -109,7 +109,7 @@ byte *ScummEngine_v71he::findWrappedBlock(uint32 tag, byte *ptr, int state, bool if (offs) return offs; - offs = heFindResourceData(MKID_BE('DEFA'), ptr); + offs = heFindResourceData(MKTAG('D','E','F','A'), ptr); if (offs == NULL) return NULL; diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 8aaf16e81b..17bd29d826 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -2039,7 +2039,7 @@ void ScummEngine_v72he::decodeParseString(int m, int n) { case 0xE1: { byte *dataPtr = getResourceAddress(rtTalkie, pop()); - byte *text = findWrappedBlock(MKID_BE('TEXT'), dataPtr, 0, 0); + byte *text = findWrappedBlock(MKTAG('T','E','X','T'), dataPtr, 0, 0); size = getResourceDataSize(text); memcpy(name, text, size); printString(m, name); diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp index 4770f28cbc..4fd7caebf5 100644 --- a/engines/scumm/he/sound_he.cpp +++ b/engines/scumm/he/sound_he.cpp @@ -499,11 +499,11 @@ byte *findSoundTag(uint32 tag, byte *ptr) { byte *endPtr; uint32 offset, size; - if (READ_BE_UINT32(ptr) == MKID_BE('WSOU')) { + if (READ_BE_UINT32(ptr) == MKTAG('W','S','O','U')) { ptr += 8; } - if (READ_BE_UINT32(ptr) != MKID_BE('RIFF')) + if (READ_BE_UINT32(ptr) != MKTAG('R','I','F','F')) return NULL; endPtr = (ptr + 12); @@ -591,14 +591,14 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) } // Support for sound in later HE games - if (READ_BE_UINT32(ptr) == MKID_BE('RIFF') || READ_BE_UINT32(ptr) == MKID_BE('WSOU')) { + if (READ_BE_UINT32(ptr) == MKTAG('R','I','F','F') || READ_BE_UINT32(ptr) == MKTAG('W','S','O','U')) { uint16 compType; int blockAlign; int codeOffs = -1; priority = (soundID > _vm->_numSounds) ? 255 : *(ptr + 18); - byte *sbngPtr = findSoundTag(MKID_BE('SBNG'), ptr); + byte *sbngPtr = findSoundTag(MKTAG('S','B','N','G'), ptr); if (sbngPtr != NULL) { codeOffs = sbngPtr - ptr + 8; } @@ -611,7 +611,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) return; } - if (READ_BE_UINT32(ptr) == MKID_BE('WSOU')) + if (READ_BE_UINT32(ptr) == MKTAG('W','S','O','U')) ptr += 8; size = READ_LE_UINT32(ptr + 4); @@ -675,7 +675,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) Audio::makeLoopingAudioStream(stream, (heFlags & 1) ? 0 : 1), soundID); } // Support for sound in Humongous Entertainment games - else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) { + else if (READ_BE_UINT32(ptr) == MKTAG('D','I','G','I') || READ_BE_UINT32(ptr) == MKTAG('T','A','L','K')) { byte *sndPtr = ptr; int codeOffs = -1; @@ -693,12 +693,12 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) return; } - if (READ_BE_UINT32(ptr) == MKID_BE('SBNG')) { + if (READ_BE_UINT32(ptr) == MKTAG('S','B','N','G')) { codeOffs = ptr - sndPtr + 8; ptr += READ_BE_UINT32(ptr + 4); } - assert(READ_BE_UINT32(ptr) == MKID_BE('SDAT')); + assert(READ_BE_UINT32(ptr) == MKTAG('S','D','A','T')); size = READ_BE_UINT32(ptr + 4) - 8; if (heOffset < 0 || heOffset > size) { // Occurs when making fireworks in puttmoon @@ -734,14 +734,14 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) Audio::makeLoopingAudioStream(stream, (heFlags & 1) ? 0 : 1), soundID); } // Support for PCM music in 3DO versions of Humongous Entertainment games - else if (READ_BE_UINT32(ptr) == MKID_BE('MRAW')) { + else if (READ_BE_UINT32(ptr) == MKTAG('M','R','A','W')) { priority = *(ptr + 18); rate = READ_LE_UINT16(ptr + 22); // Skip DIGI (8) and HSHD (24) blocks ptr += 32; - assert(READ_BE_UINT32(ptr) == MKID_BE('SDAT')); + assert(READ_BE_UINT32(ptr) == MKTAG('S','D','A','T')); size = READ_BE_UINT32(ptr + 4) - 8; byte *sound = (byte *)malloc(size); @@ -753,7 +753,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) stream = Audio::makeRawStream(sound, size, rate, 0); _mixer->playStream(Audio::Mixer::kMusicSoundType, NULL, stream, soundID); } - else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) { + else if (READ_BE_UINT32(ptr) == MKTAG('M','I','D','I')) { if (_vm->_imuse) { // This is used in the DOS version of Fatty Bear's // Birthday Surprise to change the note on the piano @@ -833,9 +833,9 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) { chan = i; } - if (!findSoundTag(MKID_BE('data'), snd1Ptr)) { - sbng1Ptr = heFindResource(MKID_BE('SBNG'), snd1Ptr); - sbng2Ptr = heFindResource(MKID_BE('SBNG'), snd2Ptr); + if (!findSoundTag(MKTAG('d','a','t','a'), snd1Ptr)) { + sbng1Ptr = heFindResource(MKTAG('S','B','N','G'), snd1Ptr); + sbng2Ptr = heFindResource(MKTAG('S','B','N','G'), snd2Ptr); } if (sbng1Ptr != NULL && sbng2Ptr != NULL) { @@ -879,10 +879,10 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) { } } - if (findSoundTag(MKID_BE('data'), snd1Ptr)) { - sdat1Ptr = findSoundTag(MKID_BE('data'), snd1Ptr); + if (findSoundTag(MKTAG('d','a','t','a'), snd1Ptr)) { + sdat1Ptr = findSoundTag(MKTAG('d','a','t','a'), snd1Ptr); assert(sdat1Ptr); - sdat2Ptr = findSoundTag(MKID_BE('data'), snd2Ptr); + sdat2Ptr = findSoundTag(MKTAG('d','a','t','a'), snd2Ptr); assert(sdat2Ptr); if (!_sndDataSize) @@ -890,9 +890,9 @@ void ScummEngine_v80he::createSound(int snd1id, int snd2id) { sdat2size = READ_LE_UINT32(sdat2Ptr + 4) - 8; } else { - sdat1Ptr = heFindResource(MKID_BE('SDAT'), snd1Ptr); + sdat1Ptr = heFindResource(MKTAG('S','D','A','T'), snd1Ptr); assert(sdat1Ptr); - sdat2Ptr = heFindResource(MKID_BE('SDAT'), snd2Ptr); + sdat2Ptr = heFindResource(MKTAG('S','D','A','T'), snd2Ptr); assert(sdat2Ptr); _sndDataSize = READ_BE_UINT32(sdat1Ptr + 4) - 8; diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp index 3d1aa5b048..16cbadd65b 100644 --- a/engines/scumm/he/wiz_he.cpp +++ b/engines/scumm/he/wiz_he.cpp @@ -1445,21 +1445,21 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int if (shadow) { dataPtr = _vm->getResourceAddress(rtImage, shadow); assert(dataPtr); - xmapPtr = _vm->findResourceData(MKID_BE('XMAP'), dataPtr); + xmapPtr = _vm->findResourceData(MKTAG('X','M','A','P'), dataPtr); assert(xmapPtr); } dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); uint32 comp = READ_LE_UINT32(wizh + 0x0); uint32 width = READ_LE_UINT32(wizh + 0x4); uint32 height = READ_LE_UINT32(wizh + 0x8); debug(3, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d", comp, width, height); - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); uint8 *mask = NULL; @@ -1467,28 +1467,28 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int uint8 *maskPtr = _vm->getResourceAddress(rtImage, maskNum); assert(maskPtr); - wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), maskPtr, maskState, 0); + wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), maskPtr, maskState, 0); assert(wizh); assert(comp == 2 && READ_LE_UINT32(wizh + 0x0) == 1); width = READ_LE_UINT32(wizh + 0x4); height = READ_LE_UINT32(wizh + 0x8); - mask = _vm->findWrappedBlock(MKID_BE('WIZD'), maskPtr, maskState, 0); + mask = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), maskPtr, maskState, 0); assert(mask); } if (flags & kWIFHasPalette) { - uint8 *pal = _vm->findWrappedBlock(MKID_BE('RGBS'), dataPtr, state, 0); + uint8 *pal = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0); assert(pal); _vm->setPaletteFromPtr(pal, 256); } uint8 *rmap = NULL; if (flags & kWIFRemapPalette) { - rmap = _vm->findWrappedBlock(MKID_BE('RMAP'), dataPtr, state, 0); + rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0); assert(rmap); if (_vm->_game.heversion <= 80 || READ_BE_UINT32(rmap) != 0x01234567) { - uint8 *rgbs = _vm->findWrappedBlock(MKID_BE('RGBS'), dataPtr, state, 0); + uint8 *rgbs = _vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0); assert(rgbs); _vm->remapHEPalette(rgbs, rmap + 4); } @@ -1526,7 +1526,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int if (dstResNum) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum); assert(dstPtr); - dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); + dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0); assert(dst); getWizImageDim(dstResNum, 0, cw, ch); dstPitch = cw * _vm->_bytesPerPixel; @@ -1567,7 +1567,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int maskNum, int maskState, int int transColor = -1; if (_vm->VAR_WIZ_TCOLOR != 0xFF) { - uint8 *trns = _vm->findWrappedBlock(MKID_BE('TRNS'), dataPtr, state, 0); + uint8 *trns = _vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0); transColor = (trns == NULL) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : -1; } @@ -1817,7 +1817,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int assert(_vm->_bytesPerPixel == 1); uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); - srcWizBuf = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + srcWizBuf = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(srcWizBuf); freeBuffer = false; } @@ -1827,7 +1827,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int } else { uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); - srcWizBuf = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + srcWizBuf = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(srcWizBuf); freeBuffer = false; } @@ -1842,7 +1842,7 @@ void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int if (dstResNum) { uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum); assert(dstPtr); - dst = _vm->findWrappedBlock(MKID_BE('WIZD'), dstPtr, 0, 0); + dst = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dstPtr, 0, 0); assert(dst); getWizImageDim(dstResNum, 0, dstw, dsth); dstpitch = dstw * _vm->_bytesPerPixel; @@ -2185,7 +2185,7 @@ void Wiz::fillWizRect(const WizParameters *params) { } uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum); if (dataPtr) { - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); @@ -2210,7 +2210,7 @@ void Wiz::fillWizRect(const WizParameters *params) { } if (areaRect.intersects(imageRect)) { areaRect.clip(imageRect); - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); int dx = areaRect.width(); int dy = areaRect.height(); @@ -2256,7 +2256,7 @@ void Wiz::fillWizLine(const WizParameters *params) { } uint8 *dataPtr = _vm->getResourceAddress(rtImage, params->img.resNum); if (dataPtr) { - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); @@ -2274,7 +2274,7 @@ void Wiz::fillWizLine(const WizParameters *params) { if (params->processFlags & kWPFFillColor) { color = params->fillColor; } - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); int x1 = params->box2.left; int y1 = params->box2.top; @@ -2309,7 +2309,7 @@ void Wiz::fillWizPixel(const WizParameters *params) { if (params->processFlags & kWPFNewState) { state = params->img.state; } - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); @@ -2327,7 +2327,7 @@ void Wiz::fillWizPixel(const WizParameters *params) { color = params->fillColor; } if (imageRect.contains(px, py)) { - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), dataPtr, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), dataPtr, state, 0); assert(wizd); *(wizd + py * w + px) = color; } @@ -2342,7 +2342,7 @@ void Wiz::remapWizImagePal(const WizParameters *params) { const uint8 *index = params->remapIndex; uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum); assert(iwiz); - uint8 *rmap = _vm->findWrappedBlock(MKID_BE('RMAP'), iwiz, st, 0); + uint8 *rmap = _vm->findWrappedBlock(MKTAG('R','M','A','P'), iwiz, st, 0); assert(rmap); WRITE_BE_UINT32(rmap, 0x01234567); while (num--) { @@ -2380,7 +2380,7 @@ void Wiz::processWizImage(const WizParameters *params) { if (f) { uint32 id = f->readUint32BE(); - if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) { + if (id == MKTAG('A','W','I','Z') || id == MKTAG('M','U','L','T')) { uint32 size = f->readUint32BE(); f->seek(0, SEEK_SET); byte *p = _vm->_res->createResource(rtImage, params->img.resNum, size); @@ -2510,7 +2510,7 @@ void Wiz::processWizImage(const WizParameters *params) { void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) { uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); w = READ_LE_UINT32(wizh + 0x4); h = READ_LE_UINT32(wizh + 0x8); @@ -2519,7 +2519,7 @@ void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) { void Wiz::getWizImageSpot(int resId, int state, int32 &x, int32 &y) { uint8 *dataPtr = _vm->getResourceAddress(rtImage, resId); assert(dataPtr); - uint8 *spotPtr = _vm->findWrappedBlock(MKID_BE('SPOT'), dataPtr, state, 0); + uint8 *spotPtr = _vm->findWrappedBlock(MKTAG('S','P','O','T'), dataPtr, state, 0); if (spotPtr) { x = READ_LE_UINT32(spotPtr + 0); y = READ_LE_UINT32(spotPtr + 4); @@ -2537,17 +2537,17 @@ int Wiz::getWizImageData(int resNum, int state, int type) { switch (type) { case 0: - wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), dataPtr, state, 0); + wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), dataPtr, state, 0); assert(wizh); return READ_LE_UINT32(wizh + 0x0); case 1: - return (_vm->findWrappedBlock(MKID_BE('RGBS'), dataPtr, state, 0) != NULL) ? 1 : 0; + return (_vm->findWrappedBlock(MKTAG('R','G','B','S'), dataPtr, state, 0) != NULL) ? 1 : 0; case 2: - return (_vm->findWrappedBlock(MKID_BE('RMAP'), dataPtr, state, 0) != NULL) ? 1 : 0; + return (_vm->findWrappedBlock(MKTAG('R','M','A','P'), dataPtr, state, 0) != NULL) ? 1 : 0; case 3: - return (_vm->findWrappedBlock(MKID_BE('TRNS'), dataPtr, state, 0) != NULL) ? 1 : 0; + return (_vm->findWrappedBlock(MKTAG('T','R','N','S'), dataPtr, state, 0) != NULL) ? 1 : 0; case 4: - return (_vm->findWrappedBlock(MKID_BE('XMAP'), dataPtr, state, 0) != NULL) ? 1 : 0; + return (_vm->findWrappedBlock(MKTAG('X','M','A','P'), dataPtr, state, 0) != NULL) ? 1 : 0; default: error("getWizImageData: Unknown type %d", type); } @@ -2556,14 +2556,14 @@ int Wiz::getWizImageData(int resNum, int state, int type) { int Wiz::getWizImageStates(int resNum) { const uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum); assert(dataPtr); - if (READ_BE_UINT32(dataPtr) == MKID_BE('MULT')) { + if (READ_BE_UINT32(dataPtr) == MKTAG('M','U','L','T')) { const byte *offs, *wrap; - wrap = _vm->findResource(MKID_BE('WRAP'), dataPtr); + wrap = _vm->findResource(MKTAG('W','R','A','P'), dataPtr); if (wrap == NULL) return 1; - offs = _vm->findResourceData(MKID_BE('OFFS'), wrap); + offs = _vm->findResourceData(MKTAG('O','F','F','S'), wrap); if (offs == NULL) return 1; @@ -2577,12 +2577,12 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags int ret = 0; uint8 *data = _vm->getResourceAddress(rtImage, resNum); assert(data); - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), data, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); int h = READ_LE_UINT32(wizh + 0x8); - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), data, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0); assert(wizd); if (x >= 0 && x < w && y >= 0 && y < h) { if (flags & kWIFFlipX) { @@ -2627,12 +2627,12 @@ uint16 Wiz::getWizPixelColor(int resNum, int state, int x, int y) { uint16 color = 0; uint8 *data = _vm->getResourceAddress(rtImage, resNum); assert(data); - uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), data, state, 0); + uint8 *wizh = _vm->findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); int w = READ_LE_UINT32(wizh + 0x4); int h = READ_LE_UINT32(wizh + 0x8); - uint8 *wizd = _vm->findWrappedBlock(MKID_BE('WIZD'), data, state, 0); + uint8 *wizd = _vm->findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0); assert(wizd); switch (c) { case 0: @@ -2671,13 +2671,13 @@ int ScummEngine_v90he::computeWizHistogram(int resNum, int state, int x, int y, Common::Rect rCapt(x, y, w + 1, h + 1); uint8 *data = getResourceAddress(rtImage, resNum); assert(data); - uint8 *wizh = findWrappedBlock(MKID_BE('WIZH'), data, state, 0); + uint8 *wizh = findWrappedBlock(MKTAG('W','I','Z','H'), data, state, 0); assert(wizh); int c = READ_LE_UINT32(wizh + 0x0); w = READ_LE_UINT32(wizh + 0x4); h = READ_LE_UINT32(wizh + 0x8); Common::Rect rWiz(w, h); - uint8 *wizd = findWrappedBlock(MKID_BE('WIZD'), data, state, 0); + uint8 *wizd = findWrappedBlock(MKTAG('W','I','Z','D'), data, state, 0); assert(wizd); if (rCapt.intersects(rWiz)) { rCapt.clip(rWiz); diff --git a/engines/scumm/imuse/imuse.cpp b/engines/scumm/imuse/imuse.cpp index 6c626cdf4e..07fd99c809 100644 --- a/engines/scumm/imuse/imuse.cpp +++ b/engines/scumm/imuse/imuse.cpp @@ -150,22 +150,22 @@ bool IMuseInternal::isMT32(int sound) { tag = READ_BE_UINT32(ptr + 4); switch (tag) { - case MKID_BE('ADL '): - case MKID_BE('ASFX'): // Special AD class for old AdLib sound effects - case MKID_BE('SPK '): + case MKTAG('A','D','L',' '): + case MKTAG('A','S','F','X'): // Special AD class for old AdLib sound effects + case MKTAG('S','P','K',' '): return false; - case MKID_BE('AMI '): - case MKID_BE('ROL '): + case MKTAG('A','M','I',' '): + case MKTAG('R','O','L',' '): return true; - case MKID_BE('MAC '): // Occurs in the Mac version of FOA and MI2 + case MKTAG('M','A','C',' '): // Occurs in the Mac version of FOA and MI2 return true; - case MKID_BE('GMD '): + case MKTAG('G','M','D',' '): return false; - case MKID_BE('MIDI'): // Occurs in Sam & Max + case MKTAG('M','I','D','I'): // Occurs in Sam & Max // HE games use Roland music if (ptr[12] == 'H' && ptr[13] == 'S') return true; @@ -197,20 +197,20 @@ bool IMuseInternal::isMIDI(int sound) { tag = READ_BE_UINT32(ptr + 4); switch (tag) { - case MKID_BE('ADL '): - case MKID_BE('ASFX'): // Special AD class for old AdLib sound effects - case MKID_BE('SPK '): + case MKTAG('A','D','L',' '): + case MKTAG('A','S','F','X'): // Special AD class for old AdLib sound effects + case MKTAG('S','P','K',' '): return false; - case MKID_BE('AMI '): - case MKID_BE('ROL '): + case MKTAG('A','M','I',' '): + case MKTAG('R','O','L',' '): return true; - case MKID_BE('MAC '): // Occurs in the Mac version of FOA and MI2 + case MKTAG('M','A','C',' '): // Occurs in the Mac version of FOA and MI2 return true; - case MKID_BE('GMD '): - case MKID_BE('MIDI'): // Occurs in Sam & Max + case MKTAG('G','M','D',' '): + case MKTAG('M','I','D','I'): // Occurs in Sam & Max return true; } diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp index 516a0497fa..3831689def 100644 --- a/engines/scumm/imuse_digi/dimuse.cpp +++ b/engines/scumm/imuse_digi/dimuse.cpp @@ -31,6 +31,7 @@ #include "scumm/sound.h" #include "scumm/imuse_digi/dimuse.h" #include "scumm/imuse_digi/dimuse_bndmgr.h" +#include "scumm/imuse_digi/dimuse_codecs.h" #include "scumm/imuse_digi/dimuse_track.h" #include "audio/audiostream.h" diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp index f10f17f3d8..cb894d77cc 100644 --- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp @@ -28,6 +28,7 @@ #include "scumm/util.h" #include "scumm/file.h" #include "scumm/imuse_digi/dimuse_bndmgr.h" +#include "scumm/imuse_digi/dimuse_codecs.h" namespace Scumm { @@ -92,7 +93,7 @@ int BundleDirCache::matchFile(const char *filename) { error("BundleDirCache::matchFileFile() Can't find free slot for file bundle dir cache"); tag = file.readUint32BE(); - if (tag == MKID_BE('LB23')) + if (tag == MKTAG('L','B','2','3')) _budleDirCache[freeSlot].isCompressed = true; offset = file.readUint32BE(); @@ -112,7 +113,7 @@ int BundleDirCache::matchFile(const char *filename) { int32 z = 0; int32 z2; - if (tag == MKID_BE('LB23')) { + if (tag == MKTAG('L','B','2','3')) { file.read(_budleDirCache[freeSlot].bundleTable[i].filename, 24); } else { for (z2 = 0; z2 < 8; z2++) @@ -224,7 +225,7 @@ bool BundleMgr::loadCompTable(int32 index) { assert(_numCompItems > 0); _file->seek(8, SEEK_CUR); - if (tag != MKID_BE('COMP')) { + if (tag != MKTAG('C','O','M','P')) { error("BundleMgr::loadCompTable() Compressed sound %d (%s:%d) invalid (%s)", index, _file->getName(), _bundleTable[index].offset, tag2str(tag)); return false; } diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.h b/engines/scumm/imuse_digi/dimuse_bndmgr.h index a78697a854..bed1ac6549 100644 --- a/engines/scumm/imuse_digi/dimuse_bndmgr.h +++ b/engines/scumm/imuse_digi/dimuse_bndmgr.h @@ -107,14 +107,6 @@ public: int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **compFinal, int headerSize, bool headerOutside); }; -namespace BundleCodecs { - -uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size); -void initializeImcTables(); -int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize); - -} // End of namespace BundleCodecs - } // End of namespace Scumm #endif diff --git a/engines/scumm/imuse_digi/dimuse_codecs.cpp b/engines/scumm/imuse_digi/dimuse_codecs.cpp index 62a006c56b..fd9deb7b44 100644 --- a/engines/scumm/imuse_digi/dimuse_codecs.cpp +++ b/engines/scumm/imuse_digi/dimuse_codecs.cpp @@ -25,6 +25,9 @@ #include "common/scummsys.h" #include "common/endian.h" #include "common/util.h" +#include "scumm/imuse_digi/dimuse_codecs.h" + +#include "audio/decoders/adpcm_intern.h" namespace Scumm { @@ -59,23 +62,10 @@ uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size) { * varies the size of each "packet" between 2 and 7 bits. */ -static byte _imcTableEntryBitCount[89]; - -static const int16 imcTable[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, - 16, 17, 19, 21, 23, 25, 28, 31, - 34, 37, 41, 45, 50, 55, 60, 66, - 73, 80, 88, 97, 107, 118, 130, 143, - 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, - 724, 796, 876, 963, 1060, 1166, 1282, 1411, - 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, - 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, - 7132, 7845, 8630, 9493,10442,11487,12635,13899, - 15289,16818,18500,20350,22385,24623,27086,29794, - 32767 -}; +static byte *_destImcTable = NULL; +static uint32 *_destImcTable2 = NULL; +// This table is the "big brother" of Audio::ADPCMStream::_stepAdjustTable. static const byte imxOtherTable[6][64] = { { 0xFF, @@ -116,23 +106,47 @@ static const byte imxOtherTable[6][64] = { } }; +void releaseImcTables() { + free(_destImcTable); + free(_destImcTable2); +} + void initializeImcTables() { int pos; - for (pos = 0; pos < ARRAYSIZE(imcTable); ++pos) { - byte put = 0; - int32 tableValue = ((imcTable[pos] * 4) / 7) / 2; + if (!_destImcTable) _destImcTable = (byte *)calloc(89, sizeof(byte)); + if (!_destImcTable2) _destImcTable2 = (uint32 *)calloc(89 * 64, sizeof(uint32)); + + for (pos = 0; pos <= 88; ++pos) { + byte put = 1; + int32 tableValue = ((Audio::Ima_ADPCMStream::_imaTable[pos] * 4) / 7) / 2; while (tableValue != 0) { tableValue /= 2; put++; } - if (put < 2) { - put = 2; + if (put < 3) { + put = 3; + } + if (put > 8) { + put = 8; } - if (put > 7) { - put = 7; + _destImcTable[pos] = put - 1; + } + + for (int n = 0; n < 64; n++) { + for (pos = 0; pos <= 88; ++pos) { + int32 count = 32; + int32 put = 0; + int32 tableValue = Audio::Ima_ADPCMStream::_imaTable[pos]; + do { + if ((count & n) != 0) { + put += tableValue; + } + count /= 2; + tableValue /= 2; + } while (count != 0); + _destImcTable2[n + pos * 64] = put; } - _imcTableEntryBitCount[pos] = put; } } @@ -183,8 +197,128 @@ static int32 compDecode(byte *src, byte *dst) { } #undef NextBit +int32 decompressADPCM(byte *compInput, byte *compOutput, int channels) { + byte *src; + + // Decoder for the the IMA ADPCM variants used in COMI. + // Contrary to regular IMA ADPCM, this codec uses a variable + // bitsize for the encoded data. + + const int MAX_CHANNELS = 2; + int32 outputSamplesLeft; + int32 destPos; + int16 firstWord; + byte initialTablePos[MAX_CHANNELS] = {0, 0}; + int32 initialimcTableEntry[MAX_CHANNELS] = {7, 7}; + int32 initialOutputWord[MAX_CHANNELS] = {0, 0}; + int32 totalBitOffset, curTablePos, outputWord; + byte *dst; + int i; + + // We only support mono and stereo + assert(channels == 1 || channels == 2); + + src = compInput; + dst = compOutput; + outputSamplesLeft = 0x1000; + + // Every data packet contains 0x2000 bytes of audio data + // when extracted. In order to encode bigger data sets, + // one has to split the data into multiple blocks. + // + // Every block starts with a 2 byte word. If that word is + // non-zero, it indicates the size of a block of raw audio + // data (not encoded) following it. That data we simply copy + // to the output buffer and the proceed by decoding the + // remaining data. + // + // If on the other hand the word is zero, then what follows + // are 7*channels bytes containing seed data for the decoder. + firstWord = READ_BE_UINT16(src); + src += 2; + if (firstWord != 0) { + // Copy raw data + memcpy(dst, src, firstWord); + dst += firstWord; + src += firstWord; + assert((firstWord & 1) == 0); + outputSamplesLeft -= firstWord / 2; + } else { + // Read the seed values for the decoder. + for (i = 0; i < channels; i++) { + initialTablePos[i] = *src; + src += 1; + initialimcTableEntry[i] = READ_BE_UINT32(src); + src += 4; + initialOutputWord[i] = READ_BE_UINT32(src); + src += 4; + } + } + + totalBitOffset = 0; + // The channels are encoded separately. + for (int chan = 0; chan < channels; chan++) { + // Read initial state (this makes it possible for the data stream + // to be split & spread across multiple data chunks. + curTablePos = initialTablePos[chan]; + //imcTableEntry = initialimcTableEntry[chan]; + outputWord = initialOutputWord[chan]; + + // We need to interleave the channels in the output; we achieve + // that by using a variables dest offset: + destPos = chan * 2; + + const int bound = (channels == 1) + ? outputSamplesLeft + : ((chan == 0) + ? (outputSamplesLeft+1) / 2 + : outputSamplesLeft / 2); + for (i = 0; i < bound; ++i) { + // Determine the size (in bits) of the next data packet + const int32 curTableEntryBitCount = _destImcTable[curTablePos]; + assert(2 <= curTableEntryBitCount && curTableEntryBitCount <= 7); + + // Read the next data packet + const byte *readPos = src + (totalBitOffset >> 3); + const uint16 readWord = (uint16)(READ_BE_UINT16(readPos) << (totalBitOffset & 7)); + const byte packet = (byte)(readWord >> (16 - curTableEntryBitCount)); + + // Advance read position to the next data packet + totalBitOffset += curTableEntryBitCount; + + // Decode the data packet into a delta value for the output signal. + const byte signBitMask = (1 << (curTableEntryBitCount - 1)); + const byte dataBitMask = (signBitMask - 1); + const byte data = (packet & dataBitMask); + + const int32 tmpA = (data << (7 - curTableEntryBitCount)); + const int32 imcTableEntry = Audio::Ima_ADPCMStream::_imaTable[curTablePos] >> (curTableEntryBitCount - 1); + int32 delta = imcTableEntry + _destImcTable2[tmpA + (curTablePos * 64)]; + + // The topmost bit in the data packet tells is a sign bit + if ((packet & signBitMask) != 0) { + delta = -delta; + } + + // Accumulate the delta onto the output data + outputWord += delta; + + // Clip outputWord to 16 bit signed, and write it into the destination stream + outputWord = CLIP<int32>(outputWord, -0x8000, 0x7fff); + WRITE_BE_UINT16(dst + destPos, outputWord); + destPos += channels << 1; + + // Adjust the curTablePos + curTablePos += (int8)imxOtherTable[curTableEntryBitCount - 2][data]; + curTablePos = CLIP<int32>(curTablePos, 0, ARRAYSIZE(Audio::Ima_ADPCMStream::_imaTable) - 1); + } + } + + return 0x2000; +} + int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize) { - int32 outputSize, channels; + int32 outputSize; int32 offset1, offset2, offset3, length, k, c, s, j, r, t, z; byte *src, *t_table, *p, *ptr; byte t_tmp1, t_tmp2; @@ -506,132 +640,7 @@ int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inpu case 13: case 15: - if (codec == 13) { - channels = 1; - } else { - channels = 2; - } - - { - // Decoder for the the IMA ADPCM variants used in COMI. - // Contrary to regular IMA ADPCM, this codec uses a variable - // bitsize for the encoded data. - - const int MAX_CHANNELS = 2; - int32 outputSamplesLeft; - int32 destPos; - int16 firstWord; - byte initialTablePos[MAX_CHANNELS] = {0, 0}; - //int32 initialimcTableEntry[MAX_CHANNELS] = {7, 7}; - int32 initialOutputWord[MAX_CHANNELS] = {0, 0}; - int32 totalBitOffset, curTablePos, outputWord; - byte *dst; - int i; - - // We only support mono and stereo - assert(channels == 1 || channels == 2); - - src = compInput; - dst = compOutput; - outputSize = 0x2000; - outputSamplesLeft = 0x1000; - - // Every data packet contains 0x2000 bytes of audio data - // when extracted. In order to encode bigger data sets, - // one has to split the data into multiple blocks. - // - // Every block starts with a 2 byte word. If that word is - // non-zero, it indicates the size of a block of raw audio - // data (not encoded) following it. That data we simply copy - // to the output buffer and the proceed by decoding the - // remaining data. - // - // If on the other hand the word is zero, then what follows - // are 7*channels bytes containing seed data for the decoder. - firstWord = READ_BE_UINT16(src); - src += 2; - if (firstWord != 0) { - // Copy raw data - memcpy(dst, src, firstWord); - dst += firstWord; - src += firstWord; - assert((firstWord & 1) == 0); - outputSamplesLeft -= firstWord / 2; - } else { - // Read the seed values for the decoder. - for (i = 0; i < channels; i++) { - initialTablePos[i] = *src; - src += 1; - //initialimcTableEntry[i] = READ_BE_UINT32(src); - src += 4; - initialOutputWord[i] = READ_BE_UINT32(src); - src += 4; - } - } - - totalBitOffset = 0; - // The channels are encoded separately. - for (int chan = 0; chan < channels; chan++) { - // Read initial state (this makes it possible for the data stream - // to be split & spread across multiple data chunks. - curTablePos = initialTablePos[chan]; - //imcTableEntry = initialimcTableEntry[chan]; - outputWord = initialOutputWord[chan]; - - // We need to interleave the channels in the output; we achieve - // that by using a variables dest offset: - destPos = chan * 2; - - const int bound = (channels == 1) - ? outputSamplesLeft - : ((chan == 0) - ? (outputSamplesLeft+1) / 2 - : outputSamplesLeft / 2); - for (i = 0; i < bound; ++i) { - // Determine the size (in bits) of the next data packet - const int32 curTableEntryBitCount = _imcTableEntryBitCount[curTablePos]; - assert(2 <= curTableEntryBitCount && curTableEntryBitCount <= 7); - - // Read the next data packet - const byte *readPos = src + (totalBitOffset >> 3); - const uint16 readWord = (uint16)(READ_BE_UINT16(readPos) << (totalBitOffset & 7)); - const byte packet = (byte)(readWord >> (16 - curTableEntryBitCount)); - - // Advance read position to the next data packet - totalBitOffset += curTableEntryBitCount; - - // Decode the data packet into a delta value for the output signal. - const byte signBitMask = (1 << (curTableEntryBitCount - 1)); - const byte dataBitMask = (signBitMask - 1); - const byte data = (packet & dataBitMask); - - int32 delta = imcTable[curTablePos] * (2 * data + 1) >> (curTableEntryBitCount - 1); - - // The topmost bit in the data packet tells is a sign bit - if ((packet & signBitMask) != 0) { - delta = -delta; - } - - // Accumulate the delta onto the output data - outputWord += delta; - - // Clip outputWord to 16 bit signed, and write it into the destination stream - if (outputWord > 0x7fff) - outputWord = 0x7fff; - if (outputWord < -0x8000) - outputWord = -0x8000; - WRITE_BE_UINT16(dst + destPos, outputWord); - destPos += channels << 1; - - // Adjust the curTablePos - curTablePos += (int8)imxOtherTable[curTableEntryBitCount - 2][data]; - if (curTablePos < 0) - curTablePos = 0; - else if (curTablePos >= ARRAYSIZE(imcTable)) - curTablePos = ARRAYSIZE(imcTable) - 1; - } - } - } + outputSize = decompressADPCM(compInput, compOutput, (codec == 13) ? 1 : 2); break; default: diff --git a/engines/scumm/imuse_digi/dimuse_codecs.h b/engines/scumm/imuse_digi/dimuse_codecs.h new file mode 100644 index 0000000000..71fd24c3ac --- /dev/null +++ b/engines/scumm/imuse_digi/dimuse_codecs.h @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + */ + +#ifndef SCUMM_IMUSE_DIGI_CODECS_H +#define SCUMM_IMUSE_DIGI_CODECS_H + +#include "common/scummsys.h" + +namespace Scumm { + +namespace BundleCodecs { + +uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size); +int32 decompressCodec(int32 codec, byte *compInput, byte *compOutput, int32 inputSize); + +void initializeImcTables(); +void releaseImcTables(); + +} // End of namespace BundleCodecs + +} // End of namespace Scumm + +#endif diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp index 00074a951a..2cd90c4f2b 100644 --- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp +++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp @@ -34,8 +34,9 @@ #include "scumm/scumm.h" #include "scumm/util.h" #include "scumm/imuse_digi/dimuse.h" -#include "scumm/imuse_digi/dimuse_sndmgr.h" #include "scumm/imuse_digi/dimuse_bndmgr.h" +#include "scumm/imuse_digi/dimuse_codecs.h" +#include "scumm/imuse_digi/dimuse_sndmgr.h" namespace Scumm { @@ -56,6 +57,7 @@ ImuseDigiSndMgr::~ImuseDigiSndMgr() { } delete _cacheBundleDir; + BundleCodecs::releaseImcTables(); } void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, int &numSyncs, int &numMarkers) { @@ -65,32 +67,32 @@ void ImuseDigiSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps, i do { tag = READ_BE_UINT32(ptr); ptr += 4; switch (tag) { - case MKID_BE('STOP'): - case MKID_BE('FRMT'): - case MKID_BE('DATA'): + case MKTAG('S','T','O','P'): + case MKTAG('F','R','M','T'): + case MKTAG('D','A','T','A'): size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('TEXT'): + case MKTAG('T','E','X','T'): if (!scumm_stricmp((const char *)(ptr + 8), "exit")) numMarkers++; size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('REGN'): + case MKTAG('R','E','G','N'): numRegions++; size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('JUMP'): + case MKTAG('J','U','M','P'): numJumps++; size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('SYNC'): + case MKTAG('S','Y','N','C'): numSyncs++; size = READ_BE_UINT32(ptr); ptr += size + 4; break; default: error("ImuseDigiSndMgr::countElements() Unknown sfx header '%s'", tag2str(tag)); } - } while (tag != MKID_BE('DATA')); + } while (tag != MKTAG('D','A','T','A')); } void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::SeekableReadStream *file, SoundDesc *sound, int32 offset, int32 size) { @@ -98,7 +100,7 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::SeekableReadStream *file, Sou file->seek(offset, SEEK_SET); uint32 tag = file->readUint32BE(); - assert(tag == MKID_BE('RMAP')); + assert(tag == MKTAG('R','M','A','P')); int32 version = file->readUint32BE(); if (version != 3) { if (version == 2) { @@ -153,7 +155,7 @@ void ImuseDigiSndMgr::prepareSoundFromRMAP(Common::SeekableReadStream *file, Sou } void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { - if (READ_BE_UINT32(ptr) == MKID_BE('Crea')) { + if (READ_BE_UINT32(ptr) == MKTAG('C','r','e','a')) { bool quit = false; int len; @@ -222,7 +224,7 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { } offset += len; } - } else if (READ_BE_UINT32(ptr) == MKID_BE('iMUS')) { + } else if (READ_BE_UINT32(ptr) == MKTAG('i','M','U','S')) { uint32 tag; int32 size = 0; byte *s_ptr = ptr; @@ -250,13 +252,13 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { do { tag = READ_BE_UINT32(ptr); ptr += 4; switch (tag) { - case MKID_BE('FRMT'): + case MKTAG('F','R','M','T'): ptr += 12; sound->bits = READ_BE_UINT32(ptr); ptr += 4; sound->freq = READ_BE_UINT32(ptr); ptr += 4; sound->channels = READ_BE_UINT32(ptr); ptr += 4; break; - case MKID_BE('TEXT'): + case MKTAG('T','E','X','T'): if (!scumm_stricmp((const char *)(ptr + 8), "exit")) { sound->marker[curIndexMarker].pos = READ_BE_UINT32(ptr + 4); sound->marker[curIndexMarker].length = strlen((const char *)(ptr + 8)) + 1; @@ -267,16 +269,16 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { } size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('STOP'): + case MKTAG('S','T','O','P'): size = READ_BE_UINT32(ptr); ptr += size + 4; break; - case MKID_BE('REGN'): + case MKTAG('R','E','G','N'): ptr += 4; sound->region[curIndexRegion].offset = READ_BE_UINT32(ptr); ptr += 4; sound->region[curIndexRegion].length = READ_BE_UINT32(ptr); ptr += 4; curIndexRegion++; break; - case MKID_BE('JUMP'): + case MKTAG('J','U','M','P'): ptr += 4; sound->jump[curIndexJump].offset = READ_BE_UINT32(ptr); ptr += 4; sound->jump[curIndexJump].dest = READ_BE_UINT32(ptr); ptr += 4; @@ -284,7 +286,7 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { sound->jump[curIndexJump].fadeDelay = READ_BE_UINT32(ptr); ptr += 4; curIndexJump++; break; - case MKID_BE('SYNC'): + case MKTAG('S','Y','N','C'): size = READ_BE_UINT32(ptr); ptr += 4; sound->sync[curIndexSync].size = size; sound->sync[curIndexSync].ptr = new byte[size]; @@ -293,13 +295,13 @@ void ImuseDigiSndMgr::prepareSound(byte *ptr, SoundDesc *sound) { curIndexSync++; ptr += size; break; - case MKID_BE('DATA'): + case MKTAG('D','A','T','A'): ptr += 4; break; default: error("ImuseDigiSndMgr::prepareSound(%d/%s) Unknown sfx header '%s'", sound->soundId, sound->name, tag2str(tag)); } - } while (tag != MKID_BE('DATA')); + } while (tag != MKTAG('D','A','T','A')); sound->offsetData = ptr - s_ptr; } else { error("ImuseDigiSndMgr::prepareSound(): Unknown sound format"); diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp index f2e50382b3..a82c0ae408 100644 --- a/engines/scumm/insane/insane.cpp +++ b/engines/scumm/insane/insane.cpp @@ -1413,7 +1413,7 @@ int32 Insane::smush_setupSanWithFlu(const char *filename, int32 setupsan2, int32 _smush_setupsan1 = setupsan1; /* skip FLUP marker */ - if (READ_BE_UINT32(fluPtr) == MKID_BE('FLUP')) + if (READ_BE_UINT32(fluPtr) == MKTAG('F','L','U','P')) tmp += 8; _smush_setupsan2 = setupsan2; diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp index d56017c6f5..7f250e45e0 100644 --- a/engines/scumm/nut_renderer.cpp +++ b/engines/scumm/nut_renderer.cpp @@ -95,7 +95,7 @@ void NutRenderer::loadFont(const char *filename) { } uint32 tag = file.readUint32BE(); - if (tag != MKID_BE('ANIM')) { + if (tag != MKTAG('A','N','I','M')) { error("NutRenderer::loadFont() there is no ANIM chunk in font header"); } @@ -104,7 +104,7 @@ void NutRenderer::loadFont(const char *filename) { file.read(dataSrc, length); file.close(); - if (READ_BE_UINT32(dataSrc) != MKID_BE('AHDR')) { + if (READ_BE_UINT32(dataSrc) != MKTAG('A','H','D','R')) { error("NutRenderer::loadFont() there is no AHDR chunk in font header"); } @@ -142,12 +142,12 @@ void NutRenderer::loadFont(const char *filename) { offset = 0; for (l = 0; l < _numChars; l++) { offset += READ_BE_UINT32(dataSrc + offset + 4) + 8; - if (READ_BE_UINT32(dataSrc + offset) != MKID_BE('FRME')) { + if (READ_BE_UINT32(dataSrc + offset) != MKTAG('F','R','M','E')) { error("NutRenderer::loadFont(%s) there is no FRME chunk %d (offset %x)", filename, l, offset); break; } offset += 8; - if (READ_BE_UINT32(dataSrc + offset) != MKID_BE('FOBJ')) { + if (READ_BE_UINT32(dataSrc + offset) != MKTAG('F','O','B','J')) { error("NutRenderer::loadFont(%s) there is no FOBJ chunk in FRME chunk %d (offset %x)", filename, l, offset); break; } diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index c44043ca81..c2547f74f4 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -416,7 +416,7 @@ void ScummEngine::getObjectXYPos(int object, int &x, int &y, int &dir) { debug(0, "getObjectXYPos: Can't find object %d", object); return; } - imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), ptr); + imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), ptr); assert(imhd); if (_game.version == 8) { switch (FROM_LE_32(imhd->v8.version)) { @@ -655,7 +655,7 @@ void ScummEngine::drawObject(int obj, int arg) { flags |= Gdi::dbDrawMaskOnAll; #ifdef ENABLE_HE - if (_game.heversion >= 70 && findResource(MKID_BE('SMAP'), ptr) == NULL) + if (_game.heversion >= 70 && findResource(MKTAG('S','M','A','P'), ptr) == NULL) _gdi->drawBMAPObject(ptr, &_virtscr[kMainVirtScreen], obj, od.x_pos, od.y_pos, od.width, od.height); else #endif @@ -762,12 +762,12 @@ void ScummEngine::resetRoomObjects() { for (i = 0; i < _numObjectsInRoom; i++) { od = &_objs[findLocalObjectSlot()]; - ptr = obcds.findNext(MKID_BE('OBCD')); + ptr = obcds.findNext(MKTAG('O','B','C','D')); if (ptr == NULL) error("Room %d missing object code block(s)", _roomResource); od->OBCDoffset = ptr - rootptr; - cdhd = (const CodeHeader *)findResourceData(MKID_BE('CDHD'), ptr); + cdhd = (const CodeHeader *)findResourceData(MKTAG('C','D','H','D'), ptr); if (_game.version >= 7) od->obj_nr = READ_LE_UINT16(&(cdhd->v7.obj_id)); @@ -779,7 +779,7 @@ void ScummEngine::resetRoomObjects() { if (_dumpScripts) { char buf[32]; sprintf(buf, "roomobj-%d-", _roomResource); - ptr = findResource(MKID_BE('VERB'), ptr); + ptr = findResource(MKTAG('V','E','R','B'), ptr); dumpResource(buf, od->obj_nr, ptr); } @@ -788,7 +788,7 @@ void ScummEngine::resetRoomObjects() { searchptr = room; ResourceIterator obims(room, false); for (i = 0; i < _numObjectsInRoom; i++) { - ptr = obims.findNext(MKID_BE('OBIM')); + ptr = obims.findNext(MKTAG('O','B','I','M')); if (ptr == NULL) error("Room %d missing image blocks(s)", _roomResource); @@ -870,7 +870,7 @@ void ScummEngine_v4::resetRoomObjects() { for (i = 0; i < _numObjectsInRoom; i++) { od = &_objs[findLocalObjectSlot()]; - ptr = obcds.findNext(MKID_BE('OBCD')); + ptr = obcds.findNext(MKTAG('O','B','C','D')); if (ptr == NULL) error("Room %d missing object code block(s)", _roomResource); @@ -887,7 +887,7 @@ void ScummEngine_v4::resetRoomObjects() { for (i = 0; i < _numObjectsInRoom; i++) { // In the PC Engine version of Loom, there aren't image blocks // for all objects. - ptr = obims.findNext(MKID_BE('OBIM')); + ptr = obims.findNext(MKTAG('O','B','I','M')); if (ptr == NULL) break; @@ -991,11 +991,11 @@ void ScummEngine::resetRoomObject(ObjectData *od, const byte *room, const byte * searchptr = room; } - cdhd = (const CodeHeader *)findResourceData(MKID_BE('CDHD'), searchptr + od->OBCDoffset); + cdhd = (const CodeHeader *)findResourceData(MKTAG('C','D','H','D'), searchptr + od->OBCDoffset); if (cdhd == NULL) error("Room %d missing CDHD blocks(s)", _roomResource); if (od->OBIMoffset) - imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), room + od->OBIMoffset); + imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), room + od->OBIMoffset); od->flags = Gdi::dbAllowMaskOr; @@ -1194,7 +1194,7 @@ const byte *ScummEngine::getObjOrActorName(int obj) { return (objptr + offset); } - return findResourceData(MKID_BE('OBNA'), objptr); + return findResourceData(MKTAG('O','B','N','A'), objptr); } void ScummEngine::setObjectName(int obj) { @@ -1278,7 +1278,7 @@ const byte *ScummEngine::getOBIMFromObjectData(const ObjectData &od) { if (od.fl_object_index) { ptr = getResourceAddress(rtFlObject, od.fl_object_index); - ptr = findResource(MKID_BE('OBIM'), ptr); + ptr = findResource(MKTAG('O','B','I','M'), ptr); } else { ptr = getResourceAddress(rtRoom, _roomResource); if (ptr) @@ -1288,23 +1288,23 @@ const byte *ScummEngine::getOBIMFromObjectData(const ObjectData &od) { } static const uint32 IMxx_tags[] = { - MKID_BE('IM00'), - MKID_BE('IM01'), - MKID_BE('IM02'), - MKID_BE('IM03'), - MKID_BE('IM04'), - MKID_BE('IM05'), - MKID_BE('IM06'), - MKID_BE('IM07'), - MKID_BE('IM08'), - MKID_BE('IM09'), - MKID_BE('IM0A'), - MKID_BE('IM0B'), - MKID_BE('IM0C'), - MKID_BE('IM0D'), - MKID_BE('IM0E'), - MKID_BE('IM0F'), - MKID_BE('IM10') + MKTAG('I','M','0','0'), + MKTAG('I','M','0','1'), + MKTAG('I','M','0','2'), + MKTAG('I','M','0','3'), + MKTAG('I','M','0','4'), + MKTAG('I','M','0','5'), + MKTAG('I','M','0','6'), + MKTAG('I','M','0','7'), + MKTAG('I','M','0','8'), + MKTAG('I','M','0','9'), + MKTAG('I','M','0','A'), + MKTAG('I','M','0','B'), + MKTAG('I','M','0','C'), + MKTAG('I','M','0','D'), + MKTAG('I','M','0','E'), + MKTAG('I','M','0','F'), + MKTAG('I','M','1','0') }; const byte *ScummEngine::getObjectImage(const byte *ptr, int state) { @@ -1317,15 +1317,15 @@ const byte *ScummEngine::getObjectImage(const byte *ptr, int state) { // The OBIM contains an IMAG, which in turn contains a WRAP, which contains // an OFFS chunk and multiple BOMP/SMAP chunks. To find the right BOMP/SMAP, // we use the offsets in the OFFS chunk, - ptr = findResource(MKID_BE('IMAG'), ptr); + ptr = findResource(MKTAG('I','M','A','G'), ptr); if (!ptr) return 0; - ptr = findResource(MKID_BE('WRAP'), ptr); + ptr = findResource(MKTAG('W','R','A','P'), ptr); if (!ptr) return 0; - ptr = findResource(MKID_BE('OFFS'), ptr); + ptr = findResource(MKTAG('O','F','F','S'), ptr); if (!ptr) return 0; @@ -1348,7 +1348,7 @@ int ScummEngine::getObjectImageCount(int object) { return 0; ptr = getOBIMFromObjectData(_objs[objnum]); - imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), ptr); + imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), ptr); if (!imhd) return 0; @@ -1365,7 +1365,7 @@ int ScummEngine::getObjectImageCount(int object) { int ScummEngine_v8::getObjectIdFromOBIM(const byte *obim) { // In V8, IMHD has no obj_id, but rather a name string. We map the name // back to an object id using a table derived from the DOBJ resource. - const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), obim); + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), obim); ObjectNameId *found = (ObjectNameId *)bsearch(imhd->v8.name, _objectIDMap, _objectIDMapSize, sizeof(ObjectNameId), (int (*)(const void*, const void*))strcmp); assert(found); @@ -1373,7 +1373,7 @@ int ScummEngine_v8::getObjectIdFromOBIM(const byte *obim) { } int ScummEngine_v7::getObjectIdFromOBIM(const byte *obim) { - const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), obim); + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), obim); return READ_LE_UINT16(&imhd->v7.obj_id); } #endif @@ -1382,7 +1382,7 @@ int ScummEngine::getObjectIdFromOBIM(const byte *obim) { if (_game.features & GF_SMALL_HEADER) return READ_LE_UINT16(obim + 6); - const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), obim); + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), obim); return READ_LE_UINT16(&imhd->old.obj_id); } @@ -1400,7 +1400,7 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, if (findWhat & foCodeHeader) { fo->obcd = obcdptr = getOBCDFromObject(id); assert(obcdptr); - fo->cdhd = (const CodeHeader *)findResourceData(MKID_BE('CDHD'), obcdptr); + fo->cdhd = (const CodeHeader *)findResourceData(MKTAG('C','D','H','D'), obcdptr); } if (findWhat & foImageHeader) { fo->obim = obimptr = getOBIMFromObjectData(_objs[id2]); @@ -1416,7 +1416,7 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, if (_game.features & GF_OLD_BUNDLE) { numobj = roomptr[20]; } else { - const RoomHeader *roomhdr = (const RoomHeader *)findResourceData(MKID_BE('RMHD'), roomptr); + const RoomHeader *roomhdr = (const RoomHeader *)findResourceData(MKTAG('R','M','H','D'), roomptr); if (_game.version == 8) numobj = READ_LE_UINT32(&(roomhdr->v8.numObjects)); @@ -1467,10 +1467,10 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, assert(searchptr); ResourceIterator obcds(searchptr, (_game.features & GF_SMALL_HEADER) != 0); for (i = 0; i < numobj; i++) { - obcdptr = obcds.findNext(MKID_BE('OBCD')); + obcdptr = obcds.findNext(MKTAG('O','B','C','D')); if (obcdptr == NULL) error("findObjectInRoom: Not enough code blocks in room %d", room); - cdhd = (const CodeHeader *)findResourceData(MKID_BE('CDHD'), obcdptr); + cdhd = (const CodeHeader *)findResourceData(MKTAG('C','D','H','D'), obcdptr); if (_game.features & GF_SMALL_HEADER) id2 = READ_LE_UINT16(obcdptr + 6); @@ -1495,7 +1495,7 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, if (findWhat & foImageHeader) { ResourceIterator obims(roomptr, (_game.features & GF_SMALL_HEADER) != 0); for (i = 0; i < numobj; i++) { - obimptr = obims.findNext(MKID_BE('OBIM')); + obimptr = obims.findNext(MKTAG('O','B','I','M')); if (obimptr == NULL) error("findObjectInRoom: Not enough image blocks in room %d", room); obim_id = getObjectIdFromOBIM(obimptr); @@ -1699,7 +1699,7 @@ void ScummEngine_v6::drawBlastObject(BlastObject *eo) { if (!img) img = getObjectImage(ptr, 1); // Backward compatibility with samnmax blast objects assert(img); - bomp = findResourceData(MKID_BE('BOMP'), img); + bomp = findResourceData(MKTAG('B','O','M','P'), img); } if (!bomp) @@ -1843,7 +1843,7 @@ void ScummEngine::loadFlObject(uint object, uint room) { char buf[32]; const byte *ptr = foir.obcd; sprintf(buf, "roomobj-%d-", room); - ptr = findResource(MKID_BE('VERB'), ptr); + ptr = findResource(MKTAG('V','E','R','B'), ptr); dumpResource(buf, object, ptr); } @@ -1869,7 +1869,7 @@ void ScummEngine::loadFlObject(uint object, uint room) { assert(flob); // Copy object code + object image to floating object - WRITE_UINT32(flob, MKID_BE('FLOB')); + WRITE_UINT32(flob, MKTAG('F','L','O','B')); WRITE_BE_UINT32(flob + 4, flob_size); memcpy(flob + 8, foir.obcd, obcd_size); memcpy(flob + 8 + obcd_size, foir.obim, obim_size); diff --git a/engines/scumm/palette.cpp b/engines/scumm/palette.cpp index 18784151b7..e81212fec8 100644 --- a/engines/scumm/palette.cpp +++ b/engines/scumm/palette.cpp @@ -1029,7 +1029,7 @@ void ScummEngine::setCurrentPalette(int palindex) { void ScummEngine::setRoomPalette(int palindex, int room) { const byte *roomptr = getResourceAddress(rtRoom, room); assert(roomptr); - const byte *pals = findResource(MKID_BE('PALS'), roomptr); + const byte *pals = findResource(MKTAG('P','A','L','S'), roomptr); assert(pals); const byte *rgbs = findPalInPals(pals, palindex); assert(rgbs); @@ -1040,11 +1040,11 @@ const byte *ScummEngine::findPalInPals(const byte *pal, int idx) { const byte *offs; uint32 size; - pal = findResource(MKID_BE('WRAP'), pal); + pal = findResource(MKTAG('W','R','A','P'), pal); if (pal == NULL) return NULL; - offs = findResourceData(MKID_BE('OFFS'), pal); + offs = findResourceData(MKTAG('O','F','F','S'), pal); if (offs == NULL) return NULL; diff --git a/engines/scumm/player_towns.cpp b/engines/scumm/player_towns.cpp index 06f97fd671..8922ff1730 100644 --- a/engines/scumm/player_towns.cpp +++ b/engines/scumm/player_towns.cpp @@ -622,7 +622,7 @@ int Player_Towns_v2::getSoundStatus(int sound) const { void Player_Towns_v2::startSound(int sound) { uint8 *ptr = _vm->getResourceAddress(rtSound, sound); - if (READ_BE_UINT32(ptr) == MKID_BE('TOWS')) { + if (READ_BE_UINT32(ptr) == MKTAG('T','O','W','S')) { _soundOverride[sound].type = 7; uint8 velo = _soundOverride[sound].velo ? _soundOverride[sound].velo - 1: (ptr[10] + ptr[11] + 1) >> 1; uint8 pan = _soundOverride[sound].pan ? _soundOverride[sound].pan - 1 : 64; @@ -630,7 +630,7 @@ void Player_Towns_v2::startSound(int sound) { _soundOverride[sound].velo = _soundOverride[sound].pan = 0; playPcmTrack(sound, ptr + 8, velo, pan, ptr[52], pri); - } else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) { + } else if (READ_BE_UINT32(ptr) == MKTAG('S','B','L',' ')) { _soundOverride[sound].type = 5; playVocTrack(ptr + 27); @@ -680,7 +680,7 @@ int32 Player_Towns_v2::doCommand(int numargs, int args[]) { case 258: if (_soundOverride[args[1]].type == 0) { ptr = _vm->getResourceAddress(rtSound, args[1]); - if (READ_BE_UINT32(ptr) == MKID_BE('TOWS')) + if (READ_BE_UINT32(ptr) == MKTAG('T','O','W','S')) _soundOverride[args[1]].type = 7; } if (_soundOverride[args[1]].type == 7) { @@ -692,7 +692,7 @@ int32 Player_Towns_v2::doCommand(int numargs, int args[]) { case 259: if (_soundOverride[args[1]].type == 0) { ptr = _vm->getResourceAddress(rtSound, args[1]); - if (READ_BE_UINT32(ptr) == MKID_BE('TOWS')) + if (READ_BE_UINT32(ptr) == MKTAG('T','O','W','S')) _soundOverride[args[1]].type = 7; } if (_soundOverride[args[1]].type == 7) { diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 5bc643a5d1..c872a83d14 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -259,26 +259,26 @@ void ScummEngine::readIndexFile() { if (_fileHandle->eos() || _fileHandle->err()) break; switch (blocktype) { - case MKID_BE('DOBJ'): + case MKTAG('D','O','B','J'): _numGlobalObjects = _fileHandle->readUint16LE(); itemsize -= 2; break; - case MKID_BE('DROO'): + case MKTAG('D','R','O','O'): _numRooms = _fileHandle->readUint16LE(); itemsize -= 2; break; - case MKID_BE('DSCR'): + case MKTAG('D','S','C','R'): _numScripts = _fileHandle->readUint16LE(); itemsize -= 2; break; - case MKID_BE('DCOS'): + case MKTAG('D','C','O','S'): _numCostumes = _fileHandle->readUint16LE(); itemsize -= 2; break; - case MKID_BE('DSOU'): + case MKTAG('D','S','O','U'): _numSounds = _fileHandle->readUint16LE(); itemsize -= 2; break; @@ -351,7 +351,7 @@ void ScummEngine_v7::readIndexBlock(uint32 blocktype, uint32 itemsize) { int num; char *ptr; switch (blocktype) { - case MKID_BE('ANAM'): // Used by: The Dig, FT + case MKTAG('A','N','A','M'): // Used by: The Dig, FT debug(9, "found ANAM block, reading audio names"); num = _fileHandle->readUint16LE(); ptr = (char*)malloc(num * 9); @@ -359,7 +359,7 @@ void ScummEngine_v7::readIndexBlock(uint32 blocktype, uint32 itemsize) { _imuseDigital->setAudioNames(num, ptr); break; - case MKID_BE('DRSC'): // Used by: COMI + case MKTAG('D','R','S','C'): // Used by: COMI readResTypeList(rtRoomScripts); break; @@ -372,37 +372,37 @@ void ScummEngine_v7::readIndexBlock(uint32 blocktype, uint32 itemsize) { void ScummEngine_v70he::readIndexBlock(uint32 blocktype, uint32 itemsize) { int i; switch (blocktype) { - case MKID_BE('DIRI'): + case MKTAG('D','I','R','I'): readResTypeList(rtRoomImage); break; - case MKID_BE('DIRM'): + case MKTAG('D','I','R','M'): readResTypeList(rtImage); break; - case MKID_BE('DIRT'): + case MKTAG('D','I','R','T'): readResTypeList(rtTalkie); break; - case MKID_BE('DLFL'): + case MKTAG('D','L','F','L'): i = _fileHandle->readUint16LE(); _fileHandle->seek(-2, SEEK_CUR); _heV7RoomOffsets = (byte *)calloc(2 + (i * 4), 1); _fileHandle->read(_heV7RoomOffsets, (2 + (i * 4)) ); break; - case MKID_BE('DISK'): + case MKTAG('D','I','S','K'): i = _fileHandle->readUint16LE(); _heV7DiskOffsets = (byte *)calloc(i, 1); _fileHandle->read(_heV7DiskOffsets, i); break; - case MKID_BE('SVER'): + case MKTAG('S','V','E','R'): // Index version number _fileHandle->seek(itemsize - 8, SEEK_CUR); break; - case MKID_BE('INIB'): + case MKTAG('I','N','I','B'): _fileHandle->seek(itemsize - 8, SEEK_CUR); debug(2, "INIB index block not yet handled, skipping"); break; @@ -415,17 +415,17 @@ void ScummEngine_v70he::readIndexBlock(uint32 blocktype, uint32 itemsize) { void ScummEngine::readIndexBlock(uint32 blocktype, uint32 itemsize) { int i; switch (blocktype) { - case MKID_BE('DCHR'): - case MKID_BE('DIRF'): + case MKTAG('D','C','H','R'): + case MKTAG('D','I','R','F'): readResTypeList(rtCharset); break; - case MKID_BE('DOBJ'): + case MKTAG('D','O','B','J'): debug(9, "found DOBJ block, reading object table"); readGlobalObjects(); break; - case MKID_BE('RNAM'): + case MKTAG('R','N','A','M'): // Names of rooms. Maybe we should put them into a table, for use by the debugger? if (_game.heversion >= 80) { for (int room; (room = _fileHandle->readUint16LE()); ) { @@ -449,32 +449,32 @@ void ScummEngine::readIndexBlock(uint32 blocktype, uint32 itemsize) { } break; - case MKID_BE('DROO'): - case MKID_BE('DIRR'): + case MKTAG('D','R','O','O'): + case MKTAG('D','I','R','R'): readResTypeList(rtRoom); break; - case MKID_BE('DSCR'): - case MKID_BE('DIRS'): + case MKTAG('D','S','C','R'): + case MKTAG('D','I','R','S'): readResTypeList(rtScript); break; - case MKID_BE('DCOS'): - case MKID_BE('DIRC'): + case MKTAG('D','C','O','S'): + case MKTAG('D','I','R','C'): readResTypeList(rtCostume); break; - case MKID_BE('MAXS'): + case MKTAG('M','A','X','S'): readMAXS(itemsize); allocateArrays(); break; - case MKID_BE('DIRN'): - case MKID_BE('DSOU'): + case MKTAG('D','I','R','N'): + case MKTAG('D','S','O','U'): readResTypeList(rtSound); break; - case MKID_BE('AARY'): + case MKTAG('A','A','R','Y'): readArrayFromIndexFile(); break; @@ -1287,14 +1287,14 @@ void ScummEngine::allocateArrays() { _arraySlot = (byte *)calloc(_numArray, 1); } - _res->allocResTypeData(rtCostume, (_game.features & GF_NEW_COSTUMES) ? MKID_BE('AKOS') : MKID_BE('COST'), + _res->allocResTypeData(rtCostume, (_game.features & GF_NEW_COSTUMES) ? MKTAG('A','K','O','S') : MKTAG('C','O','S','T'), _numCostumes, "costume", 1); - _res->allocResTypeData(rtRoom, MKID_BE('ROOM'), _numRooms, "room", 1); - _res->allocResTypeData(rtRoomImage, MKID_BE('RMIM'), _numRooms, "room image", 1); - _res->allocResTypeData(rtRoomScripts, MKID_BE('RMSC'), _numRooms, "room script", 1); - _res->allocResTypeData(rtSound, MKID_BE('SOUN'), _numSounds, "sound", 2); - _res->allocResTypeData(rtScript, MKID_BE('SCRP'), _numScripts, "script", 1); - _res->allocResTypeData(rtCharset, MKID_BE('CHAR'), _numCharsets, "charset", 1); + _res->allocResTypeData(rtRoom, MKTAG('R','O','O','M'), _numRooms, "room", 1); + _res->allocResTypeData(rtRoomImage, MKTAG('R','M','I','M'), _numRooms, "room image", 1); + _res->allocResTypeData(rtRoomScripts, MKTAG('R','M','S','C'), _numRooms, "room script", 1); + _res->allocResTypeData(rtSound, MKTAG('S','O','U','N'), _numSounds, "sound", 2); + _res->allocResTypeData(rtScript, MKTAG('S','C','R','P'), _numScripts, "script", 1); + _res->allocResTypeData(rtCharset, MKTAG('C','H','A','R'), _numCharsets, "charset", 1); _res->allocResTypeData(rtObjectName, 0, _numNewNames, "new name", 0); _res->allocResTypeData(rtInventory, 0, _numInventory, "inventory", 0); _res->allocResTypeData(rtTemp, 0, 10, "temp", 0); @@ -1304,8 +1304,8 @@ void ScummEngine::allocateArrays() { _res->allocResTypeData(rtString, 0, _numArray, "array", 0); _res->allocResTypeData(rtFlObject, 0, _numFlObject, "flobject", 0); _res->allocResTypeData(rtMatrix, 0, 10, "boxes", 0); - _res->allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1); - _res->allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1); + _res->allocResTypeData(rtImage, MKTAG('A','W','I','Z'), _numImages, "images", 1); + _res->allocResTypeData(rtTalkie, MKTAG('T','L','K','E'), _numTalkies, "talkie", 1); } void ScummEngine_v70he::allocateArrays() { @@ -1464,35 +1464,35 @@ const byte *findResourceSmall(uint32 tag, const byte *searchin) { uint16 newTag2Old(uint32 newTag) { switch (newTag) { - case (MKID_BE('RMHD')): + case (MKTAG('R','M','H','D')): return (0x4448); // HD - case (MKID_BE('IM00')): + case (MKTAG('I','M','0','0')): return (0x4D42); // BM - case (MKID_BE('EXCD')): + case (MKTAG('E','X','C','D')): return (0x5845); // EX - case (MKID_BE('ENCD')): + case (MKTAG('E','N','C','D')): return (0x4E45); // EN - case (MKID_BE('SCAL')): + case (MKTAG('S','C','A','L')): return (0x4153); // SA - case (MKID_BE('LSCR')): + case (MKTAG('L','S','C','R')): return (0x534C); // LS - case (MKID_BE('OBCD')): + case (MKTAG('O','B','C','D')): return (0x434F); // OC - case (MKID_BE('OBIM')): + case (MKTAG('O','B','I','M')): return (0x494F); // OI - case (MKID_BE('SMAP')): + case (MKTAG('S','M','A','P')): return (0x4D42); // BM - case (MKID_BE('CLUT')): + case (MKTAG('C','L','U','T')): return (0x4150); // PA - case (MKID_BE('BOXD')): + case (MKTAG('B','O','X','D')): return (0x5842); // BX - case (MKID_BE('CYCL')): + case (MKTAG('C','Y','C','L')): return (0x4343); // CC - case (MKID_BE('EPAL')): + case (MKTAG('E','P','A','L')): return (0x5053); // SP - case (MKID_BE('TILE')): + case (MKTAG('T','I','L','E')): return (0x4C54); // TL - case (MKID_BE('ZP00')): + case (MKTAG('Z','P','0','0')): return (0x505A); // ZP default: return (0); diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index 58b6cdb105..06fa0f2c39 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -264,7 +264,7 @@ void ScummEngine::setupRoomSubBlocks() { // // Determine the room dimensions (width/height) // - rmhd = (const RoomHeader *)findResourceData(MKID_BE('RMHD'), roomptr); + rmhd = (const RoomHeader *)findResourceData(MKTAG('R','M','H','D'), roomptr); if (_game.version == 8) { _roomWidth = READ_LE_UINT32(&(rmhd->v8.width)); @@ -286,18 +286,18 @@ void ScummEngine::setupRoomSubBlocks() { if (_game.version == 8) { _IM00_offs = getObjectImage(roomptr, 1) - roomptr; } else if (_game.features & GF_SMALL_HEADER) { - _IM00_offs = findResourceData(MKID_BE('IM00'), roomptr) - roomptr; + _IM00_offs = findResourceData(MKTAG('I','M','0','0'), roomptr) - roomptr; } else if (_game.heversion >= 70) { byte *roomImagePtr = getResourceAddress(rtRoomImage, _roomResource); - _IM00_offs = findResource(MKID_BE('IM00'), roomImagePtr) - roomImagePtr; + _IM00_offs = findResource(MKTAG('I','M','0','0'), roomImagePtr) - roomImagePtr; } else { - _IM00_offs = findResource(MKID_BE('IM00'), findResource(MKID_BE('RMIM'), roomptr)) - roomptr; + _IM00_offs = findResource(MKTAG('I','M','0','0'), findResource(MKTAG('R','M','I','M'), roomptr)) - roomptr; } // // Look for an exit script // - ptr = findResourceData(MKID_BE('EXCD'), roomResPtr); + ptr = findResourceData(MKTAG('E','X','C','D'), roomResPtr); if (ptr) _EXCD_offs = ptr - roomResPtr; if (_dumpScripts && _EXCD_offs) @@ -306,7 +306,7 @@ void ScummEngine::setupRoomSubBlocks() { // // Look for an entry script // - ptr = findResourceData(MKID_BE('ENCD'), roomResPtr); + ptr = findResourceData(MKTAG('E','N','C','D'), roomResPtr); if (ptr) _ENCD_offs = ptr - roomResPtr; if (_dumpScripts && _ENCD_offs) @@ -326,7 +326,7 @@ void ScummEngine::setupRoomSubBlocks() { if (_game.features & GF_SMALL_HEADER) { ResourceIterator localScriptIterator(searchptr, true); - while ((ptr = localScriptIterator.findNext(MKID_BE('LSCR'))) != NULL) { + while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) { int id = 0; ptr += _resourceHeaderSize; /* skip tag & size */ id = ptr[0]; @@ -341,7 +341,7 @@ void ScummEngine::setupRoomSubBlocks() { } } else if (_game.heversion >= 90) { ResourceIterator localScriptIterator2(searchptr, false); - while ((ptr = localScriptIterator2.findNext(MKID_BE('LSC2'))) != NULL) { + while ((ptr = localScriptIterator2.findNext(MKTAG('L','S','C','2'))) != NULL) { int id = 0; ptr += _resourceHeaderSize; /* skip tag & size */ @@ -359,7 +359,7 @@ void ScummEngine::setupRoomSubBlocks() { } ResourceIterator localScriptIterator(searchptr, false); - while ((ptr = localScriptIterator.findNext(MKID_BE('LSCR'))) != NULL) { + while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) { int id = 0; ptr += _resourceHeaderSize; /* skip tag & size */ @@ -376,7 +376,7 @@ void ScummEngine::setupRoomSubBlocks() { } else { ResourceIterator localScriptIterator(searchptr, false); - while ((ptr = localScriptIterator.findNext(MKID_BE('LSCR'))) != NULL) { + while ((ptr = localScriptIterator.findNext(MKTAG('L','S','C','R'))) != NULL) { int id = 0; ptr += _resourceHeaderSize; /* skip tag & size */ @@ -403,18 +403,18 @@ void ScummEngine::setupRoomSubBlocks() { } // Locate the EGA palette (currently unused). - ptr = findResourceData(MKID_BE('EPAL'), roomptr); + ptr = findResourceData(MKTAG('E','P','A','L'), roomptr); if (ptr) _EPAL_offs = ptr - roomptr; // Locate the standard room palette (for V3-V5 games). - ptr = findResourceData(MKID_BE('CLUT'), roomptr); + ptr = findResourceData(MKTAG('C','L','U','T'), roomptr); if (ptr) _CLUT_offs = ptr - roomptr; // Locate the standard room palettes (for V6+ games). if (_game.version >= 6) { - ptr = findResource(MKID_BE('PALS'), roomptr); + ptr = findResource(MKTAG('P','A','L','S'), roomptr); if (ptr) { _PALS_offs = ptr - roomptr; } @@ -425,7 +425,7 @@ void ScummEngine::setupRoomSubBlocks() { if (_game.version == 8) trans = (byte)READ_LE_UINT32(&(rmhd->v8.transparency)); else { - ptr = findResourceData(MKID_BE('TRNS'), roomptr); + ptr = findResourceData(MKTAG('T','R','N','S'), roomptr); if (ptr) trans = ptr[0]; else @@ -434,7 +434,7 @@ void ScummEngine::setupRoomSubBlocks() { // Actor Palette in HE 70 games if (_game.heversion == 70) { - ptr = findResourceData(MKID_BE('REMP'), roomptr); + ptr = findResourceData(MKTAG('R','E','M','P'), roomptr); if (ptr) { for (i = 0; i < 256; i++) _HEV7ActorPalette[i] = *ptr++; @@ -485,7 +485,7 @@ void ScummEngine::resetRoomSubBlocks() { _res->nukeResource(rtMatrix, 1); _res->nukeResource(rtMatrix, 2); if (_game.features & GF_SMALL_HEADER) { - ptr = findResourceData(MKID_BE('BOXD'), roomptr); + ptr = findResourceData(MKTAG('B','O','X','D'), roomptr); if (ptr) { byte numOfBoxes = *ptr; int size; @@ -506,21 +506,21 @@ void ScummEngine::resetRoomSubBlocks() { } } else { - ptr = findResourceData(MKID_BE('BOXD'), roomptr); + ptr = findResourceData(MKTAG('B','O','X','D'), roomptr); if (ptr) { int size = getResourceDataSize(ptr); _res->createResource(rtMatrix, 2, size); roomptr = getResourceAddress(rtRoom, _roomResource); - ptr = findResourceData(MKID_BE('BOXD'), roomptr); + ptr = findResourceData(MKTAG('B','O','X','D'), roomptr); memcpy(getResourceAddress(rtMatrix, 2), ptr, size); } - ptr = findResourceData(MKID_BE('BOXM'), roomptr); + ptr = findResourceData(MKTAG('B','O','X','M'), roomptr); if (ptr) { int size = getResourceDataSize(ptr); _res->createResource(rtMatrix, 1, size); roomptr = getResourceAddress(rtRoom, _roomResource); - ptr = findResourceData(MKID_BE('BOXM'), roomptr); + ptr = findResourceData(MKTAG('B','O','X','M'), roomptr); memcpy(getResourceAddress(rtMatrix, 1), ptr, size); } } @@ -531,7 +531,7 @@ void ScummEngine::resetRoomSubBlocks() { for (i = 1; i < _res->num[rtScaleTable]; i++) _res->nukeResource(rtScaleTable, i); - ptr = findResourceData(MKID_BE('SCAL'), roomptr); + ptr = findResourceData(MKTAG('S','C','A','L'), roomptr); if (ptr) { int s1, s2, y1, y2; if (_game.version == 8) { @@ -558,7 +558,7 @@ void ScummEngine::resetRoomSubBlocks() { // Color cycling // HE 7.0 games load resources but don't use them. if (_game.version >= 4 && _game.heversion <= 62) { - ptr = findResourceData(MKID_BE('CYCL'), roomptr); + ptr = findResourceData(MKTAG('C','Y','C','L'), roomptr); if (ptr) { initCycl(ptr); } @@ -567,7 +567,7 @@ void ScummEngine::resetRoomSubBlocks() { #ifdef ENABLE_HE // Polygons in HE 80+ games if (_game.heversion >= 80) { - ptr = findResourceData(MKID_BE('POLD'), roomptr); + ptr = findResourceData(MKTAG('P','O','L','D'), roomptr); if (ptr) { ((ScummEngine_v71he *)this)->_wiz->polygonLoad(ptr); } diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index fb34255683..3bfe51a77b 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -154,7 +154,7 @@ void ScummEngine::requestLoad(int slot) { } static bool saveSaveGameHeader(Common::OutSaveFile *out, SaveGameHeader &hdr) { - hdr.type = MKID_BE('SCVM'); + hdr.type = MKTAG('S','C','V','M'); hdr.size = 0; hdr.ver = CURRENT_VER; @@ -308,7 +308,7 @@ static bool loadSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &h hdr.size = in->readUint32LE(); hdr.ver = in->readUint32LE(); in->read(hdr.name, sizeof(hdr.name)); - return !in->err() && hdr.type == MKID_BE('SCVM'); + return !in->err() && hdr.type == MKTAG('S','C','V','M'); } bool ScummEngine::loadState(int slot, bool compat) { @@ -746,7 +746,7 @@ bool ScummEngine::loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos SaveInfoSection section; section.type = file->readUint32BE(); - if (section.type != MKID_BE('INFO')) { + if (section.type != MKTAG('I','N','F','O')) { return false; } @@ -793,7 +793,7 @@ bool ScummEngine::loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos void ScummEngine::saveInfos(Common::WriteStream* file) { SaveInfoSection section; - section.type = MKID_BE('INFO'); + section.type = MKTAG('I','N','F','O'); section.version = INFOSECTION_VERSION; section.size = SaveInfoSectionSize; diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index c6c1f5f58f..9e02f126cd 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -174,7 +174,7 @@ int ScummEngine::getVerbEntrypoint(int obj, int entry) { else if (_game.features & GF_SMALL_HEADER) verbptr = objptr + 19; else - verbptr = findResource(MKID_BE('VERB'), objptr); + verbptr = findResource(MKTAG('V','E','R','B'), objptr); assert(verbptr); @@ -921,7 +921,7 @@ void ScummEngine::runExitScript() { // be limiting ourselves to strictly reading the size from the header? if (_game.id == GID_INDY3 && !(_game.features & GF_OLD_BUNDLE)) { byte *roomptr = getResourceAddress(rtRoom, _roomResource); - const byte *excd = findResourceData(MKID_BE('EXCD'), roomptr) - _resourceHeaderSize; + const byte *excd = findResourceData(MKTAG('E','X','C','D'), roomptr) - _resourceHeaderSize; if (!excd || (getResourceDataSize(excd) < 1)) { debug(2, "Exit-%d is empty", _roomResource); return; diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index abe397ba7e..b2df1d0baa 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -3014,7 +3014,7 @@ void ScummEngine_v6::o6_setBoxSet() { ResourceIterator boxds(room, false); for (i = 0; i < arg; i++) - boxd = boxds.findNext(MKID_BE('BOXD')); + boxd = boxds.findNext(MKTAG('B','O','X','D')); if (!boxd) error("ScummEngine_v6::o6_setBoxSet: Can't find dboxes for set %d", arg); @@ -3027,7 +3027,7 @@ void ScummEngine_v6::o6_setBoxSet() { ResourceIterator boxms(room, false); for (i = 0; i < arg; i++) - boxm = boxms.findNext(MKID_BE('BOXM')); + boxm = boxms.findNext(MKTAG('B','O','X','M')); if (!boxm) error("ScummEngine_v6::o6_setBoxSet: Can't find mboxes for set %d", arg); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 7b98c86506..5aea36ef66 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1577,7 +1577,7 @@ void ScummEngine_v3::resetScumm() { // Load tile set and palette for the distaff byte *roomptr = getResourceAddress(rtRoom, 90); assert(roomptr); - const byte *palPtr = findResourceData(MKID_BE('CLUT'), roomptr); + const byte *palPtr = findResourceData(MKTAG('C','L','U','T'), roomptr); assert(palPtr - 4); setPCEPaletteFromPtr(palPtr); _gdi->_distaff = true; diff --git a/engines/scumm/smush/imuse_channel.cpp b/engines/scumm/smush/imuse_channel.cpp index a838fdba56..32fa99a870 100644 --- a/engines/scumm/smush/imuse_channel.cpp +++ b/engines/scumm/smush/imuse_channel.cpp @@ -29,6 +29,7 @@ #include "scumm/scumm.h" // For DEBUG_SMUSH #include "scumm/util.h" #include "scumm/smush/channel.h" +#include "scumm/imuse_digi/dimuse_codecs.h" // for decode12BitsSample namespace Scumm { @@ -64,7 +65,7 @@ bool ImuseChannel::appendData(Common::SeekableReadStream &b, int32 size) { assert(size > 8); uint32 imus_type = b.readUint32BE(); /*uint32 imus_size =*/ b.readUint32BE(); - if (imus_type != MKID_BE('iMUS')) + if (imus_type != MKTAG('i','M','U','S')) error("Invalid Chunk for imuse_channel"); size -= 8; _tbufferSize = size; @@ -115,7 +116,7 @@ bool ImuseChannel::handleMap(byte *data) { size -= 8; switch (subType) { - case MKID_BE('FRMT'): + case MKTAG('F','R','M','T'): if (subSize != 20) error("invalid size for FRMT Chunk"); //uint32 imuse_start = READ_BE_UINT32(data); @@ -125,14 +126,14 @@ bool ImuseChannel::handleMap(byte *data) { _channels = READ_BE_UINT32(data+16); assert(_channels == 1 || _channels == 2); break; - case MKID_BE('TEXT'): + case MKTAG('T','E','X','T'): // Ignore this break; - case MKID_BE('REGN'): + case MKTAG('R','E','G','N'): if (subSize != 8) error("invalid size for REGN Chunk"); break; - case MKID_BE('STOP'): + case MKTAG('S','T','O','P'): if (subSize != 4) error("invalid size for STOP Chunk"); break; @@ -171,28 +172,10 @@ void ImuseChannel::decode() { } } - // FIXME: Code duplication! See decode12BitsSample() in imuse_digi/dimuse_codecs.cpp - - int loop_size = _sbufferSize / 3; - int new_size = loop_size * 4; - byte *keep, *decoded; - uint32 value; - keep = decoded = (byte *)malloc(new_size); - assert(keep); - unsigned char * source = _sbuffer; - - while (loop_size--) { - byte v1 = *source++; - byte v2 = *source++; - byte v3 = *source++; - value = ((((v2 & 0x0f) << 8) | v1) << 4) - 0x8000; - WRITE_BE_UINT16(decoded, value); decoded += 2; - value = ((((v2 & 0xf0) << 4) | v3) << 4) - 0x8000; - WRITE_BE_UINT16(decoded, value); decoded += 2; - } + byte *keep; + _sbufferSize = BundleCodecs::decode12BitsSample(_sbuffer, &keep, _sbufferSize); free(_sbuffer); _sbuffer = (byte *)keep; - _sbufferSize = new_size; } bool ImuseChannel::handleSubTags(int32 &offset) { @@ -201,13 +184,13 @@ bool ImuseChannel::handleSubTags(int32 &offset) { uint32 size = READ_BE_UINT32(_tbuffer + offset + 4); uint32 available_size = _tbufferSize - offset; switch (type) { - case MKID_BE('MAP '): + case MKTAG('M','A','P',' '): _inData = false; if (available_size >= (size + 8)) { handleMap((byte *)_tbuffer + offset); } break; - case MKID_BE('DATA'): + case MKTAG('D','A','T','A'): _inData = true; _dataSize = size; offset += 8; diff --git a/engines/scumm/smush/saud_channel.cpp b/engines/scumm/smush/saud_channel.cpp index 94df70633f..04ed955224 100644 --- a/engines/scumm/smush/saud_channel.cpp +++ b/engines/scumm/smush/saud_channel.cpp @@ -50,7 +50,7 @@ bool SaudChannel::handleSubTags(int32 &offset) { uint32 available_size = _tbufferSize - offset; switch (type) { - case MKID_BE('STRK'): + case MKTAG('S','T','R','K'): _inData = false; if (available_size >= (size + 8)) { int32 subSize = READ_BE_UINT32((byte *)_tbuffer + offset + 4); @@ -60,14 +60,14 @@ bool SaudChannel::handleSubTags(int32 &offset) { } else return false; break; - case MKID_BE('SMRK'): + case MKTAG('S','M','R','K'): _inData = false; if (available_size >= (size + 8)) _markReached = true; else return false; break; - case MKID_BE('SHDR'): + case MKTAG('S','H','D','R'): _inData = false; if (available_size >= (size + 8)) { int32 subSize = READ_BE_UINT32((byte *)_tbuffer + offset + 4); @@ -76,7 +76,7 @@ bool SaudChannel::handleSubTags(int32 &offset) { } else return false; break; - case MKID_BE('SDAT'): + case MKTAG('S','D','A','T'): _inData = true; _dataSize = size; offset += 8; @@ -123,7 +123,7 @@ bool SaudChannel::appendData(Common::SeekableReadStream &b, int32 size) { assert(size > 8); uint32 saud_type = b.readUint32BE(); /*uint32 saud_size =*/ b.readUint32BE(); - if (saud_type != MKID_BE('SAUD')) + if (saud_type != MKTAG('S','A','U','D')) error("Invalid Chunk for SaudChannel : %X", saud_type); size -= 8; _dataSize = -2; diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index fe2b9d99ff..0e4f588593 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -190,7 +190,7 @@ static StringResource *getStrings(ScummEngine *vm, const char *file, bool is_enc theFile.read(filebuffer, length); filebuffer[length] = 0; - if (is_encoded && READ_BE_UINT32(filebuffer) == MKID_BE('ETRS')) { + if (is_encoded && READ_BE_UINT32(filebuffer) == MKTAG('E','T','R','S')) { assert(length > ETRS_HEADER_LENGTH); length -= ETRS_HEADER_LENGTH; for (int i = 0; i < length; ++i) { @@ -507,7 +507,7 @@ void SmushPlayer::handleTextResource(uint32 subType, int32 subSize, Common::Seek const char *str; char *string = NULL, *string2 = NULL; - if (subType == MKID_BE('TEXT')) { + if (subType == MKTAG('T','E','X','T')) { string = (char *)malloc(subSize - 16); str = string; b.read(string, subSize - 16); @@ -845,40 +845,40 @@ void SmushPlayer::handleFrame(int32 frameSize, Common::SeekableReadStream &b) { const int32 subSize = b.readUint32BE(); const int32 subOffset = b.pos(); switch (subType) { - case MKID_BE('NPAL'): + case MKTAG('N','P','A','L'): handleNewPalette(subSize, b); break; - case MKID_BE('FOBJ'): + case MKTAG('F','O','B','J'): handleFrameObject(subSize, b); break; #ifdef USE_ZLIB - case MKID_BE('ZFOB'): + case MKTAG('Z','F','O','B'): handleZlibFrameObject(subSize, b); break; #endif - case MKID_BE('PSAD'): + case MKTAG('P','S','A','D'): if (!_compressedFileMode) handleSoundFrame(subSize, b); break; - case MKID_BE('TRES'): + case MKTAG('T','R','E','S'): handleTextResource(subType, subSize, b); break; - case MKID_BE('XPAL'): + case MKTAG('X','P','A','L'): handleDeltaPalette(subSize, b); break; - case MKID_BE('IACT'): + case MKTAG('I','A','C','T'): handleIACT(subSize, b); break; - case MKID_BE('STOR'): + case MKTAG('S','T','O','R'): handleStore(subSize, b); break; - case MKID_BE('FTCH'): + case MKTAG('F','T','C','H'): handleFetch(subSize, b); break; - case MKID_BE('SKIP'): + case MKTAG('S','K','I','P'): _vm->_insane->procSKIP(subSize, b); break; - case MKID_BE('TEXT'): + case MKTAG('T','E','X','T'): handleTextResource(subType, subSize, b); break; default: @@ -990,7 +990,7 @@ void SmushPlayer::parseNextFrame() { const uint32 subType = _base->readUint32BE(); const int32 subSize = _base->readUint32BE(); const int32 subOffset = _base->pos(); - assert(subType == MKID_BE('AHDR')); + assert(subType == MKTAG('A','H','D','R')); handleAnimHeader(subSize, *_base); _base->seek(subOffset + subSize, SEEK_SET); @@ -1029,10 +1029,10 @@ void SmushPlayer::parseNextFrame() { debug(3, "Chunk: %s at %x", tag2str(subType), subOffset); switch (subType) { - case MKID_BE('AHDR'): // FT INSANE may seek file to the beginning + case MKTAG('A','H','D','R'): // FT INSANE may seek file to the beginning handleAnimHeader(subSize, *_base); break; - case MKID_BE('FRME'): + case MKTAG('F','R','M','E'): handleFrame(subSize, *_base); break; default: diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 0051319151..54f35c1969 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -206,7 +206,7 @@ void Sound::playSound(int soundID) { // Support for SFX in Monkey Island 1, Mac version // This is rather hackish right now, but works OK. SFX are not sounding // 100% correct, though, not sure right now what is causing this. - else if (READ_BE_UINT32(ptr) == MKID_BE('Mac1')) { + else if (READ_BE_UINT32(ptr) == MKTAG('M','a','c','1')) { // Read info from the header size = READ_BE_UINT32(ptr+0x60); rate = READ_BE_UINT16(ptr+0x64); @@ -245,7 +245,7 @@ void Sound::playSound(int soundID) { _mixer->playStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID); } // Support for sampled sound effects in Monkey Island 1 and 2 - else if (_vm->_game.platform != Common::kPlatformFMTowns && READ_BE_UINT32(ptr) == MKID_BE('SBL ')) { + else if (_vm->_game.platform != Common::kPlatformFMTowns && READ_BE_UINT32(ptr) == MKTAG('S','B','L',' ')) { debugC(DEBUG_SOUND, "Using SBL sound effect"); // SBL resources essentially contain VOC sound data. @@ -316,7 +316,7 @@ void Sound::playSound(int soundID) { stream = Audio::makeRawStream(sound, size, rate, Audio::FLAG_UNSIGNED); _mixer->playStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID); } - else if (_vm->_game.platform != Common::kPlatformFMTowns && READ_BE_UINT32(ptr) == MKID_BE('SOUN')) { + else if (_vm->_game.platform != Common::kPlatformFMTowns && READ_BE_UINT32(ptr) == MKTAG('S','O','U','N')) { if (_vm->_game.version != 3) ptr += 2; @@ -415,7 +415,7 @@ void Sound::playSound(int soundID) { // Rather it seems that starting a new music is supposed to // automatically stop the old song. if (_vm->_imuse) { - if (READ_BE_UINT32(ptr) != MKID_BE('ASFX')) + if (READ_BE_UINT32(ptr) != MKTAG('A','S','F','X')) _vm->_imuse->stopAllSounds(); } } @@ -1090,15 +1090,15 @@ int ScummEngine::readSoundResource(int idx) { debugC(DEBUG_RESOURCE, " basetag: %s, total_size=%d", tag2str(basetag), total_size); switch (basetag) { - case MKID_BE('MIDI'): - case MKID_BE('iMUS'): + case MKTAG('M','I','D','I'): + case MKTAG('i','M','U','S'): if (_musicType != MDT_PCSPK && _musicType != MDT_PCJR) { _fileHandle->seek(-8, SEEK_CUR); _fileHandle->read(_res->createResource(rtSound, idx, total_size + 8), total_size + 8); return 1; } break; - case MKID_BE('SOU '): + case MKTAG('S','O','U',' '): best_pri = -1; while (pos < total_size) { tag = _fileHandle->readUint32BE(); @@ -1108,32 +1108,32 @@ int ScummEngine::readSoundResource(int idx) { pri = -1; switch (tag) { - case MKID_BE('TOWS'): + case MKTAG('T','O','W','S'): pri = 16; break; - case MKID_BE('SBL '): + case MKTAG('S','B','L',' '): pri = 15; break; - case MKID_BE('ADL '): + case MKTAG('A','D','L',' '): pri = 1; if (_musicType == MDT_ADLIB) pri = 10; break; - case MKID_BE('AMI '): + case MKTAG('A','M','I',' '): pri = 3; break; - case MKID_BE('ROL '): + case MKTAG('R','O','L',' '): pri = 3; if (_native_mt32) pri = 5; break; - case MKID_BE('GMD '): + case MKTAG('G','M','D',' '): pri = 4; break; - case MKID_BE('MAC '): // Occurs in Mac MI2, FOA + case MKTAG('M','A','C',' '): // Occurs in Mac MI2, FOA pri = 2; break; - case MKID_BE('SPK '): + case MKTAG('S','P','K',' '): pri = -1; // if (_musicType == MDT_PCSPK || _musicType == MDT_PCJR) // pri = 11; @@ -1163,7 +1163,7 @@ int ScummEngine::readSoundResource(int idx) { return 1; } break; - case MKID_BE('Mac0'): + case MKTAG('M','a','c','0'): _fileHandle->seek(-12, SEEK_CUR); total_size = _fileHandle->readUint32BE() - 8; ptr = (byte *)calloc(total_size, 1); @@ -1173,11 +1173,11 @@ int ScummEngine::readSoundResource(int idx) { free(ptr); return 1; - case MKID_BE('Mac1'): - case MKID_BE('RIFF'): - case MKID_BE('TALK'): - case MKID_BE('DIGI'): - case MKID_BE('Crea'): + case MKTAG('M','a','c','1'): + case MKTAG('R','I','F','F'): + case MKTAG('T','A','L','K'): + case MKTAG('D','I','G','I'): + case MKTAG('C','r','e','a'): case 0x460e200d: // WORKAROUND bug # 1311447 _fileHandle->seek(-12, SEEK_CUR); total_size = _fileHandle->readUint32BE(); @@ -1186,7 +1186,7 @@ int ScummEngine::readSoundResource(int idx) { //dumpResource("sound-", idx, ptr); return 1; - case MKID_BE('HSHD'): + case MKTAG('H','S','H','D'): // HE sound type without SOUN header _fileHandle->seek(-16, SEEK_CUR); total_size = max_total_size + 8; @@ -1195,7 +1195,7 @@ int ScummEngine::readSoundResource(int idx) { //dumpResource("sound-", idx, ptr); return 1; - case MKID_BE('FMUS'): { + case MKTAG('F','M','U','S'): { // Used in 3DO version of puttputt joins the parade and probably others // Specifies a separate file to be used for music from what I gather. int tmpsize; @@ -1406,20 +1406,20 @@ static byte *writeVLQ(byte *ptr, int value) { static byte Mac0ToGMInstrument(uint32 type, int &transpose) { transpose = 0; switch (type) { - case MKID_BE('MARI'): return 12; - case MKID_BE('PLUC'): return 45; - case MKID_BE('HARM'): return 22; - case MKID_BE('PIPE'): return 19; - case MKID_BE('TROM'): transpose = -12; return 57; - case MKID_BE('STRI'): return 48; - case MKID_BE('HORN'): return 60; - case MKID_BE('VIBE'): return 11; - case MKID_BE('SHAK'): return 77; - case MKID_BE('PANP'): return 75; - case MKID_BE('WHIS'): return 76; - case MKID_BE('ORGA'): return 17; - case MKID_BE('BONG'): return 115; - case MKID_BE('BASS'): transpose = -24; return 35; + case MKTAG('M','A','R','I'): return 12; + case MKTAG('P','L','U','C'): return 45; + case MKTAG('H','A','R','M'): return 22; + case MKTAG('P','I','P','E'): return 19; + case MKTAG('T','R','O','M'): transpose = -12; return 57; + case MKTAG('S','T','R','I'): return 48; + case MKTAG('H','O','R','N'): return 60; + case MKTAG('V','I','B','E'): return 11; + case MKTAG('S','H','A','K'): return 77; + case MKTAG('P','A','N','P'): return 75; + case MKTAG('W','H','I','S'): return 76; + case MKTAG('O','R','G','A'): return 17; + case MKTAG('B','O','N','G'): return 115; + case MKTAG('B','A','S','S'): transpose = -24; return 35; default: error("Unknown Mac0 instrument %s found", tag2str(type)); } @@ -1504,13 +1504,13 @@ static void convertMac0Resource(ResourceManager *res, int idx, byte *src_ptr, in // Parse the three channels for (i = 0; i < 3; i++) { - assert(READ_BE_UINT32(src_ptr) == MKID_BE('Chan')); + assert(READ_BE_UINT32(src_ptr) == MKTAG('C','h','a','n')); len = READ_BE_UINT32(src_ptr + 4); track_len[i] = len - 24; track_instr[i] = Mac0ToGMInstrument(READ_BE_UINT32(src_ptr + 8), track_transpose[i]); track_data[i] = src_ptr + 12; src_ptr += len; - looped = (READ_BE_UINT32(src_ptr - 8) == MKID_BE('Loop')); + looped = (READ_BE_UINT32(src_ptr - 8) == MKTAG('L','o','o','p')); // For each note event, we need up to 6 bytes for the // Note On (3 VLQ, 3 event), and 6 bytes for the Note diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index e8f75dd901..6d5eb3fad7 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -1499,7 +1499,7 @@ void ScummEngine::drawVerbBitmap(int verb, int x, int y) { } imptr = getObjectImage(obim, 1); } else { - const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID_BE('IMHD'), obim); + const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKTAG('I','M','H','D'), obim); if (_game.version >= 7) { imgw = READ_LE_UINT16(&imhd->v7.width) / 8; imgh = READ_LE_UINT16(&imhd->v7.height) / 8; |