ScummVM API documentation
amiga_archive.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 MACS2_AMIGA_ARCHIVE_H
23#define MACS2_AMIGA_ARCHIVE_H
24
25#include "common/archive.h"
26#include "common/array.h"
27#include "common/file.h"
28#include "common/hashmap.h"
29#include "common/mutex.h"
30#include "common/ptr.h"
31#include "common/str.h"
32#include "common/stream.h"
33
34namespace Macs2 {
35
40enum AmigaResourceType : uint16 {
41 kAmigaResOO = 0x4F4F, // object / graphics
42 kAmigaResMM = 0x4D4D, // scene package (MXMM: planar BG + tables; not Protracker)
43 kAmigaResOS = 0x4F53, // sound effect
44 kAmigaResFF = 0x4646, // font
45 kAmigaResUnknown = 0
46};
47
49 AmigaResourceType type = kAmigaResUnknown;
50 uint16 id = 0;
51 uint16 disk = 0;
52 uint32 offset = 0; // absolute offset of the 8-byte entry header in Data*
53};
54
56 uint16 cursorResourceIds[8] = {0}; // Talk..Disabled style slots from Info
57 uint16 useInventoryCursorId = 0;
58 uint16 sceneCount = 0;
59 uint16 volumeCount = 0;
60 uint16 mdirSize = 0;
62 uint16 uiPaletteAmiga[16] = {0};
67 uint16 panelBorderColorIndices[5] = {0};
72 uint16 panelDarkenColorIndices[8] = {0};
80 uint8 prefMenuMode = 2;
81 bool usePanelPatternFill = true;
87 bool loaded = false;
88};
89
101public:
103 ~Macs2AmigaArchive() override;
104
109 bool open();
110 void close();
111 bool isOpen() const { return !_entries.empty(); }
112
113 uint16 getSceneCount() const { return _sceneCount; }
114 uint16 getResourceCount() const { return _totalResources; }
115 const AmigaInfoData &getInfo() const { return _info; }
116
118 Common::SeekableReadStream *createReadStreamForResource(AmigaResourceType type, uint16 id) const;
119
122
123 bool hasResource(AmigaResourceType type, uint16 id) const;
124
125 // Common::Archive
126 bool hasFile(const Common::Path &path) const override;
127 int listMembers(Common::ArchiveMemberList &list) const override;
128 const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
130
131 static Common::String makeResourceName(AmigaResourceType type, uint16 id);
132 static bool parseResourceName(const Common::String &name, AmigaResourceType &type, uint16 &id);
133 static AmigaResourceType typeFromTag(uint16 tag);
134 static const char *typeToString(AmigaResourceType type);
135
140 static bool decodePlanarSprite(const byte *mxoo, uint32 mxooSize, uint16 &width, uint16 &height, Common::Array<byte> &pixels);
141
142private:
143 struct Volume {
144 Common::Path path;
146 uint32 size = 0;
147 };
148
149 struct Entry {
150 AmigaDirEntry dir;
151 uint32 payloadSize = 0; // size field from the 8-byte Data* header
152 Common::String name;
153 };
154
156
157 bool openVolume(uint16 disk);
158 bool loadMdir();
159 bool loadInfo();
161 bool loadPrefMenuMode();
162 Common::SeekableReadStream *readAndDecompressEntry(const Entry &entry) const;
163 static byte *decompressPP20(const byte *src, uint32 srcLen, uint32 &outLen);
164 static byte *decompressPayload(const byte *payload, uint32 payloadLen, uint32 &outLen);
165
166 EntryMap _entries;
167 Common::Array<Volume> _volumes;
168 mutable Common::Mutex _mutex;
169
170 uint16 _sceneCount = 0;
171 uint16 _totalResources = 0;
172 uint32 _firstBlockSize = 0;
173 uint32 _firstBlockOffset = 14;
174 AmigaInfoData _info;
175};
176
177} // End of namespace Macs2
178
179#endif // MACS2_AMIGA_ARCHIVE_H
Definition: archive.h:141
bool empty() const
Definition: hashmap.h:303
Definition: list.h:44
Definition: mutex.h:67
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: amiga_archive.h:100
Common::SeekableReadStream * createSceneTableStream() const
bool hasFile(const Common::Path &path) const override
static bool decodePlanarSprite(const byte *mxoo, uint32 mxooSize, uint16 &width, uint16 &height, Common::Array< byte > &pixels)
int listMembers(Common::ArchiveMemberList &list) const override
Common::SeekableReadStream * createReadStreamForResource(AmigaResourceType type, uint16 id) const
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override
Common::SeekableReadStream * createReadStreamForMember(const Common::Path &path) const override
Definition: amiga_archive.h:48
Definition: amiga_archive.h:55
uint8 prefMenuMode
Definition: amiga_archive.h:80
uint16 panelDarkenColorIndices[8]
Definition: amiga_archive.h:72
uint16 startSceneResourceId
Definition: amiga_archive.h:86
uint16 uiPaletteAmiga[16]
Definition: amiga_archive.h:62
uint16 panelBorderColorIndices[5]
Definition: amiga_archive.h:67