25 #include "common/scummsys.h" 26 #include "common/system.h" 27 #include "common/error.h" 28 #include "common/fs.h" 29 #include "common/hash-str.h" 30 #include "common/random.h" 31 #include "common/serializer.h" 32 #include "common/util.h" 33 #include "engines/engine.h" 34 #include "engines/savestate.h" 35 #include "graphics/screen.h" 37 #include "bolt/detection.h" 38 #include "bolt/xplib/xplib.h" 42 #define SCREEN_WIDTH 320 43 #define SCREEN_HEIGHT 200 44 #define EXTENDED_SCREEN_WIDTH 384 45 #define EXTENDED_SCREEN_HEIGHT 240 47 struct BoltGameDescription;
59 uint32 groupDirOffset;
62 memset(header, 0,
sizeof(header));
68 typedef void (*BOLTCallback)(void);
71 BOLTCallback *typeLoadCallbacks;
72 BOLTCallback *typeFreeCallbacks;
73 BOLTCallback *memberLoadCallbacks;
74 BOLTCallback *memberFreeCallbacks;
75 BOLTCallback *groupLoadCallbacks;
76 BOLTCallback *groupFreeCallbacks;
79 typeLoadCallbacks =
nullptr;
80 typeFreeCallbacks =
nullptr;
81 memberLoadCallbacks =
nullptr;
82 memberFreeCallbacks =
nullptr;
83 groupLoadCallbacks =
nullptr;
84 groupFreeCallbacks =
nullptr;
95 uint32 dataPtrPlaceholder;
105 dataPtrPlaceholder = 0;
115 uint32 memberDirOffset;
116 uint32 memberDataOffset;
117 uint32 groupDataPtrPlaceholder;
127 memberDataOffset = 0;
128 groupDataPtrPlaceholder = 0;
129 memberData =
nullptr;
135 memberData =
nullptr;
141 void initMembers(
int numMembers) {
142 int actualNumber = numMembers == 0 ? 256 : numMembers;
158 fileHandle =
nullptr;
169 uint32 *indexTablePtr;
171 byte *indexTableRawData;
175 fileHandle =
nullptr;
176 indexTablePtr =
nullptr;
178 indexTableRawData =
nullptr;
179 indexTable =
nullptr;
187 void reserveTableSize(
int numElements) {
188 indexTable =
new uint32[numElements];
215 ringBufPtr =
nullptr;
221 typedef void (*SSpriteUpdateFunc)(void);
222 typedef void (*SSpritePathCallback)(
SSprite *);
231 SSpriteUpdateFunc updateFunc;
232 SSpritePathCallback pathCallback;
263 updateFunc =
nullptr;
264 pathCallback =
nullptr;
322 uint32 getFeatures()
const;
330 return (f == kSupportsReturnToLauncher);
347 XpLib *_xp =
nullptr;
348 bool _extendedViewport =
false;
349 bool _isDemo =
false;
352 virtual void boltMain() = 0;
353 void setCursorPict(byte *sprite);
356 void displayColors(byte *palette, int16 page, int16 flags);
357 byte getPixel(byte *sprite, int16 localX, int16 localY);
358 void boltPict2Pict(
XPPicDesc *dest, byte *boltSprite);
359 void displayPic(byte *boltSprite, int16 xOff, int16 yOff, int16 page);
361 const char *assetPath(
const char *fileName);
362 void boltCycleToXPCycle(byte *srcData,
XPCycleState *cycleDesc);
363 void unpackColors(int16 count, byte *packedColors);
367 void swapPicHeader();
368 void swapAndResolvePicDesc();
369 void swapFirstWord();
370 void swapFirstTwoWords();
371 void swapFirstFourWords();
372 void swapSpriteHeader();
373 void freeSpriteCleanUp();
376 bool libRead(
Common::File *fileHandle, uint32 offset, byte *dest, uint32 size);
377 void decompress(byte *dest, uint32 decompSize, byte *src);
378 void resolveIt(uint32 *ref);
379 void resolvePendingFixups();
380 void resolveFunction(uint32 *ref);
381 void resolveAllRefs();
382 byte *getResolvedPtr(byte *data,
int offset);
384 bool closeBOLTLib(
BOLTLib **lib);
385 bool attemptFreeIndex(
BOLTLib *lib, int16 groupId);
386 bool loadGroupDirectory();
387 bool getBOLTGroup(
BOLTLib *lib, int16 groupId, int16 flags);
388 void freeBOLTGroup(
BOLTLib *lib, int16 groupId, int16 flags);
389 byte *getBOLTMember(
BOLTLib *lib, int16 resId);
390 bool freeBOLTMember(
BOLTLib *lib, int16 resId);
392 byte *memberAddr(
BOLTLib *lib, int16 resId);
393 byte *memberAddrOffset(
BOLTLib *lib, uint32 resIdAndOffset);
394 uint32 memberSize(
BOLTLib *lib, int16 resId);
395 byte *groupAddr(
BOLTLib *lib, int16 groupId);
396 bool allocResourceIndex();
397 void freeResourceIndex();
401 BOLTLib *_boothsBoltLib =
nullptr;
404 static BOLTCallback _defaultTypeLoadCallbacks[25];
405 static BOLTCallback _defaultTypeFreeCallbacks[25];
406 static BOLTCallback _defaultMemberLoadCallbacks[25];
407 static BOLTCallback _defaultMemberFreeCallbacks[25];
408 static BOLTCallback _defaultGroupLoadCallbacks[25];
409 static BOLTCallback _defaultGroupFreeCallbacks[25];
411 static void noOpCb();
413 static void swapAllWordsCb();
414 static void swapAllLongsCb();
415 static void swapPicHeaderCb();
416 static void swapAndResolvePicDescCb();
417 static void swapFirstWordCb();
418 static void swapFirstTwoWordsCb();
419 static void swapFirstFourWordsCb();
420 static void swapSpriteHeaderCb();
421 static void freeSpriteCleanUpCb();
423 virtual void initCallbacks() = 0;
425 int16 _resourceIndexCount = 1000;
426 uint32 **_resourceIndex =
nullptr;
429 uint32 _cachedFilePos = 0xFFFFFFFF;
430 BOLTLib *_boltCurrentLib =
nullptr;
433 int16 _boltLoadDepth = 0;
434 byte *_boltRawMemberData =
nullptr;
436 int16 _pendingFixupCount = 0;
439 bool initVRam(int16 poolSize);
441 bool vLoad(
void *dest,
const char *name);
442 bool vSave(
void *src, uint16 srcSize,
const char *name);
443 bool vDelete(
const char *name);
444 byte *dataAddress(int16 recordOffset);
445 uint16 dataSize(int16 recordOffset);
446 bool findRecord(
const char *name, int16 *outOffset);
448 int32 _vramRecordCount = 0;
449 int32 _vramUsedBytes = 0;
450 byte *_allocatedMemPool =
nullptr;
451 uint32 _allocatedMemPoolSize = 0;
452 int32 _curErrorCode = 0;
457 bool playRTF(
RTFResource *rtfFile, int16 animIndex, byte *ringBuffer, int32 bufferSize);
458 bool fillRTFBuffer();
459 void flushRTFSoundQueue();
460 bool maintainRTF(int16 mode,
RTFPacket **outFrameData);
462 bool killRTF(uint32 *outFilePos);
464 void preProcessPacket(
RTFPacket *packet);
469 void resetPlaybackState();
470 void setAVBufferSize(uint32 bufSize);
474 uint32 _rtfChunkRemaining = 0;
475 bool _rtfMidChunk =
false;
477 byte *_ringBufBase =
nullptr;
478 byte *_ringBufWritePtr =
nullptr;
479 uint32 _ringBufSize = 0;
480 uint32 _ringBufFreeSpace = 0;
481 uint32 _ringBufLowWater = 0;
482 uint32 _ringBufHighWater = 0;
483 uint32 _ringBufUsed = 0;
484 bool _rtfSoundActive =
false;
485 int16 _rtfPlaybackTime = 0;
486 int16 _rtfCumulativeTime = 0;
492 int16 _rtfChunkCount = 0;
493 int16 _rtfQueuedSoundCount = 0;
494 int16 _rtfSoundTiming = 0;
495 uint32 _rtfAnimStartOffset = 0;
496 bool _rtfNeedInitialFill =
false;
497 uint32 _rtfChunkTag = 0;
498 uint32 _rtfChunkSize = 0;
501 bool prepareAV(
RTFResource *rtfHandle, int16 animIndex, int16 width, int16 height, int16 xOff, int16 yOff);
502 bool maintainAV(int16 mode);
504 bool playAV(
RTFResource *rtfHandle, int16 animIndex, int16 width, int16 height, int16 xOff, int16 yOff);
508 bool initAV(
RTFResource *rtfHandle, int16 animIndex, int16 width, int16 height, int16 xOff, int16 yOff);
511 byte *_avRingBuffer =
nullptr;
512 uint32 _avTargetBufSize = 0x0FA000;
513 int16 _avSkipLevel = 0;
514 byte *_avFrontPalette =
nullptr;
515 byte *_avBackPalette =
nullptr;
516 uint32 _avSavedInactivityTimer = 0;
517 uint32 _avSavedScreenSaverTimer = 0;
518 int16 _avFrameAccum = 0;
519 int16 _avDisplayX = 0;
520 int16 _avDisplayY = 0;
526 bool startAnimation(
RTFResource *rtf, int16 animIndex);
527 void stopAnimation();
528 bool maintainAudioPlay(int16 mode);
532 int16 _animPrevInactivityTimer = 0;
533 byte *_animRingBuffer =
nullptr;
537 void setUpSSprite(
SSprite *sprite, int16 frameCount, byte **frameData, int16 frameRate, int16 velocityX, int16 velocityY);
538 void animateSSprite(
SSprite *sprite, int16 page);
539 void displaySSprite(
SSprite *sprite, int16 x, int16 y);
540 void eraseSSprite(
SSprite *sprite);
541 void setSSpriteFrames(
SSprite *sprite, int16 frameCount, byte **frameData, int16 frameRate);
542 void setSSpriteDrag(
SSprite *sprite, int16 dragX, int16 dragY);
543 void setSSpriteAccel(
SSprite *sprite, int16 accelX, int16 accelY);
544 void reverseSSpriteAccel(
SSprite *sprite);
545 void addSSpriteAccel(
SSprite *sprite, int16 dx, int16 dy);
546 void setSSpriteVelocity(
SSprite *sprite, int16 vx, int16 vy);
547 void reverseSSpriteVelocity(
SSprite *sprite);
548 void setSSpriteStart(
SSprite *sprite, int16 startFrame, int16 x, int16 y);
549 void setSSpriteStop(
SSprite *sprite, int16 stopFrame);
550 void setSSpritePath(
SSprite *sprite, byte *pathData, int16 pathCount, SSpritePathCallback callback);
551 bool inSSprite(
SSprite *sprite, int16 x, int16 y);
553 void setSSpriteCollision(
SSprite *sprite, int16 *bounds);
554 bool sSpriteAlive(
SSprite *sprite);
556 void getSSpriteAccel(
SSprite *sprite, int16 *out);
557 void getSSpriteVelocity(
SSprite *sprite, int16 *out);
558 void getSSpriteDrag(
SSprite *sprite, int16 *out);
559 void setSSpriteXLimit(
SSprite *sprite, int16 high, int16 low);
560 void setSSpriteYLimit(
SSprite *sprite, int16 high, int16 low);
561 void setSSpriteInfo(
SSprite *sprite, int16 info);
562 int16 getSSpriteInfo(
SSprite *sprite);
563 void freezeSSprite(
SSprite *sprite);
564 void unfreezeSSprite(
SSprite *sprite);
566 int16 _spriteCollTempX = 0;
567 int16 _spriteCollTempY = 0;
568 int16 _spriteCollTempW = 0;
569 int16 _spriteCollTempH = 0;
570 int16 _spriteScreenX = 0;
571 int16 _spriteScreenY = 0;
572 int16 _spriteCollTempA[4] = { 0 };
573 int16 _spriteCollTempB[4] = { 0 };
574 int16 _spriteScreenAX = 0;
575 int16 _spriteScreenAY = 0;
576 int16 _spriteScreenBX = 0;
577 int16 _spriteScreenBY = 0;
581 #define SHOULD_QUIT ::Bolt::g_engine->shouldQuit()
EngineFeature
Definition: engine.h:258
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: bolt.h:334
Definition: advancedDetector.h:164
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: bolt.h:337
bool hasFeature(EngineFeature f) const override
Definition: bolt.h:329