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