mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
MADS: WIP handling of V2 walk nodes and walkable areas
This commit is contained in:
parent
9118f38b29
commit
be9c3bf72b
@ -201,9 +201,10 @@ Common::String DragonsphereScene::formAnimName(char sepChar, int suffixNum) {
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, int variant) {
|
||||
File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
|
||||
Common::String ext = Common::String::format(".WW%d", variant);
|
||||
File f(Resources::formatName(RESPREFIX_RM, _sceneId, ext));
|
||||
MadsPack codesPack(&f);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(0);
|
||||
|
||||
loadCodes(depthSurface, stream);
|
||||
|
||||
@ -213,22 +214,20 @@ void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, int variant) {
|
||||
|
||||
void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
|
||||
byte *destP = depthSurface.getData();
|
||||
byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
|
||||
byte *walkMap = new byte[stream->size()];
|
||||
stream->read(walkMap, stream->size());
|
||||
|
||||
byte runLength = stream->readByte();
|
||||
while (destP < endP && runLength > 0) {
|
||||
byte runValue = stream->readByte();
|
||||
|
||||
// Write out the run length
|
||||
Common::fill(destP, destP + runLength, runValue);
|
||||
destP += runLength;
|
||||
|
||||
// Get the next run length
|
||||
runLength = stream->readByte();
|
||||
for (int y = 0; y < 156; ++y) {
|
||||
for (int x = 0; x < 320; ++x) {
|
||||
int offset = x + (y * 320);
|
||||
if ((walkMap[offset / 8] << (offset % 8)) & 0x80)
|
||||
*destP++ = 1; // walkable
|
||||
else
|
||||
*destP++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (destP < endP)
|
||||
Common::fill(destP, endP, 0);
|
||||
delete[] walkMap;
|
||||
}
|
||||
|
||||
} // End of namespace Dragonsphere
|
||||
|
@ -169,9 +169,10 @@ Common::String PhantomScene::formAnimName(char sepChar, int suffixNum) {
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) {
|
||||
File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
|
||||
Common::String ext = Common::String::format(".WW%d", variant);
|
||||
File f(Resources::formatName(RESPREFIX_RM, _sceneId, ext));
|
||||
MadsPack codesPack(&f);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(0);
|
||||
|
||||
loadCodes(depthSurface, stream);
|
||||
|
||||
@ -181,22 +182,20 @@ void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) {
|
||||
|
||||
void SceneInfoPhantom::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
|
||||
byte *destP = depthSurface.getData();
|
||||
byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
|
||||
byte *walkMap = new byte[stream->size()];
|
||||
stream->read(walkMap, stream->size());
|
||||
|
||||
byte runLength = stream->readByte();
|
||||
while (destP < endP && runLength > 0) {
|
||||
byte runValue = stream->readByte();
|
||||
|
||||
// Write out the run length
|
||||
Common::fill(destP, destP + runLength, runValue);
|
||||
destP += runLength;
|
||||
|
||||
// Get the next run length
|
||||
runLength = stream->readByte();
|
||||
for (int y = 0; y < 156; ++y) {
|
||||
for (int x = 0; x < 320; ++x) {
|
||||
int offset = x + (y * 320);
|
||||
if ((walkMap[offset / 8] << (offset % 8)) & 0x80)
|
||||
*destP++ = 1; // walkable
|
||||
else
|
||||
*destP++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (destP < endP)
|
||||
Common::fill(destP, endP, 0);
|
||||
delete[] walkMap;
|
||||
}
|
||||
|
||||
} // End of namespace Phantom
|
||||
|
@ -151,30 +151,34 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
|
||||
_sceneId = sceneId;
|
||||
}
|
||||
|
||||
// TODO: The following isn't quite right for V2 games (it's all 0)
|
||||
_artFileNum = infoStream->readUint16LE();
|
||||
_depthStyle = infoStream->readUint16LE();
|
||||
_width = infoStream->readUint16LE();
|
||||
_height = infoStream->readUint16LE();
|
||||
int nodeCount = 20;
|
||||
|
||||
// HACK for V2 games (for now)
|
||||
if (_vm->getGameID() != GType_RexNebular) {
|
||||
if (_vm->getGameID() == GType_RexNebular) {
|
||||
_artFileNum = infoStream->readUint16LE();
|
||||
_depthStyle = infoStream->readUint16LE();
|
||||
_width = infoStream->readUint16LE();
|
||||
_height = infoStream->readUint16LE();
|
||||
|
||||
infoStream->skip(24);
|
||||
|
||||
nodeCount = infoStream->readUint16LE();
|
||||
_yBandsEnd = infoStream->readUint16LE();
|
||||
_yBandsStart = infoStream->readUint16LE();
|
||||
_maxScale = infoStream->readUint16LE();
|
||||
_minScale = infoStream->readUint16LE();
|
||||
for (int i = 0; i < DEPTH_BANDS_SIZE; ++i)
|
||||
_depthList[i] = infoStream->readUint16LE();
|
||||
_field4A = infoStream->readUint16LE();
|
||||
} else {
|
||||
_artFileNum = sceneId;
|
||||
_depthStyle = 0;
|
||||
_width = 320;
|
||||
_height = 156;
|
||||
|
||||
infoStream->skip(140);
|
||||
}
|
||||
|
||||
infoStream->skip(24);
|
||||
|
||||
int nodeCount = infoStream->readUint16LE();
|
||||
_yBandsEnd = infoStream->readUint16LE();
|
||||
_yBandsStart = infoStream->readUint16LE();
|
||||
_maxScale = infoStream->readUint16LE();
|
||||
_minScale = infoStream->readUint16LE();
|
||||
for (int i = 0; i < DEPTH_BANDS_SIZE; ++i)
|
||||
_depthList[i] = infoStream->readUint16LE();
|
||||
_field4A = infoStream->readUint16LE();
|
||||
|
||||
// Load the set of objects that are associated with the scene
|
||||
// Load the scene's walk nodes
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
WalkNode node;
|
||||
node.load(infoStream);
|
||||
@ -223,13 +227,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
|
||||
depthSurface.setSize(width, height);
|
||||
}
|
||||
|
||||
if (_vm->getGameID() == GType_RexNebular) {
|
||||
// Load the depth surface with the scene codes
|
||||
Common::SeekableReadStream *depthStream = infoPack.getItemStream(variant + 1);
|
||||
loadCodes(depthSurface, depthStream);
|
||||
delete depthStream;
|
||||
}
|
||||
|
||||
loadCodes(depthSurface, variant);
|
||||
infoFile.close();
|
||||
|
||||
if (_vm->getGameID() == GType_RexNebular) {
|
||||
|
Loading…
Reference in New Issue
Block a user