diff options
author | uruk | 2014-03-04 12:01:41 +0100 |
---|---|---|
committer | uruk | 2014-03-04 12:01:56 +0100 |
commit | d69975af14e121ff32f26bb86353e30044da1537 (patch) | |
tree | b0ae5b7b8ec85383249c0c76fb62c3dbfabab264 /engines | |
parent | c049ab0ef0a31a64c518d2faa34092d5ca44bdd5 (diff) | |
download | scummvm-rg350-d69975af14e121ff32f26bb86353e30044da1537.tar.gz scummvm-rg350-d69975af14e121ff32f26bb86353e30044da1537.tar.bz2 scummvm-rg350-d69975af14e121ff32f26bb86353e30044da1537.zip |
AVALANCHE: Move to graphics and implement GraphicManager::menuLoadIcons().
Add and implement necessary graphical functions for the main menu during the process.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/graphics.cpp | 64 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 10 | ||||
-rw-r--r-- | engines/avalanche/mainmenu.cpp | 8 | ||||
-rw-r--r-- | engines/avalanche/mainmenu.h | 1 |
4 files changed, 77 insertions, 6 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 11b149babd..83910d00ad 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -787,6 +787,70 @@ uint16 GraphicManager::seuGetPicHeight(int which) { return _seuPictures[which].h; } +void GraphicManager::menuRefreshScreen() { + g_system->copyRectToScreen(_menu.getPixels(), _menu.pitch, 0, 0, kScreenWidth, kMenuScreenHeight); + g_system->updateScreen(); +} + +void GraphicManager::menuInitialize() { + initGraphics(kScreenWidth, kMenuScreenHeight, true); + _menu.create(kScreenWidth, kMenuScreenHeight, Graphics::PixelFormat::createFormatCLUT8()); +} + +void GraphicManager::menuClear() { + _menu.free(); + initGraphics(kScreenWidth, 2 * kScreenHeight, true); +} + +void GraphicManager::menuLoadIcons() { + _menu.fillRect(Common::Rect(0, 0, kScreenWidth, kMenuScreenHeight), kColorBlack); + + Common::File file; + + if (!file.open("menu.avd")) + error("AVALANCHE: MainMenu: File not found: menu.avd"); + + int height = 33; + int width = 9 * 8; + + for (int plane = 0; plane < 4; plane++) { + // The icons themselves: + int n = 0; + for (uint16 y = 70; y < 70 + height * 6; y++) { + for (uint16 x = 48; x < 48 + width; x += 8) { + if (n < 1773) { // Magic value deciphered from the original code. + byte pixel = file.readByte(); + n++; + for (int i = 0; i < 8; i++) { + byte pixelBit = (pixel >> i) & 1; + *(byte *)_menu.getBasePtr(x + 7 - i, y) += (pixelBit << plane); + } + } + } + } + // The right borders of the menuboxes: + for (int a = 0; a < 33; a++) { + byte pixel = file.readByte(); + for (int b = 0; b < 6; b++) { + for (int i = 0; i < 8; i++) { + byte pixelBit = (pixel >> i) & 1; + *(byte *)_menu.getBasePtr(584 + 7 - i, 70 + b * 33 + a) += (pixelBit << plane); + } + } + } + } + + for (int i = 0; i < 6; i++) { + _menu.fillRect(Common::Rect(114, 73 + i * 33, 584, 100 + i * 33), kColorLightgray); + _menu.fillRect(Common::Rect(114, 70 + i * 33, 584, 73 + i * 33), kColorWhite); + _menu.fillRect(Common::Rect(114, 100 + i * 33, 584, 103 + i * 33), kColorDarkgray); + } + + menuRefreshScreen(); + + file.close(); +} + /** * This function is for skipping the difference between a stored 'size' value associated with a picture * and the actual size of the pictures when reading them from files for Ghostroom and Shoot em' up. diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index 579aa2e056..fa72847856 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -117,6 +117,14 @@ public: uint16 seuGetPicWidth(int which); uint16 seuGetPicHeight(int which); + // Main Menu's functions: + // The main menu uses a different screen height (350) from the game itself (200 * 2) + // so it needs it's own graphic functions on that matter. + void menuRefreshScreen(); + void menuInitialize(); + void menuClear(); + void menuLoadIcons(); + void clearAlso(); void clearTextBar(); void setAlsoLine(int x1, int y1, int x2, int y2, Color color); @@ -157,6 +165,7 @@ private: static const byte kEgaPaletteIndex[16]; static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth; // With 640 width it's 151. // The 8 = number of bits in a byte, and 12080 comes from Lucerna::load(). + static const uint16 kMenuScreenHeight = 350; Graphics::Surface _background; Graphics::Surface _backup; @@ -166,6 +175,7 @@ private: Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.) Graphics::Surface _scrolls; Graphics::Surface _surface; + Graphics::Surface _menu; // For the mini-game "Nim". Graphics::Surface _nimStone; diff --git a/engines/avalanche/mainmenu.cpp b/engines/avalanche/mainmenu.cpp index b9ff900bf2..30b92a9bf3 100644 --- a/engines/avalanche/mainmenu.cpp +++ b/engines/avalanche/mainmenu.cpp @@ -37,7 +37,8 @@ MainMenu::MainMenu(AvalancheEngine *vm) { } void MainMenu::run() { - icons(); + _vm->_graphics->menuInitialize(); + _vm->_graphics->menuLoadIcons(); loadMenu(); loadRegiInfo(); @@ -51,10 +52,7 @@ void MainMenu::run() { centre(303, "Make your choice, or wait for the demo."); wait(); -} - -void MainMenu::icons() { - warning("STUB: MainMenu::icons()"); + _vm->_graphics->menuClear(); } void MainMenu::loadMenu() { diff --git a/engines/avalanche/mainmenu.h b/engines/avalanche/mainmenu.h index 0eece87c02..b5e0a0e3da 100644 --- a/engines/avalanche/mainmenu.h +++ b/engines/avalanche/mainmenu.h @@ -42,7 +42,6 @@ private: Common::String registrant; - void icons(); void loadMenu(); void loadRegiInfo(); void option(byte which, Common::String what); |