2013-07-11 17:36:59 +02:00
/* 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 .
*/
2013-09-07 09:00:34 +02:00
# ifndef AVALANCHE_GRAPHICS_H
# define AVALANCHE_GRAPHICS_H
2013-07-11 17:36:59 +02:00
2013-07-16 13:03:22 +02:00
# include "common/file.h"
2013-07-11 17:36:59 +02:00
# include "graphics/surface.h"
2013-08-08 03:59:29 +02:00
# include "common/rect.h"
2013-07-11 17:36:59 +02:00
namespace Avalanche {
class AvalancheEngine ;
2013-09-05 13:20:03 +02:00
typedef byte FontType [ 256 ] [ 16 ] ; // raw font type
2013-08-11 14:06:15 +02:00
2013-09-07 09:00:34 +02:00
typedef byte ManiType [ 2049 ] ; // manitype = array[5..2053] of byte;
2013-07-18 15:13:23 +02:00
// Be aware!!!
2013-09-05 13:20:03 +02:00
typedef byte SilType [ 51 ] [ 11 ] ; // 35, 4
2013-07-18 15:13:23 +02:00
class SpriteInfo {
public :
2013-09-05 13:20:03 +02:00
byte _xWidth ;
byte _xLength , _yLength ;
ManiType * _mani [ 24 ] ;
SilType * _sil [ 24 ] ;
uint16 _size ; // The size of one picture.
2013-07-18 15:13:23 +02:00
} ;
2013-07-24 17:02:08 +02:00
class Graphics {
2013-07-11 17:36:59 +02:00
public :
2013-07-24 16:42:23 +02:00
static const int16 kScreenWidth = 640 ;
static const int16 kScreenHeight = 200 ;
2013-08-21 18:01:31 +02:00
static const uint16 kBackgroundWidth = kScreenWidth ;
2013-09-05 13:20:03 +02:00
static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth ; // With 640 width it's 151.
2013-08-21 18:01:31 +02:00
// The 8 = number of bits in a byte, and 12080 comes from Lucerna::load().
2013-08-06 01:17:44 +02:00
: : Graphics : : Surface _surface ;
2013-07-29 12:22:59 +02:00
: : Graphics : : Surface _background ;
2013-09-05 13:20:03 +02:00
: : Graphics : : Surface _magics ; // Lucerna::draw_also_lines() draws the "magical" lines here. Further information: https://github.com/urukgit/avalot/wiki/Also
2013-08-06 01:17:44 +02:00
: : Graphics : : Surface _scrolls ;
2013-07-30 20:33:05 +02:00
2013-07-24 17:52:57 +02:00
Graphics ( AvalancheEngine * vm ) ;
2013-07-24 17:02:08 +02:00
~ Graphics ( ) ;
2013-09-05 13:20:03 +02:00
void init ( ) ;
void fleshColors ( ) ;
2013-09-07 09:00:34 +02:00
2013-08-07 23:51:12 +02:00
// Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
2013-08-08 03:59:29 +02:00
// Returns the end point of the arc. (Needed in Lucerna::lucerna_clock().)
2013-08-08 12:24:37 +02:00
// TODO: Make it more accurate later.
2013-09-05 13:20:03 +02:00
Common : : Point drawArc ( : : Graphics : : Surface & surface , int16 x , int16 y , int16 stAngle , int16 endAngle , uint16 radius , byte color ) ;
2013-09-07 09:00:34 +02:00
2013-08-11 00:29:48 +02:00
void drawPieSlice ( : : Graphics : : Surface & surface , int16 x , int16 y , int16 stAngle , int16 endAngle , uint16 radius , byte color ) ;
void drawTriangle ( : : Graphics : : Surface & surface , Common : : Point * p , byte color ) ;
2013-09-05 13:20:03 +02:00
void drawText ( : : Graphics : : Surface & surface , const Common : : String & text , FontType font , byte fontHeight , int16 x , int16 y , byte color ) ;
2013-08-11 14:06:15 +02:00
2013-07-26 13:32:08 +02:00
// The caller has to .free() the returned Surfaces!!!
2013-09-05 13:20:03 +02:00
// Further information about these two: http://www.shikadi.net/moddingwiki/Raw_EGA_data
2013-07-26 13:32:08 +02:00
: : Graphics : : Surface loadPictureGraphic ( Common : : File & file ) ; // Reads Graphic-planar EGA data.
: : Graphics : : Surface loadPictureRow ( Common : : File & file , uint16 width , uint16 height ) ; // Reads Row-planar EGA data.
2013-09-05 13:20:03 +02:00
void drawSprite ( const SpriteInfo & sprite , byte picnum , int16 x , int16 y ) ;
2013-09-16 16:18:02 +02:00
void drawPicture ( : : Graphics : : Surface & target , const : : Graphics : : Surface & picture , uint16 destX , uint16 destY ) ; // Can't call .free() here. See Lucerna::showscore() for example.
2013-07-12 10:25:16 +02:00
void refreshScreen ( ) ;
2013-08-23 11:33:37 +02:00
void refreshBackground ( ) ;
2013-07-11 17:36:59 +02:00
private :
AvalancheEngine * _vm ;
2013-09-05 10:51:47 +02:00
static const byte kEgaPaletteIndex [ 16 ] ;
2013-07-11 17:36:59 +02:00
2013-07-12 08:41:14 +02:00
byte _egaPalette [ 64 ] [ 3 ] ;
2013-09-05 13:20:03 +02:00
: : Graphics : : Surface _screen ; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.)
2013-07-11 17:36:59 +02:00
} ;
} // End of namespace Avalanche
2013-09-07 09:00:34 +02:00
# endif // AVALANCHE_GRAPHICS_H