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 #ifndef HOPKINS_GRAPHICS_H
23 #define HOPKINS_GRAPHICS_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/endian.h"
28 #include "common/path.h"
29 #include "common/rect.h"
30 #include "graphics/surface.h"
31 
32 namespace Hopkins {
33 
34 #define DIRTY_RECTS_SIZE 250
35 #define PALETTE_SIZE 256
36 #define PALETTE_BLOCK_SIZE (PALETTE_SIZE * 3)
37 #define PALETTE_EXT_BLOCK_SIZE 800
38 static const byte kSetOffset = 251;
39 static const byte kByteStop = 252;
40 static const byte k8bVal = 253;
41 static const byte k16bVal = 254;
42 
43 struct RGB8 {
44  byte r;
45  byte g;
46  byte b;
47 };
48 
49 class HopkinsEngine;
50 
52 private:
53  HopkinsEngine *_vm;
54 
55  int _lockCounter;
56  bool _initGraphicsFl;
57  int _screenWidth;
58  int _screenHeight;
59  byte *_videoPtr;
60  int _width;
61  int _posXClipped, _posYClipped;
62  bool _clipFl;
63  int _specialWidth;
64 
65  int _enlargedX, _enlargedY;
66  bool _enlargedXFl, _enlargedYFl;
67  int _clipX1, _clipY1;
68  int _reduceX, _reducedY;
69  int _zoomOutFactor;
70 
71  bool _manualScroll;
72 
73  void loadScreen(const Common::Path &file);
74  void loadPCX640(byte *surface, const Common::Path &file, byte *palette, bool typeFlag);
75  void loadPCX320(byte *surface, const Common::Path &file, byte *palette);
76  void fadeIn(const byte *palette, int step, const byte *surface);
77  void fadeOut(const byte *palette, int step, const byte *surface);
78  void changePalette(const byte *palette);
79  uint16 mapRGB(byte r, byte g, byte b);
80  void copy16bFromSurfaceScaleX2(const byte *surface);
81 
82  void translateSurface(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold);
83  void displayScaled8BitRect(const byte *surface, int xp, int yp, int width, int height, int destX, int destY);
84 
85  void lockScreen();
86  void unlockScreen();
87 public:
88  byte _paletteBuffer[PALETTE_SIZE * 2];
89  byte _colorTable[PALETTE_EXT_BLOCK_SIZE];
90  byte _palette[PALETTE_EXT_BLOCK_SIZE];
91  byte _oldPalette[PALETTE_EXT_BLOCK_SIZE];
92  byte *_backBuffer;
93  byte *_frontBuffer;
94  byte *_screenBuffer;
95  byte *_backupScreen;
96  bool _largeScreenFl;
97  bool _noFadingFl;
98  bool _fadingFl;
99  bool _skipVideoLockFl;
100  int _scrollOffset;
101  int _scrollPosX;
102  int _oldScrollPosX;
103  int _scrollSpeed;
104  int _lineNbr;
105  int _lineNbr2;
106  int _minX, _minY;
107  int _maxX, _maxY;
108  int _scrollStatus;
109  int _fadeDefaultSpeed;
110  int _screenLineSize;
111 
118  Common::Array<Common::Rect> _refreshRects;
119  bool _showDirtyRects;
120  bool _showZones;
121  bool _showLines;
122 
123  byte *_palettePixels;
124 public:
126  ~GraphicsManager();
127 
128  void clearPalette();
129  void clearScreen();
130  void clearVesaScreen();
131  void resetDirtyRects();
132  void resetRefreshRects();
133  void addDirtyRect(int x1, int y1, int x2, int y2);
134  void addDirtyRect(const Common::Rect &r) { addDirtyRect(r.left, r.top, r.right, r.bottom); }
135  void addRefreshRect(int x1, int y1, int x2, int y2);
136  void addRectToArray(Common::Array<Common::Rect> &rects, const Common::Rect &newRect);
137  void displayDirtyRects();
138  void displayRefreshRects();
139  void displayZones();
140  void displayLines();
141  void displayDebugRect(Graphics::Surface *surface, const Common::Rect &srcRect, uint32 color = 0xffffff);
142  void copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY);
143  void loadImage(const Common::Path &file);
144  void loadVgaImage(const Common::Path &file);
145  void fadeInLong();
146  void fadeInBreakout();
147  void fadeInDefaultLength(const byte *surface);
148  void fadeInShort();
149  void fadeOutDefaultLength(const byte *surface);
150  void fadeOutBreakout();
151  void fadeOutLong();
152  void fadeOutShort();
153  void copyWinscanVbe3(const byte *srcData, byte *destSurface);
154  void copyWinscanVbe(const byte *srcP, byte *destP);
155  void copyVideoVbe16(const byte *srcData);
156  void copyVideoVbe16a(const byte *srcData);
157  void copySurfaceRect(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height);
158  void restoreSurfaceRect(byte *destSurface, const byte *src, int xp, int yp, int width, int height);
159  void displayFont(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int color);
160  void drawHorizontalLine(byte *surface, int xp, int yp, uint16 width, byte col);
161  void drawVerticalLine(byte *surface, int xp, int yp, int height, byte col);
162  void initColorTable(int minIndex, int maxIndex, byte *palette);
163  void setGraphicalMode(int width, int height);
164  void setPaletteVGA256(const byte *palette);
165  void setPaletteVGA256WithRefresh(const byte *palette, const byte *surface);
166  void scrollScreen(int amount);
167  int zoomIn(int v, int percentage);
168  int zoomOut(int v, int percentage);
169  void initScreen(const Common::Path &file, int mode, bool initializeScreen);
170  void displayAllBob();
171  void endDisplayBob();
172  void updateScreen();
173  void reduceScreenPart(const byte *srcSruface, byte *destSurface, int xp, int yp, int width, int height, int zoom);
174  void setScreenWidth(int pitch);
175 
176  void setColorPercentage(int palIndex, int r, int g, int b);
177  void setColorPercentage2(int palIndex, int r, int g, int b);
178  void fastDisplay(const byte *spriteData, int xp, int yp, int spriteIndex, bool addSegment = true);
179  void fastDisplay2(const byte *objectData, int xp, int yp, int idx, bool addSegment = true);
180  void drawCompressedSprite(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int zoom1, int zoom2, bool flipFl);
181  void copyRect(const byte *srcSurface, int x1, int y1, uint16 width, int height, byte *destSurface, int destX, int destY);
182  void drawVesaSprite(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex);
183  void display8BitRect(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
184  void fillSurface(byte *surface, byte *col, int size);
185  void displayScreen(bool initPalette);
186  void backupScreen();
187  void restoreScreen();
188 };
189 
190 } // End of namespace Hopkins
191 
192 #endif /* HOPKINS_GRAPHICS_H */
Definition: surface.h:67
int16 right
Definition: rect.h:146
Definition: rect.h:144
Definition: path.h:52
Definition: graphics.h:43
Definition: anim.h:30
Definition: graphics.h:51
int16 left
Definition: rect.h:145
Common::Array< Common::Rect > _dirtyRects
Definition: graphics.h:117
Definition: hopkins.h:86