[Scummvm-git-logs] scummvm master -> b54f6adcb78c260c66238a072a40fa76a12e752d

athrxx noreply at scummvm.org
Fri Sep 23 19:38:17 UTC 2022


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f0a2d470b6 KYRA: (HOF) - fix palette glitch when loading savegames
77866676a7 KYRA: init non-initialized member vars
b54f6adcb7 KYRA: more coding style and sanity checking cleanup


Commit: f0a2d470b660be9c4483c72a2a775a33933bba59
    https://github.com/scummvm/scummvm/commit/f0a2d470b660be9c4483c72a2a775a33933bba59
Author: athrxx (athrxx at scummvm.org)
Date: 2022-09-23T21:37:45+02:00

Commit Message:
KYRA: (HOF) - fix palette glitch when loading savegames

This is the same in the original interpreter, but I assume
they just don't update the screen as much as we do.
The problem is that the new scene palette is
generated and set before the new scene is actually drawn. So there is a moment where the old scene is visible with the new palette...

Changed paths:
    engines/kyra/gui/saveload_hof.cpp


diff --git a/engines/kyra/gui/saveload_hof.cpp b/engines/kyra/gui/saveload_hof.cpp
index 1dd2a6029c9..676442f7541 100644
--- a/engines/kyra/gui/saveload_hof.cpp
+++ b/engines/kyra/gui/saveload_hof.cpp
@@ -150,6 +150,8 @@ Common::Error KyraEngine_HoF::loadGameState(int slot) {
 	Common::SeekableSubReadStreamEndian in(saveFile, saveFile->pos(), saveFile->size(), !header.originalSave, DisposeAfterUse::YES);
 
 	_screen->hideMouse();
+	_screen->fadeToBlack(10);
+	_screen->fillRect(0, 0, 319, 143, 0, 0);
 
 	if (!header.originalSave) {
 		_timer->loadDataFromFile(in, header.version);


Commit: 77866676a79ed120db92db49f5d573a1f50acb39
    https://github.com/scummvm/scummvm/commit/77866676a79ed120db92db49f5d573a1f50acb39
Author: athrxx (athrxx at scummvm.org)
Date: 2022-09-23T21:37:51+02:00

Commit Message:
KYRA: init non-initialized member vars

Changed paths:
    engines/kyra/graphics/screen.cpp
    engines/kyra/sound/drivers/audstream.cpp


diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp
index 571d32c6c07..749366122e4 100644
--- a/engines/kyra/graphics/screen.cpp
+++ b/engines/kyra/graphics/screen.cpp
@@ -3910,7 +3910,7 @@ void SJISFont::drawChar(uint16 c, byte *dst, int pitch, int) const {
 }
 
 ChineseFont::ChineseFont(int pitch, int renderWidth, int renderHeight, int spacingWidth, int spacingHeight, int extraSpacingWidth, int extraSpacingHeight) : Font(),
-	_renderWidth(renderWidth), _renderHeight(renderHeight), _spacingWidth(spacingWidth), _spacingHeight(spacingHeight), _pitch(pitch), _border(false),
+	_renderWidth(renderWidth), _renderHeight(renderHeight), _spacingWidth(spacingWidth), _spacingHeight(spacingHeight), _pitch(pitch), _border(false), _colorMap(nullptr),
 	_borderExtraSpacingWidth(extraSpacingWidth), _borderExtraSpacingHeight(extraSpacingHeight), _glyphData(0), _glyphDataSize(0), _pixelColorShading(true) {
 }
 
diff --git a/engines/kyra/sound/drivers/audstream.cpp b/engines/kyra/sound/drivers/audstream.cpp
index 9634ab8203f..bb2349b59e1 100644
--- a/engines/kyra/sound/drivers/audstream.cpp
+++ b/engines/kyra/sound/drivers/audstream.cpp
@@ -77,7 +77,7 @@ const int8 AUDStream::WSTable4Bit[] = {
 
 AUDStream::AUDStream(Common::SeekableReadStream *stream) : _stream(stream), _endOfData(true), _rate(0),
 	_processedSize(0), _totalSize(0), _length(0, 1), _bytesLeft(0), _outBuffer(nullptr),
-	_outBufferOffset(0), _outBufferSize(0), _inBuffer(nullptr), _inBufferSize(0) {
+	_outBufferOffset(0), _outBufferSize(0), _inBuffer(nullptr), _inBufferSize(0), _streamStart(0) {
 
 	if (_stream->size() < 8) {
 		warning("No AUD file: too short");


Commit: b54f6adcb78c260c66238a072a40fa76a12e752d
    https://github.com/scummvm/scummvm/commit/b54f6adcb78c260c66238a072a40fa76a12e752d
Author: athrxx (athrxx at scummvm.org)
Date: 2022-09-23T21:37:55+02:00

Commit Message:
KYRA: more coding style and sanity checking cleanup

Changed paths:
    engines/kyra/engine/darkmoon.cpp
    engines/kyra/engine/eobcommon.cpp
    engines/kyra/engine/sprites_eob.cpp
    engines/kyra/graphics/screen.cpp
    engines/kyra/graphics/screen_eob_amiga.cpp
    engines/kyra/sound/drivers/audiomaster2.cpp
    engines/kyra/text/text_eob_segacd.cpp


diff --git a/engines/kyra/engine/darkmoon.cpp b/engines/kyra/engine/darkmoon.cpp
index a295593c215..656dc4cb9cd 100644
--- a/engines/kyra/engine/darkmoon.cpp
+++ b/engines/kyra/engine/darkmoon.cpp
@@ -110,8 +110,7 @@ void DarkMoonEngine::loadItemsAndDecorationsShapes() {
 	_teleporterShapes = new const uint8 *[6];
 	_sparkShapes = new const uint8 *[3];
 	_compassShapes = new const uint8 *[12];
-	if (_flags.gameID == GI_EOB2)
-		_wallOfForceShapes = new const uint8 *[6];
+	_wallOfForceShapes = new const uint8 *[6];
 
 	_lightningColumnShape = _staticres->loadRawData(kEoB2LightningColumnShapeData, size);
 	for (int i = 0; i < 6; i++)
diff --git a/engines/kyra/engine/eobcommon.cpp b/engines/kyra/engine/eobcommon.cpp
index 8283f02cec5..3bb89856b5d 100644
--- a/engines/kyra/engine/eobcommon.cpp
+++ b/engines/kyra/engine/eobcommon.cpp
@@ -827,9 +827,7 @@ void EoBCoreEngine::loadItemsAndDecorationsShapes() {
 		}
 	}
 
-	_thrownItemShapes = new const uint8*[_numThrownItemShapes];
-	if (_flags.gameID == GI_EOB2)
-		_spellShapes = new const uint8*[4];
+	_thrownItemShapes = new const uint8*[_numThrownItemShapes];	
 	_firebeamShapes = new const uint8*[3];
 
 	_screen->loadShapeSetBitmap("THROWN", 5, 3);
@@ -843,6 +841,7 @@ void EoBCoreEngine::loadItemsAndDecorationsShapes() {
 				_thrownItemShapesScl[c][i] = _screen->encodeShape((i / div) << 2, (i % div) * mul + 24 + (c << 4), 3 - c, 16 - ((c >> 1) << 3), false, _cgaMappingThrown);
 		}
 	} else {
+		_spellShapes = new const uint8*[4];
 		for (int i = 0; i < 4; i++)
 			_spellShapes[i] = _screen->encodeShape(8, i << 5, 6, 32, false, _cgaMappingThrown);
 	}
@@ -870,13 +869,12 @@ void EoBCoreEngine::loadItemsAndDecorationsShapes() {
 
 	_teleporterShapes = new const uint8*[6];
 	_sparkShapes = new const uint8*[4];
-	_compassShapes = new const uint8*[12];
-	if (_flags.gameID == GI_EOB2)
-		_wallOfForceShapes = new const uint8*[6];
+	_compassShapes = new const uint8*[12];		
 
 	_screen->loadShapeSetBitmap("DECORATE", 5, 3);
 	if (_flags.gameID == GI_EOB2) {
 		_lightningColumnShape = _screen->encodeShape(18, 88, 4, 64);
+		_wallOfForceShapes = new const uint8*[6];
 		for (int i = 0; i < 6; i++)
 			_wallOfForceShapes[i] = _screen->encodeShape(_wallOfForceShapeDefs[(i << 2)], _wallOfForceShapeDefs[(i << 2) + 1], _wallOfForceShapeDefs[(i << 2) + 2], _wallOfForceShapeDefs[(i << 2) + 3]);
 	}
diff --git a/engines/kyra/engine/sprites_eob.cpp b/engines/kyra/engine/sprites_eob.cpp
index cf950ed00e3..23909c252ca 100644
--- a/engines/kyra/engine/sprites_eob.cpp
+++ b/engines/kyra/engine/sprites_eob.cpp
@@ -386,10 +386,11 @@ void EoBCoreEngine::drawBlockItems(int index) {
 			if (scaleSteps >= 0) {
 				const uint8 *shp = 0;
 				if (_flags.gameID == GI_EOB2 || scaleSteps == 0)
-					shp = _screen->scaleShape(_dscItemShapeMap[itm->icon] < _numLargeItemShapes ? _largeItemShapes[_dscItemShapeMap[itm->icon]] : (_dscItemShapeMap[itm->icon] < 15 ? 0 : _smallItemShapes[_dscItemShapeMap[itm->icon] - 15]), scaleSteps);
+					shp = _screen->scaleShape(_dscItemShapeMap[itm->icon] < _numLargeItemShapes ? _largeItemShapes[_dscItemShapeMap[itm->icon]] : (_dscItemShapeMap[itm->icon] < 15 ? nullptr : _smallItemShapes[_dscItemShapeMap[itm->icon] - 15]), scaleSteps);
 				else
-					shp = _dscItemShapeMap[itm->icon] < _numLargeItemShapes ? _largeItemShapesScl[scaleSteps - 1][_dscItemShapeMap[itm->icon]] : (_dscItemShapeMap[itm->icon] < 15 ? 0 : _smallItemShapesScl[scaleSteps - 1][_dscItemShapeMap[itm->icon] - 15]);
+					shp = _dscItemShapeMap[itm->icon] < _numLargeItemShapes ? _largeItemShapesScl[scaleSteps - 1][_dscItemShapeMap[itm->icon]] : (_dscItemShapeMap[itm->icon] < 15 ? nullptr : _smallItemShapesScl[scaleSteps - 1][_dscItemShapeMap[itm->icon] - 15]);
 
+				assert(shp);
 				x = x + (itemPosFin[o & 7] << 1) - ((shp[2] << 3) >> 1);
 				y -= shp[1];
 
diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp
index 749366122e4..d11216536c3 100644
--- a/engines/kyra/graphics/screen.cpp
+++ b/engines/kyra/graphics/screen.cpp
@@ -569,14 +569,17 @@ void Screen::resetPagePtrsAndBuffers(int pageSize) {
 	uint32 bufferSize = numPages * _screenPageSize;
 
 	uint8 *pagePtr = new uint8[bufferSize]();
+	uint8 *pos = pagePtr;
 
 	memset(_pagePtrs, 0, sizeof(_pagePtrs));
 	for (int i = 0; i < SCREEN_PAGE_NUM; i++) {
 		if (_pagePtrs[_pageMapping[i]]) {
 			_pagePtrs[i] = _pagePtrs[_pageMapping[i]];
+		} else if (pos < &pagePtr[bufferSize]) {
+			_pagePtrs[i] = pos;
+			pos += _screenPageSize;
 		} else {
-			_pagePtrs[i] = pagePtr;
-			pagePtr += _screenPageSize;
+			error("Screen::resetPagePtrsAndBuffers(): Failed to allocate screen page buffers");
 		}
 	}
 }
diff --git a/engines/kyra/graphics/screen_eob_amiga.cpp b/engines/kyra/graphics/screen_eob_amiga.cpp
index d11ffab8cd7..798f57066d8 100644
--- a/engines/kyra/graphics/screen_eob_amiga.cpp
+++ b/engines/kyra/graphics/screen_eob_amiga.cpp
@@ -360,17 +360,19 @@ AmigaDOSFont::TextFont *AmigaDOSFont::loadContentFile(const Common::String fileN
 
 	str->seek(curPos - 18, SEEK_SET);
 	uint32 offset = str->readUint32();
-	fnt->bitmap = offset ? buffer + offset - (curPos - hunkStartPos) : 0;
+	fnt->bitmap = offset ? buffer + offset - (curPos - hunkStartPos) : nullptr;
+	assert(fnt->bitmap);
 	fnt->modulo = str->readUint16();
 
 	offset = str->readUint32();
-	uint16 *loc = (uint16*)(offset ? buffer + offset - (curPos - hunkStartPos) : 0);
+	uint16 *loc = (uint16*)(offset ? buffer + offset - (curPos - hunkStartPos) : nullptr);
+	assert(loc);
 	for (int i = 0; i <= (fnt->lastChar - fnt->firstChar) * 2 + 1; ++i)
 		loc[i] = READ_BE_UINT16(&loc[i]);
 	fnt->location = loc;
 
 	offset = str->readUint32();
-	int16 *idat = offset ? (int16*)(buffer + offset - (curPos - hunkStartPos)) : 0;
+	int16 *idat = offset ? (int16*)(buffer + offset - (curPos - hunkStartPos)) : nullptr;
 	if (idat) {
 		for (int i = 0; i <= (fnt->lastChar - fnt->firstChar) * 2 + 1; ++i)
 			idat[i] = (int16)READ_BE_UINT16(&idat[i]);
@@ -381,7 +383,7 @@ AmigaDOSFont::TextFont *AmigaDOSFont::loadContentFile(const Common::String fileN
 	// This warning will only show up if someone tries to use this code elsewhere. It cannot happen with EOB fonts.
 	if (offset)
 		warning("Trying to load an AmigaDOS font with kerning data. This is not implemented. Font Rendering will not be accurate.");
-	idat = offset ? (int16*)(buffer + offset - (curPos - hunkStartPos)) : 0;
+	idat = offset ? (int16*)(buffer + offset - (curPos - hunkStartPos)) : nullptr;
 	if (idat) {
 		for (int i = 0; i <= (fnt->lastChar - fnt->firstChar) * 2 + 1; ++i)
 			idat[i] = (int16)READ_BE_UINT16(&idat[i]);
diff --git a/engines/kyra/sound/drivers/audiomaster2.cpp b/engines/kyra/sound/drivers/audiomaster2.cpp
index 61481c6bacc..a635e0f1c4f 100644
--- a/engines/kyra/sound/drivers/audiomaster2.cpp
+++ b/engines/kyra/sound/drivers/audiomaster2.cpp
@@ -593,7 +593,7 @@ void SoundResource8SVX::setupSoundEffect(AudioMaster2IOManager::IOUnit *unit, ui
 	unit->_lenOnce = no;
 	unit->_lenRepeat = nr;
 
-	unit->_endTick = _numSamplesRepeat ? 0xFFFFFFFF : (tempo * _numSamplesOnce * 60) / _rate + sync;
+	unit->_endTick = _numSamplesRepeat ? 0xFFFFFFFF : (tempo * _numSamplesOnce * 60) / (_rate ? _rate : 2000) + sync;
 	unit->_volumeSetting = unit->_outputVolume = ((_trackVolume >= 0xFFFF ? _trackVolume >> 2 : 0x4000) * _masterVolume) / 64;
 	setupEnvelopes(unit);
 }
diff --git a/engines/kyra/text/text_eob_segacd.cpp b/engines/kyra/text/text_eob_segacd.cpp
index a9fbee28a74..a745322d58f 100644
--- a/engines/kyra/text/text_eob_segacd.cpp
+++ b/engines/kyra/text/text_eob_segacd.cpp
@@ -124,8 +124,9 @@ void TextDisplayer_SegaCD::displayText(char *str, ...) {
 	if (tc != -1)
 		SWAP(_textColor, tc);
 
-	for (const char *pos = str; *pos; updated = false) {
+	for (const char *pos = str; *pos; ) {
 		uint8 cmd = fetchCharacter(tmp, pos);
+		updated = false;
 
 		if (_dimTable[_curDim].h < _curPosY + _screen->getFontHeight()) {
 			_curPosY -= _screen->getFontHeight();




More information about the Scummvm-git-logs mailing list