[Scummvm-git-logs] scummvm master -> 76f4371f4517f633b008975c4dca53f3a69145e6

sev- noreply at scummvm.org
Tue Dec 13 17:40:21 UTC 2022


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

Summary:
b1eaf2ea0f SCUMM: GUI: Implement MI1 SegaCD menu
06f352f8e4 SCUMM: GUI: Fix restart prompt banner appearing for MI1 SegaCD
19b45e2a50 SCUMM: GUI: Fix passcode not being updated on MI1 SegaCD
beb65bc902 SCUMM: GUI: Fix warnings
f463d032d8 SCUMM: GUI: Improve readability
87625eb23e SCUMM: GUI: Use strnlen to measure current passcode length
76f4371f45 SCUMM: GUI: Handle numbers strings with const chars instead of String objects


Commit: b1eaf2ea0fad9e9956c2a3750408fa71427907b6
    https://github.com/scummvm/scummvm/commit/b1eaf2ea0fad9e9956c2a3750408fa71427907b6
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Implement MI1 SegaCD menu

Changed paths:
    engines/scumm/dialogs.cpp
    engines/scumm/gfx_gui.cpp
    engines/scumm/input.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h


diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp
index 0230e96266c..e1553d396c8 100644
--- a/engines/scumm/dialogs.cpp
+++ b/engines/scumm/dialogs.cpp
@@ -455,7 +455,9 @@ const char *InfoDialog::getPlainEngineString(int stringno, bool forceHardcodedSt
 			}
 		}
 	} else if (_vm->_game.version >= 3) {
-		if (!forceHardcodedString)
+		if (_vm->_game.platform == Common::kPlatformSegaCD)
+			result = (const char *)_vm->getStringAddress(stringno);
+		else if (!forceHardcodedString)
 			result = (const char *)_vm->getStringAddress(getStaticResString(_vm->_language, stringno - 1).num);
 
 		if (!result) {
diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index d8025bbecb0..a60f6dfb347 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -720,7 +720,7 @@ void ScummEngine::drawInternalGUIControl(int id, bool highlightColor) {
 
 		// Calculate the positioning for the text
 		int oldId = _charset->getCurID();
-		_charset->setCurID(1);
+		_charset->setCurID(_game.platform == Common::kPlatformSegaCD ? 6 : 1);
 
 		centerFlag = ctrl->centerText;
 
@@ -763,13 +763,28 @@ void ScummEngine::drawInternalGUIControl(int id, bool highlightColor) {
 
 		} else {
 			int tmpRight = _string[5].right;
+			bool nudgeJapYPos = _language == Common::JA_JPN;
+
+			if (_game.platform == Common::kPlatformSegaCD) {
+				nudgeJapYPos &= !(id >= GUI_CTRL_NUMPAD_1 && id <= GUI_CTRL_NUMPAD_0);
+				nudgeJapYPos &= (id != GUI_CTRL_NUMPAD_BACK);
+				nudgeJapYPos &= (id != GUI_CTRL_ARROW_LEFT_BUTTON);
+				nudgeJapYPos &= (id != GUI_CTRL_ARROW_RIGHT_BUTTON);
+				nudgeJapYPos &= (id != GUI_CTRL_TEXT_SPEED_SLIDER);
+
+				textYPos -= nudgeJapYPos ? 4 : 2;
+
+				textXPos += 1;
+			}
+
 			_string[5].right = _screenWidth - 1;
 
 			// The original CJK DIG interpreter limits the clipping to the save slots. Other elements
 			// seem to (theoretically) be allowed to draw text wherever they want...
-			bool isSaveSlot = (id >= GUI_CTRL_FIRST_SG && id <= GUI_CTRL_LAST_SG);
+			bool isSaveSlot = (id >= GUI_CTRL_FIRST_SG && id <= GUI_CTRL_LAST_SG) && _game.platform != Common::kPlatformSegaCD;
 			Common::Rect clipRect(relCentX, relCentY, x, y);
 			drawGUIText(buttonString, isSaveSlot ? &clipRect : nullptr, textXPos, textYPos, textColor, centerFlag);
+
 			_string[5].right = tmpRight;
 		}
 
@@ -1543,7 +1558,7 @@ void ScummEngine::queryRestart() {
 bool ScummEngine::shouldHighlightLabelAndWait(int clickedControl) {
 	return ((clickedControl >= GUI_CTRL_SAVE_BUTTON && clickedControl <= GUI_CTRL_PATH_BUTTON) ||
 			(clickedControl == GUI_CTRL_DISPLAY_TEXT_CHECKBOX ||
-			 clickedControl == GUI_CTRL_SPOOLED_MUSIC_CHECKBOX));
+			 clickedControl == GUI_CTRL_SPOOLED_MUSIC_CHECKBOX)) || _game.platform == Common::kPlatformSegaCD;
 }
 
 void ScummEngine::fillSavegameLabels() {
@@ -1863,7 +1878,8 @@ void ScummEngine::showMainMenu() {
 			rightMsClicked = false;
 
 			if (clickedControl != -1) {
-				if (clickedControl < GUI_CTRL_FIRST_SG || clickedControl > GUI_CTRL_LAST_SG) {
+				if (clickedControl < GUI_CTRL_FIRST_SG || clickedControl > GUI_CTRL_LAST_SG ||
+					_game.platform == Common::kPlatformSegaCD) {
 					// Avoid highlighting the main container boxes :-)
 					if (clickedControl != GUI_CTRL_OUTER_BOX && clickedControl != GUI_CTRL_INNER_BOX) {
 						// Highlight the control
@@ -1883,7 +1899,7 @@ void ScummEngine::showMainMenu() {
 						if (executeMainMenuOperation(clickedControl, curMouseX, curMouseY, hasLoadedState))
 							break;
 					}
-				} else {
+				} else if (_game.platform != Common::kPlatformSegaCD) {
 					int tmp = _mainMenuSavegameLabel;
 					_mainMenuSavegameLabel = clickedControl;
 
@@ -1908,8 +1924,9 @@ void ScummEngine::showMainMenu() {
 
 		if (shouldQuit() && !_quitByGUIPrompt) {
 			clearClickedStatus();
-			if (executeMainMenuOperation(GUI_CTRL_QUIT_BUTTON, 0, 0, hasLoadedState) || _quitByGUIPrompt)
-				break;
+			if (_game.platform != Common::kPlatformSegaCD)
+				if (executeMainMenuOperation(GUI_CTRL_QUIT_BUTTON, 0, 0, hasLoadedState) || _quitByGUIPrompt)
+					break;
 		}
 	}
 
@@ -1919,7 +1936,8 @@ void ScummEngine::showMainMenu() {
 		_completeScreenRedraw = true;
 
 	// Restore the old cursor state only if we're not loading a game...
-	if (_saveScriptParam != GAME_PROPER_LOAD && _saveLoadFlag != 2) {
+	if (_saveScriptParam != GAME_PROPER_LOAD && _saveLoadFlag != 2 &&
+		!(_game.platform == Common::kPlatformSegaCD && hasLoadedState)) {
 		restoreCursorPostMenu();
 	} else if (_saveLoadFlag == 2) {
 		_cursor.state = 0;
@@ -1964,7 +1982,149 @@ void ScummEngine::showMainMenu() {
 	clearClickedStatus();
 }
 
+bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY, bool &hasLoadedState) {
+	switch (op) {
+	case GUI_CTRL_PLAY_BUTTON:
+		return true;
+	case GUI_CTRL_LOAD_BUTTON:
+		_menuPage = GUI_PAGE_LOAD;
+		setUpMainMenuControls();
+		drawMainMenuControls();
+		updateMainMenuControls();
+		ScummEngine::drawDirtyScreenParts();
+		break;
+	case GUI_CTRL_RESTART_BUTTON:
+		_menuPage = GUI_PAGE_RESTART;
+		setUpMainMenuControls();
+		drawMainMenuControls();
+		ScummEngine::drawDirtyScreenParts();
+		break;
+	case GUI_CTRL_OK_BUTTON:
+		if (_menuPage == GUI_PAGE_RESTART) {
+			_cursor.state = 0;
+			CursorMan.showMouse(false);
+			hasLoadedState = true;
+			restart();
+			return true;
+		} else if (_menuPage == GUI_PAGE_CODE_CONFIRM) {
+			_bootParam = atoi(_mainMenuSegaCDPasscode);
+			int args[16];
+			memset(args, 0, sizeof(args));
+			args[0] = _bootParam;
+
+			runScript(61, 0, 0, args);
+			hasLoadedState = _scummVars[411] == _bootParam;
+			_bootParam = 0;
+			if (!hasLoadedState) {
+				_menuPage = GUI_PAGE_INVALID_CODE;
+				setUpMainMenuControls();
+				drawMainMenuControls();
+				updateMainMenuControls();
+				ScummEngine::drawDirtyScreenParts();
+
+				waitForTimer(420);
+
+				_menuPage = GUI_PAGE_MAIN;
+				setUpMainMenuControls();
+				drawMainMenuControls();
+				updateMainMenuControls();
+				ScummEngine::drawDirtyScreenParts();
+			} else {
+				return true;
+			}
+		}
+
+		break;
+	case GUI_CTRL_CANCEL_BUTTON:
+		_menuPage = GUI_PAGE_MAIN;
+		setUpMainMenuControls();
+		drawMainMenuControls();
+		updateMainMenuControls();
+		ScummEngine::drawDirtyScreenParts();
+		break;
+	case GUI_CTRL_ARROW_LEFT_BUTTON:
+	case GUI_CTRL_ARROW_RIGHT_BUTTON:
+		if (_menuPage == GUI_PAGE_MAIN) {
+			if (op == GUI_CTRL_ARROW_LEFT_BUTTON) {
+				_defaultTextSpeed = CLIP<int>(_defaultTextSpeed - 1, 0, 9);
+			} else {
+				_defaultTextSpeed = CLIP<int>(_defaultTextSpeed + 1, 0, 9);
+			}
+
+			ConfMan.setInt("original_gui_text_speed", _defaultTextSpeed);
+			setTalkSpeed(_defaultTextSpeed);
+			syncSoundSettings();
+			ConfMan.flushToDisk();
+			drawMainMenuControls();
+			updateMainMenuControls();
+			ScummEngine::drawDirtyScreenParts();
+		}
+		break;
+	case GUI_CTRL_TEXT_SPEED_SLIDER:
+		_defaultTextSpeed = CLIP<int>((mouseX - 150) / 9, 0, 9);
+
+		ConfMan.setInt("original_gui_text_speed", _defaultTextSpeed);
+		setTalkSpeed(_defaultTextSpeed);
+		syncSoundSettings();
+		ConfMan.flushToDisk();
+		updateMainMenuControls();
+		ScummEngine::drawDirtyScreenParts();
+		break;
+	case GUI_CTRL_NUMPAD_0:
+	case GUI_CTRL_NUMPAD_1:
+	case GUI_CTRL_NUMPAD_2:
+	case GUI_CTRL_NUMPAD_3:
+	case GUI_CTRL_NUMPAD_4:
+	case GUI_CTRL_NUMPAD_5:
+	case GUI_CTRL_NUMPAD_6:
+	case GUI_CTRL_NUMPAD_7:
+	case GUI_CTRL_NUMPAD_8:
+	case GUI_CTRL_NUMPAD_9:
+	case GUI_CTRL_NUMPAD_BACK:
+	{
+		int inputNum = op == GUI_CTRL_NUMPAD_0 ? 0 : op;
+		int curIdx;
+		for (curIdx = 0; curIdx < sizeof(_mainMenuSegaCDPasscode); curIdx++) {
+			if (_mainMenuSegaCDPasscode[curIdx] == '\0')
+				break;
+		}
+
+		if (op == GUI_CTRL_NUMPAD_BACK) {
+			if (curIdx > 0) {
+				_mainMenuSegaCDPasscode[curIdx - 1] = '\0';
+			}
+
+		} else {
+			_mainMenuSegaCDPasscode[curIdx] = '0' + inputNum;
+
+			if (curIdx >= 3) { // Last digit
+				updateMainMenuControls();
+				ScummEngine::drawDirtyScreenParts();
+
+				waitForTimer(120);
+
+				_menuPage = GUI_PAGE_CODE_CONFIRM;
+				setUpMainMenuControls();
+			}
+		}
+
+		drawMainMenuControls();
+		updateMainMenuControls();
+		ScummEngine::drawDirtyScreenParts();
+		break;
+	}
+	default:
+		break;
+	}
+
+	return false;
+}
+
 bool ScummEngine::executeMainMenuOperation(int op, int mouseX, int mouseY, bool &hasLoadedState) {
+	if (_game.platform == Common::kPlatformSegaCD) {
+		return executeMainMenuOperationSegaCD(op, mouseX, mouseY, hasLoadedState);
+	}
+
 	char saveScreenTitle[512];
 	Common::String formattedString;
 	int curSlot;
@@ -2180,6 +2340,7 @@ bool ScummEngine::executeMainMenuOperation(int op, int mouseX, int mouseY, bool
 		break;
 	case GUI_CTRL_TEXT_SPEED_SLIDER:
 		_defaultTextSpeed = CLIP<int>((mouseX - (_game.version == 7 ? 108 : 102)) / 9, 0, 9);
+
 		ConfMan.setInt("original_gui_text_speed", _defaultTextSpeed);
 		setTalkSpeed(_defaultTextSpeed);
 		syncSoundSettings();
@@ -2363,6 +2524,11 @@ void ScummEngine_v4::setUpMainMenuControls() {
 }
 
 void ScummEngine::setUpMainMenuControls() {
+	if (_game.platform == Common::kPlatformSegaCD) {
+		setUpMainMenuControlsSegaCD();
+		return;
+	}
+
 	int yConstant;
 	bool isLoomVGA = (_game.id == GID_LOOM && _game.version == 4);
 
@@ -2559,6 +2725,217 @@ void ScummEngine::setUpMainMenuControls() {
 	}
 }
 
+void ScummEngine::setUpMainMenuControlsSegaCD() {
+	int yConstant;
+	bool isJap = _language == Common::JA_JPN;
+
+	yConstant = _virtscr[kMainVirtScreen].topline + (_virtscr[kMainVirtScreen].h / 2);
+
+	for (int i = 0; i < ARRAYSIZE(_internalGUIControls); i++) {
+		_internalGUIControls[i].relativeCenterX = -1;
+	}
+
+	// Outer box
+	setUpInternalGUIControl(GUI_CTRL_OUTER_BOX,
+							getBannerColor(4),
+							getBannerColor(2),
+							getBannerColor(13),
+							getBannerColor(14),
+							getBannerColor(15),
+							getBannerColor(16),
+							getBannerColor(6),
+							getBannerColor(4),
+							20,
+							yConstant - 60,
+							300,
+							((yConstant + 60) < 0 ? -120 : yConstant + 60),
+							_emptyMsg, 1, 1);
+
+	// Load button
+	setUpInternalGUIControl(GUI_CTRL_LOAD_BUTTON,
+							getBannerColor(4),
+							getBannerColor(5),
+							getBannerColor(17),
+							getBannerColor(18),
+							getBannerColor(19),
+							getBannerColor(20),
+							getBannerColor(6),
+							getBannerColor(7),
+							isJap ? 26 : 44,
+							yConstant - 31,
+							isJap ? 111 : 103,
+							yConstant - 31 + 22,
+							getGUIString(gsLoad), 1, 1);
+
+	// Play button
+	setUpInternalGUIControl(GUI_CTRL_PLAY_BUTTON,
+							getBannerColor(4),
+							getBannerColor(5),
+							getBannerColor(17),
+							getBannerColor(18),
+							getBannerColor(19),
+							getBannerColor(20),
+							getBannerColor(6),
+							getBannerColor(7),
+							isJap ? 26 : 44,
+							yConstant - 5,
+							isJap ? 111 : 103,
+							yConstant - 5 + 22,
+							getGUIString(gsPlay), 1, 1);
+
+	// Restart button
+	setUpInternalGUIControl(GUI_CTRL_RESTART_BUTTON,
+							getBannerColor(4),
+							getBannerColor(5),
+							getBannerColor(17),
+							getBannerColor(18),
+							getBannerColor(19),
+							getBannerColor(20),
+							getBannerColor(6),
+							getBannerColor(7),
+							isJap ? 26 : 44,
+							yConstant + 21,
+							isJap ? 111 : 103,
+							yConstant + 21 + 22,
+							getGUIString(gsRestart), 1, 1);
+
+	if (_menuPage == GUI_PAGE_MAIN) {
+		// Arrow left button
+		setUpInternalGUIControl(GUI_CTRL_ARROW_LEFT_BUTTON,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								235,
+								yConstant + 18,
+								247,
+								yConstant + 34,
+								_arrowLeft, 1, 1);
+
+		// Arrow right button
+		setUpInternalGUIControl(GUI_CTRL_ARROW_RIGHT_BUTTON,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								248,
+								yConstant + 18,
+								260,
+								yConstant + 34,
+								_arrowRight, 1, 1);
+
+		setUpInternalGUIControl(GUI_CTRL_TEXT_SPEED_SLIDER,
+								getBannerColor(9),
+								getBannerColor(10),
+								getBannerColor(18),
+								getBannerColor(17),
+								getBannerColor(20),
+								getBannerColor(19),
+								getBannerColor(10),
+								getBannerColor(12),
+								152,
+								yConstant + 18,
+								235,
+								yConstant + 34,
+								_uncheckedBox, 1, 1);
+	}
+
+	if (_menuPage == GUI_PAGE_RESTART || _menuPage == GUI_PAGE_CODE_CONFIRM) {
+		// OK button
+		setUpInternalGUIControl(GUI_CTRL_OK_BUTTON,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								isJap ? 115 : 149,
+								yConstant + 21,
+								200,
+								yConstant + 43,
+								getGUIString(gsOK), 1, 1);
+
+		// Cancel button
+		setUpInternalGUIControl(GUI_CTRL_CANCEL_BUTTON,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								206,
+								yConstant + 21,
+								isJap ? 291 : 257,
+								yConstant + 43,
+								getGUIString(gsCancel), 1, 1);
+	}
+
+	if (_menuPage == GUI_PAGE_LOAD) {
+		Common::String numbers[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
+
+		setUpInternalGUIControl(GUI_CTRL_NUMPAD_0,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								197,
+								yConstant + 43,
+								211,
+								yConstant + 57,
+								numbers[0].c_str(), 1, 1);
+
+		setUpInternalGUIControl(GUI_CTRL_NUMPAD_BACK,
+								getBannerColor(4),
+								getBannerColor(5),
+								getBannerColor(17),
+								getBannerColor(18),
+								getBannerColor(19),
+								getBannerColor(20),
+								getBannerColor(6),
+								getBannerColor(7),
+								211,
+								yConstant + 43,
+								239,
+								yConstant + 57,
+								_arrowLeft, 1, 1);
+
+		for (int row = 0; row < 3; row++) {
+			for (int col = 0; col < 3; col++) {
+				setUpInternalGUIControl(row * 3 + (col + 1),
+										getBannerColor(4),
+										getBannerColor(5),
+										getBannerColor(17),
+										getBannerColor(18),
+										getBannerColor(19),
+										getBannerColor(20),
+										getBannerColor(6),
+										getBannerColor(7),
+										197 + col * 14,
+										yConstant + 29 - row * 14,
+										211 + col * 14,
+										yConstant + 43 - row * 14,
+										numbers[row * 3 + (col + 1)].c_str(), 1, 1);
+			}
+		}
+	}
+}
+
 void ScummEngine_v6::setUpMainMenuControls() {
 	int yConstantV6;
 
@@ -2928,6 +3305,11 @@ void ScummEngine_v6::setUpMainMenuControls() {
 }
 
 void ScummEngine::drawMainMenuControls() {
+	if (_game.platform == Common::kPlatformSegaCD) {
+		drawMainMenuControlsSegaCD();
+		return;
+	}
+
 	char namePrompt[256];
 	char loadPrompt[256];
 	char insertDisk[256];
@@ -3000,7 +3382,85 @@ void ScummEngine::drawMainMenuControls() {
 	_system->updateScreen();
 }
 
+void ScummEngine::drawMainMenuControlsSegaCD() {
+	char buf[256];
+	char formattedBuf[256];
+	bool isJap = _language == Common::JA_JPN;
+
+	int yConstant = _virtscr[kMainVirtScreen].topline + (_virtscr[kMainVirtScreen].h / 2);
+	int stringColor = getBannerColor(2);
+
+	drawInternalGUIControl(GUI_CTRL_OUTER_BOX, 0);
+	drawInternalGUIControl(GUI_CTRL_LOAD_BUTTON, 0);
+	drawInternalGUIControl(GUI_CTRL_PLAY_BUTTON, 0);
+	drawInternalGUIControl(GUI_CTRL_RESTART_BUTTON, 0);
+
+	convertMessageToString((const byte *)getGUIString(gsPause), (byte *)buf, sizeof(buf));
+	drawGUIText(buf, nullptr, isJap ? 38 : 24, yConstant - 52, stringColor, false);
+
+	convertMessageToString((const byte *)getGUIString(gsCurrentPasscode), (byte *)buf, sizeof(buf));
+	drawGUIText(buf, nullptr, isJap ? 128 : 137, yConstant - 52, stringColor, false);
+
+	Common::sprintf_s(buf, sizeof(buf), "%04d", _scummVars[411]);
+	drawGUIText(buf, nullptr, 184, yConstant - 34, stringColor, false);
+
+	if (_menuPage != GUI_PAGE_CODE_CONFIRM && _menuPage != GUI_PAGE_LOAD) {
+		for (int i = 0; i < sizeof(_mainMenuSegaCDPasscode); i++) {
+			_mainMenuSegaCDPasscode[i] = '\0';
+		}
+	}
+
+	if (_menuPage == GUI_PAGE_MAIN) {
+		drawInternalGUIControl(GUI_CTRL_TEXT_SPEED_SLIDER, 0);
+		drawInternalGUIControl(GUI_CTRL_ARROW_LEFT_BUTTON, 0);
+		drawInternalGUIControl(GUI_CTRL_ARROW_RIGHT_BUTTON, 0);
+	} else if (_menuPage == GUI_PAGE_LOAD) {
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_0, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_1, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_2, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_3, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_4, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_5, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_6, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_7, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_8, 0);
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_9, 0);
+
+		drawInternalGUIControl(GUI_CTRL_NUMPAD_BACK, 0);
+
+		drawInternalGUIControl(GUI_CTRL_OK_BUTTON, 0);
+		drawInternalGUIControl(GUI_CTRL_CANCEL_BUTTON, 0);
+
+		convertMessageToString((const byte *)getGUIString(gsEnterPasscode), (byte *)buf, sizeof(buf));
+		drawGUIText(buf, nullptr, isJap ? 166 : 146, yConstant - 18, stringColor, false);
+	} else if (_menuPage == GUI_PAGE_RESTART) {
+		drawInternalGUIControl(GUI_CTRL_OK_BUTTON, 0);
+		drawInternalGUIControl(GUI_CTRL_CANCEL_BUTTON, 0);
+
+		convertMessageToString((const byte *)getGUIString(gsRestartGame), (byte *)buf, sizeof(buf));
+		drawGUIText(buf, nullptr, isJap ? 163 : 151, yConstant + 4, stringColor, false);
+	} else if (_menuPage == GUI_PAGE_CODE_CONFIRM) {
+		drawInternalGUIControl(GUI_CTRL_OK_BUTTON, 0);
+		drawInternalGUIControl(GUI_CTRL_CANCEL_BUTTON, 0);
+
+		convertMessageToString((const byte *)getGUIString(gsConfirmPasscode), (byte *)buf, sizeof(buf));
+		Common::sprintf_s(formattedBuf, sizeof(formattedBuf), buf, atoi(_mainMenuSegaCDPasscode));
+		drawGUIText(formattedBuf, nullptr, isJap ? 129 : 135, yConstant + 4, stringColor, false);
+	} else if (_menuPage == GUI_PAGE_INVALID_CODE) {
+		convertMessageToString((const byte *)getGUIString(gsInvalidPasscode), (byte *)buf, sizeof(buf));
+		drawGUIText(buf, nullptr, isJap ? 152 : 141, yConstant + 28, stringColor, false);
+	}
+
+	ScummEngine::drawDirtyScreenParts();
+	_system->updateScreen();
+}
+
 void ScummEngine::updateMainMenuControls() {
+	if (_game.platform == Common::kPlatformSegaCD) {
+		updateMainMenuControlsSegaCD();
+		return;
+	}
+
 	if ((_game.variant && !strcmp(_game.variant, "Floppy")) || _game.version < 6)
 		return;
 
@@ -3130,7 +3590,43 @@ void ScummEngine::updateMainMenuControls() {
 	_system->updateScreen();
 }
 
+void ScummEngine::updateMainMenuControlsSegaCD() {
+	char msg[256];
+	int yConstant = _virtscr[kMainVirtScreen].topline + (_virtscr[kMainVirtScreen].h / 2);
+	bool isJap = _language == Common::JA_JPN;
+
+	if (_menuPage == GUI_PAGE_MAIN) {
+		strncpy(_mainMenuTextSpeedSlider, "\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a", sizeof(_mainMenuTextSpeedSlider));
+
+		if (VAR_CHARINC != 0xFF)
+			_mainMenuTextSpeedSlider[9 - VAR(VAR_CHARINC)] = '\x3b';
+
+		_internalGUIControls[GUI_CTRL_TEXT_SPEED_SLIDER].label = _mainMenuTextSpeedSlider;
+
+		drawInternalGUIControl(GUI_CTRL_TEXT_SPEED_SLIDER, 0);
+
+		convertMessageToString((const byte *)getGUIString(gsTextSpeed), (byte *)msg, sizeof(msg));
+		drawGUIText(msg, nullptr, isJap ? 118 : 167, yConstant, getBannerColor(2), false);
+
+		convertMessageToString((const byte *)getGUIString(gsSlowFast), (byte *)msg, sizeof(msg));
+		drawGUIText(msg, nullptr, isJap ? 151 : 158, yConstant + 37, getBannerColor(2), false);
+	} else if (_menuPage == GUI_PAGE_LOAD) {
+		drawLine(155, yConstant + 15, 191, yConstant + 15, getBannerColor(17));
+		drawLine(155, yConstant + 28, 191, yConstant + 28, getBannerColor(17));
+		drawLine(155, yConstant + 15, 155, yConstant + 28, getBannerColor(17));
+		drawLine(191, yConstant + 15, 191, yConstant + 28, getBannerColor(17));
+
+		drawGUIText(_mainMenuSegaCDPasscode, nullptr, 157, yConstant + 16, getBannerColor(2), false);
+	}
+
+	ScummEngine::drawDirtyScreenParts();
+	_system->updateScreen();
+}
+
 void ScummEngine::drawMainMenuTitle(const char *title) {
+	if (_game.platform == Common::kPlatformSegaCD)
+		return;
+
 	int boxColor, stringColor;
 	int yConstantV6 = _virtscr[kMainVirtScreen].topline + (_virtscr[kMainVirtScreen].h / 2);
 
@@ -3203,7 +3699,11 @@ void ScummEngine::drawGUIText(const char *buttonString, Common::Rect *clipRect,
 	_string[5].right = clipRect ? clipRect->right : _screenWidth - 1;
 	_string[5].center = centerFlag;
 	_string[5].color = textColor;
-	_string[5].charset = _game.version > 3 ? 1 : 0;
+
+	if (_game.platform == Common::kPlatformSegaCD)
+		_string[5].charset = 6;
+	else
+		_string[5].charset = _game.version > 3 ? 1 : 0;
 
 	drawString(5, (const byte *)buttonString);
 	_string[5].right = tmpRight;
@@ -3355,12 +3855,15 @@ const char *ScummEngine_v6::getGUIString(int stringId) {
 const char *ScummEngine::getGUIString(int stringId) {
 	InfoDialog d(this, 0);
 	int resStringId = -1;
-
+	bool isSegaCD = _game.platform == Common::kPlatformSegaCD;
 	switch (stringId) {
 	case gsPause:
-		resStringId = 4;
+		resStringId = isSegaCD ? 20 : 4;
 		break;
 	case gsRestart:
+		resStringId = isSegaCD ? 23 : 5;
+		break;
+	case gsRestartGame:
 		resStringId = 5;
 		break;
 	case gsQuitPrompt:
@@ -3499,6 +4002,24 @@ const char *ScummEngine::getGUIString(int stringId) {
 	case gsTandyMode:
 		resStringId = 46;
 		break;
+	case gsSlowFast:
+		resStringId = 22;
+		break;
+	case gsCurrentPasscode:
+		resStringId = 24;
+		break;
+	case gsEnterPasscode:
+		resStringId = 25;
+		break;
+	case gsInvalidPasscode:
+		resStringId = 26;
+		break;
+	case gsConfirmPasscode:
+		resStringId = 27;
+		break;
+	case gsTextSpeed:
+		resStringId = 28;
+		break;
 	default:
 		break;
 	}
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 289114ef2ad..3898d92d6de 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -251,7 +251,7 @@ void ScummEngine::parseEvent(Common::Event event) {
 		break;
 	case Common::EVENT_RETURN_TO_LAUNCHER:
 	case Common::EVENT_QUIT:
-		if (isUsingOriginalGUI()) {
+		if (isUsingOriginalGUI() && _game.platform != Common::kPlatformSegaCD) {
 			if (!_quitByGUIPrompt && !_mainMenuIsActive) {
 				bool exitType = (event.type == Common::EVENT_RETURN_TO_LAUNCHER);
 				// If another message banner is currently on the screen, close it
@@ -882,6 +882,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 	bool mainmenuKeyEnabled = (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
 	bool snapScrollKeyEnabled = (_game.version >= 2 && _game.version <= 4);
 	bool optionKeysEnabled = !isUsingOriginalGUI();
+	bool isSegaCD = _game.platform == Common::kPlatformSegaCD;
 
 	// In FM-TOWNS games F8 / restart is always enabled
 	if (_game.platform == Common::kPlatformFMTowns)
@@ -897,20 +898,26 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		char sliderString[256];
 		PauseToken pt;
 
-		if ((VAR_PAUSE_KEY != 0xFF && (lastKeyHit.ascii == VAR(VAR_PAUSE_KEY))) ||
-			(lastKeyHit.keycode == Common::KEYCODE_SPACE && _game.features & GF_DEMO)) {
-			// Force the cursor OFF...
-			int8 oldCursorState = _cursor.state;
-			_cursor.state = 0;
-			CursorMan.showMouse(_cursor.state > 0);
-			// "Game Paused.  Press SPACE to Continue."
-			if (_game.version > 4)
-				showBannerAndPause(0, -1, getGUIString(gsPause));
-			else
-				showOldStyleBannerAndPause(getGUIString(gsPause), 12, -1);
-
-			_cursor.state = oldCursorState;
-			return;
+		if (((VAR_PAUSE_KEY != 0xFF && (lastKeyHit.ascii == VAR(VAR_PAUSE_KEY))) ||
+			(lastKeyHit.keycode == Common::KEYCODE_SPACE && _game.features & GF_DEMO))) {
+			if (isSegaCD) {
+				if (VAR(VAR_MAINMENU_KEY) != 0)
+					showMainMenu();
+				return;
+			} else {
+				// Force the cursor OFF...
+				int8 oldCursorState = _cursor.state;
+				_cursor.state = 0;
+				CursorMan.showMouse(_cursor.state > 0);
+				// "Game Paused.  Press SPACE to Continue."
+				if (_game.version > 4)
+					showBannerAndPause(0, -1, getGUIString(gsPause));
+				else
+					showOldStyleBannerAndPause(getGUIString(gsPause), 12, -1);
+
+				_cursor.state = oldCursorState;
+				return;
+			}
 		} else if (_game.version <= 2 && lastKeyHit.keycode == Common::KEYCODE_SPACE) {
 			printMessageAndPause(getGUIString(gsPause), 0, -1, true);
 			return;
@@ -985,7 +992,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 
 		// "Text Speed  Slow  ==========  Fast"
 		if (((_game.version > 3 && _game.version < 8) || (_game.version == 8 && (_game.features & GF_DEMO)))
-			&& (lastKeyHit.ascii == '+' || lastKeyHit.ascii == '-')) {
+			&& (lastKeyHit.ascii == '+' || lastKeyHit.ascii == '-') && !isSegaCD) {
 			if (VAR_CHARINC == 0xFF)
 				return;
 
@@ -1026,7 +1033,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		}
 
 		if (_game.version <= 2 && (lastKeyHit.ascii == '+' || lastKeyHit.ascii == '-' ||
-			lastKeyHit.ascii == '>' || lastKeyHit.ascii == '<')) {
+			lastKeyHit.ascii == '>' || lastKeyHit.ascii == '<') && !isSegaCD) {
 			Common::KeyState ks = lastKeyHit;
 			byte textSpeedColor;
 
@@ -1050,7 +1057,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		}
 
 
-		if (_game.version > 4 && lastKeyHit.keycode == Common::KEYCODE_k && lastKeyHit.hasFlags(Common::KBD_CTRL)) {
+		if (_game.version > 4 && lastKeyHit.keycode == Common::KEYCODE_k && lastKeyHit.hasFlags(Common::KBD_CTRL) && !isSegaCD) {
 			showBannerAndPause(0, 120, getGUIString(gsHeap), _res->getHeapSize() / 1024);
 			return;
 		}
@@ -1066,7 +1073,12 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 
 		if (VAR_MAINMENU_KEY != 0xFF && (lastKeyHit.ascii == VAR(VAR_MAINMENU_KEY) && lastKeyHit.hasFlags(0))
 			&& _game.version > 3) {
-			showMainMenu();
+			if (isSegaCD) {
+				// We map the GMM to F5, while SPACE (which acts as our pause button) calls the original menu...
+				openMainMenuDialog();
+			} else {
+				showMainMenu();
+			}
 			return;
 		} else if (lastKeyHit.keycode == Common::KEYCODE_F5 && _game.version == 3 && _game.platform == Common::kPlatformMacintosh) {
 			// We don't have original menus for Mac versions of LOOM and INDY3, so let's just open the GMM...
@@ -1104,7 +1116,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		// The following ones serve no purpose whatsoever, but just for the sake of completeness...
 		// Also, some of these were originally mapped with the CTRL flag, but they would clash with other
 		// internal ScummVM commands, so they are instead available with the SHIFT flag.
-		if (_game.version < 7) {
+		if (_game.version < 7 && !isSegaCD) {
 			if (_game.version >= 4 && lastKeyHit.keycode == Common::KEYCODE_j && lastKeyHit.hasFlags(Common::KBD_SHIFT)) {
 				if (_game.version == 4) {
 					showOldStyleBannerAndPause(getGUIString(gsRecalJoystick), 2, 90);
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index a04c462d955..0d430f85624 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -3167,8 +3167,7 @@ bool ScummEngine::isUsingOriginalGUI() {
 
 	if (_game.platform == Common::kPlatformNES ||
 		_game.platform == Common::kPlatformPCEngine ||
-		(_game.platform == Common::kPlatformAtariST && _game.version == 2) ||
-		(_game.platform == Common::kPlatformSegaCD && _language == Common::JA_JPN))
+		(_game.platform == Common::kPlatformAtariST && _game.version == 2))
 		return false;
 
 	if (_game.heversion != 0)
@@ -3198,10 +3197,14 @@ void ScummEngine::runBootscript() {
 	}
 
 	args[0] = _bootParam;
+
 	if (_game.id == GID_MANIAC && (_game.features & GF_DEMO) && (_game.platform != Common::kPlatformC64))
 		runScript(9, 0, 0, args);
 	else
 		runScript(1, 0, 0, args);
+
+	if (_game.platform == Common::kPlatformSegaCD)
+		_scummVars[411] = _bootParam;
 }
 
 #ifdef ENABLE_HE
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 0f75920eaaf..f42df7f17cb 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -364,9 +364,12 @@ class ResourceManager;
  * GUI defines and enums.
  */
 
-#define GUI_PAGE_MAIN 0
-#define GUI_PAGE_SAVE 1
-#define GUI_PAGE_LOAD 2
+#define GUI_PAGE_MAIN         0
+#define GUI_PAGE_SAVE         1
+#define GUI_PAGE_LOAD         2
+#define GUI_PAGE_RESTART      3 // Sega CD
+#define GUI_PAGE_CODE_CONFIRM 4 // Sega CD
+#define GUI_PAGE_INVALID_CODE 5 // Sega CD
 
 #define GUI_CTRL_FIRST_SG               1
 #define GUI_CTRL_LAST_SG                9
@@ -388,6 +391,21 @@ class ResourceManager;
 #define GUI_CTRL_OUTER_BOX              26
 #define GUI_CTRL_INNER_BOX              27
 
+// Sega CD
+#define GUI_CTRL_NUMPAD_1           1
+#define GUI_CTRL_NUMPAD_2           2
+#define GUI_CTRL_NUMPAD_3           3
+#define GUI_CTRL_NUMPAD_4           4
+#define GUI_CTRL_NUMPAD_5           5
+#define GUI_CTRL_NUMPAD_6           6
+#define GUI_CTRL_NUMPAD_7           7
+#define GUI_CTRL_NUMPAD_8           8
+#define GUI_CTRL_NUMPAD_9           9
+#define GUI_CTRL_NUMPAD_0           10
+#define GUI_CTRL_RESTART_BUTTON     13
+#define GUI_CTRL_ARROW_LEFT_BUTTON  16
+#define GUI_CTRL_ARROW_RIGHT_BUTTON 17
+#define GUI_CTRL_NUMPAD_BACK        23
 
 enum GUIString {
 	gsPause = 0,
@@ -444,7 +462,13 @@ enum GUIString {
 	gsEGAMode = 52,
 	gsCGAMode = 53,
 	gsHerculesMode = 54,
-	gsTandyMode = 55
+	gsTandyMode = 55,
+	gsCurrentPasscode = 56,
+	gsEnterPasscode = 57,
+	gsConfirmPasscode = 58,
+	gsInvalidPasscode = 59,
+	gsSlowFast = 60,
+	gsRestartGame = 61
 };
 
 struct InternalGUIControl {
@@ -637,6 +661,8 @@ protected:
 	const char _checkedBox[2] = {'x', '\0'};
 	const char _arrowUp[2] = {'\x18', '\0'};
 	const char _arrowDown[2] = {'\x19', '\0'};
+	const char _arrowLeft[2] = {'\x3c', '\0'};
+	const char _arrowRight[2] = {'\x3d', '\0'};
 
 	Common::StringArray _savegameNames;
 	int _menuPage = 0;
@@ -649,6 +675,7 @@ protected:
 	char _mainMenuSpeechSlider[17];
 	char _mainMenuSfxSlider[17];
 	char _mainMenuTextSpeedSlider[17];
+	char _mainMenuSegaCDPasscode[5];
 	int _spooledMusicIsToBeEnabled = 1;
 	int _saveScriptParam = 0;
 	int _guiCursorAnimCounter = 0;
@@ -715,10 +742,14 @@ protected:
 
 	void showMainMenu();
 	virtual void setUpMainMenuControls();
+	void setUpMainMenuControlsSegaCD();
 	void drawMainMenuControls();
+	void drawMainMenuControlsSegaCD();
 	void updateMainMenuControls();
+	void updateMainMenuControlsSegaCD();
 	void drawMainMenuTitle(const char *title);
 	bool executeMainMenuOperation(int op, int mouseX, int mouseY, bool &hasLoadedState);
+	bool executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY, bool &hasLoadedState);
 	bool shouldHighlightLabelAndWait(int clickedControl);
 	void fillSavegameLabels();
 	bool canWriteGame(int slotId);


Commit: 06f352f8e4803d11f202bc1d7fbcac1c1775b419
    https://github.com/scummvm/scummvm/commit/06f352f8e4803d11f202bc1d7fbcac1c1775b419
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Fix restart prompt banner appearing for MI1 SegaCD

Changed paths:
    engines/scumm/input.cpp


diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 3898d92d6de..7531fd330cf 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -932,10 +932,13 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		restartKeyPressed |= ((_game.version < 3 || _game.version > 6) &&
 			lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.hasFlags(0));
 
-		// ...or if this is a v3 FM-Towns game, restart on F8 (the original accepted a key value of 0xFFFF8008)
+		// ...or if this is a v3 FM-Towns game, restart on F8 (the original accepted a key value of 0xFFFF8008)...
 		restartKeyPressed |= _game.platform == Common::kPlatformFMTowns && _game.version == 3 &&
 			lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.hasFlags(0);
 
+		// ...but do not allow the restart banner to appear at all, if this is MI1 SegaCD.
+		restartKeyPressed &= _game.platform != Common::kPlatformSegaCD;
+
 		if (restartKeyPressed) {
 			queryRestart();
 			return;


Commit: 19b45e2a500153ace296a65a7ab3094246d0e134
    https://github.com/scummvm/scummvm/commit/19b45e2a500153ace296a65a7ab3094246d0e134
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Fix passcode not being updated on MI1 SegaCD

Big thanks to eientei (einstein95) for the research for this commit!

Changed paths:
    engines/scumm/gfx_gui.cpp
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index a60f6dfb347..b92da508f8e 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -1746,6 +1746,15 @@ void ScummEngine::showMainMenu() {
 
 	memset(args, 0, sizeof(args));
 
+	// Run the passcode script without args to fetch the current
+	// value of the passcode, which is then stored in var 63.
+	if (_game.platform == Common::kPlatformSegaCD) {
+		int dummyArgs[16];
+		memset(dummyArgs, 0, sizeof(dummyArgs));
+
+		runScript(61, 0, 0, args);
+	}
+
 	// Generate the thumbnail, in case the game is saved
 	Graphics::createThumbnail(_savegameThumbnail);
 
@@ -2008,13 +2017,28 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 			return true;
 		} else if (_menuPage == GUI_PAGE_CODE_CONFIRM) {
 			_bootParam = atoi(_mainMenuSegaCDPasscode);
+
+			// We are running script 61 twice:
+			// - The first time we are providing it the passcode as an argument;
+			// - The second time we give no arguments, allowing var 63 to be updated.
+			// This will let us know whether we have successfully loaded a game or not.
+
+			// First time...
 			int args[16];
+			int32 prevCode = _scummVars[63];
 			memset(args, 0, sizeof(args));
 			args[0] = _bootParam;
 
 			runScript(61, 0, 0, args);
-			hasLoadedState = _scummVars[411] == _bootParam;
+
+			// Second time...
+			args[0] = 0;
+			runScript(61, 0, 0, args);
+
+			hasLoadedState = _scummVars[63] == _bootParam;
+
 			_bootParam = 0;
+
 			if (!hasLoadedState) {
 				_menuPage = GUI_PAGE_INVALID_CODE;
 				setUpMainMenuControls();
@@ -3401,7 +3425,7 @@ void ScummEngine::drawMainMenuControlsSegaCD() {
 	convertMessageToString((const byte *)getGUIString(gsCurrentPasscode), (byte *)buf, sizeof(buf));
 	drawGUIText(buf, nullptr, isJap ? 128 : 137, yConstant - 52, stringColor, false);
 
-	Common::sprintf_s(buf, sizeof(buf), "%04d", _scummVars[411]);
+	Common::sprintf_s(buf, sizeof(buf), "%04d", _scummVars[63]);
 	drawGUIText(buf, nullptr, 184, yConstant - 34, stringColor, false);
 
 	if (_menuPage != GUI_PAGE_CODE_CONFIRM && _menuPage != GUI_PAGE_LOAD) {
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 0d430f85624..a740ade7234 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -3202,9 +3202,6 @@ void ScummEngine::runBootscript() {
 		runScript(9, 0, 0, args);
 	else
 		runScript(1, 0, 0, args);
-
-	if (_game.platform == Common::kPlatformSegaCD)
-		_scummVars[411] = _bootParam;
 }
 
 #ifdef ENABLE_HE


Commit: beb65bc90266e0b25e7048109b36876918186d9b
    https://github.com/scummvm/scummvm/commit/beb65bc90266e0b25e7048109b36876918186d9b
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Fix warnings

Changed paths:
    engines/scumm/gfx_gui.cpp


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index b92da508f8e..581d72cc015 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -2025,7 +2025,6 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 
 			// First time...
 			int args[16];
-			int32 prevCode = _scummVars[63];
 			memset(args, 0, sizeof(args));
 			args[0] = _bootParam;
 
@@ -2107,7 +2106,7 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 	case GUI_CTRL_NUMPAD_BACK:
 	{
 		int inputNum = op == GUI_CTRL_NUMPAD_0 ? 0 : op;
-		int curIdx;
+		uint curIdx;
 		for (curIdx = 0; curIdx < sizeof(_mainMenuSegaCDPasscode); curIdx++) {
 			if (_mainMenuSegaCDPasscode[curIdx] == '\0')
 				break;
@@ -3429,7 +3428,7 @@ void ScummEngine::drawMainMenuControlsSegaCD() {
 	drawGUIText(buf, nullptr, 184, yConstant - 34, stringColor, false);
 
 	if (_menuPage != GUI_PAGE_CODE_CONFIRM && _menuPage != GUI_PAGE_LOAD) {
-		for (int i = 0; i < sizeof(_mainMenuSegaCDPasscode); i++) {
+		for (uint i = 0; i < sizeof(_mainMenuSegaCDPasscode); i++) {
 			_mainMenuSegaCDPasscode[i] = '\0';
 		}
 	}


Commit: f463d032d8f411de611f9443685fe6a0d7183dde
    https://github.com/scummvm/scummvm/commit/f463d032d8f411de611f9443685fe6a0d7183dde
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Improve readability

Changed paths:
    engines/scumm/gfx_gui.cpp
    engines/scumm/input.cpp
    engines/scumm/scumm.h


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index 581d72cc015..26c0d499c1a 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -2105,7 +2105,7 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 	case GUI_CTRL_NUMPAD_9:
 	case GUI_CTRL_NUMPAD_BACK:
 	{
-		int inputNum = op == GUI_CTRL_NUMPAD_0 ? 0 : op;
+		int inputNum = (op == GUI_CTRL_NUMPAD_0) ? 0 : op;
 		uint curIdx;
 		for (curIdx = 0; curIdx < sizeof(_mainMenuSegaCDPasscode); curIdx++) {
 			if (_mainMenuSegaCDPasscode[curIdx] == '\0')
@@ -2122,7 +2122,7 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 
 			if (curIdx >= 3) { // Last digit
 				updateMainMenuControls();
-				ScummEngine::drawDirtyScreenParts();
+				drawDirtyScreenParts();
 
 				waitForTimer(120);
 
@@ -2869,9 +2869,7 @@ void ScummEngine::setUpMainMenuControlsSegaCD() {
 								235,
 								yConstant + 34,
 								_uncheckedBox, 1, 1);
-	}
-
-	if (_menuPage == GUI_PAGE_RESTART || _menuPage == GUI_PAGE_CODE_CONFIRM) {
+	} else if (_menuPage == GUI_PAGE_RESTART || _menuPage == GUI_PAGE_CODE_CONFIRM) {
 		// OK button
 		setUpInternalGUIControl(GUI_CTRL_OK_BUTTON,
 								getBannerColor(4),
@@ -2903,9 +2901,7 @@ void ScummEngine::setUpMainMenuControlsSegaCD() {
 								isJap ? 291 : 257,
 								yConstant + 43,
 								getGUIString(gsCancel), 1, 1);
-	}
-
-	if (_menuPage == GUI_PAGE_LOAD) {
+	} else if (_menuPage == GUI_PAGE_LOAD) {
 		Common::String numbers[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
 
 		setUpInternalGUIControl(GUI_CTRL_NUMPAD_0,
@@ -3616,13 +3612,14 @@ void ScummEngine::updateMainMenuControls() {
 void ScummEngine::updateMainMenuControlsSegaCD() {
 	char msg[256];
 	int yConstant = _virtscr[kMainVirtScreen].topline + (_virtscr[kMainVirtScreen].h / 2);
-	bool isJap = _language == Common::JA_JPN;
+	bool isJap = (_language == Common::JA_JPN);
 
 	if (_menuPage == GUI_PAGE_MAIN) {
+		// Fill the slider string of symbols shaped like a "=" character
 		strncpy(_mainMenuTextSpeedSlider, "\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a\x3a", sizeof(_mainMenuTextSpeedSlider));
 
 		if (VAR_CHARINC != 0xFF)
-			_mainMenuTextSpeedSlider[9 - VAR(VAR_CHARINC)] = '\x3b';
+			_mainMenuTextSpeedSlider[9 - VAR(VAR_CHARINC)] = '\x3b'; // The cursor of the slider
 
 		_internalGUIControls[GUI_CTRL_TEXT_SPEED_SLIDER].label = _mainMenuTextSpeedSlider;
 
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 7531fd330cf..df73488699a 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -898,7 +898,7 @@ void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
 		char sliderString[256];
 		PauseToken pt;
 
-		if (((VAR_PAUSE_KEY != 0xFF && (lastKeyHit.ascii == VAR(VAR_PAUSE_KEY))) ||
+		if ((VAR_PAUSE_KEY != 0xFF && (lastKeyHit.ascii == VAR(VAR_PAUSE_KEY)) ||
 			(lastKeyHit.keycode == Common::KEYCODE_SPACE && _game.features & GF_DEMO))) {
 			if (isSegaCD) {
 				if (VAR(VAR_MAINMENU_KEY) != 0)
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index f42df7f17cb..79621b0340e 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -468,7 +468,7 @@ enum GUIString {
 	gsConfirmPasscode = 58,
 	gsInvalidPasscode = 59,
 	gsSlowFast = 60,
-	gsRestartGame = 61
+	gsRestartGame = 61,
 };
 
 struct InternalGUIControl {


Commit: 87625eb23e47867444dbd166ddb6bbb15705693b
    https://github.com/scummvm/scummvm/commit/87625eb23e47867444dbd166ddb6bbb15705693b
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Use strnlen to measure current passcode length

Changed paths:
    engines/scumm/gfx_gui.cpp


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index 26c0d499c1a..3a539ed44c6 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -2106,11 +2106,7 @@ bool ScummEngine::executeMainMenuOperationSegaCD(int op, int mouseX, int mouseY,
 	case GUI_CTRL_NUMPAD_BACK:
 	{
 		int inputNum = (op == GUI_CTRL_NUMPAD_0) ? 0 : op;
-		uint curIdx;
-		for (curIdx = 0; curIdx < sizeof(_mainMenuSegaCDPasscode); curIdx++) {
-			if (_mainMenuSegaCDPasscode[curIdx] == '\0')
-				break;
-		}
+		uint curIdx = strnlen(_mainMenuSegaCDPasscode, sizeof(_mainMenuSegaCDPasscode));
 
 		if (op == GUI_CTRL_NUMPAD_BACK) {
 			if (curIdx > 0) {


Commit: 76f4371f4517f633b008975c4dca53f3a69145e6
    https://github.com/scummvm/scummvm/commit/76f4371f4517f633b008975c4dca53f3a69145e6
Author: AndywinXp (andywinxp at gmail.com)
Date: 2022-12-13T18:40:11+01:00

Commit Message:
SCUMM: GUI: Handle numbers strings with const chars instead of String objects

Changed paths:
    engines/scumm/gfx_gui.cpp


diff --git a/engines/scumm/gfx_gui.cpp b/engines/scumm/gfx_gui.cpp
index 3a539ed44c6..24da7c2b440 100644
--- a/engines/scumm/gfx_gui.cpp
+++ b/engines/scumm/gfx_gui.cpp
@@ -2898,7 +2898,7 @@ void ScummEngine::setUpMainMenuControlsSegaCD() {
 								yConstant + 43,
 								getGUIString(gsCancel), 1, 1);
 	} else if (_menuPage == GUI_PAGE_LOAD) {
-		Common::String numbers[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
+		const char numbers[10][2] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
 
 		setUpInternalGUIControl(GUI_CTRL_NUMPAD_0,
 								getBannerColor(4),
@@ -2913,7 +2913,7 @@ void ScummEngine::setUpMainMenuControlsSegaCD() {
 								yConstant + 43,
 								211,
 								yConstant + 57,
-								numbers[0].c_str(), 1, 1);
+								numbers[0], 1, 1);
 
 		setUpInternalGUIControl(GUI_CTRL_NUMPAD_BACK,
 								getBannerColor(4),
@@ -2945,7 +2945,7 @@ void ScummEngine::setUpMainMenuControlsSegaCD() {
 										yConstant + 29 - row * 14,
 										211 + col * 14,
 										yConstant + 43 - row * 14,
-										numbers[row * 3 + (col + 1)].c_str(), 1, 1);
+										numbers[row * 3 + (col + 1)], 1, 1);
 			}
 		}
 	}




More information about the Scummvm-git-logs mailing list