25 #include "audio/softsynth/pcspk.h" 26 #include "audio/mixer.h" 27 #include "common/file.h" 28 #include "common/rect.h" 29 #include "common/events.h" 30 #include "common/serializer.h" 32 #include "engines/advancedDetector.h" 33 #include "engines/engine.h" 34 #include "graphics/surface.h" 36 #include "efh/constants.h" 58 static const uint8 kSavegameVersion = 1;
59 #define EFH_SAVE_HEADER MKTAG('E', 'F', 'H', 'S') 61 enum EfhDebugChannels {
62 kDebugEngine = 1 << 0,
64 kDebugGraphics = 1 << 2,
65 kDebugScript = 1 << 3,
74 int8 **_vgaLineBuffer;
99 uint16 _field5_textId;
100 uint16 _field7_textId;
124 int8 _agilityModifier;
127 uint8 _specialEffect;
129 uint8 _exclusiveType;
130 uint8 _field19_mapPosX_or_maxDeltaPoints;
145 uint16 field12_textId;
146 uint16 field14_textId;
148 uint8 _activeScore[15];
149 uint8 _passiveScore[11];
150 uint8 _infoScore[11];
154 uint8 _possessivePronounSHL6;
159 uint8 _defaultDefenseItemId;
186 const uint8 *_widthArray;
187 const uint8 *_extraLines;
188 const Font *_fontData;
190 uint8 _extraVerticalSpace;
191 uint8 _extraHorizontalSpace;
200 uint16 _lineDataSize;
201 uint8 _paletteTransformation;
211 uint8 _possessivePronounSHL6;
217 uint8 _maxDamageAbsorption;
219 uint8 _additionalInfo;
247 int16 _lastInventoryUsed;
272 uint32 getFeatures()
const;
273 const char *getGameId()
const;
276 const char *getCopyrightString()
const;
286 bool shouldQuitGame()
const {
return _shouldQuit || shouldQuit(); }
296 bool _saveAuthorized;
301 void initMapMonsters();
302 void loadMapArrays(
int idx);
303 void saveAnimImageSetId();
304 int16 getEquipmentDefense(int16 charId);
305 uint16 getEquippedExclusiveType(int16 charId, int16 exclusiveType,
bool flag);
306 void displayLowStatusScreen(
bool flag);
307 void loadImageSetToTileBank(int16 bankId, int16 setId);
308 void restoreAnimImageSetId();
309 void checkProtection();
311 void copyCurrentPlaceToBuffer(int16
id);
312 uint8 getMapTileInfo(int16 mapPosX, int16 mapPosY);
313 void writeTechAndMapFiles();
315 void setTextPos(int16 textPosX, int16 textPosY);
316 void drawGameScreenAndTempText(
bool flag);
317 void drawMap(
bool largeMapFl, int16 mapPosX, int16 mapPosY, int16 mapSize,
bool drawHeroFl,
bool drawMonstersFl);
318 void displaySmallMap(int16 posX, int16 posY);
319 void displayLargeMap(int16 posX, int16 posY);
321 void removeObject(int16 charId, int16 objectId);
322 void totalPartyKill();
323 void removeCharacterFromTeam(int16 teamMemberId);
324 void refreshTeamSize();
325 bool isNpcATeamMember(int16
id);
326 void handleWinSequence();
327 bool giveItemTo(int16 charId, int16 objectId, int16 fromCharId);
328 int16 chooseCharacterToReplace();
329 int16 handleCharacterJoining();
330 void drawText(uint8 *srcPtr, int16 posX, int16 posY, int16 maxX, int16 maxY,
bool flag);
331 void displayMiddleLeftTempText(uint8 *impArray,
bool flag);
332 void transitionMap(int16 centerX, int16 centerY);
333 void setSpecialTechZone(int16 unkId, int16 centerX, int16 centerY);
334 int16 findMapSpecialTileIndex(int16 posX, int16 posY);
335 bool isPosOutOfMap(int16 mapPosX, int16 mapPosY);
344 void handleNewRoundEffects();
346 void computeMapAnimation();
347 void handleAnimations();
348 int8 checkMonsterMoveCollisionAndTileTexture(int16 monsterId);
349 bool moveMonsterAwayFromTeam(int16 monsterId);
350 bool moveMonsterTowardsTeam(int16 monsterId);
351 bool moveMonsterGroupOther(int16 monsterId, int16 direction);
352 bool moveMonsterGroupRandom(int16 monsterId);
353 int16 computeMonsterGroupDistance(int16 monsterId);
354 bool checkWeaponRange(int16 monsterId, int16 weaponId);
355 bool checkMonsterMovementType(int16
id,
bool teamFlag);
356 bool checkTeamWeaponRange(int16 monsterId);
357 bool checkIfMonsterOnSameLargeMapPlace(int16 monsterId);
358 bool checkMonsterWeaponRange(int16 monsterId);
359 void handleMapMonsterMoves();
360 bool checkMapMonsterAvailability(int16 monsterId);
361 void displayMonsterAnim(int16 monsterId);
362 int16 countAliveMonsters(int16
id);
363 bool checkMonsterGroupDistance1OrLess(int16 monsterId);
364 bool handleTalk(int16 monsterId, int16 arg2, int16 itemId);
365 void startTalkMenu(int16 monsterId);
366 void displayImp1Text(int16 textId);
367 bool handleInteractionText(int16 mapPosX, int16 mapPosY, int16 charId, int16 itemId, int16 arg8, int16 imageSetId);
368 int8 checkTileStatus(int16 mapPosX, int16 mapPosY,
bool teamFl);
369 void computeInitiatives();
370 void redrawScreenForced();
371 int16 countMonsterGroupMembers(int16 monsterGroup);
372 uint16 getXPLevel(uint32 xp);
373 bool isItemCursed(int16 itemId);
374 bool hasObjectEquipped(int16 charId, int16 objectId);
375 void setMapMonsterAggressivenessAndMovementType(int16
id, uint8 mask);
376 bool isMonsterActive(int16 groupId, int16
id);
377 int16 getTileFactId(int16 mapPosX, int16 mapPosY);
378 void setCharacterObjectToBroken(int16 charId, int16 objectId);
379 int16 selectOtherCharFromTeam();
380 bool checkMonsterCollision();
383 bool handleFight(int16 monsterId);
384 void handleFight_checkEndEffect(int16 charId);
385 void handleFight_lastAction_A(int16 teamCharId);
386 void handleFight_lastAction_D(int16 teamCharId);
387 void handleFight_lastAction_H(int16 teamCharId);
388 bool handleFight_lastAction_U(int16 teamCharId);
389 void handleFight_MobstersAttack(
int groupId);
391 bool isMonsterAlreadyFighting(int16 monsterId, int16 teamMonsterId);
392 void createOpponentList(int16 monsterTeamId);
393 void resetTeamMonsterEffects();
394 void initFight(int16 monsterId);
395 void resetTeamMonsterIdArray();
396 bool isTeamMemberStatusNormal(int16
id);
397 void getDeathTypeDescription(int16 victimId, int16 attackerId);
398 int16 determineTeamTarget(int16 charId, int16 unkFied18Val,
bool checkDistanceFl);
399 bool getTeamAttackRoundPlans();
400 void drawCombatScreen(int16 charId,
bool whiteFl,
bool drawFl);
402 bool characterSearchesMonsterCorpse(int16 charId, int16 monsterId);
403 void addReactionText(int16
id);
404 void displayEncounterInfo(
bool WhiteFl);
405 int16 getWeakestMobster(int16 groupNumber);
406 int16 getCharacterScore(int16 charId, int16 itemId);
407 bool checkSpecialItemsOnCurrentPlace(int16 itemId);
408 bool hasAdequateDefense(int16 monsterId, uint8 attackType);
409 bool hasAdequateDefenseNPC(int16 charId, uint8 attackType);
410 void addNewOpponents(int16 monsterId);
411 int16 getTeamMonsterAnimId();
412 int16 selectMonsterGroup();
413 void redrawCombatScreenWithTempText(int16 charId);
414 void handleDamageOnArmor(int16 charId, int16 damage);
417 int32 readFileToBuffer(
const Common::Path &filename, uint8 *destBuffer);
419 void findMapFile(int16 mapId);
420 void rImageFile(
const Common::Path &filename, uint8 *targetBuffer, uint8 **subFilesArray, uint8 *packedBuffer);
422 void readImpFile(int16
id,
bool techMapFl);
423 void loadNewPortrait();
424 void loadAnimImageSet();
426 void loadTechMapImp(int16 fileId);
427 void loadPlacesFile(uint16 fullPlaceId,
bool forceReloadFl);
434 void drawLeftCenterBox();
435 void displayNextAnimFrame();
436 void displayAnimFrame();
437 void displayAnimFrames(int16 animId,
bool displayMenuBoxFl);
438 void displayFctFullScreen();
439 void copyDirtyRect(int16 minX, int16 minY, int16 maxX, int16 maxY);
441 void displayBufferBmAtPos(
BufferBM *bufferBM, int16 posX, int16 posY);
442 void drawRect(int16 minX, int16 minY, int16 maxX, int16 maxY);
443 void drawColoredRect(int16 minX, int16 minY, int16 maxX, int16 maxY, int16 color);
444 void clearScreen(int16 color);
445 void displayRawDataAtPos(uint8 *imagePtr, int16 posX, int16 posY);
446 void drawString(
const Common::String &str, int16 startX, int16 startY, uint16 textColor);
447 void displayCenteredString(
const Common::String &str, int16 minX, int16 maxX, int16 posY);
448 void displayMenuAnswerString(
const Common::String &str, int16 minX, int16 maxX, int16 posY);
449 void drawMapWindow();
450 void displayGameScreen();
451 void drawUpperLeftBorders();
452 void drawUpperRightBorders();
453 void drawBottomBorders();
454 void drawChar(uint8 curChar, int16 posX, int16 posY);
455 void setTextColorWhite();
456 void setTextColorRed();
457 void setTextColorGrey();
459 void clearBottomTextZone(int16 color);
460 void clearBottomTextZone_2(int16 color);
461 void setNextCharacterPos();
462 void displayCharAtTextPos(
char character);
463 void displayWindow(uint8 *buffer, int16 posX, int16 posY, uint8 *dest);
464 void displayColoredMenuBox(int16 minX, int16 minY, int16 maxX, int16 maxY, int16 color);
467 int16 displayBoxWithText(
const Common::String &str, int16 menuType, int16 displayOption,
bool displayTeamWindowFl);
468 bool handleDeathMenu();
469 void displayCombatMenu(int16 charId);
470 void displayMenuItemString(int16 menuBoxId, int16 thisBoxId, int16 minX, int16 maxX, int16 minY,
const char *str);
471 void displayStatusMenu(int16 windowId);
472 void prepareStatusRightWindowIndexes(int16 menuId, int16 charId);
473 void displayCharacterSummary(int16 curMenuLine, int16 npcId);
474 void displayCharacterInformationOrSkills(int16 curMenuLine, int16 npcId);
475 void displayStatusMenuActions(int16 menuId, int16 curMenuLine, int16 npcId);
476 void prepareStatusMenu(int16 windowId, int16 menuId, int16 curMenuLine, int16 charId,
bool refreshFl);
477 void displayWindowAndStatusMenu(int16 charId, int16 windowId, int16 menuId, int16 curMenuLine);
478 int16 displayStringInSmallWindowWithBorder(
const Common::String &str,
bool delayFl, int16 charId, int16 windowId, int16 menuId, int16 curMenuLine);
479 int16 handleStatusMenu(int16 gameMode, int16 charId);
480 void unequipItem(int16 charId, int16 objectId, int16 windowId, int16 menuId, int16 curMenuLine);
481 void tryToggleEquipped(int16 charId, int16 objectId, int16 windowId, int16 menuId, int16 curMenuLine);
482 int16 useObject(int16 charId, int16 objectId, int16 teamMonsterId, int16 menuId, int16 curMenuLine, int16 gameMode);
488 const uint8 *script_readNumberArray(
const uint8 *buffer, int16 destArraySize, int16 *destArray);
489 const uint8 *script_getNumber(
const uint8 *srcBuffer, int16 *retBuf);
490 int16 script_parse(
Common::String str, int16 posX, int16 posY, int16 maxX, int16 maxY,
bool scriptExecuteFlag);
493 void songDelay(
int delay);
494 void playNote(
int frequencyIndex,
int totalDelay);
495 Common::KeyCode playSong(uint8 *buffer);
496 void generateSound1(
int lowFreq,
int highFreq,
int duration);
497 void generateSound2(
int startFreq,
int endFreq,
int speed);
498 void generateSound3();
499 void generateSound4(
int repeat);
500 void generateSound5(
int repeat);
501 void generateSound(int16 soundType);
502 void genericGenerateSound(int16 soundType, int16 repeatCount);
505 void setDefaultNoteDuration();
506 void decryptImpFile(
bool techMapFl);
507 void loadImageSet(int16 imageSetId, uint8 *buffer, uint8 **subFilesArray, uint8 *destBuffer);
508 uint32 uncompressBuffer(uint8 *compressedBuf, uint8 *destBuf);
509 int16 getRandom(int16 maxVal);
510 Common::KeyCode getLastCharAfterAnimCount(int16 delay);
511 Common::KeyCode getInput(int16 delay);
513 Common::KeyCode waitForKey();
514 Common::KeyCode mapInputCode(Common::KeyCode input);
515 Common::KeyCode handleAndMapInput(
bool animFl);
516 Common::KeyCode getInputBlocking();
518 bool getValidationFromUser();
519 uint32 ROR(uint32 val, uint8 shiftVal);
523 uint8 _bufferCharBM[128];
524 int8 *_vgaLineBuffer[200];
528 uint8 _tileBank[3][12000];
529 uint8 _circleImageBuf[40100];
530 uint8 _portraitBuf[25000];
531 uint8 _decompBuf[40100];
532 uint8 _menuBuf[12500];
533 uint8 _windowWithBorderBuf[1500];
534 uint8 _mapArr[19][7000];
535 uint8 _places[12000];
536 uint8 _curPlace[24][24];
540 uint8 _titleSong[1024];
545 uint8 _techDataArr[19][4100];
559 BitmapRef _mapBitmapRefArr[19];
563 uint8 _mapGameMaps[19][64][64];
565 uint8 _defaultBoxColor;
571 int16 _oldAnimImageSetId;
572 int16 _animImageSetId;
573 uint8 _paletteTransformationConstant;
574 uint8 *_circleImageSubFileArray[12];
575 uint8 *_tileBankSubFilesArray[216];
577 int16 _currentTileBankImageSetId[3];
578 int16 _unkRelatedToAnimImageSetId;
580 int16 _currentAnimImageSetId;
581 uint8 *_portraitSubFilesArray[20];
582 int16 _unkAnimRelatedIndex;
583 uint8 *_imp1PtrArray[100];
584 uint8 *_imp2PtrArray[432];
586 int16 _guessAnimationAmount;
587 uint16 _largeMapFlag;
592 bool _engineInitPending;
593 bool _protectionPassed;
598 bool _checkTileDisabledByScriptFl;
599 bool _redrawNeededFl;
600 bool _drawHeroOnMapFl;
601 bool _drawMonstersOnMapFl;
602 bool _textBoxDisabledByScriptFl;
604 int16 _imageSetSubFilesIdx;
605 int16 _oldImageSetSubFilesIdx;
607 int16 _mapPosX, _mapPosY;
608 int16 _oldMapPosX, _oldMapPosY;
609 int16 _techDataId_MapPosX, _techDataId_MapPosY;
610 uint16 _lastMainPlaceId;
612 uint16 _tempTextDelay;
615 bool _ongoingFightFl;
616 bool _statusMenuActive;
617 int16 _menuStatItemArr[15];
619 int16 _menuItemCounter;
EngineFeature
Definition: engine.h:253
Definition: advancedDetector.h:163
Definition: constants.h:27
Definition: serializer.h:79
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: constants.h:57
Definition: algorithm.h:29