From ddbc1a8aa9963fdfa4e7eb9398e4cad6ba17e08b Mon Sep 17 00:00:00 2001
From: tomcw <tomcw@users.noreply.github.com>
Date: Sat, 18 Jan 2020 16:42:49 +0000
Subject: [PATCH] ProcessCmdLine() . Display MessageBox with all unsupported
 commands that were passed in. . MessageBox yes/no response will either
 continue or exit AppleWin. Changed -left-control-alt-buttons to
 -left-alt-control-buttons (for consistency with -right-alt-control-buttons)
 (#743) . The MessageBox will now confirm whether you typed it correctly or
 not. Fixed DHIRESON/OFF typo in comment!

---
 source/Applewin.cpp | 32 +++++++++++++++++++++++++++-----
 source/Memory.cpp   |  4 ++--
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/source/Applewin.cpp b/source/Applewin.cpp
index 8b972a94..58be97f6 100644
--- a/source/Applewin.cpp
+++ b/source/Applewin.cpp
@@ -1232,7 +1232,7 @@ static void ExceptionHandler(const char* pError)
 
 //---------------------------------------------------------------------------
 
-static void ProcessCmdLine(LPSTR lpCmdLine);
+static bool ProcessCmdLine(LPSTR lpCmdLine);
 static void GetAppleWinVersion(void);
 static void OneTimeInitialization(HINSTANCE passinstance);
 static void RepeatInitialization(void);
@@ -1300,7 +1300,9 @@ static CmdLine g_cmdLine;
 
 int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
 {
-	ProcessCmdLine(lpCmdLine);
+	if (!ProcessCmdLine(lpCmdLine))
+		return 0;
+
 	GetAppleWinVersion();
 	OneTimeInitialization(passinstance);
 
@@ -1357,9 +1359,10 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
 	return 0;
 }
 
-static void ProcessCmdLine(LPSTR lpCmdLine)
+static bool ProcessCmdLine(LPSTR lpCmdLine)
 {
 	const std::string strCmdLine(lpCmdLine);		// Keep a copy for log ouput
+	std::string strUnsupported;
 
 	while (*lpCmdLine)
 	{
@@ -1576,12 +1579,12 @@ static void ProcessCmdLine(LPSTR lpCmdLine)
 		{
 			JoySetHookAltKeys(false);
 		}
-		else if (strcmp(lpCmdLine, "-left-control-alt-buttons") == 0)
+		else if (strcmp(lpCmdLine, "-left-alt-control-buttons") == 0)	// GH#743
 		{
 			JoySetButtonVirtualKey(0, VK_CONTROL);
 			JoySetButtonVirtualKey(1, VK_MENU);
 		}
-		else if (strcmp(lpCmdLine, "-right-alt-control-buttons") == 0)
+		else if (strcmp(lpCmdLine, "-right-alt-control-buttons") == 0)	// GH#743
 		{
 			JoySetButtonVirtualKey(0, VK_MENU | KF_EXTENDED);
 			JoySetButtonVirtualKey(1, VK_CONTROL | KF_EXTENDED);
@@ -1683,12 +1686,31 @@ static void ProcessCmdLine(LPSTR lpCmdLine)
 		else	// unsupported
 		{
 			LogFileOutput("Unsupported arg: %s\n", lpCmdLine);
+			strUnsupported += lpCmdLine;
+			strUnsupported += "\n";
 		}
 
 		lpCmdLine = lpNextArg;
 	}
 
 	LogFileOutput("CmdLine: %s\n",  strCmdLine.c_str());
+
+	bool ok = true;
+
+	if (!strUnsupported.empty())
+	{
+		std::string msg("Unsupported commands:\n\n");
+		msg += strUnsupported;
+		msg += "\n";
+		msg += "Continue running AppleWin?";
+		int res = MessageBox(GetDesktopWindow(),		// NB. g_hFrameWindow is not yet valid
+				msg.c_str(),
+				"AppleWin Command Line",
+				MB_ICONSTOP | MB_SETFOREGROUND | MB_YESNO);
+		ok = (res != IDNO);
+	}
+
+	return ok;
 }
 
 static void GetAppleWinVersion(void)
diff --git a/source/Memory.cpp b/source/Memory.cpp
index bf4c96a8..591d9b62 100644
--- a/source/Memory.cpp
+++ b/source/Memory.cpp
@@ -108,8 +108,8 @@ VIDEO SOFT SWITCHES
  $C055   R/W     PAGE2ON         Select page2 display (or aux video memory)
  $C056   R/W     HIRESOFF        Select low resolution graphics
  $C057   R/W     HIRESON         Select high resolution graphics
- $C05E   R/W     DHIRESOFF       Select single (7M) resolution graphics
- $C05F   R/W     DHIRESON        Select double (14M) resolution graphics
+ $C05E   R/W     DHIRESON        Select double (14M) resolution graphics
+ $C05F   R/W     DHIRESOFF       Select single (7M) resolution graphics
 
 SOFT SWITCH STATUS FLAGS
  $C010   R7      AKD             1=key pressed   0=keys free    (clears strobe)