TOLTECS: - Fixed clipping bugs (in 256-color sprites and scaled sprites)

- Minor cleanup
This commit is contained in:
Benjamin Haisch 2009-07-06 10:59:42 +00:00 committed by Willem Jan Palenstijn
parent 9a84c13bef
commit 22db6b1558
6 changed files with 27 additions and 25 deletions

View File

@ -805,10 +805,4 @@ void Screen::loadState(Common::ReadStream *in) {
}
/*
void Screen::update() {
}
*/
} // End of namespace Toltecs

View File

@ -362,7 +362,7 @@ int8 SegmentMap::getScalingAtPoint(int16 x, int16 y) {
if (_infoRects[i].id == 0 && _infoRects[i].isPointInside(x, y)) {
int8 topScaling = (int8)_infoRects[i].b;
int8 bottomScaling = (int8)_infoRects[i].c;
if (y - _infoRects[i].y > 0) {
if (y - _infoRects[i].y != 0) {
scaling = (ABS(y - _infoRects[i].y) * (bottomScaling - topScaling) / _infoRects[i].height) + topScaling;
}
}

View File

@ -79,7 +79,7 @@ public:
void getRgbModifiertAtPoint(int16 x, int16 y, int16 id, byte &r, byte &g, byte &b);
void addMasksToRenderQueue();
//protected:
public: // for debugging purposes

View File

@ -66,7 +66,7 @@ void Sound::playSound(int16 resIndex, int16 type, int16 volume) {
debug("playSound(%d, %d, %d)", resIndex, type, volume);
if (volume == -1 || type == kChannelTypeSfx) {
if (volume == -1 || type == -2) {
if (type == kChannelTypeBackground) {
internalPlaySound(resIndex, type, 50 /*TODO*/, 0);
} else {
@ -117,7 +117,7 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
channels[i].type = kChannelTypeEmpty;
channels[i].resIndex = -1;
}
} else if (type == kChannelTypeSfx) {
} else if (type == -2) {
// Stop sounds with specified resIndex
for (int i = 0; i < 4; i++) {
if (channels[i].resIndex == resIndex) {
@ -128,7 +128,7 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
}
} else {
if (type == -2) {
if (type == -3) {
// Stop speech and play new sound
stopSpeech();
}
@ -156,7 +156,13 @@ void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 pa
channels[freeChannel].type = type;
channels[freeChannel].resIndex = resIndex;
_vm->_mixer->playInputStream(Audio::Mixer::kPlainSoundType/*TODO*/, &channels[freeChannel].handle,
Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType;
/*
switch (type) {
}
*/
_vm->_mixer->playInputStream(soundType, &channels[freeChannel].handle,
stream, -1, volume, panning);
}

View File

@ -287,7 +287,7 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
sprite.x -= xoffs;
sprite.y -= yoffs;
sprite.yerror = sprite.ydelta;
// Now we check if the sprite needs to be clipped
@ -296,7 +296,7 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
if (sprite.y - _vm->_cameraY < 0) {
int16 clipHeight = ABS(sprite.y - _vm->_cameraY);
int16 chopHeight, skipHeight, lineWidth;
int16 skipHeight = clipHeight;
byte *spriteFrameData;
sprite.height -= clipHeight;
@ -307,8 +307,7 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
// If the sprite is scaled
if (sprite.flags & 3) {
chopHeight = sprite.ydelta;
skipHeight = clipHeight;
int16 chopHeight = sprite.ydelta;
if ((sprite.flags & 2) == 0) {
do {
chopHeight -= 100;
@ -336,20 +335,21 @@ void Screen::addDrawRequest(const DrawRequest &drawRequest) {
// Now the sprite's offset is adjusted to point to the starting line
if ((sprite.flags & 0x10) == 0) {
while (clipHeight--) {
lineWidth = 0;
while (lineWidth </*CHECKME was != */ sprite.origWidth) {
while (skipHeight--) {
int16 lineWidth = 0;
while (lineWidth < sprite.origWidth) {
sprite.offset++;
lineWidth += (*spriteFrameData++) & 0x0F;
lineWidth += spriteFrameData[0] & 0x0F;
spriteFrameData++;
}
}
} else {
lineWidth = 0;
while (clipHeight--) {
while (skipHeight--) {
int16 lineWidth = 0;
while (lineWidth < sprite.origWidth) {
sprite.offset += 2;
spriteFrameData++;
lineWidth += *spriteFrameData++;
lineWidth += spriteFrameData[1];
spriteFrameData += 2;
}
}
}

View File

@ -147,6 +147,8 @@ Common::Error ToltecsEngine::run() {
_system->showMouse(true);
syncSoundSettings();
//#define TEST_MENU
#ifdef TEST_MENU
_screen->registerFont(0, 0x0D);
@ -220,7 +222,7 @@ void ToltecsEngine::loadScene(uint resIndex) {
_screen->_fullRefresh = true;
_screen->_renderQueue->clear();
}
void ToltecsEngine::updateScreen() {