25 #include "common/events.h" 26 #include "common/file.h" 27 #include "common/random.h" 28 #include "common/str.h" 29 #include "common/system.h" 30 #include "engines/engine.h" 31 #include "engines/advancedDetector.h" 33 #include "image/pcx.h" 35 #include "waynesworld/sound.h" 38 #define kWWSavegameVersion 1 39 #define kWWSavegameStrSize 14 40 #define kWWSavegameStr "SCUMMVM_WAYNES" 46 GF_GUILANGSWITCH = (1 << 0)
58 int16 saveYear, saveMonth, saveDay;
59 int16 saveHour, saveMinutes;
85 uint32 nextUpdateTicks;
89 AnimationTimer() : nextUpdateTicks(0), delay(0), counter(0), expired(
false) {}
93 kLeftButtonClicked = 1 << 0,
94 kRightButtonClicked = 1 << 1,
98 const int kRoomObjectsCount = 404;
99 const int kWalkPointsCount = 300;
100 const uint kWalkMapSize = (320 * 150) / 8;
101 const uint kRoomAnimationsCount = 20;
102 const uint kStaticRoomObjectsMapCount = 40;
103 const uint kStaticRoomObjectsCount = 58;
104 const uint kStaticRoomObjectSpritesCount = 4;
105 const uint kAnimationTimersCount = 4;
106 const int kInventorySize = 50;
107 const int kFirstInventoryObjectId = 28;
108 const int kLastInventoryObjectId = 77;
110 extern const char *savegameStr;
125 return _isSaveAllowed && (_gameState == 0 || _gameState == 4);
128 return _isSaveAllowed && (_gameState == 0 || _gameState == 4);
135 bool _isSoundEnabled =
true;
136 bool _isMusicEnabled =
true;
138 bool _introOngoing =
true;
139 bool _escPressed =
false;
140 bool _useOriginalSaveLoad =
true;
145 int _loadSaveSlot = -1;
154 byte _palette2[768] = {0};
155 Screen *_screen =
nullptr;
157 WWSurface *_backgroundScrollSurface =
nullptr;
160 GFTFont *_fontBit5x7 =
nullptr;
161 WWSurface *_roomAnimations[kRoomAnimationsCount] = {
nullptr};
177 byte *_walkMap =
nullptr;
178 int _scrollWidth = 0;
179 int _scrollRemaining = 0;
180 int _roomChangeCtr = 0;
181 int _scrollPosition = 0;
182 bool _doScrollRight =
false;
183 bool _hasRoomAnimationCallback =
false;
189 int _mouseX = 0, _mouseY = 0;
190 int _mouseClickY = 0, _mouseClickX = 0;
192 uint _mouseClickButtons = 0;
193 Common::KeyCode _keyCode = Common::KEYCODE_INVALID;
197 int _currentTextX = 0, _currentTextY = 0;
198 bool _isTextVisible =
false;
205 int _currentActorNum;
206 int _currentRoomNumber;
210 int _hoverObjectNumber;
211 int _firstObjectNumber;
215 bool _animationsRedrawBackground;
218 int _wayneSpriteX, _wayneSpriteY, _wayneKind, _wayneActorScale;
219 int _garthSpriteX, _garthSpriteY, _garthKind, _garthActorScale;
220 int _actorSpriteValue;
221 int _actorSpriteIndex;
222 WWSurface *_wayneSprites[8], *_wayneWalkSprites[8][4], *_wayneReachRightSprite, *_wayneReachLeftSprite;
223 WWSurface *_garthSprites[8], *_garthWalkSprites[8][4], *_garthReachRightSprite, *_garthReachLeftSprite;
224 WalkPoint _wayneWalkPoints[kWalkPointsCount];
225 WalkPoint _garthWalkPoints[kWalkPointsCount];
229 int _inventoryItemsCount;
230 int _inventoryItemsObjectMap[kInventorySize];
231 int _wayneInventory[kInventorySize];
232 int _garthInventory[kInventorySize];
235 int _selectedDialogChoice;
236 int _dialogChoices[5];
239 static const RoomObject kRoomObjects[kRoomObjectsCount];
248 WWSurface *_staticRoomObjectSprites[kStaticRoomObjectSpritesCount];
251 int _gameMapRoomNumber;
252 int _gameMapWayneSpriteX, _gameMapGarthSpriteX;
253 int _currentMapItemIndex;
254 int _gameMapDestinationRoomNum;
256 bool _gameMapHasPaletteHandler =
false;
258 uint32 _gameMapLastTicks = 0;
264 int getRandom(
int max);
265 void waitMillis(uint millis);
266 void waitSeconds(uint seconds);
269 void initMouseCursor();
270 bool isPointAtWayne(
int x,
int y);
271 bool isPointAtGarth(
int x,
int y);
272 void updateMouseMove();
273 void handleMouseClick();
274 void handleMouseLeftClick();
275 void handleMouseRightClick();
278 void loadPalette(
GxlArchive *lib,
const char *filename);
280 void paletteFadeIn(
int index,
int count,
int stepsSize);
281 void paletteFadeOut(
int index,
int count,
int stepsSize);
282 void paletteFadeColor(
int index, byte r, byte g, byte b,
int steps);
283 void handleMapPalette();
286 void drawImageToSurfaceIntern(
GxlArchive *lib,
const char *filename,
WWSurface *destSurface,
int x,
int y,
bool transparent);
287 void drawImageToScreenIntern(
GxlArchive *lib,
const char *filename,
int x,
int y,
bool transparent);
288 void drawImageToScreen(
GxlArchive *lib,
const char *filename,
int x,
int y);
289 void drawImageToSurface(
GxlArchive *lib,
const char *filename,
WWSurface *destSurface,
int x,
int y);
290 void drawRoomImageToBackground(
const char *filename,
int x,
int y);
291 void drawRoomImageToBackgroundTransparent(
const char *filename,
int x,
int y);
292 void drawRoomImageToScreen(
const char *filename,
int x,
int y);
293 void drawRoomImageToSurface(
const char *filename,
WWSurface *destSurface,
int x,
int y);
295 void drawSpiralEffect(
Graphics::Surface *surface,
int x,
int y,
int grainWidth,
int grainHeight);
296 void drawRandomEffect(
Graphics::Surface *surface,
int x,
int y,
int grainWidth,
int grainHeight);
299 Common::String loadString(
const char *filename,
int index,
int flag);
300 void drawCurrentTextToSurface(
WWSurface *destSurface,
int x,
int y);
301 void drawCurrentText(
int x,
int y,
WWSurface *destSurface);
302 void displayText(
const char *filename,
int index,
int flag,
int x,
int y,
int drawToVirtual);
303 void displayTextLines(
const char *filename,
int baseIndex,
int x,
int y,
int count);
306 void playSound(
const char *filename,
int flag);
311 void drawInterface(
int verbNum);
312 void selectVerbNumber2(
int x);
313 void selectVerbNumber(
int x);
315 void drawVerbLine(
int verbNumber,
int objectNumber,
const char *objectName);
316 void rememberFirstObjectName(
int objectId);
319 void redrawInventory();
320 void refreshInventory(
bool doRefresh);
321 void drawInventory();
322 void setWayneInventoryItemQuantity(
int objectId,
int quantity);
323 void setGarthInventoryItemQuantity(
int objectId,
int quantity);
324 int getWayneInventoryItemQuantity(
int objectId);
325 int getGarthInventoryItemQuantity(
int objectId);
328 void loadMainActorSprites();
329 void unloadMainActorSprites();
330 int getActorScaleFromY(
int actorY);
331 void drawActorReachObject(
int objectId,
int spriteIndex);
332 int drawActors(
int direction,
int wayneKind,
int garthKind,
int spriteIndex,
int wayneX,
int wayneY,
int garthX,
int garthY);
333 void refreshActors();
334 void pickupObject(
int objectId, byte &flags, byte flagsSet,
int inventoryObjectId);
335 void playAnimation(
const char *prefix,
int startIndex,
int count,
int x,
int y,
int flag, uint ticks);
336 void playAnimationLoops(
const char *prefix,
int startIndex,
int count,
int x,
int y,
int flag, uint ticks,
int loopCount);
337 void setWaynePosition(
int x,
int y);
338 void setGarthPosition(
int x,
int y);
341 void selectActorWayne();
342 void selectActorGarth();
346 bool walkIsPixelWalkable(
int x,
int y);
347 bool walkAdjustDestPoint(
int &x,
int &y);
348 void walkGetNextPoint(
int sourceX,
int sourceY,
int destX,
int destY,
int &nextX,
int &nextY);
349 void walkCalcOtherActorDest(
int flag,
int &x,
int &y);
350 int walkCalcPath(
int flag,
int sourceX,
int sourceY,
int destX,
int destY,
int pointsCount);
351 bool walkFindPoint(
int flag,
int &sourceX,
int &sourceY,
int &nextSourceX,
int &nextSourceY,
int destX,
int destY,
int pointsCount);
352 int walkAddWalkLine(
int flag,
int x1,
int y1,
int x2,
int y2,
int pointsCount);
353 bool walkTestPoint(
int sourceX,
int sourceY,
int nextSourceX,
int nextSourceY,
int destX,
int destY);
354 bool walkIsLineWalkable(
int sourceX,
int sourceY,
int destX,
int destY);
355 int walkCalcDirection(
int deltaX,
int deltaY);
356 bool walkTo(
int actor1_destX,
int actor1_destY,
int direction,
int actor2_destX,
int actor2_destY);
359 void setMouseBounds(
int x1,
int x2,
int y1,
int y2);
361 void openRoomLibrary(
int roomNum);
362 void openAlternateRoomLibrary(
const char *name);
363 void loadRoomBackground();
364 void changeRoom(
int roomNum);
365 void refreshRoomBackground(
int roomNum);
366 void handleRoomEvent();
367 void changeRoomScrolling();
368 void loadScrollSprite();
370 void loadRoomMask(
int roomNum);
371 void fillRoomMaskArea(
int x1,
int y1,
int x2,
int y2,
bool blocked);
374 void loadAnimationSpriteRange(
int baseIndex,
const char *filename,
int count);
375 void loadAnimationSprite(
int index,
const char *filename);
376 void drawAnimationSprite(
int index,
int x,
int y);
377 void drawAnimationSpriteTransparent(
int index,
int x,
int y);
378 void updateRoomAnimations();
379 void startRoomAnimations();
380 void stopRoomAnimations();
381 void updateAnimationTimers();
382 void setAnimationTimer(uint index, uint32 delay,
int initialCounter = 0);
383 bool isAnimationTimerExpired(uint index);
384 int getAnimationTimerCounter(uint index);
387 void initStaticRoomObjects();
388 void loadStaticRoomObjects(
int roomNum);
389 void unloadStaticRoomObjects();
390 void setStaticRoomObjectPosition(
int roomNum,
int fromIndex,
int toIndex,
int x,
int y);
391 void drawStaticRoomObjects(
int roomNum,
int x,
int y,
int actorHeight,
int actorWidth,
WWSurface *surface);
394 void initRoomObjects();
395 void moveObjectToRoom(
int objectId,
int roomNum);
396 void moveObjectToNowhere(
int objectId);
397 const RoomObject *getRoomObject(
int objectId);
398 const char *getRoomObjectName(
int objectId);
399 int getObjectRoom(
int objectId);
400 int getObjectDirection(
int objectId);
401 int findRoomObjectIdAtPoint(
int x,
int y);
406 void setDialogChoices(
int choice1,
int choice2,
int choice3,
int choice4,
int choice5);
407 void drawDialogChoices(
int choiceIndex);
408 void handleDialogMouseClick();
411 void handleVerb(
int verbFlag);
412 void handleVerbPickUp();
413 void handleVerbLookAt();
414 void handleVerbUse();
415 void handleVerbTalkTo();
416 void handleVerbPush();
417 void handleVerbPull();
418 void handleVerbExtremeCloseupOf();
419 void handleVerbGive();
420 void handleVerbOpen();
421 void handleVerbClose();
423 void lookAtUnusedTicket();
424 void unusedTicketHandleMouseMove();
425 void unusedTicketHandleMouseClick();
427 void extremeCloseUpHandleMouseClick();
430 void gameMapFinish();
431 void gameMapHandleMouseMove(
int objectNumber);
432 void gameMapHandleMouseClick();
433 void gameMapSelectItem(
const char *prefix,
int animX,
int animY);
435 void gameMapPaletteHandlerStart();
436 void gameMapPaletteHandlerStop();
440 enum kReadSaveHeaderError {
442 kRSHEInvalidType = 1,
443 kRSHEInvalidVersion = 2,
465 #endif // WAYNESWORLD_H
EngineFeature
Definition: engine.h:258
Definition: savefile.h:54
Definition: waynesworld.h:63
Definition: graphics.h:30
Definition: gamelogic.h:30
Definition: detection.h:25
Definition: waynesworld.h:80
Definition: advancedDetector.h:164
Definition: waynesworld.h:112
Definition: waynesworld.h:75
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: waynesworld.h:124
Definition: atari-screen.h:58
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: waynesworld.h:127
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: graphics.h:45
Definition: gxlarchive.h:44
Definition: graphics.h:65
Definition: waynesworld.h:71
Definition: waynesworld.h:84