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 #ifndef TWINE_RESOURCES_HQR_H
24 #define TWINE_RESOURCES_HQR_H
25
26 #include "common/scummsys.h"
27 #include "common/stream.h"
28 #include "twine/shared.h"
29
30 namespace TwinE {
31
32 class TwinEEngine;
33
34 /**
35 * High Quality Resource
36 *
37 * http://lbafileinfo.kazekr.net/index.php?title=High_quality_resource
38 */
39 namespace HQR {
40
41
42 /**
43 * Get a HQR entry pointer
44 * @param ptr pointer to save the entry
45 * @param filename HQR file name
46 * @param index entry index to extract
47 * @return entry real size
48 */
49 int32 getEntry(uint8 *ptr, const char *filename, int32 index);
getEntry(uint8 * ptr,const TwineResource & resource)50 inline int32 getEntry(uint8 *ptr, const TwineResource &resource) {
51 return getEntry(ptr, resource.hqr, resource.index);
52 }
53
54 /**
55 * Get a HQR entry pointer
56 * @param filename HQR file name
57 * @param index entry index to extract
58 * @return entry real size
59 */
60 int32 entrySize(const char *filename, int32 index);
entrySize(const TwineResource & resource)61 inline int32 entrySize(const TwineResource &resource) {
62 return entrySize(resource.hqr, resource.index);
63 }
64
65 /**
66 * Get a HQR total number of entries
67 * @param filename HQR file name
68 * @return total number of entries
69 */
70 int32 numEntries(const char *filename);
71
72 /**
73 * Get a HQR entry pointer with memory allocation
74 * @param ptr pointer to save the entry. This pointer is automatically freed and therefore must be initialized
75 * to @c nullptr on the first run.
76 * @param filename HQR file name
77 * @param index entry index to extract
78 * @return entry real size
79 */
80 int32 getAllocEntry(uint8 **ptr, const char *filename, int32 index);
getAllocEntry(uint8 ** ptr,const TwineResource & resource)81 inline int32 getAllocEntry(uint8 **ptr, const TwineResource &resource) {
82 return getAllocEntry(ptr, resource.hqr, resource.index);
83 }
84
85 /**
86 * @brief Helper method to dump the content of the given hqr index to a file
87 */
88 bool dumpEntry(const char *filename, int32 index, const char *targetFileName);
dumpEntry(const TwineResource & resource,const char * targetFileName)89 inline bool dumpEntry(const TwineResource &resource, const char *targetFileName) {
90 return dumpEntry(resource.hqr, resource.index, targetFileName);
91 }
92
93 /**
94 * Get a HQR entry pointer
95 * @param ptr pointer to save the entry
96 * @param filename HQR file name
97 * @param index entry index to extract
98 * @return entry real size
99 */
100 int32 getVoxEntry(uint8 *ptr, const char *filename, int32 index, int32 hiddenIndex);
101 /**
102 * Get a HQR entry pointer with memory allocation
103 * @param ptr pointer to save the entry. This pointer is automatically freed and therefore must be initialized
104 * to @c nullptr on the first run.
105 * @param filename HQR file name
106 * @param index entry index to extract
107 * @return entry real size
108 */
109 int32 getAllocVoxEntry(uint8 **ptr, const char *filename, int32 index, int32 hiddenIndex);
110
111 Common::SeekableReadStream *makeReadStream(const char *filename, int index);
makeReadStream(const TwineResource & resource)112 inline Common::SeekableReadStream *makeReadStream(const TwineResource &resource) {
113 return makeReadStream(resource.hqr, resource.index);
114 }
115 } // namespace HQR
116
117 } // namespace TwinE
118
119 #endif
120