mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 03:10:37 +00:00
Add HE7.2 difference in o_getResourceSize().
Add support for checking size of music resource. svn-id: r17595
This commit is contained in:
parent
50bf840b9f
commit
a3882f3af7
@ -808,6 +808,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 getMusicResourceSize(int id);
|
||||
|
||||
/* HE version 72 script opcodes */
|
||||
void o72_pushDWord();
|
||||
@ -895,6 +896,7 @@ protected:
|
||||
void o80_drawWizPolygon();
|
||||
void o80_unknownE0();
|
||||
void o80_pickVarRandom();
|
||||
void o80_getResourceSize();
|
||||
};
|
||||
|
||||
struct SpriteInfo;
|
||||
|
@ -1753,4 +1753,58 @@ byte *ScummEngine_v72he::getStringAddress(int i) {
|
||||
return ((ScummEngine_v72he::ArrayHeader *)addr)->data;
|
||||
}
|
||||
|
||||
int ScummEngine_v72he::getMusicResourceSize(int id) {
|
||||
int size, total_size;
|
||||
uint tracks, skip;
|
||||
char buf[32], buf1[128];
|
||||
File musicFile;
|
||||
|
||||
sprintf(buf, "%s.he4", getGameName());
|
||||
|
||||
if (_substResFileNameIndex > 0) {
|
||||
generateSubstResFileName(buf, buf1, sizeof(buf1));
|
||||
strcpy(buf, buf1);
|
||||
}
|
||||
if (musicFile.open(buf) == false) {
|
||||
warning("getMusicResourceSize: Music file is not open");
|
||||
return 0;
|
||||
}
|
||||
musicFile.seek(4, SEEK_SET);
|
||||
total_size = musicFile.readUint32BE();
|
||||
musicFile.seek(+8, SEEK_CUR);
|
||||
tracks = musicFile.readUint32LE();
|
||||
|
||||
skip = 0;
|
||||
if (id >= 8500)
|
||||
skip = (id - 8500);
|
||||
else if (id >= 8000)
|
||||
skip = (id - 8000);
|
||||
else if (id >= 4000)
|
||||
skip = (id - 4000);
|
||||
|
||||
if (skip > tracks - 1)
|
||||
skip = 0;
|
||||
|
||||
if (_heversion >= 80) {
|
||||
// Skip to offsets
|
||||
musicFile.seek(+40, SEEK_CUR);
|
||||
|
||||
// Skip to correct music header
|
||||
skip *= 21;
|
||||
} else {
|
||||
// Skip to offsets
|
||||
musicFile.seek(+4, SEEK_CUR);
|
||||
|
||||
// Skip to correct music header
|
||||
skip *= 25;
|
||||
}
|
||||
|
||||
musicFile.seek(+skip, SEEK_CUR);
|
||||
musicFile.readUint32LE();
|
||||
size = musicFile.readUint32LE();
|
||||
musicFile.close();
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
|
@ -2191,9 +2191,9 @@ void ScummEngine_v100he::o100_writeFile() {
|
||||
}
|
||||
|
||||
void ScummEngine_v100he::o100_getResourceSize() {
|
||||
int size = 0, type;
|
||||
int size, type;
|
||||
|
||||
int idx = pop();
|
||||
int resid = pop();
|
||||
byte subOp = fetchScriptByte();
|
||||
|
||||
switch (subOp) {
|
||||
@ -2210,9 +2210,8 @@ void ScummEngine_v100he::o100_getResourceSize() {
|
||||
type = rtScript;
|
||||
break;
|
||||
case 72:
|
||||
if (idx > _numSounds) {
|
||||
// TODO Music resource size
|
||||
push(100);
|
||||
if (resid > _numSounds) {
|
||||
push(getMusicResourceSize(resid));
|
||||
return;
|
||||
}
|
||||
type = rtSound;
|
||||
@ -2221,8 +2220,8 @@ void ScummEngine_v100he::o100_getResourceSize() {
|
||||
error("o100_getResourceSize: default type %d", subOp);
|
||||
}
|
||||
|
||||
const byte *ptr = getResourceAddress(type, idx);
|
||||
if (ptr)
|
||||
const byte *ptr = getResourceAddress(type, resid);
|
||||
assert(ptr);
|
||||
size = READ_BE_UINT32(ptr + 4) - 8;
|
||||
push(size);
|
||||
}
|
||||
|
@ -2151,40 +2151,16 @@ void ScummEngine_v72he::o72_writeINI() {
|
||||
}
|
||||
|
||||
void ScummEngine_v72he::o72_getResourceSize() {
|
||||
int size = 0, type;
|
||||
int resid, size;
|
||||
|
||||
int idx = pop();
|
||||
byte subOp = fetchScriptByte();
|
||||
|
||||
switch (subOp) {
|
||||
case 13:
|
||||
if (idx > _numSounds) {
|
||||
// TODO Music resource size
|
||||
push(100);
|
||||
return;
|
||||
}
|
||||
type = rtSound;
|
||||
break;
|
||||
case 14:
|
||||
type = rtRoomImage;
|
||||
break;
|
||||
case 15:
|
||||
type = rtImage;
|
||||
break;
|
||||
case 16:
|
||||
type = rtCostume;
|
||||
break;
|
||||
case 17:
|
||||
type = rtScript;
|
||||
break;
|
||||
default:
|
||||
warning("o72_getResourceSize: default type %d", subOp);
|
||||
push(0);
|
||||
resid = pop();
|
||||
if (resid > _numSounds) {
|
||||
push(getMusicResourceSize(resid));
|
||||
return;
|
||||
}
|
||||
|
||||
const byte *ptr = getResourceAddress(type, idx);
|
||||
if (ptr)
|
||||
const byte *ptr = getResourceAddress(rtSound, resid);
|
||||
assert(ptr);
|
||||
size = READ_BE_UINT32(ptr + 4) - 8;
|
||||
push(size);
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ void ScummEngine_v80he::setupOpcodes() {
|
||||
OPCODE(o70_getCharIndexInString),
|
||||
OPCODE(o6_invalid),
|
||||
/* F8 */
|
||||
OPCODE(o72_getResourceSize),
|
||||
OPCODE(o80_getResourceSize),
|
||||
OPCODE(o72_setFilePath),
|
||||
OPCODE(o72_setWindowCaption),
|
||||
OPCODE(o70_polygonOps),
|
||||
@ -808,4 +808,40 @@ void ScummEngine_v80he::o80_pickVarRandom() {
|
||||
push(readArray(value, 0, num));
|
||||
}
|
||||
|
||||
void ScummEngine_v80he::o80_getResourceSize() {
|
||||
int size, type;
|
||||
|
||||
int resid = pop();
|
||||
byte subOp = fetchScriptByte();
|
||||
|
||||
switch (subOp) {
|
||||
case 13:
|
||||
if (resid > _numSounds) {
|
||||
push(getMusicResourceSize(resid));
|
||||
return;
|
||||
}
|
||||
type = rtSound;
|
||||
break;
|
||||
case 14:
|
||||
type = rtRoomImage;
|
||||
break;
|
||||
case 15:
|
||||
type = rtImage;
|
||||
break;
|
||||
case 16:
|
||||
type = rtCostume;
|
||||
break;
|
||||
case 17:
|
||||
type = rtScript;
|
||||
break;
|
||||
default:
|
||||
error("o80_getResourceSize: default type %d", subOp);
|
||||
}
|
||||
|
||||
const byte *ptr = getResourceAddress(type, resid);
|
||||
assert(ptr);
|
||||
size = READ_BE_UINT32(ptr + 4) - 8;
|
||||
push(size);
|
||||
}
|
||||
|
||||
} // End of namespace Scumm
|
||||
|
@ -352,7 +352,7 @@ void ScummEngine_v90he::setupOpcodes() {
|
||||
OPCODE(o70_getCharIndexInString),
|
||||
OPCODE(o6_invalid),
|
||||
/* F8 */
|
||||
OPCODE(o72_getResourceSize),
|
||||
OPCODE(o80_getResourceSize),
|
||||
OPCODE(o72_setFilePath),
|
||||
OPCODE(o72_setWindowCaption),
|
||||
OPCODE(o70_polygonOps),
|
||||
|
Loading…
Reference in New Issue
Block a user