aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/supernova/graphics.cpp157
-rw-r--r--engines/supernova/graphics.h58
-rw-r--r--engines/supernova/module.mk5
-rw-r--r--engines/supernova/msn_def.h147
-rw-r--r--engines/supernova/supernova.cpp156
-rw-r--r--engines/supernova/supernova.h17
6 files changed, 485 insertions, 55 deletions
diff --git a/engines/supernova/graphics.cpp b/engines/supernova/graphics.cpp
index 1daa94b42d..e2467d1c3c 100644
--- a/engines/supernova/graphics.cpp
+++ b/engines/supernova/graphics.cpp
@@ -1,11 +1,162 @@
+#include "common/algorithm.h"
+#include "common/file.h"
+#include "common/stream.h"
+#include "common/system.h"
+#include "graphics/palette.h"
+#include "graphics/surface.h"
+
#include "graphics.h"
+namespace Supernova {
+
MSNImageDecoder::MSNImageDecoder()
-{
+ : _surface(NULL)
+ , _palette(NULL) {
+}
+MSNImageDecoder::~MSNImageDecoder() {
+ destroy();
}
-MSNImageDecoder::~MSNImageDecoder()
-{
+bool MSNImageDecoder::loadStream(Common::SeekableReadStream &stream) {
+ destroy();
+
+ size_t size = 0;
+ size = (stream.readUint16LE() + 0xF) >> 4;
+ size |= (stream.readUint16LE() & 0xF) << 12;
+ size += 0x70; // zus_paragraph
+ size *= 16; // a paragraph is 16 bytes
+ _encodedImage = new byte[size];
+
+ _palette = new byte[768];
+ g_system->getPaletteManager()->grabPalette(_palette, 0, 256);
+
+ byte pal_diff;
+ byte flag = stream.readByte();
+ if (flag == 0) {
+ pal_diff = 0;
+ _palette[141] = 0x38;
+ _palette[142] = 0x38;
+ _palette[143] = 0x38;
+ } else {
+ pal_diff = 1;
+ for (int i = flag * 3; i != 0; --i) {
+ _palette[717 - i] = stream.readByte();
+ }
+ }
+ g_system->getPaletteManager()->setPalette(_palette, 0, 256);
+
+ byte numSections = stream.readByte();
+ for (size_t i = 0; i < kMaxSections; ++i) {
+ _section[i].addressHigh = 0xff;
+ _section[i].addressLow = 0xffff;
+ _section[i].x2 = 0;
+ }
+ for (int i = 0; i < numSections; ++i) {
+ _section[i].x1 = stream.readUint16LE();
+ _section[i].x2 = stream.readUint16LE();
+ _section[i].y1 = stream.readByte();
+ _section[i].y2 = stream.readByte();
+ _section[i].next = stream.readByte();
+ _section[i].addressLow = stream.readUint16LE();
+ _section[i].addressHigh = stream.readByte();
+ }
+
+ byte numClickFields = stream.readByte();
+ for (int i = 0; i < numClickFields; ++i) {
+ _clickField[i].x1 = stream.readUint16LE();
+ _clickField[i].x2 = stream.readUint16LE();
+ _clickField[i].y1 = stream.readByte();
+ _clickField[i].y2 = stream.readByte();
+ _clickField[i].next = stream.readByte();
+ }
+
+ byte zwCodes[256];
+ byte numRepeat = stream.readByte();
+ byte numZw = stream.readByte();
+ stream.read(zwCodes, numZw);
+ numZw += numRepeat;
+
+ byte input = 0;
+ size_t i = 0;
+ // wat
+ while (stream.read(&input, 1)) {
+ if (input < numRepeat) {
+ ++input;
+ byte value = stream.readByte();
+ for (--value; input > 0; --input) {
+ _encodedImage[i++] = value;
+ }
+ } else if (input < numZw) {
+ input = zwCodes[input];
+ --input;
+ _encodedImage[i++] = input;
+ _encodedImage[i++] = input;
+ } else {
+ input -= pal_diff;
+ _encodedImage[i++] = input;
+ }
+ }
+ return true;
+}
+
+bool MSNImageDecoder::loadSection(int section) {
+ _surface = new Graphics::Surface;
+ _surface->create(320, 200, g_system->getScreenFormat());
+ byte *surfacePixels = static_cast<byte *>(_surface->getPixels());
+
+ const uint32 kInvalidAddress = 0x00FFFFFF;
+
+ size_t image = section;
+ if (image < 128) {
+ do {
+ uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow;
+ if (offset == kInvalidAddress) {
+ return false;
+ }
+ int width = _section[image].x2 - _section[image].x1 + 1;
+ int height = _section[image].y2 - _section[image].y1 + 1;
+ uint32 destAddress = 320 * _section[image].y1 + _section[image].x1;
+ while (height) {
+ Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress);
+ offset += width;
+ destAddress += 320;
+ --height;
+ }
+
+ image = _section[image].next;
+ } while (image != 0);
+ } else {
+ image -= 128;
+ do {
+ int width = _section[image].x2 - _section[image].x1 + 1;
+ int height = _section[image].y2 - _section[image].y1 + 1;
+ uint32 destAddress = 320 * _section[image].y1 + _section[image].x1;
+ uint32 offset = (_section[image].addressHigh << 16) + _section[image].addressLow + destAddress;
+ while (height) {
+ Common::copy(_encodedImage + offset, _encodedImage + offset + width, surfacePixels + destAddress);
+ offset += 320;
+ destAddress += 320;
+ --height;
+ }
+
+ image = _section[image].next;
+ } while (image != 0);
+ }
+
+ return true;
+}
+
+void MSNImageDecoder::destroy() {
+ if (_palette) {
+ delete[] _palette;
+ _palette = NULL;
+ }
+ if (_surface) {
+ _surface->free();
+ _surface = NULL;
+ }
+}
+
}
diff --git a/engines/supernova/graphics.h b/engines/supernova/graphics.h
index 2717350ce0..94d6b5e936 100644
--- a/engines/supernova/graphics.h
+++ b/engines/supernova/graphics.h
@@ -1,12 +1,35 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
-#include "common/stream.h"
+#include "common/scummsys.h"
#include "image/image_decoder.h"
-#include "graphics/surface.h"
-class MSNImageDecoder : public Image::ImageDecoder
-{
+namespace Common {
+class SeekableReadStream;
+}
+
+namespace Graphics {
+class Surface;
+}
+
+namespace Supernova {
+
+const byte initPalette[48] = {
+// r g b
+ 0, 0, 0, 16, 16, 16, 22, 22, 22,
+ 28, 28, 28, 63, 63, 63, 0, 52, 0,
+ 0, 63, 0, 54, 0, 0, 63, 0, 0,
+ 0, 0, 30, 0, 0, 45, 40, 40, 40,
+ 20, 50, 63, 10, 63, 10, 60, 60, 0,
+ 63, 10, 10
+};
+
+// TODO
+const byte defaultVGAPalette[] = {
+ 0, 0, 0
+};
+
+class MSNImageDecoder : public Image::ImageDecoder {
public:
MSNImageDecoder();
virtual ~MSNImageDecoder();
@@ -15,10 +38,35 @@ public:
virtual bool loadStream(Common::SeekableReadStream &stream);
virtual const Graphics::Surface *getSurface() const { return _surface; }
virtual const byte *getPalette() const { return _palette; }
+
+ bool loadSection(int _section);
private:
- const Graphics::Surface *_surface;
+ static const int kMaxSections = 50;
+ static const int kMaxClickFields = 80;
+
+ Graphics::Surface *_surface;
byte *_palette;
+ byte *_encodedImage;
+
+ struct Section {
+ int16 x1;
+ int16 x2;
+ byte y1;
+ byte y2;
+ byte next;
+ uint16 addressLow;
+ byte addressHigh;
+ } _section[kMaxSections];
+
+ struct ClickField {
+ int16 x1;
+ int16 x2;
+ byte y1;
+ byte y2;
+ byte next;
+ } _clickField[kMaxClickFields];
};
+}
#endif
diff --git a/engines/supernova/module.mk b/engines/supernova/module.mk
index 07317f6557..b63bd2d78d 100644
--- a/engines/supernova/module.mk
+++ b/engines/supernova/module.mk
@@ -1,9 +1,10 @@
MODULE := engines/supernova
MODULE_OBJS := \
- supernova.o \
console.o \
- detection.o
+ detection.o \
+ graphics.o \
+ supernova.o \
MODULE_DIRS += \
engines/supernova
diff --git a/engines/supernova/msn_def.h b/engines/supernova/msn_def.h
index b8e20b1e14..c17b7bdc3c 100644
--- a/engines/supernova/msn_def.h
+++ b/engines/supernova/msn_def.h
@@ -362,4 +362,151 @@ enum {X,
TICKETS};
}
+
+const byte mouseNormal[64] = {
+ 0xff,0x3f,0xff,0x1f,0xff,0x0f,0xff,0x07,
+ 0xff,0x03,0xff,0x01,0xff,0x00,0x7f,0x00,
+ 0x3f,0x00,0x1f,0x00,0x0f,0x00,0x0f,0x00,
+ 0xff,0x00,0x7f,0x18,0x7f,0x38,0x7f,0xfc,
+
+ 0x00,0x00,0x00,0x40,0x00,0x60,0x00,0x70,
+ 0x00,0x78,0x00,0x7c,0x00,0x7e,0x00,0x7f,
+ 0x80,0x7f,0xc0,0x7f,0xe0,0x7f,0x00,0x7e,
+ 0x00,0x66,0x00,0x43,0x00,0x03,0x00,0x00
+};
+
+const byte mouseWait[64] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
+ 0x01,0x80,0x01,0x80,0x11,0x88,0x31,0x8c,
+ 0x31,0x8c,0x11,0x88,0x01,0x80,0x01,0x80,
+ 0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
+
+ 0x00,0x00,0xfe,0x7f,0xf4,0x2f,0xf4,0x2f,
+ 0x14,0x28,0x24,0x24,0x44,0x22,0x84,0x21,
+ 0x84,0x21,0xc4,0x23,0xe4,0x27,0x74,0x2e,
+ 0x34,0x2c,0x14,0x28,0xfe,0x7f,0x00,0x00
+};
+
+char font[][5] =
+{
+ {0x00,0x00,0x00,0xff},
+ {0x5f,0xff},
+ {0x03,0x00,0x03,0xff},
+ {0x14,0x7f,0x14,0x7f,0x14},
+ {0x24,0x2a,0x7f,0x2a,0x12},
+ {0x61,0x10,0x08,0x04,0x43},
+ {0x38,0x4e,0x59,0x26,0x50},
+ {0x03,0xff},
+ {0x3e,0x41,0xff},
+ {0x41,0x3e,0xff},
+ {0x10,0x54,0x38,0x54,0x10},
+ {0x10,0x10,0x7c,0x10,0x10},
+ {0x80,0x40,0xff},
+ {0x10,0x10,0x10,0x10,0x10},
+ {0x40,0xff},
+ {0x60,0x10,0x08,0x04,0x03},
+
+ {0x3e,0x41,0x41,0x41,0x3e}, /* digits */
+ {0x04,0x02,0x7f,0xff},
+ {0x42,0x61,0x51,0x49,0x46},
+ {0x22,0x41,0x49,0x49,0x36},
+ {0x18,0x14,0x12,0x7f,0x10},
+ {0x27,0x45,0x45,0x45,0x39},
+ {0x3e,0x49,0x49,0x49,0x32},
+ {0x01,0x61,0x19,0x07,0x01},
+ {0x36,0x49,0x49,0x49,0x36},
+ {0x26,0x49,0x49,0x49,0x3e},
+
+ {0x44,0xff},
+ {0x80,0x44,0xff},
+ {0x10,0x28,0x44,0xff},
+ {0x28,0x28,0x28,0x28,0x28},
+ {0x44,0x28,0x10,0xff},
+ {0x02,0x01,0x51,0x09,0x06},
+ {0x3e,0x41,0x5d,0x5d,0x1e},
+
+ {0x7c,0x12,0x11,0x12,0x7c}, /* uppercase letters*/
+ {0x7f,0x49,0x49,0x49,0x36},
+ {0x3e,0x41,0x41,0x41,0x22},
+ {0x7f,0x41,0x41,0x22,0x1c},
+ {0x7f,0x49,0x49,0x49,0xff},
+ {0x7f,0x09,0x09,0x09,0xff},
+ {0x3e,0x41,0x41,0x49,0x3a},
+ {0x7f,0x08,0x08,0x08,0x7f},
+ {0x41,0x7f,0x41,0xff},
+ {0x20,0x40,0x40,0x3f,0xff},
+ {0x7f,0x08,0x14,0x22,0x41},
+ {0x7f,0x40,0x40,0x40,0xff},
+ {0x7f,0x02,0x04,0x02,0x7f},
+ {0x7f,0x02,0x0c,0x10,0x7f},
+ {0x3e,0x41,0x41,0x41,0x3e},
+ {0x7f,0x09,0x09,0x09,0x06},
+ {0x3e,0x41,0x51,0x21,0x5e},
+ {0x7f,0x09,0x19,0x29,0x46},
+ {0x26,0x49,0x49,0x49,0x32},
+ {0x01,0x01,0x7f,0x01,0x01},
+ {0x3f,0x40,0x40,0x40,0x3f},
+ {0x07,0x18,0x60,0x18,0x07},
+ {0x1f,0x60,0x18,0x60,0x1f},
+ {0x63,0x14,0x08,0x14,0x63},
+ {0x03,0x04,0x78,0x04,0x03},
+ {0x61,0x51,0x49,0x45,0x43},
+
+ {0x7f,0x41,0x41,0xff},
+ {0x03,0x04,0x08,0x10,0x60},
+ {0x41,0x41,0x7f,0xff},
+ {0x02,0x01,0x02,0xff},
+ {0x80,0x80,0x80,0x80,0x80},
+ {0x01,0x02,0xff},
+
+ {0x38,0x44,0x44,0x44,0x7c}, /* lowercase letters */
+ {0x7f,0x44,0x44,0x44,0x38},
+ {0x38,0x44,0x44,0x44,0x44},
+ {0x38,0x44,0x44,0x44,0x7f},
+ {0x38,0x54,0x54,0x54,0x58},
+ {0x04,0x7e,0x05,0x01,0xff},
+ {0x98,0xa4,0xa4,0xa4,0x7c},
+ {0x7f,0x04,0x04,0x04,0x78},
+ {0x7d,0xff},
+ {0x80,0x80,0x7d,0xff},
+ {0x7f,0x10,0x28,0x44,0xff},
+ {0x7f,0xff},
+ {0x7c,0x04,0x7c,0x04,0x78},
+ {0x7c,0x04,0x04,0x04,0x78},
+ {0x38,0x44,0x44,0x44,0x38},
+ {0xfc,0x24,0x24,0x24,0x18},
+ {0x18,0x24,0x24,0x24,0xfc},
+ {0x7c,0x08,0x04,0x04,0xff},
+ {0x48,0x54,0x54,0x54,0x24},
+ {0x04,0x3e,0x44,0x40,0xff},
+ {0x7c,0x40,0x40,0x40,0x3c},
+ {0x0c,0x30,0x40,0x30,0x0c},
+ {0x3c,0x40,0x3c,0x40,0x3c},
+ {0x44,0x28,0x10,0x28,0x44},
+ {0x9c,0xa0,0xa0,0xa0,0x7c},
+ {0x44,0x64,0x54,0x4c,0x44},
+
+ {0x08,0x36,0x41,0xff},
+ {0x77,0xff},
+ {0x41,0x36,0x08,0xff},
+ {0x02,0x01,0x02,0x01,0xff},
+ {0xff},
+
+ {0xfe,0x49,0x49,0x4e,0x30}, /* รก */
+
+ {0x7c,0x41,0x40,0x41,0x3c}, /* umlauts */
+
+ {0x04,0x06,0x7f,0x06,0x04}, /* arrows */
+ {0x20,0x60,0xfe,0x60,0x20},
+
+ {0x38,0x45,0x44,0x45,0x7c}, /* umlauts */
+ {0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},
+ {0x79,0x14,0x12,0x14,0x79},
+ {0xff},{0xff},{0xff},{0xff},{0xff},
+ {0x38,0x45,0x44,0x45,0x38},
+ {0xff},{0xff},{0xff},{0xff},
+ {0x3d,0x42,0x42,0x42,0x3d},
+ {0x3d,0x40,0x40,0x40,0x3d},
+};
+
#endif // MSN_DEF_H
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 3d83af1546..0a1eb459b0 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -45,6 +45,7 @@ namespace Supernova {
SupernovaEngine::SupernovaEngine(OSystem *syst)
: Engine(syst)
, _console(NULL)
+ , _colorIndex(0)
{
// const Common::FSNode gameDataDir(ConfMan.get("path"));
// SearchMan.addSubDirectoryMatching(gameDataDir, "sound");
@@ -63,35 +64,20 @@ SupernovaEngine::~SupernovaEngine() {
}
Common::Error SupernovaEngine::run() {
+// const Graphics::PixelFormat format(3, 8, 8, 8, 0, 16, 8, 0, 0);
+// initGraphics(kScreenWidth, kScreenHeight, &format);
initGraphics(kScreenWidth, kScreenHeight);
+ debug(_system->getScreenFormat().toString().c_str());
_console = new Console(this);
+ initPalette();
initData();
- bool running = true;
- while (running) {
- Common::Event event;
- while (g_system->getEventManager()->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_QUIT:
- case Common::EVENT_RTL:
- running = false;
- break;
-
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
- _console->attach();
- }
- if (event.kbd.keycode == Common::KEYCODE_q) {
- playSound(48, 13530);
- }
-
- break;
- default:
- break;
- }
- }
-
+ _gameRunning = true;
+ while (_gameRunning) {
+ updateEvents();
+ renderImage(31, 0);
+
_system->updateScreen();
_system->delayMillis(10);
}
@@ -102,20 +88,99 @@ Common::Error SupernovaEngine::run() {
return Common::kNoError;
}
-void SupernovaEngine::initData() {
- Common::File f;
- if (!f.open("msn_data.047")) {
- error("File s could not be read!");
+void SupernovaEngine::updateEvents() {
+ Common::Event event;
+
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RTL:
+ _gameRunning = false;
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
+ _console->attach();
+ }
+ if (event.kbd.keycode == Common::KEYCODE_q) {
+ playSound(48, 13530);
+ }
+ if (event.kbd.keycode == Common::KEYCODE_w) {
+ ++_colorIndex;
+ }
+ break;
+ default:
+ break;
+ }
}
+}
+
+void SupernovaEngine::initData() {
+}
+
+void SupernovaEngine::initPalette() {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00, 0x70, 0x70, 0x00, 0x54, 0x70, 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x00,
+ 0x00, 0x70, 0x00, 0x00, 0x70, 0x1c, 0x00, 0x70, 0x38, 0x00, 0x70, 0x54, 0x00, 0x70, 0x70, 0x00, 0x54, 0x70,
+ 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70,
+ 0x70, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38,
+ 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70, 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x38,
+ 0x38, 0x70, 0x38, 0x38, 0x70, 0x44, 0x38, 0x70, 0x54, 0x38, 0x70, 0x60, 0x38, 0x70, 0x70, 0x38, 0x60, 0x70,
+ 0x38, 0x54, 0x70, 0x38, 0x44, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70,
+ 0x70, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50,
+ 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70, 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x50,
+ 0x50, 0x70, 0x50, 0x50, 0x70, 0x58, 0x50, 0x70, 0x60, 0x50, 0x70, 0x68, 0x50, 0x70, 0x70, 0x50, 0x68, 0x70,
+ 0x50, 0x60, 0x70, 0x50, 0x58, 0x70, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40,
+ 0x40, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00,
+ 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40, 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x00,
+ 0x00, 0x40, 0x00, 0x00, 0x40, 0x10, 0x00, 0x40, 0x20, 0x00, 0x40, 0x30, 0x00, 0x40, 0x40, 0x00, 0x30, 0x40,
+ 0x00, 0x20, 0x40, 0x00, 0x10, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40,
+ 0x40, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20,
+ 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40, 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x20,
+ 0x20, 0x40, 0x20, 0x20, 0x40, 0x28, 0x20, 0x40, 0x30, 0x20, 0x40, 0x38, 0x20, 0x40, 0x40, 0x20, 0x38, 0x40,
+ 0x20, 0x30, 0x40, 0x20, 0x28, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40,
+ 0x40, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c,
+ 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40, 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x2c,
+ 0x2c, 0x40, 0x2c, 0x2c, 0x40, 0x30, 0x2c, 0x40, 0x34, 0x2c, 0x40, 0x3c, 0x2c, 0x40, 0x40, 0x2c, 0x3c, 0x40,
+ 0x2c, 0x34, 0x40, 0x2c, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ byte init_pal[] = {
+ 0, 0, 0, 16,16,16, 22,22,22, 28,28,28,
+ 63,63,63, 0,52, 0, 0,63, 0, 54, 0, 0,
+ 63, 0, 0, 0, 0,30, 0, 0,45, 40,40,40,
+ 20,50,63, 10,63,10, 60,60, 0, 63,10,10
+ };
+ Common::copy(init_pal, init_pal + sizeof(init_pal), pal);
- debug("%s\t%u", f.getName(), f.size());
+ _system->getPaletteManager()->setPalette(pal, 0, 256);
}
void SupernovaEngine::playSound(int filenumber, int offset) {
- Common::File *file = new Common::File();
- Common::String filename(Common::String::format("msn_data.0%2d", filenumber));
- if (!file->open(filename)) {
- error("File %s could not be read!", filename.c_str());
+ Common::File *file = new Common::File;
+ if (!file->open(Common::String::format("msn_data.0%2d", filenumber))) {
+ error("File %s could not be read!", file->getName());
}
file->seek(offset);
@@ -129,8 +194,29 @@ void SupernovaEngine::stopSound() {
_mixer->stopHandle(_soundHandle);
}
-void SupernovaEngine::renderImage(int file, int section) {
- // STUB
+void playSoundMod(int filenumber)
+{
+ if (filenumber != 49 || filenumber != 52) {
+ error("File not supposed to be played!");
+ }
+
+ Common::File *file = new Common::File;
+ if (!file->open(Common::String::format("msn_data.0%2d", filenumber))) {
+ error("File %s could not be read!", file->getName());
+ }
+
+ // play Supernova MOD file
+}
+
+void SupernovaEngine::renderImage(int filenumber, int section) {
+ Common::File file;
+ if (!file.open(Common::String::format("msn_data.0%2d", filenumber))) {
+ error("File %s could not be read!", file.getName());
+ }
+
+ _image.loadStream(file);
+ _image.loadSection(section);
+ _system->copyRectToScreen(_image.getSurface()->getPixels(), 320, 0, 0, 320, 200);
}
}
diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h
index 4eef366ddd..8319e9a87a 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -51,20 +51,17 @@ private:
Common::RandomSource *_rnd;
Console *_console;
Audio::SoundHandle _soundHandle;
-
- // name is file ending of msn_data.xxx
- // image decoded from file
- // sections ??
-// struct imageFile {
-// Common::String name;
-// MSNImageDecoder image;
-// };
-// Common::Array<imageFile> _images;
+ bool _gameRunning;
+ MSNImageDecoder _image;
+ byte _colorIndex;
void initData();
+ void initPalette();
+ void updateEvents();
void playSound(int filenumber, int offset = 0);
+ void playSoundMod(int filenumber);
void stopSound();
- void renderImage(int file, int section);
+ void renderImage(int filenumber, int section);
};
}