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

sluicebox noreply at scummvm.org
Fri Dec 13 17:31:24 UTC 2024


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

Summary:
12568a3f40 AGI: PREAGI: Cleanup WINNIE game loop
2ced551825 AGI: PREAGI: Cleanup sound code
3454766544 AGI: PREAGI: Improve WINNIE event handling
7ca5359977 AGI: PREAGI: Improve TROLL intro event handling
613a0c2f79 AGI: PREAGI: Improve MICKEY event handling
429b7c3734 AGI: PREAGI: Fix MICKEY crystal animation
bdf451b647 AGI: PREAGI: Fix MICKEY object placement
188b0685f3 AGI: PREAGI: Fix MICKEY saves always loading to Earth
4cfe4e139f AGI: PREAGI: Fix MICKEY crystal persistence
6822ff599e AGI: PREAGI: Fix MICKEY crystal appearing before room change
088c5b3ae1 AGI: PREAGI: Fix MICKEY ship button behavior
0cd9a31d8c AGI: PREAGI: Fix MICKEY game over handling
d461e132d6 AGI: PREAGI: Cleanup MICKEY code
8fdd360ae0 AGI: Remove PictureMgr::setPattern(), used by MICKEY
e134785c50 AGI: Remove PictureMgr::setPictureData(), used by TROLL
c47bbe3427 AGI: Remove AgiPictureVersion::AGIPIC_256
04471e0dff AGI: Remove AgiPictureFlags::kPicFf3Cont
ecfe4dd4de AGI: Move PictureMgr::unloadPicture() to AgiEngine
b3fe3a7288 AGI: Remove PictureMgr::clear(), used by TROLL
c6c2924258 AGI: Cleanup PictureMgr


Commit: 12568a3f4010a0e52a68cd0119727487eaf54268
    https://github.com/scummvm/scummvm/commit/12568a3f4010a0e52a68cd0119727487eaf54268
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:30:59-08:00

Commit Message:
AGI: PREAGI: Cleanup WINNIE game loop

Changed paths:
    engines/agi/preagi/winnie.cpp


diff --git a/engines/agi/preagi/winnie.cpp b/engines/agi/preagi/winnie.cpp
index d0a7d775858..ae883c1258e 100644
--- a/engines/agi/preagi/winnie.cpp
+++ b/engines/agi/preagi/winnie.cpp
@@ -1134,13 +1134,13 @@ void WinnieEngine::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
 void WinnieEngine::gameLoop() {
 	WTP_ROOM_HDR hdr;
 	uint8 *roomdata = (uint8 *)malloc(4096);
-	int iBlock;
 	uint8 decodePhase = 0;
 
 	startTimer();
 
 	while (!shouldQuit()) {
-		if (decodePhase == 0) {
+		switch (decodePhase) {
+		case 0:
 			if (!_gameStateWinnie.nObjMiss && (_room == IDI_WTP_ROOM_PICNIC)) {
 				_room = IDI_WTP_ROOM_PARTY;
 				stopTimer();
@@ -1150,18 +1150,16 @@ void WinnieEngine::gameLoop() {
 			drawRoomPic();
 			_system->updateScreen();
 			decodePhase = 1;
-		}
-
-		if (decodePhase == 1) {
+			break;
+		case 1:
 			if (getObjInRoom(_room)) {
 				printObjStr(getObjInRoom(_room), IDI_WTP_OBJ_DESC);
 				getSelection(kSelAnyKey);
 			}
 			decodePhase = 2;
-		}
-
-		if (decodePhase == 2) {
-			for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
+			break;
+		case 2:
+			for (int iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
 				if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK) {
 					decodePhase = 1;
 					break;
@@ -1169,10 +1167,9 @@ void WinnieEngine::gameLoop() {
 			}
 			if (decodePhase == 2)
 				decodePhase = 3;
-		}
-
-		if (decodePhase == 3) {
-			for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
+			break;
+		case 3:
+			for (int iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
 				int result = parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata);
 				if (result == IDI_WTP_PAR_GOTO) {
 					decodePhase = 0;
@@ -1187,6 +1184,9 @@ void WinnieEngine::gameLoop() {
 					break;
 				}
 			}
+			break;
+		default:
+			break;
 		}
 	}
 


Commit: 2ced551825af73225a522fe9adfbf3bafcb48a28
    https://github.com/scummvm/scummvm/commit/2ced551825af73225a522fe9adfbf3bafcb48a28
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Cleanup sound code

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/preagi.cpp
    engines/agi/preagi/preagi.h
    engines/agi/preagi/troll.cpp


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 49db9570240..180b679cebb 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -664,7 +664,7 @@ void MickeyEngine::playNote(MSA_SND_NOTE note) {
 		// Pause
 		_system->delayMillis((uint)(note.length / IDI_SND_TIMER_RESOLUTION));
 	} else {
-		PreAgiEngine::playNote(IDI_SND_OSCILLATOR_FREQUENCY / note.counter, (int32)(note.length / IDI_SND_TIMER_RESOLUTION));
+		playSpeakerNote(IDI_SND_OSCILLATOR_FREQUENCY / note.counter, (int32)(note.length / IDI_SND_TIMER_RESOLUTION));
 	}
 }
 
diff --git a/engines/agi/preagi/preagi.cpp b/engines/agi/preagi/preagi.cpp
index e824182c4cf..cf6e7a3b0a8 100644
--- a/engines/agi/preagi/preagi.cpp
+++ b/engines/agi/preagi/preagi.cpp
@@ -275,15 +275,11 @@ int PreAgiEngine::getSelection(SelectionTypes type) {
 	return 0;
 }
 
-void PreAgiEngine::playNote(int16 frequency, int32 length) {
+void PreAgiEngine::playSpeakerNote(int16 frequency, int32 length) {
 	_speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, frequency, length);
-	waitForTimer(length);
-}
-
-void PreAgiEngine::waitForTimer(int msec_delay) {
-	uint32 start_time = _system->getMillis();
 
-	while (_system->getMillis() < start_time + msec_delay) {
+	uint32 startTime = _system->getMillis();
+	while (_system->getMillis() - startTime < (uint32)length) {
 		_system->updateScreen();
 		_system->delayMillis(10);
 	}
diff --git a/engines/agi/preagi/preagi.h b/engines/agi/preagi/preagi.h
index a4c666790c9..fb3837a84be 100644
--- a/engines/agi/preagi/preagi.h
+++ b/engines/agi/preagi/preagi.h
@@ -56,7 +56,6 @@ class PreAgiEngine : public AgiBase {
 protected:
 	void initialize() override;
 
-	void pollTimer() {}
 	int getKeypress() override { return 0; }
 	bool isKeypress() override { return false; }
 	void clearKeyQueue() override {}
@@ -101,8 +100,7 @@ protected:
 	// Saved Games
 	Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
 
-	void playNote(int16 frequency, int32 length);
-	void waitForTimer(int msec_delay);
+	void playSpeakerNote(int16 frequency, int32 length);
 
 private:
 	int _defaultColor;
diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index 4edb2e202c8..960681705eb 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -468,16 +468,15 @@ void TrollEngine::playTune(int tune, int len) {
 	if (!_soundOn)
 		return;
 
-	int freq, duration;
 	int ptr = _tunes[tune - 1];
 
 	for (int i = 0; i < len; i++) {
-		freq = READ_LE_UINT16(_gameData + ptr);
+		int freq = READ_LE_UINT16(_gameData + ptr);
 		ptr += 2;
-		duration = READ_LE_UINT16(_gameData + ptr);
+		int duration = READ_LE_UINT16(_gameData + ptr);
 		ptr += 2;
 
-		playNote(freq, duration);
+		playSpeakerNote(freq, duration);
 	}
 }
 


Commit: 345476654436038f2ffd95009995c4e72153bcfd
    https://github.com/scummvm/scummvm/commit/345476654436038f2ffd95009995c4e72153bcfd
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Improve WINNIE event handling

Changed paths:
    engines/agi/preagi/preagi.cpp
    engines/agi/preagi/preagi.h
    engines/agi/preagi/winnie.cpp


diff --git a/engines/agi/preagi/preagi.cpp b/engines/agi/preagi/preagi.cpp
index cf6e7a3b0a8..688cf349d11 100644
--- a/engines/agi/preagi/preagi.cpp
+++ b/engines/agi/preagi/preagi.cpp
@@ -285,4 +285,22 @@ void PreAgiEngine::playSpeakerNote(int16 frequency, int32 length) {
 	}
 }
 
+void PreAgiEngine::wait(uint32 delay) {
+	Common::Event event;
+	uint32 startTime = _system->getMillis();
+
+	while (!shouldQuit()) {
+		// process events
+		while (_eventMan->pollEvent(event)) {
+		}
+
+		if (_system->getMillis() - startTime >= delay) {
+			return;
+		}
+
+		_system->updateScreen();
+		_system->delayMillis(10);
+	}
+}
+
 } // End of namespace Agi
diff --git a/engines/agi/preagi/preagi.h b/engines/agi/preagi/preagi.h
index fb3837a84be..29aaa9a14fb 100644
--- a/engines/agi/preagi/preagi.h
+++ b/engines/agi/preagi/preagi.h
@@ -101,6 +101,7 @@ protected:
 	Common::SaveFileManager *getSaveFileMan() { return _saveFileMan; }
 
 	void playSpeakerNote(int16 frequency, int32 length);
+	void wait(uint32 delay);
 
 private:
 	int _defaultColor;
diff --git a/engines/agi/preagi/winnie.cpp b/engines/agi/preagi/winnie.cpp
index ae883c1258e..2ce3dcaf30b 100644
--- a/engines/agi/preagi/winnie.cpp
+++ b/engines/agi/preagi/winnie.cpp
@@ -212,17 +212,11 @@ void WinnieEngine::randomize() {
 void WinnieEngine::intro() {
 	drawPic(IDS_WTP_FILE_LOGO);
 	printStr(IDS_WTP_INTRO_0);
-	_system->updateScreen();
-	_system->delayMillis(0x640);
-
-	if (getPlatform() == Common::kPlatformAmiga)
-		_gfx->clearDisplay(0);
+	wait(1600);
 
 	drawPic(IDS_WTP_FILE_TITLE);
-
 	printStr(IDS_WTP_INTRO_1);
-	_system->updateScreen();
-	_system->delayMillis(0x640);
+	wait(1600);
 
 	if (!playSound(IDI_WTP_SND_POOH_0))
 		return;
@@ -1298,10 +1292,19 @@ bool WinnieEngine::playSound(ENUM_WTP_SOUND iSound) {
 	// Loop until the sound is done
 	bool skippedSound = false;
 	while (!shouldQuit() && _game.sounds[0]->isPlaying()) {
+		// process all events to keep window responsive and to
+		// allow interruption by mouse button or key press.
 		Common::Event event;
 		while (_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_KEYDOWN:
+				// don't interrupt if a modifier is pressed
+				if (event.kbd.flags & Common::KBD_NON_STICKY) {
+					continue;
+				}
+				// fall through
+			case Common::EVENT_LBUTTONUP:
+			case Common::EVENT_RBUTTONUP:
 				_sound->stopSound();
 				skippedSound = true;
 				break;
@@ -1310,6 +1313,7 @@ bool WinnieEngine::playSound(ENUM_WTP_SOUND iSound) {
 			}
 		}
 
+		_system->updateScreen();
 		_system->delayMillis(10);
 	}
 


Commit: 7ca53599771978892ba5f4e728d243a11c5c0697
    https://github.com/scummvm/scummvm/commit/7ca53599771978892ba5f4e728d243a11c5c0697
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Improve TROLL intro event handling

Changed paths:
    engines/agi/preagi/troll.cpp


diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index 960681705eb..c41835935cf 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -196,10 +196,16 @@ void TrollEngine::waitAnyKeyIntro() {
 	while (!shouldQuit()) {
 		while (_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
+			case Common::EVENT_KEYDOWN:
+				// don't interrupt if a modifier is pressed
+				if (event.kbd.flags & Common::KBD_NON_STICKY) {
+					continue;
+				}
+				// fall through
 			case Common::EVENT_RETURN_TO_LAUNCHER:
 			case Common::EVENT_QUIT:
 			case Common::EVENT_LBUTTONUP:
-			case Common::EVENT_KEYDOWN:
+			case Common::EVENT_RBUTTONUP:
 				return;
 			default:
 				break;
@@ -212,11 +218,9 @@ void TrollEngine::waitAnyKeyIntro() {
 			// fall through
 		case 0:
 			drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_2);
-			_system->updateScreen();
 			break;
 		case 100:
 			drawStr(22, 3, kColorDefault, IDS_TRO_INTRO_3);
-			_system->updateScreen();
 			break;
 		default:
 			break;
@@ -356,8 +360,7 @@ void TrollEngine::intro() {
 	clearScreen(0x2F);
 	drawStr(9, 10, kColorDefault, IDS_TRO_INTRO_0);
 	drawStr(14, 15, kColorDefault, IDS_TRO_INTRO_1);
-	_system->updateScreen();
-	_system->delayMillis(3200);
+	wait(3200);
 
 	CursorMan.showMouse(true);
 


Commit: 613a0c2f793e0471ff48ebccaf8b81e7977f2700
    https://github.com/scummvm/scummvm/commit/613a0c2f793e0471ff48ebccaf8b81e7977f2700
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Improve MICKEY event handling

Changed paths:
    engines/agi/preagi/mickey.cpp


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 180b679cebb..a893bf2de0d 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -700,11 +700,16 @@ void MickeyEngine::playSound(ENUM_MSA_SOUND iSound) {
 			if (iSound == IDI_MSA_SND_THEME) {
 				while (_system->getEventManager()->pollEvent(event)) {
 					switch (event.type) {
+					case Common::EVENT_KEYDOWN:
+						// don't interrupt if a modifier is pressed
+						if (event.kbd.flags & Common::KBD_NON_STICKY) {
+							continue;
+						}
+						// fall through
 					case Common::EVENT_RETURN_TO_LAUNCHER:
 					case Common::EVENT_QUIT:
 					case Common::EVENT_LBUTTONUP:
 					case Common::EVENT_RBUTTONUP:
-					case Common::EVENT_KEYDOWN:
 						delete[] buffer;
 						return;
 					default:
@@ -2203,9 +2208,14 @@ void MickeyEngine::waitAnyKey(bool anim) {
 	while (!shouldQuit()) {
 		while (_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
+			case Common::EVENT_KEYDOWN:
+				// don't interrupt if a modifier is pressed
+				if (event.kbd.flags & Common::KBD_NON_STICKY) {
+					continue;
+				}
+				// fall through
 			case Common::EVENT_RETURN_TO_LAUNCHER:
 			case Common::EVENT_QUIT:
-			case Common::EVENT_KEYDOWN:
 			case Common::EVENT_LBUTTONUP:
 			case Common::EVENT_RBUTTONUP:
 				return;


Commit: 429b7c37341aa1d21cbdb02049e09430942c9e63
    https://github.com/scummvm/scummvm/commit/429b7c37341aa1d21cbdb02049e09430942c9e63
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY crystal animation

Fixes crystal animation not looping, fixes the next room picture
not being completely drawn.

Regression from: 1ef27b3e5b0b2ef955af87c8ac6ff0458299e7bc

Removes the hard-coded Mickey-crystal logic from PictureMgr;
MickeyEngine is now responsible for animating crystals.

Changed paths:
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi/mickey.cpp


diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index d226c52a790..7d17cc3aea7 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -52,7 +52,7 @@ PictureMgr::PictureMgr(AgiBase *agi, GfxMgr *gfx) {
 	_yOffset = 0;
 
 	_flags = 0;
-	_currentStep = 0;
+	_maxStep = 0;
 }
 
 void PictureMgr::putVirtPixel(int x, int y) {
@@ -482,8 +482,6 @@ void PictureMgr::drawPictureV15() {
 
 void PictureMgr::drawPictureV2() {
 	bool nibbleMode = false;
-	bool mickeyCrystalAnimation = false;
-	int  mickeyIteration = 0;
 
 	debugC(8, kDebugLevelMain, "Drawing V2/V3 picture");
 
@@ -492,10 +490,7 @@ void PictureMgr::drawPictureV2() {
 		nibbleMode = true;
 	}
 
-	if ((_flags & kPicFStep) && _vm->getGameType() == GType_PreAGI) {
-		mickeyCrystalAnimation = true;
-	}
-
+	int step = 0;
 	while (_dataOffset < _dataSize) {
 		byte curByte = getNextByte();
 
@@ -559,24 +554,10 @@ void PictureMgr::drawPictureV2() {
 			break;
 		}
 
-		// This is used by Mickey for the crystal animation
-		// One frame of the crystal animation is shown on each iteration, based on _currentStep
-		if (mickeyCrystalAnimation) {
-			if (_currentStep == mickeyIteration) {
-				int16 storedXOffset = _xOffset;
-				int16 storedYOffset = _yOffset;
-				// Note that picture coordinates are correct for Mickey only
-				showPic(10, 0, _width, _height);
-				_xOffset = storedXOffset;
-				_yOffset = storedYOffset;
-				_currentStep++;
-				if (_currentStep > 14)  // crystal animation is 15 frames
-					_currentStep = 0;
-				// reset the picture step flag - it will be set when the next frame of the crystal animation is drawn
-				_flags &= ~kPicFStep;
-				return;     // return back to the game loop
-			}
-			mickeyIteration++;
+		// Limit drawing to the optional maximum number of opcodes
+		step++;
+		if (step == _maxStep) {
+			return;
 		}
 	}
 }
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 37d19237f8e..55be9bbe583 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -54,10 +54,9 @@ enum AgiPictureVersion {
 enum AgiPictureFlags {
 	kPicFNone      = (1 << 0),
 	kPicFCircle    = (1 << 1),
-	kPicFStep      = (1 << 2),
-	kPicFf3Stop    = (1 << 3),
-	kPicFf3Cont    = (1 << 4),
-	kPicFTrollMode = (1 << 5)
+	kPicFf3Stop    = (1 << 2),
+	kPicFf3Cont    = (1 << 3),
+	kPicFTrollMode = (1 << 4)
 };
 
 class AgiBase;
@@ -134,6 +133,9 @@ public:
 		_height = h;
 	}
 
+	void setMaxStep(int maxStep) { _maxStep = maxStep; }
+	int getMaxStep() const { return _maxStep; }
+
 private:
 	int16  _resourceNr;
 	uint8 *_data;
@@ -157,7 +159,7 @@ private:
 	int16 _yOffset;
 
 	int _flags;
-	int _currentStep;
+	int _maxStep; // Max opcodes to draw, zero for all. Used by preagi (Mickey)
 };
 
 } // End of namespace Agi
diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index a893bf2de0d..af4690349f0 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -740,9 +740,18 @@ void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
 	file.read(buffer, size);
 	file.close();
 
-	if (iObj == IDI_MSA_OBJECT_CRYSTAL)
-		_picture->setPictureFlags(kPicFStep);
+	int maxStep = 0; // default: draw all opcodes
+	if (iObj == IDI_MSA_OBJECT_CRYSTAL) {
+		// Handle crystal animation. Each "frame" is the picture
+		// drawn with an additional opcode until it wraps around.
+		// The crystal has 14 opcodes followed by the terminator.
+		maxStep = _picture->getMaxStep() + 1;
+		if (maxStep == 15) {
+			maxStep = 1;
+		}
+	}
 
+	_picture->setMaxStep(maxStep);
 	_picture->setOffset(x0, y0);
 	_picture->decodePictureFromBuffer(buffer, size, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 	_picture->setOffset(0, 0);
@@ -763,6 +772,7 @@ void MickeyEngine::drawPic(int iPic) {
 	file.close();
 
 	// Note that decodePicture clears the screen
+	_picture->setMaxStep(0);
 	_picture->setOffset(10, 0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 	_picture->setOffset(0, 0);
@@ -808,6 +818,7 @@ void MickeyEngine::drawRoomAnimation() {
 
 			_picture->setPictureData(objLight);
 			_picture->setPictureFlags(kPicFCircle);
+			_picture->setMaxStep(0);
 			_picture->drawPicture();
 		}
 		_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);


Commit: bdf451b6478cb5228f6ba847b2aa634c3b091741
    https://github.com/scummvm/scummvm/commit/bdf451b6478cb5228f6ba847b2aa634c3b091741
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY object placement

Fixes all objects being drawn 10 pixels to the left

Regression from: 1ef27b3e5b0b2ef955af87c8ac6ff0458299e7bc

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/mickey.h


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index af4690349f0..2ec72d0135c 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -752,10 +752,10 @@ void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
 	}
 
 	_picture->setMaxStep(maxStep);
-	_picture->setOffset(x0, y0);
+	_picture->setOffset(IDI_MSA_PIC_X0 + x0, IDI_MSA_PIC_Y0 + y0);
 	_picture->decodePictureFromBuffer(buffer, size, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 	_picture->setOffset(0, 0);
-	_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
 void MickeyEngine::drawPic(int iPic) {
@@ -773,10 +773,10 @@ void MickeyEngine::drawPic(int iPic) {
 
 	// Note that decodePicture clears the screen
 	_picture->setMaxStep(0);
-	_picture->setOffset(10, 0);
+	_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 	_picture->setOffset(0, 0);
-	_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
 void MickeyEngine::drawRoomAnimation() {
@@ -819,10 +819,10 @@ void MickeyEngine::drawRoomAnimation() {
 			_picture->setPictureData(objLight);
 			_picture->setPictureFlags(kPicFCircle);
 			_picture->setMaxStep(0);
+			_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
 			_picture->drawPicture();
 		}
-		_picture->showPic(10, 0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
-
+		_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 
 		_gameStateMickey.nFrame--;
 		if (_gameStateMickey.nFrame < 0)
diff --git a/engines/agi/preagi/mickey.h b/engines/agi/preagi/mickey.h
index a92fe82e36f..dfa563c2106 100644
--- a/engines/agi/preagi/mickey.h
+++ b/engines/agi/preagi/mickey.h
@@ -99,6 +99,8 @@ const char IDS_MSA_INSERT_DISK[][40] = {
 
 #define IDI_MSA_PIC_WIDTH   140
 #define IDI_MSA_PIC_HEIGHT  159
+#define IDI_MSA_PIC_X0      10
+#define IDI_MSA_PIC_Y0      0
 
 // pictures
 


Commit: 188b0685f3c49a93ae5ae3099e054ab922e806a9
    https://github.com/scummvm/scummvm/commit/188b0685f3c49a93ae5ae3099e054ab922e806a9
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY saves always loading to Earth

Fixes loading a saved game and always returning to Earth instead of the
planet the game was saved on.

Unclear if this was original behavior, but we already save the current
planet and load it back, so it seems wrong to discard that and send the
player to a different planet instead.

Changed paths:
    engines/agi/preagi/mickey.cpp


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 2ec72d0135c..23e811d6fe3 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -1013,14 +1013,11 @@ bool MickeyEngine::loadGame() {
 			}
 
 			saveVersion = infile->readByte();
-			if (saveVersion < 2) {
-				warning("The planet data in this save game is corrupted. Load aborted");
+			if (saveVersion != MSA_SAVEGAME_VERSION) { // currently only one valid version
+				warning("MickeyEngine::loadGame unknown save version: %d", saveVersion);
 				return false;
 			}
 
-			if (saveVersion != MSA_SAVEGAME_VERSION)
-				warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, MSA_SAVEGAME_VERSION);
-
 			_gameStateMickey.iRoom = infile->readByte();
 			_gameStateMickey.iPlanet = infile->readByte();
 			_gameStateMickey.iDisk = infile->readByte();
@@ -1426,9 +1423,7 @@ void MickeyEngine::intro() {
 	_gameStateMickey.fIntro = true;
 	if (chooseY_N(IDO_MSA_LOAD_GAME[0], true)) {
 		if (loadGame()) {
-			_gameStateMickey.iPlanet = IDI_MSA_PLANET_EARTH;
 			_gameStateMickey.fIntro = false;
-			_gameStateMickey.iRoom = IDI_MSA_PIC_SHIP_CORRIDOR;
 			return;
 		}
 	}


Commit: 4cfe4e139f926ce3d87a3e78bc7215ca57285207
    https://github.com/scummvm/scummvm/commit/4cfe4e139f926ce3d87a3e78bc7215ca57285207
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY crystal persistence

Fixes crystal reappearing on Earth, and other edge cases.

The fHasXtal flag was being used to track two conflicting things:

1. If the player picked up a crystal but hadn't flipped the switch yet.
2. If the current planet still has a crystal.

Now the flag is only used for the former, and the latter is derived
from stable game state.

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/mickey.h


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 23e811d6fe3..6377f134116 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -849,7 +849,7 @@ void MickeyEngine::drawRoomAnimation() {
 
 		// draw crystal
 		if (_gameStateMickey.iRoom == IDI_MSA_XTAL_ROOM_XY[_gameStateMickey.iPlanet][0]) {
-			if (!_gameStateMickey.fHasXtal) {
+			if (isCrystalOnCurrentPlanet()) {
 				switch (_gameStateMickey.iPlanet) {
 				case IDI_MSA_PLANET_VENUS:
 					if (_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] != 2)
@@ -1301,7 +1301,7 @@ void MickeyEngine::gameOver() {
 }
 
 void MickeyEngine::flipSwitch() {
-	if (_gameStateMickey.fHasXtal || _gameStateMickey.nXtals) {
+	if (_gameStateMickey.nXtals) {
 		if (!_gameStateMickey.fStoryShown)
 			printStory();
 
@@ -1784,14 +1784,14 @@ bool MickeyEngine::parse(int cmd, int arg) {
 	// MERCURY
 
 	case IDI_MSA_ACTION_GET_XTAL_MERCURY:
-		if (_gameStateMickey.fHasXtal) {
-			_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] = 2;
-			printDatMessage(32);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			if (_gameStateMickey.fItem[IDI_MSA_ITEM_SUNGLASSES]) {
 				_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] = 1;
 			}
 			printDatMessage(arg);
+		} else {
+			_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] = 2;
+			printDatMessage(32);
 		}
 		break;
 	case IDI_MSA_ACTION_GIVE_SUNGLASSES:
@@ -1822,10 +1822,10 @@ bool MickeyEngine::parse(int cmd, int arg) {
 
 		return true;
 	case IDI_MSA_ACTION_GET_XTAL_SATURN:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(29);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			getXtal(arg);
+		} else {
+			printDatMessage(29);
 		}
 		break;
 	case IDI_MSA_ACTION_LEAVE_ISLAND:
@@ -1838,13 +1838,13 @@ bool MickeyEngine::parse(int cmd, int arg) {
 	// PLUTO
 
 	case IDI_MSA_ACTION_GET_XTAL_PLUTO:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(19);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			if (_gameStateMickey.fItem[IDI_MSA_ITEM_BONE]) {
 				_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] = 1;
 			}
 			printDatMessage(arg);
+		} else {
+			printDatMessage(19);
 		}
 		break;
 	case IDI_MSA_ACTION_GIVE_BONE:
@@ -1870,9 +1870,7 @@ bool MickeyEngine::parse(int cmd, int arg) {
 		}
 		break;
 	case IDI_MSA_ACTION_GET_XTAL_JUPITER:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(15);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			switch (_gameStateMickey.nRocks) {
 			case 0:
 				if (_gameStateMickey.fItem[IDI_MSA_ITEM_ROCK]) {
@@ -1892,6 +1890,8 @@ bool MickeyEngine::parse(int cmd, int arg) {
 			default:
 				break;
 			}
+		} else {
+			printDatMessage(15);
 		}
 		break;
 	case IDI_MSA_ACTION_THROW_ROCK:
@@ -1928,17 +1928,17 @@ bool MickeyEngine::parse(int cmd, int arg) {
 
 		return true;
 	case IDI_MSA_ACTION_PLUTO_DIG:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(21);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			getXtal(arg);
+		} else {
+			printDatMessage(21);
 		}
 		break;
 	case IDI_MSA_ACTION_GET_XTAL_MARS:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(23);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			printDatMessage(arg);
+		} else {
+			printDatMessage(23);
 		}
 		break;
 
@@ -1984,13 +1984,13 @@ bool MickeyEngine::parse(int cmd, int arg) {
 		}
 		break;
 	case IDI_MSA_ACTION_GET_XTAL_URANUS:
-		if (_gameStateMickey.fHasXtal) {
-			printDatMessage(34);
-		} else {
+		if (isCrystalOnCurrentPlanet()) {
 			if (_gameStateMickey.fItem[IDI_MSA_ITEM_CROWBAR]) {
 				_gameStateMickey.iRmMenu[_gameStateMickey.iRoom] = 1;
 			}
 			printDatMessage(arg);
+		} else {
+			printDatMessage(34);
 		}
 		break;
 	case IDI_MSA_ACTION_USE_CROWBAR_1:
@@ -2019,7 +2019,6 @@ bool MickeyEngine::parse(int cmd, int arg) {
 			if ((_gameStateMickey.nXtals == IDI_MSA_MAX_PLANET) && (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH))
 				gameOver();
 			if ((_gameStateMickey.iPlanet == _gameStateMickey.iPlanetXtal[_gameStateMickey.nXtals]) || (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH)) {
-				_gameStateMickey.fHasXtal = false;
 				_gameStateMickey.iRoom = IDI_MSA_HOME_PLANET[_gameStateMickey.iPlanet];
 
 				if (_gameStateMickey.iPlanet != IDI_MSA_PLANET_EARTH)
@@ -2367,4 +2366,22 @@ Common::Error MickeyEngine::go() {
 	return Common::kNoError;
 }
 
+bool MickeyEngine::isCrystalOnCurrentPlanet() const {
+	// Earth is a special case, because the planet list may not have been
+	// initialized yet. Earth is always the first planet, so if no crystals
+	// have been gotten yet, then earth's crystal must still be there.
+	if (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH) {
+		return (_gameStateMickey.nXtals == 0);
+	}
+
+	if (_gameStateMickey.fPlanetsInitialized) {
+		for (uint8 i = 1; i < IDI_MSA_MAX_DAT; i++) {
+			if (_gameStateMickey.iPlanetXtal[i] == _gameStateMickey.iPlanet) {
+				return (_gameStateMickey.nXtals <= i);
+			}
+		}
+	}
+	return false;
+}
+
 } // End of namespace Agi
diff --git a/engines/agi/preagi/mickey.h b/engines/agi/preagi/mickey.h
index dfa563c2106..a107e7bad28 100644
--- a/engines/agi/preagi/mickey.h
+++ b/engines/agi/preagi/mickey.h
@@ -754,6 +754,8 @@ protected:
 			return false;
 		}
 	}
+
+	bool isCrystalOnCurrentPlanet() const;
 };
 
 } // End of namespace Agi


Commit: 6822ff599eaf8c7148437156d95c8cf60a631646
    https://github.com/scummvm/scummvm/commit/6822ff599eaf8c7148437156d95c8cf60a631646
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY crystal appearing before room change

Changed paths:
    engines/agi/preagi/mickey.cpp


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 6377f134116..1ce12eb58bb 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -1816,9 +1816,12 @@ bool MickeyEngine::parse(int cmd, int arg) {
 
 		break;
 	case IDI_MSA_ACTION_USE_MATTRESS:
-		_gameStateMickey.iRoom = IDI_MSA_PIC_SATURN_ISLAND;
-
 		printDatMessage(arg);
+		
+		// must set room after printDatMessage, or else the crystal from
+		// the next room will appear and animate while still displaying
+		// the picture for the current room
+		_gameStateMickey.iRoom = IDI_MSA_PIC_SATURN_ISLAND;
 
 		return true;
 	case IDI_MSA_ACTION_GET_XTAL_SATURN:


Commit: 088c5b3ae1607088828afc661dab7b9acf10c94e
    https://github.com/scummvm/scummvm/commit/088c5b3ae1607088828afc661dab7b9acf10c94e
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY ship button behavior

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/mickey.h


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 1ce12eb58bb..3c8c54681dc 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -1195,8 +1195,7 @@ void MickeyEngine::saveGame() {
 
 void MickeyEngine::showPlanetInfo() {
 	for (int i = 0; i < 4; i++) {
-		printExeStr(IDO_MSA_PLANET_INFO[_gameStateMickey.iPlanet][i]);
-		waitAnyKey();
+		printExeMsg(IDO_MSA_PLANET_INFO[_gameStateMickey.iPlanet][i]);
 	}
 }
 
@@ -1268,7 +1267,7 @@ void MickeyEngine::pressOB(int iButton) {
 	}
 
 	// print pressed buttons
-	printLine("MICKEY HAS PRESSED:                  ");
+	printExeStr(IDO_MSA_MICKEY_HAS_PRESSED);
 	drawStr(20, 22, IDA_DEFAULT, szButtons);
 	waitAnyKey();
 }
diff --git a/engines/agi/preagi/mickey.h b/engines/agi/preagi/mickey.h
index a107e7bad28..617bd54d015 100644
--- a/engines/agi/preagi/mickey.h
+++ b/engines/agi/preagi/mickey.h
@@ -618,6 +618,7 @@ const int IDO_MSA_NEXT_PIECE[IDI_MSA_MAX_PLANET][5] = {
 
 #define IDO_MSA_PRESS_1_TO_9                    0x7530
 #define IDO_MSA_PRESS_YES_OR_NO                 0x480D
+#define IDO_MSA_MICKEY_HAS_PRESSED              0x5D90
 #define IDO_MSA_TOO_MANY_BUTTONS_PRESSED        0x5DF7
 
 #define IDO_MSA_XL30_SPEAKING                   0x4725


Commit: 0cd9a31d8cfca1b8bbc2b46dfa2a2c119e380e9b
    https://github.com/scummvm/scummvm/commit/0cd9a31d8cfca1b8bbc2b46dfa2a2c119e380e9b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Fix MICKEY game over handling

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/mickey.h


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 3c8c54681dc..8e4d86bdc15 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -1279,10 +1279,6 @@ void MickeyEngine::insertDisk(int iDisk) {
 }
 
 void MickeyEngine::gameOver() {
-	// We shouldn't run the game over segment if we're quitting.
-	if (shouldQuit())
-		return;
-
 	drawPic(IDI_MSA_PIC_EARTH_SHIP_LEAVING);
 	printExeMsg(IDO_MSA_GAME_OVER[3]);
 	playSound(IDI_MSA_SND_GAME_OVER);
@@ -1296,7 +1292,7 @@ void MickeyEngine::gameOver() {
 		printExeMsg(IDO_MSA_GAME_OVER[7]);
 	}
 
-	waitAnyKey();
+	_isGameOver = true;
 }
 
 void MickeyEngine::flipSwitch() {
@@ -2018,8 +2014,11 @@ bool MickeyEngine::parse(int cmd, int arg) {
 		break;
 	case IDI_MSA_ACTION_GO_PLANET:
 		if (!_gameStateMickey.fShipDoorOpen) {
-			if ((_gameStateMickey.nXtals == IDI_MSA_MAX_PLANET) && (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH))
+			if ((_gameStateMickey.nXtals == IDI_MSA_MAX_PLANET) && (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH)) {
 				gameOver();
+				return true;
+			}
+
 			if ((_gameStateMickey.iPlanet == _gameStateMickey.iPlanetXtal[_gameStateMickey.nXtals]) || (_gameStateMickey.iPlanet == IDI_MSA_PLANET_EARTH)) {
 				_gameStateMickey.iRoom = IDI_MSA_HOME_PLANET[_gameStateMickey.iPlanet];
 
@@ -2256,6 +2255,7 @@ void MickeyEngine::debugGotoRoom(int room) {
 }
 
 MickeyEngine::MickeyEngine(OSystem *syst, const AGIGameDescription *gameDesc) : PreAgiEngine(syst, gameDesc) {
+	_isGameOver = false;
 	setDebugger(new MickeyConsole(this));
 }
 
@@ -2323,7 +2323,7 @@ Common::Error MickeyEngine::go() {
 	intro();
 
 	// Game loop
-	while (!shouldQuit()) {
+	while (!shouldQuit() && !_isGameOver) {
 		drawRoom();
 
 		if (_gameStateMickey.fIntro) {
@@ -2363,8 +2363,6 @@ Common::Error MickeyEngine::go() {
 		_gameStateMickey.nFrame = 0;
 	}
 
-	gameOver();
-
 	return Common::kNoError;
 }
 
diff --git a/engines/agi/preagi/mickey.h b/engines/agi/preagi/mickey.h
index 617bd54d015..f4e881a510b 100644
--- a/engines/agi/preagi/mickey.h
+++ b/engines/agi/preagi/mickey.h
@@ -694,6 +694,7 @@ public:
 protected:
 	MSA_GAME _gameStateMickey;
 	bool _clickToMove;
+	bool _isGameOver;
 
 	int getDat(int);
 	void readExe(int, uint8 *, long);


Commit: d461e132d6685cb25fcd2b3250cfa35340c40dda
    https://github.com/scummvm/scummvm/commit/d461e132d6685cb25fcd2b3250cfa35340c40dda
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: PREAGI: Cleanup MICKEY code

Changed paths:
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/winnie.cpp


diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 8e4d86bdc15..03453f1ac38 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -136,15 +136,13 @@ int MickeyEngine::choose1to9(int ofsPrompt) {
 }
 
 void MickeyEngine::printStr(char *buffer) {
-	int pc = 1;
-	int nRows, iCol, iRow;
-
-	nRows = *buffer + IDI_MSA_ROW_MENU_0;
-
 	clearTextArea();
 
-	for (iRow = IDI_MSA_ROW_MENU_0; iRow < nRows; iRow++) {
-		iCol = *(buffer + pc++);
+	int pc = 1;
+	const int nRows = *buffer + IDI_MSA_ROW_MENU_0;
+
+	for (int iRow = IDI_MSA_ROW_MENU_0; iRow < nRows; iRow++) {
+		int iCol = *(buffer + pc++);
 		drawStr(iRow, iCol, IDA_DEFAULT, buffer + pc);
 		pc += strlen(buffer + pc) + 1;
 	}
@@ -255,26 +253,12 @@ bool MickeyEngine::checkMenu() {
 }
 
 void MickeyEngine::drawMenu(MSA_MENU &menu, int sel0, int sel1) {
-	int iWord;
-	int iRow;
-	int sel;
-	uint8 attr;
-
-	// draw menu
-
 	clearTextArea();
 
-	for (iRow = 0; iRow < 2; iRow++) {
-		for (iWord = 0; iWord < menu.row[iRow].count; iWord++) {
-			if (iRow)
-				sel = sel1;
-			else
-				sel = sel0;
-
-			if (iWord == sel)
-				attr = IDA_DEFAULT_REV;
-			else
-				attr = IDA_DEFAULT;
+	for (int iRow = 0; iRow < 2; iRow++) {
+		for (int iWord = 0; iWord < menu.row[iRow].count; iWord++) {
+			int sel = (iRow == 0) ? sel0 : sel1;
+			uint8 attr = (iWord == sel) ? IDA_DEFAULT_REV : IDA_DEFAULT;
 
 			drawStr(IDI_MSA_ROW_MENU_0 + iRow, menu.row[iRow].entry[iWord].x0,
 			        attr, (char *)menu.row[iRow].entry[iWord].szText);
@@ -286,7 +270,6 @@ void MickeyEngine::drawMenu(MSA_MENU &menu, int sel0, int sel1) {
 }
 
 void MickeyEngine::getMouseMenuSelRow(MSA_MENU &menu, int *sel0, int *sel1, int iRow, int x, int y) {
-	int iWord;
 	int *sel = nullptr;
 
 	switch (iRow) {
@@ -302,7 +285,7 @@ void MickeyEngine::getMouseMenuSelRow(MSA_MENU &menu, int *sel0, int *sel1, int
 		return;
 	}
 
-	for (iWord = 0; iWord < menu.row[iRow].count; iWord++) {
+	for (int iWord = 0; iWord < menu.row[iRow].count; iWord++) {
 		if ((x >= menu.row[iRow].entry[iWord].x0) &&
 		        (x < (int)(menu.row[iRow].entry[iWord].x0 +
 		                   strlen((char *)menu.row[iRow].entry[iWord].szText)))) {
@@ -315,7 +298,6 @@ void MickeyEngine::getMouseMenuSelRow(MSA_MENU &menu, int *sel0, int *sel1, int
 bool MickeyEngine::getMenuSelRow(MSA_MENU &menu, int *sel0, int *sel1, int iRow) {
 	Common::Event event;
 	int *sel = nullptr;
-	int nWords;
 	int x, y;
 	int goIndex = -1, northIndex = -1, southIndex = -1, eastIndex = -1, westIndex = -1;
 
@@ -329,7 +311,7 @@ bool MickeyEngine::getMenuSelRow(MSA_MENU &menu, int *sel0, int *sel1, int iRow)
 	default:
 		break;
 	}
-	nWords = menu.row[iRow].count;
+	int nWords = menu.row[iRow].count;
 	_clickToMove = false;
 
 	for (int i = 0; i <= menu.row[0].count; i++)
@@ -587,19 +569,15 @@ void MickeyEngine::getMenuSel(char *buffer, int *sel0, int *sel1) {
 }
 
 void MickeyEngine::centerMenu(MSA_MENU *menu) {
-	int iWord;
-	int iRow;
-	int w, x;
-
-	for (iRow = 0; iRow < 2; iRow++) {
-		w = 0;
-		for (iWord = 0; iWord < menu->row[iRow].count; iWord++) {
+	for (int iRow = 0; iRow < 2; iRow++) {
+		int w = 0;
+		for (int iWord = 0; iWord < menu->row[iRow].count; iWord++) {
 			w += strlen((char *)menu->row[iRow].entry[iWord].szText);
 		}
 		w += menu->row[iRow].count - 1;
-		x = (40 - w) / 2;   // FIX
+		int x = (40 - w) / 2;   // FIX
 
-		for (iWord = 0; iWord < menu->row[iRow].count; iWord++) {
+		for (int iWord = 0; iWord < menu->row[iRow].count; iWord++) {
 			menu->row[iRow].entry[iWord].x0 = x;
 			x += strlen((char *)menu->row[iRow].entry[iWord].szText) + 1;
 		}
@@ -607,11 +585,6 @@ void MickeyEngine::centerMenu(MSA_MENU *menu) {
 }
 
 void MickeyEngine::patchMenu(MSA_MENU *menu) {
-	uint8 buffer[512];
-	uint8 menubuf[sizeof(MSA_MENU)];
-	int nPatches;
-	int pBuf = 0;
-
 	// change planet name in ship airlock menu
 	if (_gameStateMickey.iRoom == IDI_MSA_PIC_SHIP_AIRLOCK) {
 		Common::strcpy_s(menu->row[1].entry[2].szText, IDS_MSA_NAME_PLANET[_gameStateMickey.iPlanet]);
@@ -624,9 +597,11 @@ void MickeyEngine::patchMenu(MSA_MENU *menu) {
 	}
 
 	// copy menu to menubuf
+	uint8 menubuf[sizeof(MSA_MENU)];
 	memcpy(menubuf, menu, sizeof(menubuf));
 
 	// read patches
+	uint8 buffer[512];
 	readOfsData(
 	    IDOFS_MSA_MENU_PATCHES,
 	    _gameStateMickey.nRmMenu[_gameStateMickey.iRoom] + _gameStateMickey.iRmMenu[_gameStateMickey.iRoom] - 1,
@@ -634,7 +609,8 @@ void MickeyEngine::patchMenu(MSA_MENU *menu) {
 	);
 
 	// get number of patches
-	nPatches = buffer[pBuf++];
+	int pBuf = 0;
+	int nPatches = buffer[pBuf++];
 
 	// patch menubuf
 	for (int iPatch = 0; iPatch < nPatches; iPatch++) {
@@ -754,7 +730,6 @@ void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
 	_picture->setMaxStep(maxStep);
 	_picture->setOffset(IDI_MSA_PIC_X0 + x0, IDI_MSA_PIC_Y0 + y0);
 	_picture->decodePictureFromBuffer(buffer, size, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
-	_picture->setOffset(0, 0);
 	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
@@ -775,7 +750,6 @@ void MickeyEngine::drawPic(int iPic) {
 	_picture->setMaxStep(0);
 	_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
-	_picture->setOffset(0, 0);
 	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
@@ -804,12 +778,10 @@ void MickeyEngine::drawRoomAnimation() {
 	case IDI_MSA_PIC_SHIP_URANUS: {
 		// draw blinking ship lights
 
-		uint8 iColor = 0;
-
 		_picture->setPattern(2, 0);
 
 		for (int i = 0; i < 12; i++) {
-			iColor = _gameStateMickey.nFrame + i;
+			uint8 iColor = _gameStateMickey.nFrame + i;
 			if (iColor > 15)
 				iColor -= 15;
 
@@ -871,10 +843,6 @@ void MickeyEngine::drawRoomAnimation() {
 }
 
 void MickeyEngine::drawRoom() {
-	uint8 buffer[512];
-	int pBuf = 0;
-	int nObjs;
-
 	// Draw room picture
 	if (_gameStateMickey.iRoom == IDI_MSA_PIC_TITLE) {
 		drawPic(IDI_MSA_PIC_TITLE);
@@ -894,10 +862,12 @@ void MickeyEngine::drawRoom() {
 	// Draw room objects
 	if (_gameStateMickey.iRoom < IDI_MSA_MAX_ROOM &&
 		_gameStateMickey.iRmObj[_gameStateMickey.iRoom] != IDI_MSA_OBJECT_NONE) {
+		uint8 buffer[512];
 		readOfsData(IDO_MSA_ROOM_OBJECT_XY_OFFSETS,
 		            _gameStateMickey.iRmObj[_gameStateMickey.iRoom], buffer, sizeof(buffer));
 
-		nObjs = buffer[pBuf++];
+		int pBuf = 0;
+		int nObjs = buffer[pBuf++];
 
 		for (int iObj = 0; iObj < nObjs; iObj++) {
 			drawObj((ENUM_MSA_OBJECT)buffer[pBuf], buffer[pBuf + 1], buffer[pBuf + 2]);
@@ -910,23 +880,18 @@ void MickeyEngine::drawRoom() {
 }
 
 // Straight mapping, CGA colors to CGA
-const byte BCGColorMappingCGAToCGA[4] = {
+static const byte BCGColorMappingCGAToCGA[4] = {
 	0, 1, 2, 3
 };
 
 // Mapping table to map CGA colors to EGA
-const byte BCGColorMappingCGAToEGA[4] = {
+static const byte BCGColorMappingCGAToEGA[4] = {
 	0, 11, 13, 15
 };
 
 void MickeyEngine::drawLogo() {
 	const int width = 80;
 	const int height = 85 * 2;
-	byte  color1, color2, color3, color4;
-	byte  *fileBuffer = nullptr;
-	uint32 fileBufferSize = 0;
-	byte  *dataBuffer;
-	byte   curByte;
 	const byte *BCGColorMapping = BCGColorMappingCGAToEGA;
 
 	// disable color mapping in case we are in CGA mode
@@ -938,8 +903,8 @@ void MickeyEngine::drawLogo() {
 	if (!infile.open(IDS_MSA_PATH_LOGO))
 		return;
 
-	fileBufferSize = infile.size();
-	fileBuffer = new byte[fileBufferSize];
+	uint32 fileBufferSize = infile.size();
+	byte *fileBuffer = new byte[fileBufferSize];
 	infile.read(fileBuffer, fileBufferSize);
 	infile.close();
 
@@ -948,15 +913,15 @@ void MickeyEngine::drawLogo() {
 
 	// Show BCG picture
 	// It's basically uncompressed CGA 4-color data (4 pixels per byte)
-	dataBuffer = fileBuffer;
+	byte *dataBuffer = fileBuffer;
 	for (int y = 0; y < height; y++) {
 		for (int x = 0; x < width; x++) {
-			curByte = *dataBuffer++;
+			byte curByte = *dataBuffer++;
 
-			color1 = BCGColorMapping[(curByte >> 6) & 0x03];
-			color2 = BCGColorMapping[(curByte >> 4) & 0x03];
-			color3 = BCGColorMapping[(curByte >> 2) & 0x03];
-			color4 = BCGColorMapping[(curByte >> 0) & 0x03];
+			byte color1 = BCGColorMapping[(curByte >> 6) & 0x03];
+			byte color2 = BCGColorMapping[(curByte >> 4) & 0x03];
+			byte color3 = BCGColorMapping[(curByte >> 2) & 0x03];
+			byte color4 = BCGColorMapping[(curByte >> 0) & 0x03];
 
 			_gfx->putPixelOnDisplay(x * 4 + 0, y, color1);
 			_gfx->putPixelOnDisplay(x * 4 + 1, y, color2);
@@ -990,12 +955,10 @@ bool MickeyEngine::loadGame() {
 	Common::InSaveFile *infile;
 	char szFile[256] = {0};
 	bool diskerror = true;
-	int sel;
-	int saveVersion = 0;
 	int i = 0;
 
 	while (diskerror) {
-		sel = choose1to9(IDO_MSA_LOAD_GAME[1]);
+		int sel = choose1to9(IDO_MSA_LOAD_GAME[1]);
 		if (!sel)
 			return false;
 
@@ -1009,12 +972,14 @@ bool MickeyEngine::loadGame() {
 		} else {
 			if (infile->readUint32BE() != MKTAG('M', 'I', 'C', 'K')) {
 				warning("MickeyEngine::loadGame wrong save game format");
+				delete infile;
 				return false;
 			}
 
-			saveVersion = infile->readByte();
+			byte saveVersion = infile->readByte();
 			if (saveVersion != MSA_SAVEGAME_VERSION) { // currently only one valid version
 				warning("MickeyEngine::loadGame unknown save version: %d", saveVersion);
+				delete infile;
 				return false;
 			}
 
@@ -1087,7 +1052,6 @@ void MickeyEngine::saveGame() {
 	Common::OutSaveFile *outfile;
 	char szFile[256] = {0};
 	bool diskerror = true;
-	int sel;
 	int i = 0;
 
 	bool fOldDisk = chooseY_N(IDO_MSA_SAVE_GAME[0], false);
@@ -1101,7 +1065,7 @@ void MickeyEngine::saveGame() {
 		return;
 
 	while (diskerror) {
-		sel = choose1to9(IDO_MSA_SAVE_GAME[3]);
+		int sel = choose1to9(IDO_MSA_SAVE_GAME[3]);
 		if (!sel)
 			return;
 
@@ -1202,13 +1166,12 @@ void MickeyEngine::showPlanetInfo() {
 void MickeyEngine::printStory() {
 	char buffer[IDI_MSA_LEN_STORY] = {0};
 	char szLine[41] = {0};
-	int iRow;
 	int pBuf = 0;
 
 	readExe(IDO_MSA_GAME_STORY, (uint8 *)buffer, sizeof(buffer));
 
 	clearScreen(IDA_DEFAULT);
-	for (iRow = 0; iRow < 25; iRow++) {
+	for (int iRow = 0; iRow < 25; iRow++) {
 		Common::strlcpy(szLine, buffer + pBuf, 41);
 		drawStr(iRow, 0, IDA_DEFAULT, szLine);
 		pBuf += strlen(szLine) + 1;
@@ -1216,7 +1179,7 @@ void MickeyEngine::printStory() {
 	waitAnyKey();
 
 	clearScreen(IDA_DEFAULT);
-	for (iRow = 0; iRow < 21; iRow++) {
+	for (int iRow = 0; iRow < 21; iRow++) {
 		Common::strlcpy(szLine, buffer + pBuf, 41);
 		drawStr(iRow, 0, IDA_DEFAULT, szLine);
 		pBuf += strlen(szLine) + 1;
diff --git a/engines/agi/preagi/winnie.cpp b/engines/agi/preagi/winnie.cpp
index 2ce3dcaf30b..0019a074b85 100644
--- a/engines/agi/preagi/winnie.cpp
+++ b/engines/agi/preagi/winnie.cpp
@@ -1209,7 +1209,6 @@ void WinnieEngine::drawPic(const char *szName) {
 
 	_picture->setOffset(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->setOffset(0, 0);
 	_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	free(buffer);
@@ -1226,7 +1225,6 @@ void WinnieEngine::drawObjPic(int iObj, int x0, int y0) {
 
 	_picture->setOffset(x0, y0);
 	_picture->decodePictureFromBuffer(buffer + objhdr.ofsPic - _objOffset, objSize, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->setOffset(0, 0);
 	_picture->showPic(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	free(buffer);
@@ -1246,7 +1244,6 @@ void WinnieEngine::drawRoomPic() {
 	// draw room picture
 	_picture->setOffset(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer + roomhdr.ofsPic - _roomOffset, 4096, true, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->setOffset(0, 0);
 	_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	// draw object picture


Commit: 8fdd360ae0f02151a479e15231b1869d624dfa3f
    https://github.com/scummvm/scummvm/commit/8fdd360ae0f02151a479e15231b1869d624dfa3f
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: Remove PictureMgr::setPattern(), used by MICKEY

This was a custom interface that was only used by Mickey's spaceship
lights, but it had no effect on the outcome.

MickeyEngine called setPattern() to initialize the pattern code and
pattern number before drawing each spaceship light picture from memory.
But the pattern code can also be initialized with pic opcode F9, and
that's what MickeyEngine's hard-coded picture data already starts with.

For the pattern number, MickeyEngine only initialized it to zero,
and that's already the default when using the normal interfaces.

Changed paths:
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi/mickey.cpp


diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 7d17cc3aea7..e7f42c7fef5 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -293,8 +293,6 @@ void PictureMgr::plotPattern(int x, int y) {
 
 		pen_x = pen_final_x;
 	}
-
-	return;
 }
 
 /**************************************************************************
@@ -995,12 +993,6 @@ void PictureMgr::showPicWithTransition() {
 	_gfx->render_Block(0, 0, SCRIPT_WIDTH, SCRIPT_HEIGHT);
 }
 
-// preagi needed functions (for plotPattern)
-void PictureMgr::setPattern(uint8 code, uint8 num) {
-	_patCode = code;
-	_patNum = num;
-}
-
 void PictureMgr::setPictureVersion(AgiPictureVersion version) {
 	_pictureVersion = version;
 
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 55be9bbe583..02ea5e3291c 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -74,6 +74,7 @@ public:
 private:
 	void xCorner(bool skipOtherCoords = false);
 	void yCorner(bool skipOtherCoords = false);
+	void plotPattern(int x, int y);
 	void plotBrush();
 
 	byte getNextByte();
@@ -112,10 +113,6 @@ public:
 	void showPic(int16 x, int16 y, int16 pic_width, int16 pic_height); // <-- for preAGI games
 	void showPicWithTransition();
 
-	void plotPattern(int x, int y);     // public because it's used directly by preagi
-
-	void setPattern(uint8 code, uint8 num);
-
 	void setPictureVersion(AgiPictureVersion version);
 	void setPictureData(uint8 *data, int len = 4096);
 
diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 03453f1ac38..804739c29a0 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -754,10 +754,6 @@ void MickeyEngine::drawPic(int iPic) {
 }
 
 void MickeyEngine::drawRoomAnimation() {
-	uint8 objLight[] = {
-		0xF0, 1, 0xF9, 2, 43, 45, 0xFF
-	};
-
 	switch (_gameStateMickey.iRoom) {
 	case IDI_MSA_PIC_EARTH_SHIP:
 	case IDI_MSA_PIC_VENUS_SHIP:
@@ -777,22 +773,27 @@ void MickeyEngine::drawRoomAnimation() {
 	case IDI_MSA_PIC_SHIP_MARS:
 	case IDI_MSA_PIC_SHIP_URANUS: {
 		// draw blinking ship lights
-
-		_picture->setPattern(2, 0);
+		uint8 lightPicture[] = {
+			0xF0, 1,          // Set Color: 1
+			0xF9, 2, 43, 45,  // Set Pattern: 2, plot at 43,45
+			0xFF              // End
+		};
 
 		for (int i = 0; i < 12; i++) {
 			uint8 iColor = _gameStateMickey.nFrame + i;
 			if (iColor > 15)
 				iColor -= 15;
 
-			objLight[1] = iColor;
-			objLight[4] += 7;
+			// FIXME: this is not the correct animation pattern.
+			// the lights do not simply advance in a sequence from
+			// left to right in the original, they do something else.
+			lightPicture[1] = iColor; // change light color
+			lightPicture[4] += 7;     // increase x coordinate
 
-			_picture->setPictureData(objLight);
 			_picture->setPictureFlags(kPicFCircle);
 			_picture->setMaxStep(0);
 			_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
-			_picture->drawPicture();
+			_picture->decodePictureFromBuffer(lightPicture, sizeof(lightPicture), false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 		}
 		_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 


Commit: e134785c5012fc207694c79967de88328dda31af
    https://github.com/scummvm/scummvm/commit/e134785c5012fc207694c79967de88328dda31af
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: Remove PictureMgr::setPictureData(), used by TROLL

All preagi games now use PictureMgr::decodePictureFromBuffer()

- Removes PictureMgr::setPictureData()
- Removes PictureMgr::setDimensions()
- PictureMgr::drawPicture() is no longer public
- Troll now uses correct dimensions when showing pictures

Changed paths:
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi/troll.cpp


diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index e7f42c7fef5..05bb6d367a1 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -1002,12 +1002,4 @@ void PictureMgr::setPictureVersion(AgiPictureVersion version) {
 		_minCommand = 0xf0;
 }
 
-void PictureMgr::setPictureData(uint8 *data, int len) {
-	_data = data;
-	_dataSize = len;
-	_dataOffset = 0;
-	_dataOffsetNibble = false;
-	_flags = 0;
-}
-
 } // End of namespace Agi
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 02ea5e3291c..e82eba66a86 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -87,8 +87,9 @@ public:
 	void decodePicture(int16 resourceNr, bool clearScreen, bool agi256 = false, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
 	void decodePictureFromBuffer(byte *data, uint32 length, bool clearScreen, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
 	void unloadPicture(int picNr);
-	void drawPicture();
+
 private:
+	void drawPicture();
 	void drawPictureC64();
 	void drawPictureV1();
 	void drawPictureV15();
@@ -114,7 +115,6 @@ public:
 	void showPicWithTransition();
 
 	void setPictureVersion(AgiPictureVersion version);
-	void setPictureData(uint8 *data, int len = 4096);
 
 	void setPictureFlags(int flags) { _flags = flags; }
 
@@ -125,11 +125,6 @@ public:
 		_yOffset = offY;
 	}
 
-	void setDimensions(int w, int h) {
-		_width = w;
-		_height = h;
-	}
-
 	void setMaxStep(int maxStep) { _maxStep = maxStep; }
 	int getMaxStep() const { return _maxStep; }
 
diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index c41835935cf..29100d4eae4 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -129,32 +129,27 @@ bool TrollEngine::getMenuSel(const char *szMenu, int *iSel, int nSel) {
 // Graphics
 
 void TrollEngine::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
-	_picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
-
 	if (clr) {
 		clearScreen(0x0f, false);
-		_picture->clear();
 	}
 
-	_picture->setPictureData(_gameData + IDO_TRO_FRAMEPIC);
-	_picture->drawPicture();
-
-	_picture->setPictureData(_gameData + _pictureOffsets[iPic]);
-
-	int addFlag = 0;
-
-	if (troll)
-		addFlag = kPicFTrollMode;
+	// draw the frame picture
+	_picture->decodePictureFromBuffer(_gameData + IDO_TRO_FRAMEPIC, 4096, clr, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 
+	// draw the picture
+	int flags = 0;
 	if (f3IsCont) {
-		_picture->setPictureFlags(kPicFf3Cont | addFlag);
+		flags |= kPicFf3Cont;
 	} else {
-		_picture->setPictureFlags(kPicFf3Stop | addFlag);
+		flags |= kPicFf3Stop;
 	}
+	if (troll) {
+		flags |= kPicFTrollMode;
+	}
+	_picture->setPictureFlags(flags);
+	_picture->decodePictureFromBuffer(_gameData + _pictureOffsets[iPic], 4096, false, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 
-	_picture->drawPicture();
-
-	_picture->showPic(); // TODO: *HAVE* to add coordinates + height/width!!
+	_picture->showPic(0, 0, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 	_system->updateScreen();
 }
 
@@ -426,7 +421,6 @@ int TrollEngine::drawRoom(char *menu) {
 	bool contFlag = false;
 
 	if (_currentRoom == 1) {
-		_picture->setDimensions(IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 		clearScreen(0x00, false);
 		_picture->clear();
 	} else {


Commit: c47bbe34272d4ef1f087d392eb1b00f86de1a338
    https://github.com/scummvm/scummvm/commit/c47bbe34272d4ef1f087d392eb1b00f86de1a338
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:00-08:00

Commit Message:
AGI: Remove AgiPictureVersion::AGIPIC_256

Unreachable code; this is not how AGI256 pics are drawn

Changed paths:
    engines/agi/picture.cpp
    engines/agi/picture.h


diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index 05bb6d367a1..f488120622c 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -339,9 +339,6 @@ void PictureMgr::drawPicture() {
 	case AGIPIC_V2:
 		drawPictureV2();
 		break;
-	case AGIPIC_256:
-		drawPictureAGI256();
-		break;
 	default:
 		break;
 	}
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index e82eba66a86..cd7ecbc721c 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -47,8 +47,7 @@ enum AgiPictureVersion {
 	AGIPIC_C64,
 	AGIPIC_V1,
 	AGIPIC_V15,
-	AGIPIC_V2,
-	AGIPIC_256
+	AGIPIC_V2
 };
 
 enum AgiPictureFlags {


Commit: 04471e0dff7daa3674172a02aa36f722821577bc
    https://github.com/scummvm/scummvm/commit/04471e0dff7daa3674172a02aa36f722821577bc
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:01-08:00

Commit Message:
AGI: Remove AgiPictureFlags::kPicFf3Cont

It's unused, because it's the opposite of kPicFf3Stop

Changed paths:
    engines/agi/picture.h
    engines/agi/preagi/troll.cpp


diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index cd7ecbc721c..fd1f0bd6771 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -54,8 +54,7 @@ enum AgiPictureFlags {
 	kPicFNone      = (1 << 0),
 	kPicFCircle    = (1 << 1),
 	kPicFf3Stop    = (1 << 2),
-	kPicFf3Cont    = (1 << 3),
-	kPicFTrollMode = (1 << 4)
+	kPicFTrollMode = (1 << 3)
 };
 
 class AgiBase;
diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index 29100d4eae4..35a05ce84ca 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -138,9 +138,8 @@ void TrollEngine::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
 
 	// draw the picture
 	int flags = 0;
-	if (f3IsCont) {
-		flags |= kPicFf3Cont;
-	} else {
+	if (!f3IsCont) {
+		// stop on opcode F3
 		flags |= kPicFf3Stop;
 	}
 	if (troll) {


Commit: ecfe4dd4de63c494b9e6800611c48ebce63c890a
    https://github.com/scummvm/scummvm/commit/ecfe4dd4de63c494b9e6800611c48ebce63c890a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:01-08:00

Commit Message:
AGI: Move PictureMgr::unloadPicture() to AgiEngine

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/picture.cpp
    engines/agi/picture.h


diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 552193a69d1..e902a2b1b64 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -305,7 +305,7 @@ void AgiEngine::unloadResource(int16 resourceType, int16 resourceNr) {
 		unloadLogic(resourceNr);
 		break;
 	case RESOURCETYPE_PICTURE:
-		_picture->unloadPicture(resourceNr);
+		unloadPicture(resourceNr);
 		break;
 	case RESOURCETYPE_VIEW:
 		unloadView(resourceNr);
@@ -318,6 +318,14 @@ void AgiEngine::unloadResource(int16 resourceType, int16 resourceNr) {
 	}
 }
 
+void AgiEngine::unloadPicture(int16 picNr) {
+	if (_game.dirPic[picNr].flags & RES_LOADED) {
+		free(_game.pictures[picNr].rdata);
+		_game.pictures[picNr].rdata = nullptr;
+		_game.dirPic[picNr].flags &= ~RES_LOADED;
+	}
+}
+
 struct GameSettings {
 	const char *gameid;
 	const char *description;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index b8d18521251..42bb3d6bf25 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -991,6 +991,10 @@ public:
 	bool testController(uint8 cont);
 	bool testCompareStrings(uint8 s1, uint8 s2);
 
+	// Picture
+private:
+	void unloadPicture(int16 picNr);
+
 	// View
 private:
 	void updateView(ScreenObjEntry *screenObj);
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index f488120622c..c4af4ddc218 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -913,21 +913,6 @@ void PictureMgr::decodePictureFromBuffer(byte *data, uint32 length, bool clearSc
 	drawPicture(); // Draw 16 color picture.
 }
 
-/**
- * Unload an AGI picture resource.
- * This function unloads an AGI picture resource and deallocates
- * resource data.
- * @param picNr AGI picture resource number
- */
-void PictureMgr::unloadPicture(int picNr) {
-	// remove visual buffer & priority buffer if they exist
-	if (_vm->_game.dirPic[picNr].flags & RES_LOADED) {
-		free(_vm->_game.pictures[picNr].rdata);
-		_vm->_game.pictures[picNr].rdata = nullptr;
-		_vm->_game.dirPic[picNr].flags &= ~RES_LOADED;
-	}
-}
-
 void PictureMgr::clear() {
 	_gfx->clear(15, 4); // Clear 16 color AGI screen (Priority 4, color white).
 }
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index fd1f0bd6771..7fb74d0894d 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -84,7 +84,6 @@ public:
 
 	void decodePicture(int16 resourceNr, bool clearScreen, bool agi256 = false, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
 	void decodePictureFromBuffer(byte *data, uint32 length, bool clearScreen, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
-	void unloadPicture(int picNr);
 
 private:
 	void drawPicture();


Commit: b3fe3a72888779dc05ab39898f4a5b0c929ab67d
    https://github.com/scummvm/scummvm/commit/b3fe3a72888779dc05ab39898f4a5b0c929ab67d
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:01-08:00

Commit Message:
AGI: Remove PictureMgr::clear(), used by TROLL

Had no effect

Changed paths:
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi/troll.cpp


diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index c4af4ddc218..b920a434f13 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -907,16 +907,12 @@ void PictureMgr::decodePictureFromBuffer(byte *data, uint32 length, bool clearSc
 	_height = height;
 
 	if (clearScreen) {
-		clear();
+		_gfx->clear(15, 4); // Clear 16 color AGI screen (Priority 4, color white).
 	}
 
 	drawPicture(); // Draw 16 color picture.
 }
 
-void PictureMgr::clear() {
-	_gfx->clear(15, 4); // Clear 16 color AGI screen (Priority 4, color white).
-}
-
 void PictureMgr::showPic() {
 	debugC(8, kDebugLevelMain, "Show picture!");
 
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 7fb74d0894d..6fe59da7378 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -115,8 +115,6 @@ public:
 
 	void setPictureFlags(int flags) { _flags = flags; }
 
-	void clear();
-
 	void setOffset(int offX, int offY) {
 		_xOffset = offX;
 		_yOffset = offY;
diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index 35a05ce84ca..bb225e22d7d 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -134,6 +134,7 @@ void TrollEngine::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
 	}
 
 	// draw the frame picture
+	_picture->setPictureFlags(kPicFNone);
 	_picture->decodePictureFromBuffer(_gameData + IDO_TRO_FRAMEPIC, 4096, clr, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 
 	// draw the picture
@@ -421,7 +422,6 @@ int TrollEngine::drawRoom(char *menu) {
 
 	if (_currentRoom == 1) {
 		clearScreen(0x00, false);
-		_picture->clear();
 	} else {
 
 		if (_currentRoom != 42) {


Commit: c6c2924258c18f32b245dd395322577a0444178e
    https://github.com/scummvm/scummvm/commit/c6c2924258c18f32b245dd395322577a0444178e
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-12-13T09:31:01-08:00

Commit Message:
AGI: Cleanup PictureMgr

Changed paths:
    engines/agi/agi.cpp
    engines/agi/op_cmd.cpp
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi/mickey.cpp
    engines/agi/preagi/troll.cpp
    engines/agi/preagi/winnie.cpp
    engines/agi/saveload.cpp


diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index e902a2b1b64..17cc4ccbdc9 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -544,7 +544,7 @@ void AgiEngine::redrawScreen() {
 	_gfx->setPalette(true); // set graphics mode palette
 	_text->charAttrib_Set(_text->_textAttrib.foreground, _text->_textAttrib.background);
 	_gfx->clearDisplay(0);
-	_picture->showPic();
+	_picture->showPicture();
 	_text->statusDraw();
 	_text->promptRedraw();
 }
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 3cd90845a93..42c73ecb410 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1185,7 +1185,7 @@ void cmdShowPic(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 
 	vm->setFlag(VM_FLAG_OUTPUT_MODE, false);
 	vm->_text->closeWindow();
-	vm->_picture->showPicWithTransition();
+	vm->_picture->showPictureWithTransition();
 	state->pictureShown = true;
 
 	debugC(6, kDebugLevelScripts, "--- end of show pic ---");
@@ -2310,6 +2310,8 @@ void cmdAgi256LoadPic(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
 	vm->loadResource(RESOURCETYPE_PICTURE, resourceNr);
 
 	// Draw the picture. Similar to void cmdDrawPic.
+	// Must not clear the screen; AGI256 uses the priority
+	// screen from the previously drawn picture.
 	vm->_picture->decodePicture(resourceNr, false, true);
 	spritesMgr->drawAllSpriteLists();
 	state->pictureShown = false;
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp
index b920a434f13..1cfcce9109c 100644
--- a/engines/agi/picture.cpp
+++ b/engines/agi/picture.cpp
@@ -56,14 +56,13 @@ PictureMgr::PictureMgr(AgiBase *agi, GfxMgr *gfx) {
 }
 
 void PictureMgr::putVirtPixel(int x, int y) {
-	byte drawMask = 0;
-
 	if (x < 0 || y < 0 || x >= _width || y >= _height)
 		return;
 
 	x += _xOffset;
 	y += _yOffset;
 
+	byte drawMask;
 	if (_priOn)
 		drawMask |= GFX_SCREEN_MASK_PRIORITY;
 	if (_scrOn)
@@ -319,6 +318,8 @@ void PictureMgr::plotBrush() {
 ** Draw AGI picture
 **************************************************************************/
 void PictureMgr::drawPicture() {
+	_dataOffset = 0;
+	_dataOffsetNibble = false;
 	_patCode = 0;
 	_patNum = 0;
 	_priOn = false;
@@ -345,9 +346,9 @@ void PictureMgr::drawPicture() {
 }
 
 void PictureMgr::drawPictureC64() {
-	debugC(8, kDebugLevelMain, "Drawing C64 picture");
+	debugC(8, kDebugLevelMain, "Drawing Apple II / C64 / CoCo picture");
 
-	_scrColor = 0x0;
+	_scrColor = 0;
 
 	while (_dataOffset < _dataSize) {
 		byte curByte = getNextByte();
@@ -476,14 +477,10 @@ void PictureMgr::drawPictureV15() {
 }
 
 void PictureMgr::drawPictureV2() {
-	bool nibbleMode = false;
-
 	debugC(8, kDebugLevelMain, "Drawing V2/V3 picture");
 
-	if (_vm->_game.dirPic[_resourceNr].flags & RES_PICTURE_V3_NIBBLE_PARM) {
-		// check, if this resource uses nibble mode (0xF0 + 0xF2 commands take nibbles instead of bytes)
-		nibbleMode = true;
-	}
+	// AGIv3 nibble parameters are indicated by a flag in the picture's directory entry
+	bool nibbleMode = (_vm->_game.dirPic[_resourceNr].flags & RES_PICTURE_V3_NIBBLE_PARM) != 0;
 
 	int step = 0;
 	while (_dataOffset < _dataSize) {
@@ -842,7 +839,7 @@ bool PictureMgr::draw_FillCheck(int16 x, int16 y) {
 }
 
 /**
- * Decode an AGI picture resource.
+ * Decode an AGI picture resource. Used by regular AGI games.
  * This function decodes an AGI picture resource into the correct slot
  * and draws it on the AGI screen, optionally clearing the screen before
  * drawing.
@@ -851,27 +848,18 @@ bool PictureMgr::draw_FillCheck(int16 x, int16 y) {
  * @param agi256 load an AGI256 picture resource
  */
 void PictureMgr::decodePicture(int16 resourceNr, bool clearScreen, bool agi256, int16 width, int16 height) {
-	_patCode = 0;
-	_patNum = 0;
-	_priOn = _scrOn = false;
-	_scrColor = 0xF;
-	_priColor = 0x4;
-
 	_resourceNr = resourceNr;
 	_data = _vm->_game.pictures[resourceNr].rdata;
 	_dataSize = _vm->_game.dirPic[resourceNr].len;
-	_dataOffset = 0;
-	_dataOffsetNibble = false;
-
 	_width = width;
 	_height = height;
 
-	if (clearScreen && !agi256) { // 256 color pictures should always fill the whole screen, so no clearing for them.
-		_gfx->clear(15, 4); // Clear 16 color AGI screen (Priority 4, color white).
+	if (clearScreen) {
+		_gfx->clear(15, 4); // white, priority 4
 	}
 
 	if (!agi256) {
-		drawPicture(); // Draw 16 color picture.
+		drawPicture();
 	} else {
 		drawPictureAGI256();
 	}
@@ -883,7 +871,7 @@ void PictureMgr::decodePicture(int16 resourceNr, bool clearScreen, bool agi256,
 }
 
 /**
- * Decode an AGI picture resource.
+ * Decode an AGI picture resource. Used by preAGI.
  * This function decodes an AGI picture resource into the correct slot
  * and draws it on the AGI screen, optionally clearing the screen before
  * drawing.
@@ -892,51 +880,29 @@ void PictureMgr::decodePicture(int16 resourceNr, bool clearScreen, bool agi256,
  * @param clear  clear AGI screen before drawing
  */
 void PictureMgr::decodePictureFromBuffer(byte *data, uint32 length, bool clearScreen, int16 width, int16 height) {
-	_patCode = 0;
-	_patNum = 0;
-	_priOn = _scrOn = false;
-	_scrColor = 0xF;
-	_priColor = 0x4;
-
 	_data = data;
 	_dataSize = length;
-	_dataOffset = 0;
-	_dataOffsetNibble = false;
-
 	_width = width;
 	_height = height;
 
 	if (clearScreen) {
-		_gfx->clear(15, 4); // Clear 16 color AGI screen (Priority 4, color white).
+		_gfx->clear(15, 4); // white, priority 4
 	}
 
-	drawPicture(); // Draw 16 color picture.
+	drawPicture();
 }
 
-void PictureMgr::showPic() {
-	debugC(8, kDebugLevelMain, "Show picture!");
+void PictureMgr::showPicture(int16 x, int16 y, int16 width, int16 height) {
+	debugC(8, kDebugLevelMain, "Show picture");
 
-	_gfx->render_Block(0, 0, SCRIPT_WIDTH, SCRIPT_HEIGHT);
+	_gfx->render_Block(x, y, width, height);
 }
 
-/**
- * Show AGI picture.
- * This function copies a ``hidden'' AGI picture to the output device.
- */
-void PictureMgr::showPic(int16 x, int16 y, int16 pic_width, int16 pic_height) {
-	_width = pic_width;
-	_height = pic_height;
-
-	debugC(8, kDebugLevelMain, "Show picture!");
-
-	_gfx->render_Block(x, y, pic_width, pic_height);
-}
-
-void PictureMgr::showPicWithTransition() {
+void PictureMgr::showPictureWithTransition() {
 	_width = SCRIPT_WIDTH;
 	_height = SCRIPT_HEIGHT;
 
-	debugC(8, kDebugLevelMain, "Show picture!");
+	debugC(8, kDebugLevelMain, "Show picture");
 
 	if (!_vm->_game.automaticRestoreGame) {
 		// only do transitions when we are not restoring a saved game
@@ -955,7 +921,6 @@ void PictureMgr::showPicWithTransition() {
 			_gfx->render_Block(0, 0, SCRIPT_WIDTH, SCRIPT_HEIGHT, false);
 			_gfx->transition_Amiga();
 			return;
-			break;
 		case Common::kRenderAtariST:
 			// Platform Atari ST used a different transition, looks "high-res" (full 320x168)
 			_gfx->render_Block(0, 0, SCRIPT_WIDTH, SCRIPT_HEIGHT, false);
diff --git a/engines/agi/picture.h b/engines/agi/picture.h
index 6fe59da7378..46f0b2f7226 100644
--- a/engines/agi/picture.h
+++ b/engines/agi/picture.h
@@ -42,19 +42,18 @@ struct AgiPicture {
 	AgiPicture() { reset(); }
 };
 
-// AGI picture version
 enum AgiPictureVersion {
-	AGIPIC_C64,
-	AGIPIC_V1,
-	AGIPIC_V15,
-	AGIPIC_V2
+	AGIPIC_C64,     // Winnie (Apple II, C64, CoCo)
+	AGIPIC_V1,      // Currently unused
+	AGIPIC_V15,     // Troll (DOS)
+	AGIPIC_V2       // AGIv2, AGIv3, Winnie (DOS, Amiga), Mickey (DOS)
 };
 
 enum AgiPictureFlags {
 	kPicFNone      = (1 << 0),
-	kPicFCircle    = (1 << 1),
-	kPicFf3Stop    = (1 << 2),
-	kPicFTrollMode = (1 << 3)
+	kPicFCircle    = (1 << 1), // Mickey, spaceship lights (not drawn accurately)
+	kPicFf3Stop    = (1 << 2), // Troll, certain pictures
+	kPicFTrollMode = (1 << 3)  // Troll, drawing the Troll
 };
 
 class AgiBase;
@@ -70,6 +69,7 @@ public:
 	int16 getResourceNr() const { return _resourceNr; };
 
 private:
+	void putVirtPixel(int x, int y);
 	void xCorner(bool skipOtherCoords = false);
 	void yCorner(bool skipOtherCoords = false);
 	void plotPattern(int x, int y);
@@ -80,8 +80,6 @@ private:
 	byte getNextNibble();
 
 public:
-	void putVirtPixel(int x, int y);
-
 	void decodePicture(int16 resourceNr, bool clearScreen, bool agi256 = false, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
 	void decodePictureFromBuffer(byte *data, uint32 length, bool clearScreen, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
 
@@ -107,9 +105,8 @@ private:
 	void draw_Fill();
 
 public:
-	void showPic(); // <-- for regular AGI games
-	void showPic(int16 x, int16 y, int16 pic_width, int16 pic_height); // <-- for preAGI games
-	void showPicWithTransition();
+	void showPicture(int16 x = 0, int16 y = 0, int16 width = _DEFAULT_WIDTH, int16 height = _DEFAULT_HEIGHT);
+	void showPictureWithTransition();
 
 	void setPictureVersion(AgiPictureVersion version);
 
diff --git a/engines/agi/preagi/mickey.cpp b/engines/agi/preagi/mickey.cpp
index 804739c29a0..edd64aead8b 100644
--- a/engines/agi/preagi/mickey.cpp
+++ b/engines/agi/preagi/mickey.cpp
@@ -730,7 +730,7 @@ void MickeyEngine::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) {
 	_picture->setMaxStep(maxStep);
 	_picture->setOffset(IDI_MSA_PIC_X0 + x0, IDI_MSA_PIC_Y0 + y0);
 	_picture->decodePictureFromBuffer(buffer, size, false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
-	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+	_picture->showPicture(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
 void MickeyEngine::drawPic(int iPic) {
@@ -750,7 +750,7 @@ void MickeyEngine::drawPic(int iPic) {
 	_picture->setMaxStep(0);
 	_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
-	_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+	_picture->showPicture(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 }
 
 void MickeyEngine::drawRoomAnimation() {
@@ -795,7 +795,7 @@ void MickeyEngine::drawRoomAnimation() {
 			_picture->setOffset(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0);
 			_picture->decodePictureFromBuffer(lightPicture, sizeof(lightPicture), false, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 		}
-		_picture->showPic(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
+		_picture->showPicture(IDI_MSA_PIC_X0, IDI_MSA_PIC_Y0, IDI_MSA_PIC_WIDTH, IDI_MSA_PIC_HEIGHT);
 
 		_gameStateMickey.nFrame--;
 		if (_gameStateMickey.nFrame < 0)
diff --git a/engines/agi/preagi/troll.cpp b/engines/agi/preagi/troll.cpp
index bb225e22d7d..35d760e8bcc 100644
--- a/engines/agi/preagi/troll.cpp
+++ b/engines/agi/preagi/troll.cpp
@@ -149,7 +149,7 @@ void TrollEngine::drawPic(int iPic, bool f3IsCont, bool clr, bool troll) {
 	_picture->setPictureFlags(flags);
 	_picture->decodePictureFromBuffer(_gameData + _pictureOffsets[iPic], 4096, false, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 
-	_picture->showPic(0, 0, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
+	_picture->showPicture(0, 0, IDI_TRO_PIC_WIDTH, IDI_TRO_PIC_HEIGHT);
 	_system->updateScreen();
 }
 
diff --git a/engines/agi/preagi/winnie.cpp b/engines/agi/preagi/winnie.cpp
index 0019a074b85..7c92bf58a47 100644
--- a/engines/agi/preagi/winnie.cpp
+++ b/engines/agi/preagi/winnie.cpp
@@ -1209,7 +1209,7 @@ void WinnieEngine::drawPic(const char *szName) {
 
 	_picture->setOffset(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer, size, true, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_picture->showPicture(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	free(buffer);
 }
@@ -1225,7 +1225,7 @@ void WinnieEngine::drawObjPic(int iObj, int x0, int y0) {
 
 	_picture->setOffset(x0, y0);
 	_picture->decodePictureFromBuffer(buffer + objhdr.ofsPic - _objOffset, objSize, false, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->showPic(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_picture->showPicture(10, 0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	free(buffer);
 }
@@ -1244,7 +1244,7 @@ void WinnieEngine::drawRoomPic() {
 	// draw room picture
 	_picture->setOffset(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0);
 	_picture->decodePictureFromBuffer(buffer + roomhdr.ofsPic - _roomOffset, 4096, true, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
-	_picture->showPic(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
+	_picture->showPicture(IDI_WTP_PIC_X0, IDI_WTP_PIC_Y0, IDI_WTP_PIC_WIDTH, IDI_WTP_PIC_HEIGHT);
 
 	// draw object picture
 	drawObjPic(iObj, IDI_WTP_PIC_X0 + roomhdr.objX, IDI_WTP_PIC_Y0 + roomhdr.objY);
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 2d776256956..4c960c3b8fa 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -744,7 +744,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
 	_sprites->eraseSprites();
 	_sprites->buildAllSpriteLists();
 	_sprites->drawAllSpriteLists();
-	_picture->showPicWithTransition();
+	_picture->showPictureWithTransition();
 	_game.pictureShown = true;
 	_text->statusDraw();
 	_text->promptRedraw();




More information about the Scummvm-git-logs mailing list