diff options
author | Matthew Stewart | 2018-07-23 22:06:24 -0400 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 |
commit | 0e85e19ee7530b4d41668982e0b10f04d6f29741 (patch) | |
tree | 4ef9ad91daeffd899e3e4f4ecf27be32f53aaa67 /engines/startrek | |
parent | c2dd39a6c2f1f9356110dcfe0cb36607373b19e3 (diff) | |
download | scummvm-rg350-0e85e19ee7530b4d41668982e0b10f04d6f29741.tar.gz scummvm-rg350-0e85e19ee7530b4d41668982e0b10f04d6f29741.tar.bz2 scummvm-rg350-0e85e19ee7530b4d41668982e0b10f04d6f29741.zip |
STARTREK: Move function descriptions to headers
Diffstat (limited to 'engines/startrek')
-rw-r--r-- | engines/startrek/awaymission.cpp | 21 | ||||
-rw-r--r-- | engines/startrek/bitmap.h | 22 | ||||
-rw-r--r-- | engines/startrek/graphics.cpp | 23 | ||||
-rw-r--r-- | engines/startrek/graphics.h | 23 | ||||
-rw-r--r-- | engines/startrek/iwfile.cpp | 4 | ||||
-rw-r--r-- | engines/startrek/iwfile.h | 4 | ||||
-rw-r--r-- | engines/startrek/menu.cpp | 38 | ||||
-rw-r--r-- | engines/startrek/room.cpp | 9 | ||||
-rw-r--r-- | engines/startrek/room.h | 151 | ||||
-rw-r--r-- | engines/startrek/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/startrek/sound.cpp | 6 | ||||
-rw-r--r-- | engines/startrek/sound.h | 3 | ||||
-rw-r--r-- | engines/startrek/sprite.cpp | 4 | ||||
-rw-r--r-- | engines/startrek/sprite.h | 3 | ||||
-rw-r--r-- | engines/startrek/startrek.cpp | 45 | ||||
-rw-r--r-- | engines/startrek/startrek.h | 145 | ||||
-rw-r--r-- | engines/startrek/text.cpp | 38 |
17 files changed, 308 insertions, 235 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp index c422f80b9a..63a0458ed4 100644 --- a/engines/startrek/awaymission.cpp +++ b/engines/startrek/awaymission.cpp @@ -463,10 +463,6 @@ void StarTrekEngine::unloadRoom() { _mapFile.reset(); } -/** - * Similar to loadActorAnim, but scale is determined by the y-position in the room. The - * further up (away) the object is, the smaller it is. - */ int StarTrekEngine::loadActorAnimWithRoomScaling(int actorIndex, const Common::String &animName, int16 x, int16 y) { Fixed8 scale = getActorScaleAtPosition(y); return loadActorAnim(actorIndex, animName, x, y, scale); @@ -673,14 +669,6 @@ void StarTrekEngine::handleAwayMissionAction() { } } -/** - * Returns true if the given position is contained in a polygon? - * - * The data passed contains the following words in this order: - * * Index of polygon (unused here) - * * Number of vertices in polygon - * * For each vertex: x and y coordinates. - */ bool StarTrekEngine::isPointInPolygon(int16 *data, int16 x, int16 y) { int16 numVertices = data[1]; int16 *vertData = &data[2]; @@ -740,10 +728,6 @@ void StarTrekEngine::checkTouchedLoadingZone(int16 x, int16 y) { _activeWarpHotspot = -1; } -/** - * Updates any nonzero away mission timers, and invokes ACTION_TIMER_EXPIRED when any one - * reaches 0. - */ void StarTrekEngine::updateAwayMissionTimers() { for (int i = 0; i < 8; i++) { if (_awayMission.timers[i] == 0) @@ -754,11 +738,6 @@ void StarTrekEngine::updateAwayMissionTimers() { } } -/** - * Returns true if the given position in the room is solid (not walkable). - * Reads from a ".map" file which has a bit for each position in the room, which is true - * when that position is solid. - */ bool StarTrekEngine::isPositionSolid(int16 x, int16 y) { assert(x >= 0 && x < SCREEN_WIDTH && y >= 0 && y < SCREEN_HEIGHT); diff --git a/engines/startrek/bitmap.h b/engines/startrek/bitmap.h index 8bc9cd2952..4ff285cbab 100644 --- a/engines/startrek/bitmap.h +++ b/engines/startrek/bitmap.h @@ -22,23 +22,27 @@ struct Bitmap { protected: int32 pixelsArraySize; - Bitmap() : xoffset(0),yoffset(0),width(0),height(0),pixels(nullptr),pixelsArraySize(0) {} + Bitmap() : xoffset(0), yoffset(0), width(0), height(0), pixels(nullptr), pixelsArraySize(0) {} }; -// TextBitmap is the same as Bitmap, except it stores character indices in its "pixels" -// array instead of actual pixels. -// A consequence of this is that the pixels array is smaller than otherwise expected -// (since width/height still reflect the actual size when drawn). +/** + * TextBitmap is the same as Bitmap, except it stores character indices in its "pixels" + * array instead of actual pixels. + * A consequence of this is that the pixels array is smaller than otherwise expected + * (since width/height still reflect the actual size when drawn). + */ struct TextBitmap : Bitmap { TextBitmap(int w, int h); }; -// StubBitmap is a bitmap without any actual pixel data. Used as a stub for the -// "starfield" sprite, which is always in draw mode 1 (invisible), so it never gets drawn; -// however, it does trigger refreshes on the background in that area, so the game can draw -// on the background layer manually. +/** + * StubBitmap is a bitmap without any actual pixel data. Used as a stub for the + * "starfield" sprite, which is always in draw mode 1 (invisible), so it never gets drawn; + * however, it does trigger refreshes on the background in that area, so the game can draw + * on the background layer manually. + */ struct StubBitmap : Bitmap { StubBitmap(int w, int h); }; diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index 1612dc0347..5cbb528752 100644 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -118,9 +118,6 @@ void Graphics::clearScreenAndPriBuffer() { _vm->_system->updateScreen(); } -/** - * Note: this doesn't flush the palette to the screen (must call "setPaletteFadeLevel") - */ void Graphics::loadPalette(const Common::String &paletteName) { // Set the palette from a PAL file Common::String palFile = paletteName + ".PAL"; @@ -170,9 +167,6 @@ void Graphics::fadeoutScreen() { _paletteFadeLevel = 0; } -/** - * This flushes the palette to the screen. fadeLevel ranges from 0-100. - */ void Graphics::setPaletteFadeLevel(byte *palData, int fadeLevel) { byte palBuffer[256 * 3]; @@ -239,10 +233,6 @@ Common::Point Graphics::getMousePos() { return _vm->_system->getEventManager()->getMousePos(); } -/** - * The change to the mouse's bitmap won't take effect until drawAllSprites is called - * again. - */ void Graphics::setMouseBitmap(SharedPtr<Bitmap> bitmap) { _mouseBitmap = bitmap; @@ -250,13 +240,6 @@ void Graphics::setMouseBitmap(SharedPtr<Bitmap> bitmap) { _lockedMouseSprite.setBitmap(_mouseBitmap); } -/** - * This function is a workaround for when the mouse position needs to be locked in a set - * position (used in the action menu). This only affects the position it is drawn at; the - * sprite's "real" position is still updated normally. - * - * This does not call updateScreen. - */ void Graphics::lockMousePosition(int16 x, int16 y) { if (_mouseLocked) { if (x != _lockedMouseSprite.pos.x || y != _lockedMouseSprite.pos.y) { @@ -617,18 +600,12 @@ void Graphics::drawAllSprites(bool updateScreen) { } } -/** - * Sets "bitmapChanged" to true on all sprites before calling drawAllSprites. - */ void Graphics::forceDrawAllSprites(bool updateScreen) { for (int i = 0; i < _numSprites; i++) _sprites[i]->bitmapChanged = true; drawAllSprites(updateScreen); } -/** - * Returns the sprite at the given position (ignores mouse). - */ Sprite *Graphics::getSpriteAt(int16 x, int16 y) { for (int i = _numSprites - 1; i >= 0; i--) { Sprite *sprite = _sprites[i]; diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h index 7d48c035e6..bea8b8939a 100644 --- a/engines/startrek/graphics.h +++ b/engines/startrek/graphics.h @@ -63,10 +63,16 @@ public: byte *getBackgroundPixels(); void clearScreenAndPriBuffer(); + /** + * Note: this doesn't flush the palette to the screen (must call "setPaletteFadeLevel") + */ void loadPalette(const String &paletteFile); void copyRectBetweenBitmaps(Bitmap *destBitmap, int destX, int destY, Bitmap *srcBitmap, int srcX, int srcY, int width, int height); void fadeinScreen(); void fadeoutScreen(); + /** + * This flushes the palette to the screen. fadeLevel ranges from 0-100. + */ void setPaletteFadeLevel(byte *palData, int fadeLevel); void incPaletteFadeLevel(); void decPaletteFadeLevel(); @@ -78,7 +84,18 @@ public: SharedPtr<Bitmap> loadBitmap(String basename); Common::Point getMousePos(); + /** + * Changes the mouse bitmap. The change won't take effect until drawAllSprites is + * called again. + */ void setMouseBitmap(SharedPtr<Bitmap> bitmap); + /** + * This function is a workaround for when the mouse position needs to be locked in a set + * position (used in the action menu). This only affects the position it is drawn at; the + * sprite's "real" position is still updated normally. + * + * This does not call updateScreen. + */ void lockMousePosition(int16 x, int16 y); void unlockMousePosition(); SharedPtr<Bitmap> getMouseBitmap(); @@ -88,7 +105,13 @@ public: void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface); void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface, const Common::Rect &rect); void drawAllSprites(bool updateScreen=true); + /** + * Sets "bitmapChanged" to true on all sprites before calling drawAllSprites. + */ void forceDrawAllSprites(bool updateScreen=true); + /** + * Returns the sprite at the given position (ignores mouse). + */ Sprite *getSpriteAt(int16 x, int16 y); Sprite *getSpriteAt(Common::Point p) { return getSpriteAt(p.x, p.y); } diff --git a/engines/startrek/iwfile.cpp b/engines/startrek/iwfile.cpp index d97c20e7ea..9e9131f151 100644 --- a/engines/startrek/iwfile.cpp +++ b/engines/startrek/iwfile.cpp @@ -51,10 +51,6 @@ bool iwSorter(const Common::Point &p1, const Common::Point &p2) { return p1.y < p2.y; } -/** - * Returns the index of the nearest "key position" in the room that an object can walk to - * (in a straight line) from a given position. - */ int IWFile::getClosestKeyPosition(int16 x, int16 y) { // This is a sorted list of indices from 0 to _numEntries-1. // The index is stored in Point.x, and the "cost" (distance from position) is stored diff --git a/engines/startrek/iwfile.h b/engines/startrek/iwfile.h index ffc5467a6b..16291ad4c1 100644 --- a/engines/startrek/iwfile.h +++ b/engines/startrek/iwfile.h @@ -39,6 +39,10 @@ public: IWFile(StarTrekEngine *vm, const Common::String &filename); int getNumEntries() { return _numEntries; } + /** + * Returns the index of the nearest "key position" in the room that an object can walk to + * (in a straight line) from a given position. + */ int getClosestKeyPosition(int16 x, int16 y); ///< List of "key positions" used for pathing. diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp index 39f4c5af5b..e7d0b9abc1 100644 --- a/engines/startrek/menu.cpp +++ b/engines/startrek/menu.cpp @@ -28,9 +28,6 @@ namespace StarTrek { -/** - * Returns the index of the button at the given position, or -1 if none. - */ int StarTrekEngine::getMenuButtonAt(Sprite *sprites, int numSprites, int x, int y) { for (int i = 0; i < numSprites; i++) { const Sprite &spr = sprites[i]; @@ -52,14 +49,6 @@ int StarTrekEngine::getMenuButtonAt(Sprite *sprites, int numSprites, int x, int return -1; } -/** - * This chooses a sprite from the list to place the mouse cursor at. The sprite it chooses - * may be, for example, the top-leftmost one in the list. Exact behaviour is determined by - * the "mode" parameter. - * - * If "containMouseSprite" is a valid index, it's ensured that the mouse is contained - * within it. "mode" should be -1 in this case. - */ void StarTrekEngine::chooseMousePositionFromSprites(Sprite *sprites, int numSprites, int containMouseSprite, int mode) { uint16 mouseX1 = 0x7fff; // Candidate positions to warp mouse to uint16 mouseY1 = 0x7fff; @@ -167,10 +156,6 @@ void StarTrekEngine::chooseMousePositionFromSprites(Sprite *sprites, int numSpri } -/** - * Draws or removes the outline on menu buttons when the cursor hovers on them, or leaves - * them. - */ void StarTrekEngine::drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color) { int lineWidth = bitmap->width-2; int offsetToBottom = (bitmap->height-3)*bitmap->width; @@ -266,9 +251,6 @@ void StarTrekEngine::showOptionsMenu(int x, int y) { } } -/** - * Show the "action selection" menu, ie. look, talk, etc. - */ int StarTrekEngine::showActionMenu() { const int actionMappingUp[] = { // Actions to jump to when up is pressed ACTION_TALK, // <- ACTION_WALK @@ -513,9 +495,6 @@ lookupNextAction: return action; } -/** - * Loads a .MNU file, which is a list of buttons to display. - */ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) { if (_activeMenu == nullptr) _keyboardControlsMouseOutsideMenu = _keyboardControlsMouse; @@ -563,9 +542,6 @@ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) { _keyboardControlsMouse = false; } -/** - * Sets which buttons are visible based on the given bitmask. - */ void StarTrekEngine::setVisibleMenuButtons(uint32 bits) { for (int i = 0; i < _activeMenu->numButtons; i++) { Sprite *sprite = &_activeMenu->sprites[i]; @@ -608,9 +584,6 @@ void StarTrekEngine::setVisibleMenuButtons(uint32 bits) { } } -/** - * Disables the given bitmask of buttons. - */ void StarTrekEngine::disableMenuButtons(uint32 bits) { _activeMenu->disabledButtons |= bits; if (_activeMenu->selectedButton != -1 @@ -627,10 +600,6 @@ void StarTrekEngine::enableMenuButtons(uint32 bits) { _activeMenu->disabledButtons &= ~bits; } -/** - * This returns either a special menu event (negative number) or the retval of the button - * clicked (usually an index, always positive). - */ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTextbox) { uint32 tickWhenClickingEnabled = _clockTicks + ticksUntilClickingEnabled; @@ -886,9 +855,6 @@ void StarTrekEngine::unloadMenuButtons() { _keyboardControlsMouse = _keyboardControlsMouseOutsideMenu; } -/** - * Sets the mouse bitmap based on which action is selected. - */ void StarTrekEngine::chooseMouseBitmapForAction(int action, bool withRedOutline) { const char *lookActionBitmaps[] = { "lookh0", // The "look" action randomly animates with these images @@ -1005,10 +971,6 @@ void StarTrekEngine::showGameOverMenu() { } } -/** - * This can be called from startup or from the options menu. - * On startup, this tries to load the setting without user input. - */ void StarTrekEngine::showTextConfigurationMenu(bool fromOptionMenu) { const char *options[] = { // TODO: languages... "Text display", diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index a9f83118b6..9806fedc33 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -251,9 +251,6 @@ void Room::loadActorStandAnim(int actorIndex) { } } -/** - * This is exactly the same as "loadActorAnim", but the game calls it at different times? - */ void Room::loadActorAnim2(int actorIndex, Common::String anim, int16 x, int16 y, uint16 finishedAnimActionParam) { loadActorAnim(actorIndex, anim, x, y, finishedAnimActionParam); } @@ -373,9 +370,6 @@ void Room::walkCrewmanC(int actorIndex, int16 destX, int16 destY, void (Room::*f } } -/** - * Loads a pair of .map and .iw files to change the room's collisions and pathfinding. - */ void Room::loadMapFile(const Common::String &name) { _vm->_mapFilename = name; _vm->_iwFile.reset(); @@ -418,9 +412,6 @@ Common::Point Room::getActorPos(int actorIndex) { return _vm->_actorList[actorIndex].pos; } -/** - * Returns a word in range [start, end] (that's inclusive). - */ int16 Room::getRandomWordInRange(int start, int end) { return _vm->getRandomWord() % (end - start + 1) + start; } diff --git a/engines/startrek/room.h b/engines/startrek/room.h index 937d0ff213..19585c36ea 100644 --- a/engines/startrek/room.h +++ b/engines/startrek/room.h @@ -58,26 +58,33 @@ public: Room(StarTrekEngine *vm, const Common::String &name); ~Room(); - // Helper stuff for RDF access uint16 readRdfWord(int offset); - // Scale-related stuff; at the "min Y" position or below, the crewmembers have - // "minimum" scale; that value rises to the "max scale" value by the time they reach - // the "max Y" value. + /** + * Scale-related stuff; at the "min Y" position or below, the crewmembers have + * "minimum" scale; that value rises to the "max scale" value by the time they reach + * the "max Y" value. + */ uint16 getMaxY() { return readRdfWord(0x06); } uint16 getMinY() { return readRdfWord(0x08); } Fixed8 getMinScale() { return Fixed8::fromRaw(readRdfWord(0x0a)); } Fixed8 getMaxScale() { return Fixed8::fromRaw(readRdfWord(0x0c)); } - // words 0x0e and 0x10 in RDF file are pointers to start and end of event code. - // That code is instead rewritten on a per-room basis. + /** + * Check if a particular action is defined for this room. + */ bool actionHasCode(const Action &action); bool actionHasCode(byte type, byte b1, byte b2, byte b3); + /** + * Execute a particular action for this room, if defined. + */ bool handleAction(const Action &action); bool handleAction(byte type, byte b1, byte b2, byte b3); - // Same as above, but if any byte in the action is -1 (0xff), it matches any value. + /** + * Same as above, but if any byte in the action is -1 (0xff), it matches any value. + */ bool handleActionWithBitmask(const Action &action); bool handleActionWithBitmask(byte type, byte b1, byte b2, byte b3); @@ -90,10 +97,16 @@ public: uint16 getFirstDoorPolygonOffset() { return readRdfWord(0x1a); } uint16 getDoorPolygonEndOffset() { return readRdfWord(0x1c); } + /** + * Get the point at which a crewman beams in to this room (not properly defined for + * all rooms). + */ Common::Point getBeamInPosition(int crewmanIndex); - // This is analagous to above, but instead of beaming in, they just appear in a spot. - // Used sparingly, ie. in feather's serpent when appearing in cave after Quetzecoatl - // warps the crew. + /** + * This is analagous to above, but instead of beaming in, they just appear in a spot. + * Used sparingly, ie. in feather's serpent when appearing in cave after Quetzecoatl + * warps the crew. + */ Common::Point getSpawnPosition(int crewmanIndex); public: @@ -110,38 +123,106 @@ private: int findFunctionPointer(int action, void (Room::*funcPtr)()); + // Interface for room-specific code - void loadActorAnim(int actorIndex, Common::String anim, int16 x = -1, int16 y = -1, uint16 field66 = 0); // Cmd 0x00 - void loadActorAnimC(int actorIndex, Common::String anim, int16 x, int16 y, void (Room::*funcPtr)());// Cmd 0x00 - void loadActorStandAnim(int actorIndex); // Cmd 0x01 - void loadActorAnim2(int actorIndex, Common::String anim, int16 x = -1, int16 y = -1, uint16 field66 = 0);// Cmd 0x02 - int showRoomSpecificText(const char **textAddr); // (Deprecated, use function below) // Cmd 0x03 - int showText(const TextRef *text); // Cmd 0x03 - int showText(TextRef speaker, TextRef text); // Cmd 0x03 - int showText(TextRef text); // Cmd 0x03 - void giveItem(int item); // Cmd 0x04 + /** + * Cmd 0x00 + */ + void loadActorAnim(int actorIndex, Common::String anim, int16 x = -1, int16 y = -1, uint16 field66 = 0); + /** + * Cmd 0x00 + */ + void loadActorAnimC(int actorIndex, Common::String anim, int16 x, int16 y, void (Room::*funcPtr)()); + /** + * Cmd 0x01 + */ + void loadActorStandAnim(int actorIndex); + /** + * Cmd 0x02 + * This is exactly the same as "loadActorAnim", but the game calls it at different times? + */ + void loadActorAnim2(int actorIndex, Common::String anim, int16 x = -1, int16 y = -1, uint16 field66 = 0); + /** + * Cmd 0x03 + */ + int showRoomSpecificText(const char **textAddr); + int showText(const TextRef *text); + int showText(TextRef speaker, TextRef text); + int showText(TextRef text); + /** + * Cmd 0x04 + */ + void giveItem(int item); + // Command 0x05: "demon4ShowSunPuzzle" - void loadRoomIndex(int roomIndex, int spawnIndex); // Cmd 0x06 - void loseItem(int item); // Cmd 0x07 - void walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam = 0);// Cmd 0x08 + + /** + * Cmd 0x06 + */ + void loadRoomIndex(int roomIndex, int spawnIndex); + /** + * Cmd 0x07 + */ + void loseItem(int item); + /** + * Cmd 0x08 + */ + void walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam = 0); void walkCrewmanC(int actorIndex, int16 destX, int16 destY, void (Room::*funcPtr)()); // Cmd 0x08 - void loadMapFile(const Common::String &name); // Cmd 0x09 - void showBitmapFor5Ticks(const Common::String &bmpName, int priority); // Cmd 0x0a + /** + * Cmd 0x09: Loads a pair of .map and .iw files to change the room's collisions and pathfinding. + */ + void loadMapFile(const Common::String &name); + /** + * Cmd 0x0a + */ + void showBitmapFor5Ticks(const Common::String &bmpName, int priority); + /** + * Cmd 0x0b + */ + bool haveItem(int item); + // Command 0x0c: "demon6ShowCase" - bool haveItem(int item); // Cmd 0x0b - Common::Point getActorPos(int actorIndex); // Cmd 0x0d - int16 getRandomWordInRange(int start, int end); // Cmd 0x0e - void playSoundEffectIndex(int soundEffect); // Cmd 0x0f - void playMidiMusicTracks(int startTrack, int loopTrack = -1); // Cmd 0x10 - void endMission(int16 score, int16 arg2, int16 arg3); // Cmd 0x11 - void showGameOverMenu(); // Cmd 0x12 - void playVoc(Common::String filename); // Cmd 0x15 - void stopAllVocSounds(); // Cmd 0x17 + + /** + * Cmd 0x0d + */ + Common::Point getActorPos(int actorIndex); + /** + * Cmd 0x0e: Returns a word in range [start, end] (that's inclusive). + */ + int16 getRandomWordInRange(int start, int end); + /** + * Cmd 0x0f + */ + void playSoundEffectIndex(int soundEffect); + /** + * Cmd 0x10 + */ + void playMidiMusicTracks(int startTrack, int loopTrack = -1); + /** + * Cmd 0x11 + */ + void endMission(int16 score, int16 arg2, int16 arg3); + /** + * Cmd 0x12 + */ + void showGameOverMenu(); + /** + * Cmd 0x15 + */ + void playVoc(Common::String filename); + /** + * Cmd 0x17 + */ + void stopAllVocSounds(); // Helper functions for repetitive stuff. - // If "changeDirection" is true, they remain facing that direction even after their - // animation is finished. The game is inconsistent about doing this. + /** + * If "changeDirection" is true, they remain facing that direction even after their + * animation is finished. The game is inconsistent about doing this. + */ void spockScan(int direction, TextRef text, bool changeDirection = false); void mccoyScan(int direction, TextRef text, bool changeDirection = false); diff --git a/engines/startrek/saveload.cpp b/engines/startrek/saveload.cpp index 3d1a1aad3f..87f5a8a27a 100644 --- a/engines/startrek/saveload.cpp +++ b/engines/startrek/saveload.cpp @@ -172,10 +172,6 @@ bool StarTrekEngine::loadGame(int slot) { return true; } -/** - * Call this after loading "saveOrLoadMetadata" to load all the data pertaining to game - * execution. - */ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common::WriteStream *out, SavegameMetadata *meta) { Common::Serializer ser(in, out); diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp index 3d141499d3..9db92f87a6 100644 --- a/engines/startrek/sound.cpp +++ b/engines/startrek/sound.cpp @@ -85,9 +85,6 @@ void Sound::clearAllMidiSlots() { } } -/** - * Plays a midi track as a sound effect (one of midi slots 1-7) - */ void Sound::playMidiTrack(int track) { if (!_vm->_musicEnabled || !_vm->_musicWorking) return; @@ -261,9 +258,6 @@ void Sound::playSpeech(const Common::String &basename) { } } -/** - * Called when disabling sfx. - */ void Sound::stopAllVocSounds() { stopPlayingSpeech(); diff --git a/engines/startrek/sound.h b/engines/startrek/sound.h index f708456c02..37100b467c 100644 --- a/engines/startrek/sound.h +++ b/engines/startrek/sound.h @@ -116,6 +116,9 @@ public: ~Sound(); void clearAllMidiSlots(); + /** + * Plays a midi track as a sound effect (one of midi slots 1-7) + */ void playMidiTrack(int track); void playMidiTrackInSlot(int slot, int track); bool isMidiPlaying(); diff --git a/engines/startrek/sprite.cpp b/engines/startrek/sprite.cpp index 8961f9c5e4..2d5d4f8d3c 100644 --- a/engines/startrek/sprite.cpp +++ b/engines/startrek/sprite.cpp @@ -60,9 +60,7 @@ void Sprite::dontDrawNextFrame() { field16 = true; bitmapChanged = true; } -/** - * Returns a rect containing the sprite's bitmap on the screen. - */ + Common::Rect Sprite::getRect() { Common::Rect rect(bitmap->width, bitmap->height); rect.translate(pos.x - bitmap->xoffset, pos.y - bitmap->yoffset); diff --git a/engines/startrek/sprite.h b/engines/startrek/sprite.h index 9b052a135b..d498c18f63 100644 --- a/engines/startrek/sprite.h +++ b/engines/startrek/sprite.h @@ -65,6 +65,9 @@ struct Sprite : Common::Serializable { void setXYAndPriority(int16 x, int16 y, int16 priority); void dontDrawNextFrame(); + /** + * Returns a rect containing the sprite's bitmap on the screen. + */ Common::Rect getRect(); /// NOTE: even after calling this, "bitmap" must be reloaded by the caller. diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index fbbf535601..9a553d1116 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -577,9 +577,6 @@ void StarTrekEngine::initActors() { strcpy(_redshirtActor->animationString, "rstnd"); } -/** - * Set an actor's animation, position, and scale. - */ int StarTrekEngine::loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale) { debugC(6, kDebugGraphics, "Load animation '%s' on actor %d", animName.c_str(), actorIndex); @@ -606,10 +603,6 @@ int StarTrekEngine::loadActorAnim(int actorIndex, const Common::String &animName return actorIndex; } -/** - * Tries to make an actor walk to a position. - * Returns true if successful in initiating the walk. - */ bool StarTrekEngine::actorWalkToPosition(int actorIndex, const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY) { debugC(6, "Obj %d: walk from (%d,%d) to (%d,%d)", actorIndex, srcX, srcY, destX, destY); @@ -927,10 +920,6 @@ void StarTrekEngine::updateActorPositionWhileWalking(Actor *actor, int16 x, int1 actor->pos.y = y; } -/** - * Chooses a value for the actor's speed and direction, based on a source position and - * a destination position it's walking to. - */ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, int16 srcY, int16 destX, int16 destY) { actor->granularPosX = srcX; actor->granularPosY = srcY; @@ -988,10 +977,6 @@ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, in } } -/** - * Returns true if an actor can walk directly from a source position to a destination - * position without running into unwalkable terrain. - */ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16 destY) { int32 distX = destX - srcX; int32 distY = destY - srcY; @@ -1096,9 +1081,6 @@ int StarTrekEngine::findObjectAt(int x, int y) { return -1; } -/** - * Loads a bitmap for the animation frame with the given scale. - */ SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed8 scale) { SharedPtr<Bitmap> bitmapToReturn; @@ -1196,11 +1178,6 @@ SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filen } -/** - * Called when the "get" action is first selected. Returns a selected object. - * This behaves like other menus in that it holds game execution, but no actual menu pops - * up; it just waits for the player to select something on the screen. - */ int StarTrekEngine::selectObjectForUseAction() { while (true) { if (!(_awayMission.crewDownBitset & (1 << OBJECT_KIRK))) @@ -1307,9 +1284,6 @@ Common::String StarTrekEngine::getCrewmanAnimFilename(int actorIndex, const Comm return crewmanChars[actorIndex] + basename; } -/** - * Checks whether to change the mouse bitmap to have the red outline. - */ void StarTrekEngine::updateMouseBitmap() { const bool worksOnCrewmen[] = { // True if the action reacts with crewmen false, // ACTION_WALK @@ -1352,10 +1326,6 @@ void StarTrekEngine::updateMouseBitmap() { chooseMouseBitmapForAction(action, withRedOutline); } -/** - * Checks whether to walk a crewman to a hotspot (the last one obtained from - * a "findObjectAt" call). - */ bool StarTrekEngine::walkActiveObjectToHotspot() { if (!_objectHasWalkPosition) return false; @@ -1462,9 +1432,6 @@ void StarTrekEngine::showInventoryIcons(bool showItem) { _inventoryIconSprite.setBitmap(_gfx->loadBitmap("inv00")); } -/** - * Return true if an object is unselectable with the given action? - */ bool StarTrekEngine::isObjectUnusable(int object, int action) { if (action == ACTION_LOOK) return false; @@ -1501,9 +1468,6 @@ void StarTrekEngine::hideInventoryIcons() { } } -/** - * When a crewman is collapsed, they get once a timer reaches 0. - */ void StarTrekEngine::updateCrewmanGetupTimers() { if (_awayMission.crewDownBitset == 0) return; @@ -1798,11 +1762,6 @@ SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 s return scaledBitmap; } -/** - * This takes a row of an unscaled bitmap, and copies it to a row of a scaled bitmap. - * This was heavily optimized in the original game (manually constructed an unrolled - * loop). - */ void StarTrekEngine::scaleBitmapRow(byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth) { if (origWidth >= scaledWidth) { int16 var2 = (scaledWidth << 1) - origWidth; @@ -2088,10 +2047,6 @@ uint16 StarTrekEngine::getRandomWord() { return _randomSource.getRandomNumber(0xffff); } -/** - * ".txt" files are just lists of strings. This traverses the file to get a particular - * string index. - */ Common::String StarTrekEngine::getLoadedText(int textIndex) { SharedPtr<FileStream> txtFile = loadFile(_txtFilename + ".txt"); diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index 7ab582bcd8..312942a27d 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -239,6 +239,10 @@ public: void awayMissionUseObject(int16 clickedObject); void awayMissionGetLookOrTalk(int16 clickedObject); void unloadRoom(); + /** + * Similar to loadActorAnim, but scale is determined by the y-position in the room. The + * further up (away) the object is, the smaller it is. + */ int loadActorAnimWithRoomScaling(int actorIndex, const Common::String &animName, int16 x, int16 y); Fixed8 getActorScaleAtPosition(int16 y); void addAction(const Action &action); @@ -246,9 +250,26 @@ public: bool checkItemInteractionExists(int action, int activeItem, int passiveItem, int16 arg6); void handleAwayMissionAction(); + /** + * Returns true if the given position is contained in a polygon. + * + * The data passed contains the following words in this order: + * * Index of polygon (unused here) + * * Number of vertices in polygon + * * For each vertex: x and y coordinates. + */ bool isPointInPolygon(int16 *data, int16 x, int16 y); void checkTouchedLoadingZone(int16 x, int16 y); + /** + * Updates any nonzero away mission timers, and invokes ACTION_TIMER_EXPIRED when any one + * reaches 0. + */ void updateAwayMissionTimers(); + /** + * Returns true if the given position in the room is solid (not walkable). + * Reads from a ".map" file which has a bit for each position in the room, which is true + * when that position is solid. + */ bool isPositionSolid(int16 x, int16 y); void loadRoomIndex(int roomIndex, int spawnIndex); @@ -307,7 +328,14 @@ public: // Actors void initActors(); + /** + * Set an actor's animation, position, and scale. + */ int loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale); + /** + * Tries to make an actor walk to a position. + * Returns true if successful in initiating the walk. + */ bool actorWalkToPosition(int actorIndex, const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY); void updateActorAnimations(); void removeActorFromScreen(int actorIndex); @@ -316,24 +344,58 @@ public: void releaseAnim(Actor *actor); void initStandAnim(int actorIndex); void updateActorPositionWhileWalking(Actor *actor, int16 x, int16 y); + /** + * Chooses a value for the actor's speed and direction, based on a source position and + * a destination position it's walking to. + */ void chooseActorDirectionForWalking(Actor *actor, int16 srcX, int16 srcY, int16 destX, int16 destY); + /** + * Returns true if an actor can walk directly from a source position to a destination + * position without running into unwalkable terrain. + */ bool directPathExists(int16 srcX, int16 srcY, int16 destX, int16 destY); int findObjectAt(int x, int y); int findObjectAt(Common::Point p) { return findObjectAt(p.x, p.y); } + /** + * Loads a bitmap for the animation frame with the given scale. + */ SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, Fixed8 scale); + /** + * Called when the "get" action is first selected. Returns a selected object. + * This behaves like other menus in that it holds game execution, but no actual menu pops + * up; it just waits for the player to select something on the screen. + */ int selectObjectForUseAction(); Common::String getCrewmanAnimFilename(int actorIndex, const Common::String &basename); + /** + * Checks whether to change the mouse bitmap to have the red outline. + */ void updateMouseBitmap(); + /** + * Checks whether to walk a crewman to a hotspot (the last one obtained from + * a "findObjectAt" call). + */ bool walkActiveObjectToHotspot(); + /** + * Return true if an object is unselectable with the given action? + */ bool isObjectUnusable(int objectIndex, int action); + /** + * When a crewman is collapsed, they get once a timer reaches 0. + */ void updateCrewmanGetupTimers(); void showInventoryIcons(bool showItem); void hideInventoryIcons(); int showInventoryMenu(int x, int y, bool restoreMouse); void initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitmap, const Common::Rect &rect); SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 scale); + /** + * This takes a row of an unscaled bitmap, and copies it to a row of a scaled bitmap. + * This was heavily optimized in the original game (manually constructed an unrolled + * loop). + */ void scaleBitmapRow(byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth); // Events @@ -372,48 +434,123 @@ private: // text.cpp public: + /** + * Gets one line of text (does not include words that won't fit). + * Returns position of text to continue from, or nullptr if done. + */ const char *getNextTextLine(const char *text, char *line, int lineWidth); String centerTextboxHeader(String headerText); void getTextboxHeader(String *headerTextOutput, String speakerText, int choiceIndex); + /** + * Text getter for showText which reads from an rdf file. + * Not really used, since it would require hardcoding text locations in RDF files. + * "readTextFromArrayWithChoices" replaces this. + */ String readTextFromRdf(int choiceIndex, uintptr data, String *headerTextOutput); String readTextFromBuffer(int choiceIndex, uintptr data, String *headerTextOutput); + /** + * Shows text with the given header and main text. + */ void showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines); // TODO: better name. (return type?) String skipTextAudioPrompt(const String &str); + /** + * Plays an audio prompt, if it exists, and returns the string starting at the end of the + * prompt. + */ String playTextAudio(const String &str); + /** + * @param rclickCancelsChoice If true, right-clicks return "-1" as choice instead of + * whatever was selected. + */ int showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, bool rclickCancelsChoice); + /** + * Returns the number of lines this string will take up in a textbox. + */ int getNumTextboxLines(const String &str); String putTextIntoLines(const String &text); + /** + * Creates a blank textbox in a TextBitmap, and initializes a sprite to use it. + */ SharedPtr<TextBitmap> initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite); + /** + * Draws the "main" text (everything but the header at the top) to a TextBitmap. + */ void drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines, int numTextboxLines, const String &text, bool withHeader); String readLineFormattedText(TextGetterFunc textGetter, uintptr var, int choiceIndex, SharedPtr<TextBitmap> textBitmap, int numTextboxLines, int *numLines); + /** + * Text getter for showText which reads choices from an array of pointers. + * Last element in the array must be an empty string. + */ String readTextFromArray(int choiceIndex, uintptr data, String *headerTextOutput); + /** + * Similar to above, but shows the choice index when multiple choices are present. + * Effectively replaces the "readTextFromRdf" function. + */ String readTextFromArrayWithChoices(int choiceIndex, uintptr data, String *headerTextOutput); // menu.cpp public: + /** + * Returns the index of the button at the given position, or -1 if none. + */ int getMenuButtonAt(Sprite *sprites, int numSprites, int x, int y); + /** + * This chooses a sprite from the list to place the mouse cursor at. The sprite it chooses + * may be, for example, the top-leftmost one in the list. Exact behaviour is determined by + * the "mode" parameter. + * + * If "containMouseSprite" is a valid index, it's ensured that the mouse is contained + * within it. "mode" should be -1 in this case. + */ void chooseMousePositionFromSprites(Sprite *sprites, int numSprites, int spriteIndex, int mode); + /** + * Draws or removes the outline on menu buttons when the cursor hovers on them, or leaves + * them. + */ void drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color); void showOptionsMenu(int x, int y); + /** + * Show the "action selection" menu, ie. look, talk, etc. + */ int showActionMenu(); + /** + * Loads a .MNU file, which is a list of buttons to display. + */ void loadMenuButtons(String mnuFilename, int xpos, int ypos); + /** + * Sets which buttons are visible based on the given bitmask. + */ void setVisibleMenuButtons(uint32 bits); + /** + * Disables the given bitmask of buttons. + */ void disableMenuButtons(uint32 bits); void enableMenuButtons(uint32 bits); + /** + * This returns either a special menu event (negative number) or the retval of the button + * clicked (usually an index, always positive). + */ int handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTextbox); void unloadMenuButtons(); + /** + * Sets the mouse bitmap based on which action is selected. + */ void chooseMouseBitmapForAction(int action, bool withRedOutline); void showQuitGamePrompt(int x, int y); void showGameOverMenu(); + /** + * This can be called from startup or from the options menu. + * On startup, this tries to load the setting without user input. + */ void showTextConfigurationMenu(bool fromOptionMenu); int loadTextDisplayMode(); @@ -437,6 +574,10 @@ public: bool saveGame(int slot, Common::String desc); bool loadGame(int slot); + /** + * Call this after loading "saveOrLoadMetadata" to load all the data pertaining to game + * execution. + */ bool saveOrLoadGameData(Common::SeekableReadStream *in, Common::WriteStream *out, SavegameMetadata *meta); Common::String getSavegameFilename(int slotId) const; @@ -463,6 +604,10 @@ public: // Misc uint16 getRandomWord(); + /** + * ".txt" files are just lists of strings. This traverses the file to get a particular + * string index. + */ Common::String getLoadedText(int textIndex); diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp index 87ecdb2cd8..0d6d469e2d 100644 --- a/engines/startrek/text.cpp +++ b/engines/startrek/text.cpp @@ -30,10 +30,6 @@ namespace StarTrek { -/** - * Gets one line of text (does not include words that won't fit). - * Returns position of text to continue from, or nullptr if done. - */ const char *StarTrekEngine::getNextTextLine(const char *text, char *lineOutput, int lineWidth) { *lineOutput = '\0'; if (*text == '\0') @@ -106,11 +102,6 @@ void StarTrekEngine::getTextboxHeader(String *headerTextOutput, String speakerTe *headerTextOutput = centerTextboxHeader(header); } -/** - * Text getter for showText which reads from an rdf file. - * Not really used, since it would require hardcoding text locations in RDF files. - * "readTextFromArrayWithChoices" replaces this. - */ String StarTrekEngine::readTextFromRdf(int choiceIndex, uintptr data, String *headerTextOutput) { SharedPtr<Room> room = getRoom(); @@ -137,9 +128,6 @@ String StarTrekEngine::readTextFromRdf(int choiceIndex, uintptr data, String *he return (char*)&room->_rdfData[textOffset]; } -/** - * Shows text with the given header and main text. - */ void StarTrekEngine::showTextbox(String headerText, const String &mainText, int xoffset, int yoffset, byte textColor, int maxTextLines) { if (!headerText.empty()) headerText = centerTextboxHeader(headerText); @@ -180,10 +168,6 @@ String StarTrekEngine::skipTextAudioPrompt(const String &str) { return String(text+1); } -/** - * Plays an audio prompt, if it exists, and returns the string starting at the end of the - * prompt. - */ String StarTrekEngine::playTextAudio(const String &str) { const char *text = str.c_str(); char soundFile[0x100]; @@ -205,10 +189,6 @@ String StarTrekEngine::playTextAudio(const String &str) { return String(text+1); } -/** - * @param rclickCancelsChoice If true, right-clicks return "-1" as choice instead of - * whatever was selected. - */ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int yoffset, int textColor, bool loopChoices, int maxTextLines, bool rclickCancelsChoice) { int16 tmpTextDisplayMode = _textDisplayMode; @@ -437,9 +417,6 @@ reloadText: return choiceIndex; } -/** - * Returns the number of lines this string will take up in a textbox. - */ int StarTrekEngine::getNumTextboxLines(const String &str) { const char *text = str.c_str(); char line[TEXTBOX_WIDTH]; @@ -475,9 +452,6 @@ String StarTrekEngine::putTextIntoLines(const String &_text) { return output; } -/** - * Creates a blank textbox in a TextBitmap, and initializes a sprite to use it. - */ SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite) { int linesBeforeTextStart = 2; if (withHeader) @@ -552,10 +526,6 @@ SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffs return bitmap; } -/** - * Draws the "main" text (everything but the header which includes the speaker) to - * a TextBitmap. - */ void StarTrekEngine::drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines, int numTextboxLines, const String &_text, bool withHeader) { byte *dest = bitmap->pixels + TEXTBOX_WIDTH + 1; // Start of 2nd row const char *text = _text.c_str(); @@ -631,10 +601,6 @@ String StarTrekEngine::readLineFormattedText(TextGetterFunc textGetter, uintptr */ } -/** - * Text getter for showText which reads choices from an array of pointers. - * Last element in the array must be an empty string. - */ String StarTrekEngine::readTextFromArray(int choiceIndex, uintptr data, String *headerTextOutput) { const char **textArray = (const char **)data; @@ -651,10 +617,6 @@ String StarTrekEngine::readTextFromArray(int choiceIndex, uintptr data, String * return String(mainText); } -/** - * Similar to above, but shows the choice index when multiple choices are present. - * Effectively replaces the "readTextFromRdf" function. - */ String StarTrekEngine::readTextFromArrayWithChoices(int choiceIndex, uintptr data, String *headerTextOutput) { const char **textArray = (const char **)data; |