ScummVM API documentation
graphics.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
24  * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
25  */
26 
27 #ifndef AVALANCHE_GRAPHICS_H
28 #define AVALANCHE_GRAPHICS_H
29 
30 #include "avalanche/enums.h"
31 
32 #include "common/file.h"
33 #include "common/rect.h"
34 #include "graphics/surface.h"
35 
36 namespace Avalanche {
37 class AvalancheEngine;
38 class AnimationType;
39 struct SpriteType;
40 struct ChunkBlock;
41 
42 typedef byte FontType[256][16];
43 typedef byte ManiType[2049];
44 typedef byte SilType[51][11]; // 35, 4
45 
47  int16 _horizontal, _vertical;
48 };
49 
51 public:
52  static const MouseHotspotType kMouseHotSpots[9];
53  Color _talkBackgroundColor, _talkFontColor;
54 
56  ~GraphicManager();
57  void init();
58  void loadDigits();
59  void loadMouse(byte which);
60 
61  void drawRectangle(Common::Rect rect, Color color);
62  void drawFilledRectangle(Common::Rect rect, Color color);
63  void blackOutScreen();
64  void drawDot(int x, int y, Color color);
65  void drawLine(int x1, int y1, int x2, int y2, int penX, int penY, Color color);
66  Common::Point drawScreenArc(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
67  void drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
68  void drawTriangle(Common::Point *p, Color color);
69  void drawNormalText(const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
70  void drawScrollText(const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
71  void drawDigit(int index, int x, int y);
72  void drawDirection(int index, int x, int y);
73  void drawScrollShadow(int16 x1, int16 y1, int16 x2, int16 y2);
74  void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text);
75  void drawScroll(int mx, int lx, int my, int ly);
76  void drawMenuBar(Color color);
77  void drawSpeedBar(int speed);
78  void drawBackgroundSprite(int16 x, int16 y, SpriteType &sprite);
79  void drawMenuBlock(int x1, int y1, int x2, int y2, Color color);
80  void drawMenuItem(int x1, int y1, int x2, int y2);
81  void wipeChar(int x, int y, Color color);
82  void drawChar(byte ander, int x, int y, Color color);
83  void drawDebugLines();
84 
85  // For the mini-game "Nim".
86  void nimLoad();
87  void nimDrawStone(int x, int y);
88  void nimDrawInitials();
89  void nimDrawLogo();
90  void nimFree();
91 
92  // Used in wobble()
93  void shiftScreen();
94 
95  // Used in winning()
96  void drawWinningPic();
97 
98  /*
99  * Used in quitting(), the parameter is to accept different numbers (representing different scenarios). I put it here to
100  * preserve some of the multi-purpose functionality of the original function.
101  */
102 
103  void drawQuittingPic();
104 
105  // Ghostroom's functions:
106  void ghostDrawMonster(byte ***picture, uint16 destX, int16 destY, MonsterType type);
107  Graphics::Surface ghostLoadPicture(Common::File &file, Common::Point &coord);
108  void ghostDrawPicture(const Graphics::Surface &picture, uint16 destX, uint16 destY);
109  void ghostDrawBackgroundItems(Common::File &file);
110 
111  // Help's function:
112  void helpDrawButton(int y, byte which);
113  void helpDrawHighlight(byte which, Color color);
114  void helpDrawBigText(const Common::String &text, int16 x, int16 y, Color color);
115 
116  // Shoot em' up's functions:
117  void seuDrawTitle();
118  void seuLoad();
119  void seuFree();
120  void seuDrawPicture(int x, int y, byte which);
121  void seuDrawCameo(int destX, int destY, byte w1, byte w2);
122  uint16 seuGetPicWidth(int which);
123  uint16 seuGetPicHeight(int which);
124 
125  // Main Menu's functions:
126  // The main menu uses a different screen height (350) from the game itself (200 * 2)
127  // so it needs it's own graphic functions on that matter.
128  void menuRefreshScreen();
129  void menuInitialize();
130  void menuFree();
131  void menuRestoreScreen();
132  void menuLoadPictures();
133  void menuDrawBigText(FontType font, uint16 x, uint16 y, Common::String text, Color color);
134 
135  void clearAlso();
136  void clearTextBar();
137  void setAlsoLine(int x1, int y1, int x2, int y2, Color color);
138  byte getAlsoColor(int x1, int y1, int x2, int y2);
139  byte getScreenColor(Common::Point pos);
140 
141  // Further information about this: https://moddingwiki.shikadi.net/wiki/Raw_EGA_data
142  Graphics::Surface loadPictureRaw(Common::File &file, uint16 width, uint16 height);
143 
144  void drawSprite(AnimationType *sprite, byte picnum, int16 x, int16 y);
145  void drawThinkPic(const Common::Path &filename, int id);
146  void drawToolbar();
147  void drawCursor(byte pos);
148  void drawReadyLight(Color color);
149  void drawSoundLight(bool state);
150  void drawErrorLight(bool state);
151  void drawSign(Common::String name, int16 xl, int16 yl, int16 y);
152  void drawIcon(int16 x, int16 y, byte which);
153  void drawScreenLine(int16 x, int16 y, int16 x2, int16 y2, Color color);
154  void prepareBubble(int xc, int xw, int my, Common::Point points[3]);
155  void refreshScreen();
156  void loadBackground(Common::File &file);
157  void refreshBackground();
158  void setBackgroundColor(Color newColor);
159  void setDialogColor(Color bg, Color text);
160 
161  void zoomOut(int16 x, int16 y);
162  void showScroll();
163  void getNaturalPicture(SpriteType &sprite);
164 
165  void saveScreen();
166  void restoreScreen();
167  void removeBackup();
168 
169  Graphics::Surface &getSurface() { return _surface; }
170 
171 private:
172  static const int16 kMouseSize = 134;
173  static const uint16 kBackgroundWidth = kScreenWidth;
174  static const byte kEgaPaletteIndex[16];
175  static const byte kBackgroundHeight = 8 * 12080 / kScreenWidth; // With 640 width it's 151.
176  // The 8 = number of bits in a byte, and 12080 comes from Lucerna::load().
177  static const uint16 kMenuScreenHeight = 350;
178 
179  Graphics::Surface _background;
180  Graphics::Surface _backup;
181  Graphics::Surface _digits[10]; // digitsize and rwlitesize are defined in loadDigits() !!!
182  Graphics::Surface _directions[9]; // Maybe it will be needed to move them to the class itself instead.
183  Graphics::Surface _magics; // Lucerna::draw_also_lines() draws the "magical" lines here. Further information: https://github.com/marnanel/avalot/wiki/Also
184  Graphics::Surface _screen; // Only used in refreshScreen() to make it more optimized. (No recreation of it at every call of the function.)
185  Graphics::Surface _scrolls;
186  Graphics::Surface _surface;
187  Graphics::Surface _menu;
188 
189  // For the mini-game "Nim".
190  Graphics::Surface _nimStone;
191  Graphics::Surface _nimInitials[3];
192  Graphics::Surface _nimLogo;
193 
194  // For the mini-game "Shoot em' up".
195  Graphics::Surface _seuPictures[99];
196 
197  byte _egaPalette[64][3];
198 
199  AvalancheEngine *_vm;
200 
201  void skipDifference(int size, const Graphics::Surface &picture, Common::File &file);
202 
203  // Further information about these two: https://moddingwiki.shikadi.net/wiki/Raw_EGA_data
204  Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data.
205  Graphics::Surface loadPictureSign(Common::File &file, uint16 width, uint16 height); // Reads a tricky type of picture used for the "game over"/"about" scrolls and in the mini-game Nim.
206 
207  void drawText(Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
208  void drawBigText(Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color);
209  void drawPicture(Graphics::Surface &target, const Graphics::Surface &picture, uint16 destX, uint16 destY);
210 
211  // Taken from Free Pascal's Procedure InternalEllipseDefault. Used to replace Pascal's procedure arc.
212  // Returns the end point of the arc. (Needed in Clock.)
213  Common::Point drawArc(Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color);
214 };
215 
216 } // End of namespace Avalanche
217 
218 #endif // AVALANCHE_GRAPHICS_H
Definition: str.h:59
Definition: surface.h:67
Definition: animation.h:32
Definition: graphics.h:46
Definition: animation.h:42
Definition: rect.h:524
Definition: path.h:52
Definition: avalanche.h:77
Definition: graphics.h:50
Definition: file.h:47
Definition: rect.h:144
Definition: background.h:39