ScummVM API documentation
resource.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 AWE_RESOURCE_H
23 #define AWE_RESOURCE_H
24 
25 #include "awe/detection.h"
26 #include "awe/intern.h"
27 
28 namespace Awe {
29 
30 struct MemEntry {
31  uint8 status = 0; // 0x0
32  uint8 type = 0; // 0x1, Resource::ResType
33  uint8 *bufPtr = nullptr; // 0x2
34  uint8 rankNum = 0; // 0x6
35  uint8 bankNum = 0; // 0x7
36  uint32 bankPos = 0; // 0x8
37  uint32 packedSize = 0; // 0xC
38  uint32 unpackedSize = 0; // 0x12
39 
40  void load(Common::SeekableReadStream *src);
41 };
42 
43 struct AmigaMemEntry {
44  uint8 type;
45  uint8 bank;
46  uint32 offset;
47  uint32 packedSize;
48  uint32 unpackedSize;
49 };
50 
51 struct DemoJoy {
52  uint8 keymask = 0;
53  uint8 counter = 0;
54 
55  uint8 *bufPtr = nullptr;
56  int bufPos = 0, bufSize = 0;
57 
58  bool start() {
59  if (bufSize > 0) {
60  keymask = bufPtr[0];
61  counter = bufPtr[1];
62  bufPos = 2;
63  return true;
64  }
65  return false;
66  }
67 
68  uint8 update() {
69  if (bufPos >= 0 && bufPos < bufSize) {
70  if (counter == 0) {
71  keymask = bufPtr[bufPos++];
72  counter = bufPtr[bufPos++];
73  } else {
74  --counter;
75  }
76  return keymask;
77  }
78  return 0;
79  }
80 };
81 
82 struct ResourceNth;
83 struct ResourceWin31;
84 struct Resource3do;
85 struct Video;
86 
87 typedef void (*PreloadSoundProc)(void *userdata, int num, const uint8 *data);
88 
89 struct Resource {
90  enum ResType {
91  RT_SOUND = 0,
92  RT_MUSIC = 1,
93  RT_BITMAP = 2, // full screen 4bpp video buffer, size=200*320/2
94  RT_PALETTE = 3, // palette (1024=vga + 1024=ega), size=2048
95  RT_BYTECODE = 4,
96  RT_SHAPE = 5,
97  RT_BANK = 6, // common part shapes (bank2.mat)
98  };
99 
100  enum {
101  MEM_BLOCK_SIZE = 1 * 1024 * 1024,
102  ENTRIES_COUNT = 146,
103  ENTRIES_COUNT_20TH = 178,
104  };
105 
106  enum {
107  STATUS_NULL,
108  STATUS_LOADED,
109  STATUS_TOLOAD,
110  };
111 
112  static const AmigaMemEntry MEMLIST_AMIGA_FR[ENTRIES_COUNT];
113  static const AmigaMemEntry MEMLIST_AMIGA_EN[ENTRIES_COUNT];
114  static const AmigaMemEntry MEMLIST_ATARI_EN[ENTRIES_COUNT];
115  static const uint8 MEMLIST_PARTS[][4];
116  static const AmigaMemEntry *detectAmigaAtari();
117 
118  Video *_vid;
119  DataType _dataType;
120  MemEntry _memList[ENTRIES_COUNT_20TH];
121  uint16 _numMemList = 0;
122  uint16 _currentPart = 0, _nextPart = 0;
123  uint8 *_memPtrStart = nullptr,
124  *_scriptBakPtr = nullptr,
125  *_scriptCurPtr = nullptr,
126  *_vidCurPtr = nullptr;
127  bool _useSegVideo2 = false;
128  uint8 *_segVideoPal = nullptr;
129  uint8 *_segCode = nullptr;
130  uint8 *_segVideo1 = nullptr;
131  uint8 *_segVideo2 = nullptr;
132  const char *_bankPrefix = "bank";
133  bool _hasPasswordScreen = true;
134  ResourceNth *_nth = nullptr;
135  ResourceWin31 *_win31 = nullptr;
136  Resource3do *_3do = nullptr;
137  Language _lang = Language::EN_ANY;
138  const AmigaMemEntry *_amigaMemList;
139  DemoJoy _demo3Joy;
140  bool _copyProtection = false;
141 
142  Resource(Video *vid, DataType dataType);
143  ~Resource();
144 
145  DataType getDataType() const {
146  return _dataType;
147  }
148  const char *getGameTitle(Language lang) const;
149  bool readBank(const MemEntry *me, uint8 *dstBuf);
150  void readEntries();
151  void readEntriesAmiga(const AmigaMemEntry *entries, int count);
152  void dumpEntries();
153  void load();
154  void invalidateAll();
155  void invalidateRes();
156  void update(uint16 num, PreloadSoundProc, void *);
157  void loadBmp(int num);
158  uint8 *loadDat(int num);
159  void loadFont();
160  void loadHeads();
161  uint8 *loadWav(int num, uint32 *size = nullptr);
162  const char *getString(int num);
163  const char *getMusicPath(int num, char *buf, int bufSize, uint32 *offset = nullptr);
164  void setupPart(int part);
165  void allocMemBlock();
166  void freeMemBlock();
167  void readDemo3Joy();
168 };
169 
170 } // namespace Awe
171 
172 #endif
Definition: resource_3do.h:29
Definition: resource.h:30
Definition: stream.h:745
Definition: resource_win31.h:39
Definition: resource.h:89
Definition: aifc_player.h:29
Definition: resource.h:43
Definition: resource_nth.h:29
Definition: avi_frames.h:36
Definition: resource.h:51
Language
Definition: language.h:45