aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/graph.cpp
diff options
context:
space:
mode:
authoruruk2013-07-11 17:36:59 +0200
committeruruk2013-07-11 17:36:59 +0200
commit0aaffcfb941c95141eaa400082ee943463360068 (patch)
tree594358ee71afbad58e00e65423922c07e724672c /engines/avalanche/graph.cpp
parent6b87fc4f45d99d8d6f69984afa9bd408ccacd887 (diff)
downloadscummvm-rg350-0aaffcfb941c95141eaa400082ee943463360068.tar.gz
scummvm-rg350-0aaffcfb941c95141eaa400082ee943463360068.tar.bz2
scummvm-rg350-0aaffcfb941c95141eaa400082ee943463360068.zip
AVALANCHE: Add Graph.
Diffstat (limited to 'engines/avalanche/graph.cpp')
-rw-r--r--engines/avalanche/graph.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/engines/avalanche/graph.cpp b/engines/avalanche/graph.cpp
new file mode 100644
index 0000000000..30dd20aa2f
--- /dev/null
+++ b/engines/avalanche/graph.cpp
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
+ * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
+ */
+
+/* Replacement class for the Graph unit from Pascal. */
+
+#include "avalanche/avalanche.h"
+#include "avalanche/graph.h"
+
+#include "common/system.h"
+
+#include "engines/util.h"
+
+#include "graphics/palette.h"
+
+namespace Avalanche {
+
+const byte Graph::ega_palette_index[16] = {0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63};
+
+const byte Graph::ega_palette[64][3] =
+{
+ {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
+ {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
+ {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
+ {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
+ {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
+ {0x00,0x00,0x00}, {0x00,0x00,0x2a}, {0x00,0x2a,0x00}, {0x00,0x2a,0x2a}, {0x2a,0x00,0x00}, {0x2a,0x00,0x2a}, {0x2a,0x15,0x00}, {0x2a,0x2a,0x2a},
+ {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f},
+ {0x15,0x15,0x15}, {0x15,0x15,0x3f}, {0x15,0x3f,0x15}, {0x15,0x3f,0x3f}, {0x3f,0x15,0x15}, {0x3f,0x15,0x3f}, {0x3f,0x3f,0x15}, {0x3f,0x3f,0x3f}
+};
+
+
+
+
+void Graph::setParent(AvalancheEngine *vm) {
+ _vm = vm;
+}
+
+void Graph::init() {
+ initGraphics(_screenWidth, _screenHeight, false);
+
+ for (byte i = 0; i < 16; i++)
+ g_system->getPaletteManager()->setPalette(ega_palette[ega_palette_index[i]], i, 1);
+
+ _surface.create(_screenWidth, _screenHeight, Graphics::PixelFormat::createFormatCLUT8());
+}
+
+Graph::~Graph() {
+ _surface.free();
+}
+
+byte *Graph::getPixel(int16 x, int16 y) {
+ return (byte *)_surface.getBasePtr(x, y);
+}
+
+void Graph::setPixel(byte *pixel, byte color) {
+ memset(pixel, color, 1);
+}
+
+void Graph::drawToScreen() {
+ g_system->copyRectToScreen(_surface.pixels, _surface.pitch , 0, 0, _screenWidth, _screenHeight);
+ g_system->updateScreen();
+}
+
+} // End of namespace Avalanche