mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-01 07:46:11 +00:00
MADS: Fixed loading of scene depth surface for Rex Nebular
This commit is contained in:
parent
408f5e79df
commit
0df4d0aed1
@ -68,6 +68,13 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
|
||||
MadsPack codesPack(&f);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(0);
|
||||
|
||||
loadCodes(depthSurface, stream);
|
||||
|
||||
delete stream;
|
||||
f.close();
|
||||
}
|
||||
|
||||
void SceneInfoNebular::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
|
||||
byte *destP = depthSurface.getData();
|
||||
byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
|
||||
|
||||
@ -85,8 +92,6 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
|
||||
|
||||
if (destP < endP)
|
||||
Common::fill(destP, endP, 0);
|
||||
delete stream;
|
||||
f.close();
|
||||
}
|
||||
|
||||
} // End of namespace Nebular
|
||||
|
@ -115,6 +115,8 @@ class SceneInfoNebular : public SceneInfo {
|
||||
protected:
|
||||
virtual void loadCodes(MSurface &depthSurface);
|
||||
|
||||
virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -229,7 +229,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
|
||||
palette[palIndex]._palIndex = var4;
|
||||
}
|
||||
|
||||
_vm->_palette->_rgbList[rgbIndex] = 0xffff;
|
||||
_vm->_palette->_rgbList[rgbIndex] = -1;
|
||||
|
||||
delete[] pal1;
|
||||
delete[] pal2;
|
||||
@ -541,7 +541,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
|
||||
}
|
||||
|
||||
_rgbList.clear();
|
||||
_rgbList[0] = _rgbList[1] = 0xffff;
|
||||
_rgbList[0] = _rgbList[1] = -1;
|
||||
|
||||
_v1 = 0;
|
||||
_lowRange = lowRange;
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
|
||||
class RGBList {
|
||||
private:
|
||||
uint16 _data[32];
|
||||
int16 _data[32];
|
||||
public:
|
||||
RGBList() { clear(); }
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
*/
|
||||
int scan();
|
||||
|
||||
uint16 &operator[](int idx) { return _data[idx]; }
|
||||
int16 &operator[](int idx) { return _data[idx]; }
|
||||
};
|
||||
|
||||
#define PALETTE_COUNT 256
|
||||
|
@ -383,7 +383,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
|
||||
if (vm->getGameID() == GType_RexNebular) {
|
||||
return new Nebular::SceneInfoNebular(vm);
|
||||
} else {
|
||||
return new SceneInfo(vm);
|
||||
error("Unknown game");
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,9 +453,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
|
||||
if (i < spriteInfoCount)
|
||||
spriteInfo.push_back(info);
|
||||
}
|
||||
|
||||
delete infoStream;
|
||||
infoFile.close();
|
||||
|
||||
int width = _width;
|
||||
int height = _height;
|
||||
@ -471,7 +469,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
|
||||
}
|
||||
|
||||
// Load the depth surface with the scene codes
|
||||
loadCodes(depthSurface);
|
||||
Common::SeekableReadStream *depthStream = infoPack.getItemStream(1);
|
||||
loadCodes(depthSurface, depthStream);
|
||||
delete depthStream;
|
||||
|
||||
infoFile.close();
|
||||
|
||||
// Get the ART resource
|
||||
if (sceneFlag) {
|
||||
@ -554,35 +556,6 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
|
||||
}
|
||||
}
|
||||
|
||||
void SceneInfo::loadCodes(MSurface &depthSurface) {
|
||||
File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
|
||||
MadsPack codesPack(&f);
|
||||
Common::SeekableReadStream *stream = codesPack.getItemStream(0);
|
||||
|
||||
uint16 width = _width;
|
||||
uint16 height = _height;
|
||||
byte *walkMap = new byte[stream->size()];
|
||||
|
||||
depthSurface.setSize(width, height);
|
||||
stream->read(walkMap, f.size());
|
||||
delete stream;
|
||||
f.close();
|
||||
|
||||
byte *ptr = (byte *)depthSurface.getPixels();
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int ofs = x + (y * width);
|
||||
if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
|
||||
*ptr++ = 1; // walkable
|
||||
else
|
||||
*ptr++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] walkMap;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
SceneLogic::SceneLogic(MADSEngine *vm) : _vm(vm) {
|
||||
|
@ -253,7 +253,12 @@ protected:
|
||||
/**
|
||||
* Loads the given surface with depth information of a given scene
|
||||
*/
|
||||
virtual void loadCodes(MSurface &depthSurface);
|
||||
virtual void loadCodes(MSurface &depthSurface) = 0;
|
||||
|
||||
/**
|
||||
* Loads the given surface with depth information of a given scene
|
||||
*/
|
||||
virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
|
||||
public:
|
||||
int _sceneId;
|
||||
int _artFileNum;
|
||||
|
Loading…
x
Reference in New Issue
Block a user