1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-01-11 23:52:48 +00:00

SCP: Updated to current.

This commit is contained in:
Richard Cornwell 2022-12-13 23:10:55 -05:00
parent fe099e1b16
commit b96a69157d
6 changed files with 86 additions and 58 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Lars Brinkhoff
* Copyright (c) 2018, 2022 Lars Brinkhoff
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -24,6 +24,8 @@
* from the authors.
*/
#include <string.h>
#include <assert.h>
#include "display.h" /* XY plot interface */
#include "ng.h"
@ -33,6 +35,8 @@
#define TKGO 010000
#define TKSTOP 020000
/* Number of displays. */
#define DISPLAYS 8
static void *ng_dptr;
static int ng_dbit;
@ -51,12 +55,12 @@ extern void _sim_debug_device (unsigned int dbits, DEVICE* dptr, const char* fmt
int ng_type = 0;
int ng_scale = PIX_SCALE;
static uint16 status = 0;
static uint16 status[DISPLAYS];
static int reloc = 0;
static int console = 0;
static int dpc[8];
static int x[8];
static int y[8];
static int dpc[DISPLAYS];
static int x[DISPLAYS];
static int y[DISPLAYS];
static unsigned char sync_period = 0;
static unsigned char time_out = 0;
@ -66,14 +70,16 @@ ng_get_csr(void)
{
if (ng_type == TYPE_DAZZLE) {
DEBUGF("[%d] Get CSR: ", 0);
if (status & TKRUN)
if (status[console] & TKRUN)
DEBUGF("running\n");
else
DEBUGF("stopped\n");
return status[console];
} else if (ng_type == TYPE_LOGO) {
DEBUGF("Get CSR: %06o\n", status);
DEBUGF("Get CSR: %06o\n", status[0]);
return status[0];
}
return status;
return 0;
}
int32
@ -90,19 +96,19 @@ ng_set_csr(uint16 d)
if (d & TKGO) {
DEBUGF("[%d] Set CSR: GO\n", console);
if ((status & TKRUN) == 0)
if ((status[console] & TKRUN) == 0)
dpc[console] = 2*console;
status |= TKRUN;
status[console] = TKRUN | console;
}
if (d & TKSTOP) {
DEBUGF("[%d] Set CSR: STOP\n", console);
status &= ~TKRUN;
status[console] = console;
}
} else if (ng_type == TYPE_LOGO) {
DEBUGF("Set CSR: %06o\n", d);
if ((status & 1) == 0 && (d & 1))
if ((status[0] & 1) == 0 && (d & 1))
dpc[0] = 2*0;
status = d;
status[0] = d;
}
}
@ -116,8 +122,12 @@ ng_set_reloc(uint16 d)
int
ng_init(void *dev, int debug)
{
/* Don't change this number. */
assert (DISPLAYS == 8);
ng_dptr = dev;
ng_dbit = debug;
memset (status, 0, sizeof status);
return display_init(DIS_NG, ng_scale, ng_dptr);
}
@ -217,7 +227,7 @@ void stop (void)
{
DEBUGF("[%d] STOP\n", console);
if (ng_type == TYPE_DAZZLE)
status &= ~TKRUN;
status[console] &= ~TKRUN;
else if (ng_type == TYPE_LOGO)
dpc[0] = 2*0;
}
@ -298,6 +308,8 @@ ng_cycle(int us, int slowdown)
static uint32 usec = 0;
static uint32 msec = 0;
uint32 new_msec;
int running = 0;
int saved;
new_msec = (usec += us) / 1000;
@ -307,20 +319,22 @@ ng_cycle(int us, int slowdown)
msec = new_msec;
if (ng_type == TYPE_DAZZLE) {
if ((status & TKRUN) == 0)
if (ng_type == TYPE_LOGO) {
DEBUGF("LOGO/STATUS %06o\n", status[0]);
if ((status[0] & 1) == 0)
goto age_ret;
} else if (ng_type == TYPE_LOGO) {
DEBUGF("STATUS %06o\n", status);
if ((status & 1) == 0)
goto age_ret;
} else
return 1;
} else if (ng_type != TYPE_DAZZLE)
return 0;
if (sync_period)
goto age_ret;
saved = console;
for (console = 0; console < 1; console++) {
if (ng_type == TYPE_DAZZLE && (status[console] & TKRUN) == 0)
continue;
running = 1;
time_out = fetch(dpc[console], &inst);
DEBUGF("[%d] PC %06o, INSTR %06o\n", console, dpc[console], inst);
dpc[console] += 2;
@ -339,8 +353,9 @@ ng_cycle(int us, int slowdown)
break;
}
}
console = saved;
age_ret:
display_age(us, slowdown);
return 1;
return running || !display_is_blank();
}

36
scp.c
View File

@ -1690,8 +1690,8 @@ static const char simh_help2[] =
" %%CTIME%%, %%DATE_YYYY%%, %%DATE_YY%%, %%DATE_YC%%, %%DATE_MM%%, %%DATE_MMM%%,\n"
" %%DATE_MONTH%%, %%DATE_DD%%, %%DATE_D%%, %%DATE_WYYYY%%, %%DATE_WW%%,\n"
" %%TIME_HH%%, %%TIME_MM%%, %%TIME_SS%%, %%TIME_MSEC%%, %%STATUS%%, %%TSTATUS%%,\n"
" %%SIM_VERIFY%%, %%SIM_QUIET%%, %%SIM_MESSAGE%% %%SIM_MESSAGE%%\n"
" %%SIM_NAME%%, %%SIM_BIN_NAME%%, %%SIM_BIN_PATH%%m %%SIM_OSTYPE%%\n\n"
" %%SIM_VERIFY%%, %%SIM_QUIET%%, %%SIM_MESSAGE%%, %%SIM_NAME%%, %%SIM_BIN_NAME%%,\n"
" %%SIM_BIN_PATH%%, %%SIM_OSTYPE%%\n\n"
"+Token %%0 expands to the command file name.\n"
"+Token %%n (n being a single digit) expands to the n'th argument\n"
"+Token %%* expands to the whole set of arguments (%%1 ... %%9)\n\n"
@ -1934,10 +1934,20 @@ static const char simh_help2[] =
" the ON command.\n"
"4Enabling Error Traps\n"
" Error trapping is enabled with:\n\n"
"++set on enable error traps\n"
"++set on enable error traps\n\n"
"4Disabling Error Traps\n"
" Error trapping is disabled with:\n\n"
"++set noon disable error traps\n"
"++set noon disable error traps\n\n"
" Disables error traps for the currently running command file.\n\n"
"4Inheritance of Error Traps\n"
" Error traps can be local the current command file or inherited into\n"
" nested command file invocations:\n\n"
"++set on INHERIT|NOINHERIT enable/disable inheritance\n\n"
" By default, ON state is NOINHERIT which means that the scope of pending ON\n"
" actions is bound to the currently executing command file. If INHERIT is\n"
" enabled, the currently defined ON actions are inherited by nested command\n"
" files that may be invoked.\n\n"
"4ON\n"
"4ON\n"
" To set the action(s) to take when a specific error status is returned by\n"
" a command in the currently running do command file:\n\n"
@ -4698,7 +4708,11 @@ if (!ap) { /* no environment variable found? */
ap = rbuf;
}
else if (!strcmp ("TSTATUS", gbuf)) {
sprintf (rbuf, "%s", sim_error_text (sim_last_cmd_stat));
t_stat stat = SCPE_BARE_STATUS(sim_last_cmd_stat);
if ((stat > SCPE_OK) && (stat < SCPE_BASE) && (sim_stop_messages[stat] != NULL))
sprintf (rbuf, "%s", sim_stop_messages[stat]);
else
sprintf (rbuf, "%s", sim_error_text (stat));
ap = rbuf;
}
else if (!strcmp ("SIM_VERIFY", gbuf)) {
@ -7292,7 +7306,7 @@ gbuf[sizeof(gbuf)-1] = '\0';
strlcpy (gbuf, cptr, sizeof(gbuf));
sim_trim_endspc(gbuf);
if (sim_chdir(gbuf) != 0)
return sim_messagef(SCPE_IOERR, "Unable to directory change to: %s\n", gbuf);
return sim_messagef(SCPE_IOERR, "Unable to change directory to: %s\n", gbuf);
return SCPE_OK;
}
@ -9435,7 +9449,7 @@ t_value pcval;
fputc ('\n', st); /* start on a new line */
if (v >= SCPE_BASE) /* SCP error? */
if (v == SCPE_OK || v >= SCPE_BASE) /* SCP error? */
fputs (sim_error_text (v), st); /* print it from the SCP list */
else { /* VM error */
if (sim_stop_messages [v])
@ -16030,18 +16044,10 @@ for (i = 0; (dptr = devices[i]) != NULL; i++) {
REG *rptr;
for (rptr = dptr->registers; (rptr != NULL) && (rptr->name != NULL); rptr++) {
uint32 bytes = 1;
uint32 rsz = SZ_R(rptr);
uint32 memsize = ((rptr->flags & REG_FIT) || (rptr->depth > 1)) ? rptr->depth * rsz : 4;
DEVICE *udptr = NULL;
t_bool Bad;
while ((bytes << 3) < rptr->offset + rptr->width)
bytes <<= 1;
if (rptr->depth > 1)
bytes = rptr->size;
if (((rptr->width + rptr->offset + CHAR_BIT - 1) / CHAR_BIT) >= sizeof(size_map) / sizeof(size_map[0])) {
Bad = TRUE;
rsz = 0;

View File

@ -90,7 +90,7 @@ struct ROM_File_Descriptor {
#endif
int sim_read_ROM_include(const char *include_filename,
int *psize,
size_t *psize,
unsigned char **pROMData,
unsigned int *pchecksum,
char **prom_array_name,
@ -227,7 +227,7 @@ return 1;
}
int sim_make_ROM_include(const char *rom_filename,
int expected_size,
size_t expected_size,
unsigned int expected_checksum,
const char *include_filename,
const char *rom_array_name,
@ -237,7 +237,7 @@ FILE *rFile;
FILE *iFile;
time_t now;
int bytes_written = 0;
int include_bytes;
size_t include_bytes;
int c;
int rom;
struct stat statb;
@ -275,8 +275,8 @@ if (stat (rom_filename, &statb)) {
fclose (rFile);
return -1;
}
if (statb.st_size != expected_size) {
printf ("Error: ROM file '%s' has an unexpected size: %d vs %d\n", rom_filename, (int)statb.st_size, expected_size);
if ((size_t)statb.st_size != (size_t)expected_size) {
printf ("Error: ROM file '%s' has an unexpected size: %d vs %d\n", rom_filename, (int)statb.st_size, (int)expected_size);
printf ("This can happen if the file was transferred or unpacked incorrectly\n");
printf ("and in the process tried to convert line endings rather than passing\n");
printf ("the file's contents unmodified\n");

View File

@ -5670,10 +5670,10 @@ _rand_uuid_gen (uuidaddr);
#endif
static VHDHANDLE
CreateVirtualDisk(const char *szVHDPath,
uint32 SizeInSectors,
uint32 BlockSize,
t_bool bFixedVHD)
sim_CreateVirtualDisk(const char *szVHDPath,
uint32 SizeInSectors,
uint32 BlockSize,
t_bool bFixedVHD)
{
VHD_Footer Footer;
VHD_DynamicDiskHeader Dynamic;
@ -5965,10 +5965,10 @@ if ((Status = GetVHDFooter (szParentVHDPath,
NULL,
0)))
goto Cleanup_Return;
hVHD = CreateVirtualDisk (szVHDPath,
(uint32)(NtoHll(ParentFooter.CurrentSize)/BytesPerSector),
NtoHl(ParentDynamic.BlockSize),
FALSE);
hVHD = sim_CreateVirtualDisk (szVHDPath,
(uint32)(NtoHll(ParentFooter.CurrentSize)/BytesPerSector),
NtoHl(ParentDynamic.BlockSize),
FALSE);
if (!hVHD) {
Status = errno;
goto Cleanup_Return;
@ -6111,7 +6111,7 @@ return hVHD;
static FILE *sim_vhd_disk_create (const char *szVHDPath, t_offset desiredsize)
{
return (FILE *)CreateVirtualDisk (szVHDPath, (uint32)(desiredsize/512), 0, (sim_switches & SWMASK ('X')));
return (FILE *)sim_CreateVirtualDisk (szVHDPath, (uint32)(desiredsize/512), 0, (sim_switches & SWMASK ('X')));
}
static FILE *sim_vhd_disk_create_diff (const char *szVHDPath, const char *szParentVHDPath)

View File

@ -88,6 +88,9 @@
#include "sim_defs.h"
#include <ctype.h>
#include <math.h>
#ifdef HAVE_WINMM
#include <windows.h>
#endif
#define SIM_INTERNAL_CLK (SIM_NTIMERS+(1<<30))
#define SIM_INTERNAL_UNIT sim_internal_timer_unit
@ -462,7 +465,7 @@ return 0;
}
#endif /* CLOCK_REALTIME */
#elif defined (_WIN32)
#elif defined (_WIN32) || defined(HAVE_WINMM)
/* Win32 routines */

View File

@ -709,6 +709,7 @@ vptr->vid_height = height;
vptr->vid_mouse_captured = FALSE;
vptr->vid_cursor_visible = (vptr->vid_flags & SIM_VID_INPUTCAPTURED);
vptr->vid_blending = FALSE;
vptr->vid_ready = FALSE;
if (!vid_active) {
vid_key_events.head = 0;
@ -2055,12 +2056,14 @@ while (vid_active) {
event.user.code = 0; /* Mark as done */
continue;
}
vptr = vid_get_event_window (&event, event.user.windowID);
if (vptr == NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vptr->vid_dev, "vid_thread() - Ignored event not bound to a window\n");
event.user.code = 0; /* Mark as done */
break;
if (event.user.code != EVENT_OPEN) {
vptr = vid_get_event_window (&event, event.user.windowID);
if (vptr == NULL) {
sim_debug (SIM_VID_DBG_VIDEO, vptr->vid_dev, "vid_thread() - Ignored event not bound to a window\n");
event.user.code = 0; /* Mark as done */
break;
}
}
if (event.user.code == EVENT_REDRAW) {
vid_update (vptr);
event.user.code = 0; /* Mark as done */
@ -2072,6 +2075,7 @@ while (vid_active) {
event.user.code = 0; /* Mark as done */
continue;
}
vptr = vid_get_event_window (&event, event.user.windowID);
break;
}
}