21 #ifndef PELROCK_TYPES_H 22 #define PELROCK_TYPES_H 24 #include "common/rect.h" 25 #include "common/system.h" 43 const byte kActionMaskNone = 0;
44 const byte kActionMaskOpen = 1;
45 const byte kActionMaskClose = 2;
46 const byte kActionMaskUnknown = 4;
47 const byte kActionMaskPickup = 8;
48 const byte kActionMaskTalk = 16;
49 const byte kActionMaskPush = 32;
50 const byte kActionMaskPull = 128;
66 const int kCursorWidth = 16;
67 const int kCursorHeight = 18;
68 const int kCursorSize = 288;
70 const int kVerbIconWidth = 60;
71 const int kVerbIconHeight = 60;
72 const int kNumVerbIcons = 9;
74 const int kBalloonWidth = 247;
75 const int kBalloonHeight = 112;
76 const int kBalloonFrames = 4;
78 const int kAlfredFrameWidth = 51;
79 const int kAlfredFrameHeight = 102;
81 const int kTalkAnimationSpeed = 2;
82 const int kAlfredAnimationSpeed = 2;
84 const int kAlfredIdleAnimationFrameCount = 300;
85 const int kAlfredIdleScreenSaverFrameCount = 1090;
87 const int kInventoryPageSize = 10;
89 const int kAlfredInitialPosX = 235;
90 const int kAlfredInitialPosY = 279;
93 const byte kMoveRight = 0x01;
94 const byte kMoveLeft = 0x02;
95 const byte kMoveHoriz = 0x03;
96 const byte kMoveDown = 0x04;
97 const byte kMoveUp = 0x08;
98 const byte kMoveVert = 0x0C;
99 const int kMaxPathLength = 100;
100 const int kMaxMovementSteps = 100;
101 const byte kPathEnd = 0xFF;
103 const byte kAlfredColor = 0x0D;
108 OVERLAY_PICKUP_ICON = 2,
113 const byte kPasserbyRight = 0;
114 const byte kPasserbyLeft = 1;
115 const byte kPasserbyDown = 2;
117 const byte kIconBlinkPeriod = 4;
119 enum AlfredAnimState {
129 enum AlfredDirection {
137 byte *animData =
nullptr;
147 AlfredSpecialAnim(
int nF,
int width,
int height,
int nBudas, uint32 off,
int lCount, uint32 sz,
int spd = 2)
148 : numFrames(nF), w(width), h(height), loopCount(lCount), size(sz), speed(spd) {
161 bool isActive =
false;
166 bool isAlfredUnder =
false;
170 bool isActive =
false;
171 int invStartingPos = 0;
172 int flashingIconIndex = -1;
175 byte *arrows[2] = {
nullptr,
nullptr};
177 bool posInInventorySelectionArea(
int x,
int y) {
178 return inventorySelectionArea.
contains(x, y);
183 AlfredAnimState animState = ALFRED_IDLE;
184 AlfredDirection direction = ALFRED_DOWN;
186 uint16 movementSpeedX = 6;
187 uint16 movementSpeedY = 5;
188 uint16 x = kAlfredInitialPosX;
189 uint16 y = kAlfredInitialPosY;
190 byte w = kAlfredFrameWidth;
191 byte h = kAlfredFrameHeight;
192 int idleFrameCounter = 0;
193 int screenSaverFrameCounter = 0;
194 bool isWalkingCancelable =
true;
196 void setState(AlfredAnimState nextState) {
197 animState = nextState;
202 idleFrameCounter = 0;
203 screenSaverFrameCounter = 0;
208 bool enabled =
false;
237 uint16 movementCount;
238 uint16 compressed_length;
243 uint32 paletteOffset;
269 byte **animData =
nullptr;
272 byte elpapsedFrames = 0;
273 uint16 movementFlags = 0;
297 int curAnimIndex = 0;
300 bool isHotspotDisabled;
301 bool disableAfterSequence =
false;
302 bool isTalking =
false;
303 byte talkingAnimIndex = 0;
316 byte actionFlags = 0;
318 bool isEnabled =
true;
319 bool isSprite =
false;
324 uint32 spritePointer = 0;
328 int8 offsetXAnimA = 0;
329 int8 offsetYAnimA = 0;
334 byte numFramesAnimA = 0;
338 int8 offsetXAnimB = 0;
339 int8 offsetYAnimB = 0;
344 byte numFramesAnimB = 0;
350 byte currentFrameAnimA = 0;
351 byte currentFrameAnimB = 0;
353 byte **animA =
nullptr;
354 byte **animB =
nullptr;
360 bool isAction =
false;
361 uint16 actionTrigger = 0;
429 byte iconData[60 * 60];
446 byte curFrameCount = 0;
459 byte paletteMode = 0;
462 byte unknownBytes[7] = {0};
464 byte curFrameCount = 0;
469 byte paletteMode = 0;
476 uint32 frameTrigger = 0x3FF;
485 PasserByAnim(byte spriteIndex_, int16 startX_, int16 startY_, byte dir_, int16 resetCoord_, byte targetZIndex_, uint32 frameTrigger_)
486 : frameTrigger(frameTrigger_), startX(startX_), startY(startY_), resetCoord(resetCoord_), dir(dir_), spriteIndex(spriteIndex_), targetZIndex(targetZIndex_) {}
492 byte currentAnimIndex = 0;
495 RoomPasserBys(byte roomNum, byte nAnims) : roomNumber(roomNum), numAnims(nAnims) {}
502 byte room =
static_cast<byte
>(-1);
506 bool isDisabled =
false;
507 bool shouldDisableOnSelect =
false;
508 bool hasConversationEndMarker =
false;
509 bool isTerminator =
false;
519 byte *data =
nullptr;
522 #define FLAG_BOSS_WIRED_MONEY 0 523 #define FLAG_BOSS_IN_JAIL 1 524 #define FLAG_SPICY_SAUCE_PLACED 2 525 #define FLAG_BROKEN_GLASS 3 526 #define FLAG_FIRST_TIME_IN_SHOP 4 527 #define FLAG_ELECTROSHOCK 5 528 #define FLAG_CABLES_PLACED 6 529 #define FLAG_DOORMAN_BRIBED 7 530 #define FLAG_BOOK_MEMORIZED 8 531 #define FLAG_ALFRED_SMART 9 532 #define FLAG_ALFRED_SPEAKS_EGYPTIAN 10 533 #define FLAG_SALESMAN_LEAVES_ALFRED_ALONE 11 534 #define FLAG_TRAVEL_TO_EGYPT 12 535 #define FLAG_SOLVED_PARADOX 13 536 #define FLAG_CROCODILE_ON 14 537 #define FLAG_LOOKED_SYMBOL_MUSEUM_EXTERIOR 15 538 #define FLAG_SECRET_DOOR_OPEN 16 539 #define FLAG_STOLE_PRINCESS_HAIR 17 540 #define FLAG_TO_JAIL 18 541 #define FLAG_SAFE_COMBINATION 19 542 #define FLAG_DOLL_PLACED 20 543 #define FLAG_GUARD_WATER_DRINKED 21 544 #define FLAG_GUARD_PEEING 22 545 #define FLAG_PYRAMID_COLLAPSED 23 546 #define FLAG_PYRAMID_COLLAPSED2 24 547 #define FLAG_GUARD_HAVINGFUN 25 548 #define FLAG_MAGIC_FORMULA 26 549 #define FLAG_TIME_TRAVEL 27 550 #define FLAG_EUNUCH_APPEARS 28 551 #define FLAG_PHARAOH_VIEWING 29 552 #define FLAG_TO_WORK 30 553 #define FLAG_STONE_GIVEN 31 554 #define FLAG_COLLECTED_STONES 32 555 #define FLAG_DRUNK_GUARDS 33 556 #define FLAG_FAKE_STONE_WET 34 557 #define FLAG_CORRECT_DOOR 35 558 #define FLAG_TRAPDOOR_OPEN 36 559 #define FLAG_PRINCESS_ROOM 37 560 #define FLAG_GET_THE_PRINCESS 38 561 #define FLAG_GAME_RESTART 39 562 #define FLAG_CORRIDORS 40 563 #define FLAG_GODS_STANCES 41 564 #define FLAG_END_OF_GAME 42 565 #define FLAG_FROM_INTRO 43 566 #define FLAG_STONE_THROWN 44 567 #define FLAG_USED_WATER 45 568 #define FLAG_OPEN_SHOP 46 569 #define FLAG_DRINKS_NUMBER 47 570 #define FLAG_COLLECTED_INGREDIENTS 48 571 #define FLAG_GUARD_ASKS_FOR_STUFF 49 572 #define FLAG_GUARD_ID_DELIVERED 50 573 #define FLAG_TRAVELAGENCY_OPEN 51 574 #define FLAG_MERCHANT_SLOGANS 52 575 #define FLAG_HOOKER_250_TIMES 53 576 #define FLAG_CORRECT_ANSWERS 54 577 #define FLAG_CHEAT_CODE_ENABLED 55 578 #define FLAG_RIDDLE_PRESENTED 56 579 #define FLAG_SYMBOLS_PUSHED 57 580 #define FLAG_MERCHANT_GIVENITEMS 58 581 #define FLAG_CORRECT_DOOR_CHOSEN 59 582 #define FLAG_SKELETON_RECOGNIZES 60 583 #define FLAG_PIGEON_DEAD 61 584 #define FLAG_RECIPE_TAKEN 62 586 const int kNumGameFlags = 63;
589 byte flags[kNumGameFlags];
591 GameState stateGame = INTRO;
594 int16 selectedInventoryItem = -1;
596 int libraryShelf = -1;
597 int selectedBookIndex = -1;
598 char bookLetter =
'\0';
612 delete[] conversationCurrentRoot;
613 conversationCurrentRoot =
nullptr;
617 memset(conversationCurrentRoot, 0xFF, 112);
618 for (
int i = 0; i < kNumGameFlags; i++)
620 flags[FLAG_FIRST_TIME_IN_SHOP] =
true;
621 inventoryItems.
clear();
622 stickersPerRoom.
clear();
623 roomExitChanges.
clear();
624 roomWalkBoxChanges.
clear();
625 roomHotSpotChanges.
clear();
626 spriteChanges.
clear();
629 selectedBookIndex = -1;
634 void clearBranches() {
635 for(
auto &entry : disabledBranches) {
637 if (resetEntry.data) {
638 delete[] resetEntry.data;
639 resetEntry.data =
nullptr;
643 disabledBranches.clear();
647 disabledBranches[entry.room].push_back(entry);
650 byte getFlag(
int flagIndex)
const {
651 if (flagIndex < 0 || flagIndex >= kNumGameFlags)
653 return flags[flagIndex];
656 bool getBoolFlag(
int flagIndex)
const {
657 return getFlag(flagIndex) != 0;
660 void setFlag(
int flagIndex, byte value) {
661 if (flagIndex < 0 || flagIndex >= kNumGameFlags)
663 flags[flagIndex] = value;
666 void addInventoryItem(
int id) {
670 void clearInventory() {
671 inventoryItems.
clear();
672 selectedInventoryItem = -1;
675 void removeInventoryItem(
int id) {
676 for (uint i = 0; i < inventoryItems.
size(); i++) {
677 if (inventoryItems[i] ==
id) {
682 if (selectedInventoryItem ==
id) {
683 if (inventoryItems.
size() > 0) {
684 selectedInventoryItem = inventoryItems[0];
686 selectedInventoryItem = -1;
691 bool hasInventoryItem(
int id)
const {
692 for (uint i = 0; i < inventoryItems.
size(); i++) {
693 if (inventoryItems[i] ==
id) {
701 byte *conversationCurrentRoot =
new byte[112];
703 int getCurrentRoot(byte room,
int npc)
const {
706 return (conversationCurrentRoot[room * 2 + npc] == 0xFF) ? -1 : conversationCurrentRoot[room * 2 + npc];
709 void setCurrentRoot(byte room,
int root,
int npc) {
712 if (root < 0 || root > 254) {
713 conversationCurrentRoot[room * 2 + npc] = 0xFF;
715 conversationCurrentRoot[room * 2 + npc] = (byte)root;
719 int findFirstBookIndex() {
720 for (uint i = 0; i < inventoryItems.
size(); i++) {
721 int x = inventoryItems[i];
722 if ((x >= 11) && (x <= 58))
728 int booksInInventory() {
729 int l = inventoryItems.
size();
731 for (
int i = 0; i < l; i++) {
732 int x = inventoryItems[i];
733 if ((x >= 11) && (x <= 58))
741 byte currentRoom = 0;
744 AlfredDirection alfredDir = ALFRED_DOWN;
virtual void setShakePos(int shakeXOffset, int shakeYOffset)=0
void clear(bool shrinkArray=0)
Definition: hashmap.h:431
void clear()
Definition: array.h:321
void push_back(const T &element)
Definition: array.h:181
Definition: atari-cursor.h:35
size_type size() const
Definition: array.h:316
bool contains(T x, T y) const
Definition: rect.h:246
T remove_at(size_type idx)
Definition: array.h:261