Permalink
Browse files

STARTREK: Move function descriptions to headers

  • Loading branch information...
Drenn1 authored and sev- committed Jul 24, 2018
1 parent c2dd39a commit 0e85e19ee7530b4d41668982e0b10f04d6f29741
@@ -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);

@@ -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);
};
@@ -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,24 +233,13 @@ 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;

if (_mouseLocked)
_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];
@@ -63,10 +63,16 @@ class Graphics {
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 @@ class Graphics {
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 @@ class Graphics {
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); }

@@ -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
@@ -39,6 +39,10 @@ class IWFile {
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.
@@ -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 @@ int StarTrekEngine::showActionMenu() {
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",
@@ -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;
}
Oops, something went wrong.

0 comments on commit 0e85e19

Please sign in to comment.