ScummVM API documentation
file.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 Hugo Trilogy source code
24  *
25  * Copyright (c) 1989-1995 David P. Gray
26  *
27  */
28 
29 #ifndef HUGO_FILE_H
30 #define HUGO_FILE_H
31 
32 #include "common/file.h"
33 
34 namespace Hugo {
38 enum OvlType {kOvlBoundary, kOvlOverlay, kOvlBase};
39 
40 struct UifHdr { // UIF font/image look up
41  uint16 _size; // Size of uif item
42  uint32 _offset; // Offset of item in file
43 };
44 
45 
46 class FileManager {
47 public:
49  virtual ~FileManager();
50 
51  SoundPtr getSound(const int16 sound, uint16 *size);
52 
53  void readBootFile();
54  void readImage(const int objNum, Object *objPtr);
55  void readUIFImages();
56  void readUIFItem(const int16 id, byte *buf);
57  bool restoreGame(const int16 slot);
58  bool saveGame(const int16 slot, const Common::String &descrip);
59 
60  // Name scenery and objects picture databases
61  const char *getBootFilename() const;
62  const char *getObjectFilename() const;
63  const char *getSceneryFilename() const;
64  const char *getSoundFilename() const;
65  const char *getStringFilename() const;
66  const char *getUifFilename() const;
67 
68  virtual void openDatabaseFiles() = 0;
69  virtual void closeDatabaseFiles() = 0;
70  virtual void instructions() const = 0;
71 
72  virtual void readBackground(const int screenIndex) = 0;
73  virtual void readOverlay(const int screenNum, ImagePtr image, OvlType overlayType) = 0;
74 
75  virtual const char *fetchString(const int index) = 0;
76 
77 protected:
78  HugoEngine *_vm;
79  static const int kMaxUifs = 32; // Max possible uif items in hdr
80  static const int kMaxSounds = 64; // Max number of sounds
81  static const int kRepeatMask = 0xC0; // Top 2 bits mean a repeat code
82  static const int kLengthMask = 0x3F; // Lower 6 bits are length
83  static const int kNumColors = 16; // Num colors to save in palette
84 
88  struct SceneBlock {
89  uint32 _sceneOffset;
90  uint32 _sceneLength;
91  uint32 _boundaryOffset;
92  uint32 _boundaryLength;
93  uint32 _overlayOffset;
94  uint32 _overlayLength;
95  uint32 _baseOffset;
96  uint32 _baseLength;
97  };
98 
99  struct PCCHeader { // Structure of PCX file header
100  byte _mfctr, _vers, _enc, _bpx;
101  uint16 _x1, _y1, _x2, _y2; // bounding box
102  uint16 _xres, _yres;
103  byte _palette[3 * kNumColors]; // EGA color palette
104  byte _vmode, _planes;
105  uint16 _bytesPerLine; // Bytes per line
106  byte _fill2[60];
107  }; // Header of a PCC file
108 
109  bool _firstUIFFl;
110  UifHdr _UIFHeader[kMaxUifs]; // Lookup for uif fonts/images
111 
112  Common::File _stringArchive; // Handle for string file
113  Common::File _sceneryArchive1; // Handle for scenery file
114  Common::File _objectsArchive; // Handle for objects file
115 
116  Seq *readPCX(Common::SeekableReadStream &f, Seq *seqPtr, byte *imagePtr, const bool firstFl, const char *name);
117 
118  // If this is the first call, read the lookup table
119  bool _hasReadHeader;
120  SoundHdr _soundHdr[kMaxSounds]; // Sound lookup table
121 
122 private:
123  UifHdr *getUIFHeader(const Uif id);
124 };
125 
126 class FileManager_v1d : public FileManager {
127 public:
129  ~FileManager_v1d() override;
130 
131  void closeDatabaseFiles() override;
132  void instructions() const override;
133  void openDatabaseFiles() override;
134  void readBackground(const int screenIndex) override;
135  void readOverlay(const int screenNum, ImagePtr image, OvlType overlayType) override;
136  const char *fetchString(const int index) override;
137 };
138 
140 public:
142  ~FileManager_v2d() override;
143 
144  void closeDatabaseFiles() override;
145  void openDatabaseFiles() override;
146  void readBackground(const int screenIndex) override;
147  void readOverlay(const int screenNum, ImagePtr image, OvlType overlayType) override;
148  const char *fetchString(const int index) override;
149 private:
150  char *_fetchStringBuf;
151 };
152 
154 public:
156  ~FileManager_v3d() override;
157 
158  void closeDatabaseFiles() override;
159  void openDatabaseFiles() override;
160  void readBackground(const int screenIndex) override;
161  void readOverlay(const int screenNum, ImagePtr image, OvlType overlayType) override;
162 private:
163  Common::File _sceneryArchive2; // Handle for scenery file
164 };
165 
167 public:
169  ~FileManager_v2w() override;
170 
171  void instructions() const override;
172 };
173 
175 public:
177  ~FileManager_v1w() override;
178 
179  void readOverlay(const int screenNum, ImagePtr image, OvlType overlayType) override;
180 };
181 
182 } // End of namespace Hugo
183 #endif //HUGO_FILE_H
Definition: console.h:27
byte * ImagePtr
Definition: game.h:96
Definition: file.h:40
Definition: str.h:59
Definition: file.h:166
Definition: file.h:139
Definition: stream.h:745
Definition: file.h:99
Definition: file.h:47
Definition: file.h:174
Definition: file.h:46
Definition: game.h:131
Definition: hugo.h:210
Definition: game.h:114
Definition: file.h:153
Definition: game.h:142
Definition: file.h:88
Definition: file.h:126
OvlType
Definition: file.h:38