BLADERUNNER: Fix glitches in CT01 and PS15

PS15 was rogue pixels with bad z-buffer. Both are original bugs

CT01 fix is an expansion of the existing fix to cover other loops and chapters affected.
This commit is contained in:
antoniou79 2023-05-08 00:54:50 +03:00
parent fceab98331
commit 4534114106
4 changed files with 44 additions and 2 deletions

View File

@ -27,6 +27,7 @@
#if BLADERUNNER_ORIGINAL_SETTINGS
#include "bladerunner/audio_speech.h"
#endif
#include "bladerunner/zbuffer.h"
#include "audio/decoders/raw.h"
@ -47,6 +48,7 @@ bool VQAPlayer::open() {
}
#if !BLADERUNNER_ORIGINAL_BUGS
_specialPS15GlitchFix = false;
// TB05 has wrong end of a loop and this will load empty zbuffer from next loop, which will lead to broken pathfinding
if (_name.equals("TB05_2.VQA")) {
_decoder._loopInfo.loops[1].end = 60;
@ -54,11 +56,19 @@ bool VQAPlayer::open() {
// smoke (overlay) after explosion of Dermo Labs in DR04
// This has still frames in the end that so it looked as if the smoke was "frozen"
_decoder._loopInfo.loops[0].end = 58; // 59 up to 74 are still frames
} else if (_name.equals("CT01.VQA")) {
} else if (_name.equals("CT01.VQA") || _name.equals("CT01_2.VQA") || _name.equals("CT01_3.VQA") ) {
// In the last frame of the Mainloop (255) a Howie Lee's customer's hand
// backwards abruptly the loop looks jarring. We skip the last frame.
// The issue is also present in the non-spinner versions of the loop
// and for all chapters where this scene is available (Acts 1 through 5)
_decoder._loopInfo.loops[2].end = 254;
_decoder._loopInfo.loops[3].end = 254;
_decoder._loopInfo.loops[7].end = 510;
_decoder._loopInfo.loops[8].end = 510;
} else if (_name.equals("PS15.VQA") || _name.equals("PS15_2.VQA")) {
// Fix should be applied in Act 1-3 versions of this background
_specialPS15GlitchFix = true;
}
#endif
@ -306,6 +316,21 @@ int VQAPlayer::update(bool forceDraw, bool advanceFrame, bool useTime, Graphics:
void VQAPlayer::updateZBuffer(ZBuffer *zbuffer) {
_decoder.decodeZBuffer(zbuffer);
#if !BLADERUNNER_ORIGINAL_BUGS
if (_specialPS15GlitchFix) {
// The glitch (bad z-buffer, value zero (0))
// is present in the following pixels:
// x: 387, y in [179, 192]
// x: 388, y in [179, 202]
for (int y = 179; y < 193; ++y) {
_vm->_zbuffer->setDataZbufExplicit(387, y, 10720);
_vm->_zbuffer->setDataZbufExplicit(388, y, 10720);
}
for (int y = 193; y < 203; ++y) {
_vm->_zbuffer->setDataZbufExplicit(388, y, 10720);
}
}
#endif
}
void VQAPlayer::updateView(View *view) {

View File

@ -86,6 +86,8 @@ class VQAPlayer {
bool _audioStarted;
Audio::SoundHandle _soundHandle;
bool _specialPS15GlitchFix;
void (*_callbackLoopEnded)(void *, int frame, int loopId);
void *_callbackData;
@ -112,6 +114,7 @@ public:
_frameNextTime(0),
_hasAudio(false),
_audioStarted(false),
_specialPS15GlitchFix(false),
_callbackLoopEnded(nullptr),
_callbackData(nullptr) { }

View File

@ -167,7 +167,8 @@ bool ZBuffer::decodeData(const uint8 *data, int size) {
} else {
clean();
decodePartialZBuffer(data, _zbuf1, size);
decodePartialZBuffer(data, _zbuf2, size);
//decodePartialZBuffer(data, _zbuf2, size);
memcpy(_zbuf2, _zbuf1, size);
}
return true;
@ -177,6 +178,15 @@ uint16 *ZBuffer::getData() const {
return _zbuf2;
}
#if !BLADERUNNER_ORIGINAL_BUGS
void ZBuffer::setDataZbufExplicit(int x, int y, uint16 overidingVal) {
assert(x >= 0 && x < _width);
assert(y >= 0 && y < _height);
_zbuf1[y * _width + x] = overidingVal;
_zbuf2[y * _width + x] = overidingVal;
}
#endif // BLADERUNNER_ORIGINAL_BUGS
uint16 ZBuffer::getZValue(int x, int y) const {
assert(x >= 0 && x < _width);
assert(y >= 0 && y < _height);

View File

@ -67,6 +67,10 @@ public:
uint16 *getData() const;
uint16 getZValue(int x, int y) const;
#if !BLADERUNNER_ORIGINAL_BUGS
void setDataZbufExplicit(int x, int y, uint16 overidingVal);
#endif // BLADERUNNER_ORIGINAL_BUGS
private:
void blit(Common::Rect rect);