SHERLOCK: bit of work on 3DO graphic resources
This commit is contained in:
parent
26ed7954c3
commit
ae64cca8f0
2 changed files with 59 additions and 14 deletions
|
@ -600,6 +600,39 @@ ImageFile3DO::~ImageFile3DO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
|
void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
|
||||||
|
uint32 headerId = stream.readUint32BE();
|
||||||
|
|
||||||
|
// Sekk back to the start
|
||||||
|
stream.seek(0);
|
||||||
|
|
||||||
|
// Identify type of file
|
||||||
|
switch (headerId) {
|
||||||
|
case MKTAG('C', 'C', 'B', ' '):
|
||||||
|
// .cel file (title1a.cel etc.)
|
||||||
|
load3DOCelFile(stream);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MKTAG('A', 'N', 'I', 'M'):
|
||||||
|
// 3DO animation file (walk.anim)
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Sherlock animation file (.3da files)
|
||||||
|
loadAnimationFile(stream, animImages);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3DO uses RGB555, we use RGB565 internally so that more platforms are able to run us
|
||||||
|
inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
|
||||||
|
byte red = (pixel3DO >> 10) & 0x1F;
|
||||||
|
byte green = (pixel3DO >> 5) & 0x1F;
|
||||||
|
byte blue = pixel3DO & 0x1F;;
|
||||||
|
|
||||||
|
return ((red << 11) | (green << 6) | (blue));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream, bool animImages) {
|
||||||
int streamSize = stream.size();
|
int streamSize = stream.size();
|
||||||
uint32 compressedSize = 0;
|
uint32 compressedSize = 0;
|
||||||
|
|
||||||
|
@ -635,23 +668,18 @@ void ImageFile3DO::load(Common::SeekableReadStream &stream, bool animImages) {
|
||||||
// Load data for frame and decompress it
|
// Load data for frame and decompress it
|
||||||
byte *data = new byte[compressedSize];
|
byte *data = new byte[compressedSize];
|
||||||
stream.read(data, compressedSize);
|
stream.read(data, compressedSize);
|
||||||
decompressFrame(&stream, frame, data);
|
decompressAnimationFrame(&stream, frame, data);
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
push_back(frame);
|
push_back(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3DO uses RGB555, we use RGB565 internally so that more platforms are able to run us
|
// Decompresses an animation frame of a .3DA file
|
||||||
inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
|
// note: the .3DA files seem to use an "in memory" format, which uses the same compression technique
|
||||||
byte red = (pixel3DO >> 10) & 0x1F;
|
// as regular 3DO cel files, but every scanline is started with a length UINT16 and each scanline
|
||||||
byte green = (pixel3DO >> 5) & 0x1F;
|
// also starts on UINT32 boundaries
|
||||||
byte blue = pixel3DO & 0x1F;;
|
void ImageFile3DO::decompressAnimationFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src) {
|
||||||
|
|
||||||
return ((red << 11) | (green << 6) | (blue));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageFile3DO::decompressFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src) {
|
|
||||||
frame._frame.create(frame._width, frame._height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
|
frame._frame.create(frame._width, frame._height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
|
||||||
uint16 *dest = (uint16 *)frame._frame.getPixels();
|
uint16 *dest = (uint16 *)frame._frame.getPixels();
|
||||||
Common::fill(dest, dest + frame._width * frame._height, 0);
|
Common::fill(dest, dest + frame._width * frame._height, 0);
|
||||||
|
@ -722,4 +750,8 @@ void ImageFile3DO::decompressFrame(Common::SeekableReadStream *stream, ImageFram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageFile3DO::load3DOCelFile(Common::SeekableReadStream &stream) {
|
||||||
|
warning("3DO-cel file loader currently missing");
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Sherlock
|
} // End of namespace Sherlock
|
||||||
|
|
|
@ -231,12 +231,25 @@ private:
|
||||||
*/
|
*/
|
||||||
void load(Common::SeekableReadStream &stream, bool animImages);
|
void load(Common::SeekableReadStream &stream, bool animImages);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert pixel RGB values from RGB555 to RGB565
|
||||||
|
*/
|
||||||
|
inline uint16 convertPixel(uint16 pixel3DO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load 3DO cel file
|
||||||
|
*/
|
||||||
|
void load3DOCelFile(Common::SeekableReadStream &stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load animation graphics file
|
||||||
|
*/
|
||||||
|
void loadAnimationFile(Common::SeekableReadStream &stream, bool animImages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decompress a single frame for the sprite
|
* Decompress a single frame for the sprite
|
||||||
*/
|
*/
|
||||||
void decompressFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src);
|
void decompressAnimationFrame(Common::SeekableReadStream *stream, ImageFrame &frame, const byte *src);
|
||||||
|
|
||||||
inline uint16 convertPixel(uint16 pixel3DO);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ImageFile3DO(const Common::String &name, bool animImages = false);
|
ImageFile3DO(const Common::String &name, bool animImages = false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue