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

sdelamarre noreply at scummvm.org
Sun Feb 22 15:38:37 UTC 2026


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

Summary:
cc4c2b0b40 GOB: Add printing support for Playtoons


Commit: cc4c2b0b40d98315a1e4a2b55f0d081b8c5de101
    https://github.com/scummvm/scummvm/commit/cc4c2b0b40d98315a1e4a2b55f0d081b8c5de101
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-02-22T16:25:06+01:00

Commit Message:
GOB: Add printing support for Playtoons

Move the o7_writeData() opcode from Adibou2/Adi4 classes to the Playtoons
base class.

Changed paths:
    engines/gob/inter.h
    engines/gob/inter_playtoons.cpp
    engines/gob/inter_v7.cpp


diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index ffd7479fe66..715075161a3 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -681,6 +681,7 @@ protected:
 	void oPlaytoons_freeSprite(OpFuncParams &params);
 	void oPlaytoons_checkData(OpFuncParams &params);
 	void oPlaytoons_readData(OpFuncParams &params);
+	void oPlaytoons_writeData(OpFuncParams &params);
 
 	void oPlaytoons_loadMultObject();
 	void oPlaytoons_getObjAnimSize();
@@ -786,7 +787,6 @@ protected:
 	void o7_invalidate(OpFuncParams &params);
 	void o7_checkData(OpFuncParams &params);
 	void o7_readData(OpFuncParams &params);
-	void o7_writeData(OpFuncParams &params);
 	void o7_manageDataFile(OpFuncParams &params);
 
 	bool readAdi4InfDataForChild(Common::Array<byte> &dest, uint32 childNumber, uint32 offset, uint32 size);
diff --git a/engines/gob/inter_playtoons.cpp b/engines/gob/inter_playtoons.cpp
index 5d171017e71..ce9b76701b4 100644
--- a/engines/gob/inter_playtoons.cpp
+++ b/engines/gob/inter_playtoons.cpp
@@ -29,6 +29,7 @@
 #include "common/str.h"
 #include "common/translation.h"
 
+#include "gui/gui-manager.h"
 #include "gui/message.h"
 
 #include "gob/gob.h"
@@ -96,6 +97,7 @@ void Inter_Playtoons::setupOpcodesFunc() {
 	OPCODEFUNC(0x27, oPlaytoons_freeSprite);
 	OPCODEFUNC(0x3F, oPlaytoons_checkData);
 	OPCODEFUNC(0x4D, oPlaytoons_readData);
+	OPCODEFUNC(0x4E, oPlaytoons_writeData);
 }
 
 void Inter_Playtoons::setupOpcodesGob() {
@@ -338,6 +340,86 @@ void Inter_Playtoons::oPlaytoons_readData(OpFuncParams &params) {
 	delete stream;
 }
 
+void Inter_Playtoons::oPlaytoons_writeData(OpFuncParams &params) {
+	Common::String file = getFile(_vm->_game->_script->evalString(), false);
+
+	uint16 dataVar = _vm->_game->_script->readVarIndex();
+	int32 size    = _vm->_game->_script->readValExpr();
+	int32 offset  = _vm->_game->_script->evalInt();
+
+	debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)",
+		   file.c_str(), dataVar, size, offset);
+
+	WRITE_VAR(1, 1);
+
+	if (file.compareToIgnoreCase("PRINTER") == 0) {
+		// Send a sprite to the printer.
+		int32 spriteIndex = -size - 1;
+		if (spriteIndex < 0 || spriteIndex >= Draw::kSpriteCount) {
+			warning("o7_writeData: Invalid sprite index %d for printing", spriteIndex);
+			return;
+		}
+
+		SurfacePtr sprite = _vm->_draw->_spritesArray[spriteIndex];
+		if (!sprite) {
+			warning("o7_writeData: no sprite at index %d for printing", spriteIndex);
+			return;
+		}
+
+		Graphics::ManagedSurface surf(sprite->getWidth(),
+									  sprite->getHeight(),
+									  sprite->getBPP() > 1 ? _vm->getPixelFormat()
+														   : Graphics::PixelFormat::createFormatCLUT8());
+
+		if (sprite->getBPP() > 1) {
+			// Fill the background with white color, and ensure 0 is treated as the transparent color key
+			surf.fillRect(Common::Rect(0, 0, surf.w, surf.h),
+						  surf.format.RGBToColor(255, 255, 255));
+			surf.copyRectToSurfaceWithKey(sprite->getData(),
+										  sprite->getWidth() * sprite->getBPP(),
+										  0,
+										  0,
+										  sprite->getWidth(),
+										  sprite->getHeight(),
+										  0);
+		} else {
+			byte pal[768];
+			int16 numcolors = _vm->_global->_setAllPalette ? 256 : 16;
+			for (int i = 0; i < numcolors; i++) {
+				_vm->_video->setPalColor(pal + i * 3, _vm->_global->_pPaletteDesc->vgaPal[i]);
+			}
+			surf.setPalette(pal, 0, numcolors);
+			surf.copyRectToSurface(sprite->getData(),
+								   sprite->getWidth() * sprite->getBPP(),
+								   0,
+								   0,
+								   sprite->getWidth(),
+								   sprite->getHeight());
+		}
+
+		g_gui.printImage(surf);
+		return;
+	}
+
+	if (size == 0) {
+		dataVar = 0;
+		size = _vm->_game->_script->getVariablesCount() * 4;
+	}
+
+	SaveLoad::SaveMode mode = _vm->_saveLoad ? _vm->_saveLoad->getSaveMode(file.c_str()) : SaveLoad::kSaveModeNone;
+	if (mode == SaveLoad::kSaveModeSave) {
+		if (!_vm->_saveLoad->save(file.c_str(), dataVar, size, offset)) {
+			GUI::MessageDialog dialog(_("Failed to save game to file."));
+			dialog.runModal();
+		} else
+			WRITE_VAR(1, 0);
+	} else if (mode == SaveLoad::kSaveModeIgnore)
+		return;
+	else if (mode == SaveLoad::kSaveModeNone)
+		warning("Attempted to write to file \"%s\"", file.c_str());
+}
+
+
 void Inter_Playtoons::oPlaytoons_loadMultObject() {
 	assert(_vm->_mult->_objects);
 
diff --git a/engines/gob/inter_v7.cpp b/engines/gob/inter_v7.cpp
index 9e3fe41c333..284b779090c 100644
--- a/engines/gob/inter_v7.cpp
+++ b/engines/gob/inter_v7.cpp
@@ -35,7 +35,6 @@
 #include "graphics/cursorman.h"
 #include "graphics/wincursor.h"
 
-#include "gui/gui-manager.h"
 #include "gui/message.h"
 
 #include "image/iff.h"
@@ -148,7 +147,6 @@ void Inter_v7::setupOpcodesFunc() {
 	OPCODEFUNC(0x3E, o7_getFreeMem);
 	OPCODEFUNC(0x3F, o7_checkData);
 	OPCODEFUNC(0x4D, o7_readData);
-	OPCODEFUNC(0x4E, o7_writeData);
 	OPCODEFUNC(0x4F, o7_manageDataFile);
 }
 
@@ -1946,89 +1944,6 @@ void Inter_v7::o7_readData(OpFuncParams &params) {
 	delete stream;
 }
 
-void Inter_v7::o7_writeData(OpFuncParams &params) {
-	Common::String file = getFile(_vm->_game->_script->evalString(), false);
-
-	uint16 dataVar = _vm->_game->_script->readVarIndex();
-	int32 size    = _vm->_game->_script->readValExpr();
-	int32 offset  = _vm->_game->_script->evalInt();
-
-	debugC(2, kDebugFileIO, "Write to file \"%s\" (%d, %d bytes at %d)",
-		   file.c_str(), dataVar, size, offset);
-
-	WRITE_VAR(1, 1);
-
-	if (file.compareToIgnoreCase("PRINTER") == 0) {
-		// Send a sprite to the printer.
-		int32 spriteIndex = -size - 1;
-		if (spriteIndex < 0 || spriteIndex >= Draw::kSpriteCount) {
-			warning("o7_writeData: Invalid sprite index %d for printing", spriteIndex);
-			return;
-		}
-
-		SurfacePtr sprite = _vm->_draw->_spritesArray[spriteIndex];
-		if (!sprite) {
-			warning("o7_writeData: no sprite at index %d for printing", spriteIndex);
-			return;
-		}
-
-		Graphics::ManagedSurface surf(sprite->getWidth(),
-									  sprite->getHeight(),
-									  sprite->getBPP() > 1 ? _vm->getPixelFormat()
-														   : Graphics::PixelFormat::createFormatCLUT8());
-
-		if (sprite->getBPP() > 1) {
-			// Fill the background with white color, and ensure 0 is treated as the transparent color key
-			surf.fillRect(Common::Rect(0, 0, surf.w, surf.h),
-						  surf.format.RGBToColor(255, 255, 255));
-			surf.copyRectToSurfaceWithKey(sprite->getData(),
-										  sprite->getWidth() * sprite->getBPP(),
-										  0,
-										  0,
-										  sprite->getWidth(),
-										  sprite->getHeight(),
-										  0);
-		} else {
-			byte pal[768];
-			int16 numcolors = _vm->_global->_setAllPalette ? 256 : 16;
-			for (int i = 0; i < numcolors; i++) {
-				_vm->_video->setPalColor(pal + i * 3, _vm->_global->_pPaletteDesc->vgaPal[i]);
-			}
-			surf.setPalette(pal, 0, numcolors);
-			surf.copyRectToSurface(sprite->getData(),
-								   sprite->getWidth() * sprite->getBPP(),
-								   0,
-								   0,
-								   sprite->getWidth(),
-								   sprite->getHeight());
-		}
-
-		g_gui.printImage(surf);
-		return;
-	}
-
-	if (size == 0) {
-		dataVar = 0;
-		size = _vm->_game->_script->getVariablesCount() * 4;
-	}
-
-	SaveLoad::SaveMode mode = _vm->_saveLoad ? _vm->_saveLoad->getSaveMode(file.c_str()) : SaveLoad::kSaveModeNone;
-	if (mode == SaveLoad::kSaveModeSave) {
-
-		if (!_vm->_saveLoad->save(file.c_str(), dataVar, size, offset)) {
-
-			GUI::MessageDialog dialog(_("Failed to save game to file."));
-			dialog.runModal();
-
-		} else
-			WRITE_VAR(1, 0);
-
-	} else if (mode == SaveLoad::kSaveModeIgnore)
-		return;
-	else if (mode == SaveLoad::kSaveModeNone)
-		warning("Attempted to write to file \"%s\"", file.c_str());
-}
-
 void Inter_v7::o7_manageDataFile(OpFuncParams &params) {
 	Common::String file = _vm->_game->_script->evalString();
 




More information about the Scummvm-git-logs mailing list