aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/assets.cpp65
-rw-r--r--engines/mads/assets.h35
-rw-r--r--engines/mads/compression.cpp6
-rw-r--r--engines/mads/events.cpp7
-rw-r--r--engines/mads/events.h9
-rw-r--r--engines/mads/font.h14
-rw-r--r--engines/mads/game.cpp6
-rw-r--r--engines/mads/mads.cpp1
-rw-r--r--engines/mads/mads.h3
-rw-r--r--engines/mads/msprite.h4
-rw-r--r--engines/mads/palette.cpp4
11 files changed, 135 insertions, 19 deletions
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 7c1b169396..6ad313ce3e 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -22,9 +22,74 @@
#include "common/scummsys.h"
#include "mads/mads.h"
+#include "mads/assets.h"
+#include "mads/compression.h"
#include "mads/events.h"
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
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index dcd7390b75..c64209eab2 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -24,10 +24,45 @@
#define MADS_ASSETS_H
#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/msprite.h"
+#include "mads/palette.h"
#include "mads/msprite.h"
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
diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index febb6ec90f..5000319a63 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -46,9 +46,9 @@ MadsPack::MadsPack(Common::SeekableReadStream *stream) {
}
MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
- Common::SeekableReadStream *stream = nullptr; //vm->_resources->get(resourceName);
- initialise(stream);
-// vm->_resources->toss(resourceName);
+ File file(resourceName);
+ initialise(&file);
+ file.close();
}
void MadsPack::initialise(Common::SeekableReadStream *stream) {
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index ec0628710c..bb980af7ff 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -38,11 +38,16 @@ EventsManager::~EventsManager() {
}
void EventsManager::loadCursors(const Common::String &spritesName) {
- error("TODO: load SpriteSet");
+ _cursorSprites = new SpriteAsset(_vm, "*CURSOR.SS", 0x4000);
}
void EventsManager::setCursor(CursorType cursorId) {
_cursorId = cursorId;
+ changeCursor();
+}
+
+void EventsManager::setCursor2(CursorType cursorId) {
+ _cursorId = cursorId;
_newCursorId = cursorId;
changeCursor();
}
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 860f36d69f..c5cc5bf352 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "mads/msprite.h"
+#include "mads/assets.h"
namespace MADS {
@@ -38,13 +39,14 @@ private:
MADSEngine *_vm;
CursorType _cursorId;
CursorType _newCursorId;
- void *_cursorSprites;
/**
* Updates the cursor image when the current cursor changes
*/
void changeCursor();
public:
+ SpriteAsset *_cursorSprites;
+public:
/**
* Constructor
*/
@@ -65,6 +67,11 @@ public:
*/
void setCursor(CursorType cursorId);
+ /**
+ * Sets the cursor
+ */
+ void setCursor2(CursorType cursorId);
+
void handleEvents();
};
diff --git a/engines/mads/font.h b/engines/mads/font.h
index e042768c40..3deb3f4d2d 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -30,13 +30,13 @@
namespace MADS {
-#define FONT_CONVERSATION "fontconv.ff"
-#define FONT_INTERFACE "fontintr.ff"
-#define FONT_MAIN "fontmain.ff"
-#define FONT_MENU "fontmenu.ff" // Not in Rex (uses bitmap files for menu strings)
-#define FONT_MISC "fontmisc.ff"
-#define FONT_TELE "fonttele.ff" // Not in Phantom
-#define FONT_PHAN "fontphan.ff" // Phantom only
+#define FONT_CONVERSATION "*FONTCONV.FF"
+#define FONT_INTERFACE "*FONTINTR.FF"
+#define FONT_MAIN "*FONTMAIN.FF"
+#define FONT_MENU "*FONTMENU.FF" // Not in Rex (uses bitmap files for menu strings)
+#define FONT_MISC "*FONTMISC.FF"
+#define FONT_TELE "*FONTTELE.FF" // Not in Phantom
+#define FONT_PHAN "*FONTPHAN.FF" // Phantom only
class MADSEngine;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 48c79ba32d..774ec98eb4 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -55,8 +55,10 @@ void Game::initSection(int sectionNumber) {
_vm->_palette->resetGamePalette(18, 10);
_vm->_palette->setLowRange();
-
- // TODO
+
+ assert(_vm->_events->_cursorSprites);
+ _vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ?
+ CURSOR_ARROW : CURSOR_WAIT);
}
} // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 687852a59b..aa2bd55dd8 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -67,6 +67,7 @@ void MADSEngine::initialise() {
// Set up debug channels
DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+ DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
// Initial sub-system engine references
MSurface::setVm(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index a6ae776690..b50cf07678 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -54,7 +54,8 @@ namespace MADS {
enum MADSDebugChannels {
kDebugPath = 1 << 0,
- kDebugScripts = 1 << 1
+ kDebugScripts = 1 << 1,
+ kDebugGraphics = 1 << 2
};
enum {
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
index c49aac4fba..c454597a3a 100644
--- a/engines/mads/msprite.h
+++ b/engines/mads/msprite.h
@@ -97,8 +97,8 @@ struct SpriteFrameHeader {
class MSprite {
public:
- MSprite *init(MSurface &s);
- MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal,
+ static MSprite *init(MSurface &s);
+ static MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal,
int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
protected:
static MADSEngine *_vm;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 2d7bd42f29..82ffa4e43a 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -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) {
int rgbCtr = 0;
- int rgbDiff = -(rgbValue2 - rgbValue1);
int rgbCurrent = rgbValue2;
+ int rgbDiff = -(rgbValue2 - rgbValue1);
if (count > 0) {
byte *pDest = palette + start * 3;
@@ -251,7 +251,7 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
do {
pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
- if (count > 1) {
+ if (numLeft > 1) {
rgbCtr += rgbDiff;
if (rgbCtr >= endVal) {
do {