ScummVM API documentation
immortal.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 IMMORTAL_H
23 #define IMMORTAL_H
24 
25 // Audio is only handled in kernel, therefore it is only needed here
26 #include "audio/mixer.h"
27 
28 // Immortal.h is the engine, so it needs the engine headers
29 #include "engines/engine.h"
30 #include "engines/savestate.h"
31 
32 // Theorectically, all graphics should be handled through driver, which is part of kernel, which is in immortal.h
33 #include "graphics/screen.h"
34 #include "graphics/surface.h"
35 
36 // Detection is only needed by the main engine
37 #include "immortal/detection.h"
38 
39 #include "common/formats/prodos.h"
40 #include "common/debug-channels.h"
41 #include "common/events.h"
42 #include "common/scummsys.h"
43 #include "common/system.h"
44 #include "common/fs.h"
45 #include "common/hash-str.h"
46 #include "common/random.h"
47 #include "common/serializer.h"
48 #include "common/util.h"
49 #include "common/platform.h"
50 
51 // Utilities.h contains many things used by all objects, not just immortal
52 #include "immortal/utilities.h"
53 
54 // Room also includes story.h
55 #include "immortal/room.h"
56 
57 namespace Immortal {
58 
59 // Needed by kernel for input
60 enum InputAction {
61  kActionNothing,
62  kActionKey,
63  kActionRestart, // Key "R" <-- Debug?
64  kActionSound,
65  kActionFire,
66  kActionButton, // Does this just refer to whatever is not the fire button?
67  kActionDBGStep // Debug key for moving engine forward one frame at a time
68 };
69 
70 enum ButtonHeldMask {
71  kButton0Held = 2,
72  kButton1Held = 4
73 };
74 
75 enum InputDirection {
76  kDirectionUp,
77  kDirectionLeft,
78  kDirectionDown,
79  kDirectionRight
80 };
81 
82 // Needed by kernel for text
83 enum FadeType {
84  kTextFadeIn,
85  kTextDontFadeIn
86 };
87 
88 // Needed by kernel for music
89 enum Song {
90  kSongNothing,
91  kSongMaze,
92  kSongCombat,
93  kSongText
94 };
95 
96 enum Sound {
97  kSoundSwish = 6,
98  kSoundAwe,
99  kSoundHuh,
100  kSoundClank,
101  kSoundFireBall,
102  kSoundDoor
103 };
104 
105 // Needed by logic for various things
106 enum MonsterID {
107  kPlayerID
108 };
109 
110 // Needed by logic for certificate processing
111 enum CertificateIndex : uint8 {
112  kCertHits,
113  kCertLevel,
114  kCertLoGameFlags,
115  kCertHiGameFlags,
116  kCertQuickness,
117  kCertInvLo,
118  kCertInvHi,
119  kCertGoldLo,
120  kCertGoldHi
121 };
122 
123 // Needed by logic for various things
124 enum GameFlags : uint8 {
125  kSavedNone,
126  kSavedKing,
127  kSavedAna
128 };
129 
130 // Needed by level (maybe?)
131 enum LevelType {
132  kRoomType,
133  kMonsterType,
134  kObjectType
135 };
136 
137 // Basically the equivalent of the explosion from a projectile in other games I think
138 struct Spark {
139 };
140 
141 // Generic sprites can be used anywhere, just sort of misc sprites
143 };
144 
145 // Doors are a property of the level, not the room, they define the connections between rooms
146 struct Door {
147  uint8 _x = 0;
148  uint8 _y = 0;
149  uint8 _fromRoom = 0;
150  uint8 _toRoom = 0;
151  uint8 _busyOnRight = 0;
152  uint8 _on = 0;
153 };
154 
155 // Universe is a set of properties for the entire level, nor just the room
156 struct Univ {
157  uint16 _rectX = 0;
158  uint16 _rectY = 0;
159  uint16 _numAnims = 0;
160  uint16 _numCols = 0;
161  uint16 _numRows = 0;
162  uint16 _numChrs = 0;
163  uint16 _num2Cols = 0;
164  uint16 _num2Rows = 0;
165  uint16 _num2Cells = 0;
166  uint16 _num2Chrs = 0;
167 };
168 
169 struct Chr {
170  byte *_scanlines[32];
171 };
172 
173 struct ImmortalGameDescription;
174 
175 // Forward declaration because we will need the Disk and Room classes
176 class ProDosDisk;
177 class Room;
178 
179 class ImmortalEngine : public Engine {
180 private:
181  Common::RandomSource _randomSource;
182 
183 protected:
184  // Engine APIs
185  Common::Error run() override;
186 
187 public:
188  ImmortalEngine(OSystem *syst, const ADGameDescription *gameDesc);
189  ~ImmortalEngine() override;
190 
191  const ADGameDescription *_gameDescription;
192 
193  /* Terrible functions because C doesn't like
194  * bit manipulation enough
195  */
196  uint16 xba(uint16 ab); // This just replicates the XBA command from the 65816, because flipping the byte order is somehow not a common library function???
197  uint16 rol(uint16 ab, int n); // Rotate bits left by n
198  uint16 ror(uint16 ab, int n); // Rotate bits right by n
199  uint16 mult16(uint16 a, uint16 b); // Just avoids using (uint16) everywhere, and is slightly closer to the original
200 
201  /*
202  * --- Members ---
203  *
204  */
205 
206  /*
207  * Constants
208  */
209 
210  // Misc constants
211  const int kNumLengths = 21;
212  const int kNiceTime = 36;
213  const int kMaxCertificate = 16;
214 
215  // Screen constants
216  const int kScreenW__ = 128; // ??? labeled in source as SCREENWIDTH
217  const int kScreenH__ = 128; // ???
218  const int kViewPortW = 256;
219  const int kViewPortH = 128;
220  const int kScreenSize = (kResH * kResV) * 2; // The size of the screen buffer is (320x200) * 2 byte words
221  const uint16 kScreenLeft = 32;
222  const uint16 kScreenTop = 20;
223  const uint8 kTextLeft = 8;
224  const uint8 kTextTop = 4;
225  const uint8 kGaugeX = 0;
226  const uint8 kGaugeY = static_cast<uint8>((-13) & 0xff); // ???
227  const uint16 kScreenBMW = 160; // Screen BitMap Width?
228  const uint16 kChrW = 64;
229  const uint16 kChrH = 32;
230  const uint16 kChrH2 = kChrH * 2;
231  const uint16 kChrH3 = kChrH * 3;
232  const uint16 kChrLen = (kChrW / 2) * kChrH;
233  const uint16 kChrBMW = kChrW / 2;
234  const uint16 kLCutaway = 4;
235  const uint16 kLDrawSolid = 32 * ((3 * 16) + 5);
236 
237  const uint16 kChrDy[19] = {kChr0, kChrH, kChrH2, kChrH, kChrH2,
238  kChrH2, kChrH, kChrH2, kChrH2, kChr0,
239  kChr0, kChrH2, kChrH, kChrH2, kChrH2,
240  kChrH2, kChrH, kChrH2, kChrH2
241  };
242 
243  const uint16 kChrMask[19] = {kChr0, kChr0, kChr0, kChr0,
244  kChrR, kChrL, kChr0, kChrL,
245  kChrR, kChr0, kChr0, kChrLD,
246  kChr0, kChrR, kChrLD, kChrRD,
247  kChr0, kChrRD, kChrL
248  };
249 
250  const uint16 kIsBackground[36] = {1, 0, 0, 0, 0, 0,
251  0, 0, 0, 1, 1, 0,
252  0, 0, 0, 0, 0, 0,
253  0, 0, 0, 0, 0, 0,
254  0, 0, 0, 0, 0, 0,
255  0, 0, 0, 0, 0, 0
256  };
257 
258  // Disk offsets
259  const int kPaletteOffset = 21205; // This is the byte position of the palette data in the disk
260 
261  // Sprite constants
262  const uint16 kMaxSpriteW = 64;
263  const uint16 kMaxSpriteH = 64;
264  const uint16 kSpriteDY = 32;
265  const uint16 kVSX = kMaxSpriteW;
266  const uint16 kVSY = kSpriteDY;
267  const uint16 kVSBMW = (kViewPortW + kMaxSpriteW) / 2;
268  const uint16 kVSLen = kVSBMW * (kViewPortH + kMaxSpriteH);
269  const uint16 kVSDY = 32; // difference from top of screen to top of viewport in the virtual screen buffer
270  const uint16 kMySuperBottom = kVSDY + kViewPortH;
271  const uint16 kSuperBottom = 200;
272  const uint16 kMySuperTop = kVSDY;
273  const uint16 kSuperTop = 0;
274  const uint16 kViewPortSpX = 32;
275  const uint16 kViewPortSpY = 0;
276  const uint16 kWizardX = 28; // Common sprite center for some reason
277  const uint16 kWizardY = 37;
278  const uint16 kObjectY = 24;
279  const uint16 kObjectX = 32;
280  const uint16 kObjectHeight = 48;
281  const uint16 kObjectWidth = 64;
282 
283  // Text constants
284  const uint8 kMaxRows = 5;
285  const uint8 kMaxCollumns = 26;
286 
287  const uint16 kYesNoY = 88;
288  const uint16 kYesNoX1 = 8;
289  const uint16 kYesNoX2 = 182;
290 
291  // Asset constants
292  const char kGaugeOn = 1; // On uses the sprite at index 1 of the font spriteset
293  const char kGaugeOff = 0; // Off uses the sprite at index 0 of the font spriteset
294  const char kGaugeStop = 1; // Literally just means the final kGaugeOn char to draw
295  const char kGaugeStart = 1; // First kGaugeOn char to draw
296 
297  // Level constants
298  const int kStoryNull = 5;
299  const int kMaxFilesPerLevel = 16;
300  const int kMaxPartInstances = 4;
301  const int kLevelToMaze[8] = {0, 0, 1, 1, 2, 2, 2, 3};
302 
303  /*
304  * 'global' members
305  */
306 
307  // Misc
308  Common::ErrorCode _err; // If this is not kNoError at any point, the engine will stop
309  uint8 _certificate[16]; // The certificate (password) is basically the inventory/equipment array
310  uint8 _lastCertLen = 0;
311  bool _draw = 0; // Whether the screen should draw this frame
312  int _zero = 0; // No idea what this is yet
313  bool _gameOverFlag = false;
314  uint8 _gameFlags = 0; // Bitflag array of event flags, but only two were used (saving ana and saving the king) <-- why is gameOverFlag not in this? Lol
315  bool _themePaused = false; // In the source, this is actually considered a bit flag array of 2 bits (b0 and b1). However, it only ever checks for non-zero, so it's effectively only 1 bit.
316  int _titlesShown = 0;
317  int _time = 0;
318  int _promoting = 0; // I think promoting means the title stuff
319  bool _restart = false;
320 
321  // Story members
322  Story _stories[8];
323 
324  // Level members
325  int _maxLevels = 0; // This is determined when loading in story files
326  int _level = 0;
327  bool _levelOver = false;
328  int _count = 0;
329  int _lastLevelLoaded = 0;
330  int _lastSongLoaded = 0;
331  int _storyLevel = 0;
332  int _storyX = 0;
333  int _loadA = 0;
334  int _loadY = 0;
335  uint16 _initialX = 0;
336  uint16 _initialY = 0;
337  int _initialBX = 0;
338  int _initialBY = 0;
339  int _dRoomNum = 0;
340  int _initialRoom = 0;
341  int _currentRoom = 0;
342  int _lastType = 0;
343  int _roomCellX = 0;
344  int _roomCellY = 0;
345  Room *_rooms[kMaxRooms]; // Rooms within the level
346  Common::Array<SFlame> _allFlames[kMaxRooms]; // The level needs it's own set of flames so that the flames can be turned on/off permanently. This is technically more like a hashmap in the source, but it could also be seen as a 2d array, just hashed together in the source
347 
348  // Door members
349  Common::Array<Door> _doors;
350  uint8 _numDoors = 0;
351  uint8 _doorRoom = 0;
352  uint8 _doorToNextLevel = 0;
353  uint8 _doorCameInFrom = 0;
354  uint8 _ladders = 0;
355  uint8 _numLadders = 0;
356  uint8 _ladderInUse = 0;
357  uint8 _secretLadder = 0;
358  uint8 _secretCount = 0;
359  uint8 _secretDelta = 0;
360 
361  // Debug members
362  bool _singleStep = false; // Flag for _singleStep mode
363 
364  // Input members
365  int _pressedAction = 0;
366  int _heldAction = 0;
367  int _pressedDirection = 0;
368  int _heldDirection = 0;
369 
370  // Text printing members
371  uint8 _slowText = 0;
372  uint8 _formatted = 0;
373  uint8 _collumn = 0;
374  uint8 _row = 0;
375  uint8 _myButton = 0;
376  uint8 _lastYes = 0;
377 
378  // Music members
379  Song _playing; // Currently playing song
380  int _themeID = 0; // Not sure yet tbh
381  int _combatID = 0;
382 
383  // Asset members
384  int _numSprites = 0; // This is more accurately actually the index within the sprite array, so _numSprites + 1 is the current number of sprites
385  DataSprite _dataSprites[kFont + 1]; // All the sprite data, indexed by SpriteName
386  Sprite _sprites[kMaxSprites]; // All the sprites shown on screen
387  Cycle _cycles[kMaxCycles];
388  Common::Array<Common::String> _strPtrs; // Str should really be a char array, but inserting frame values will be stupid so it's just a string instead
389  Common::Array<Motive> _motivePtrs;
390  Common::Array<Damage> _damagePtrs;
391  Common::Array<Use> _usePtrs;
392  Common::Array<Pickup> _pickupPtrs;
393  Common::Array<SCycle> _cycPtrs; // This is not actually a set of pointers, but it is serving the function of what was called cycPtrs in the source
394  CArray2D<Motive> _programPtrs;
395  Common::Array<ObjType> _objTypePtrs;
396 
397  // Universe members
398  Univ *_univ; // Pointer to the struct that contains the universe properties
399  uint16 *_logicalCNM; // Draw-type data for the CNM (indexes into )
400  uint16 *_CNM; // Stands for CHARACTER NUMBER MAP, but really it should be TILE NUMBER MAP, because it points to tiles, which are made of characters
401  byte *_oldCBM; // Stands for CHARACTER BIT MAP, but should probably be called like, TILE CHARACTER MAP, because it is the full gfx data for all tiles
402  Common::Array<Chr> _Draw; // In the source this contained the Linear Coded Chr Routines, but here it just contains the expanded pixel data
403  uint16 *_Solid;
404  uint16 *_Right;
405  uint16 *_Left;
406  Common::SeekableReadStream *_dataBuffer; // This contains the uncompressed CNM + CBM
407 
408  uint16 *_modCNM;
409  uint16 *_modLogicalCNM;
410 
411  uint16 _myCNM[(kViewPortCW + 1)][(kViewPortCH + 1)];
412  uint16 _myModCNM[(kViewPortCW + 1)][(kViewPortCH + 1)];
413  uint16 _myModLCNM[(kViewPortCW + 1)][(kViewPortCH + 1)];
414 
415  // Screen members
416  byte *_screenBuff; // The final buffer that will transfer to the screen
417  Graphics::Surface *_mainSurface; // The ScummVM Surface
418 
419  uint16 _columnX[kViewPortCW + 1];
420  uint16 _columnTop[kViewPortCW + 1];
421  uint16 _columnIndex[kViewPortCW + 1]; // Why the heck is this an entire array, when it's just an index that gets zeroed before it gets used anyway...
422  uint16 _tIndex[kMaxDrawItems];
423  uint16 _tPriority[kMaxDrawItems];
424  uint16 _viewPortX = 0;
425  uint16 _viewPortY = 0;
426  uint16 _myViewPortX = 0; // Probably mirror of viewportX
427  uint16 _myViewPortY = 0;
428  int _lastGauge = 0; // Mirror for player health, used to update health gauge display
429  uint16 _lastBMW = 0; // Mirrors used to determine where bitmap width needs to be re-calculated
430  uint16 _lastY = 0;
431  uint16 _lastPoint = 0;
432  uint16 _penX = 0; // Basically where in the screen we are currently drawing
433  uint16 _penY = 0;
434  uint16 _myUnivPointX = 0;
435  uint16 _myUnivPointY = 0;
436  int _num2DrawItems = 0;
437  GenericSprite _genSprites[6];
438 
439  // Palette members
440  int _dontResetColors = 0; // Not sure yet
441  bool _usingNormal = 0; // Whether the palette is using normal
442  bool _dim = 0; // Whether the palette is dim
443  uint16 _palUniv[16];
444  uint16 _palDefault[16];
445  uint16 _palWhite[16];
446  uint16 _palBlack[16];
447  uint16 _palDim[16];
448  byte _palRGB[48]; // Palette that ScummVM actually uses, which is an RGB conversion of the original
449 
450 
451  /*
452  * --- Functions ---
453  *
454  */
455 
456  /*
457  * [Kernel.cpp] Functions from Kernel.gs and Driver.gs
458  */
459 
460  // Screen
461  void clearScreen(); // Draws a black rectangle on the screen buffer but only inside the frame
462  void whiteScreen(); // Draws a white rectanlge on the screen buffer (but does not do anything with resetColors)
463  void rect(int x, int y, int w, int h); // Draws a solid rectangle at x,y with size w,h. Also shadows for blit?
464  void backspace(); // Moves draw position back and draws empty rect in place of char
465  void printByte(int b);
466  void printChr(char c);
467  void loadWindow(); // Gets the window.bm file
468  void drawUniv(); // Draw the background, add the sprites, determine draw order, draw the sprites
469  void copyToScreen(); // If draw is 0, just check input, otherwise also copy the screen buffer to the scummvm surface and update screen
470  void mungeBM(); // Put together final bitmap?
471  void blit(); // Will probably want this to be it's own function
472  void blit40(); // Uses macro blit 40 times
473  void sBlit();
474  void scroll();
475  void makeMyCNM(); // ?
476  void drawBGRND(); // Draw floor parts of leftmask rightmask and maskers
477  void addRows(); // Add rows to drawitem array
478  void addSprite(uint16 vpX, uint16 vpY, SpriteName s, int img, uint16 x, uint16 y, uint16 p);
479  void addSprites(); // Add all active sprites that are in the viewport, into a list that will be sorted by priority
480  void sortDrawItems(); // Sort said items
481  void drawItems(); // Draw the items over the background
482  void drawIcon(int img);
483  void setPen(uint16 penX, uint16 penY); // Sets the 'pen' x and y positions, including making y negative if above a certain point
484  void center();
485  void carriageReturn();
486 
487  // Music
488  void toggleSound(); // Actually pauses the sound, doesn't just turn it off/mute
489  void fixPause();
490  Song getPlaying();
491  void playMazeSong();
492  void playCombatSong();
493  void playTextSong();
494  void doGroan();
495  void stopMusic();
496  void musicPause(int sID);
497  void musicUnPause(int sID);
498  void loadSingles(Common::String songName); // Loads and then parse the maze song
499  void standardBeep();
500 
501  // Palette
502  void loadPalette(); // Get the static palette data from the disk
503  void setColors(uint16 pal[]); // Applies the current palette to the ScummVM surface palette
504  void fixColors(); // Determine whether the screen should be dim or normal
505  void useNormal();
506  void useDim();
507  void useBlack();
508  void useWhite();
509  void pump(); // Alternates between white and black with delays in between (flashes screen)
510  void fadePal(uint16 pal[], int count, uint16 target[]); // Fades the palette except the frame
511  void fade(uint16 pal[], int dir, int delay); // Calls fadePal() by a given delay each iteration
512  void fadeOut(int j); // Calls Fade with a delay of j jiffies and direction 1
513  void fadeIn(int j); // || and direction 0
514  void normalFadeOut();
515  void slowFadeOut();
516  void normalFadeIn();
517 
518  // Assets
519  Common::SeekableReadStream *loadIFF(Common::String fileName); // Loads a file and uncompresses if it is compressed
520  void initStoryStatic(); // Sets up all of the global static story elements
521  int loadUniv(char mazeNum); // Unpacks the .CNM and .UNV files into all the CNM stuff, returns the total length of everything
522  void loadMazeGraphics(int m); // Creates a universe with a maze
523  void makeBlisters(int povX, int povY); // Turns the unmodified CNM/CBM/LCNM etc into the modified ones to actually be used for drawing the game
524  void loadFont(); // Gets the font.spr file, and centers the sprite
525  void clearSprites(); // Clears all sprites before drawing the current frame
526  void loadSprites(); // Loads all the sprite files and centers their sprites (in spritelist, but called from kernel)
527 
528  // Input
529  void userIO(); // Get input
530  void pollKeys(); // Buffer input
531  void noNetwork(); // Setup input mirrors
532  void waitKey(); // Waits until a key is pressed (until getInput() returns true)
533  void waitClick(); // Waits until one of the two buttons is pressed
534  void blit8(); // This is actually just input, but it is called blit because it does a 'paddle blit' 8 times
535 
536  // These will replace the myriad of hardware input handling from the source
537  bool getInput(); // True if there was input, false if not
538  void addKeyBuffer();
539  void clearKeyBuff();
540 
541 
542  /*
543  * [DrawChr.cpp] Functions from DrawChr.cpp
544  */
545 
546  // Main
547  int mungeCBM(uint16 num2Chrs);
548  void storeAddr(uint16 *drawType, uint16 chr2, uint16 drawIndex);
549  void mungeSolid(int oldChr, uint16 &drawIndex);
550  void mungeLRHC(int oldChr, uint16 &drawIndex);
551  void mungeLLHC(int oldChr, uint16 &drawIndex);
552  void mungeULHC(int oldChr, uint16 &drawIndex);
553  void mungeURHC(int oldChr, uint16 &drawIndex);
554  void drawSolid(int chr, int x, int y);
555  void drawULHC(int chr, int x, int y);
556  void drawURHC(int chr, int x, int y);
557  void drawLLHC(int chr, int x, int y);
558  void drawLRHC(int chr, int x, int y);
559 
560 
561  /*
562  * [Logic.cpp] Functions from Logic.GS
563  */
564 
565  // Debug
566  void doSingleStep(); // Let the user advance the engine one frame at a time
567 
568  // Main
569  void trapKeys(); // Poorly named, this checks if the player wants to restart/pause music/use debug step
570  int keyOrButton(); // Returns value based on whether it was a keyboard key or a button press
571  void logicInit();
572  void logic(); // Keeps time, handles win and lose conditions, then general logic
573  void restartLogic(); // This is the actual logic init
574  int logicFreeze(); // Overcomplicated way to check if game over or level over
575  void updateHitGauge();
576  void drawGauge(int h);
577  void makeCertificate();
578  void calcCheckSum(int l, uint8 checksum[]); // Checksum is one word, but the source called it CheckSum
579  bool getCertificate();
580  void printCertificate();
581 
582  // Misc
583  bool printAnd(Str s);
584  bool fromOldGame();
585  void setGameFlags(uint16 f);
586  uint16 getGameFlags();
587  void setSavedKing();
588  bool isSavedKing();
589  void setSavedAna();
590  bool isSavedAna();
591  int getLevel(); // Literally just return _level...
592  void gameOverDisplay();
593  void gameOver();
594  void levelOver();
595 
596 
597  /*
598  * [Misc.cpp] Functions from Misc
599  */
600 
601  // Misc
602  void miscInit();
603  void setRandomSeed();
604  void getRandom();
605 
606  // Input related
607  bool buttonPressed();
608  bool firePressed();
609 
610  // Text printing
611  void myFadeOut();
612  void myFadeIn();
613  bool textPrint(Str s, int n);
614  bool textBeginning(Str s, int n);
615  bool textSub(Str s, FadeType f, int n);
616  void textEnd(Str s, int n);
617  void textMiddle(Str s, int n);
618 
619  void textCR();
620  void textPageBreak(Common::String s, int &index);
621  void textAutoPageBreak();
622  void textDoSpace(Common::String s, int index);
623  void textBounceDelay();
624 
625  bool yesNo();
626  void noOn();
627  void yesOn();
628 
629  void myDelay(int j);
630 
631 
632  /*
633  * [Level.cpp] Functions from level.GS
634  * < All functions implemented (in some capacity)! >
635  */
636  // Init
637  void levelInitAtStartOfGameOnly();
638  void levelInit();
639  //void levelGetCount <-- lda count
640 
641  // Main
642  void levelStory(int l);
643  void levelLoadFile(int l);
644  void levelNew(int l);
645  void levelDrawAll();
646  void levelShowRoom(int r, int bX, int bY);
647  bool levelIsShowRoom(int r);
648  bool levelIsLoaded(int l);
649  void univAtNew(int l);
650  //void getLastType <-- lda lastType
651  //void setLastType <-- sta lastType
652  //void getShowRoom <-- lda currentRoom
653 
654  /*
655  * [Cycle.cpp] Functions from Cyc
656  */
657 
658  // Misc
659  void cycleFreeAll(); // Delete all cycles
660 
661 
662  /*
663  * [Story.cpp] Functions related to Story.GS
664  */
665 
666  // Init
667  void initStoryDynamic();
668 
669  /*
670  * [Sprites.cpp] Functions from Sprites.GS and spriteList.GS
671  */
672 
673  // Init
674  void initDataSprite(Common::SeekableReadStream *f, DataSprite *d, int index, uint16 cenX, uint16 cenY); // Initializes the data sprite
675 
676  // Main
677  void superSprite(DataSprite *dSprite, uint16 x, uint16 y, int img, uint16 bmw, byte *dst, uint16 superTop, uint16 superBottom);
678  bool clipSprite(uint16 &height, uint16 &pointIndex, uint16 &skipY, DataSprite *dSprite, uint16 &pointX, uint16 &pointY, int img, uint16 bmw, uint16 superTop, uint16 superBottom);
679  void spriteAligned(DataSprite *dSprite, Image &img, uint16 &skipY, uint16 &pointIndex, uint16 &height, uint16 bmw, byte *dst);
680 
681  /*
682  * [Compression.cpp] Functions from Compression.GS
683  */
684 
685  // Main routines
686  Common::SeekableReadStream *unCompress(Common::File *source, int lSource);
687 
688  // Subroutines called by unCompress
689  void setUpDictionary(uint16 *pCodes, uint16 *pTk, uint16 &findEmpty);
690  int inputCode(uint16 &outCode, int &lSource, Common::File *source, uint16 &evenOdd);
691  int member(uint16 &codeW, uint16 &k, uint16 *pCodes, uint16 *pTk, uint16 &findEmpty, uint16 &index);
692 
693  /*
694  * [door.cpp] Functions from Door.GS
695  */
696 
697  void roomTransfer(int r, int x, int y); // Transfers the player from the current room to a new room at x,y
698  void doorOpenSecret();
699  void doorCloseSecret();
700  //void doorToNextLevel();
701  void doorInit();
702  void doorClrLock();
703  void doorNew(SDoor door);
704  void doorDrawAll();
705  void doorOnDoorMat();
706  //void doorEnter(); // <-- this is actually a method of Player Monster, should probably move it there later
707  int findDoorTop(int x, int y);
708  int findDoor(int x, int y);
709  bool doLockStuff(int d, MonsterID m, int top);
710  bool inDoorTop(int x, int y, MonsterID m);
711  bool inDoor(int x, int y, MonsterID m);
712  int doorDoStep(MonsterID m, int d, int index);
713  int doorSetOn(int d);
714  int doorComeOut(MonsterID m);
715  void doorSetLadders(MonsterID m);
716 
717 
718  /*
719  * [Music.cpp] Functions from music.GS and sound.GS
720  */
721 
722  // Misc
723 
724 
725  /*
726  * --- ScummVM general engine Functions ---
727  *
728  */
729 
730  Common::ErrorCode initDisks(); // Opens and parses IMMORTAL.dsk and IMMORTAL_GFX.dsk
731  uint32 getFeatures() const; // Returns the game description flags
732  Common::String getGameId() const; // Returns the game Id
733 
734  /* Gets a random number
735  */
736  uint32 getRandomNumber(uint maxNum) {
737  return _randomSource.getRandomNumber(maxNum);
738  }
739 
740  bool hasFeature(EngineFeature f) const override {
741  return
742  (f == kSupportsLoadingDuringRuntime) ||
743  (f == kSupportsSavingDuringRuntime) ||
744  (f == kSupportsReturnToLauncher);
745  };
746 
747  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
748  return true;
749  }
750  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
751  return true;
752  }
753 
754  /* Uses a serializer to allow implementing savegame
755  * loading and saving using a single method
756  */
757  Common::Error syncGame(Common::Serializer &s);
758 
759  /* Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) {
760  Common::Serializer s(nullptr, stream);
761  return syncGame(s);
762  }
763 
764  Common::Error loadGameStream(Common::SeekableReadStream *stream) {
765  Common::Serializer s(stream, nullptr);
766  return syncGame(s);
767  } */
768 };
769 
770 extern ImmortalEngine *g_immortal;
771 #define SHOULD_QUIT ::Immortal::g_immortal->shouldQuit()
772 
773 } // namespace Immortal
774 
775 #endif
Definition: sprite_list.h:47
Definition: str.h:59
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
Definition: error.h:84
Definition: immortal.h:142
Definition: definitions.h:25
Definition: array.h:52
Definition: advancedDetector.h:163
Definition: random.h:44
ErrorCode
Definition: error.h:47
Definition: room.h:91
Definition: immortal.h:179
uint getRandomNumber(uint max)
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: immortal.h:747
Definition: stream.h:745
Definition: serializer.h:79
bool hasFeature(EngineFeature f) const override
Definition: immortal.h:740
Definition: immortal.h:156
Definition: ustr.h:57
Definition: file.h:47
Definition: story.h:165
Definition: story.h:240
Definition: immortal.h:146
Definition: immortal.h:169
Definition: sprite_list.h:40
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: immortal.h:750
Definition: story.h:130
Definition: system.h:161
Definition: movie_decoder.h:32
Definition: engine.h:144
Definition: immortal.h:138