[Scummvm-git-logs] scummvm master -> 6af35ed45d5745fd382967493745ef3f223587a9

yuv422 yuv422 at users.noreply.github.com
Sat Mar 7 12:07:06 UTC 2020


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

Summary:
005b2ded72 DRAGONS: Fix playing videos that are less than screen height
6af35ed45d DRAGONS: Started on main menu support


Commit: 005b2ded720b826cb218f4d0ead75055010412ca
    https://github.com/scummvm/scummvm/commit/005b2ded720b826cb218f4d0ead75055010412ca
Author: Eric Fry (yuv422 at users.noreply.github.com)
Date: 2020-03-07T23:06:02+11:00

Commit Message:
DRAGONS: Fix playing videos that are less than screen height

Changed paths:
    engines/dragons/dragons.cpp
    engines/dragons/strplayer.cpp


diff --git a/engines/dragons/dragons.cpp b/engines/dragons/dragons.cpp
index 26c0510c75..76bc9a9484 100644
--- a/engines/dragons/dragons.cpp
+++ b/engines/dragons/dragons.cpp
@@ -219,7 +219,7 @@ Common::Error DragonsEngine::run() {
 		loadGameState(ConfMan.getInt("save_slot"));
 	} else {
 		_strPlayer->playVideo("crystald.str");
-		//TODO why doesn't this file load correctly? _video->playVideo("illusion.str");
+		_strPlayer->playVideo("illusion.str");
 		_strPlayer->playVideo("labintro.str");
 
 		//TODO main menu here.
diff --git a/engines/dragons/strplayer.cpp b/engines/dragons/strplayer.cpp
index 5645e2f7e4..6a976da9c1 100644
--- a/engines/dragons/strplayer.cpp
+++ b/engines/dragons/strplayer.cpp
@@ -32,7 +32,6 @@ StrPlayer::StrPlayer(DragonsEngine *vm, Screen *screen) : _vm(vm), _screen(scree
 
 void StrPlayer::playVideo(const Common::String &filename) {
 	bool skipped = false;
-	Common::Rect srcRect(0, 0, DRAGONS_SCREEN_WIDTH, DRAGONS_SCREEN_HEIGHT);
 	_decoder->loadFile(filename);
 	_decoder->start();
 
@@ -40,7 +39,7 @@ void StrPlayer::playVideo(const Common::String &filename) {
 		if (_decoder->needsUpdate()) {
 			const Graphics::Surface *frame = _decoder->decodeNextFrame();
 			if (frame) {
-				_screen->copyRectToSurface(*frame, 0, 0, srcRect);
+				_screen->copyRectToSurface(*frame, 0, 0, Common::Rect(frame->w, frame->h));
 				_screen->updateScreen();
 			}
 		}


Commit: 6af35ed45d5745fd382967493745ef3f223587a9
    https://github.com/scummvm/scummvm/commit/6af35ed45d5745fd382967493745ef3f223587a9
Author: Eric Fry (yuv422 at users.noreply.github.com)
Date: 2020-03-07T23:06:02+11:00

Commit Message:
DRAGONS: Started on main menu support

Changed paths:
    engines/dragons/dragons.cpp
    engines/dragons/dragons.h
    engines/dragons/font.cpp
    engines/dragons/font.h
    engines/dragons/saveload.cpp
    engines/dragons/scene.cpp
    engines/dragons/screen.cpp


diff --git a/engines/dragons/dragons.cpp b/engines/dragons/dragons.cpp
index 76bc9a9484..ad5a5c6c22 100644
--- a/engines/dragons/dragons.cpp
+++ b/engines/dragons/dragons.cpp
@@ -97,6 +97,7 @@ DragonsEngine::DragonsEngine(OSystem *syst, const ADGameDescription *desc) : Eng
 
 	_debugMode = false;
 	_isGamePaused = false;
+	_inMenu = false;
 
 	_bit_flags_8006fbd8 = 0;
 
@@ -222,7 +223,8 @@ Common::Error DragonsEngine::run() {
 		_strPlayer->playVideo("illusion.str");
 		_strPlayer->playVideo("labintro.str");
 
-		//TODO main menu here.
+		init();
+		mainMenu();
 		loadScene(0);
 	}
 
@@ -1161,7 +1163,7 @@ bool DragonsEngine::hasFeature(Engine::EngineFeature f) const {
 		(f == kSupportsSavingDuringRuntime);
 }
 
-void DragonsEngine::loadScene(uint16 sceneId) {
+void DragonsEngine::init() {
 	_flags = 0x1046;
 	_flags &= 0x1c07040;
 	_flags |= 0x26;
@@ -1183,7 +1185,9 @@ void DragonsEngine::loadScene(uint16 sceneId) {
 
 	_screen->loadPalette(4, _cursor->getPalette());
 	_screen->updatePaletteTransparency(4, 1, 0xff, true);
+}
 
+void DragonsEngine::loadScene(uint16 sceneId) {
 	// TODO fun_80017010_update_actor_texture_maybe();
 	if (sceneId > 2) {
 		_dragonVAR->setVar(1, 1);
@@ -1492,6 +1496,59 @@ void DragonsEngine::initSubtitleFlag() {
 	}
 }
 
+int centerText(const char *text) {
+	return 0x14 - (strlen(text) / 2 + 1);
+}
+
+void DragonsEngine::mainMenu() {
+	_inMenu = true;
+	//TODO need to support other languages.
+	const char copyright[6][40] = {
+			"Crystal Dynamics is a trademark",
+			"of Crystal Dynamics.",
+			"Blazing Dragons is a trademark and",
+			"copyright of Terry Jones and is",
+			"used with permission.",
+			"Licensed by Nelvana Marketing Inc."
+	};
+	const char menuItems[3][40] = {
+			"Start",
+			"Options",
+			"Previews"
+	};
+
+	_screen->clearScreen();
+	Actor *actor = _actorManager->loadActor(0xd9,0,0,0,3);
+	actor->setFlag(ACTOR_FLAG_8000);
+	actor->setFlag(ACTOR_FLAG_100);
+	actor->setFlag(ACTOR_FLAG_80);
+
+	//TODO fix palette for copyright image.
+	_screen->loadPalette(0, _cursor->getPalette()); //actor->_actorResource->getPalette());
+
+	for (int i = 0; i < 6; i++) {
+		_fontManager->addAsciiText(centerText(&copyright[i][0]) * 8, (0x12 + i) * 8, &copyright[i][0], strlen(copyright[i]), 1);
+	}
+
+	waitForFramesAllowSkip(400);
+	_fontManager->clearText();
+	actor->updateSequence(1);
+
+	for (int i = 0; i < 3; i++) {
+		_fontManager->addAsciiText(centerText(&menuItems[i][0]) * 8, (0x12 + i) * 8, &menuItems[i][0], strlen(menuItems[i]), 1);
+	}
+
+	do {
+		waitForFrames(1);
+	} while (!isActionButtonPressed() && !shouldQuit());
+
+	_inMenu = false;
+}
+
+bool DragonsEngine::isInMenu() {
+	return _inMenu;
+}
+
 void (*DragonsEngine::getSceneUpdateFunction())() {
 	return _sceneUpdateFunction;
 }
diff --git a/engines/dragons/dragons.h b/engines/dragons/dragons.h
index f9e1cb00ff..1ffc8f14e3 100644
--- a/engines/dragons/dragons.h
+++ b/engines/dragons/dragons.h
@@ -194,6 +194,7 @@ private:
 
 	bool _debugMode;
 	bool _isGamePaused;
+	bool _inMenu;
 
 	void (*_sceneUpdateFunction)();
 	void (*_vsyncUpdateFunction)();
@@ -248,6 +249,7 @@ public:
 
 	void reset_screen_maybe();
 
+	void init();
 	void loadScene(uint16 sceneId);
 
 	void reset();
@@ -281,6 +283,8 @@ public:
 
 	void setupPalette1();
 
+	bool isInMenu();
+
 	//TODO this logic should probably go in its own class.
 	uint32 getBigFileInfoTblFromDragonEXE();
 	uint32 getFontOffsetFromDragonEXE();
@@ -317,6 +321,8 @@ private:
 	void SomeInitSound_fun_8003f64c();
 
 	void initSubtitleFlag();
+
+	void mainMenu();
 };
 
 DragonsEngine *getEngine();
diff --git a/engines/dragons/font.cpp b/engines/dragons/font.cpp
index 3e352c3451..378e18319f 100644
--- a/engines/dragons/font.cpp
+++ b/engines/dragons/font.cpp
@@ -166,7 +166,7 @@ void updatePalEntry(uint16 *pal, uint16 index, uint16 newValue) {
 void FontManager::updatePalette() {
 	uint16 *palette_f2_font_maybe = (uint16 *)_screen->getPalette(2);
 	const uint16 cursor3 = 0x14a5 | 0x8000;
-	if (_vm->isFlagSet(ENGINE_FLAG_200)) {
+	if (_vm->isInMenu() || _vm->isFlagSet(ENGINE_FLAG_200)) {
 		updatePalEntry(palette_f2_font_maybe, 3, cursor3); //TODO move this to palette initialisation
 		if (!_vm->isUnkFlagSet(ENGINE_UNK1_FLAG_1)) {
 			updatePalEntry(palette_f2_font_maybe, 16, cursor3);
@@ -249,4 +249,18 @@ void FontManager::drawBoxChar(uint32 x, uint32 y, uint8 tileIndex) {
 	}
 }
 
+void FontManager::addAsciiText(int16 x, int16 y, const char *text, uint16 length, uint8 fontType) {
+	uint16 wText[41];
+	memset(wText, 0, sizeof(wText));
+	if (length > 40) {
+		length = 40;
+	}
+
+	for (int i = 0; i < length; i++) {
+		wText[i] = text[i];
+	}
+
+	addText(x, y, wText, length, fontType);
+}
+
 } // End of namespace Dragons
diff --git a/engines/dragons/font.h b/engines/dragons/font.h
index 3d581bb643..3b3c1f7481 100644
--- a/engines/dragons/font.h
+++ b/engines/dragons/font.h
@@ -67,6 +67,7 @@ public:
 	FontManager(DragonsEngine *vm, Screen *screen, BigfileArchive *bigfileArchive);
 	~FontManager();
 	void addText(int16 x, int16 y, uint16 *text, uint16 length, uint8 fontType);
+	void addAsciiText(int16 x, int16 y, const char *text, uint16 length, uint8 fontType);
 	void draw();
 	void clearText();
 	void updatePalette();
diff --git a/engines/dragons/saveload.cpp b/engines/dragons/saveload.cpp
index 200d6f2893..e5947368a9 100644
--- a/engines/dragons/saveload.cpp
+++ b/engines/dragons/saveload.cpp
@@ -133,6 +133,7 @@ bool DragonsEngine::loadgame(const char *filename) {
 
 	_dragonINIResource->reset();
 
+	init();
 	loadScene(newSceneId);
 	setFlags(ENGINE_FLAG_8); //Re-enable cursor TODO should we need to do this?
 
diff --git a/engines/dragons/scene.cpp b/engines/dragons/scene.cpp
index a1bc2483b6..ab12d1ef00 100644
--- a/engines/dragons/scene.cpp
+++ b/engines/dragons/scene.cpp
@@ -338,7 +338,7 @@ void Scene::draw() {
 	_vm->_screen->clearScreen();
 
 	for (uint16 priority = 1; priority < 16; priority++) {
-		if (priority == 7 && _vm->isFlagSet(ENGINE_FLAG_200)) {
+		if (_vm->isInMenu() || (priority == 7 && _vm->isFlagSet(ENGINE_FLAG_200))) {
 			_vm->_fontManager->updatePalette();
 			_vm->_fontManager->draw();
 		}
diff --git a/engines/dragons/screen.cpp b/engines/dragons/screen.cpp
index 7c6b0438f8..9a03267399 100644
--- a/engines/dragons/screen.cpp
+++ b/engines/dragons/screen.cpp
@@ -373,7 +373,7 @@ byte *Screen::getPalette(uint16 paletteNum) {
 }
 
 void Screen::clearScreen() {
-	_backSurface->fillRect(Common::Rect(0, 0, _backSurface->w - 1, _backSurface->h - 1), 0);
+	_backSurface->fillRect(Common::Rect(0, 0, _backSurface->w, _backSurface->h), 0);
 }
 
 void Screen::drawRect(uint16 colour, Common::Rect rect, int id) {




More information about the Scummvm-git-logs mailing list