SCP: Allow for simulator specific processing of DO commands.

This commit is contained in:
Mark Pizzolato 2021-09-06 10:18:36 -07:00
parent d57b182701
commit 82f9f5b966

16
scp.c
View file

@ -2708,6 +2708,7 @@ int32 i, sw;
t_bool lookswitch; t_bool lookswitch;
t_bool register_check = FALSE; t_bool register_check = FALSE;
t_stat stat = SCPE_OK; t_stat stat = SCPE_OK;
CTAB *docmdp = NULL;
#if defined (__MWERKS__) && defined (macintosh) #if defined (__MWERKS__) && defined (macintosh)
argc = ccommand (&argv); argc = ccommand (&argv);
@ -2896,14 +2897,15 @@ if (cptr == NULL) {
} }
else else
cptr2 = NULL; cptr2 = NULL;
docmdp = find_cmd ("DO");
if (cptr && (sizeof (nbuf) > strlen (cptr) + strlen ("/simh.ini") + 3)) { if (cptr && (sizeof (nbuf) > strlen (cptr) + strlen ("/simh.ini") + 3)) {
snprintf(nbuf, sizeof (nbuf), "\"%s%s%ssimh.ini\"", cptr2 ? cptr2 : "", cptr, strchr (cptr, '/') ? "/" : "\\"); snprintf(nbuf, sizeof (nbuf), "\"%s%s%ssimh.ini\"", cptr2 ? cptr2 : "", cptr, strchr (cptr, '/') ? "/" : "\\");
stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* simh.ini proc cmd file */ stat = docmdp->action (-1, nbuf) & ~SCPE_NOMESSAGE; /* simh.ini proc cmd file */
} }
if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR) if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR)
stat = do_cmd (-1, "simh.ini"); /* simh.ini proc cmd file */ stat = docmdp->action (-1, "simh.ini"); /* simh.ini proc cmd file */
if (*cbuf) /* cmd file arg? */ if (*cbuf) /* cmd file arg? */
stat = do_cmd (0, cbuf); /* proc cmd file */ stat = docmdp->action (0, cbuf); /* proc cmd file */
else if (*argv[0]) { /* sim name arg? */ else if (*argv[0]) { /* sim name arg? */
char *np; /* "path.ini" */ char *np; /* "path.ini" */
nbuf[0] = '"'; /* starting " */ nbuf[0] = '"'; /* starting " */
@ -2911,7 +2913,7 @@ else if (*argv[0]) { /* sim name arg? */
if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */ if ((np = (char *)match_ext (nbuf, "EXE"))) /* remove .exe */
*np = 0; *np = 0;
strlcat (nbuf, ".ini\"", sizeof (nbuf)); /* add .ini" */ strlcat (nbuf, ".ini\"", sizeof (nbuf)); /* add .ini" */
stat = do_cmd (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */ stat = docmdp->action (-1, nbuf) & ~SCPE_NOMESSAGE; /* proc default cmd file */
if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */ if (stat == SCPE_OPENERR) { /* didn't exist/can't open? */
np = strrchr (nbuf, '/'); /* stript path and try again in cwd */ np = strrchr (nbuf, '/'); /* stript path and try again in cwd */
if (np == NULL) if (np == NULL)
@ -2920,7 +2922,7 @@ else if (*argv[0]) { /* sim name arg? */
np = strrchr (nbuf, ']'); /* VMS path separator */ np = strrchr (nbuf, ']'); /* VMS path separator */
if (np != NULL) { if (np != NULL) {
*np = '"'; *np = '"';
stat = do_cmd (-1, np) & ~SCPE_NOMESSAGE; /* proc default cmd file */ stat = docmdp->action (-1, np) & ~SCPE_NOMESSAGE;/* proc default cmd file */
} }
} }
} }
@ -4129,11 +4131,11 @@ do {
if ((cmdp = find_cmd (gbuf))) { /* lookup command */ if ((cmdp = find_cmd (gbuf))) { /* lookup command */
if (cmdp->action == &return_cmd) /* RETURN command? */ if (cmdp->action == &return_cmd) /* RETURN command? */
break; /* done! */ break; /* done! */
if (cmdp->action == &do_cmd) { /* DO command? */ if (strcmp (cmdp->name, "DO") == 0) { /* DO command? */
if (sim_do_depth >= MAX_DO_NEST_LVL) /* nest too deep? */ if (sim_do_depth >= MAX_DO_NEST_LVL) /* nest too deep? */
stat = SCPE_NEST; stat = SCPE_NEST;
else else
stat = do_cmd (sim_do_depth+1, cptr); /* exec DO cmd */ stat = cmdp->action (sim_do_depth+1, cptr);/* exec DO cmd */
} }
else else
if (cmdp->action == &shift_cmd) /* SHIFT command */ if (cmdp->action == &shift_cmd) /* SHIFT command */