MADS: Further cursor/event initialisation
This commit is contained in:
parent
82514b4a28
commit
02a1d0eaa3
11 changed files with 135 additions and 19 deletions
|
@ -22,9 +22,74 @@
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "mads/mads.h"
|
#include "mads/mads.h"
|
||||||
|
#include "mads/assets.h"
|
||||||
|
#include "mads/compression.h"
|
||||||
#include "mads/events.h"
|
#include "mads/events.h"
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags):
|
||||||
|
_vm(vm) {
|
||||||
|
Common::String resName = resourceName;
|
||||||
|
if (!resName.hasSuffix(".SS"))
|
||||||
|
resName += ".SS";
|
||||||
|
|
||||||
|
File file(resName);
|
||||||
|
MadsPack sprites(&file);
|
||||||
|
|
||||||
|
int curFrame = 0;
|
||||||
|
uint32 frameOffset = 0;
|
||||||
|
_frameRate = 0;
|
||||||
|
_pixelSpeed = 0;
|
||||||
|
_maxWidth = 0;
|
||||||
|
_maxHeight = 0;
|
||||||
|
|
||||||
|
Common::SeekableReadStream *spriteStream = sprites.getItemStream(0);
|
||||||
|
for (int i = 0; i < 19; i++) {
|
||||||
|
spriteStream->readUint16LE();
|
||||||
|
}
|
||||||
|
_frameCount = spriteStream->readUint16LE();
|
||||||
|
// we skip the rest of the data
|
||||||
|
delete spriteStream;
|
||||||
|
|
||||||
|
// Get the palette data
|
||||||
|
spriteStream = sprites.getItemStream(2);
|
||||||
|
int numColors = 0;
|
||||||
|
byte *palData = _vm->_palette->decodePalette(spriteStream, &numColors);
|
||||||
|
|
||||||
|
Common::copy(palData, &palData[numColors], &_palette[0]);
|
||||||
|
if (numColors < 256)
|
||||||
|
Common::fill(&_palette[numColors * 3], &_palette[PALETTE_SIZE], 0);
|
||||||
|
_colorCount = numColors;
|
||||||
|
delete[] palData;
|
||||||
|
delete spriteStream;
|
||||||
|
|
||||||
|
spriteStream = sprites.getItemStream(1);
|
||||||
|
Common::SeekableReadStream *spriteDataStream = sprites.getItemStream(3);
|
||||||
|
|
||||||
|
SpriteAssetFrame frame;
|
||||||
|
for (curFrame = 0; curFrame < _frameCount; curFrame++) {
|
||||||
|
frame.comp = 0;
|
||||||
|
frameOffset = spriteStream->readUint32LE();
|
||||||
|
_frameOffsets.push_back(frameOffset);
|
||||||
|
spriteStream->readUint32LE(); // frame size
|
||||||
|
frame.x = spriteStream->readUint16LE();
|
||||||
|
frame.y = spriteStream->readUint16LE();
|
||||||
|
frame.w = spriteStream->readUint16LE();
|
||||||
|
frame.h = spriteStream->readUint16LE();
|
||||||
|
if (curFrame == 0) {
|
||||||
|
debugN(kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n",
|
||||||
|
_frameCount, frame.x, frame.y, frame.w, frame.h);
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.frame = MSprite::init(spriteDataStream, Common::Point(frame.x, frame.y),
|
||||||
|
frame.w, frame.h, false);
|
||||||
|
_frames.push_back(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete spriteStream;
|
||||||
|
delete spriteDataStream;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
||||||
|
|
|
@ -24,10 +24,45 @@
|
||||||
#define MADS_ASSETS_H
|
#define MADS_ASSETS_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "common/array.h"
|
||||||
|
#include "mads/msprite.h"
|
||||||
|
#include "mads/palette.h"
|
||||||
#include "mads/msprite.h"
|
#include "mads/msprite.h"
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
struct SpriteAssetFrame {
|
||||||
|
uint32 stream;
|
||||||
|
int x, y, w, h;
|
||||||
|
uint32 comp;
|
||||||
|
MSprite *frame;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SpriteAsset {
|
||||||
|
private:
|
||||||
|
MADSEngine *_vm;
|
||||||
|
byte _palette[PALETTE_SIZE];
|
||||||
|
int _colorCount;
|
||||||
|
uint32 _srcSize;
|
||||||
|
int _frameRate, _pixelSpeed;
|
||||||
|
int _maxWidth, _maxHeight;
|
||||||
|
int _frameCount;
|
||||||
|
Common::Array<uint32> _frameOffsets;
|
||||||
|
Common::Array<SpriteAssetFrame> _frames;
|
||||||
|
uint32 _frameStartOffset;
|
||||||
|
public:
|
||||||
|
SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags);
|
||||||
|
int getCount() { return _frameCount; }
|
||||||
|
int getFrameRate() const { return _frameRate; }
|
||||||
|
int getPixelSpeed() const { return _pixelSpeed; }
|
||||||
|
int getFrameWidth(int index);
|
||||||
|
int getFrameHeight(int index);
|
||||||
|
int getMaxFrameWidth() const { return _maxWidth; }
|
||||||
|
int getMaxFrameHeight() const { return _maxHeight; }
|
||||||
|
MSprite *getFrame(int frameIndex);
|
||||||
|
byte *getPalette() { return _palette; }
|
||||||
|
int getColorCount() { return _colorCount; }
|
||||||
|
};
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ MadsPack::MadsPack(Common::SeekableReadStream *stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
|
MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
|
||||||
Common::SeekableReadStream *stream = nullptr; //vm->_resources->get(resourceName);
|
File file(resourceName);
|
||||||
initialise(stream);
|
initialise(&file);
|
||||||
// vm->_resources->toss(resourceName);
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MadsPack::initialise(Common::SeekableReadStream *stream) {
|
void MadsPack::initialise(Common::SeekableReadStream *stream) {
|
||||||
|
|
|
@ -38,10 +38,15 @@ EventsManager::~EventsManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventsManager::loadCursors(const Common::String &spritesName) {
|
void EventsManager::loadCursors(const Common::String &spritesName) {
|
||||||
error("TODO: load SpriteSet");
|
_cursorSprites = new SpriteAsset(_vm, "*CURSOR.SS", 0x4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventsManager::setCursor(CursorType cursorId) {
|
void EventsManager::setCursor(CursorType cursorId) {
|
||||||
|
_cursorId = cursorId;
|
||||||
|
changeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventsManager::setCursor2(CursorType cursorId) {
|
||||||
_cursorId = cursorId;
|
_cursorId = cursorId;
|
||||||
_newCursorId = cursorId;
|
_newCursorId = cursorId;
|
||||||
changeCursor();
|
changeCursor();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "mads/msprite.h"
|
#include "mads/msprite.h"
|
||||||
|
#include "mads/assets.h"
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
|
@ -38,12 +39,13 @@ private:
|
||||||
MADSEngine *_vm;
|
MADSEngine *_vm;
|
||||||
CursorType _cursorId;
|
CursorType _cursorId;
|
||||||
CursorType _newCursorId;
|
CursorType _newCursorId;
|
||||||
void *_cursorSprites;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the cursor image when the current cursor changes
|
* Updates the cursor image when the current cursor changes
|
||||||
*/
|
*/
|
||||||
void changeCursor();
|
void changeCursor();
|
||||||
|
public:
|
||||||
|
SpriteAsset *_cursorSprites;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -65,6 +67,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setCursor(CursorType cursorId);
|
void setCursor(CursorType cursorId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cursor
|
||||||
|
*/
|
||||||
|
void setCursor2(CursorType cursorId);
|
||||||
|
|
||||||
void handleEvents();
|
void handleEvents();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
|
|
||||||
namespace MADS {
|
namespace MADS {
|
||||||
|
|
||||||
#define FONT_CONVERSATION "fontconv.ff"
|
#define FONT_CONVERSATION "*FONTCONV.FF"
|
||||||
#define FONT_INTERFACE "fontintr.ff"
|
#define FONT_INTERFACE "*FONTINTR.FF"
|
||||||
#define FONT_MAIN "fontmain.ff"
|
#define FONT_MAIN "*FONTMAIN.FF"
|
||||||
#define FONT_MENU "fontmenu.ff" // Not in Rex (uses bitmap files for menu strings)
|
#define FONT_MENU "*FONTMENU.FF" // Not in Rex (uses bitmap files for menu strings)
|
||||||
#define FONT_MISC "fontmisc.ff"
|
#define FONT_MISC "*FONTMISC.FF"
|
||||||
#define FONT_TELE "fonttele.ff" // Not in Phantom
|
#define FONT_TELE "*FONTTELE.FF" // Not in Phantom
|
||||||
#define FONT_PHAN "fontphan.ff" // Phantom only
|
#define FONT_PHAN "*FONTPHAN.FF" // Phantom only
|
||||||
|
|
||||||
class MADSEngine;
|
class MADSEngine;
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,10 @@ void Game::initSection(int sectionNumber) {
|
||||||
|
|
||||||
_vm->_palette->resetGamePalette(18, 10);
|
_vm->_palette->resetGamePalette(18, 10);
|
||||||
_vm->_palette->setLowRange();
|
_vm->_palette->setLowRange();
|
||||||
|
|
||||||
// TODO
|
assert(_vm->_events->_cursorSprites);
|
||||||
|
_vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ?
|
||||||
|
CURSOR_ARROW : CURSOR_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace MADS
|
} // End of namespace MADS
|
||||||
|
|
|
@ -67,6 +67,7 @@ void MADSEngine::initialise() {
|
||||||
// Set up debug channels
|
// Set up debug channels
|
||||||
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
|
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
|
||||||
DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
|
DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
|
||||||
|
DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
|
||||||
|
|
||||||
// Initial sub-system engine references
|
// Initial sub-system engine references
|
||||||
MSurface::setVm(this);
|
MSurface::setVm(this);
|
||||||
|
|
|
@ -54,7 +54,8 @@ namespace MADS {
|
||||||
|
|
||||||
enum MADSDebugChannels {
|
enum MADSDebugChannels {
|
||||||
kDebugPath = 1 << 0,
|
kDebugPath = 1 << 0,
|
||||||
kDebugScripts = 1 << 1
|
kDebugScripts = 1 << 1,
|
||||||
|
kDebugGraphics = 1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -97,8 +97,8 @@ struct SpriteFrameHeader {
|
||||||
|
|
||||||
class MSprite {
|
class MSprite {
|
||||||
public:
|
public:
|
||||||
MSprite *init(MSurface &s);
|
static MSprite *init(MSurface &s);
|
||||||
MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal,
|
static MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal,
|
||||||
int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
|
int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
|
||||||
protected:
|
protected:
|
||||||
static MADSEngine *_vm;
|
static MADSEngine *_vm;
|
||||||
|
|
|
@ -240,8 +240,8 @@ void Palette::fadeRange(byte *srcPal, byte *destPal, int startIndex, int endInd
|
||||||
|
|
||||||
void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
|
void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
|
||||||
int rgbCtr = 0;
|
int rgbCtr = 0;
|
||||||
int rgbDiff = -(rgbValue2 - rgbValue1);
|
|
||||||
int rgbCurrent = rgbValue2;
|
int rgbCurrent = rgbValue2;
|
||||||
|
int rgbDiff = -(rgbValue2 - rgbValue1);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
byte *pDest = palette + start * 3;
|
byte *pDest = palette + start * 3;
|
||||||
|
@ -251,7 +251,7 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
|
||||||
do {
|
do {
|
||||||
pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
|
pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
|
||||||
|
|
||||||
if (count > 1) {
|
if (numLeft > 1) {
|
||||||
rgbCtr += rgbDiff;
|
rgbCtr += rgbDiff;
|
||||||
if (rgbCtr >= endVal) {
|
if (rgbCtr >= endVal) {
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue