[Scummvm-cvs-logs] scummvm master -> d69975af14e121ff32f26bb86353e30044da1537

urukgit urukgit at users.noreply.github.com
Tue Mar 4 12:02:35 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d69975af14 AVALANCHE: Move to graphics and implement GraphicManager::menuLoadIcons().


Commit: d69975af14e121ff32f26bb86353e30044da1537
    https://github.com/scummvm/scummvm/commit/d69975af14e121ff32f26bb86353e30044da1537
Author: uruk (koppirnyo at gmail.com)
Date: 2014-03-04T03:01:56-08:00

Commit Message:
AVALANCHE: Move to graphics and implement GraphicManager::menuLoadIcons().

Add and implement necessary graphical functions for the main menu during the process.

Changed paths:
    engines/avalanche/graphics.cpp
    engines/avalanche/graphics.h
    engines/avalanche/mainmenu.cpp
    engines/avalanche/mainmenu.h



diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 11b149b..83910d0 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 579aa2e..fa72847 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 b9ff900..30b92a9 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 0eece87..b5e0a0e 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);






More information about the Scummvm-git-logs mailing list