aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authoruruk2013-12-17 08:32:19 +0100
committeruruk2013-12-17 08:35:42 +0100
commit16194e227f9bef26240b8ecd3cfc604e8bc84c19 (patch)
tree57b2f4a63fbfb488e39772aa5053ba28c3f19296 /engines
parent5a1fe83911495bc91e08a27d76e1db03719ec8ec (diff)
downloadscummvm-rg350-16194e227f9bef26240b8ecd3cfc604e8bc84c19.tar.gz
scummvm-rg350-16194e227f9bef26240b8ecd3cfc604e8bc84c19.tar.bz2
scummvm-rg350-16194e227f9bef26240b8ecd3cfc604e8bc84c19.zip
AVALANCHE: Add some graphic functions for Nim.
Diffstat (limited to 'engines')
-rw-r--r--engines/avalanche/graphics.cpp72
-rw-r--r--engines/avalanche/graphics.h7
2 files changed, 58 insertions, 21 deletions
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 841512847f..4fdb21db7b 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -59,6 +59,7 @@ GraphicManager::~GraphicManager() {
_screen.free();
_scrolls.free();
_backup.free();
+ _nimStone.free();
for (int i = 0; i < 10; i++)
_digits[i].free();
@@ -451,6 +452,28 @@ void GraphicManager::drawDebugLines() {
}
}
+void GraphicManager::blackOutScreen() {
+ _surface.fillRect(Common::Rect(0, 0, _surface.w, _surface.h), Color::kColorBlack);
+}
+
+void GraphicManager::loadNimStone() {
+ Common::File file;
+ Common::String filename = "nim.avd";
+
+ if (!file.open(filename))
+ error("AVALANCHE: Scrolls: File not found: %s", filename.c_str());
+
+ file.seek(41);
+
+ _nimStone = loadPictureSign(file, 7, 23);
+
+ file.close();
+}
+
+void GraphicManager::drawNimStone(int x, int y) {
+ drawPicture(_surface, _nimStone, x, y);
+}
+
/**
* This function mimics Pascal's getimage().
*/
@@ -503,6 +526,31 @@ Graphics::Surface GraphicManager::loadPictureRaw(Common::File &file, uint16 widt
return picture;
}
+Graphics::Surface GraphicManager::loadPictureSign(Common::File &file, int xl, int yl) {
+ // I know it looks very similar to the other loadPicture methods, but in truth it's the combination of the two.
+ uint16 width = xl * 8;
+ uint16 height = yl;
+
+ Graphics::Surface picture; // We make a Surface object for the picture itself.
+ picture.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+
+ // Produce the picture. We read it in row-by-row, and every row has 4 planes.
+ for (int yy = 0; yy < height; yy++) {
+ for (int8 plane = 0; plane < 4; plane++) { // The planes are in the "right" order.
+ for (uint16 xx = 0; xx < width; xx += 8) {
+ byte pixel = file.readByte();
+ for (int bit = 0; bit < 8; bit++) {
+ byte pixelBit = (pixel >> bit) & 1;
+ if (pixelBit != 0)
+ *(byte *)picture.getBasePtr(xx + 7 - bit, yy) += (pixelBit << plane);
+ }
+ }
+ }
+ }
+
+ return picture;
+}
+
void GraphicManager::clearAlso() {
_magics.fillRect(Common::Rect(0, 0, 640, 200), 0);
_magics.frameRect(Common::Rect(0, 45, 640, 161), 15);
@@ -603,28 +651,10 @@ void GraphicManager::drawSign(Common::String fn, int16 xl, int16 yl, int16 y) {
if (!file.open(filename))
error("AVALANCHE: Scrolls: File not found: %s", filename.c_str());
- // I know it looks very similar to the loadPicture methods, but in truth it's the combination of the two.
- uint16 width = xl * 8;
- uint16 height = yl;
-
Graphics::Surface sign; // We make a Surface object for the picture itself.
- sign.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
-
- // Produce the picture. We read it in row-by-row, and every row has 4 planes.
- for (int yy = 0; yy < height; yy++) {
- for (int8 plane = 0; plane < 4; plane++) { // The planes are in the "right" order.
- for (uint16 xx = 0; xx < width; xx += 8) {
- byte pixel = file.readByte();
- for (int bit = 0; bit < 8; bit++) {
- byte pixelBit = (pixel >> bit) & 1;
- if (pixelBit != 0)
- *(byte *)sign.getBasePtr(xx + 7 - bit, yy) += (pixelBit << plane);
- }
- }
- }
- }
-
- drawPicture(_scrolls, sign, kScreenWidth / 2 - width / 2, y);
+ sign = loadPictureSign(file, xl, yl);
+ uint16 width = xl * 8;
+ drawPicture(_scrolls, sign, kScreenWidth / 2 - width / 2, y); // x coord: center the picture.
file.close();
}
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index 4af6d4e8db..0df91de67f 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -77,6 +77,11 @@ public:
void drawChar(byte ander, int x, int y, Color color);
void drawDebugLines();
+ // For the mini-game "Nim".
+ void blackOutScreen();
+ void loadNimStone();
+ void drawNimStone(int x, int y);
+
void clearAlso();
void clearTextBar();
void setAlsoLine(int x1, int y1, int x2, int y2, Color color);
@@ -125,11 +130,13 @@ 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 _nimStone; // For the mini-game "Nim".
byte _egaPalette[64][3];
AvalancheEngine *_vm;
Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data.
+ Graphics::Surface loadPictureSign(Common::File &file, int xl, int yl); // Reads a tricky type of picture used for the "game over"/"about" scrolls and in the mini-game Nim.
void drawText(Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
// Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
// Returns the end point of the arc. (Needed in Clock.)