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 
32 class OSystem;
33 
34 namespace Common {
35 struct Rect;
36 }
37 
38 namespace Sky {
39 
40 class Disk;
41 class SkyEngine;
42 class SkyCompact;
43 struct Compact;
44 struct DataFileHeader;
45 struct 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 
57 typedef struct {
58  uint16 yCood;
59  Compact *compact;
60  DataFileHeader *sprite;
61 } StSortList;
62 
63 enum 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 
78 extern const int invIconId[];
79 
80 class Screen {
81 public:
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 renderControlPanel(uint8 *buffer);
123  void update32BitScreen(uint8 *overrideBuffer);
124  Icon _uiIcon[NUM_UI_ICONS];
125  Icon _proximityIcon[NUM_PROXIMITY_ICONS];
126  Icon _invIcon[NUM_INV_ICONS];
127  Icon _dragIcon;
128 
129  void setIcon(int idx, int x, int y);
130  void drawIbassIcon();
131  void drawIbassInventory();
132  void initIbassIcon(int idx, const char *filename);
133  void clearIbassIcon(int idx, bool fade);
134  void clearAllIbassIcons(bool fade);
135 
136  bool isUIOpen();
137 
138  void addInvIcon(int frame, int x, int y, bool highlighted = false);
139  void showInventory(int x1, int y1, int x2, int y2);
140  void hideInventory(void);
141  void clearAllInvIcons();
142  int getInventoryAnimIdx(int frame);
143 
144  void setProximityIcon(int idx, int x, int y, float alpha, int frame);
145  void clearAllProximityIcons(bool fade = true);
146  void clearProximityIcon(int idx, bool fade = true);
147  void setProximityNotAnimate(int idx);
148 
149  void setDragIcon(int frame, bool highlighted = false);
150  void clearDragIcon();
151  void setDragIconHighlight(bool highlighted);
152 
153 protected:
154 
155  int _invX1;
156  int _invY1;
157  int _invX2;
158  int _invY2;
159  bool _invVisible;
160  int _invIconsInUse;
161 
162  Animation *_invAnim[NUM_INV_ANIMS];
163 
164 
165 private:
166  OSystem *_system;
167  Disk *_skyDisk;
168  SkyCompact *_skyCompact;
169  static uint8 _top16Colors[16 * 3];
170  uint8 _palette[VGA_COLORS * 3];
171  uint32 _currentPalette;
172  uint8 _seqGrid[20 * 12];
173 
174  void waitForTick();
175 
176  uint8 *_gameGrid;
177  uint8 *_currentScreen;
178  uint8 *_scrollScreen;
179  struct {
180  uint32 nextFrame;
181  uint32 framesLeft;
182  uint8 *seqData;
183  uint8 *seqDataPos;
184  volatile bool running;
185  bool runningItem; // when playing an item, don't free it afterwards.
186  } _seqInfo;
187 
188  //- more regular screen.asm + layer.asm routines
189  void convertPalette(uint8 *inPal, uint8* outPal);
190  void palette_fadedown_helper(uint8 *pal, uint num);
191 
192  //- sprite.asm routines
193  // fixme: get rid of these globals
194  uint32 _sprWidth, _sprHeight, _sprX, _sprY, _maskX1, _maskX2;
195  void doSprites(uint8 layer);
196  void sortSprites();
197  void drawSprite(uint8 *spriteData, Compact *sprCompact);
198  void verticalMask();
199  void vertMaskSub(uint16 *grid, uint32 gridOfs, uint8 *screenPtr, uint32 layerId);
200  void vectorToGame(uint8 gridVal);
201 };
202 
203 } // End of namespace Sky
204 
205 #endif //SKYSCREEN_H
Definition: surface.h:67
Definition: struc.h:112
Definition: struc.h:53
Definition: screen.h:57
Definition: rect.h:536
Definition: disk.h:59
Definition: struc.h:35
Definition: disk.h:52
Definition: icon.h:25
Definition: algorithm.h:29
Definition: screen.h:80
Definition: system.h:166
Definition: compact.h:58
Definition: autoroute.h:28