diff options
Diffstat (limited to 'engines/supernova/supernova.cpp')
-rw-r--r-- | engines/supernova/supernova.cpp | 156 |
1 files changed, 121 insertions, 35 deletions
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() { + // Default VGA palette + byte pal[768] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0x00, 0xa8, 0x00, 0x00, 0xa8, 0xa8, 0xa8, 0x00, 0x00, 0xa8, 0x00, 0xa8, + 0xa8, 0x54, 0x00, 0xa8, 0xa8, 0xa8, 0x54, 0x54, 0x54, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0x54, 0x54, 0xfc, 0xfc, + 0xfc, 0x54, 0x54, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x54, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x14, 0x14, 0x14, + 0x20, 0x20, 0x20, 0x2c, 0x2c, 0x2c, 0x38, 0x38, 0x38, 0x44, 0x44, 0x44, 0x50, 0x50, 0x50, 0x60, 0x60, 0x60, + 0x70, 0x70, 0x70, 0x80, 0x80, 0x80, 0x90, 0x90, 0x90, 0xa0, 0xa0, 0xa0, 0xb4, 0xb4, 0xb4, 0xc8, 0xc8, 0xc8, + 0xe0, 0xe0, 0xe0, 0xfc, 0xfc, 0xfc, 0x00, 0x00, 0xfc, 0x40, 0x00, 0xfc, 0x7c, 0x00, 0xfc, 0xbc, 0x00, 0xfc, + 0xfc, 0x00, 0xfc, 0xfc, 0x00, 0xbc, 0xfc, 0x00, 0x7c, 0xfc, 0x00, 0x40, 0xfc, 0x00, 0x00, 0xfc, 0x40, 0x00, + 0xfc, 0x7c, 0x00, 0xfc, 0xbc, 0x00, 0xfc, 0xfc, 0x00, 0xbc, 0xfc, 0x00, 0x7c, 0xfc, 0x00, 0x40, 0xfc, 0x00, + 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x40, 0x00, 0xfc,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+ 0x70, 0x00, 0x70, 0x70, 0x00, 0x54, 0x70, 0x00, 0x38, 0x70, 0x00, 0x1c, 0x70, 0x00, 0x00, 0x70, 0x1c, 0x00, + 0x70, 0x38, 0x00, 0x70, 0x54, 0x00, 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); } } |