ScummVM API documentation
scumm.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCUMM_SCUMM_H
23#define SCUMM_SCUMM_H
24
25#include "engines/engine.h"
26
27#include "common/endian.h"
28#include "common/events.h"
29#include "common/file.h"
30#include "common/savefile.h"
31#include "common/keyboard.h"
32#include "common/mutex.h"
33#include "common/random.h"
34#include "common/rect.h"
35#include "common/rendermode.h"
36#include "common/str.h"
37#include "common/textconsole.h"
38#include "common/text-to-speech.h"
39#include "graphics/surface.h"
40#include "graphics/sjis.h"
41#include "graphics/palette.h"
42
43#include "scumm/file.h"
44#include "scumm/gfx.h"
45#include "scumm/detection.h"
46#include "scumm/script.h"
47#include "scumm/serializer.h"
48
49#ifdef __DS__
50/* This disables the dual layer mode which is used in FM-Towns versions
51 * of SCUMM games and which emulates the behavior of the original code.
52 * The only purpose is code size reduction for certain backends.
53 * SCUMM 3 (FM-Towns) games will run in English in normal (DOS VGA) mode,
54 * which should work just fine in most situations. Some glitches might
55 * occur. Japanese mode and SCUMM 5 FM-Towns games will not work without
56 * dual layer (and 16 bit color) support.
57 */
58#define DISABLE_TOWNS_DUAL_LAYER_MODE
59#endif
60
61namespace GUI {
62class Dialog;
63}
64using GUI::Dialog;
65namespace Common {
66class SeekableReadStream;
67class WriteStream;
68class SeekableWriteStream;
69}
70namespace Graphics {
71class FontSJIS;
72}
73
86namespace Scumm {
87
88class Actor;
89class BaseCostumeLoader;
90class BaseCostumeRenderer;
91class BaseScummFile;
92class CharsetRenderer;
93class IMuse;
94class IMuseDigital;
95class MacGui;
96class MusicEngine;
97class Player_Towns;
98class ScummEngine;
99class ScummDebugger;
100class Sound;
101class Localizer;
102class GlyphRenderer_v7;
103
104struct Box;
105struct BoxCoords;
106struct FindObjectInRoom;
107
108// Use g_scumm from error() ONLY
109extern ScummEngine *g_scumm;
110
111/* System Wide Constants */
112enum {
113 NUM_SENTENCE = 6,
114 NUM_SHADOW_PALETTE = 8
115};
116
117/* SCUMM Debug Channels */
118void debugC(int level, MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
119
120struct VerbSlot;
121struct ObjectData;
122
123enum {
131
137
144
153 //
155
156enum {
157 MBS_LEFT_CLICK = 0x8000,
158 MBS_RIGHT_CLICK = 0x4000,
159 MBS_MOUSE_MASK = (MBS_LEFT_CLICK | MBS_RIGHT_CLICK),
160 MBS_MAX_KEY = 0x0200
161};
162
164 byte verb;
165 byte preposition;
166 uint16 objectA;
167 uint16 objectB;
168 uint8 freezeCount;
169};
170
172 int16 xpos;
173 int16 ypos;
174 int16 right;
175 int16 height;
176 byte color;
177 byte charset;
178 bool center;
179 bool overhead;
180 bool no_talk_anim;
181 bool wrapping;
182};
183
185 // The 'default' values for this string slot. This is used so that the
186 // string slot can temporarily be set to different values, and then be
187 // easily reset to a previously set default.
188 StringSlot _default;
189
190 void saveDefault() {
191 StringSlot &s = *this;
192 _default = s;
193 }
194
195 void loadDefault() {
196 StringSlot &s = *this;
197 s = _default;
198 }
199};
200
202 bool _screenScroll;
203 uint _objectRedrawCount;
204 uint _objectStripRedrawCount;
205 uint _actorRedrawCount;
206 uint _actorLimbRedrawDrawCount;
207
208};
209
210enum WhereIsObject {
211 WIO_NOT_FOUND = -1,
212 WIO_INVENTORY = 0,
213 WIO_ROOM = 1,
214 WIO_GLOBAL = 2,
215 WIO_LOCAL = 3,
216 WIO_FLOBJECT = 4
217};
218
220 uint32 date;
221 uint16 time;
222 uint32 playtime;
223};
224
225enum UserStates {
226 USERSTATE_SET_FREEZE = 0x01, // freeze scripts if USERSTATE_FREEZE_ON is set, unfreeze otherwise
227 USERSTATE_SET_CURSOR = 0x02, // shows cursor if USERSTATE_CURSOR_ON is set, hides it otherwise
228 USERSTATE_SET_IFACE = 0x04, // change user-interface (sentence-line, inventory, verb-area)
229 USERSTATE_FREEZE_ON = 0x08, // only interpreted if USERSTATE_SET_FREEZE is set
230 USERSTATE_CURSOR_ON = 0x10, // only interpreted if USERSTATE_SET_CURSOR is set
231 USERSTATE_IFACE_SENTENCE = 0x20, // only interpreted if USERSTATE_SET_IFACE is set
232 USERSTATE_IFACE_INVENTORY = 0x40, // only interpreted if USERSTATE_SET_IFACE is set
233 USERSTATE_IFACE_VERBS = 0x80 // only interpreted if USERSTATE_SET_IFACE is set
234};
235
236#define USERSTATE_IFACE_ALL (USERSTATE_IFACE_SENTENCE | USERSTATE_IFACE_INVENTORY | USERSTATE_IFACE_VERBS)
237
244 rtInvalid = 0,
245 rtFirst = 1,
246 rtRoom = 1,
247 rtScript = 2,
248 rtCostume = 3,
249 rtSound = 4,
250 rtInventory = 5,
251 rtCharset = 6,
252 rtString = 7,
253 rtVerb = 8,
254 rtActorName = 9,
255 rtBuffer = 10,
256 rtScaleTable = 11,
257 rtTemp = 12,
258 rtFlObject = 13,
259 rtMatrix = 14,
260 rtBox = 15,
261 rtObjectName = 16,
262 rtRoomScripts = 17,
263 rtRoomImage = 18,
264 rtImage = 19,
265 rtTalkie = 20,
266 rtSpoolBuffer = 21,
267 rtLast = 21
268};
269
270typedef uint16 ResId;
271
272class ResourceManager;
273
314#define PIT_BASE_FREQUENCY 1193182.0 // In Hz
315#define PIT_V1_DIVISOR 65536.0
316#define PIT_V2_4_DIVISOR 5041.0
317#define PIT_V5_6_ORCHESTRATOR_DIVISOR 4096.0
318#define PIT_V5_6_SUBTIMER_INC 3433.0
319#define PIT_V5_SUBTIMER_THRESH 4167.0
320#define PIT_V6_SAMNMAX_SUBTIMER_THRESH 4167.0
321#define PIT_V6_DOTT_SUBTIMER_THRESH 4237.0
322#define PIT_V7_ORCHESTRATOR_DIVISOR 3977.0
323#define PIT_V7_SUBTIMER_INC 3977.0
324#define PIT_V7_SUBTIMER_THRESH 4971.0
325
326#define PIT_HE_PUTT_PUTT_DIVISOR 9362.0
327#define PIT_HE_FATTY_BEAR_DIVISOR 21845.0
328
329#define LOOM_STEAM_CDDA_RATE 240.0
330
344#define AMIGA_NTSC_VBLANK_RATE 240.0
345#define AMIGA_PAL_VBLANK_RATE 200.0
346
356#define C64_NTSC_VBLANK_RATE 240.0
357#define C64_PAL_VBLANK_RATE 200.0
358
363#define GAME_PROPER_SAVE 201
364#define GAME_FAILED_SAVE 202
365#define GAME_PROPER_LOAD 203
366#define GAME_FAILED_LOAD 204
367
372#define GUI_PAGE_MAIN 0
373#define GUI_PAGE_SAVE 1
374#define GUI_PAGE_LOAD 2
375#define GUI_PAGE_RESTART 3 // Sega CD
376#define GUI_PAGE_CODE_CONFIRM 4 // Sega CD
377#define GUI_PAGE_INVALID_CODE 5 // Sega CD
378
379#define GUI_CTRL_FIRST_SG 1
380#define GUI_CTRL_LAST_SG 9
381#define GUI_CTRL_SAVE_BUTTON 10
382#define GUI_CTRL_LOAD_BUTTON 11
383#define GUI_CTRL_PLAY_BUTTON 12
384#define GUI_CTRL_QUIT_BUTTON 13
385#define GUI_CTRL_OK_BUTTON 14
386#define GUI_CTRL_CANCEL_BUTTON 15
387#define GUI_CTRL_ARROW_UP_BUTTON 16
388#define GUI_CTRL_ARROW_DOWN_BUTTON 17
389#define GUI_CTRL_PATH_BUTTON 18
390#define GUI_CTRL_MUSIC_SLIDER 19
391#define GUI_CTRL_SPEECH_SLIDER 20
392#define GUI_CTRL_SFX_SLIDER 21
393#define GUI_CTRL_TEXT_SPEED_SLIDER 22
394#define GUI_CTRL_DISPLAY_TEXT_CHECKBOX 23
395#define GUI_CTRL_SPOOLED_MUSIC_CHECKBOX 24
396#define GUI_CTRL_OUTER_BOX 26
397#define GUI_CTRL_INNER_BOX 27
398
399// Sega CD
400#define GUI_CTRL_NUMPAD_1 1
401#define GUI_CTRL_NUMPAD_2 2
402#define GUI_CTRL_NUMPAD_3 3
403#define GUI_CTRL_NUMPAD_4 4
404#define GUI_CTRL_NUMPAD_5 5
405#define GUI_CTRL_NUMPAD_6 6
406#define GUI_CTRL_NUMPAD_7 7
407#define GUI_CTRL_NUMPAD_8 8
408#define GUI_CTRL_NUMPAD_9 9
409#define GUI_CTRL_NUMPAD_0 10
410#define GUI_CTRL_RESTART_BUTTON 13
411#define GUI_CTRL_ARROW_LEFT_BUTTON 16
412#define GUI_CTRL_ARROW_RIGHT_BUTTON 17
413#define GUI_CTRL_NUMPAD_BACK 23
414
415enum GUIString {
416 gsPause = 0,
417 gsVersion = 1,
418 gsTextSpeedSlider = 2,
419 gsRestart = 3,
420 gsQuitPrompt = 4,
421 gsSave = 5,
422 gsLoad = 6,
423 gsPlay = 7,
424 gsCancel = 8,
425 gsQuit = 9,
426 gsOK = 10,
427 gsMustName = 11,
428 gsGameNotSaved = 12,
429 gsGameNotLoaded = 13,
430 gsSaving = 14,
431 gsLoading = 15,
432 gsNamePrompt = 16,
433 gsSelectLoadPrompt = 17,
434 gsReplacePrompt = 18,
435 gsYes = 20,
436 gsNo = 21,
437 gsIMuseBuffer = 22,
438 gsVoiceAndText = 23,
439 gsTextDisplayOnly = 24,
440 gsVoiceOnly = 25,
441 gsYesKey = 26,
442 gsMusicVolumeSlider = 27,
443 gsVoiceVolumeSlider = 28,
444 gsSfxVolumeSlider = 29,
445 gsHeap = 30,
446 gsSavePath = 31,
447 gsTitle = 32,
448 gsDisabled = 33,
449 gsMusic = 34,
450 gsVoice = 35,
451 gsSfx = 36,
452 gsTextSpeed = 37,
453 gsDisplayText = 38,
454 gsSpooledMusic = 39,
455 gsInsertSaveDisk = 40,
456 gsSnapOn = 41,
457 gsSnapOff = 42,
458 gsRecalJoystick = 43,
459 gsMouseMode = 44,
460 gsMouseOn = 45,
461 gsMouseOff = 46,
462 gsJoystickOn = 47,
463 gsJoystickOff = 48,
464 gsSoundsOn = 49,
465 gsSoundsOff = 50,
466 gsVGAMode = 51,
467 gsEGAMode = 52,
468 gsCGAMode = 53,
469 gsHerculesMode = 54,
470 gsTandyMode = 55,
471 gsCurrentPasscode = 56,
472 gsEnterPasscode = 57,
473 gsConfirmPasscode = 58,
474 gsInvalidPasscode = 59,
475 gsSlowFast = 60,
476 gsRestartGame = 61,
477 gsHeapExt = 62,
478};
479
481 int relativeCenterX;
482 int relativeCenterY;
483 int xPos;
484 int yPos;
485 int normalFillColor;
486 int topLineColor;
487 int bottomLineColor;
488 int leftLineColor;
489 int rightLineColor;
490 int normalTextColor;
491 int highlightedTextColor;
492 int highlightedFillColor;
493 bool centerText;
494 Common::String label;
495#ifdef USE_TTS
496 Common::String alternateTTSLabel;
497#endif
498 bool doubleLinesFlag;
499};
500
501enum ScummAction {
502 kScummActionNone,
503 kScummActionInsaneDownLeft,
504 kScummActionInsaneDown,
505 kScummActionInsaneDownRight,
506 kScummActionInsaneLeft,
507 kScummActionInsaneRight,
508 kScummActionInsaneUpLeft,
509 kScummActionInsaneUp,
510 kScummActionInsaneUpRight,
511 kScummActionInsaneAttack,
512 kScummActionInsaneSwitch,
513 kScummActionInsaneCheat,
514 kScummActionInsaneBack,
515 kScummActionInsaneSkip,
516
517 kScummActionCount
518};
519
520enum ScummBackendAction {
521 kScummBackendActionRebel1AxisUp = 11000,
522 kScummBackendActionRebel1AxisDown,
523 kScummBackendActionRebel1AxisLeft,
524 kScummBackendActionRebel1AxisRight,
525 kScummBackendActionRebel2AxisUp,
526 kScummBackendActionRebel2AxisDown,
527 kScummBackendActionRebel2AxisLeft,
528 kScummBackendActionRebel2AxisRight
529};
530
531extern const char *const insaneKeymapId;
532
537 friend class ScummDebugger;
538 friend class CharsetRenderer;
539 friend class CharsetRendererClassic;
540 friend class CharsetRendererTownsClassic;
541 friend class ResourceManager;
542 friend class MacGuiImpl;
543 friend class MacIndy3Gui;
544 friend class MacLoomGui;
545 friend class MacV5Gui;
546 friend class MacV6Gui;
547 friend class LogicHEBasketball;
548 friend class ScummEditor;
549
550public:
551 /* Put often used variables at the top.
552 * That results in a shorter form of the opcode
553 * on some architectures. */
554 IMuse *_imuse = nullptr;
555 IMuseDigital *_imuseDigital = nullptr;
556 MusicEngine *_musicEngine = nullptr;
557 Player_Towns *_townsPlayer = nullptr;
558 Sound *_sound = nullptr;
559
560 VerbSlot *_verbs = nullptr;
561 ObjectData *_objs = nullptr;
562
563 // Core variables
564 GameSettings _game;
565 uint8 _gameMD5[16];
566
569
571 Gdi *_gdi = nullptr;
572
575 int _insideCreateResource = 0; // Counter for HE sound
576
577 bool _useOriginalGUI = true;
578 bool _enableAudioOverride = false;
579 bool _enableCOMISong = false;
580 bool _isAmigaPALSystem = false;
581 bool _isC64PALSystem = false;
582 bool _quitFromScriptCmd = false;
583 bool _isHE995 = false;
584 bool _enableHECompetitiveOnlineMods = false;
585
586 Common::Keymap *_insaneKeymap;
587
588protected:
590
591 bool _needsSoundUnpause = false;
592
593public:
594 // Constructor / Destructor
595 ScummEngine(OSystem *syst, const DetectorResult &dr);
596 ~ScummEngine() override;
597
598 // Engine APIs
599 Common::Error init();
600 Common::Error go();
601 Common::Error run() override {
602 Common::Error err;
603 err = init();
604 if (err.getCode() != Common::kNoError)
605 return err;
606 return go();
607 }
608
609 void errorString(const char *buf_input, char *buf_output, int buf_output_size) override;
610 bool hasFeature(EngineFeature f) const override;
611 bool gameSupportsQuitDialogOverride() const;
612 void syncSoundSettings() override;
613
614 Common::Error loadGameState(int slot) override;
615 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
616 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
617 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
618 Common::String getSaveStateName(int slot) const override { return makeSavegameName(slot, false); }
619
620 void pauseEngineIntern(bool pause) override;
621
622protected:
623 virtual void setupScumm(const Common::Path &macResourceFile);
624 virtual void resetScumm();
625
626 virtual void setupScummVars();
627 virtual void resetScummVars();
628 void setVideoModeVarToCurrentConfig();
629 void setSoundCardVarToCurrentConfig();
630
631 void setupCharsetRenderer(const Common::Path &macFontFile);
632 void setupCostumeRenderer();
633
634 virtual void loadLanguageBundle();
635 void loadCJKFont();
636 void loadKorFont();
637 void setupMusic(int midi);
638 void setTalkSpeed(int talkspeed);
639 int getTalkSpeed();
640
641 // Scumm main loop & helper functions.
642 virtual void scummLoop(int delta);
643 virtual void scummLoop_updateScummVars();
644 virtual void scummLoop_handleSaveLoad();
645 virtual void scummLoop_handleDrawing();
646 virtual void scummLoop_handleActors() = 0;
647 virtual void scummLoop_handleEffects();
648 virtual void scummLoop_handleSound();
649
650 virtual void runBootscript();
651
652 virtual void terminateSaveMenuScript() {};
653
654 // Event handling
655public:
656 void beginTextInput();
657 void endTextInput();
658
659 void parseEvents(); // Used by IMuseDigital::startSound
660protected:
661 virtual void parseEvent(Common::Event event);
662
663 void waitForTimer(int quarterFrames, bool freezeMacGui = false);
664 uint32 _lastWaitTime;
665
666 void setTimerAndShakeFrequency();
667
673 uint32 getIntegralTime(double fMsecs);
674 double _msecFractParts = 0.0;
675
676 virtual void processInput();
677 virtual void processKeyboard(Common::KeyState lastKeyHit);
678 virtual void clearClickedStatus();
679
680 // Cursor/palette
681 virtual void updateCursor();
682 virtual void animateCursor() {}
683 virtual void updatePalette();
684 virtual void setDefaultCursor() {};
685 virtual void setCursorTransparency(int a) {};
686 virtual void resetCursors() {}
687 virtual void setCursorHotspot(int x, int y) {}
688 virtual void setCursorFromBuffer(const byte *ptr, int width, int height, int pitch, bool preventScale = false) {}
689
690public:
691 void pauseGame();
692 void restart();
693 bool isUsingOriginalGUI() const;
694 bool isMessageBannerActive(); // For Indy4 Jap character shadows
695
696 bool _isIndy4Jap = false;
697
698protected:
699 Dialog *_pauseDialog = nullptr;
700 Dialog *_messageDialog = nullptr;
701 Dialog *_versionDialog = nullptr;
702
703 void confirmExitDialog();
704 void confirmRestartDialog();
705 void pauseDialog();
706 void messageDialog(const Common::U32String &message);
707 void versionDialog();
708
709 // Original GUI
710 int32 _bannerColors[50]; // Colors for the original GUI
711 byte *_bannerMem = nullptr;
712 uint32 _bannerMemSize = 0;
713 int _bannerSaveYStart = 0;
714
715 bool _messageBannerActive = false;
716 bool _comiQuitMenuIsOpen = false;
717 bool _closeBannerAndQueryQuitFlag = false;
718
719 // The followings are needed for MI1 FM-Towns
720 byte *_textSurfBannerMem = nullptr;
721 uint32 _textSurfBannerMemSize = 0;
722
723 InternalGUIControl _internalGUIControls[30];
724
725 // Special GUI strings
726 const char _emptyMsg[1] = {'\0'};
727 const char _uncheckedBox[2] = {' ', '\0'};
728 const char _checkedBox[2] = {'x', '\0'};
729 const char _arrowUp[2] = {'\x18', '\0'};
730 const char _arrowDown[2] = {'\x19', '\0'};
731 const char _arrowLeft[2] = {'\x3c', '\0'};
732 const char _arrowRight[2] = {'\x3d', '\0'};
733
734 Common::StringArray _savegameNames;
735 int _menuPage = 0;
736 int _mainMenuSavegameLabel = 1;
737 int _curDisplayedSaveSlotPage = 0;
738 int _firstSaveStateOfList = 0; // For LOOM VGA
739 bool _mainMenuIsActive = false;
740 bool _quitByGUIPrompt = false;
741 char _mainMenuMusicSlider[17];
742 char _mainMenuSpeechSlider[17];
743 char _mainMenuSfxSlider[17];
744 char _mainMenuTextSpeedSlider[17];
745 char _mainMenuSegaCDPasscode[5];
746 int _spooledMusicIsToBeEnabled = 1;
747 int _saveScriptParam = 0;
748 int _guiCursorAnimCounter = 0;
749 int _v5VoiceMode = 0;
750
751 // Fake flags just for sub v5 GUIs
752 int _internalSpeakerSoundsAreOn = 1;
753 int _guiMouseFlag = 1;
754 int _guiJoystickFlag = 1;
755
756 bool _mixerMutedByGUI = false;
757
758 Graphics::Surface _savegameThumbnail;
759 byte *_tempTextSurface = nullptr;
760 byte *_tempMainSurface = nullptr;
761 byte *_tempVerbSurface = nullptr;
762 bool _postGUICharMask = false;
763
764 // Saved cursor pre and post GUI
765 byte *_curGrabbedCursor = nullptr;
766 int8 _oldCursorState = 0;
767 int _curCursorState = 0;
768 int _curCursorWidth = 0;
769 int _curCursorHeight = 0;
770 int _curCursorHotspotX = 0;
771 int _curCursorHotspotY = 0;
772
773 virtual void setSnailCursor() {}
774
775 void initBanners();
776 Common::KeyState showBannerAndPause(int bannerId, int32 waitTime, const char *msg, ...);
777 bool showBannerAndPauseForTextInput(int bannerId, const char *prompt, Common::String &input, uint maxLength = 255);
778 Common::KeyState showOldStyleBannerAndPause(const char *msg, int color, int32 waitTime);
779 Common::KeyState printMessageAndPause(const char *msg, int color, int32 waitTime, bool drawOnSentenceLine);
780
781 void clearBanner();
782 void setBannerColors(int bannerId, byte r, byte g, byte b);
783 virtual int getBannerColor(int bannerId);
784 void setUpInternalGUIControl(int id, int normalFillColor, int normalTextColor,
785 int topLineColor, int bottomLineColor, int leftLineColor, int rightLineColor,
786 int highlightedTextColor, int highlightedFillColor,
787 int anchorPointX, int anchorPointY, int x, int y, const char *label, bool centerFlag, bool unknownFlag);
788 void drawInternalGUIControl(int id, bool highlightColor);
789 int getInternalGUIControlFromCoordinates(int x, int y);
790 virtual bool isSmushActive() { return false; }
791 virtual bool isInsaneActive() { return false; }
792
793 virtual void queryQuit(bool returnToLauncher);
794 virtual void queryRestart();
795 virtual const char *getGUIString(int stringId);
796 void waitForBannerInput(int32 waitTime, Common::KeyState &ks, bool &leftBtnClicked, bool &rightBtnClicked, bool handleMouseWheel = false);
797 virtual int getGUIStringHeight(const char *str);
798 virtual int getGUIStringWidth(const char *str);
799 virtual void drawGUIText(const char *buttonString, Common::Rect *clipRect, int textXPos, int textYPos, int textColor, bool centerFlag);
800 void getSliderString(int stringId, int value, char *sliderString, int size);
801 virtual int getMusicVolume();
802 virtual int getSpeechVolume();
803 virtual int getSFXVolume();
804 virtual void setMusicVolume(int volume);
805 virtual void setSpeechVolume(int volume);
806 virtual void setSFXVolume(int volume);
807 virtual void toggleVoiceMode();
808 virtual void handleLoadDuringSmush() {}
809 virtual void setSkipVideo(int value) {}
810
811 void showMainMenu();
812 virtual void setUpMainMenuControls();
813 void setUpMainMenuControlsSegaCD();
814 void setUpMainMenuControlsIndy4Jap();
815 void drawMainMenuControls();
816 void drawMainMenuControlsSegaCD();
817 void updateMainMenuControls();
818 void updateMainMenuControlsSegaCD();
819 void drawMainMenuTitle(const char *title);
820 bool executeMainMenuOperation(int op, int mouseX, int mouseY, bool &hasLoadedState);
821 bool executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY, bool &hasLoadedState);
822 bool shouldHighlightLabelAndWait(int clickedControl);
823 void fillSavegameLabels();
824 bool canWriteGame(int slotId);
825 bool userWriteLabelRoutine(Common::KeyState &ks, bool &leftMsClicked, bool &rightMsClicked);
826 void saveCursorPreMenu();
827 void restoreCursorPostMenu();
828 void saveSurfacesPreGUI();
829 void restoreSurfacesPostGUI();
830 void showDraftsInventory();
831 void setUpDraftsInventory();
832 void drawDraftsInventory();
833
834public:
835 char displayMessage(MSVC_PRINTF const char *message, ...) GCC_PRINTF(2, 3);
836 bool displayMessageYesNo(MSVC_PRINTF const char *message, ...) GCC_PRINTF(2, 3);
837 bool displayMessageOKQuit(MSVC_PRINTF const char *message, ...) GCC_PRINTF(2, 3);
838
839protected:
840 byte _fastMode = 0;
841
842 byte _numActors = 0;
843 Actor **_actors = nullptr; // Has _numActors elements
844 Actor **_sortedActors = nullptr;
845
846 byte *_arraySlot = nullptr;
847 uint16 *_inventory = nullptr;
848 uint16 *_newNames = nullptr;
849public:
850 // VAR is a wrapper around scummVar, which attempts to include additional
851 // useful information should an illegal var access be detected.
852 #define VAR(x) scummVar(x, #x, __FILE__, __LINE__)
853 int32& scummVar(byte var, const char *varName, const char *file, int line) {
854 if (var == 0xFF) {
855 error("Illegal access to variable %s in file %s, line %d", varName, file, line);
856 }
857 return _scummVars[var];
858 }
859 int32 scummVar(byte var, const char *varName, const char *file, int line) const {
860 if (var == 0xFF) {
861 error("Illegal access to variable %s in file %s, line %d", varName, file, line);
862 }
863 return _scummVars[var];
864 }
865
866 bool applyMi2NiDemoOverride();
867 struct Playback {
868 struct FrameEvent {
869 bool hasPos = false;
870 uint16 x = 0;
871 uint16 y = 0;
872
873 uint16 mbs = 0;
874 uint16 key = 0;
875 };
876
877 static void parseStream(const Common::Array<byte> &stream, Common::Array<FrameEvent> &outEvents);
878
879 bool _loaded = false;
880 bool _attempted = false;
881 bool _active = false;
882
883 bool _mi2DemoVarsApplied = false;
884
886
887 uint32 _streamOff = 0;
888 uint32 _streamBytes = 0;
889
890 uint32 _nextIndex = 0;
891 int _lastRoom = -1;
892
893 bool _hasPrevMbs = false;
894 uint16 _prevMbs = 0;
895 uint32 _firstInteractIndex = 0;
896 bool _firstInteractValid = false;
897
898 int16 _curX = 0;
899 int16 _curY = 0;
900 bool _pendingLUp = false;
901 bool _pendingRUp = false;
902
903 bool _sputmCmdActive = false;
904 byte _sputmCmdEnterCount = 0;
905 Common::String _sputmCmdBuf;
906 Common::String _name;
907
908 void reset();
909 bool tryLoadPlayback(ScummEngine *engine, const Common::Path &path = Common::Path("demo.rec"));
910 bool startPlayback(ScummEngine *engine);
911 void playbackPump(ScummEngine *engine);
912
913 //MI2 DOS NI Demo specific playback helpers
914 void mi2DemoArmPlaybackByRoom(ScummEngine *engine);
915 void mi2DemoPlaybackJumpRoom(ScummEngine *engine, int room);
916 bool handleMi2NIDemoSputmDebugKey(ScummEngine *engine, uint16 rawKey);
917 };
918
919 Playback _playback;
920
921protected:
922 int16 _varwatch = 0;
923 int32 *_roomVars = nullptr;
924 int32 *_scummVars = nullptr;
925 byte *_bitVars = nullptr;
926
927 /* Global resource tables */
928 int _numVariables = 0;
929 int _numBitVariables = 0;
930 int _numLocalObjects = 0;
931 int _numGlobalObjects = 0;
932 int _numArray = 0;
933 int _numVerbs = 0;
934 int _numFlObject = 0;
935 int _numInventory = 0;
936 int _numNewNames = 0;
937 int _numGlobalScripts = 0;
938 int _numRoomVariables = 0;
939 int _numPalettes = 0;
940 int _numSprites = 0;
941 int _numTalkies = 0;
942 int _numWindows = 0;
943 int _HEHeapSize = 0;
944
945public:
946 int _numLocalScripts = 60, _numImages = 0, _numRooms = 0, _numScripts = 0, _numSounds = 0; // Used by HE games
947 int _numCostumes = 0; // FIXME - should be protected, used by Actor::remapActorPalette
948 int32 _numCharsets = 0; // FIXME - should be protected, used by CharsetRenderer
949
950 BaseCostumeLoader *_costumeLoader = nullptr;
951 BaseCostumeRenderer *_costumeRenderer = nullptr;
952
953 int _NESCostumeSet = 0;
954 void NES_loadCostumeSet(int n);
955 byte *_NEScostdesc = nullptr, *_NEScostlens = nullptr, *_NEScostoffs = nullptr, *_NEScostdata = nullptr;
956 byte _NESPatTable[2][4096];
957 byte _NESPalette[2][16];
958 byte _NESBaseTiles = 0;
959
960 int _NESStartStrip = 0;
961
962protected:
963 int _curPalIndex = 0;
964
965public:
966 byte _currentRoom = 0; // FIXME - should be protected but Actor::isInCurrentRoom uses it
967 int _roomResource = 0; // FIXME - should be protected but Sound::pauseSounds uses it
968 bool _egoPositioned = false; // Used by Actor::putActor, hence public
969
970 FilenamePattern _filenamePattern;
971
972 virtual Common::Path generateFilename(const int room) const;
973
974protected:
975 Common::KeyState _keyPressed;
976 bool _keyDownMap[512]; // FIXME - 512 is a guess. it's max(kbd.ascii)
977 bool _actionMap[kScummActionCount];
978
979 Common::Point _mouse;
980 Common::Point _virtualMouse;
981
982 uint16 _mouseAndKeyboardStat = 0;
983 byte _leftBtnPressed = 0, _rightBtnPressed = 0;
984
985 int _mouseWheelFlag = 0; // For original save/load dialog only
986
987 bool _setupIsComplete = false;
988
994
996 int _bootParam = 0;
997
998 // Various options useful for debugging
999 bool _dumpScripts = false;
1000 bool _hexdumpScripts = false;
1001 bool _showStack = false;
1002 bool _debugMode = false;
1003
1004 // Save/Load class - some of this may be GUI
1005 byte _saveLoadFlag = 0, _saveLoadSlot = 0;
1006 uint32 _lastSaveTime = 0;
1007 bool _saveTemporaryState = false;
1008 bool _pauseSoundsDuringSave = true;
1009 bool _loadFromLauncher = false;
1010 bool _videoModeChanged = false;
1011 Common::String _saveLoadFileName;
1012 Common::String _saveLoadDescription;
1013
1014 bool saveState(Common::SeekableWriteStream *out, bool writeHeader = true);
1015 bool saveState(int slot, bool compat, Common::String &fileName);
1016 bool loadState(int slot, bool compat);
1017 bool loadState(int slot, bool compat, Common::String &fileName);
1018 void saveLoadWithSerializer(Common::Serializer &s) override;
1019 void saveResource(Common::Serializer &ser, ResType type, ResId idx);
1020 void loadResource(Common::Serializer &ser, ResType type, ResId idx);
1021 void loadResourceOLD(Common::Serializer &ser, ResType type, ResId idx); // "Obsolete"
1022
1023 virtual int checkSoundEngineSaveDataSize(Serializer &s);
1024
1025 void copyHeapSaveGameToFile(int slot, const char *saveName);
1026 bool changeSavegameName(int slot, char *newName);
1027 virtual Common::SeekableReadStream *openSaveFileForReading(int slot, bool compat, Common::String &fileName);
1028 virtual Common::SeekableWriteStream *openSaveFileForWriting(int slot, bool compat, Common::String &fileName);
1029
1030 Common::String makeSavegameName(int slot, bool temporary) const {
1031 return makeSavegameName(_targetName, slot, temporary);
1032 }
1033
1034 int getKeyState(int key);
1035 int getActionState(ScummAction action);
1036
1037public:
1038 static Common::String makeSavegameName(const Common::String &target, int slot, bool temporary);
1039
1040 bool getSavegameName(int slot, Common::String &desc);
1041 void listSavegames(bool *marks, int num);
1042
1043 void requestSave(int slot, const Common::String &name);
1044 void requestLoad(int slot);
1045
1046 Common::String getTargetName() const { return _targetName; }
1047 bool canPauseSoundsDuringSave() const { return _pauseSoundsDuringSave; }
1048
1049// thumbnail + info stuff
1050public:
1051 static bool querySaveMetaInfos(const char *target, int slot, int heversion, Common::String &desc, Graphics::Surface *&thumbnail, SaveStateMetaInfos *&timeInfos);
1052
1053protected:
1054 void saveInfos(Common::WriteStream *file);
1055 static bool loadInfos(Common::SeekableReadStream *file, SaveStateMetaInfos *stuff);
1056
1057 /* Script VM - should be in Script class */
1058 uint32 _localScriptOffsets[1024];
1059 Common::HashMap<int, byte *> _scriptOverrides;
1060 const byte *_scriptPointer = nullptr;
1061 const byte *_scriptOrgPointer = nullptr;
1062 const byte * const *_lastCodePtr = nullptr;
1063 byte _opcode = 0;
1064 bool _debug = false;
1065 byte _currentScript = 0xFF; // Let debug() work on init stage
1066 int _scummStackPos = 0;
1067 int _vmStack[256];
1068
1069 char _engineVersionString[50];
1070 char _dataFileVersionString[50];
1071
1072 OpcodeEntry _opcodes[256];
1073
1078 bool currentScriptSlotIs(uint16 script) const {
1079 return _currentScript != 0xFF && vm.slot[_currentScript].number == script;
1080 }
1081
1082 virtual void setupOpcodes() = 0;
1083 void executeOpcode(byte i);
1084 const char *getOpcodeDesc(byte i);
1085
1086 void initializeLocals(int slot, int *vars);
1087 int getScriptSlot();
1088
1089 void startScene(int room, Actor *a, int b);
1090 bool startManiac();
1091
1092public:
1093 void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0);
1094 void stopScript(int script);
1095 void nukeArrays(byte scriptSlot);
1096
1097protected:
1098 void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1, int cycle = 0);
1099 void runScriptNested(int script);
1100 void executeScript();
1101 void updateScriptPtr();
1102 virtual void runInventoryScript(int i);
1103 virtual void runInventoryScriptEx(int i);
1104 virtual void checkAndRunSentenceScript();
1105 bool monkey1HermanNoteWorkaround(const SentenceTab &st);
1106 void runExitScript();
1107 void runEntryScript();
1108 void runQuitScript();
1109 void runAllScripts();
1110 void freezeScripts(int scr);
1111 void unfreezeScripts();
1112
1113 bool isScriptInUse(int script) const;
1114 bool isRoomScriptRunning(int script) const;
1115 bool isScriptRunning(int script) const;
1116
1117 void killAllScriptsExceptCurrent();
1118 void killScriptsAndResources();
1119 void decreaseScriptDelay(int amount);
1120
1121 void stopObjectCode();
1122 void stopObjectScript(int script);
1123
1124 void getScriptBaseAddress();
1125 void resetScriptPointer();
1126 int getVerbEntrypoint(int obj, int entry);
1127
1128 void refreshScriptPointer();
1129 byte fetchScriptByte();
1130 virtual uint fetchScriptWord();
1131 virtual int fetchScriptWordSigned();
1132 uint fetchScriptDWord();
1133 int fetchScriptDWordSigned();
1134 void ignoreScriptWord() { fetchScriptWord(); }
1135 void ignoreScriptByte() { fetchScriptByte(); }
1136 void push(int a);
1137 int pop();
1138 virtual int readVar(uint var);
1139 virtual void writeVar(uint var, int value);
1140 // SCUMM 1/2
1141 virtual void resetSentence() {}
1142
1143protected:
1144 virtual void beginCutscene(int *args);
1145 virtual void endCutscene();
1146 void abortCutscene();
1147 void beginOverride();
1148 void endOverride();
1149
1150 void copyScriptString(byte *dst);
1151 int resStrLen(const byte *src);
1152 void doSentence(int c, int b, int a);
1153
1154 /* Should be in Resource class */
1155 BaseScummFile *_fileHandle = nullptr;
1156 uint32 _fileOffset = 0;
1157public:
1160 Common::Path _macCursorFile;
1161
1162 bool openFile(BaseScummFile &file, const Common::Path &filename, bool resourceFile = false);
1163 ScummFile *instantiateScummFile(bool indexPAKFiles = true);
1164
1165protected:
1166 int _resourceHeaderSize = 8;
1167 byte _resourceMapper[128];
1168 const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
1169 uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
1170
1171 virtual void allocateArrays();
1172 void openRoom(int room);
1173 void closeRoom();
1174 void deleteRoomOffsets();
1175 virtual void readRoomsOffsets();
1176 void askForDisk(const Common::Path &filename, int disknum);
1177 byte getEncByte(int room);
1178 bool openResourceFile(const Common::Path &filename, byte encByte);
1179
1180 void loadPtrToResource(ResType type, ResId idx, const byte *ptr);
1181 virtual int readResTypeList(ResType type);
1182// void allocResTypeData(ResType type, uint32 tag, int num, int mode);
1183// byte *createResource(int type, int index, uint32 size);
1184 int loadResource(ResType type, ResId idx);
1185// void nukeResource(ResType type, ResId idx);
1186 int getResourceRoomNr(ResType type, ResId idx);
1187 virtual uint32 getResourceRoomOffset(ResType type, ResId idx);
1188
1189 void scriptOverride(ResId room, int script);
1190
1191public:
1192 int getResourceSize(ResType type, ResId idx);
1193 byte *getResourceAddress(ResType type, ResId idx);
1194 virtual byte *getStringAddress(ResId idx);
1195 byte *getStringAddressVar(int i);
1196 void ensureResourceLoaded(ResType type, ResId idx);
1197
1198protected:
1199 Common::Mutex _resourceAccessMutex; // Used in getResourceSize(), getResourceAddress() and findResource()
1200 // to avoid race conditions between the audio thread of Digital iMUSE
1201 // and the main SCUMM thread
1202
1203 int readSoundResource(ResId idx);
1204 int readSoundResourceSmallHeader(ResId idx);
1205 bool isResourceInUse(ResType type, ResId idx) const;
1206
1207 virtual void setupRoomSubBlocks();
1208 virtual void resetRoomSubBlocks();
1209
1210 virtual void clearRoomObjects();
1211 virtual void resetRoomObjects();
1212 virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
1213
1214 virtual void readArrayFromIndexFile();
1215 virtual void readMAXS(int blockSize) = 0;
1216 virtual void readGlobalObjects();
1217 virtual void readIndexFile();
1218 virtual void readIndexBlock(uint32 block, uint32 itemsize);
1219 virtual void loadCharset(int i);
1220 void nukeCharset(int i);
1221
1222 int _lastLoadedRoom = 0;
1223public:
1224 const byte *findResourceData(uint32 tag, const byte *ptr);
1225 const byte *findResource(uint32 tag, const byte *ptr);
1226 void applyWorkaroundIfNeeded(ResType type, int idx);
1227 bool verifyMI2MacBootScript();
1228 bool verifyMI2MacBootScript(byte *buf, int size);
1229 bool tryPatchMI1CannibalScript(byte *buf, int size);
1230
1231 int getResourceDataSize(const byte *ptr) const;
1232 void dumpResource(const char *tag, int index, const byte *ptr, int length = -1);
1233
1234public:
1235 /* Should be in Object class */
1236 byte OF_OWNER_ROOM = 0;
1237 int getInventorySlot();
1238 int findInventory(int owner, int index);
1239 int getInventoryCount(int owner);
1240
1241protected:
1242 byte *_objectOwnerTable = nullptr, *_objectRoomTable = nullptr, *_objectStateTable = nullptr;
1243 int _numObjectsInRoom = 0;
1244
1245public:
1246 uint32 *_classData = nullptr;
1247
1248protected:
1249 void markObjectRectAsDirty(int obj);
1250 virtual void loadFlObject(uint object, uint room);
1251 void nukeFlObjects(int min, int max);
1252 int findFlObjectSlot();
1253 int findLocalObjectSlot();
1254 void addObjectToInventory(uint obj, uint room);
1255 void updateObjectStates();
1256public:
1257 bool getClass(int obj, int cls) const; // Used in actor.cpp, hence public
1258protected:
1259 void putClass(int obj, int cls, bool set);
1260 int getState(int obj);
1261 void putState(int obj, int state);
1262 void setObjectState(int obj, int state, int x, int y);
1263 int getOwner(int obj) const;
1264 void putOwner(int obj, int owner);
1265 void setOwnerOf(int obj, int owner);
1266 void clearOwnerOf(int obj);
1267 int getObjectRoom(int obj) const;
1268 virtual bool objIsActor(int obj);
1269 virtual int objToActor(int obj);
1270 virtual int actorToObj(int actor);
1271 int getObjX(int obj);
1272 int getObjY(int obj);
1273 void getObjectWidth(int object, int &width) { int x, y, dir; getObjectXYPos(object, x, y, dir, width); }
1274 void getObjectXYPos(int object, int &x, int &y) { int dir, width; getObjectXYPos(object, x, y, dir, width); }
1275 void getObjectXYPos(int object, int &x, int &y, int &dir) { int width; getObjectXYPos(object, x, y, dir, width); }
1276 void getObjectXYPos(int object, int &x, int &y, int &dir, int &width);
1277 int getObjOldDir(int obj);
1278 int getObjNewDir(int obj);
1279 int getObjectIndex(int object) const;
1280 int getObjectImageCount(int object);
1281 int whereIsObject(int object) const;
1282 int findObject(int x, int y);
1283 void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room);
1284public:
1285 int getObjectOrActorWidth(int object, int &width); // Used in v4 and below
1286 int getObjectOrActorXY(int object, int &x, int &y); // Used in actor.cpp, hence public
1287 int getDist(int x, int y, int x2, int y2); // Also used in actor.cpp
1288protected:
1289
1290 int getObjActToObjActDist(int a, int b); // Not sure how to handle
1291 const byte *getObjOrActorName(int obj); // these three..
1292 void setObjectName(int obj);
1293
1294 void addObjectToDrawQue(int object);
1295 void removeObjectFromDrawQue(int object);
1296 void clearDrawObjectQueue();
1297 void processDrawQue();
1298
1299 virtual void clearDrawQueues();
1300
1301 uint32 getOBCDOffs(int object) const;
1302 byte *getOBCDFromObject(int obj, bool v0CheckInventory = true);
1303 const byte *getOBIMFromObjectData(const ObjectData &od);
1304 const byte *getObjectImage(const byte *ptr, int state);
1305 virtual int getObjectIdFromOBIM(const byte *obim);
1306
1307protected:
1308 /* Should be in Verb class */
1309 uint16 _verbMouseOver = 0;
1310 int8 _userPut = 0;
1311 uint16 _userState = 0;
1312
1313 virtual void handleMouseOver(bool updateInventory);
1314 virtual void redrawVerbs();
1315 virtual void checkExecVerbs();
1316
1317 void verbMouseOver(int verb);
1318 int findVerbAtPos(int x, int y) const;
1319 virtual void drawVerb(int verb, int mode, Common::TextToSpeechManager::Action ttsAction = Common::TextToSpeechManager::INTERRUPT);
1320 virtual void runInputScript(int clickArea, int val, int mode);
1321 void restoreVerbBG(int verb);
1322 void drawVerbBitmap(int verb, int x, int y);
1323 int getVerbSlot(int id, int mode) const;
1324 void killVerb(int slot);
1325 void setVerbObject(uint room, uint object, uint verb);
1326
1327public:
1328 bool isValidActor(int id) const;
1329
1330 /* Should be in Actor class */
1331 Actor *derefActor(int id, const char *errmsg = 0) const;
1332 Actor *derefActorSafe(int id, const char *errmsg) const;
1333
1334protected:
1335 void walkActors();
1336 void playActorSounds();
1337 void redrawAllActors();
1338 virtual void setActorRedrawFlags();
1339 void putActors();
1340 void showActors();
1341 void resetV1ActorTalkColor();
1342 virtual void resetActorBgs();
1343 virtual void processActors();
1344 void processUpperActors();
1345 virtual int getActorFromPos(int x, int y);
1346
1347public:
1348 /* Actor talking stuff */
1349 byte _actorToPrintStrFor = 0, _V1TalkingActor = 0;
1350 int _sentenceNum = 0;
1351 SentenceTab _sentence[NUM_SENTENCE];
1352 StringTab _string[6];
1353 byte _haveMsg = 0;
1354 int16 _talkDelay = 0;
1355 int _NES_lastTalkingActor = 0;
1356 int _NES_talkColor = 0;
1357
1358 virtual void actorTalk(const byte *msg);
1359 void stopTalk();
1360 int getTalkingActor(); // Wrapper around VAR_TALK_ACTOR for V1 Maniac
1361 void setTalkingActor(int variable);
1362
1363 // Generic costume code
1364 bool isCostumeInUse(int i) const;
1365
1366protected:
1367 /* Should be in Graphics class? */
1368 uint16 _screenB = 0, _screenH = 0;
1369public:
1370 int _roomHeight = 0, _roomWidth = 0;
1371 int _screenHeight = 0, _screenWidth = 0;
1372 VirtScreen _virtscr[4]; // Virtual screen areas
1373 CameraData camera; // 'Camera' - viewport
1374 bool _cameraIsFrozen = false;
1375
1376 int _screenStartStrip = 0, _screenEndStrip = 0;
1377 int _screenTop = 0;
1378 bool _forceBannerVirtScreen = false;
1379
1380 // For Mac versions of 320x200 games:
1381 // these versions rendered at 640x480 without any aspect ratio correction;
1382 // in order to correctly display the games as they should be, we perform some
1383 // offset corrections within the various rendering pipelines.
1384 //
1385 // The only reason I've made _useMacScreenCorrectHeight toggleable is because
1386 // maybe someday the screen correction can be activated or deactivated from the
1387 // ScummVM GUI; but currently I'm not taking that responsibility, after all the
1388 // work done on ensuring that old savegames translate correctly to the new setting... :-P
1389 bool _useMacScreenCorrectHeight = true;
1390 int _macScreenDrawOffset = 20;
1391
1392 Common::RenderMode _renderMode;
1393 uint8 _bytesPerPixel = 1;
1394 Graphics::PixelFormat _outputPixelFormat;
1395
1396protected:
1397 ColorCycle _colorCycle[16]; // Palette cycles
1398 uint8 _colorUsedByCycle[256];
1399 Graphics::PaletteLookup _pl; // Used by the internal GUI
1400
1401 uint32 _ENCD_offs = 0, _EXCD_offs = 0;
1402 uint32 _CLUT_offs = 0, _EPAL_offs = 0;
1403 uint32 _IM00_offs = 0, _PALS_offs = 0;
1404
1405 //ender: fullscreen
1406 bool _fullRedraw = false, _bgNeedsRedraw = false;
1407 bool _screenEffectFlag = false, _completeScreenRedraw = false;
1408 bool _disableFadeInEffect = false;
1409
1410 struct {
1411 int hotspotX, hotspotY, width, height;
1412 byte animate, animateIndex;
1413 int8 state;
1414 } _cursor;
1415
1416 // HACK Double the array size to handle 16-bit images.
1417 // this should be dynamically allocated based on game depth instead.
1418 byte _grabbedCursor[16384];
1419 byte _macGrabbedCursor[16384 * 4]; // Double resolution cursor
1420 byte _currentCursor = 0;
1421
1422 byte _newEffect = 0, _switchRoomEffect2 = 0, _switchRoomEffect = 0;
1423 bool _doEffect = false;
1424
1425 bool _snapScroll = false;
1426
1427 virtual void setBuiltinCursor(int index) {}
1428public:
1429 bool isLightOn() const;
1430
1431 virtual int getCurrentLights() const;
1432
1433protected:
1434 void initScreens(int b, int h);
1435 void initVirtScreen(VirtScreenNumber slot, int top, int width, int height, bool twobufs, bool scrollable);
1436 void initBGBuffers(int height);
1437 void initCycl(const byte *ptr); // Color cycle
1438
1439 void decodeNESBaseTiles();
1440 void playNESTitleScreens();
1441
1442 void drawObject(int obj, int scrollType);
1443 void drawRoomObjects(int arg);
1444 void drawRoomObject(int i, int arg);
1445 void drawBox(int x, int y, int x2, int y2, int color);
1446 void drawLine(int x1, int y1, int x2, int y2, int color);
1447 void drawPixel(VirtScreen *vs, int x, int y, int16 color, bool useBackbuffer = false);
1448
1449 void moveScreen(int dx, int dy, int height);
1450
1451 void restoreBackground(Common::Rect rect, byte backcolor = 0);
1452 void redrawBGStrip(int start, int num);
1453 virtual void redrawBGAreas();
1454
1455 void cameraMoved();
1456 void setCameraAtEx(int at);
1457 virtual void setCameraAt(int pos_x, int pos_y);
1458 virtual void setCameraFollows(Actor *a, bool setCamera = false);
1459 virtual void moveCamera();
1460 virtual void panCameraTo(int x, int y);
1461 void clampCameraPos(Common::Point *pt);
1462 void actorFollowCamera(int act);
1463
1464 const byte *getPalettePtr(int palindex, int room);
1465
1466 void setPaletteFromTable(const byte *ptr, int numcolor, int firstIndex = 0);
1467 void resetPalette(bool isBootUp = false);
1468
1469 void setCurrentPalette(int pal);
1470 void setRoomPalette(int pal, int room);
1471 void setPCEPaletteFromPtr(const byte *ptr);
1472 void setAmigaPaletteFromPtr(const byte *ptr);
1473 virtual void setPaletteFromPtr(const byte *ptr, int numcolor = -1);
1474 void setV1ColorTable(int renderMode);
1475
1476 virtual void setPalColor(int index, int r, int g, int b);
1477 void setDirtyColors(int min, int max);
1478 const byte *findPalInPals(const byte *pal, int index);
1479 void swapPalColors(int a, int b);
1480 virtual void copyPalColor(int dst, int src);
1481 void cyclePalette();
1482 void stopCycle(int i);
1483 virtual void palManipulateInit(int resID, int start, int end, int time);
1484 void palManipulate();
1485 uint32 findClosestPaletteColor(byte *palette, int paletteLength, byte r, byte g, byte b);
1486 void applyGrayscaleToPaletteRange(int min, int max); // For Sam&Max original noir mode
1487 bool haveToApplyMonkey1PaletteFix();
1488
1489public:
1490 uint8 *getHEPaletteSlot(uint16 palSlot);
1491 uint16 get16BitColor(uint8 r, uint8 g, uint8 b);
1492 uint32 getPaletteColorFromRGB(byte *palette, byte r, byte g, byte b);
1493 uint32 getPackedRGBColorFromPalette(byte *palette, uint32 color);
1494 void fetchBlackAndWhite(uint32 &black, uint32 &white, byte *palette, int paletteEntries);
1495 int remapPaletteColor(int r, int g, int b, int threshold); // Used by Actor::remapActorPalette
1496 void readPCEPalette(const byte **ptr, byte **dest, int numEntries);
1497 void colorPCEToRGB(uint16 color, byte *r, byte *g, byte *b);
1498 void setPCETextPalette(uint8 color);
1499protected:
1500 void moveMemInPalRes(int start, int end, byte direction);
1501 void setShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
1502 void setShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
1503 virtual void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
1504
1505public:
1506 void markRectAsDirty(VirtScreenNumber virt, int left, int right, int top, int bottom, int dirtybit = 0);
1507 void markRectAsDirty(VirtScreenNumber virt, const Common::Rect& rect, int dirtybit = 0) {
1508 markRectAsDirty(virt, rect.left, rect.right, rect.top, rect.bottom, dirtybit);
1509 }
1510protected:
1511 // Screen rendering
1512 byte *_compositeBuf;
1513 byte *_hercCGAScaleBuf = nullptr;
1514 bool _enableEGADithering = false;
1515 bool _supportsEGADithering = false;
1516 bool _enableSegaShadowMode = false;
1517
1518 virtual void drawDirtyScreenParts();
1519 void updateDirtyScreen(VirtScreenNumber slot);
1520 void drawStripToScreen(VirtScreen *vs, int x, int width, int top, int bottom);
1521
1522 void mac_markScreenAsDirty(int x, int y, int w, int h);
1523 void mac_drawStripToScreen(VirtScreen *vs, int top, int x, int y, int width, int height);
1524 void mac_drawIndy3TextBox();
1525 void mac_undrawIndy3TextBox();
1526 void mac_undrawIndy3CreditsText();
1527 void mac_drawBufferToScreen(const byte *buffer, int pitch, int x, int y, int width, int height, bool epxRectangleExpansion = true);
1528 void mac_updateCompositeBuffer(const byte *buffer, int pitch, int x, int y, int width, int height);
1529 void mac_blitDoubleResImage(const byte *buffer, int pitch, int x, int y, int width, int height);
1530 void mac_applyDoubleResToBuffer(const byte *inputBuffer, byte *outputBuffer, int width, int height, int inputPitch, int outputPitch);
1531 void mac_blitEPXImage(const byte *buffer, int pitch, int x, int y, int width, int height, bool epxRectangleExpansion = true);
1532 void mac_applyEPXToBuffer(const byte *inputBuffer, byte *outputBuffer, int width, int height, int inputPitch, int outputPitch, int xOffset, int yOffset, int bufferWidth, int bufferHeight);
1533 void mac_scaleCursor(byte *&outCursor, int &outHotspotX, int &outHotspotY, int &outWidth, int &outHeight);
1534 void mac_toggleSmoothing();
1535
1536 Common::KeyState mac_showOldStyleBannerAndPause(const char *msg, int32 waitTime);
1537
1538 const byte *postProcessDOSGraphics(VirtScreen *vs, int &pitch, int &x, int &y, int &width, int &height) const;
1539 const byte *ditherVGAtoEGA(int &pitch, int &x, int &y, int &width, int &height) const;
1540
1541public:
1542 VirtScreen *findVirtScreen(int y);
1543 byte *getMaskBuffer(int x, int y, int z);
1544
1545protected:
1546 void fadeIn(int effect);
1547 void fadeOut(int effect);
1548
1549 void dissolveEffectSelector();
1550 void transitionEffect(int a);
1551 void dissolveEffect(int width, int height);
1552 void scrollEffect(int dir);
1553
1554 void updateScreenShakeEffect();
1555
1556public:
1557 double getTimerFrequency();
1558 double getAmigaMusicTimerFrequency(); // For setting up Players v2 and v3
1559
1560protected:
1561 bool _shakeEnabled = false;
1562 bool _shakeTempSavedState = false; // For saving and restoring before and after GUI calls
1563 uint _shakeFrame = 0;
1564 uint32 _shakeNextTick = 0;
1565 uint32 _shakeTickCounter = 0;
1566 double _shakeTimerRate;
1567 double _timerFrequency;
1568
1569 void setShake(int mode);
1570
1571 int _drawObjectQueNr = 0;
1572 byte _drawObjectQue[200];
1573
1574 /* For each of the 410 screen strips, gfxUsageBits contains a
1575 * bitmask. The lower 80 bits each correspond to one actor and
1576 * signify if any part of that actor is currently contained in
1577 * that strip.
1578 *
1579 * If the leftmost bit is set, the strip (background) is dirty
1580 * needs to be redrawn.
1581 *
1582 * The second leftmost bit is set by restoreBlastObjectsRect() and
1583 * restoreBackground(), but I'm not yet sure why.
1584 */
1585 uint32 gfxUsageBits[410 * 3];
1586
1587 void upgradeGfxUsageBits();
1588 void setGfxUsageBit(int strip, int bit);
1589 void clearGfxUsageBit(int strip, int bit);
1590
1591 // speed optimization: inline due to frequent calling
1592 bool testGfxUsageBit(int strip, int bit) {
1593 assert(strip >= 0 && strip < ARRAYSIZE(gfxUsageBits) / 3);
1594 assert(1 <= bit && bit <= 96);
1595 bit--;
1596 return (gfxUsageBits[3 * strip + bit / 32] & (1 << (bit % 32))) != 0;
1597 }
1598
1599 bool testGfxAnyUsageBits(int strip);
1600 bool testGfxObjectUsageBits(int strip); // Used for HE actors overlap calculations
1601 bool testGfxOtherUsageBits(int strip, int bit);
1602
1603public:
1604 byte _roomPalette[256];
1605 byte *_shadowPalette = nullptr;
1606 bool _skipDrawObject = 0;
1607 int _voiceMode = 0;
1608 int _soundEnabled = 0;
1609
1610 // HE specific
1611 byte _HEV7ActorPalette[256];
1612 uint8 *_hePalettes = nullptr;
1613 uint16 _hePaletteSlot = 0;
1614 uint16 *_16BitPalette = nullptr;
1615
1616 // Indy4 Amiga specific
1617 byte *_verbPalette = nullptr;
1618
1619 ScummEngine_v0_Delays _V0Delay;
1620
1621protected:
1622 int _shadowPaletteSize = 0;
1623 byte _currentPalette[3 * 256];
1624 byte _darkenPalette[3 * 256];
1625 int _paletteChangedCounter = 1;
1626
1627 int _palDirtyMin = 0, _palDirtyMax = 0;
1628
1629 byte _palManipStart = 0, _palManipEnd = 0;
1630 uint16 _palManipCounter = 0;
1631 byte *_palManipPalette = nullptr;
1632 byte *_palManipIntermediatePal = nullptr;
1633
1634 bool _haveActorSpeechMsg = false;
1635 bool _useTalkAnims = false;
1636 uint16 _defaultTextSpeed = 0;
1637 int _saveSound = 0;
1638 bool _native_mt32 = false;
1639 bool _copyProtection = false;
1640 bool _shadowPalRemap = false;
1641
1642 // Indy4 Amiga specific
1643 uint16 _amigaFirstUsedColor = 0;
1644 byte _amigaPalette[3 * 64];
1645 void amigaPaletteFindFirstUsedColor();
1646 void mapRoomPalette(int idx);
1647 int remapRoomPaletteColor(int r, int g, int b);
1648 void mapVerbPalette(int idx);
1649 int remapVerbPaletteColor(int r, int g, int b);
1650
1651 // EGA dithering mode color tables for certain VGA games like MI2, LOOM Talkie...
1652 byte *_egaColorMap[2];
1653
1654public:
1655 uint16 _extraBoxFlags[65];
1656
1657 byte getNumBoxes();
1658 byte *getBoxMatrixBaseAddr();
1659 byte *getBoxConnectionBase(int box);
1660
1661 int getNextBox(byte from, byte to);
1662
1663 void setBoxFlags(int box, int val);
1664 void setBoxScale(int box, int b);
1665
1666 bool checkXYInBoxBounds(int box, int x, int y);
1667
1668 BoxCoords getBoxCoordinates(int boxnum);
1669
1670 byte getMaskFromBox(int box);
1671 Box *getBoxBaseAddr(int box);
1672 byte getBoxFlags(int box);
1673 int getBoxScale(int box);
1674
1675 int getScale(int box, int x, int y);
1676 int getScaleFromSlot(int slot, int x, int y);
1677
1678protected:
1679 // Scaling slots/items
1680 struct ScaleSlot {
1681 int x1, y1, scale1;
1682 int x2, y2, scale2;
1683 };
1684 friend void syncWithSerializer(Common::Serializer &, ScaleSlot &);
1685 ScaleSlot _scaleSlots[20];
1686 void setScaleSlot(int slot, int x1, int y1, int scale1, int x2, int y2, int scale2);
1687 void setBoxScaleSlot(int box, int slot);
1688 void convertScaleTableToScaleSlot(int slot);
1689
1690 void calcItineraryMatrix(byte *itineraryMatrix, int num);
1691 void createBoxMatrix();
1692 virtual bool areBoxesNeighbors(int i, int j);
1693
1694 /* String class */
1695public:
1696 CharsetRenderer *_charset = nullptr;
1697 byte _charsetColorMap[16];
1698
1704 int _textSurfaceMultiplier = 0;
1705
1706 bool _isModernMacVersion = false;
1707 bool _useGammaCorrection = true;
1708
1709 Graphics::Surface *_macScreen = nullptr;
1710 MacGui *_macGui = nullptr;
1711 bool _useMacGraphicsSmoothing = true;
1712 byte _completeScreenBuffer[320 * 200];
1713
1714protected:
1715 byte _charsetColor = 0;
1716 byte _charsetData[23][16];
1717
1718 int _charsetBufPos = 0;
1719 byte _charsetBuffer[512];
1720
1721 bool _keepText = false;
1722 byte _msgCount = 0;
1723
1724 int _nextLeft = 0, _nextTop = 0;
1725
1726 Localizer *_localizer = nullptr;
1727
1728#ifdef USE_TTS
1729 bool _voiceNextString = false;
1730 bool _checkPreviousSaid = false;
1731 bool _voicePassHelpButtons = false;
1732 int _previousVerb = -1;
1733 int _previousControl = -1;
1734 Common::String _previousSaid;
1735 Common::String _passHelpButtons[6];
1736#endif
1737
1738 void restoreCharsetBg();
1739 void clearCharsetMask();
1740 void clearTextSurface();
1741
1742 virtual void initCharset(int charset);
1743
1744 virtual void printString(int m, const byte *msg);
1745
1746 virtual bool handleNextCharsetCode(Actor *a, int *c);
1747 virtual void drawSentence() {}
1748 virtual void displayDialog();
1749 int countNumberOfWaits(); // For SE speech support, from disasm
1750 bool newLine();
1751 void drawString(int a, const byte *msg, Common::TextToSpeechManager::Action ttsAction = Common::TextToSpeechManager::QUEUE);
1752 virtual void fakeBidiString(byte *ltext, bool ignoreVerb, int ltextSize) const;
1753 void wrapSegaCDText();
1754 void debugMessage(const byte *msg);
1755 virtual void showMessageDialog(const byte *msg);
1756
1757#ifdef USE_TTS
1758 void sayText(const Common::String &text, Common::TextToSpeechManager::Action action = Common::TextToSpeechManager::QUEUE) const;
1759 void stopTextToSpeech() const;
1760 void sayButtonText();
1761#endif
1762
1763 virtual int convertMessageToString(const byte *msg, byte *dst, int dstSize);
1764 int convertIntMessage(byte *dst, int dstSize, int var);
1765 int convertVerbMessage(byte *dst, int dstSize, int var);
1766 int convertNameMessage(byte *dst, int dstSize, int var);
1767 int convertStringMessage(byte *dst, int dstSize, int var);
1768
1769public:
1770 Common::Language _language; // Accessed by a hack in NutRenderer::loadFont
1771
1772 // Used by class ScummDialog:
1773 virtual void translateText(const byte *text, byte *trans_buff, int transBufferSize);
1774 // Old Hebrew games require reversing the dialog text.
1775 bool reverseIfNeeded(const byte *text, byte *reverseBuf, int reverseBufSize) const;
1776 // Returns codepage that matches the game for languages that require it.
1777 Common::CodePage getDialogCodePage() const;
1778
1779 // Somewhat hackish stuff for 2 byte support (Chinese/Japanese/Korean)
1780 bool _useCJKMode = false;
1781 bool _useMultiFont = false;
1782 int _numLoadedFont = 0;
1783 int _2byteShadow = 0;
1784 bool _force2ByteCharHeight = false;
1785
1786 int _2byteHeight = 0;
1787 int _2byteWidth = 0;
1788 int _krStrPost = 0;
1789 byte _newLineCharacter = 0;
1790 byte *get2byteCharPtr(int idx);
1791
1792 bool isScummvmKorTarget();
1793 bool hasLocalizer();
1794
1795//protected:
1796 byte *_2byteFontPtr = nullptr;
1797 byte *_2byteMultiFontPtr[20];
1798 int _2byteMultiHeight[20];
1799 int _2byteMultiWidth[20];
1800 int _2byteMultiShadow[20];
1801
1802private:
1803 struct TranslatedLine {
1804 uint32 originalTextOffset;
1805 uint32 translatedTextOffset;
1806 };
1807
1808 struct TranslationRange {
1809 uint32 left;
1810 uint32 right;
1811
1812 TranslationRange(uint32 left_, uint32 right_) : left(left_), right(right_) {}
1813 TranslationRange() : left(0), right(0) {}
1814 };
1815
1816 struct TranslationRoom {
1818 };
1819
1820 bool _existLanguageFile = false;
1821 bool _isRTL = false;
1822 byte *_languageBuffer = nullptr;
1823 int _numTranslatedLines = 0;
1824 TranslatedLine *_translatedLines = nullptr;
1825 uint16 *_languageLineIndex = nullptr;
1827
1828 const byte *searchTranslatedLine(const byte *text, const TranslationRange &range, bool useIndex);
1829
1830 virtual void createTextRenderer(GlyphRenderer_v7 *gr) {}
1831
1832public:
1833
1834 /* Scumm Vars */
1835 byte VAR_KEYPRESS = 0xFF;
1836 byte VAR_SYNC = 0xFF;
1837 byte VAR_EGO = 0xFF;
1838 byte VAR_CAMERA_POS_X = 0xFF;
1839 byte VAR_HAVE_MSG = 0xFF;
1840 byte VAR_ROOM = 0xFF;
1841 byte VAR_OVERRIDE = 0xFF;
1842 byte VAR_MACHINE_SPEED = 0xFF;
1843 byte VAR_ME = 0xFF;
1844 byte VAR_NUM_ACTOR = 0xFF;
1845 byte VAR_CURRENT_LIGHTS = 0xFF;
1846 byte VAR_CURRENTDRIVE = 0xFF; // How about merging this with VAR_CURRENTDISK?
1847 byte VAR_CURRENTDISK = 0xFF;
1848 byte VAR_TMR_1 = 0xFF;
1849 byte VAR_TMR_2 = 0xFF;
1850 byte VAR_TMR_3 = 0xFF;
1851 byte VAR_MUSIC_TIMER = 0xFF;
1852 byte VAR_ACTOR_RANGE_MIN = 0xFF;
1853 byte VAR_ACTOR_RANGE_MAX = 0xFF;
1854 byte VAR_CAMERA_MIN_X = 0xFF;
1855 byte VAR_CAMERA_MAX_X = 0xFF;
1856 byte VAR_TIMER_NEXT = 0xFF;
1857 byte VAR_VIRT_MOUSE_X = 0xFF;
1858 byte VAR_VIRT_MOUSE_Y = 0xFF;
1859 byte VAR_ROOM_RESOURCE = 0xFF;
1860 byte VAR_LAST_SOUND = 0xFF;
1861 byte VAR_CUTSCENEEXIT_KEY = 0xFF;
1862 byte VAR_OPTIONS_KEY = 0xFF;
1863 byte VAR_TALK_ACTOR = 0xFF;
1864 byte VAR_CAMERA_FAST_X = 0xFF;
1865 byte VAR_SCROLL_SCRIPT = 0xFF;
1866 byte VAR_ENTRY_SCRIPT = 0xFF;
1867 byte VAR_ENTRY_SCRIPT2 = 0xFF;
1868 byte VAR_EXIT_SCRIPT = 0xFF;
1869 byte VAR_EXIT_SCRIPT2 = 0xFF;
1870 byte VAR_VERB_SCRIPT = 0xFF;
1871 byte VAR_SENTENCE_SCRIPT = 0xFF;
1872 byte VAR_INVENTORY_SCRIPT = 0xFF;
1873 byte VAR_CUTSCENE_START_SCRIPT = 0xFF;
1874 byte VAR_CUTSCENE_END_SCRIPT = 0xFF;
1875 byte VAR_CHARINC = 0xFF;
1876 byte VAR_WALKTO_OBJ = 0xFF;
1877 byte VAR_DEBUGMODE = 0xFF;
1878 byte VAR_HEAPSPACE = 0xFF;
1879 byte VAR_RESTART_KEY = 0xFF;
1880 byte VAR_PAUSE_KEY = 0xFF;
1881 byte VAR_MOUSE_X = 0xFF;
1882 byte VAR_MOUSE_Y = 0xFF;
1883 byte VAR_TIMER = 0xFF;
1884 byte VAR_TIMER_TOTAL = 0xFF;
1885 byte VAR_SOUNDCARD = 0xFF;
1886 byte VAR_VIDEOMODE = 0xFF;
1887 byte VAR_MAINMENU_KEY = 0xFF;
1888 byte VAR_FIXEDDISK = 0xFF;
1889 byte VAR_CURSORSTATE = 0xFF;
1890 byte VAR_USERPUT = 0xFF;
1891 byte VAR_SOUNDRESULT = 0xFF;
1892 byte VAR_TALKSTOP_KEY = 0xFF;
1893 byte VAR_FADE_DELAY = 0xFF;
1894 byte VAR_NOSUBTITLES = 0xFF;
1895
1896 // V5+
1897 byte VAR_SOUNDPARAM = 0xFF;
1898 byte VAR_SOUNDPARAM2 = 0xFF;
1899 byte VAR_SOUNDPARAM3 = 0xFF;
1900 byte VAR_INPUTMODE = 0xFF;
1901 byte VAR_MEMORY_PERFORMANCE = 0xFF;
1902 byte VAR_VIDEO_PERFORMANCE = 0xFF;
1903 byte VAR_ROOM_FLAG = 0xFF;
1904 byte VAR_GAME_LOADED = 0xFF;
1905 byte VAR_NEW_ROOM = 0xFF;
1906
1907 // V4/V5
1908 byte VAR_V5_TALK_STRING_Y = 0xFF;
1909
1910 // V6+
1911 byte VAR_ROOM_WIDTH = 0xFF;
1912 byte VAR_ROOM_HEIGHT = 0xFF;
1913 byte VAR_SUBTITLES = 0xFF;
1914 byte VAR_V6_EMSSPACE = 0xFF;
1915
1916 // V7/V8 specific variables
1917 byte VAR_CAMERA_POS_Y = 0xFF;
1918 byte VAR_CAMERA_MIN_Y = 0xFF;
1919 byte VAR_CAMERA_MAX_Y = 0xFF;
1920 byte VAR_CAMERA_THRESHOLD_X = 0xFF;
1921 byte VAR_CAMERA_THRESHOLD_Y = 0xFF;
1922 byte VAR_CAMERA_SPEED_X = 0xFF;
1923 byte VAR_CAMERA_SPEED_Y = 0xFF;
1924 byte VAR_CAMERA_ACCEL_X = 0xFF;
1925 byte VAR_CAMERA_ACCEL_Y = 0xFF;
1926 byte VAR_CAMERA_DEST_X = 0xFF;
1927 byte VAR_CAMERA_DEST_Y = 0xFF;
1928 byte VAR_CAMERA_FOLLOWED_ACTOR = 0xFF;
1929
1930 // V7/V8 specific variables
1931 byte VAR_VERSION_KEY = 0xFF;
1932 byte VAR_DEFAULT_TALK_DELAY = 0xFF;
1933 byte VAR_CUSTOMSCALETABLE = 0xFF;
1934 byte VAR_BLAST_ABOVE_TEXT = 0xFF;
1935 byte VAR_VOICE_MODE = 0xFF;
1936 byte VAR_MUSIC_BUNDLE_LOADED = 0xFF;
1937 byte VAR_VOICE_BUNDLE_LOADED = 0xFF;
1938
1939 byte VAR_LEFTBTN_DOWN = 0xFF; // V7/V8
1940 byte VAR_RIGHTBTN_DOWN = 0xFF; // V7/V8
1941 byte VAR_LEFTBTN_HOLD = 0xFF; // V6/V72HE/V7/V8
1942 byte VAR_RIGHTBTN_HOLD = 0xFF; // V6/V72HE/V7/V8
1943 byte VAR_PRE_SAVELOAD_SCRIPT = 0xFF; // V6/V7 (not HE)
1944 byte VAR_POST_SAVELOAD_SCRIPT = 0xFF; // V6/V7 (not HE)
1945 byte VAR_SAVELOAD_PAGE = 0xFF; // V8
1946 byte VAR_OBJECT_LABEL_FLAG = 0xFF; // V8
1947
1948 // V6/V7 specific variables (FT & Sam & Max specific)
1949 byte VAR_CHARSET_MASK = 0xFF;
1950
1951 // V6 specific variables
1952 byte VAR_V6_SOUNDMODE = 0xFF;
1953
1954 // V1/V2 specific variables
1955 byte VAR_CHARCOUNT = 0xFF;
1956 byte VAR_VERB_ALLOWED = 0xFF;
1957 byte VAR_ACTIVE_VERB = 0xFF;
1958 byte VAR_ACTIVE_OBJECT1 = 0xFF;
1959 byte VAR_ACTIVE_OBJECT2 = 0xFF;
1960
1961 // HE specific variables
1962 byte VAR_ALWAYS_REDRAW_ACTORS = 0xFF; // Used in setActorRedrawFlags()
1963 byte VAR_SKIP_RESET_TALK_ACTOR = 0xFF; // Used in setActorCostume()
1964
1965 byte VAR_SOUND_CHANNEL = 0xFF; // Used in o_startSound()
1966 byte VAR_TALK_CHANNEL = 0xFF; // Used in playVoice()
1967 byte VAR_SOUND_TOKEN_OFFSET = 0xFF; // Used in handleSoundFrame()
1968 byte VAR_START_DYN_SOUND_CHANNELS = 0xFF; // Used in getNextDynamicChannel()
1969 byte VAR_SOUND_CALLBACK_SCRIPT = 0xFF;
1970
1971 byte VAR_EARLY_TALKIE_CALLBACK = 0xFF;
1972 byte VAR_EARLY_CHAN_0_CALLBACK = 0xFF;
1973 byte VAR_EARLY_CHAN_1_CALLBACK = 0xFF;
1974 byte VAR_EARLY_CHAN_2_CALLBACK = 0xFF;
1975 byte VAR_EARLY_CHAN_3_CALLBACK = 0xFF;
1976
1977 byte VAR_MAIN_SCRIPT = 0xFF; // Used in scummLoop()
1978
1979 byte VAR_DEFAULT_SCRIPT_PRIORITY = 0xFF; // Used in runScript()/runObjectScript()
1980 byte VAR_LAST_SCRIPT_PRIORITY = 0xFF; // Used in runAllScripts()
1981
1982 byte VAR_QUIT_SCRIPT = 0xFF; // Used in confirmExitDialog()
1983 byte VAR_ERROR_FLAG = 0xFF; // HE70-90
1984 byte VAR_OPERATION_FAILURE = 0xFF; // HE99+
1985
1986 byte VAR_COLOR_BLACK = 0xFF;
1987
1988 // Exists both in V7 and in V72HE:
1989 byte VAR_NUM_GLOBAL_OBJS = 0xFF;
1990
1991 byte VAR_LAST_FRAME_BURN_TIME = 0xFF; // HE90+
1992 byte VAR_LAST_FRAME_SCUMM_TIME = 0xFF; // HE90+
1993
1994 byte VAR_WINDEX_RUNNING = 0xFF;
1995
1996#ifdef USE_RGB_COLOR
1997 // FM-Towns / PC-Engine specific
1998 Graphics::FontSJIS *_cjkFont = nullptr;
1999#endif
2000
2001 // FM-Towns specific
2002#ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
2003public:
2004 bool towns_isRectInStringBox(int x1, int y1, int x2, int y2);
2005 byte _townsPaletteFlags = 0;
2006 byte _townsCharsetColorMap[16];
2007
2008protected:
2009 void towns_drawStripToScreen(VirtScreen *vs, int dstX, int dstY, int srcX, int srcY, int w, int h);
2010 void towns_fillTopLayerRect(int x1, int y1, int x2, int y2, int col);
2011 void towns_swapVirtScreenArea(VirtScreen *vs, int x, int y, int w, int h);
2012 void towns_clearStrip(int strip);
2013#ifdef USE_RGB_COLOR
2014 void towns_setPaletteFromPtr(const byte *ptr, int numcolor = -1);
2015 void towns_setTextPaletteFromPtr(const byte *ptr);
2016#endif
2017 void towns_setupPalCycleField(int x1, int y1, int x2, int y2);
2018 void towns_processPalCycleField();
2019 void towns_resetPalCycleFields();
2020 void towns_restoreCharsetBg();
2021 void towns_scriptScrollEffect(int dir);
2022
2023 void requestScroll(int dir);
2024 void scrollLeft() { requestScroll(-1); }
2025 void scrollRight() { requestScroll(1); }
2026 void towns_waitForScroll(int waitForDirection, int threshold = 0);
2027 void towns_updateGfx();
2028
2029 Common::Rect _cyclRects[10];
2030 int _numCyclRects = 0;
2031 int _scrollRequest = 0;
2032 int _scrollDeltaAdjust = 0;
2033 bool _scrollNeedDeltaAdjust = 0;
2034 int _refreshDuration[20];
2035 int _refreshArrayPos = 0;
2036 bool _refreshNeedCatchUp = false;
2037 bool _enableSmoothScrolling = false;
2038 bool _forceFMTownsHiResMode = false;
2039 uint32 _scrollTimer = 0;
2040 uint32 _scrollDestOffset = 0;
2041 uint16 _scrollFeedStrips[3];
2042
2043 Common::Rect _curStringRect;
2044
2045 byte _townsOverrideShadowColor = 0;
2046 byte _textPalette[48];
2047 byte _townsClearLayerFlag = 1;
2048 byte _townsActiveLayerFlags = 3;
2049 static const uint8 _townsLayer2Mask[];
2050
2051 TownsScreen *_townsScreen = nullptr;
2052#else
2053 void scrollLeft() { redrawBGStrip(_gdi->_numStrips - 1, 1); }
2054 void scrollRight() { redrawBGStrip(0, 1); }
2055 void towns_updateGfx() {}
2056 void towns_waitForScroll(int waitForDirection, int threshold = 0) {}
2057 void towns_fillTopLayerRect(int x1, int y1, int x2, int y2, int col) {}
2058 void towns_swapVirtScreenArea(VirtScreen *vs, int x, int y, int w, int h) {}
2059#endif // DISABLE_TOWNS_DUAL_LAYER_MODE
2060};
2061
2062} // End of namespace Scumm
2063
2064#endif
Definition: error.h:81
ErrorCode getCode() const
Definition: error.h:112
Definition: keymap.h:66
Definition: mutex.h:67
Definition: path.h:52
Definition: random.h:44
Definition: stream.h:745
Definition: stream.h:351
Definition: serializer.h:352
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:155
const Common::String _targetName
Definition: engine.h:192
EngineFeature
Definition: engine.h:293
Definition: dialog.h:49
Definition: palette.h:195
Definition: system.h:166
Definition: actor.h:100
Definition: base-costume.h:49
Definition: base-costume.h:68
Definition: file.h:36
Definition: charset.h:159
Definition: charset.h:70
Definition: gfx.h:292
Definition: imuse.h:50
Definition: localizer.h:31
Definition: macgui.h:39
Definition: macgui_impl.h:52
Definition: macgui_indy3.h:39
Definition: macgui_loom.h:33
Definition: macgui_v5.h:33
Definition: macgui_v6.h:33
Definition: music.h:40
Definition: player_towns.h:32
Definition: resource.h:80
Definition: debugger.h:33
Definition: editor.h:49
Definition: scumm.h:536
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Gdi * _gdi
Definition: scumm.h:571
uint32 _lastInputScriptTime
Definition: scumm.h:993
ResourceManager * _res
Definition: scumm.h:574
void pauseEngineIntern(bool pause) override
bool currentScriptSlotIs(uint16 script) const
Definition: scumm.h:1078
void syncSoundSettings() override
bool hasFeature(EngineFeature f) const override
Graphics::Surface _textSurface
Definition: scumm.h:1703
Common::Error loadGameState(int slot) override
void errorString(const char *buf_input, char *buf_output, int buf_output_size) override
uint32 getIntegralTime(double fMsecs)
Common::Path _containerFile
Definition: scumm.h:1159
int _bootParam
Definition: scumm.h:996
Common::Error run() override
Definition: scumm.h:601
Common::RandomSource _rnd
Definition: scumm.h:568
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Common::String getSaveStateName(int slot) const override
Definition: scumm.h:618
Definition: serializer.h:33
Definition: sound.h:59
void void void void void debugC(int level, uint32 debugChannel, MSVC_PRINTF const char *s,...) GCC_PRINTF(3
@ kNoError
No error occurred.
Definition: error.h:48
Language
Definition: language.h:45
RenderMode
Definition: rendermode.h:48
int FORCEINLINE GCC_PRINTF(2, 0) int vsprintf_s(T(&dst)[N]
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
#define ARRAYSIZE(x)
Definition: util.h:114
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: actor.h:30
@ LIGHTMODE_actor_use_colors
Definition: scumm.h:152
@ LIGHTMODE_room_lights_on
Definition: scumm.h:136
@ LIGHTMODE_actor_use_base_palette
Definition: scumm.h:130
@ LIGHTMODE_flashlight_on
Definition: scumm.h:143
VirtScreenNumber
Definition: gfx.h:161
ResType
Definition: scumm.h:243
Definition: events.h:218
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: surface.h:67
Definition: detection.h:144
Definition: detection.h:130
Definition: detection.h:57
Definition: scumm.h:480
Definition: object.h:64
Definition: scumm.h:219
Definition: scumm.h:867
Definition: scumm.h:1680
Definition: scumm.h:201
Definition: scumm.h:163
Definition: scumm.h:171
Definition: scumm.h:184
Definition: verbs.h:47
Definition: script.h:128