25 #include "common/events.h" 26 #include "common/rect.h" 27 #include "common/scummsys.h" 28 #include "common/system.h" 29 #include "common/error.h" 30 #include "common/fs.h" 31 #include "common/hash-str.h" 32 #include "common/random.h" 33 #include "common/serializer.h" 34 #include "common/util.h" 35 #include "common/array.h" 36 #include "common/memstream.h" 37 #include "engines/engine.h" 38 #include "engines/savestate.h" 39 #include "graphics/screen.h" 40 #include "audio/mixer.h" 41 #include "audio/audiostream.h" 42 #include "audio/decoders/raw.h" 44 #include "gamos/pool.h" 46 #include "gamos/keycodes.h" 48 #include "gamos/proc.h" 49 #include "gamos/music.h" 50 #include "gamos/movie.h" 53 #include "gamos/detection.h" 54 #include "gamos/file.h" 56 #include "gamos/array2d.h" 58 #include "gamos/blit.h" 62 struct GamosGameDescription;
69 CONFTP_RESMASK = 0x7f,
76 RESTP_GAMECONF2 = 0x10,
77 RESTP_DATACONF = 0x11,
82 RESTP_ACT_INFO = 0x20,
83 RESTP_ACT_ONCREATE = 0x21,
84 RESTP_ACT_ONDELETE = 0x22,
85 RESTP_ACT_COUNT = 0x23,
86 RESTP_ACT_DATA = 0x2a,
87 RESTP_ACT_COND = 0x2b,
88 RESTP_ACT_FUNC = 0x2c,
89 RESTP_UNK_MASKS = 0x38,
90 RESTP_UNK_OIDS = 0x39,
91 RESTP_UNK_ACTST = 0x3a,
92 RESTP_SPR_INFO = 0x40,
93 RESTP_SPR_SEQLEN = 0x41,
94 RESTP_SPR_SEQIMGINFO = 0x42,
95 RESTP_SPR_SEQIMGDATA = 0x43,
96 RESTP_UNKNOWN_50 = 0x50,
97 RESTP_SFX_SAMPLE = 0x51,
98 RESTP_MIDI_TRACK = 0x52,
100 RESTP_SUB_PLACE = 0x61,
101 RESTP_XORSEQ0 = 0x7c,
102 RESTP_XORSEQ1 = 0x7d,
103 RESTP_XORSEQ2 = 0x7e,
139 Image *image =
nullptr;
180 ObjState(uint8 aa, uint8 af, uint8 at): actid(aa), flags(af), t(at) {};
203 byte num_act_10e = 0;
213 int32 conditionAddress = -1;
214 int32 functionAddress = -1;
216 void parse(
const byte *data, uint32 dataSize);
223 uint8 storageSize = 0;
224 int32 onCreateAddress = -1;
226 int32 onDeleteAddress = -1;
240 FLAG_FREECOORDS = 0x40,
259 int16 actObjIndex = -1;
266 int16 tgtObjectId = -1;
267 int16 curObjectId = -1;
301 inline bool isActionObject()
const {
return (flags & (FLAG_HASACTION | FLAG_VALID)) == (FLAG_HASACTION | FLAG_VALID); };
302 inline bool isGraphicObject()
const {
return (flags & (FLAG_GRAPHIC | FLAG_VALID | FLAG_HASACTION)) == (FLAG_GRAPHIC | FLAG_VALID); };
303 inline bool isOverlayObject()
const {
return (flags & (FLAG_GRAPHIC | FLAG_OVERLAY | FLAG_FREECOORDS | FLAG_VALID | FLAG_HASACTION)) ==
304 (FLAG_GRAPHIC | FLAG_OVERLAY | FLAG_FREECOORDS | FLAG_VALID); };
305 inline bool isStaticObject()
const {
return (flags & (FLAG_GRAPHIC | FLAG_FREECOORDS | FLAG_VALID)) == (FLAG_GRAPHIC | FLAG_VALID); };
316 byte *palette =
nullptr;
327 byte *objMem =
nullptr;
329 inline bool isObjMem()
const {
return getMemType() == VM::REF_EBX;}
334 if (s.size() > maxLen)
339 return _vm.readMemString(getOffset(), maxLen);
342 inline uint8 getU8()
const {
344 return objMem[getOffset()];
345 return _vm.memory().getU8(getOffset());
348 inline uint32 getU32()
const {
350 return _vm.getU32(objMem + getOffset());
351 return _vm.memory().getU32(getOffset());
354 inline void write(byte *src, uint len) {
356 memcpy(objMem + getOffset(), src, len);
358 _vm.writeMemory(getOffset(), src, len);
361 inline void setU8(uint8 v) {
363 objMem[getOffset()] = v;
365 _vm.memory().setU8(getOffset(), v);
368 inline void setU32(uint32 v) {
370 _vm.setU32(objMem + getOffset(), v);
372 _vm.memory().setU32(getOffset(), v);
382 bool _errSet =
false;
389 bool _isResLoadingProcess =
false;
390 int _currentModuleID = 0;
392 byte _saveLoadID = 0;
393 uint32 _magic = 0xBAD00BAD;
396 int32 _gridCellW = 0;
397 int32 _gridCellH = 0;
398 uint32 _movieCount = 0;
400 byte _drawCursor = 0;
401 byte _fadeEffectID = 0;
404 byte _currentFade = 0;
406 int _isMoviePlay = 0;
408 bool _onlyScanImage =
false;
409 int32 _resReadOffset = 0;
434 uint32 _delayTime = 0;
435 uint32 _lastTimeStamp = 0;
444 int32 _cursorFrame = 0;
445 int32 _mouseCursorImgId = 0;
446 int32 _currentCursor = -1;
450 bool _isSaveLoadingProcess =
false;
451 bool _ignoreSoundActions =
false;
454 uint8 _inputMouseActId = 0;
455 uint8 _inputMouseActType = 0;
457 bool _midiStarted =
false;
459 uint8 DAT_004173ec = 0;
465 int32 _svModuleId = 0;
466 int32 _svGameScreen = 0;
467 uint32 _d2_fld10 = 0;
468 bool _enableSounds =
false;
469 bool _enableInput =
false;
470 bool _enableMovie =
false;
471 bool _enableCDAudio =
false;
472 int8 _cdAudioTrack = -1;
475 int32 _scrollTrackObj = 0;
476 int16 _scrollSpeed = 0;
477 int16 _scrollCutoff = 0;
478 int16 _scrollSpeedReduce = 0;
479 uint8 _scrollBorderL = 0;
480 uint8 _scrollBorderR = 0;
481 uint8 _scrollBorderU = 0;
482 uint8 _scrollBorderB = 0;
483 uint8 _sndChannels = 0;
484 uint8 _sndVolume = 0;
485 uint8 _midiVolume = 0;
489 uint8 _sndVolumeTarget = 0;
490 uint8 _midiVolumeTarget = 0;
491 uint8 _savedSndVolume = 0;
492 uint8 _savedMidiVolume = 0;
494 bool _enableMidi =
false;
495 int32 _midiTrack = 0;
497 uint16 _scummMidiVolume = 256;
498 uint16 _scummSndVolume = 256;
501 uint32 _readingBkgOffset = 0;
502 int32 _readingBkgMainId = -1;
503 int32 _countReadedBkg = 0;
504 int32 _currentGameScreen = -1;
505 int32 _loadedDataSize = -1;
507 uint32 _addrBlk12 = 0;
509 uint32 _addrKeyDown = 2;
510 uint32 _addrKeyCode = 3;
511 uint32 _addrCurrentFrame = 4;
517 uint32 _statesWidth = 0;
518 uint32 _statesHeight = 0;
519 uint32 _statesShift = 0;
523 uint8 _preprocDataId = 0;
530 bool _curObjectActProcessed =
false;
532 Object *_firstUpdateObject =
nullptr;
535 Object *_curObject =
nullptr;
536 Object *_inputActObj =
nullptr;
538 uint8 _curObjectT = 0;
539 bool _gfxObjectCreated =
false;
540 bool _restartUpdateObject =
false;
543 byte *_curObjStorage =
nullptr;
548 byte *PTR_00417388 =
nullptr;
550 int32 _curObjIndex = 0;
556 uint8 _inputActId = 0;
557 bool _pathInMove =
false;
559 uint8 _pressedKeyCode = 0;
564 int32 _txtInputVmOffset = -1;
565 int32 _txtInputSpriteID = 0;
566 int32 _txtInputX = 0;
567 int32 _txtInputY = 0;
568 uint8 _txtInputBuffer[256];
569 Object *_txtInputObjects[256];
570 int32 _txtInputLength = 0;
571 int32 _txtInputMaxLength = 0;
573 uint8 _txtInputFlags = 0;
574 bool _txtInputTyped =
false;
575 bool _txtInputIsNumber =
false;
576 Object *_txtInputObject =
nullptr;
578 int32 _txtInputObjectIndex = -1;
581 bool _txtInputActive =
false;
591 uint32 _statesCount = 0;
592 uint32 _pathRight = 0;
593 uint32 _pathBottom = 0;
599 bool _needReload =
false;
601 uint32 _engineVersion = 0x18;
611 bool loadModule(uint
id);
614 bool loadResHandler(uint tp, uint pid, uint p1, uint p2, uint p3,
const byte *data, uint32 dataSize);
615 bool loadResHandler(uint tp, uint pid, uint p1, uint p2, uint p3,
const RawData &data);
617 bool reuseLastResource(uint tp, uint pid, uint p1, uint p2, uint p3);
619 bool initMainDatas();
622 bool loadInitModule();
624 void readElementsConfig(
const RawData &data);
626 void setFPS(uint fps);
628 void loadXorSeq(
const byte *data, uint32 dataSize,
int id);
630 bool loadSpriteInfo(int32
id,
const byte *data, uint32 dataSize);
631 bool loadSpriteSeqLength(int32
id,
const byte *data, uint32 dataSize);
632 bool loadSpriteSeqImageInfo(int32
id, int32 p1,
const byte *data, uint32 dataSize);
633 bool loadSpriteSeqImageData(int32
id, int32 p1, int32 p2,
const byte *data, uint32 dataSize);
635 bool loadMidiTrack(int32
id,
const byte *data, uint32 dataSize);
637 bool loadBackground(int32
id,
const byte *data, uint32 dataSize);
640 void freeSequences();
645 bool playSound(uint
id);
646 int stepVolume(
int volume,
int target);
650 void syncSoundSettings()
override;
659 bool playMovie(uint32
id);
660 uint32 playMidiTrack(uint32
id);
664 void updateScreen(
bool checkers,
const Common::Rect &rect);
666 void readData2(
const RawData &data);
670 int32 doActions(
const Actions &a,
bool absolute);
671 uint32 savedDoActions(
const Actions &a);
673 static uint32 getU32(
const void *ptr);
675 void preprocessData(
int id,
ActEntry *e);
676 void preprocessDataB1(
int id,
ActEntry *e);
677 int processData(
ActEntry e,
bool absolute);
681 void processActionCurObject(
ActEntry e);
685 void removeObjectAtCoords(
Common::Point cell,
bool deleteGfxObj);
688 void removeObject(
Object *obj);
689 void removeObjectMarkDirty(
Object *obj);
690 void removeObjectByIDMarkDirty(int32
id);
692 void removeSubtitles(
Object *obj);
693 void cycleNextInputObj(
Object *obj);
695 bool updateObjects();
698 bool scrollAndDraw();
699 bool updateVMInputFrameStates();
700 bool updateGfxFrames(
Object *obj,
bool p2,
bool p1);
702 void updateGfxObjectPosition(
Object *obj);
703 void addDirtRectOnObject(
Object *obj);
707 void flushDirtyRects(
bool apply);
709 bool usePalette(
const byte *pal,
int num,
int fade,
bool winColors);
710 bool setPaletteCurrentGS();
712 bool loadImage(
Image *img);
714 uint32 doScript(uint32 scriptAddress);
716 bool createGfxObject(uint32
id,
Common::Point position,
bool p);
718 void gfxObjectCalculateFlip(int32 sprId,
Object *obj,
bool p);
720 void updateLinkedGfxObject(
Object *obj);
722 bool moviePlayerPlay(
int id);
724 void setCursor(
int id,
bool dirtRect);
729 void setNeedReload() {
731 _vm._interrupt =
true;
734 Object *addSubtitleImage(uint32 frame, int32 spr, int32 *pX, int32 y);
735 void addSubtitles(
VM::Context *ctx, byte memtype, int32 offset, int32 sprId, int32 x, int32 y);
739 void FUN_00407db8(uint8 p);
740 byte FUN_00408648(uint8 p1, uint8 p2, uint8 p3);
741 byte FUN_004084bc(uint8 p);
742 byte FUN_00408510(uint8 p);
744 byte FUN_004085d8(uint8 p);
745 byte pathFindCalcMove(
bool faceTarget);
746 byte pathFindMoveToTarget();
747 byte pathFindTraceMove(uint8 p);
748 byte pathFindSetNeighbor(uint8 checkVal, uint8 setVal);
750 byte FUN_004088cc(uint8 p1, uint8 p2, uint8 p3);
755 bool FUN_0040705c(
int a,
int b);
758 void runRenewStaticGfxCurObj(uint8 val,
bool rnd);
759 void removeStaticGfxCurObj();
761 int txtInputBegin(
VM::Context *ctx, byte memtype, int32 offset,
int sprId, int32 x, int32 y);
762 void txtInputProcess(uint8 c);
763 void txtInputEraseBack(
int n);
765 bool onTxtInputUpdate(uint8 c);
768 void storeToGameScreen(
int id);
769 bool switchToGameScreen(
int id,
bool doNotStore);
776 bool writeStateFile();
781 bool loadStateFile();
784 bool writeSaveFile(
int id);
785 bool loadSaveFile(
int id);
786 bool deleteSaveFile(
int id);
791 void vmCallDispatcher(
VM::Context *ctx, uint32 funcID);
796 static void callbackVMCallDispatcher(
void *engine,
VM::Context *ctx, uint32 funcID);
808 bool eventsSkip(
bool breakOnInput =
false);
812 inline void rndSeed(uint32 seed) {
813 _seed = seed * 0x41c64e6d + 0x3039;
816 inline uint32 rnd() {
818 _seed = _seed * 0x41c64e6d + 0x3039;
822 inline uint16 rndRange16(uint32 range) {
823 uint16 percent = _seed >> 16;
824 _seed = _seed * 0x41c64e6d + 0x3039;
825 return (percent * range) >> 16;
834 uint32 getFeatures()
const {
835 return _gameDescription->desc.
flags;
839 return _gameDescription->desc.
gameId;
843 return _gameDescription->desc.
language;
850 uint32 getEngineVersion()
const {
851 return _gameDescription->engineVersion;
856 #define SHOULD_QUIT ::Gamos::g_engine->shouldQuit()
const char * fileName
Name of the described file.
Definition: advancedDetector.h:79
const char * gameId
Definition: advancedDetector.h:170
uint32 flags
Definition: advancedDetector.h:207
Definition: detection.h:29
Common::Language language
Definition: advancedDetector.h:194
byte readByte()
Definition: stream.h:434
Definition: keycodes.h:29
void erase(uint32 p, uint32 len=npos)
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
ADGameFileDescription filesDescriptions[14]
Definition: advancedDetector.h:189
Definition: movie_decoder.h:32
Language
Definition: language.h:45