1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-01-13 15:27:04 +00:00

SCP: Updated to current.

This commit is contained in:
Richard Cornwell 2021-03-04 21:13:46 -05:00
parent 32c20e2795
commit 874e6ab2ba
3 changed files with 102 additions and 26 deletions

59
scp.c
View File

@ -3248,12 +3248,19 @@ t_bool found = FALSE;
t_bool deb_desc_available = FALSE;
char buf[CBUFSIZE], header[CBUFSIZE];
uint32 enabled_units = dptr->numunits;
uint32 unit;
char unit_spec[50];
uint32 unit, found_unit = 0;
sprintf (header, "\n%s device SET commands:\n\n", dptr->name);
for (unit=0; unit < dptr->numunits; unit++)
if (dptr->units[unit].flags & UNIT_DIS)
--enabled_units;
else
found_unit = unit;
if (enabled_units == 1)
snprintf (unit_spec, sizeof (unit_spec), "%s%u", sim_dname (dptr), found_unit);
else
snprintf (unit_spec, sizeof (unit_spec), "%sn", sim_dname (dptr));
if (dptr->modifiers) {
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
if (!MODMASK(mptr,MTAB_VDV) && MODMASK(mptr,MTAB_VUN) && (dptr->numunits != 1))
@ -3299,34 +3306,33 @@ if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) {
fprintf (st, "%-30s\tDisables specific debugging for device %s\n", buf, sim_dname (dptr));
}
}
if ((dptr->modifiers) && (dptr->units) && (enabled_units != 1)) {
if ((dptr->modifiers) && (dptr->units)) { /* handle unit specific modifiers */
if (dptr->units->flags & UNIT_DISABLE) {
fprint_header (st, &found, header);
sprintf (buf, "set %sn ENABLE", sim_dname (dptr));
fprintf (st, "%-30s\tEnables unit %sn\n", buf, sim_dname (dptr));
sprintf (buf, "set %sn DISABLE", sim_dname (dptr));
fprintf (st, "%-30s\tDisables unit %sn\n", buf, sim_dname (dptr));
sprintf (buf, "set %s ENABLE", unit_spec);
fprintf (st, "%-30s\tEnables unit %s\n", buf, unit_spec);
sprintf (buf, "set %s DISABLE", unit_spec);
fprintf (st, "%-30s\tDisables unit %sn\n", buf, unit_spec);
}
if (((dptr->flags & DEV_DEBUG) || (dptr->debflags)) &&
((DEV_TYPE(dptr) == DEV_DISK) || (DEV_TYPE(dptr) == DEV_TAPE))) {
sprintf (buf, "set %sn DEBUG", sim_dname (dptr));
fprintf (st, "%-30s\tEnables debugging for device unit %sn\n", buf, sim_dname (dptr));
sprintf (buf, "set %sn NODEBUG", sim_dname (dptr));
fprintf (st, "%-30s\tDisables debugging for device unit %sn\n", buf, sim_dname (dptr));
sprintf (buf, "set %s DEBUG", unit_spec);
fprintf (st, "%-30s\tEnables debugging for device unit %s\n", buf, unit_spec);
sprintf (buf, "set %s NODEBUG", unit_spec);
fprintf (st, "%-30s\tDisables debugging for device unit %s\n", buf, unit_spec);
if (dptr->debflags) {
strcpy (buf, "");
fprintf (st, "set %sn DEBUG=", sim_dname (dptr));
fprintf (st, "set %s DEBUG=", unit_spec);
for (dep = dptr->debflags; dep->name != NULL; dep++)
fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name);
fprintf (st, "\n");
fprintf (st, "%-30s\tEnables specific debugging for device unit %sn\n", buf, sim_dname (dptr));
fprintf (st, "set %sn NODEBUG=", sim_dname (dptr));
fprintf (st, "%-30s\tEnables specific debugging for device unit %s\n", buf, unit_spec);
fprintf (st, "set %s NODEBUG=", unit_spec);
for (dep = dptr->debflags; dep->name != NULL; dep++)
fprintf (st, "%s%s", ((dep == dptr->debflags) ? "" : ";"), dep->name);
fprintf (st, "\n");
fprintf (st, "%-30s\tDisables specific debugging for device unit %sn\n", buf, sim_dname (dptr));
fprintf (st, "%-30s\tDisables specific debugging for device unit %s\n", buf, unit_spec);
}
}
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
if ((!MODMASK(mptr,MTAB_VUN)) && MODMASK(mptr,MTAB_XTD))
@ -3335,7 +3341,7 @@ if ((dptr->modifiers) && (dptr->units) && (enabled_units != 1)) {
continue; /* skip show only modifiers */
if (mptr->mstring) {
fprint_header (st, &found, header);
sprintf (buf, "set %s%s %s%s", sim_dname (dptr), (dptr->numunits > 1) ? "n" : "0", mptr->mstring, (strchr(mptr->mstring, '=')) ? "" : (MODMASK(mptr,MTAB_VALR) ? "=val" : (MODMASK(mptr,MTAB_VALO) ? "{=val}": "")));
sprintf (buf, "set %s %s%s", unit_spec, mptr->mstring, (strchr(mptr->mstring, '=')) ? "" : (MODMASK(mptr,MTAB_VALR) ? "=val" : (MODMASK(mptr,MTAB_VALO) ? "{=val}": "")));
fprintf (st, "%-30s\t%s\n", buf, (strchr (mptr->mstring, '=')) ? ((strlen (buf) > 30) ? "" : mptr->help) : (mptr->help ? mptr->help : ""));
if ((strchr (mptr->mstring, '=')) && (strlen (buf) > 30))
fprintf (st, "%-30s\t%s\n", "", mptr->help);
@ -3372,12 +3378,21 @@ MTAB *mptr;
t_bool found = FALSE;
char buf[CBUFSIZE], header[CBUFSIZE];
uint32 enabled_units = dptr->numunits;
uint32 unit;
char unit_spec[50];
uint32 unit, found_unit = 0;
sprintf (header, "\n%s device SHOW commands:\n\n", dptr->name);
for (unit=0; unit < dptr->numunits; unit++)
if (dptr->units[unit].flags & UNIT_DIS)
--enabled_units;
else
found_unit = unit;
if (enabled_units == 1)
snprintf (unit_spec, sizeof (unit_spec), "%s%u", sim_dname (dptr), found_unit);
else
snprintf (unit_spec, sizeof (unit_spec), "%sn", sim_dname (dptr));
snprintf (unit_spec, sizeof (unit_spec), "%s%s", sim_dname (dptr),
((enabled_units == 1) && ((dptr->units[0].flags & UNIT_DIS) == 0)) ? "0" : "n");
if (dptr->modifiers) {
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
if (!MODMASK(mptr,MTAB_VDV) && MODMASK(mptr,MTAB_VUN) && (dptr->numunits != 1))
@ -3396,14 +3411,20 @@ if ((dptr->flags & DEV_DEBUG) || (dptr->debflags)) {
sprintf (buf, "show %s DEBUG", sim_dname (dptr));
fprintf (st, "%-30s\tDisplays debugging status for device %s\n", buf, sim_dname (dptr));
}
if ((dptr->modifiers) && (dptr->units) && (enabled_units != 1)) {
if (((dptr->flags & DEV_DEBUG) || (dptr->debflags)) &&
((DEV_TYPE(dptr) == DEV_DISK) || (DEV_TYPE(dptr) == DEV_TAPE))) {
sprintf (buf, "show %s DEBUG", unit_spec);
fprintf (st, "%-30s\tDisplays debugging status for device unit %s\n", buf, unit_spec);
}
if ((dptr->modifiers) && (dptr->units)) { /* handle unit specific modifiers */
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
if ((!MODMASK(mptr,MTAB_VUN)) && MODMASK(mptr,MTAB_XTD))
continue; /* skip device only modifiers */
if ((!mptr->disp) || (!mptr->pstring))
continue;
fprint_header (st, &found, header);
sprintf (buf, "show %s%s %s%s", sim_dname (dptr), (dptr->numunits > 1) ? "n" : "0", mptr->pstring, MODMASK(mptr,MTAB_SHP) ? "=arg" : "");
sprintf (buf, "show %s %s%s", unit_spec, mptr->pstring, MODMASK(mptr,MTAB_SHP) ? "=arg" : "");
fprintf (st, "%-30s\t%s\n", buf, mptr->help ? mptr->help : "");
}
}

View File

@ -370,6 +370,7 @@ t_bool vid_cursor_visible; /* cursor visibility sta
DEVICE *vid_dev;
t_bool vid_key_state[SDL_NUM_SCANCODES];
VID_DISPLAY *next;
t_bool vid_blending;
};
SDL_Thread *vid_thread_handle = NULL; /* event thread handle */
@ -448,6 +449,8 @@ if (vid_main_thread_handle == NULL) {
vid_beep_setup (400, 660);
memset (&event, 0, sizeof (event));
while (1) {
int status = SDL_WaitEvent (&event);
if (status == 1) {
@ -623,6 +626,7 @@ vptr->vid_width = width;
vptr->vid_height = height;
vptr->vid_mouse_captured = FALSE;
vptr->vid_cursor_visible = (vptr->vid_flags & SIM_VID_INPUTCAPTURED);
vptr->vid_blending = FALSE;
if (!vid_active) {
vid_key_events.head = 0;
@ -784,6 +788,11 @@ uint32 vid_map_rgb (uint8 r, uint8 g, uint8 b)
return vid_map_rgb_window (&vid_first, r, g, b);
}
uint32 vid_map_rgba_window (VID_DISPLAY *vptr, uint8 r, uint8 g, uint8 b, uint8 a)
{
return SDL_MapRGBA (vptr->vid_format, r, g, b, a);
}
static SDL_Rect *vid_dst_last;
static uint32 *vid_data_last;
@ -1572,11 +1581,15 @@ vid_stretch(vptr, &vid_dst);
sim_debug (SIM_VID_DBG_VIDEO, vptr->vid_dev, "Video Update Event: \n");
if (sim_deb)
fflush (sim_deb);
if (SDL_RenderClear (vptr->vid_renderer))
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
if (SDL_RenderCopy (vptr->vid_renderer, vptr->vid_texture, NULL, &vid_dst))
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
SDL_RenderPresent (vptr->vid_renderer);
if (vptr->vid_blending)
SDL_RenderPresent (vptr->vid_renderer);
else {
if (SDL_RenderClear (vptr->vid_renderer))
sim_printf ("%s: Video Update Event: SDL_RenderClear error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
if (SDL_RenderCopy (vptr->vid_renderer, vptr->vid_texture, NULL, &vid_dst))
sim_printf ("%s: Video Update Event: SDL_RenderCopy error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
SDL_RenderPresent (vptr->vid_renderer);
}
}
void vid_update_cursor (VID_DISPLAY *vptr, SDL_Cursor *cursor, t_bool visible)
@ -1618,8 +1631,13 @@ if (vid_dst == vid_dst_last) {
}
SDL_UnlockMutex (vptr->vid_draw_mutex);
if (SDL_UpdateTexture(vptr->vid_texture, vid_dst, buf, vid_dst->w*sizeof(*buf)))
sim_printf ("%s: vid_draw_region() - SDL_UpdateTexture error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
if (vptr->vid_blending) {
SDL_UpdateTexture(vptr->vid_texture, vid_dst, buf, vid_dst->w*sizeof(*buf));
SDL_RenderCopy (vptr->vid_renderer, vptr->vid_texture, vid_dst, vid_dst);
}
else
if (SDL_UpdateTexture(vptr->vid_texture, vid_dst, buf, vid_dst->w*sizeof(*buf)))
sim_printf ("%s: vid_draw_region() - SDL_UpdateTexture error: %s\n", vid_dname(vptr->vid_dev), SDL_GetError());
free (vid_dst);
free (buf);
@ -1686,6 +1704,36 @@ vid_active++;
return 1;
}
t_stat vid_set_alpha_mode (VID_DISPLAY *vptr, int mode)
{
SDL_BlendMode x;
switch (mode) {
case SIM_ALPHA_NONE:
vptr->vid_blending = FALSE;
x = SDL_BLENDMODE_NONE;
break;
case SIM_ALPHA_BLEND:
vptr->vid_blending = TRUE;
x = SDL_BLENDMODE_BLEND;
break;
case SIM_ALPHA_ADD:
vptr->vid_blending = TRUE;
x = SDL_BLENDMODE_ADD;
break;
case SIM_ALPHA_MOD:
vptr->vid_blending = TRUE;
x = SDL_BLENDMODE_MOD;
break;
default:
return SCPE_ARG;
}
if (SDL_SetTextureBlendMode (vptr->vid_texture, x))
return SCPE_IERR;
if (SDL_SetRenderDrawBlendMode (vptr->vid_renderer, x))
return SCPE_IERR;
return SCPE_OK;
}
static void vid_destroy (VID_DISPLAY *vptr)
{
VID_DISPLAY *parent;

View File

@ -157,6 +157,11 @@ extern "C" {
#define SIM_KEY_UNKNOWN 200
#define SIM_ALPHA_NONE 1
#define SIM_ALPHA_BLEND 2
#define SIM_ALPHA_ADD 3
#define SIM_ALPHA_MOD 4
typedef struct VID_DISPLAY VID_DISPLAY;
struct mouse_event {
@ -214,12 +219,14 @@ t_stat vid_open_window (VID_DISPLAY **vptr, DEVICE *dptr, const char *title, uin
t_stat vid_close_window (VID_DISPLAY *vptr);
t_stat vid_close_all (void);
uint32 vid_map_rgb_window (VID_DISPLAY *vptr, uint8 r, uint8 g, uint8 b);
uint32 vid_map_rgba_window (VID_DISPLAY *vptr, uint8 r, uint8 g, uint8 b, uint8 a);
void vid_draw_window (VID_DISPLAY *vptr, int32 x, int32 y, int32 w, int32 h, uint32 *buf);
void vid_refresh_window (VID_DISPLAY *vptr);
t_stat vid_set_cursor_window (VID_DISPLAY *vptr, t_bool visible, uint32 width, uint32 height, uint8 *data, uint8 *mask, uint32 hot_x, uint32 hot_y);
t_bool vid_is_fullscreen_window (VID_DISPLAY *vptr);
t_stat vid_set_fullscreen_window (VID_DISPLAY *vptr, t_bool flag);
void vid_set_cursor_position_window (VID_DISPLAY *vptr, int32 x, int32 y); /* cursor position (set by calling code) */
t_stat vid_set_alpha_mode (VID_DISPLAY *vptr, int mode);
/* A device simulator can optionally set the vid_display_kb_event_process
* routine pointer to the address of a routine.