aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/actor.cpp22
-rw-r--r--scumm/object.cpp6
-rw-r--r--scumm/resource.h15
3 files changed, 14 insertions, 29 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index d3aba7f03a..1cc051b5ca 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -1742,17 +1742,14 @@ void Actor::remapActorPaletteColor(int color, int new_color) {
return;
}
- akpl = _vm->findResource(MKID('AKPL'), akos);
+ akpl = _vm->findResourceData(MKID('AKPL'), akos);
if (!akpl) {
warning("Can't remap actor %d, costume %d doesn't contain an AKPL block", number, costume);
return;
}
- //get num palette entries
- akpl_size = RES_SIZE(akpl) - 8;
-
- //skip resource header
- akpl = RES_DATA(akpl);
+ // Get the number palette entries
+ akpl_size = _vm->getResourceDataSize(akpl);
for (i = 0; i < akpl_size; i++) {
akpl_color = *akpl++;
@@ -1783,26 +1780,21 @@ void Actor::remapActorPalette(int r_fact, int g_fact, int b_fact, int threshold)
return;
}
- akpl = _vm->findResource(MKID('AKPL'), akos);
+ akpl = _vm->findResourceData(MKID('AKPL'), akos);
if (!akpl) {
warning("Can't remap actor %d, costume %d doesn't contain an AKPL block", number, costume);
return;
}
- //get num palette entries
- akpl_size = RES_SIZE(akpl) - 8;
-
- //skip resource header
- akpl = RES_DATA(akpl);
+ // Get the number palette entries
+ akpl_size = _vm->getResourceDataSize(akpl);
- rgbs = _vm->findResource(MKID('RGBS'), akos);
+ rgbs = _vm->findResourceData(MKID('RGBS'), akos);
if (!rgbs) {
debugC(DEBUG_ACTORS, "Can't remap actor %d costume %d doesn't contain an RGB block", number, costume);
return;
}
- // skip resource header
- rgbs = RES_DATA(rgbs);
for (i = 0; i < akpl_size; i++) {
r = *rgbs++;
diff --git a/scumm/object.cpp b/scumm/object.cpp
index 0cad4b021b..57802bd735 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -1124,13 +1124,13 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id,
if (findWhat & foCheckAlreadyLoaded && getObjectIndex(id) != -1) {
if (_features & GF_OLD_BUNDLE) {
// I am not sure if this is even needed for old games...
- // but using RES_SIZE definitely won't work with OLD_BUNDLE, since it
- // assumes the size is 32 bit but in old games it's 16 bit
+ // but using READ_BE_UINT32 below to determine the resource size
+ // definitely won't work with OLD_BUNDLE games
error("findObjectInRoom foCheckAlreadyLoaded NYI for GF_OLD_BUNDLE (id = %d, room = %d)", id, room);
}
fo->obcd = obcdptr = getOBCDFromObject(id);
assert(obcdptr);
- fo->obim = obimptr = obcdptr + RES_SIZE(obcdptr);
+ fo->obim = obimptr = obcdptr + READ_BE_UINT32(obcdptr + 4);
fo->cdhd = (const CodeHeader *)findResourceData(MKID('CDHD'), obcdptr);
fo->imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obimptr);
return;
diff --git a/scumm/resource.h b/scumm/resource.h
index d2f0f125db..968f700f97 100644
--- a/scumm/resource.h
+++ b/scumm/resource.h
@@ -23,14 +23,6 @@
namespace Scumm {
-#if !defined(__GNUC__)
- #pragma START_PACK_STRUCTS
-#endif
-
-struct ResHdr {
- uint32 tag, size;
-} GCC_PACK;
-
enum ArrayType {
kBitArray = 1,
kNibbleArray = 2,
@@ -40,6 +32,10 @@ enum ArrayType {
kDwordArray = 6
};
+#if !defined(__GNUC__)
+ #pragma START_PACK_STRUCTS
+#endif
+
struct ArrayHeader {
int16 dim1;
int16 type;
@@ -51,9 +47,6 @@ struct ArrayHeader {
#pragma END_PACK_STRUCTS
#endif
-#define RES_DATA(x) (((const byte*)x) + sizeof(ResHdr))
-#define RES_SIZE(x) (READ_BE_UINT32(&((const ResHdr* )x)->size))
-
enum {
OF_OWNER_MASK = 0x0F,
OF_STATE_MASK = 0xF0,