aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/intern.h1
-rw-r--r--scumm/resource_v7he.cpp29
-rw-r--r--scumm/script_v100he.cpp11
-rw-r--r--scumm/script_v72he.cpp15
-rw-r--r--scumm/script_v80he.cpp11
5 files changed, 34 insertions, 33 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index 089270a3d3..45ff6e8399 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -812,6 +812,7 @@ protected:
byte *heFindResource(uint32 tag, byte *ptr);
byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
int findObject(int x, int y, int num, int *args);
+ int getSoundResourceSize(int id);
/* HE version 72 script opcodes */
void o72_pushDWord();
diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp
index 52e92518b5..d5a2a1bc8f 100644
--- a/scumm/resource_v7he.cpp
+++ b/scumm/resource_v7he.cpp
@@ -28,6 +28,7 @@
#include "scumm/intern.h"
#include "scumm/resource.h"
#include "scumm/resource_v7he.h"
+#include "scumm/sound.h"
#include "scumm/util.h"
#include "common/stream.h"
@@ -1753,4 +1754,32 @@ byte *ScummEngine_v72he::getStringAddress(int i) {
return ((ScummEngine_v72he::ArrayHeader *)addr)->data;
}
+int ScummEngine_v72he::getSoundResourceSize(int id) {
+ const byte *ptr;
+ int offs, size;
+
+ if (id > _numSounds) {
+ _sound->getHEMusicDetails(id, offs, size);
+ } else {
+ ptr = getResourceAddress(rtSound, id);
+ if (!ptr)
+ return 0;
+
+ if (READ_UINT32(ptr) == MKID('HSHD')) {
+ ptr += READ_BE_UINT32(ptr + 4);
+ } else {
+ ptr += 8 + READ_BE_UINT32(ptr + 12);
+ }
+
+ if (READ_UINT32(ptr) == MKID('SBNG')) {
+ ptr += READ_BE_UINT32(ptr + 4);
+ }
+
+ assert(READ_UINT32(ptr) == MKID('SDAT'));
+ size = READ_BE_UINT32(ptr + 4) - 8;
+ }
+
+ return size;
+}
+
} // End of namespace Scumm
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index 1494cdc40f..c0939cc947 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -2211,16 +2211,7 @@ void ScummEngine_v100he::o100_getResourceSize() {
type = rtScript;
break;
case 72:
- if (resid > _numSounds) {
- int offs;
- _sound->getHEMusicDetails(resid, offs, size);
- push(size);
- } else {
- ptr = getResourceAddress(rtSound, resid);
- assert(ptr);
- size = READ_BE_UINT32(ptr + 4) - 40;
- push(size);
- }
+ push (getSoundResourceSize(resid));
return;
default:
error("o100_getResourceSize: default type %d", subOp);
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp
index b20716e850..a60ed8abe5 100644
--- a/scumm/script_v72he.cpp
+++ b/scumm/script_v72he.cpp
@@ -2156,19 +2156,8 @@ void ScummEngine_v72he::o72_writeINI() {
}
void ScummEngine_v72he::o72_getResourceSize() {
- int resid, size;
-
- resid = pop();
- if (resid > _numSounds) {
- int offs;
- _sound->getHEMusicDetails(resid, offs, size);
- push(size);
- } else {
- const byte *ptr = getResourceAddress(rtSound, resid);
- assert(ptr);
- size = READ_BE_UINT32(ptr + 4) - 40;
- push(size);
- }
+ int resid = pop();
+ push(getSoundResourceSize(resid));
}
void ScummEngine_v72he::o72_setFilePath() {
diff --git a/scumm/script_v80he.cpp b/scumm/script_v80he.cpp
index 8e523d90dc..482315f47b 100644
--- a/scumm/script_v80he.cpp
+++ b/scumm/script_v80he.cpp
@@ -814,16 +814,7 @@ void ScummEngine_v80he::o80_getResourceSize() {
switch (subOp) {
case 13:
- if (resid > _numSounds) {
- int offs;
- _sound->getHEMusicDetails(resid, offs, size);
- push(size);
- } else {
- ptr = getResourceAddress(rtSound, resid);
- assert(ptr);
- size = READ_BE_UINT32(ptr + 4) - 40;
- push(size);
- }
+ push (getSoundResourceSize(resid));
return;
case 14:
type = rtRoomImage;