ScummVM API documentation
vga13h.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 original Soltys source code
24  * Copyright (c) 1994-1995 Janusz B. Wisniewski and L.K. Avalon
25  */
26 
27 #ifndef CGE_VGA13H_H
28 #define CGE_VGA13H_H
29 
30 #include "common/serializer.h"
31 #include "common/events.h"
32 #include "graphics/surface.h"
33 #include "cge/general.h"
34 #include "cge/bitmap.h"
35 #include "cge/snail.h"
36 #include "cge/cge.h"
37 
38 namespace CGE {
39 
40 #define kFadeStep 2
41 #define kVgaColDark 207
42 #define kVgaColDarkGray 225 /*219*/
43 #define kVgaColGray 231
44 #define kVgaColLightGray 237
45 #define kPixelTransp 0xFE
46 #define kNoSeq (-1)
47 #define kNoPtr ((uint8)-1)
48 #define kSprExt ".SPR"
49 #define kPalCount 256
50 #define kPalSize (kPalCount * 3)
51 
52 
53 struct Seq {
54  uint8 _now;
55  uint8 _next;
56  int8 _dx;
57  int8 _dy;
58  int _dly;
59 };
60 
61 class SprExt {
62 public:
63  int _x0;
64  int _y0;
65  int _x1;
66  int _y1;
67  BitmapPtr _b0;
68  BitmapPtr _b1;
69  BitmapPtr *_shpList;
70  Seq *_seq;
71  char *_name;
74  SprExt() :
75  _x0(0), _y0(0),
76  _x1(0), _y1(0),
77  _b0(NULL), _b1(NULL),
78  _shpList(NULL), _seq(NULL),
79  _name(NULL), _near(NULL), _take(NULL)
80  {}
81 };
82 
83 class Sprite {
84 protected:
85  SprExt *_ext;
86 public:
87  int _ref;
88  signed char _scene;
89  struct Flags {
90  bool _hide; // general visibility switch
91  bool _near; // Near action lock
92  bool _drag; // sprite is moveable
93  bool _hold; // sprite is held with mouse
94  bool _dummy; // interrupt driven animation
95  bool _slav; // slave object
96  bool _syst; // system object
97  bool _kill; // dispose memory after remove
98  bool _xlat; // 2nd way display: xlat table
99  bool _port; // portable
100  bool _kept; // kept in pocket
101  bool _east; // talk to east (in opposite to west)
102  bool _shad; // shadow
103  bool _back; // 'send to background' request
104  bool _bDel; // delete bitmaps in ~SPRITE
105  bool _tran; // transparent (untouchable)
106  } _flags;
107  int _x;
108  int _y;
109  signed char _z;
110  uint16 _w;
111  uint16 _h;
112  uint16 _time;
113  uint8 _nearPtr;
114  uint8 _takePtr;
115  int _seqPtr;
116  int _shpCnt;
117  char _file[kMaxFile];
118  Sprite *_prev;
119  Sprite *_next;
120 
121  bool works(Sprite *spr);
122  bool seqTest(int n);
123  inline bool active() {
124  return _ext != NULL;
125  }
126 
127  Sprite(CGEEngine *vm, BitmapPtr *shp);
128  virtual ~Sprite();
129  BitmapPtr shp();
130  BitmapPtr *setShapeList(BitmapPtr *shp);
131  Sprite *expand();
132  Sprite *contract();
133  Sprite *backShow(bool fast = false);
134  void setName(char *newName);
135  inline char *name() {
136  return (_ext) ? _ext->_name : NULL;
137  }
138  void gotoxy(int x, int y);
139  void center();
140  void show();
141  void hide();
142  BitmapPtr ghost();
143  void show(uint16 pg);
144  void makeXlat(uint8 *x);
145  void killXlat();
146  void step(int nr = -1);
147  Seq *setSeq(Seq *seq);
148  CommandHandler::Command *snList(SnList type);
149  virtual void touch(uint16 mask, int x, int y);
150  virtual void tick();
151  void sync(Common::Serializer &s);
152 private:
153  CGEEngine *_vm;
154 };
155 
156 class Queue {
157  Sprite *_head;
158  Sprite *_tail;
159 public:
160  Queue(bool show);
161  ~Queue();
162 
163  bool _show;
164 
165  void append(Sprite *spr);
166  void insert(Sprite *spr, Sprite *nxt);
167  void insert(Sprite *spr);
168  Sprite *remove(Sprite *spr);
169  Sprite *first() {
170  return _head;
171  }
172  Sprite *last() {
173  return _tail;
174  }
175  Sprite *locate(int ref);
176  void clear();
177 };
178 
179 class Vga {
180  CGEEngine *_vm;
181  bool _setPal;
182  Dac *_oldColors;
183  Dac *_newColors;
184  const char *_msg;
185  const char *_name;
186 
187  void updateColors();
188  void setColors();
189  void waitVR();
190  uint8 closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
191 
192 public:
193  uint32 _frmCnt;
194  Queue *_showQ;
195  Queue *_spareQ;
196  int _mono;
197  Graphics::Surface *_page[4];
198  Dac *_sysPal;
199 
200  Vga(CGEEngine *vm);
201  ~Vga();
202 
203  uint8 *glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
204  void getColors(Dac *tab);
205  void setColors(Dac *tab, int lum);
206  void clear(uint8 color);
207  void copyPage(uint16 d, uint16 s);
208  void sunrise(Dac *tab);
209  void sunset();
210  void show();
211  void update();
212 
213  void palToDac(const byte *palData, Dac *tab);
214  void dacToPal(const Dac *tab, byte *palData);
215 };
216 
217 class HorizLine: public Sprite {
218  CGEEngine *_vm;
219 public:
220  HorizLine(CGEEngine *vm);
221 };
222 
223 class SceneLight: public Sprite {
224  CGEEngine *_vm;
225 public:
226  SceneLight(CGEEngine *vm);
227 };
228 
229 class Speaker: public Sprite {
230  CGEEngine *_vm;
231 public:
232  Speaker(CGEEngine *vm);
233 };
234 
235 class PocLight: public Sprite {
236  CGEEngine *_vm;
237 public:
238  PocLight(CGEEngine *vm);
239 };
240 
241 } // End of namespace CGE
242 
243 #endif
Definition: surface.h:67
Definition: snail.h:55
Definition: vga13h.h:217
Definition: vga13h.h:156
Definition: cge.h:150
Definition: serializer.h:79
Definition: vga13h.h:53
Definition: bitmap.h:55
Definition: vga13h.h:83
Definition: vga13h.h:235
Definition: vga13h.h:229
Definition: vga13h.h:61
Definition: bitmap.h:33
Definition: vga13h.h:223
Definition: vga13h.h:89
Definition: general.h:34
Definition: vga13h.h:179