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