Re: [hatari-devel] Autostart support for more options |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Autostart support for more options
- From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
- Date: Mon, 2 Jun 2025 23:46:43 +0300
- Dkim-filter: OpenDKIM Filter v2.11.0 smtp.dnamail.fi 9638A2113E23
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=helsinkinet.fi; s=2025-03; t=1748897208; bh=k2u3vTOClnVKVxhDJ7Tu2rdmAqx97zRmDYiHi6t7Kro=; h=Date:Subject:To:References:From:In-Reply-To:From; b=h1GOmAbAnyu7iZfAJXpeuwGUk2JayFNif3XIzXS1otj8hXkl7ZWoITC+ckbYwgYyr wtd81NK97k1/MpWzQ0tsm7I0RtI8PYNexEbgF0sOyjGTrCIKxkb/4ZLsXJtSyE52fj q1pyihnsnCW31Dkr8+B6aZvVYLQ3gnOtFkaFSHg87nrXMo3b55jnS4f6VmP4rbhgVE WkNJl237TAcghBvkjjqHqBU7qssPK7m7NqqF4cx1r2l2ByQIEIgPNjKyOyKq7usQr9 XjsmtohkmXGKqtX+nohdZNE+esWj5s8D5HbNv8O6Pccc71lH6Uq1MnRtyIUjyRfIdg 79DX979T5LIFQ==
Hi,
On 2.6.2025 0.22, Nicolas Pomarède wrote:
the patch doesn't look too intrusive, but as a release date is close, I
think what could make the difference to include it now or later is
whether this patch can be extensively tested by several people (with
"real life" situations) before 2.6 is released ?
If so, then it might be possible to include it, but if not I'd rather
postpone it for later (whether it's 2.6.1 or 2.7).
I'm starting to lean on it coming later, because:
* there are additional options where support for optional autostart
prefix would make sense, i.e. need for more testing + documentation, and
* due to the still open question of how much there's need to get these
actions closer to program start than what the current patch does, and
whether it's even possible to (reliably) improve on that
Attached is updated first patch for the most relevant autostartable
options, and another patch for adding that support for few additional,
less relevant options.
Btw. I'm thinking that it would make sense also for AVI recording.
Re-recording the same TOS boot sequence is just waste of disk space,
when recording could be enabled just before the program that one is
interested about, is to start...
Personnaly I'd rather include it fully tested in 2.6.1 (if such release
should exist) than adding it now to 2.6 and realize later that not
everything is working (because doing a 2.6.1 release just for this would
be time consuming).
So, who's volunteering to test this a lot ?
I'm going to test few of them extensively (debugger commands + tracing +
exceptions), and cursorily at least most of the rest.
- Eero
From 5a7fdf53528adc0884dbe4e0cac268547ecda0bf Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Mon, 2 Jun 2025 23:39:29 +0300
Subject: [PATCH 2/2] Support autostart prefix for more more options
Rest of options taking integer parameter, where post-poning
them until autostart processing can make sense.
---
src/debug/console.c | 15 +++++++++++----
src/debug/console.h | 3 ++-
src/includes/inffile.h | 3 +++
src/inffile.c | 22 ++++++++++++++++++++++
src/options.c | 32 +++++++++++++++++++++++++++-----
5 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/src/debug/console.c b/src/debug/console.c
index 3ae874b6..90bd1624 100644
--- a/src/debug/console.c
+++ b/src/debug/console.c
@@ -1,7 +1,7 @@
/*
* Hatari - console.c
*
- * Copyright (C) 2012-2015 by Eero Tamminen
+ * Copyright (C) 2012-2025 by Eero Tamminen
*
* This file is distributed under the GNU General Public License, version 2
* or at your option any later version. Read the file gpl.txt for details.
@@ -30,19 +30,25 @@ static int con_dev = CONOUT_DEVICE_NONE;
static bool con_trace;
/**
- * Set which Atari xconout device output goes to host console.
* Returns true for valid device values (0-7), false otherwise
*/
-bool Console_SetDevice(int dev)
+bool Console_Validate(int dev)
{
if (dev < 0 || dev > 7) {
return false;
}
+ return true;
+}
+
+/**
+ * Set which Atari xconout device output goes to host console.
+ */
+void Console_SetDevice(int dev)
+{
if (con_dev == CONOUT_DEVICE_NONE) {
ConOutDevices++;
}
con_dev = dev;
- return true;
}
/**
@@ -231,6 +237,7 @@ void Console_Check(void)
if (con_trace) {
dev = 2;
} else {
+ assert(Console_Validate(con_dev));
dev = con_dev;
}
/* xconout vector for requested device? */
diff --git a/src/debug/console.h b/src/debug/console.h
index ae4845e0..39e3c63b 100644
--- a/src/debug/console.h
+++ b/src/debug/console.h
@@ -10,7 +10,8 @@
extern int ConOutDevices;
-extern bool Console_SetDevice(int dev);
+extern bool Console_Validate(int dev);
+extern void Console_SetDevice(int dev);
extern void Console_SetTrace(bool enable);
extern void Console_Check(void);
diff --git a/src/includes/inffile.h b/src/includes/inffile.h
index 5693241c..cfdd5687 100644
--- a/src/includes/inffile.h
+++ b/src/includes/inffile.h
@@ -20,6 +20,9 @@ typedef struct {
const char *exceptionMask;
bool fastForward;
int slowDown;
+ int frameSkips;
+ int runVBLs;
+ int conoutDev;
} autostart_actions_t;
extern autostart_actions_t INF_AutoStartActions;
diff --git a/src/inffile.c b/src/inffile.c
index 2b823aa0..9da005fa 100644
--- a/src/inffile.c
+++ b/src/inffile.c
@@ -14,6 +14,7 @@ const char INFFILE_fileid[] = "Hatari inffile.c";
#include "main.h"
#include "configuration.h"
+#include "console.h"
#include "debugui.h"
#include "inffile.h"
#include "options.h"
@@ -900,6 +901,13 @@ FILE *INF_OpenOverride(const char *filename)
Log_Printf(LOG_WARN, "Fast forward: %d\n", act->fastForward);
}
+ /* set frame skip? */
+ if (act->frameSkips)
+ {
+ ConfigureParams.Screen.nFrameSkips = act->frameSkips;
+ Log_Printf(LOG_WARN, "Frame skips: %d\n", act->frameSkips);
+ }
+
/* set slowdown? */
if (act->slowDown)
{
@@ -907,6 +915,20 @@ FILE *INF_OpenOverride(const char *filename)
Log_Printf(LOG_WARN, "VBL wait slow down factor: %d\n", act->slowDown);
}
+ /* set runVBLs? */
+ if (act->runVBLs)
+ {
+ Main_SetRunVBLs(act->runVBLs);
+ Log_Printf(LOG_WARN, "Exit after %d VBLs.\n", act->runVBLs);
+ }
+
+ /* set console redirection? */
+ if (act->conoutDev)
+ {
+ Console_SetDevice(act->conoutDev);
+ Log_Printf(LOG_WARN, "Xcounout device %d vector redirection enabled.\n", act->conoutDev);
+ }
+
/* parse debugger commands? */
if (act->parseFile)
{
diff --git a/src/options.c b/src/options.c
index 25e3e577..2a149ba5 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1238,7 +1238,9 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_FRAMESKIPS:
- skips = atoi(argv[++i]);
+ str = argv[++i];
+ has = Opt_HasAutoStartPrefix(&str);
+ skips = atoi(str);
if (skips < 0)
{
return Opt_ShowError(OPT_FRAMESKIPS, argv[i],
@@ -1248,6 +1250,12 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
{
Log_Printf(LOG_WARN, "Extravagant frame skip value %d!\n", skips);
}
+ if (has)
+ {
+ INF_AutoStartActions.frameSkips = skips;
+ break;
+ }
+ Log_Printf(LOG_DEBUG, "Frame skip = %d.\n", skips);
ConfigureParams.Screen.nFrameSkips = skips;
break;
@@ -2224,13 +2232,20 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_CONOUT:
- i += 1;
- dev = atoi(argv[i]);
- if (!Console_SetDevice(dev))
+ str = argv[++i];
+ has = Opt_HasAutoStartPrefix(&str);
+ dev = atoi(str);
+ if (!Console_Validate(dev))
{
return Opt_ShowError(OPT_CONOUT, argv[i], "Invalid console device vector number");
}
+ if (has)
+ {
+ INF_AutoStartActions.conoutDev = dev;
+ break;
+ }
Log_Printf(LOG_DEBUG, "Xcounout device %d vector redirection enabled.\n", dev);
+ Console_SetDevice(dev);
break;
case OPT_NATFEATS:
@@ -2342,7 +2357,14 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_RUNVBLS:
- val = atoi(argv[++i]);
+ str = argv[++i];
+ has = Opt_HasAutoStartPrefix(&str);
+ val = atoi(str);
+ if (has)
+ {
+ INF_AutoStartActions.runVBLs = val;
+ break;
+ }
Log_Printf(LOG_DEBUG, "Exit after %d VBLs.\n", val);
Main_SetRunVBLs(val);
break;
--
2.39.5
From ec599a80c154be2dda16a8a7924189f2b1fe4864 Mon Sep 17 00:00:00 2001
From: Eero Tamminen <oak@xxxxxxxxxxxxxx>
Date: Wed, 28 May 2025 10:57:00 +0300
Subject: [PATCH 1/2] Add support for autostart prefix for most relevant
options
"autostart:" prefix can be used with options to:
- Parse debugger commands
- Set exception debug mask
- Set trace flags
- Set fast-forward
- Set slowndown factor
It post-pones given action until program autostart handling
(i.e. Hatari providing virtual TOS INF file for TOS).
These can change values set by these options right at Hatari start,
e.g. to fast-forward TOS boot, but disable forwarding when program
is to be started.
---
src/includes/inffile.h | 11 ++++++
src/inffile.c | 48 +++++++++++++++++++++++--
src/options.c | 79 ++++++++++++++++++++++++++++++++++--------
3 files changed, 120 insertions(+), 18 deletions(-)
diff --git a/src/includes/inffile.h b/src/includes/inffile.h
index 042e0411..5693241c 100644
--- a/src/includes/inffile.h
+++ b/src/includes/inffile.h
@@ -13,6 +13,17 @@ typedef enum {
AUTOSTART_FOPEN
} autostart_t;
+/* items to set along with autostarting */
+typedef struct {
+ const char *parseFile;
+ const char *traceFlags;
+ const char *exceptionMask;
+ bool fastForward;
+ int slowDown;
+} autostart_actions_t;
+
+extern autostart_actions_t INF_AutoStartActions;
+
extern bool INF_SetAutoStart(const char *prgname, int opt_id);
extern bool INF_SetResolution(const char *resolution, int opt_id);
extern void INF_SetVdiMode(int vdi_res);
diff --git a/src/inffile.c b/src/inffile.c
index 04bec57e..2b823aa0 100644
--- a/src/inffile.c
+++ b/src/inffile.c
@@ -14,6 +14,7 @@ const char INFFILE_fileid[] = "Hatari inffile.c";
#include "main.h"
#include "configuration.h"
+#include "debugui.h"
#include "inffile.h"
#include "options.h"
#include "gemdos.h"
@@ -27,6 +28,8 @@ const char INFFILE_fileid[] = "Hatari inffile.c";
/* debug output + leaves virtual INF file behind */
#define INF_DEBUG 0
+autostart_actions_t INF_AutoStartActions;
+
/* TOS resolution numbers used in Atari TOS INF files.
*
* Note: EmuTOS uses different numbers, so these are re-mapped.
@@ -880,18 +883,57 @@ bool INF_Overriding(autostart_t t)
/*-----------------------------------------------------------------------*/
/**
- * If given name matches virtual INF file name, return its handle, NULL otherwise
+ * If given name matches virtual INF file name, return its handle,
+ * NULL otherwise. Runs also other actions configured to be done
+ * at same time with autostart (INF file overriding).
*/
FILE *INF_OpenOverride(const char *filename)
{
if (TosOverride.file && strcmp(filename, TosOverride.infname) == 0)
{
- /* whether to "autostart" also exception debugging? */
+ autostart_actions_t const *act = &INF_AutoStartActions; /* alias */
+
+ /* set fast forwarding? */
+ if (act->fastForward)
+ {
+ ConfigureParams.System.bFastForward = act->fastForward;
+ Log_Printf(LOG_WARN, "Fast forward: %d\n", act->fastForward);
+ }
+
+ /* set slowdown? */
+ if (act->slowDown)
+ {
+ Main_SetVBLSlowdown(act->slowDown);
+ Log_Printf(LOG_WARN, "VBL wait slow down factor: %d\n", act->slowDown);
+ }
+
+ /* parse debugger commands? */
+ if (act->parseFile)
+ {
+ Log_Printf(LOG_WARN, "Parsing debugger command file: '%s'\n", act->parseFile);
+ DebugUI_AddParseFile(act->parseFile);
+ }
+
+ /* set tracing? */
+ if (act->traceFlags)
+ {
+ Log_SetTraceOptions(act->traceFlags);
+ Log_Printf(LOG_WARN, "Tracing flags: 0x%lx\n", LogTraceFlags);
+ }
+
+ /* set exception debug mask? */
if (ConfigureParams.Debugger.nExceptionDebugMask & EXCEPT_AUTOSTART)
{
+ /* legacy/backwards compatible method */
ExceptionDebugMask = ConfigureParams.Debugger.nExceptionDebugMask & ~EXCEPT_AUTOSTART;
- Log_Printf(LOG_INFO, "Exception debugging enabled (0x%x).\n", ExceptionDebugMask);
+ Log_Printf(LOG_WARN, "Exception debug mask: 0x%x)\n", ExceptionDebugMask);
+ }
+ else if (act->exceptionMask)
+ {
+ Log_SetExceptionDebugMask(act->exceptionMask);
+ Log_Printf(LOG_WARN, "Exception debug mask: 0x%x\n", ExceptionDebugMask);
}
+
Log_Printf(LOG_DEBUG, "Virtual INF file '%s' matched.\n", filename);
return TosOverride.file;
}
diff --git a/src/options.c b/src/options.c
index d1b160b9..25e3e577 100644
--- a/src/options.c
+++ b/src/options.c
@@ -56,6 +56,8 @@ bool BenchmarkMode; /* Start in benchmark mode (try to run at maximum emulati
static bool bBiosIntercept;
+#define AUTOSTART_PREFIX "autostart:"
+
/* List of supported options. */
enum {
OPT_HEADER, /* options section header */
@@ -662,7 +664,8 @@ static void Opt_ShowHelp(void)
"\tEnable by using 'y', 'yes', 'on', 'true' or '1'\n"
"<file>\tDevices accept also special 'stdout' and 'stderr' file names\n"
"\t(if you use stdout for midi or printer, set log to stderr).\n"
- "\tSetting the file to 'none', disables given device or disk\n");
+ "\tSetting the file to 'none', disables given device or disk\n"
+ "'"AUTOSTART_PREFIX"' prefix => see manual on how it works.\n");
}
@@ -738,7 +741,7 @@ int Opt_ValueAlignMinMax(int value, int align, int min, int max)
* If 'conf' given, set it:
* - true if given option 'arg' is y/yes/on/true/1
* - false if given option 'arg' is n/no/off/false/0
- * Return false for any other value, otherwise true
+ * Return false for any other value + show error, otherwise return true
*/
static bool Opt_Bool(const char *arg, int optid, bool *conf)
{
@@ -799,6 +802,21 @@ static bool Opt_CountryCode(const char *arg, int optid, int *conf)
}
+/**
+ * Return true if given string has autostart prefix, and set
+ * string pointer to address after the prefix.
+ */
+static bool Opt_HasAutoStartPrefix(const char **arg)
+{
+ const size_t len = strlen(AUTOSTART_PREFIX);
+ if (strncmp(*arg, AUTOSTART_PREFIX, len) == 0)
+ {
+ *arg = *arg + len;
+ return true;
+ }
+ return false;
+}
+
/**
* Parse "<drive>=<value>". If single digit "<drive>" and/or '=' missing,
* assume drive ID 0, and interpret whole arg as "<value>".
@@ -907,7 +925,11 @@ static int Opt_WhichOption(int argc, const char * const argv[], int idx)
/* early check for bools */
if (strcmp(opt->arg, "<bool>") == 0)
{
- if (!Opt_Bool(argv[idx+1], opt->id, NULL))
+ const char *value = argv[idx+1];
+
+ /* skip autostart prefix for all bools */
+ Opt_HasAutoStartPrefix(&value);
+ if (!Opt_Bool(value, opt->id, NULL))
{
return OPT_ERROR;
}
@@ -1089,11 +1111,10 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
{
int ncpu, skips, planes, cpuclock, threshold, memsize;
int dev, port, freq, temp, drive, year;
+ bool valid, enabled, has, ok = true;
const char *errstr, *str;
- int i, ok = true;
float zoom;
- int val;
- bool valid;
+ int i, val;
/* Defaults for loading initial memory snap-shots */
bLoadMemorySave = false;
@@ -1125,7 +1146,17 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_FASTFORWARD:
- ok = Opt_Bool(argv[++i], OPT_FASTFORWARD, &ConfigureParams.System.bFastForward);
+ str = argv[++i];
+ has = Opt_HasAutoStartPrefix(&str);
+ if (!Opt_Bool(str, OPT_FASTFORWARD, &enabled))
+ return false;
+ if (has)
+ {
+ INF_AutoStartActions.fastForward = enabled;
+ break;
+ }
+ Log_Printf(LOG_DEBUG, "Fast forward = %s.\n", str);
+ ConfigureParams.System.bFastForward = enabled;
break;
case OPT_AUTOSTART:
@@ -1221,7 +1252,14 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_SLOWDOWN:
- val = atoi(argv[++i]);
+ str = argv[++i];
+ has = Opt_HasAutoStartPrefix(&str);
+ val = atoi(str);
+ if (has)
+ {
+ INF_AutoStartActions.slowDown = val;
+ break;
+ }
errstr = Main_SetVBLSlowdown(val);
if (errstr)
{
@@ -2133,9 +2171,12 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_EXCEPTIONS:
- i += 1;
- /* sets ConfigureParams.Debugger.nExceptionDebugMask */
- errstr = Log_SetExceptionDebugMask(argv[i]);
+ str = argv[++i];
+ if (Opt_HasAutoStartPrefix(&str)) {
+ INF_AutoStartActions.exceptionMask = str;
+ break;
+ }
+ errstr = Log_SetExceptionDebugMask(str);
if (errstr)
{
if (!errstr[0])
@@ -2212,8 +2253,12 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_TRACE:
- i += 1;
- errstr = Log_SetTraceOptions(argv[i]);
+ str = argv[++i];
+ if (Opt_HasAutoStartPrefix(&str)) {
+ INF_AutoStartActions.traceFlags = str;
+ break;
+ }
+ errstr = Log_SetTraceOptions(str);
if (errstr)
{
if (!errstr[0])
@@ -2262,8 +2307,12 @@ bool Opt_ParseParameters(int argc, const char * const argv[])
break;
case OPT_PARSE:
- i += 1;
- ok = DebugUI_AddParseFile(argv[i]);
+ str = argv[++i];
+ if (Opt_HasAutoStartPrefix(&str)) {
+ INF_AutoStartActions.parseFile = str;
+ } else {
+ ok = DebugUI_AddParseFile(str);
+ }
break;
case OPT_SAVECONFIG:
--
2.39.5