mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
MADS: Removed M4-specific code. Keeping engine MADS-specific for now
This commit is contained in:
parent
02a1d0eaa3
commit
3df1237187
@ -181,4 +181,4 @@ int FabDecompressor::getBit() {
|
||||
return bit;
|
||||
}
|
||||
|
||||
} // End of namespace M4
|
||||
} // End of namespace MADS
|
||||
|
@ -38,7 +38,7 @@ static const MADSGameDescription gameDescriptions[] = {
|
||||
GUIO1(GUIO_NONE)
|
||||
},
|
||||
GType_RexNebular,
|
||||
GF_MADS
|
||||
0
|
||||
},
|
||||
|
||||
{ AD_TABLE_END_MARKER }
|
||||
|
@ -65,11 +65,6 @@ enum {
|
||||
GType_Riddle = 3
|
||||
};
|
||||
|
||||
enum {
|
||||
GF_MADS = 1 << 0,
|
||||
GF_M4 = 1 << 1
|
||||
};
|
||||
|
||||
struct MADSGameDescription;
|
||||
|
||||
|
||||
|
@ -38,21 +38,13 @@ enum {
|
||||
MADSEngine *MSprite::_vm;
|
||||
|
||||
MSprite *MSprite::init(MSurface &s) {
|
||||
if (_vm->getGameFeatures() & GF_MADS) {
|
||||
return new MSpriteMADS(s);
|
||||
} else {
|
||||
return new MSpriteM4(s);
|
||||
}
|
||||
return new MSprite(s);
|
||||
}
|
||||
|
||||
MSprite *MSprite::init(Common::SeekableReadStream *source, const Common::Point &offset,
|
||||
int widthVal, int heightVal, bool decodeRle, uint8 encodingVal) {
|
||||
|
||||
if (_vm->getGameFeatures() & GF_MADS) {
|
||||
return new MSpriteMADS(source, offset, widthVal, heightVal, decodeRle, encodingVal);
|
||||
} else {
|
||||
return new MSpriteM4(source, offset, widthVal, heightVal, decodeRle, encodingVal);
|
||||
}
|
||||
return new MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal);
|
||||
}
|
||||
|
||||
MSprite::MSprite(MSurface &s): _surface(s) {
|
||||
@ -65,21 +57,15 @@ MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset
|
||||
_encoding(encodingVal), _offset(offset) {
|
||||
|
||||
// Load the sprite data
|
||||
load(source, widthVal, heightVal, decodeRle);
|
||||
loadSprite(source);
|
||||
}
|
||||
|
||||
MSprite::~MSprite() {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void MSpriteMADS::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
|
||||
bool decodeRle) {
|
||||
loadSprite(stream);
|
||||
}
|
||||
|
||||
// TODO: The sprite outlines (pixel value 0xFD) are not shown
|
||||
void MSpriteMADS::loadSprite(Common::SeekableReadStream *source) {
|
||||
void MSprite::loadSprite(Common::SeekableReadStream *source) {
|
||||
byte *outp, *lineStart;
|
||||
bool newLine = false;
|
||||
|
||||
@ -130,78 +116,4 @@ void MSpriteMADS::loadSprite(Common::SeekableReadStream *source) {
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void MSpriteM4::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
|
||||
bool decodeRle) {
|
||||
if (decodeRle) {
|
||||
loadRle(stream);
|
||||
} else {
|
||||
// Raw sprite data, load directly
|
||||
byte *dst = _surface.getData();
|
||||
stream->read(dst, widthVal * heightVal);
|
||||
}
|
||||
}
|
||||
|
||||
void MSpriteM4::loadRle(Common::SeekableReadStream* rleData) {
|
||||
byte *dst = _surface.getData();
|
||||
for (;;) {
|
||||
byte len = rleData->readByte();
|
||||
if (len == 0) {
|
||||
len = rleData->readByte();
|
||||
if (len <= kMarker) {
|
||||
if (len == kEndOfSprite)
|
||||
break;
|
||||
} else {
|
||||
while (len--) {
|
||||
*dst++ = rleData->readByte();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
byte value = rleData->readByte();
|
||||
while (len--)
|
||||
*dst++ = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MSpriteM4::loadDeltaRle(Common::SeekableReadStream* rleData, int destX, int destY) {
|
||||
int lineNum = 0;
|
||||
byte *dst = _surface.getBasePtr(destX, destY);
|
||||
|
||||
for (;;) {
|
||||
byte len = rleData->readByte();
|
||||
if (len == 0) {
|
||||
len = rleData->readByte();
|
||||
if (len <= kMarker) {
|
||||
if (len == kEndOfLine) {
|
||||
dst = _surface.getBasePtr(destX, destY + lineNum);
|
||||
lineNum++;
|
||||
} else if (len == kEndOfSprite)
|
||||
break;
|
||||
} else {
|
||||
while (len--) {
|
||||
byte pixel = rleData->readByte();
|
||||
if (pixel == 0)
|
||||
dst++;
|
||||
else
|
||||
*dst++ = pixel;
|
||||
/* NOTE: The change below behaved differently than the old code,
|
||||
so I put the old code back in again above.
|
||||
If the pixel value is 0, nothing should be written to the
|
||||
output buffer, since 0 means transparent. */
|
||||
//*dst++ = (pixel == 0xFD) ? 0 : pixel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
byte value = rleData->readByte();
|
||||
if (value == 0)
|
||||
dst += len;
|
||||
else
|
||||
while (len--)
|
||||
*dst++ = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace MADS
|
||||
|
@ -107,7 +107,7 @@ protected:
|
||||
MSprite(Common::SeekableReadStream *source, const Common::Point &offset,
|
||||
int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
|
||||
|
||||
virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle) {}
|
||||
void loadSprite(Common::SeekableReadStream *source);
|
||||
public:
|
||||
static void setVm(MADSEngine *vm) { _vm = vm; }
|
||||
virtual ~MSprite();
|
||||
@ -118,35 +118,6 @@ public:
|
||||
uint8 _encoding;
|
||||
};
|
||||
|
||||
class MSpriteMADS: public MSprite {
|
||||
friend class MSprite;
|
||||
private:
|
||||
void loadSprite(Common::SeekableReadStream *source);
|
||||
protected:
|
||||
MSpriteMADS(MSurface &s): MSprite(s) {}
|
||||
MSpriteMADS(Common::SeekableReadStream *source, const Common::Point &offset,
|
||||
int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
|
||||
MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
|
||||
|
||||
virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
|
||||
};
|
||||
|
||||
class MSpriteM4: public MSprite {
|
||||
friend class MSprite;
|
||||
private:
|
||||
// Loads a sprite from the given stream, and optionally decompresses the RLE-encoded data
|
||||
// Loads an RLE compressed sprite; the surface must have been created before
|
||||
void loadRle(Common::SeekableReadStream *rleData);
|
||||
void loadDeltaRle(Common::SeekableReadStream *rleData, int destX, int destY);
|
||||
protected:
|
||||
MSpriteM4(MSurface &s): MSprite(s) {}
|
||||
MSpriteM4(Common::SeekableReadStream *source, const Common::Point &offset,
|
||||
int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
|
||||
MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
|
||||
|
||||
virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
|
||||
};
|
||||
|
||||
} // End of namespace MADS
|
||||
|
||||
#endif /* MADS_MSPRITE_H */
|
||||
|
@ -35,20 +35,16 @@ MADSEngine *MSurface::_vm = nullptr;
|
||||
MSurface *MSurface::init(bool isScreen) {
|
||||
if (_vm->getGameID() == GType_RexNebular) {
|
||||
return new MSurfaceNebular(isScreen);
|
||||
} else if (_vm->getGameFeatures() & GF_MADS) {
|
||||
return new MSurfaceMADS(isScreen);
|
||||
} else {
|
||||
return new MSurfaceM4(isScreen);
|
||||
return new MSurfaceMADS(isScreen);
|
||||
}
|
||||
}
|
||||
|
||||
MSurface *MSurface::init(int width, int height) {
|
||||
if (_vm->getGameID() == GType_RexNebular) {
|
||||
return new MSurfaceNebular(width, height);
|
||||
} else if (_vm->getGameFeatures() & GF_MADS) {
|
||||
return new MSurfaceMADS(width, height);
|
||||
} else {
|
||||
return new MSurfaceM4(width, height);
|
||||
return new MSurfaceMADS(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,96 +575,4 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
|
||||
delete sourceUnc;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void MSurfaceM4::loadCodes(Common::SeekableReadStream *source) {
|
||||
if (!source) {
|
||||
free();
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 width = source->readUint16LE();
|
||||
uint16 height = source->readUint16LE();
|
||||
|
||||
setSize(width, height);
|
||||
source->read(pixels, width * height);
|
||||
}
|
||||
|
||||
void MSurfaceM4::loadBackground(int roomNumber, RGBList **palData) {
|
||||
if (palData)
|
||||
*palData = NULL;
|
||||
Common::String resourceName = Common::String::format("%i.tt", roomNumber);
|
||||
Common::SeekableReadStream *stream = nullptr;//_vm->_resources->get(resourceName);
|
||||
loadBackgroundStream(stream);
|
||||
|
||||
// _vm->_resources->toss(resourceName);
|
||||
}
|
||||
|
||||
void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
|
||||
MSurface *tileBuffer = MSurface::init();
|
||||
uint curTileX = 0, curTileY = 0;
|
||||
int clipX = 0, clipY = 0;
|
||||
byte palette[256];
|
||||
|
||||
source->skip(4);
|
||||
/*uint32 size =*/ source->readUint32LE();
|
||||
uint32 width = source->readUint32LE();
|
||||
uint32 height = source->readUint32LE();
|
||||
uint32 tilesX = source->readUint32LE();
|
||||
uint32 tilesY = source->readUint32LE();
|
||||
uint32 tileWidth = source->readUint32LE();
|
||||
uint32 tileHeight = source->readUint32LE();
|
||||
uint8 blackIndex = 0;
|
||||
|
||||
// BGR data, which is converted to RGB8
|
||||
for (uint i = 0; i < 256; i++) {
|
||||
byte r, g, b;
|
||||
palette[i * 3] = r = source->readByte() << 2;
|
||||
palette[i * 3 + 1] = g = source->readByte() << 2;
|
||||
palette[i * 3 + 2] = b = source->readByte() << 2;
|
||||
source->skip(1);
|
||||
|
||||
if ((blackIndex == 0) && !r && !g && !b)
|
||||
blackIndex = i;
|
||||
}
|
||||
|
||||
_vm->_palette->setPalette(palette, 0, 256);
|
||||
|
||||
// resize or create the surface
|
||||
// Note that the height of the scene in game scenes is smaller than the screen height,
|
||||
// as the bottom part of the screen is the inventory
|
||||
assert(getWidth() == (int)width);
|
||||
|
||||
tileBuffer->setSize(tileWidth, tileHeight);
|
||||
|
||||
for (curTileY = 0; curTileY < tilesY; curTileY++) {
|
||||
clipY = MIN(height, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
|
||||
|
||||
for (curTileX = 0; curTileX < tilesX; curTileX++) {
|
||||
clipX = MIN(width, (1 + curTileX) * tileWidth) - (curTileX * tileWidth);
|
||||
|
||||
// Read a tile and copy it to the destination surface
|
||||
source->read(tileBuffer->getData(), tileWidth * tileHeight);
|
||||
Common::Rect srcBounds(0, 0, clipX, clipY);
|
||||
copyFrom(tileBuffer, srcBounds,
|
||||
Common::Point(curTileX * tileWidth, curTileY * tileHeight));
|
||||
}
|
||||
}
|
||||
|
||||
if (height < (uint)getHeight())
|
||||
fillRect(Common::Rect(0, height, getWidth(), getHeight()), blackIndex);
|
||||
|
||||
delete tileBuffer;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void MSurfaceRiddle::loadBackground(const Common::String &sceneName) {
|
||||
// Loads a Riddle scene
|
||||
Common::String resName = Common::String::format("%s.tt", sceneName.c_str());
|
||||
File stream(resName);
|
||||
|
||||
loadBackgroundStream(&stream);
|
||||
}
|
||||
|
||||
} // End of namespace MADS
|
||||
|
@ -282,27 +282,6 @@ public:
|
||||
virtual void loadBackground(int roomNumber, RGBList **palData);
|
||||
};
|
||||
|
||||
class MSurfaceM4: public MSurface {
|
||||
friend class MSurface;
|
||||
protected:
|
||||
MSurfaceM4(bool isScreen = false): MSurface(isScreen) {}
|
||||
MSurfaceM4(int width, int height): MSurface(width, height) {}
|
||||
|
||||
void loadBackgroundStream(Common::SeekableReadStream *source);
|
||||
public:
|
||||
virtual void loadCodes(Common::SeekableReadStream *source);
|
||||
virtual void loadBackground(int roomNumber, RGBList **palData);
|
||||
};
|
||||
|
||||
class MSurfaceRiddle: public MSurfaceM4 {
|
||||
friend class MSurface;
|
||||
protected:
|
||||
MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {}
|
||||
MSurfaceRiddle(int width, int height): MSurfaceM4(width, height) {}
|
||||
public:
|
||||
virtual void loadBackground(const Common::String &sceneName);
|
||||
};
|
||||
|
||||
} // End of namespace MADS
|
||||
|
||||
#endif /* MADS_MSURFACE_H */
|
||||
|
@ -89,10 +89,7 @@ public:
|
||||
};
|
||||
|
||||
void ResourcesManager::init(MADSEngine *vm) {
|
||||
if (vm->getGameFeatures() & GF_MADS)
|
||||
SearchMan.add("HAG", new HagArchive());
|
||||
else
|
||||
error("Unsupported game engine");
|
||||
SearchMan.add("HAG", new HagArchive());
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user