ScummVM API documentation
screen.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 SKY_SCREEN_H
23#define SKY_SCREEN_H
24
25
26#include "common/scummsys.h"
27#include "sky/skydefs.h"
28#include "sky/struc.h"
29
30#include "graphics/surface.h"
31
32class OSystem;
33
34namespace Common {
35struct Rect;
36}
37
38namespace Sky {
39
40class Disk;
41class SkyEngine;
42class SkyCompact;
43struct Compact;
44struct DataFileHeader;
45struct Icon;
46
47#define SCROLL_JUMP 16
48#define VGA_COLORS 256
49#define GAME_COLORS 240
50
51#define FORE 1
52#define BACK 0
53#define NUM_INV_ANIMS 44 // unique textures
54#define NUM_INV_ICONS 20 // (max) number of on-screen items
55#define NUM_PROXIMITY_ICONS 16 // (max) number of proximity icons
56
57typedef struct {
58 uint16 yCood;
59 Compact *compact;
60 DataFileHeader *sprite;
62
63enum UIIcon : uint8{
64 UI_ICON_INV = 0,
65 UI_ICON_LOOK,
66 UI_ICON_USE,
67 UI_ICON_HAND,
68 UI_ICON_MOUTH,
69 UI_ICON_HELP,
70 UI_ICON_OPTIONS,
71 UI_ICON_UP,
72 UI_ICON_DOWN,
73 UI_ICON_LEFT,
74 UI_ICON_RIGHT,
75 NUM_UI_ICONS
76};
77
78extern const int invIconId[];
79
80class Screen {
81public:
82 Screen(OSystem *pSystem, Disk *pDisk, SkyCompact *skyCompact);
83 ~Screen();
84 void setPalette(uint8 *pal);
85 void setPaletteEndian(uint8 *pal);
86 void setPalette(uint16 fileNum);
87 void paletteFadeUp(uint8 *pal);
88 void paletteFadeUp(uint16 fileNr);
89
90 void showScreen(uint16 fileNum, bool fullscreen = false);
91 void showScreen(uint8 *pScreen, bool fullscreen = false);
92
93 void handleTimer();
94 void startSequence(uint16 fileNum);
95 void startSequenceItem(uint16 itemNum);
96 void stopSequence();
97 bool sequenceRunning() { return _seqInfo.running; }
98 void processSequence();
99 void waitForSequence();
100 uint32 seqFramesLeft() { return _seqInfo.framesLeft; }
101 uint8 *giveCurrent() { return _currentScreen; }
102 void halvePalette();
103
104 //- regular screen.asm routines
105 void forceRefresh() { memset(_gameGrid, 0x80, GRID_X * GRID_Y); }
106 void fnFadeUp(uint32 palNum, uint32 scroll);
107 void fnFadeDown(uint32 scroll);
108 void fnDrawScreen(uint32 palette, uint32 scroll);
109 void clearScreen(bool fullscreen = false);
110 void setFocusRectangle(const Common::Rect& rect);
111
112 void recreate();
113 void flip(bool doUpdate = true);
114
115 void spriteEngine();
116
117 void paintBox(uint16 x, uint16 y);
118 void showGrid(uint8 *gridBuf);
119 Graphics::Surface _screen32;
120 Graphics::Surface _iconSurface;
121 void renderFinalFrame();
122 void renderRect(const uint8 *buffer, uint16 x, uint16 y, uint16 width, uint16 height);
123 void renderControlPanel(uint8 *buffer);
124 void update32BitScreen(uint8 *overrideBuffer, uint16 x, uint16 y, uint16 width, uint16 height);
125 Icon _uiIcon[NUM_UI_ICONS];
126 Icon _proximityIcon[NUM_PROXIMITY_ICONS];
127 Icon _invIcon[NUM_INV_ICONS];
128 Icon _dragIcon;
129
130 void setIcon(int idx, int x, int y);
131 void drawIbassIcon();
132 void drawIbassInventory();
133 void initIbassIcon(int idx, const char *filename);
134 void clearIbassIcon(int idx, bool fade);
135 void clearAllIbassIcons(bool fade);
136
137 bool isUIOpen();
138
139 void addInvIcon(int frame, int x, int y, bool highlighted = false);
140 void showInventory(int x1, int y1, int x2, int y2);
141 void hideInventory(void);
142 void clearAllInvIcons();
143 int getInventoryAnimIdx(int frame);
144
145 void setProximityIcon(int idx, int x, int y, float alpha, int frame);
146 void clearAllProximityIcons(bool fade = true);
147 void clearProximityIcon(int idx, bool fade = true);
148 void setProximityNotAnimate(int idx);
149
150 void setDragIcon(int frame, bool highlighted = false);
151 void clearDragIcon();
152 void setDragIconHighlight(bool highlighted);
153
154protected:
155
156 int _invX1;
157 int _invY1;
158 int _invX2;
159 int _invY2;
160 bool _invVisible;
161 int _invIconsInUse;
162
163 Animation *_invAnim[NUM_INV_ANIMS];
164
165
166private:
167 OSystem *_system;
168 Disk *_skyDisk;
169 SkyCompact *_skyCompact;
170 static uint8 _top16Colors[16 * 3];
171 uint8 _palette[VGA_COLORS * 3];
172 uint32 _currentPalette;
173 bool _paletteDirty;
174 uint8 _seqGrid[20 * 12];
175
176 void waitForTick();
177
178 uint8 *_gameGrid;
179 uint8 *_currentScreen;
180 uint8 *_scrollScreen;
181 struct {
182 uint32 nextFrame;
183 uint32 framesLeft;
184 uint8 *seqData;
185 uint8 *seqDataPos;
186 volatile bool running;
187 bool runningItem; // when playing an item, don't free it afterwards.
188 } _seqInfo;
189
190 //- more regular screen.asm + layer.asm routines
191 void convertPalette(uint8 *inPal, uint8* outPal);
192 void palette_fadedown_helper(uint8 *pal, uint num);
193
194 //- sprite.asm routines
195 // fixme: get rid of these globals
196 uint32 _sprWidth, _sprHeight, _sprX, _sprY, _maskX1, _maskX2;
197 void doSprites(uint8 layer);
198 void sortSprites();
199 void drawSprite(uint8 *spriteData, Compact *sprCompact);
200 void verticalMask();
201 void vertMaskSub(uint16 *grid, uint32 gridOfs, uint8 *screenPtr, uint32 layerId);
202 void vectorToGame(uint8 gridVal);
203};
204
205} // End of namespace Sky
206
207#endif //SKYSCREEN_H
Definition: icon.h:26
Definition: system.h:166
Definition: disk.h:59
Definition: screen.h:80
Definition: compact.h:58
Definition: algorithm.h:29
Definition: autoroute.h:28
Definition: rect.h:536
Definition: surface.h:67
Definition: disk.h:52
Definition: struc.h:112
Definition: struc.h:35
Definition: struc.h:53
Definition: screen.h:57