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 Hugo Trilogy source code 25 * 26 * Copyright (c) 1989-1995 David P. Gray 27 * 28 */ 29 30 #ifndef HUGO_DISPLAY_H 31 #define HUGO_DISPLAY_H 32 33 namespace Common { 34 class ReadStream; 35 class WriteStream; 36 } 37 38 namespace Hugo { 39 enum OverlayState {kOvlUndef, kOvlForeground, kOvlBackground}; // Overlay state 40 41 static const int kCenter = -1; // Used to center text in x 42 43 44 class Screen { 45 public: 46 struct Rect { // Rectangle used in Display list 47 int16 _x; // Position in dib 48 int16 _y; // Position in dib 49 int16 _dx; // width 50 int16 _dy; // height 51 }; 52 53 Screen(HugoEngine *vm); 54 virtual ~Screen(); 55 56 virtual void loadFont(int16 fontId) = 0; 57 virtual void loadFontArr(Common::ReadStream &in) = 0; 58 59 int16 fontHeight() const; 60 int16 stringLength(const char *s) const; 61 62 void displayBackground(); 63 void displayFrame(const int sx, const int sy, Seq *seq, const bool foreFl); 64 void displayList(int update, ...); 65 void displayRect(const int16 x, const int16 y, const int16 dx, const int16 dy); 66 void drawBoundaries(); 67 void drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color); 68 void drawShape(const int x, const int y, const int color1, const int color2); 69 void drawStatusText(); 70 void freeScreen(); 71 void hideCursor(); 72 void initDisplay(); 73 void initNewScreenDisplay(); 74 void loadPalette(Common::ReadStream &in); 75 void moveImage(ImagePtr srcImage, const int16 x1, const int16 y1, const int16 dx, int16 dy, const int16 width1, ImagePtr dstImage, const int16 x2, const int16 y2, const int16 width2); 76 void remapPal(uint16 oldIndex, uint16 newIndex); 77 void resetInventoryObjId(); 78 void restorePal(Common::ReadStream *f); 79 void savePal(Common::WriteStream *f) const; 80 void setBackgroundColor(const uint16 color); 81 void setCursorPal(); 82 void selectInventoryObjId(const int16 objId); 83 void shadowStr(int16 sx, const int16 sy, const char *s, const byte color); 84 void showCursor(); 85 void userHelp() const; 86 void writeStr(int16 sx, const int16 sy, const char *s, const byte color); 87 88 Icondib &getIconBuffer(); 89 Viewdib &getBackBuffer(); 90 Viewdib &getBackBufferBackup(); 91 Viewdib &getFrontBuffer(); 92 Viewdib &getGUIBuffer(); 93 94 protected: 95 HugoEngine *_vm; 96 97 static const int kRectListSize = 16; // Size of add/restore rect lists 98 static const int kBlitListSize = kRectListSize * 2; // Size of dirty rect blit list 99 static const int kShapeSize = 24; 100 static const int kFontLength = 128; // Number of chars in font 101 static const int kFontSize = 1200; // Max size of font data 102 static const int kNumFonts = 3; // Number of dib fonts 103 static const byte stdMouseCursorHeight = 20; 104 static const byte stdMouseCursorWidth = 12; 105 106 bool fontLoadedFl[kNumFonts]; 107 108 // Fonts used in dib (non-GDI) 109 byte *_arrayFont[kNumFonts]; 110 byte _fnt; // Current font number 111 byte _fontdata[kNumFonts][kFontSize]; // Font data 112 byte *_font[kNumFonts][kFontLength]; // Ptrs to each char 113 byte *_mainPalette; 114 int16 _arrayFontSize[kNumFonts]; 115 116 Viewdib _frontBuffer; 117 118 inline bool isInX(const int16 x, const Rect *rect) const; 119 inline bool isInY(const int16 y, const Rect *rect) const; 120 inline bool isOverlapping(const Rect *rectA, const Rect *rectB) const; 121 122 virtual OverlayState findOvl(Seq *seqPtr, ImagePtr dstPtr, uint16 y) = 0; 123 124 private: 125 byte *_curPalette; 126 byte _iconImage[kInvDx * kInvDy]; 127 byte _paletteSize; 128 129 Icondib _iconBuffer; // Inventory icon DIB 130 131 int16 mergeLists(Rect *list, Rect *blist, const int16 len, int16 blen); 132 int16 center(const char *s) const; 133 134 Viewdib _backBuffer; 135 Viewdib _GUIBuffer; // User interface images 136 Viewdib _backBufferBackup; // Backup _backBuffer during inventory 137 138 // Formerly static variables used by displayList() 139 int16 _dlAddIndex, _dlRestoreIndex; // Index into add/restore lists 140 Rect _dlRestoreList[kRectListSize]; // The restore list 141 Rect _dlAddList[kRectListSize]; // The add list 142 Rect _dlBlistList[kBlitListSize]; // The blit list 143 // 144 145 void createPal(); 146 void merge(const Rect *rectA, Rect *rectB); 147 void writeChr(const int sx, const int sy, const byte color, const char *local_fontdata); 148 }; 149 150 class Screen_v1d : public Screen { 151 public: 152 Screen_v1d(HugoEngine *vm); 153 ~Screen_v1d() override; 154 155 void loadFont(int16 fontId) override; 156 void loadFontArr(Common::ReadStream &in) override; 157 protected: 158 OverlayState findOvl(Seq *seqPtr, ImagePtr dstPtr, uint16 y) override; 159 }; 160 161 class Screen_v1w : public Screen { 162 public: 163 Screen_v1w(HugoEngine *vm); 164 ~Screen_v1w() override; 165 166 void loadFont(int16 fontId) override; 167 void loadFontArr(Common::ReadStream &in) override; 168 protected: 169 OverlayState findOvl(Seq *seqPtr, ImagePtr dstPtr, uint16 y) override; 170 }; 171 172 } // End of namespace Hugo 173 174 #endif //HUGO_DISPLAY_H 175