22 #ifndef SCI_RESOURCE_RESOURCE_H 23 #define SCI_RESOURCE_RESOURCE_H 25 #include "common/str.h" 26 #include "common/list.h" 27 #include "common/hashmap.h" 29 #include "sci/graphics/helpers.h" 30 #include "sci/resource/decompressor.h" 33 #include "sci/version.h" 40 class SeekableReadStream;
48 kResPatVolumeNumber = 100,
59 kResStatusNoMalloc = 0,
68 SCI_ERROR_IO_ERROR = 1,
69 SCI_ERROR_EMPTY_RESOURCE = 2,
71 SCI_ERROR_RESMAP_NOT_FOUND = 4,
73 SCI_ERROR_UNKNOWN_COMPRESSION = 6,
83 kResourceTypeView = 0,
95 kResourceTypeCdAudio = 12,
97 kResourceTypeWave = 12,
101 kResourceTypeMessage,
104 kResourceTypeAudio36,
106 kResourceTypeTranslation,
112 kResourceTypeAnimation,
122 kResourceTypeMacIconBarPictN,
123 kResourceTypeMacIconBarPictS,
124 kResourceTypeMacPict,
131 const char *getResourceTypeName(ResourceType restype);
132 const char *getResourceTypeExtension(ResourceType restype);
136 kResVersionSci0Sci1Early,
137 kResVersionSci1Middle,
162 static inline ResourceType fixupType(ResourceType type) {
163 if (type >= kResourceTypeInvalid)
164 return kResourceTypeInvalid;
177 int character = number % 36;
178 string = ((character < 10) ? (character +
'0') : (character +
'A' - 10)) + string;
188 ResourceId() : _type(kResourceTypeInvalid), _number(0), _tuple(0) { }
190 ResourceId(ResourceType type_, uint16 number_, uint32 tuple_ = 0)
191 : _type(fixupType(type_)), _number(number_), _tuple(tuple_) {
194 ResourceId(ResourceType type_, uint16 number_, byte noun, byte verb, byte cond, byte seq)
195 : _type(fixupType(type_)), _number(number_) {
196 _tuple = (noun << 24) | (verb << 16) | (cond << 8) | seq;
203 retStr +=
Common::String::format(
"(%d, %d, %d, %d)", _tuple >> 24, (_tuple >> 16) & 0xff, (_tuple >> 8) & 0xff, _tuple & 0xff);
213 if (getSciVersion() >= SCI_VERSION_2) {
214 output += (getType() == kResourceTypeAudio36) ?
'A' :
'S';
216 output += (getType() == kResourceTypeAudio36) ?
'@' :
'#';
218 output += intToBase36(getNumber(), 3);
219 output += intToBase36(getTuple() >> 24, 2);
220 output += intToBase36((getTuple() >> 16) & 0xff, 2);
222 output += intToBase36((getTuple() >> 8) & 0xff, 2);
223 output += intToBase36(getTuple() & 0xff, 1);
225 assert(output.size() == 12);
229 inline ResourceType getType()
const {
return _type; }
230 inline uint16 getNumber()
const {
return _number; }
231 inline uint32 getTuple()
const {
return _tuple; }
233 inline uint hash()
const {
234 return ((uint)((_type << 16) | _number)) ^ _tuple;
237 bool operator==(
const ResourceId &other)
const {
238 return (_type == other._type) && (_number == other._number) && (_tuple == other._tuple);
241 bool operator!=(
const ResourceId &other)
const {
242 return !operator==(other);
245 bool operator<(
const ResourceId &other)
const {
246 return (_type < other._type) || ((_type == other._type) && (_number < other._number))
247 || ((_type == other._type) && (_number == other._number) && (_tuple < other._tuple));
252 uint operator()(
ResourceId val)
const {
return val.hash(); }
268 friend class ChunkResourceSource;
285 inline ResourceType getType()
const {
return _id.getType(); }
286 inline uint16 getNumber()
const {
return _id.getNumber(); }
303 uint32 getAudioCompressionType()
const;
305 uint16 getNumLockers()
const {
return _lockers; }
316 bool loadFromPatchFile();
321 int readResourceInfo(ResVersion volVersion,
Common::SeekableReadStream *file, uint32 &szPacked, ResourceCompression &compression);
341 friend class ChunkResourceSource;
360 void addAppropriateSources();
365 void addAppropriateSourcesForDetection(
const Common::FSList &fslist);
408 bool hasResourceType(ResourceType type);
410 bool setAudioLanguage(
int language);
411 void unloadAudioLanguage();
412 int getAudioLanguage()
const;
415 bool isGMTrackIncluded();
416 bool isSci11Mac()
const {
return _volVersion == kResVersionSci11Mac; }
417 ViewType getViewType()
const {
return _viewType; }
418 const char *getMapVersionDesc()
const {
return versionDescription(_mapVersion); }
419 const char *getVolVersionDesc()
const {
return versionDescription(_volVersion); }
420 ResVersion getVolVersion()
const {
return _volVersion; }
428 void addNewGMPatch(SciGameId gameId);
429 void addNewD110Patch(SciGameId gameId);
436 void addResourcesFromChunk(uint16
id);
441 void findDisc(
const int16 discNo);
446 int16 getCurrentDiscNo()
const {
return _currentDiscNo; }
452 int16 _currentDiscNo;
458 bool _multiDiscAudio;
464 bool detectFontExtended();
466 bool detectPaletteMergingSci11();
468 bool detectEarlySound();
481 reg_t findGameObject(
const bool addSci11ScriptOffset);
488 ResourceType convertResType(byte type);
501 SourcesList _sources;
544 void scanNewSources();
546 bool addAudioSources();
547 void addScriptChunkSources();
548 void freeResourceSources();
555 const char *versionDescription(ResVersion version)
const;
565 void freeOldResources();
566 bool validateResource(
const ResourceId &resourceId,
const Common::Path &sourceMapLocation,
const Common::Path &sourceName,
const uint32 offset,
const uint32 size,
const uint32 sourceSize)
const;
573 ResVersion detectMapVersion();
574 ResVersion detectVolVersion();
576 bool detectSci2Mac();
613 void readResourcePatches();
614 void readResourcePatchesBase36();
620 bool isBlacklistedPatch(
const ResourceId &resId)
const;
622 void processPatch(
ResourceSource *source, ResourceType resourceType, uint16 resourceNr, uint32 tuple = 0);
627 void readWaveAudioPatches();
634 void readAIFFAudioPatches();
645 bool hasOldScriptHeader();
650 ResourceCompression getViewCompression();
651 ViewType detectViewType();
652 bool hasSci0Voc999();
653 bool hasSci1Voc900();
654 bool checkResourceDataForSignature(
Resource *resource,
const byte *signature);
655 bool checkResourceForSignatures(ResourceType resourceType, uint16 resourceNr,
const byte *signature1,
const byte *signature2);
656 void detectSciVersion();
667 bool _hasBadResources;
699 int16 digitalChannelNr;
700 uint16 digitalSampleRate;
701 uint16 digitalSampleSize;
702 uint16 digitalSampleStart;
703 uint16 digitalSampleEnd;
709 Track *getTrackByNumber(uint16 number);
711 Track *getTrackByType(byte type);
712 Track *getDigitalTrack();
713 int getChannelFilterMask(
int hardwareMask,
bool wantsRhythm);
715 byte getInitialVoiceCount(byte channel);
717 byte getSoundPriority()
const {
return _soundPriority; }
718 bool exists()
const {
return _resource !=
nullptr; }
733 #endif // SCI_RESOURCE_RESOURCE_H ResVersion _mapVersion
resource.map version
Definition: resource.h:509
uint16 _lockers
Definition: resource.h:311
Definition: resource.h:670
byte * _header
Definition: resource.h:277
Definition: resource.h:70
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
ResourceSource * _audioMapSCI1
Currently loaded audio map for SCI1.
Definition: resource.h:507
patch type + header size
Definition: resource.h:51
int _memoryLocked
Amount of resource bytes in locked memory.
Definition: resource.h:502
SciVersion
Definition: detection.h:135
SciVersion getSciVersionForDetection()
Definition: resource.h:694
int32 _fileOffset
Definition: resource.h:309
Definition: resource_intern.h:92
Definition: serializer.h:79
Definition: resource.h:327
Definition: resource_intern.h:178
Definition: resource.h:672
Max number of simultaneously opened volumes.
Definition: resource.h:79
Definition: resource_intern.h:99
Definition: resource.h:61
Definition: resource_intern.h:197
Definition: resource_intern.h:135
Common::List< Common::File * > _volumeFiles
list of opened volume files
Definition: resource.h:506
Definition: resource.h:75
Definition: resource.h:62
Definition: resource.h:54
Definition: resource_intern.h:126
Definition: algorithm.h:29
const char * getSciVersionDesc(SciVersion version)
Definition: resource.h:256
Definition: resource_patcher.h:90
Definition: resource_intern.h:145
Definition: resource.h:161
Definition: resource_intern.h:187
ResourceErrorCodes
Definition: resource.h:66
ResVersion _volVersion
resource.0xx version
Definition: resource.h:508
int _memoryLRU
Amount of resource bytes under LRU control.
Definition: resource.h:503
Definition: resource_intern.h:48
Definition: resource.h:72
Definition: vm_types.h:39
Definition: resource.h:74
Definition: resource.h:251
Common::List< Resource * > _LRU
Last Resource Used list.
Definition: resource.h:504
ResourceStatus
Definition: resource.h:58