MADS: General cleanup and minor fixes

This commit is contained in:
Paul Gilbert 2014-03-12 22:45:33 -04:00
parent d9bb593b5f
commit 408f5e79df
12 changed files with 63 additions and 67 deletions

View File

@ -347,7 +347,7 @@ void Animation::loadFrame(int frameNumber) {
}
if (drawFrame(spriteSet, pt, frameNumber))
error("proc1 failure");
error("drawFrame failure");
}
bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber) {
@ -373,8 +373,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
if (palAnimData)
palAnimData->clear();
}
else {
} else {
// Original has useless code here
}
}

View File

@ -78,6 +78,7 @@ private:
public:
SpriteSetCharInfo *_charInfo;
int _usageIndex;
Common::Point _pos;
public:
/**
* Constructor

View File

@ -340,10 +340,10 @@ int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing,
void TextDisplayList::setDirtyAreas() {
Scene &scene = _vm->_game->_scene;
for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < size(); ++idx, ++dirtyIdx) {
if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active)
for (uint idx = 0, dirtyIdx = SPRITE_SLOTS_MAX_SIZE; dirtyIdx < size(); ++idx, ++dirtyIdx) {
if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active) {
scene._dirtyAreas[dirtyIdx]._active = false;
else {
} else {
scene._dirtyAreas[dirtyIdx]._textActive = true;
scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
}
@ -353,7 +353,7 @@ void TextDisplayList::setDirtyAreas() {
void TextDisplayList::setDirtyAreas2() {
Scene &scene = _vm->_game->_scene;
for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; idx < size(); ++idx, ++dirtyIdx) {
for (uint idx = 0, dirtyIdx = SPRITE_SLOTS_MAX_SIZE; idx < size(); ++idx, ++dirtyIdx) {
if ((*this)[idx]._active && ((*this)[idx]._expire >= 0)) {
scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
scene._dirtyAreas[dirtyIdx]._textActive = ((*this)[idx]._expire <= 0) ? 0 : 1;

View File

@ -230,10 +230,10 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
byte *destPtr = (byte *)pixels + (destY * getWidth()) + destX;
for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
if (transparentColor == -1)
if (transparentColor == -1) {
// No transparency, so copy line over
Common::copy(srcPtr, srcPtr + copyRect.width(), destPtr);
else {
} else {
// Copy each byte one at a time checking for the transparency color
for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr)
if (srcPtr[xCtr] != transparentColor) destPtr[xCtr] = srcPtr[xCtr];
@ -311,8 +311,7 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
distCtr += scale;
if (distCtr < 100) {
lineDist[distIndex] = false;
}
else {
} else {
lineDist[distIndex] = true;
distCtr -= 100;
@ -425,8 +424,7 @@ void MSurface::scrollX(int xAmount) {
Common::copy(srcP + xSize, srcP + this->w, srcP);
// Move buffered area to the end of the line
Common::copy(&buffer[0], &buffer[xSize], srcP + this->w - xSize);
}
else {
} else {
// Copy area to be overwritten
Common::copy_backward(srcP + this->w - xSize, srcP + this->w, &buffer[80]);
// Shift the remainder of the line over the given area
@ -459,8 +457,7 @@ void MSurface::scrollY(int yAmount) {
pixelsP + (pitch * this->h));
// Transfer the buffered lines top the top of the screen
Common::copy(tempData, tempData + blockSize, pixelsP);
}
else {
} else {
// Buffer the lines to be overwritten
Common::copy(pixelsP, pixelsP + (pitch * ySize), tempData);
// Vertically shift all the lines

View File

@ -106,8 +106,7 @@ void Scene804::enter() {
_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
_globals._spriteIndexes[4], 0, 1);
_scene->_sequences.addTimer(60, 100);
}
else {
} else {
_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
_globals._spriteIndexes[5], false, 1);
_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
@ -115,8 +114,7 @@ void Scene804::enter() {
_scene->_sequences.addTimer(160, 70);
_game._player._stepEnabled = false;
}
}
else {
} else {
if (_globals[167] == 0) {
_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
_globals._spriteIndexes[7], false, 1);

View File

@ -308,8 +308,7 @@ Common::String Resources::formatName(int prefix, char asciiCh, int id, EXTTYPE e
Common::String result;
if (prefix <= 0) {
result = "*";
}
else {
} else {
result = Common::String::format("%s%.3d",
(prefix < 100) ? "*SC" : "*RM", prefix);
}

View File

@ -170,7 +170,9 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
_interfaceY = MADS_SCENE_HEIGHT;
_spritesCount = _sprites.size();
warning("TODO: sub_1EA80 / showMouse");
_interface.setup(_screenObjects._v832EC);
warning("TODO: showMouse");
warning("TODO: inventory_anim_allocate");
}

View File

@ -199,8 +199,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
if (spriteSlot->_scale == -1) {
width = frame->w;
height = frame->h;
}
else {
} else {
width = frame->w * spriteSlot->_scale / 100;
height = frame->h * spriteSlot->_scale / 100;

View File

@ -46,8 +46,9 @@ class SpriteSlot;
#define DEPTH_BANDS_SIZE 15
#define MAX_ROUTE_NODES 22
#define DIRTY_AREAS_SIZE 90
#define DIRTY_AREAS_TEXT_DISPLAY_IDX 50
#define SPRITE_SLOTS_MAX_SIZE 50
#define TEXT_DISPLAY_MAX_SIZE 40
#define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
enum ScrCategory {
CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,

View File

@ -184,7 +184,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
if (!timerEntry._nonFixed) {
spriteSlot._position = timerEntry._msgPos;
} else {
spriteSlot._position = spriteSet.getFrame(timerEntry._frameIndex - 1)->_pos;
spriteSlot._position = spriteSet._pos;
}
}
@ -243,15 +243,13 @@ bool SequenceList::loadSprites(int seqIndex) {
if (seqEntry._animType == ANIMTYPE_CYCLED) {
// back to the starting frame (cyclic)
seqEntry._frameIndex = seqEntry._frameStart;
}
else {
} else {
// Switch into reverse mode
seqEntry._frameIndex = seqEntry._numSprites - 1;
seqEntry._frameInc = -1;
}
}
}
else {
} else {
// Currently in reverse mode and moved past starting frame
result = true;
@ -260,8 +258,7 @@ bool SequenceList::loadSprites(int seqIndex) {
// Switch back to forward direction again
seqEntry._frameIndex = seqEntry._frameStart + 1;
seqEntry._frameInc = 1;
}
else {
} else {
// Otherwise reset back to last sprite for further reverse animating
seqEntry._frameIndex = seqEntry._numSprites;
}
@ -271,8 +268,7 @@ bool SequenceList::loadSprites(int seqIndex) {
if (--seqEntry._triggerCountdown == 0)
seqEntry._doneFlag = true;
}
}
else {
} else {
// Out of sprite display slots, so mark entry as done
seqEntry._doneFlag = true;
}
@ -402,8 +398,9 @@ void SequenceList::setMsgPosition(int seqIndex, const Common::Point &pt) {
int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) {
Scene &scene = _vm->_game->_scene;
MSprite *spriteFrame = scene._sprites[srcSpriteIdx]->getFrame(0);
int depth = scene._depthSurface.getDepth(Common::Point(spriteFrame->_pos.x +
(spriteFrame->w / 2), spriteFrame->_pos.y + (spriteFrame->h / 2)));
int depth = scene._depthSurface.getDepth(Common::Point(
spriteFrame->_offset.x + (spriteFrame->w / 2),
spriteFrame->_offset.y + (spriteFrame->h / 2)));
return add(srcSpriteIdx, flipped, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0,
true, 100, depth - 1, 1, ANIMTYPE_CYCLED, 0, 0);
@ -422,7 +419,7 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
SpriteAsset *sprites = _vm->_game->_scene._sprites[srcSpriteIndex];
MSprite *frame = sprites->getFrame(0);
int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point(
frame->_pos.x + frame->w / 2, frame->_pos.y + frame->h / 2));
frame->_offset.x + frame->w / 2, frame->_offset.y + frame->h / 2));
return add(srcSpriteIndex, flipped, 1, triggerCountdown, timeoutTicks, extraTicks,
numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0);

View File

@ -235,31 +235,33 @@ void SpriteSlots::drawBackground() {
Scene &scene = _vm->_game->_scene;
// Initial draw loop for any active sprites in the background
for (uint i = 0; i < scene._spriteSlots.size(); ++i) {
if (scene._spriteSlots[i]._spriteType >= ST_NONE) {
scene._dirtyAreas[i]._active = false;
}
else {
scene._dirtyAreas[i]._active = true;
scene._dirtyAreas[i].setSpriteSlot(&scene._spriteSlots[i]);
for (uint i = 0; i < size(); ++i) {
SpriteSlot &spriteSlot = (*this)[i];
DirtyArea &dirtyArea = scene._dirtyAreas[i];
SpriteAsset *asset = scene._sprites[scene._spriteSlots[i]._spritesIndex];
MSprite *frame = asset->getFrame(scene._spriteSlots[i]._frameNumber);
if (spriteSlot._spriteType >= ST_NONE) {
dirtyArea._active = false;
} else {
dirtyArea._active = true;
dirtyArea.setSpriteSlot(&spriteSlot);
if (scene._spriteSlots[i]._spriteType == ST_BACKGROUND) {
Common::Point pt = scene._spriteSlots[i]._position;
if (scene._spriteSlots[i]._scale != -1) {
SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
MSprite *frame = asset->getFrame(spriteSlot._frameNumber);
if (spriteSlot._spriteType == ST_BACKGROUND) {
Common::Point pt = spriteSlot._position;
if (spriteSlot._scale != -1) {
// Adjust the drawing position
pt.x -= frame->w / 2;
pt.y -= frame->h / 2;
}
if (scene._spriteSlots[i]._depth <= 1) {
asset->draw(&scene._backgroundSurface, scene._spriteSlots[i]._frameNumber, pt);
if (spriteSlot._depth <= 1) {
asset->draw(&scene._backgroundSurface, spriteSlot._frameNumber, pt);
}
else if (scene._depthStyle == 0) {
asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, scene._spriteSlots[i]._frameNumber,
pt, scene._spriteSlots[i]._depth);
asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, spriteSlot._frameNumber,
pt, spriteSlot._depth);
} else {
error("Unsupported depth style");
}
@ -267,18 +269,20 @@ void SpriteSlots::drawBackground() {
}
}
// Mark any remaning dirty areas as inactive
for (uint i = scene._spriteSlots.size(); i < 50; ++i)
// Mark any remaning sprite slot dirty areas as inactive
for (uint i = size(); i < SPRITE_SLOTS_MAX_SIZE; ++i)
scene._dirtyAreas[i]._active = false;
// Flag any active text display
for (uint i = 50; i < scene._textDisplay.size(); ++i) {
TextDisplay &textDisplay = scene._textDisplay[i - 50];
if (scene._textDisplay[i]._expire >= 0 || !textDisplay._active) {
scene._dirtyAreas[i]._active = false;
for (uint i = 0; i < scene._textDisplay.size(); ++i) {
TextDisplay &textDisplay = scene._textDisplay[i];
DirtyArea &dirtyArea = scene._dirtyAreas[i + SPRITE_SLOTS_MAX_SIZE];
if (textDisplay._expire >= 0 || !textDisplay._active) {
dirtyArea._active = false;
} else {
scene._dirtyAreas[i]._active = true;
scene._dirtyAreas[i].setTextDisplay(&textDisplay);
dirtyArea._active = true;
dirtyArea.setTextDisplay(&textDisplay);
}
}
}
@ -289,8 +293,9 @@ void SpriteSlots::drawForeground(MSurface *s) {
// Get a list of sprite object depths for active objects
for (uint i = 0; i < size(); ++i) {
if ((*this)[i]._spriteType >= ST_NONE) {
DepthEntry rec(16 - (*this)[i]._depth, i);
SpriteSlot &spriteSlot = (*this)[i];
if (spriteSlot._spriteType >= ST_NONE) {
DepthEntry rec(16 - spriteSlot._depth, i);
depthList.push_back(rec);
}
}

View File

@ -52,8 +52,7 @@ typedef struct {
uint8 depth; // depth code for source (0 if no depth processing)
} DrawRequestX;
typedef struct
{
typedef struct {
uint32 Pack;
uint32 Stream;
long hot_x;
@ -111,7 +110,6 @@ public:
int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
virtual ~MSprite();
Common::Point _pos;
Common::Point _offset;
uint8 _encoding;