[Scummvm-git-logs] scummvm master -> 0c41f4c49a3762df6d5d9d21acf4e5f034cb5a2c

neuromancer noreply at scummvm.org
Wed Sep 11 19:23:14 UTC 2024


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:
df47092a7c FREESCAPE: parse and render riddle background in castle ega dos
1cceb9c018 FREESCAPE: parse header and bitmaps from castle ega dos
0c41f4c49a FREESCAPE: refactor code to parse header and bitmaps from castle ega dos


Commit: df47092a7c0bee2bf9e87af7b6353985b5a5b41b
    https://github.com/scummvm/scummvm/commit/df47092a7c0bee2bf9e87af7b6353985b5a5b41b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-09-11T21:24:15+02:00

Commit Message:
FREESCAPE: parse and render riddle background in castle ega dos

Changed paths:
  R devtools/create_freescape/castle_menu_ega.bmp
  R devtools/create_freescape/castle_strength_background_ega.bmp
    dists/engine-data/freescape.dat
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/castle.h
    engines/freescape/games/castle/dos.cpp


diff --git a/devtools/create_freescape/castle_menu_ega.bmp b/devtools/create_freescape/castle_menu_ega.bmp
deleted file mode 100644
index 7ae5f0b4de8..00000000000
Binary files a/devtools/create_freescape/castle_menu_ega.bmp and /dev/null differ
diff --git a/devtools/create_freescape/castle_strength_background_ega.bmp b/devtools/create_freescape/castle_strength_background_ega.bmp
deleted file mode 100644
index 13a590d3522..00000000000
Binary files a/devtools/create_freescape/castle_strength_background_ega.bmp and /dev/null differ
diff --git a/dists/engine-data/freescape.dat b/dists/engine-data/freescape.dat
index 5312702e978..4eceb1f18cc 100644
Binary files a/dists/engine-data/freescape.dat and b/dists/engine-data/freescape.dat differ
diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 3cc50acb21d..5805e80e9cb 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -446,6 +446,12 @@ void CastleEngine::executeRedraw(FCLInstruction &instruction) {
 void CastleEngine::loadAssets() {
 	FreescapeEngine::loadAssets();
 	if (isDOS()) {
+
+		/*Graphics::Surface *surface = loadBundledImage("castle_riddle_background");
+		surface->convertToInPlace(_gfx->_texturePixelFormat);
+		_riddleBackgroundFrame = new Graphics::ManagedSurface();
+		_riddleBackgroundFrame->copyFrom(surface);*/
+
 		for (auto &it : _areaMap) {
 			it._value->addStructure(_areaMap[255]);
 			it._value->addObjectFromArea(229, _areaMap[255]);
@@ -602,34 +608,20 @@ void CastleEngine::drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics
 	for (int i = 6 * riddle; i < 6 * (riddle + 1); i++) {
 		riddleMessages.push_back(_riddleList[i]);
 	}
-
-	uint32 noColor = _gfx->_texturePixelFormat.ARGBToColor(0x00, 0x00, 0x00, 0x00);
-	uint32 black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
-	uint32 grey = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x60, 0x60, 0x60);
-	uint32 frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xA7, 0xA7, 0xA7);
-
-	Common::Rect outerFrame(47, 47, 271, 147);
-	Common::Rect innerFrame(53, 53, 266, 141);
-
+	uint32 frameColor = 0;
 	if (isDOS()) {
-		black = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x00, 0x00, 0x00);
-		grey = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0x60, 0x60, 0x60);
-		frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xA7, 0xA7, 0xA7);
+		int w = 34;
+		surface->copyRectToSurface((const Graphics::Surface)*_riddleTopFrame, 40, w, Common::Rect(0, 0, _riddleTopFrame->w, _riddleTopFrame->h));
+		for (w += _riddleTopFrame->h; w < 136;) {
+			surface->copyRectToSurface((const Graphics::Surface)*_riddleBackgroundFrame, 40, w, Common::Rect(0, 0, _riddleBackgroundFrame->w, _riddleBackgroundFrame->h));
+			w += _riddleBackgroundFrame->h;
+		}
+		surface->copyRectToSurface((const Graphics::Surface)*_riddleBottomFrame, 40, 136, Common::Rect(0, 0, _riddleBottomFrame->w, _riddleBottomFrame->h - 1));
 	} else {
-		outerFrame = Common::Rect(67, 47, 251, 143 - 5);
-		innerFrame = Common::Rect(70, 49, 249, 141 - 5);
-		grey = noColor;
-		frame = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xD8, 0xD8, 0xD8);
+		frameColor = _gfx->_texturePixelFormat.ARGBToColor(0xFF, 0xD8, 0xD8, 0xD8);
+		surface->fillRect(_viewArea, frameColor);
 	}
 
-	surface->fillRect(_fullscreenViewArea, noColor);
-	surface->fillRect(_viewArea, black);
-
-	surface->fillRect(outerFrame, grey);
-	surface->frameRect(outerFrame, frame);
-	surface->frameRect(innerFrame, frame);
-
-	surface->fillRect(Common::Rect(54, 54, 265, 140), back);
 	int x = 0;
 	int y = 0;
 	int numberOfLines = 6;
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 135e42eb498..ac797d9b030 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -94,6 +94,11 @@ public:
 	Common::Array<Graphics::ManagedSurface *> _strenghtWeightsFrames;
 	Graphics::ManagedSurface *_flagFrames[4];
 	Graphics::ManagedSurface *_thunderFrame;
+	Graphics::ManagedSurface *_riddleTopFrame;
+	Graphics::ManagedSurface *_riddleBackgroundFrame;
+	Graphics::ManagedSurface *_riddleBottomFrame;
+
+	Graphics::ManagedSurface *_endOfGameThroneFrame;
 
 	int _numberKeys;
 	bool _useRockTravel;
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index 7672fb727d0..c01879a67fe 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -186,21 +186,29 @@ void CastleEngine::loadAssetsDOSFullGame() {
 			_flagFrames[3]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&flagPalette, 4);
 
 			//debug("%lx", stream->pos());
-			//stream->seek(0x25a90);
-			// This has only two planes?
-			//_riddleTopFrames[0] = loadFrameFromPlanes(stream, 30, ??, lightGreen, transparent, darkGreen, transparent);
-			//_riddleBottomFrames[0] = loadFrameFromPlanes(stream, 30, ??, lightGreen, transparent, darkGreen, transparent);*/
-
-			/*stream->seek(0x25a94 + 0xe00);
-			byte *grayPalette = (byte *)malloc(16 * 3);
-			for (int i = 0; i < 16; i++) { // gray scale palette
-				grayPalette[i * 3 + 0] = i * (255 / 16);
-				grayPalette[i * 3 + 1] = i * (255 / 16);
-				grayPalette[i * 3 + 2] = i * (255 / 16);
-			}
+			stream->seek(0x25a90);
+			_riddleTopFrame = loadFrameFromPlanes(stream, 120, 20);
+			_riddleTopFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+
+			_riddleBackgroundFrame = loadFrameFromPlanes(stream, 120, 1);
+			_riddleBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
+			//loadFrameFromPlanes(stream, 60, 8);
+			//debug("%lx", stream->pos());
+
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+
+			_riddleBottomFrame = loadFrameFromPlanes(stream, 120, 8);
+			_riddleBottomFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
 
-			_something = loadFrameFromPlanes(stream, 36, 82);
-			_something->convertToInPlace(_gfx->_texturePixelFormat, grayPalette, 16);*/
+			stream->seek(0x25a94 + 0xe00);
+			_endOfGameThroneFrame = loadFrameFromPlanes(stream, 36, 82);
+			_endOfGameThroneFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 		}
 
 		delete stream;


Commit: 1cceb9c01882e0f3dff947c0a0c65a5b95999bcd
    https://github.com/scummvm/scummvm/commit/1cceb9c01882e0f3dff947c0a0c65a5b95999bcd
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-09-11T21:24:15+02:00

Commit Message:
FREESCAPE: parse header and bitmaps from castle ega dos

Changed paths:
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/castle.h
    engines/freescape/games/castle/dos.cpp


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 5805e80e9cb..48ffd8f05e6 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -665,10 +665,13 @@ void CastleEngine::drawEnergyMeter(Graphics::Surface *surface) {
 	Common::Point origin;
 
 	if (isDOS())
-		origin = Common::Point(40, 160);
+		origin = Common::Point(39, 157);
 	if (isSpectrum())
 		origin = Common::Point(63, 154);
 
+	if (!_strenghtBackgroundFrame)
+		return;
+
 
 	surface->copyRectToSurface((const Graphics::Surface)*_strenghtBackgroundFrame, origin.x, origin.y, Common::Rect(0, 0, _strenghtBackgroundFrame->w, _strenghtBackgroundFrame->h));
 	if (!_strenghtBarFrame)
@@ -684,6 +687,9 @@ void CastleEngine::drawEnergyMeter(Graphics::Surface *surface) {
 	frameIdx++;
 	frameIdx = frameIdx % 4;
 
+	if (_strenghtWeightsFrames.empty())
+		return;
+
 	surface->copyRectToSurface((const Graphics::Surface)*_strenghtWeightsFrames[frameIdx], weightPoint.x, weightPoint.y, Common::Rect(0, 0, 3, _strenghtWeightsFrames[frameIdx]->h));
 	weightPoint += Common::Point(3, 0);
 
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index ac797d9b030..7352d46ec9f 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -77,6 +77,8 @@ public:
 
 	void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
 	//void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
+	Graphics::ManagedSurface *loadFrameWithHeaderDOS(Common::SeekableReadStream *file);
+
 	Common::Array<Graphics::ManagedSurface *> loadFramesWithHeader(Common::SeekableReadStream *file, int pos, int numFrames, uint32 front, uint32 back);
 	Graphics::ManagedSurface *loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back);
 	Graphics::ManagedSurface *loadFrame(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height, uint32 back);
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index c01879a67fe..e4e9aef2f1a 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -119,6 +119,23 @@ Graphics::ManagedSurface *CastleEngine::loadFrameFromPlanesInternal(Common::Seek
 	return surface;
 }
 
+Graphics::ManagedSurface *CastleEngine::loadFrameWithHeaderDOS(Common::SeekableReadStream *file) {
+	uint8 header1 = file->readByte();
+	uint8 header2 = file->readByte();
+	int height = file->readByte();
+	uint8 mask = file->readByte();
+	int size = file->readUint16LE();
+
+	assert(size % height == 0);
+	int widthBytes = (size / height);
+
+	Graphics::ManagedSurface *frame = loadFrameFromPlanes(file, widthBytes, height);
+	frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
+	debug("header: %x %x, height: %d, mask: %x, widthBytes: %d, size: %d", header1, header2, height, mask, widthBytes, size);
+	return frame;
+}
+
 void CastleEngine::loadAssetsDOSFullGame() {
 	Common::File file;
 	Common::SeekableReadStream *stream = nullptr;
@@ -137,7 +154,12 @@ void CastleEngine::loadAssetsDOSFullGame() {
 			_background->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 			// Eye widget is next to 0x1f058
 
-			stream->seek(0x1f4ea);
+			stream->seek(0x1f4e3);
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+			debug("%lx", stream->pos());
+			debug("extra: %x", stream->readByte());
+
 			for (int i = 0; i < 9; i++) {
 				Graphics::ManagedSurface *frame = loadFrameFromPlanes(stream, 8, 14);
 				frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
@@ -150,14 +172,56 @@ void CastleEngine::loadAssetsDOSFullGame() {
 				_keysMenuFrames.push_back(frame);
 			}
 
-			stream->seek(0x202b8);
-			_strenghtBackgroundFrame = loadFrameFromPlanes(stream, 40, 14);
-			_strenghtBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			//for (int i = 0; i < 6; i++)
+			//	debug("i: %d -> %x", i, stream->readByte());
+
+			//loadFrameWithHeaderDOS(stream);
+			//debug("%lx", stream->pos());
+			//assert(0);
+
+			stream->seek(0x20262);
+			_strenghtBackgroundFrame = loadFrameWithHeaderDOS(stream);
+			//loadFrameFromPlanes(stream, 40, 15);
+			//_strenghtBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
+			_strenghtBarFrame = loadFrameWithHeaderDOS(stream);
+			//assert(0);
+			//for (int i = 0; i < 6; i++)
+			//	debug("i: %d -> %x", i, stream->readByte());
+			//debug("%lx", stream->pos());
+			//assert(0);
+
+			/*_strenghtBarFrame = loadFrameFromPlanes(stream, 40, 3);
+			_strenghtBarFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);*/
+
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+			debug("%lx", stream->pos());
+			//assert(0);
+
+			Graphics::ManagedSurface *frame = nullptr;
+
+			for (int i = 0; i < 4; i++) {
+				frame = loadFrameFromPlanes(stream, 4, 15);
+				frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+				_strenghtWeightsFrames.push_back(frame);
+			}
+
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+			debug("%lx", stream->pos());
+			//assert(0);
 
 			stream->seek(0x221ae);
+			// No header?
 			_menu = loadFrameFromPlanes(stream, 112, 114);
 			_menu->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+			debug("%lx", stream->pos());
+			//assert(0);
+
 			//debug("%lx", stream->pos());
 			// TODO: some space here from the menu image
 			/*stream->seek(0x25414);
@@ -168,47 +232,39 @@ void CastleEngine::loadAssetsDOSFullGame() {
 			_menuFxOnIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);*/
 
 			// This end in 0x257d4??
-			byte flagPalette[4][3] = {
-				{0x00, 0x00, 0x00},
-				{0x00, 0xaa, 0x00},
-				{0x55, 0xff, 0x55},
-				{0xff, 0xff, 0xff}
-			};
+			stream->seek(0x257c2);
+			for (int i = 0; i < 6; i++)
+				debug("i: %d -> %x", i, stream->readByte());
+			debug("%lx", stream->pos());
 
-			stream->seek(0x257cc);
 			_flagFrames[0] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[0]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&flagPalette, 4);
+			_flagFrames[0]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
 			_flagFrames[1] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[1]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&flagPalette, 4);
+			_flagFrames[1]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
 			_flagFrames[2] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[2]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&flagPalette, 4);
+			_flagFrames[2]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
 			_flagFrames[3] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[3]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&flagPalette, 4);
+			_flagFrames[3]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
 
-			//debug("%lx", stream->pos());
-			stream->seek(0x25a90);
-			_riddleTopFrame = loadFrameFromPlanes(stream, 120, 20);
-			_riddleTopFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			debug("extra: %x", stream->readByte());
+			debug("extra: %x", stream->readByte());
 
-			for (int i = 0; i < 6; i++)
-				debug("i: %d -> %x", i, stream->readByte());
-
-			_riddleBackgroundFrame = loadFrameFromPlanes(stream, 120, 1);
-			_riddleBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
-
-			//loadFrameFromPlanes(stream, 60, 8);
-			//debug("%lx", stream->pos());
-
-			for (int i = 0; i < 6; i++)
+			/*for (int i = 0; i < 6; i++)
 				debug("i: %d -> %x", i, stream->readByte());
 
-			_riddleBottomFrame = loadFrameFromPlanes(stream, 120, 8);
-			_riddleBottomFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			debug("%lx", stream->pos());*/
+			//stream->seek(0x25a8a);
 
+			_riddleTopFrame = loadFrameWithHeaderDOS(stream);
+			_riddleBackgroundFrame = loadFrameWithHeaderDOS(stream);
+			_riddleBottomFrame = loadFrameWithHeaderDOS(stream);
+			_endOfGameThroneFrame = loadFrameWithHeaderDOS(stream);
+			// No header
+			_thunderFrame = loadFrameFromPlanes(stream, 16, 128);
+			_thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 
-			stream->seek(0x25a94 + 0xe00);
-			_endOfGameThroneFrame = loadFrameFromPlanes(stream, 36, 82);
-			_endOfGameThroneFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			// No header
+			// Another thunder frame?
 		}
 
 		delete stream;
@@ -383,7 +439,7 @@ void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
 	drawEnergyMeter(surface);
 	int flagFrameIndex = (_ticks / 10) % 4;
 	surface->copyRectToSurface(*_flagFrames[flagFrameIndex], 282, 5, Common::Rect(10, 0, _flagFrames[flagFrameIndex]->w, _flagFrames[flagFrameIndex]->h));
-	//surface->copyRectToSurface(*_something, 100, 50, Common::Rect(0, 0, _something->w, _something->h));
+	//surface->copyRectToSurface(*_endOfGameThroneFrame, 100, 50, Common::Rect(0, 0, _endOfGameThroneFrame->w, _endOfGameThroneFrame->h));
 }
 
 } // End of namespace Freescape


Commit: 0c41f4c49a3762df6d5d9d21acf4e5f034cb5a2c
    https://github.com/scummvm/scummvm/commit/0c41f4c49a3762df6d5d9d21acf4e5f034cb5a2c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2024-09-11T21:24:15+02:00

Commit Message:
FREESCAPE: refactor code to parse header and bitmaps from castle ega dos

Changed paths:
    engines/freescape/games/castle/castle.cpp
    engines/freescape/games/castle/castle.h
    engines/freescape/games/castle/dos.cpp


diff --git a/engines/freescape/games/castle/castle.cpp b/engines/freescape/games/castle/castle.cpp
index 48ffd8f05e6..f52a67649af 100644
--- a/engines/freescape/games/castle/castle.cpp
+++ b/engines/freescape/games/castle/castle.cpp
@@ -74,11 +74,6 @@ CastleEngine::CastleEngine(OSystem *syst, const ADGameDescription *gd) : Freesca
 	_menuFxOnIndicator = nullptr;
 	_menuFxOffIndicator = nullptr;
 
-	_flagFrames[0] = nullptr;
-	_flagFrames[1] = nullptr;
-	_flagFrames[2] = nullptr;
-	_flagFrames[3] = nullptr;
-
 	_numberKeys = 0;
 	_spiritsDestroyed = 0;
 	_spiritsMeter = 32;
diff --git a/engines/freescape/games/castle/castle.h b/engines/freescape/games/castle/castle.h
index 7352d46ec9f..d0c9cfa977f 100644
--- a/engines/freescape/games/castle/castle.h
+++ b/engines/freescape/games/castle/castle.h
@@ -34,7 +34,6 @@ public:
 	Graphics::ManagedSurface *_menuRunIndicator;
 	Graphics::ManagedSurface *_menuFxOnIndicator;
 	Graphics::ManagedSurface *_menuFxOffIndicator;
-	Graphics::ManagedSurface *_something;
 	Graphics::ManagedSurface *_menu;
 
 	void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
@@ -78,6 +77,7 @@ public:
 	void drawStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
 	//void drawStringInSurface(const Common::String &str, int x, int y, uint32 primaryFontColor, uint32 secondaryFontColor, uint32 backColor, Graphics::Surface *surface, int offset = 0) override;
 	Graphics::ManagedSurface *loadFrameWithHeaderDOS(Common::SeekableReadStream *file);
+	Common::Array <Graphics::ManagedSurface *>loadFramesWithHeaderDOS(Common::SeekableReadStream *file, int numFrames);
 
 	Common::Array<Graphics::ManagedSurface *> loadFramesWithHeader(Common::SeekableReadStream *file, int pos, int numFrames, uint32 front, uint32 back);
 	Graphics::ManagedSurface *loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back);
@@ -90,17 +90,19 @@ public:
 
 	Common::Array<Graphics::ManagedSurface *>_keysBorderFrames;
 	Common::Array<Graphics::ManagedSurface *>_keysMenuFrames;
+	Graphics::ManagedSurface *_spiritsMeterIndicatorBackgroundFrame;
 	Graphics::ManagedSurface *_spiritsMeterIndicatorFrame;
 	Graphics::ManagedSurface *_strenghtBackgroundFrame;
 	Graphics::ManagedSurface *_strenghtBarFrame;
 	Common::Array<Graphics::ManagedSurface *> _strenghtWeightsFrames;
-	Graphics::ManagedSurface *_flagFrames[4];
+	Common::Array<Graphics::ManagedSurface *> _flagFrames;
 	Graphics::ManagedSurface *_thunderFrame;
 	Graphics::ManagedSurface *_riddleTopFrame;
 	Graphics::ManagedSurface *_riddleBackgroundFrame;
 	Graphics::ManagedSurface *_riddleBottomFrame;
 
-	Graphics::ManagedSurface *_endOfGameThroneFrame;
+	Graphics::ManagedSurface *_endGameThroneFrame;
+	Graphics::ManagedSurface *_endGameBackgroundFrame;
 
 	int _numberKeys;
 	bool _useRockTravel;
diff --git a/engines/freescape/games/castle/dos.cpp b/engines/freescape/games/castle/dos.cpp
index e4e9aef2f1a..12c6c16c747 100644
--- a/engines/freescape/games/castle/dos.cpp
+++ b/engines/freescape/games/castle/dos.cpp
@@ -119,6 +119,27 @@ Graphics::ManagedSurface *CastleEngine::loadFrameFromPlanesInternal(Common::Seek
 	return surface;
 }
 
+Common::Array <Graphics::ManagedSurface *>CastleEngine::loadFramesWithHeaderDOS(Common::SeekableReadStream *file, int numFrames) {
+	uint8 header1 = file->readByte();
+	uint8 header2 = file->readByte();
+	int height = file->readByte();
+	uint8 mask = file->readByte();
+	int size = file->readUint16LE();
+
+	assert(size % height == 0);
+	int widthBytes = (size / height);
+
+	Common::Array<Graphics::ManagedSurface *> frames;
+	for (int i = 0; i < numFrames; i++) {
+		Graphics::ManagedSurface *frame = loadFrameFromPlanes(file, widthBytes, height);
+		frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+		frames.push_back(frame);
+	}
+
+	debug("header: %x %x, height: %d, mask: %x, widthBytes: %d, size: %d", header1, header2, height, mask, widthBytes, size);
+	return frames;
+}
+
 Graphics::ManagedSurface *CastleEngine::loadFrameWithHeaderDOS(Common::SeekableReadStream *file) {
 	uint8 header1 = file->readByte();
 	uint8 header2 = file->readByte();
@@ -133,6 +154,7 @@ Graphics::ManagedSurface *CastleEngine::loadFrameWithHeaderDOS(Common::SeekableR
 	frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 
 	debug("header: %x %x, height: %d, mask: %x, widthBytes: %d, size: %d", header1, header2, height, mask, widthBytes, size);
+	debug("pos: %lx", file->pos());
 	return frame;
 }
 
@@ -149,9 +171,13 @@ void CastleEngine::loadAssetsDOSFullGame() {
 			loadSpeakerFxDOS(stream, 0x636d + 0x200, 0x63ed + 0x200);
 			loadDOSFonts(stream, 0x29696);
 
-			stream->seek(0x1c700);
+			stream->seek(0x197c0);
+			_endGameBackgroundFrame = loadFrameFromPlanes(stream, 112, 108);
+			_endGameBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+
 			_background = loadFrameFromPlanes(stream, 252, 42);
 			_background->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
+			debug("%lx", stream->pos());
 			// Eye widget is next to 0x1f058
 
 			stream->seek(0x1f4e3);
@@ -181,84 +207,35 @@ void CastleEngine::loadAssetsDOSFullGame() {
 
 			stream->seek(0x20262);
 			_strenghtBackgroundFrame = loadFrameWithHeaderDOS(stream);
-			//loadFrameFromPlanes(stream, 40, 15);
-			//_strenghtBackgroundFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
-
 			_strenghtBarFrame = loadFrameWithHeaderDOS(stream);
-			//assert(0);
-			//for (int i = 0; i < 6; i++)
-			//	debug("i: %d -> %x", i, stream->readByte());
-			//debug("%lx", stream->pos());
-			//assert(0);
+			_strenghtWeightsFrames = loadFramesWithHeaderDOS(stream, 4);
+			_spiritsMeterIndicatorBackgroundFrame = loadFrameWithHeaderDOS(stream);
+			_spiritsMeterIndicatorFrame = loadFrameWithHeaderDOS(stream);
+			loadFrameWithHeaderDOS(stream); // side
+			loadFrameWithHeaderDOS(stream); // ???
 
-			/*_strenghtBarFrame = loadFrameFromPlanes(stream, 40, 3);
-			_strenghtBarFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);*/
-
-			for (int i = 0; i < 6; i++)
-				debug("i: %d -> %x", i, stream->readByte());
-			debug("%lx", stream->pos());
-			//assert(0);
-
-			Graphics::ManagedSurface *frame = nullptr;
-
-			for (int i = 0; i < 4; i++) {
-				frame = loadFrameFromPlanes(stream, 4, 15);
-				frame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
-				_strenghtWeightsFrames.push_back(frame);
-			}
-
-			for (int i = 0; i < 6; i++)
+			/*for (int i = 0; i < 6; i++)
 				debug("i: %d -> %x", i, stream->readByte());
-			debug("%lx", stream->pos());
+			debug("%lx", stream->pos());*/
 			//assert(0);
 
 			stream->seek(0x221ae);
 			// No header?
-			_menu = loadFrameFromPlanes(stream, 112, 114);
+			_menu = loadFrameFromPlanes(stream, 112, 115);
 			_menu->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
 
-			for (int i = 0; i < 6; i++)
-				debug("i: %d -> %x", i, stream->readByte());
-			debug("%lx", stream->pos());
-			//assert(0);
-
-			//debug("%lx", stream->pos());
-			// TODO: some space here from the menu image
-			/*stream->seek(0x25414);
-			_menuCrawlIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);
-			_menuWalkIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);
-			_menuRunIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);
-			_menuFxOffIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);
-			_menuFxOnIndicator = loadFrameFromPlanes(stream, 16, 12, lightGray, lightGray, lightGray, darkGray);*/
-
-			// This end in 0x257d4??
-			stream->seek(0x257c2);
-			for (int i = 0; i < 6; i++)
-				debug("i: %d -> %x", i, stream->readByte());
-			debug("%lx", stream->pos());
-
-			_flagFrames[0] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[0]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
-			_flagFrames[1] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[1]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
-			_flagFrames[2] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[2]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
-			_flagFrames[3] = loadFrameFromPlanes(stream, 16, 11);
-			_flagFrames[3]->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 4);
-
-			debug("extra: %x", stream->readByte());
-			debug("extra: %x", stream->readByte());
-
-			/*for (int i = 0; i < 6; i++)
-				debug("i: %d -> %x", i, stream->readByte());
-
-			debug("%lx", stream->pos());*/
-			//stream->seek(0x25a8a);
+			Common::Array <Graphics::ManagedSurface *> menuFrames = loadFramesWithHeaderDOS(stream, 5);
+			_menuCrawlIndicator = menuFrames[0];
+			_menuWalkIndicator = menuFrames[1];
+			_menuRunIndicator = menuFrames[2];
+			_menuFxOffIndicator = menuFrames[3];
+			_menuFxOnIndicator = menuFrames[4];
 
+			_flagFrames = loadFramesWithHeaderDOS(stream, 4);
 			_riddleTopFrame = loadFrameWithHeaderDOS(stream);
 			_riddleBackgroundFrame = loadFrameWithHeaderDOS(stream);
 			_riddleBottomFrame = loadFrameWithHeaderDOS(stream);
-			_endOfGameThroneFrame = loadFrameWithHeaderDOS(stream);
+			_endGameThroneFrame = loadFrameWithHeaderDOS(stream);
 			// No header
 			_thunderFrame = loadFrameFromPlanes(stream, 16, 128);
 			_thunderFrame->convertToInPlace(_gfx->_texturePixelFormat, (byte *)&kEGADefaultPalette, 16);
@@ -438,8 +415,9 @@ void CastleEngine::drawDOSUI(Graphics::Surface *surface) {
 
 	drawEnergyMeter(surface);
 	int flagFrameIndex = (_ticks / 10) % 4;
-	surface->copyRectToSurface(*_flagFrames[flagFrameIndex], 282, 5, Common::Rect(10, 0, _flagFrames[flagFrameIndex]->w, _flagFrames[flagFrameIndex]->h));
-	//surface->copyRectToSurface(*_endOfGameThroneFrame, 100, 50, Common::Rect(0, 0, _endOfGameThroneFrame->w, _endOfGameThroneFrame->h));
+	surface->copyRectToSurface(*_flagFrames[flagFrameIndex], 285, 5, Common::Rect(0, 0, _flagFrames[flagFrameIndex]->w, _flagFrames[flagFrameIndex]->h));
+	surface->copyRectToSurface((const Graphics::Surface)*_spiritsMeterIndicatorFrame, 140 + _spiritsMeterPosition, 156, Common::Rect(0, 0, 15, 8));
+	//surface->copyRectToSurface(*_spiritsMeterIndicatorFrame, 100, 50, Common::Rect(0, 0, _spiritsMeterIndicatorFrame->w, _spiritsMeterIndicatorFrame->h));
 }
 
 } // End of namespace Freescape




More information about the Scummvm-git-logs mailing list