From bc5b3fbb65cc902d9ac2b44f3038f9543342ee96 Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 24 Jul 2013 17:02:08 +0200 Subject: AVALANCHE: Rename Graph to Graphics. Update everything accordingly. --- engines/avalanche/avalanche.h | 4 +- engines/avalanche/avalot.cpp | 2 +- engines/avalanche/graph.cpp | 148 ----------------------------------------- engines/avalanche/graph.h | 94 -------------------------- engines/avalanche/graphics.cpp | 148 +++++++++++++++++++++++++++++++++++++++++ engines/avalanche/graphics.h | 94 ++++++++++++++++++++++++++ engines/avalanche/lucerna2.cpp | 4 +- engines/avalanche/module.mk | 2 +- engines/avalanche/trip6.h | 2 +- 9 files changed, 249 insertions(+), 249 deletions(-) delete mode 100644 engines/avalanche/graph.cpp delete mode 100644 engines/avalanche/graph.h create mode 100644 engines/avalanche/graphics.cpp create mode 100644 engines/avalanche/graphics.h (limited to 'engines') diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index fac36b4217..122959ee27 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -30,7 +30,7 @@ #include "avalanche/console.h" -#include "avalanche/graph.h" +#include "avalanche/graphics.h" #include "avalanche/avalot.h" #include "avalanche/gyro2.h" @@ -65,7 +65,7 @@ static const int kSavegameVersion = 1; class AvalancheEngine : public Engine { public: - Graph _graph; + Graphics _graph; Avalot _avalot; Gyro _gyro; diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index f9b6a1fcf5..2f62dc1712 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -29,7 +29,7 @@ #include "avalanche/avalanche.h" -#include "avalanche/graph.h" +#include "avalanche/graphics.h" #include "avalanche/avalot.h" #include "avalanche/gyro2.h" #include "avalanche/trip6.h" diff --git a/engines/avalanche/graph.cpp b/engines/avalanche/graph.cpp deleted file mode 100644 index b3d5012353..0000000000 --- a/engines/avalanche/graph.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* 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" -#include "common/rect.h" - -namespace Avalanche { - -const byte Graph::_egaPaletteIndex[16] = {0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63}; - - - -void Graph::setParent(AvalancheEngine *vm) { - _vm = vm; -} - -void Graph::init() { - initGraphics(kScreenWidth, kScreenHeight, true); - - for (int i = 0; i < 64; ++i) { - _egaPalette[i][0] = (i >> 2 & 1) * 0xaa + (i >> 5 & 1) * 0x55; - _egaPalette[i][1] = (i >> 1 & 1) * 0xaa + (i >> 4 & 1) * 0x55; - _egaPalette[i][2] = (i & 1) * 0xaa + (i >> 3 & 1) * 0x55; - } - - for (byte i = 0; i < 16; i++) - g_system->getPaletteManager()->setPalette(_egaPalette[_egaPaletteIndex[i]], i, 1); - - _surface.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8()); -} - -Graph::~Graph() { - _surface.free(); -} - - -void Graph::flesh_colours() -{ - g_system->getPaletteManager()->setPalette(_egaPalette[39], 13, 1); - g_system->getPaletteManager()->setPalette(_egaPalette[28], 5, 1); -} - - -byte *Graph::getPixel(int16 x, int16 y) { - return (byte *)_surface.getBasePtr(x, y); -} - -void Graph::drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color) { - _surface.fillRect(Common::Rect(x1, y1, x2, y2), color); -} - -void Graph::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y) { - - /* First we make the pixels of the spirte blank. */ - for (byte qay = 0; qay < sprite.yl; qay++) { - byte *mask = new byte[sprite.xl]; - - for (byte qax = 0; qax < sprite.xl; qax++) { - byte count = qax / 8; - mask[qax] = ((*sprite.sil[picnum])[qay][count] >> ((7 - qax % 8)) & 1); - if (mask[qax] == 0) - *getPixel(x + qax, y + qay) = 0; - } - - delete[] mask; - } - - /* Then we draw the picture to the blank places. */ - uint16 i = 0; // Because the original siltype starts at 5!!! See Graph.h for definition. - - for (byte qay = 0; qay < sprite.yl; qay++) - for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way. - for (uint16 qax = 0; qax < sprite.xl; qax += 8) { - byte pixel = (*sprite.mani[picnum])[i++]; - for (byte bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - *getPixel(x + qax + 7 - bit, y + qay) += (pixelBit << plane); - } - } -} - -void Graph::drawPicture(const byte *source, uint16 destX, uint16 destY) { - // The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1. - uint16 pictureWidth = READ_LE_UINT16(source) + 1; - uint16 pictureHeight = READ_LE_UINT16(source + 2) + 1; - - uint32 i = 4; - - Graphics::Surface picture; // We make a Surface object for the picture itself. - - picture.create(pictureWidth, pictureHeight, Graphics::PixelFormat::createFormatCLUT8()); - - // Produce the picture. - for (byte y = 0; y < pictureHeight; y++) - for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way. - for (uint16 x = 0; x < pictureWidth; x += 8) { - byte pixel = source[i++]; - for (byte bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - *(byte *)picture.getBasePtr(x + 7 - bit, y) += (pixelBit << plane); - } - } - - // Copy the picture to a given place on the screen. - for (uint16 y = 0; y < picture.h; y++) - for (uint16 x = 0; x < picture.w; x++) - *(byte *)_surface.getBasePtr(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y); -} - -void Graph::refreshScreen() { - g_system->copyRectToScreen(_surface.pixels, _surface.pitch , 0, 0, kScreenWidth, kScreenHeight); - g_system->updateScreen(); -} - -} // End of namespace Avalanche diff --git a/engines/avalanche/graph.h b/engines/avalanche/graph.h deleted file mode 100644 index e24e042abd..0000000000 --- a/engines/avalanche/graph.h +++ /dev/null @@ -1,94 +0,0 @@ -/* 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. */ - -#ifndef GRAPH_H -#define GRAPH_H - -#include "common/file.h" - -#include "graphics/surface.h" - -namespace Avalanche { -class AvalancheEngine; - -typedef byte manitype[2049]; // manitype = array[5..2053] of byte; -// Be aware!!! - -typedef byte siltype[51][11]; /* 35, 4 */ - -class SpriteInfo { -public: - byte xw; /* x-width in bytes */ - byte xl, yl; /* x & y lengths of pictures */ - - manitype *mani[24]; - siltype *sil[24]; - - uint16 size; /* the size of one picture */ -}; - - -class Graph { -public: - static const int16 kScreenWidth = 640; - static const int16 kScreenHeight = 200; - - - - void setParent(AvalancheEngine *vm); - - void init(); - - ~Graph(); - - void flesh_colours(); - - byte *getPixel(int16 x, int16 y); - - void drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color); - - void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y); - - void drawPicture(const byte *source, uint16 destX, uint16 destY); - - void refreshScreen(); - -private: - AvalancheEngine *_vm; - - Graphics::Surface _surface; - - static const byte _egaPaletteIndex[16]; - - byte _egaPalette[64][3]; -}; - -} // End of namespace Avalanche - -#endif // GRAPH_H diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp new file mode 100644 index 0000000000..aefaa49054 --- /dev/null +++ b/engines/avalanche/graphics.cpp @@ -0,0 +1,148 @@ +/* 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/graphics.h" + +#include "common/system.h" + +#include "engines/util.h" + +#include "graphics/palette.h" +#include "common/rect.h" + +namespace Avalanche { + +const byte Graphics::_egaPaletteIndex[16] = {0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63}; + + + +void Graphics::setParent(AvalancheEngine *vm) { + _vm = vm; +} + +void Graphics::init() { + initGraphics(kScreenWidth, kScreenHeight, true); + + for (int i = 0; i < 64; ++i) { + _egaPalette[i][0] = (i >> 2 & 1) * 0xaa + (i >> 5 & 1) * 0x55; + _egaPalette[i][1] = (i >> 1 & 1) * 0xaa + (i >> 4 & 1) * 0x55; + _egaPalette[i][2] = (i & 1) * 0xaa + (i >> 3 & 1) * 0x55; + } + + for (byte i = 0; i < 16; i++) + g_system->getPaletteManager()->setPalette(_egaPalette[_egaPaletteIndex[i]], i, 1); + + _surface.create(kScreenWidth, kScreenHeight, ::Graphics::PixelFormat::createFormatCLUT8()); +} + +Graphics::~Graphics() { + _surface.free(); +} + + +void Graphics::flesh_colours() +{ + g_system->getPaletteManager()->setPalette(_egaPalette[39], 13, 1); + g_system->getPaletteManager()->setPalette(_egaPalette[28], 5, 1); +} + + +byte *Graphics::getPixel(int16 x, int16 y) { + return (byte *)_surface.getBasePtr(x, y); +} + +void Graphics::drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color) { + _surface.fillRect(Common::Rect(x1, y1, x2, y2), color); +} + +void Graphics::drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y) { + + /* First we make the pixels of the spirte blank. */ + for (byte qay = 0; qay < sprite.yl; qay++) { + byte *mask = new byte[sprite.xl]; + + for (byte qax = 0; qax < sprite.xl; qax++) { + byte count = qax / 8; + mask[qax] = ((*sprite.sil[picnum])[qay][count] >> ((7 - qax % 8)) & 1); + if (mask[qax] == 0) + *getPixel(x + qax, y + qay) = 0; + } + + delete[] mask; + } + + /* Then we draw the picture to the blank places. */ + uint16 i = 0; // Because the original siltype starts at 5!!! See Graph.h for definition. + + for (byte qay = 0; qay < sprite.yl; qay++) + for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way. + for (uint16 qax = 0; qax < sprite.xl; qax += 8) { + byte pixel = (*sprite.mani[picnum])[i++]; + for (byte bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + *getPixel(x + qax + 7 - bit, y + qay) += (pixelBit << plane); + } + } +} + +void Graphics::drawPicture(const byte *source, uint16 destX, uint16 destY) { + // The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1. + uint16 pictureWidth = READ_LE_UINT16(source) + 1; + uint16 pictureHeight = READ_LE_UINT16(source + 2) + 1; + + uint32 i = 4; + + ::Graphics::Surface picture; // We make a Surface object for the picture itself. + + picture.create(pictureWidth, pictureHeight, ::Graphics::PixelFormat::createFormatCLUT8()); + + // Produce the picture. + for (byte y = 0; y < pictureHeight; y++) + for (int8 plane = 3; plane >= 0; plane--) // The planes are in the opposite way. + for (uint16 x = 0; x < pictureWidth; x += 8) { + byte pixel = source[i++]; + for (byte bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + *(byte *)picture.getBasePtr(x + 7 - bit, y) += (pixelBit << plane); + } + } + + // Copy the picture to a given place on the screen. + for (uint16 y = 0; y < picture.h; y++) + for (uint16 x = 0; x < picture.w; x++) + *(byte *)_surface.getBasePtr(x + destX, y + destY) = *(byte *)picture.getBasePtr(x, y); +} + +void Graphics::refreshScreen() { + g_system->copyRectToScreen(_surface.pixels, _surface.pitch , 0, 0, kScreenWidth, kScreenHeight); + g_system->updateScreen(); +} + +} // End of namespace Avalanche diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h new file mode 100644 index 0000000000..333cbddfca --- /dev/null +++ b/engines/avalanche/graphics.h @@ -0,0 +1,94 @@ +/* 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. */ + +#ifndef GRAPH_H +#define GRAPH_H + +#include "common/file.h" + +#include "graphics/surface.h" + +namespace Avalanche { +class AvalancheEngine; + +typedef byte manitype[2049]; // manitype = array[5..2053] of byte; +// Be aware!!! + +typedef byte siltype[51][11]; /* 35, 4 */ + +class SpriteInfo { +public: + byte xw; /* x-width in bytes */ + byte xl, yl; /* x & y lengths of pictures */ + + manitype *mani[24]; + siltype *sil[24]; + + uint16 size; /* the size of one picture */ +}; + + +class Graphics { +public: + static const int16 kScreenWidth = 640; + static const int16 kScreenHeight = 200; + + + + void setParent(AvalancheEngine *vm); + + void init(); + + ~Graphics(); + + void flesh_colours(); + + byte *getPixel(int16 x, int16 y); + + void drawBar(int16 x1, int16 y1, int16 x2, int16 y2, int16 color); + + void drawSprite(const SpriteInfo &sprite, byte picnum, int16 x, int16 y); + + void drawPicture(const byte *source, uint16 destX, uint16 destY); + + void refreshScreen(); + +private: + AvalancheEngine *_vm; + + ::Graphics::Surface _surface; + + static const byte _egaPaletteIndex[16]; + + byte _egaPalette[64][3]; +}; + +} // End of namespace Avalanche + +#endif // GRAPH_H diff --git a/engines/avalanche/lucerna2.cpp b/engines/avalanche/lucerna2.cpp index d75468d99c..3b30451bed 100644 --- a/engines/avalanche/lucerna2.cpp +++ b/engines/avalanche/lucerna2.cpp @@ -243,13 +243,13 @@ void Lucerna::load(byte n) { /* Load2, actually */ move(a0, a1, 12080); }*/ - Graphics::Surface background; + ::Graphics::Surface background; uint16 backgroundWidht = _vm->_graph.kScreenWidth; byte backgroundHeight = 8 * 12080 / _vm->_graph.kScreenWidth; // With 640 width it's 151 // The 8 = number of bits in a byte, and 12080 comes from the original code (see above) - background.create(backgroundWidht, backgroundHeight, Graphics::PixelFormat::createFormatCLUT8()); + background.create(backgroundWidht, backgroundHeight, ::Graphics::PixelFormat::createFormatCLUT8()); for (byte plane = 0; plane < 4; plane++) for (uint16 y = 0; y < backgroundHeight; y++) diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk index 222482e406..306df15513 100644 --- a/engines/avalanche/module.mk +++ b/engines/avalanche/module.mk @@ -2,7 +2,7 @@ MODULE := engines/avalanche MODULE_OBJS = \ avalanche.o \ - graph.o \ + graphics.o \ avalot.o \ console.o \ detection.o \ diff --git a/engines/avalanche/trip6.h b/engines/avalanche/trip6.h index bd9b00a608..4b84221e11 100644 --- a/engines/avalanche/trip6.h +++ b/engines/avalanche/trip6.h @@ -31,7 +31,7 @@ #ifndef TRIP6_H #define TRIP6_H -#include "avalanche/graph.h" +#include "avalanche/graphics.h" #include "common/scummsys.h" #include "common/str.h" -- cgit v1.2.3