Re: [hatari-devel] Recent Hatari change problems

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 04/17/2018 09:33 AM, Thomas Huth wrote:
Am Tue, 17 Apr 2018 00:17:16 +0300
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
On 04/16/2018 01:53 AM, Eero Tamminen wrote:
On 04/15/2018 12:33 PM, Thomas Huth wrote:
schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:
[...]
Giving a program to Hatari enables automatically GEMDOS HD
emulation for the directory where that program is (Hatari
autostarting would be pretty stupid feature without that).

Not sure, but I think this automatic enablement is bypassed in
"--tos none" mode since the program is not loaded by TOS, but by
Hatari here.

Enabling is done in options.c, not TOS handling code.

(And I tested it, -d is not needed.)

Sorry, my mistake, I was confused by my own GEMDOS tracing
(I forgot that it enables GEMDOS emulation partially now).

Is there some particular reason why your commit disabled
GEMDOS HD enabling in options.c when giving program name
after --tos none option:
https://hg.tuxfamily.org/mercurialroot/hatari/hatari/rev/0db1fad64cf3
?

It was simply not necessary. And for the buserror tester, I needed a
GEMDOS hd directory that is different from the PRG directory - since
this tester creates a file, and the file should not be put into the
source repository directory.

But we can change that - you're right, it'd be more consistent. But
then you likely have to adapt the tests/buserror/run_tests.sh script
accordingly, too.

Logging needs additional changes too.

I though it best to change all options.c logging to respect log
levels, instead of logging being a flag for option parsing. See
attached patch.

(Before commit I need to split the program name parsing change,
but I think current megapatch is OK for review.)


Btw. I added Halt dialog skipping when --run-vbls is used.  You
may want to add video driver check there too.

(Bus error tests will halt if user has "--protect-hd yes" option
saved to Hatari config file.)


	- Eero
diff -r 8a1eff5a73d6 src/includes/options.h
--- a/src/includes/options.h	Thu Apr 19 00:25:34 2018 +0300
+++ b/src/includes/options.h	Thu Apr 19 01:05:46 2018 +0300
@@ -19,7 +19,7 @@
 extern bool Opt_IsAtariProgram(const char *path);
 extern bool Opt_ShowError(unsigned int optid, const char *value, const char *error);
 extern int Opt_ValueAlignMinMax(int value, int align, int min, int max);
-extern bool Opt_ParseParameters(int argc, const char * const argv[], bool verbose);
+extern bool Opt_ParseParameters(int argc, const char * const argv[]);
 extern char *Opt_MatchOption(const char *text, int state);
 
 #endif /* HATARI_OPTIONS_H */
diff -r 8a1eff5a73d6 src/change.c
--- a/src/change.c	Thu Apr 19 00:25:34 2018 +0300
+++ b/src/change.c	Thu Apr 19 01:05:46 2018 +0300
@@ -480,7 +480,7 @@
 	/* get configuration changes */
 	current = ConfigureParams;
 	ConfigureParams.Screen.bFullScreen = bInFullScreen;
-	bOK = Opt_ParseParameters(argc, argv, false);
+	bOK = Opt_ParseParameters(argc, argv);
 
 	/* Check if reset is required and ask user if he really wants to continue */
 	if (bOK && Change_DoNeedReset(&current, &ConfigureParams)
diff -r 8a1eff5a73d6 src/debug/debugui.c
--- a/src/debug/debugui.c	Thu Apr 19 00:25:34 2018 +0300
+++ b/src/debug/debugui.c	Thu Apr 19 01:05:46 2018 +0300
@@ -364,7 +364,7 @@
 	current = ConfigureParams;
 
 	/* Parse and apply options */
-	if (Opt_ParseParameters(argc, (const char * const *)argv, true))
+	if (Opt_ParseParameters(argc, (const char * const *)argv))
 	{
 		ConfigureParams.Screen.bFullScreen = false;
 		Change_CopyChangedParamsToConfiguration(&current, &ConfigureParams, false);
diff -r 8a1eff5a73d6 src/main.c
--- a/src/main.c	Thu Apr 19 00:25:34 2018 +0300
+++ b/src/main.c	Thu Apr 19 01:05:46 2018 +0300
@@ -900,7 +900,7 @@
 	Main_LoadInitialConfig();
 
 	/* Check for any passed parameters */
-	if (!Opt_ParseParameters(argc, (const char * const *)argv, false))
+	if (!Opt_ParseParameters(argc, (const char * const *)argv))
 	{
 		return 1;
 	}
diff -r 8a1eff5a73d6 src/options.c
--- a/src/options.c	Thu Apr 19 00:25:34 2018 +0300
+++ b/src/options.c	Thu Apr 19 01:05:46 2018 +0300
@@ -54,7 +54,6 @@
 
 int ConOutDevice = CONOUT_DEVICE_NONE; /* device number for xconout device to track */
 
-static bool bForceLog;     /* Always print option parsing log messages? */
 static bool bNoSDLParachute, bBiosIntercept;
 
 /*  List of supported options. */
@@ -482,14 +481,15 @@
 
 /**
  * We can not use Log_Printf during option parsing yet, since the
- * log file has not been opened yet. So we use our own debug print
+ * Log_* functionality (log levels & log file) are initialized only
+ * after options have been parsed. So we use our own debug print
  * function here.
  */
-static void Opt_Log(const char *psFormat, ...)
+static void Opt_Log(LOGTYPE nType, const char *psFormat, ...)
 {
 	va_list argptr;
 
-	if (ConfigureParams.Log.nTextLogLevel != LOG_DEBUG && !bForceLog)
+	if (nType > (LOGTYPE) ConfigureParams.Log.nTextLogLevel)
 		return;
 
 	va_start(argptr, psFormat);
@@ -948,21 +948,14 @@
  * Filename can be a disk image or Atari program.
  * Return false if it's none of these.
  */
-static bool Opt_HandleArgument(const char *path)
+static bool Opt_HandleArgument(const char *origpath)
 {
+	const char *prgname = NULL, *path = origpath;
 	char *dir = NULL;
 
 	/* Atari program? */
 	if (Opt_IsAtariProgram(path))
 	{
-		const char *prgname;
-
-		if (!bUseTos)
-		{
-			TOS_SetTestPrgName(path);
-			return true;
-		}
-
 		prgname = strrchr(path, PATHSEP);
 		if (prgname)
 		{
@@ -975,13 +968,21 @@
 			dir = strdup(Paths_GetWorkingDir());
 			prgname = path;
 		}
-		Log_Printf(LOG_INFO, "ARG = autostart program: %s\n", prgname);
+		if (bUseTos)
+		{
+			Opt_Log(LOG_INFO, "ARG = autostart program: %s\n", prgname);
 
-		/* after above, dir should point to valid dir,
-		 * then make sure that given program from that
-		 * dir will be started.
-		 */
-		INF_SetAutoStart(prgname, OPT_AUTOSTART);
+			/* after above, dir should point to valid dir,
+			 * then make sure that given program from that
+			 * dir will be started.
+			 */
+			INF_SetAutoStart(prgname, OPT_AUTOSTART);
+		}
+	}
+	if (!bUseTos && !prgname)
+	{
+		Opt_Log(LOG_ERROR, "No program to run instead of TOS!\n");
+		exit(1);
 	}
 	if (dir)
 	{
@@ -991,7 +992,7 @@
 	/* GEMDOS HDD directory (as argument, or for the Atari program)? */
 	if (File_DirExists(path))
 	{
-		Log_Printf(LOG_INFO, "ARG = GEMDOS HD dir: %s\n", path);
+		Opt_Log(LOG_INFO, "ARG = GEMDOS HD dir: %s\n", path);
 		if (Opt_StrCpy(OPT_HARDDRIVE, false, ConfigureParams.HardDisk.szHardDiskDirectories[0],
 			       path, sizeof(ConfigureParams.HardDisk.szHardDiskDirectories[0]),
 			       &ConfigureParams.HardDisk.bUseHardDiskDirectories)
@@ -1004,6 +1005,10 @@
 		{
 			free(dir);
 		}
+		if (!bUseTos)
+		{
+			TOS_SetTestPrgName(origpath);
+		}
 		return true;
 	}
 	else
@@ -1011,7 +1016,7 @@
 		if (dir)
 		{
 			/* if dir is set, it should be valid... */
-			Log_Printf(LOG_ERROR, "Given atari program path '%s' doesn't exist (anymore?)!\n", dir);
+			Opt_Log(LOG_ERROR, "Given atari program path '%s' doesn't exist (anymore?)!\n", dir);
 			free(dir);
 			exit(1);
 		}
@@ -1020,7 +1025,7 @@
 	/* disk image? */
 	if (Floppy_SetDiskFileName(0, path, NULL))
 	{
-		Log_Printf(LOG_INFO, "ARG = floppy image: %s\n", path);
+		Opt_Log(LOG_INFO, "ARG = floppy image: %s\n", path);
 		ConfigureParams.HardDisk.bBootFromHardDisk = false;
 		bLoadAutoSave = false;
 		return true;
@@ -1033,7 +1038,7 @@
  * parse all Hatari command line options and set Hatari state accordingly.
  * Returns true if everything was OK, false otherwise.
  */
-bool Opt_ParseParameters(int argc, const char * const argv[], bool verbose)
+bool Opt_ParseParameters(int argc, const char * const argv[])
 {
 	int ncpu, skips, zoom, planes, cpuclock, threshold, memsize, port, freq, temp, drive;
 	const char *errstr, *str;
@@ -1044,8 +1049,6 @@
 	bLoadMemorySave = false;
 	bLoadAutoSave = ConfigureParams.Memory.bAutoSave;
 
-	bForceLog = verbose;
-
 	for(i = 1; i < argc; i++)
 	{
 		/* last argument can be a non-option */
@@ -1076,7 +1079,18 @@
 			break;
 
 		case OPT_AUTOSTART:
-			if (!(ok = INF_SetAutoStart(argv[++i], OPT_AUTOSTART)))
+			i++;
+			if (!bUseTos)
+			{
+				if (Opt_IsAtariProgram(argv[i]))
+				{
+					TOS_SetTestPrgName(argv[i]);
+					break;
+				}
+				return Opt_ShowError(OPT_AUTOSTART, argv[i],
+						     "With '--tos none' --auto value must be host (not Atari) path for Atari program");
+			}
+			if (!(ok = INF_SetAutoStart(argv[i], OPT_AUTOSTART)))
 			{
 				return Opt_ShowError(OPT_AUTOSTART, argv[i], "Invalid drive and/or path specified for autostart program");
 			}
@@ -1163,7 +1177,7 @@
 			}
 			else if (skips > 8)
 			{
-				Log_Printf(LOG_WARN, "Extravagant frame skip value %d!\n", skips);
+				Opt_Log(LOG_WARN, "Extravagant frame skip value %d!\n", skips);
 			}
 			ConfigureParams.Screen.nFrameSkips = skips;
 			break;
@@ -1174,7 +1188,7 @@
 			{
 				return Opt_ShowError(OPT_SLOWDOWN, argv[i], "Invalid VBL wait slowdown multiplier");
 			}
-			Opt_Log("Slow down host VBL wait by factor of %d.\n", val);
+			Opt_Log(LOG_INFO, "Slow down host VBL wait by factor of %d.\n", val);
 			break;
 
 		case OPT_MOUSE_WARP:
@@ -1203,7 +1217,7 @@
 			default:
 				return Opt_ShowError(OPT_FORCEBPP, argv[i], "Invalid bit depth");
 			}
-			Opt_Log("Hatari window BPP = %d.\n", planes);
+			Opt_Log(LOG_INFO, "Hatari window BPP = %d.\n", planes);
 			ConfigureParams.Screen.nForceBpp = planes;
 			break;
 
@@ -1232,7 +1246,7 @@
 				return Opt_ShowError(OPT_SPEC512, argv[i],
 						     "Invalid palette writes per line threshold for Spec512");
 			}
-			Opt_Log("Spec512 threshold = %d palette writes per line.\n", threshold);
+			Opt_Log(LOG_INFO, "Spec512 threshold = %d palette writes per line.\n", threshold);
 			ConfigureParams.Screen.nSpec512Threshold = threshold;
 			break;
 
@@ -1327,7 +1341,7 @@
 				return Opt_ShowError(OPT_AVIRECORD_FPS, argv[i],
 							"Invalid frame rate for avi recording");
 			}
-			Opt_Log("AVI recording FPS = %d.\n", val);
+			Opt_Log(LOG_INFO, "AVI recording FPS = %d.\n", val);
 			ConfigureParams.Video.AviRecordFps = val;
 			break;
 
@@ -1928,7 +1942,7 @@
 				ConfigureParams.Sound.nPlaybackFreq = freq;
 				ConfigureParams.Sound.bEnableSound = true;
 			}
-			Opt_Log("Sound %s, frequency = %d.\n",
+			Opt_Log(LOG_INFO, "Sound %s, frequency = %d.\n",
 			        ConfigureParams.Sound.bEnableSound ? "ON" : "OFF",
 			        ConfigureParams.Sound.nPlaybackFreq);
 			break;
@@ -1942,7 +1956,7 @@
 				{
 					return Opt_ShowError(OPT_SOUNDBUFFERSIZE, argv[i], "Unsupported sound buffer size");
 				}
-			Opt_Log("SDL sound buffer size = %d ms.\n", temp);
+			Opt_Log(LOG_INFO, "SDL sound buffer size = %d ms.\n", temp);
 			ConfigureParams.Sound.SdlAudioBufferSize = temp;
 			break;
 
@@ -1975,12 +1989,12 @@
 			if (ExceptionDebugMask)
 			{
 				ExceptionDebugMask = EXCEPT_NONE;
-				Opt_Log("Exception debugging disabled.\n");
+				Opt_Log(LOG_WARN, "Exception debugging disabled.\n");
 			}
 			else
 			{
 				ExceptionDebugMask = ConfigureParams.Debugger.nExceptionDebugMask;
-				Opt_Log("Exception debugging enabled (0x%x).\n", ExceptionDebugMask);
+				Opt_Log(LOG_WARN, "Exception debugging enabled (0x%x).\n", ExceptionDebugMask);
 			}
 			break;
 
@@ -2002,14 +2016,14 @@
 				/* already enabled, change run-time config */
 				int oldmask = ExceptionDebugMask;
 				ExceptionDebugMask = ConfigureParams.Debugger.nExceptionDebugMask;
-				Opt_Log("Exception debugging changed (0x%x -> 0x%x).\n",
+				Opt_Log(LOG_WARN, "Exception debugging changed (0x%x -> 0x%x).\n",
 				        oldmask, ExceptionDebugMask);
 			}
 			break;
 
 		case OPT_BIOSINTERCEPT:
 			ok = Opt_Bool(argv[++i], OPT_BIOSINTERCEPT, &bBiosIntercept);
-			Opt_Log("XBIOS 11/20/255 Hatari versions %sabled: "
+			Opt_Log(LOG_INFO, "XBIOS 11/20/255 Hatari versions %sabled: "
 			        "Dbmsg(), Scrdmp(), HatariControl().\n",
 			        bBiosIntercept ? "en" : "dis");
 			XBios_EnableCommands(bBiosIntercept);
@@ -2022,12 +2036,12 @@
 			{
 				return Opt_ShowError(OPT_CONOUT, argv[i], "Invalid console device vector number");
 			}
-			Opt_Log("Xcounout device %d vector redirection enabled.\n", ConOutDevice);
+			Opt_Log(LOG_INFO, "Xcounout device %d vector redirection enabled.\n", ConOutDevice);
 			break;
 
 		case OPT_NATFEATS:
 			ok = Opt_Bool(argv[++i], OPT_NATFEATS, &ConfigureParams.Log.bNatFeats);
-			Opt_Log("Native Features %s.\n", ConfigureParams.Log.bNatFeats ? "enabled" : "disabled");
+			Opt_Log(LOG_INFO, "Native Features %s.\n", ConfigureParams.Log.bNatFeats ? "enabled" : "disabled");
 			break;
 
 		case OPT_PARACHUTE:
@@ -2116,7 +2130,7 @@
 
 		case OPT_RUNVBLS:
 			val = atoi(argv[++i]);
-			Opt_Log("Exit after %d VBLs.\n", val);
+			Opt_Log(LOG_INFO, "Exit after %d VBLs.\n", val);
 			Main_SetRunVBLs(val);
 			break;
 		       
diff -r 8a1eff5a73d6 tests/buserror/run_test.sh
--- a/tests/buserror/run_test.sh	Thu Apr 19 00:25:34 2018 +0300
+++ b/tests/buserror/run_test.sh	Thu Apr 19 01:05:46 2018 +0300
@@ -13,7 +13,7 @@
 
 width=$2
 machine=$3
-basedir=$(dirname $0)
+basedir=$(realpath $(dirname $0))
 testdir=$(mktemp -d)
 
 case "$machine" in
@@ -29,8 +29,14 @@
 export SDL_VIDEODRIVER=dummy
 export SDL_AUDIODRIVER=dummy
 
+cd $testdir
+# temporary directory is needed to have something writable at build time.
+# run tester from same directory, because that will automatically be mounted
+# as C:
+ln -s $basedir/buserr_$width.prg
+
 HOME="$testdir" $hatari --log-level fatal --sound off --machine $machine \
-	--tos none --fast-forward on -d $testdir "$basedir/buserr_$width.prg" \
+	--tos none --fast-forward on --run-vbls 500 "buserr_$width.prg" \
 	2> $testdir/stderr.txt > $testdir/stdout.txt
 exitstat=$?
 if [ $exitstat -ne 0 ]; then
diff -r 8a1eff5a73d6 tests/natfeats/run_test.sh
--- a/tests/natfeats/run_test.sh	Thu Apr 19 00:25:34 2018 +0300
+++ b/tests/natfeats/run_test.sh	Thu Apr 19 01:05:46 2018 +0300
@@ -19,7 +19,7 @@
 export SDL_AUDIODRIVER=dummy
 
 HOME="$testdir" $hatari --log-level fatal --sound off --fast-forward on --tos none \
-	--natfeats on -d "$basedir" --run-vbls 500 $* "$basedir/nf_vbcc.tos" \
+	--natfeats on --protect-hd on --run-vbls 500 $* "$basedir/nf_vbcc.tos" \
 	2>&1 | sed "s/^Hatari v.*/Hatari v/" > "$testdir/out.txt"
 exitstat=$?
 if [ $exitstat -ne 0 ]; then
diff -r 8a1eff5a73d6 tests/xbios/run_test.sh
--- a/tests/xbios/run_test.sh	Thu Apr 19 00:25:34 2018 +0300
+++ b/tests/xbios/run_test.sh	Thu Apr 19 01:05:46 2018 +0300
@@ -24,7 +24,8 @@
 export SDL_AUDIODRIVER=dummy
 
 HOME="$testdir" $hatari --log-level fatal --sound off --cpuclock 32 \
-	--tos none -d "$testdir" --bios-intercept on $* "$basedir/xbiostst.prg" \
+	--tos none --bios-intercept on --protect-hd on --run-vbls 500 \
+	$* "$basedir/xbiostst.prg" \
 	2> "$testdir/out.txt" << EOF
 c
 c


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/