Bug fixes for various video code. (#80)

* VIDEO: Fix bug: vid_ready can be used uninitialized.

* VIDEO: Not all events come with a valid windowID.

* PDP11: Fix NG SET TYPE.

The sense of MATCH_CMD is reversed.

* display: Fix bug in NG display controller.

There should be a separate state for each of the eight displays.

* display: Symbolic constant for number of displays.
This commit is contained in:
Lars Brinkhoff 2022-10-23 10:42:00 -05:00 committed by GitHub
parent 65410851d5
commit 2a4e4dc10d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 31 deletions

View file

@ -1,7 +1,7 @@
#ifdef USE_DISPLAY #ifdef USE_DISPLAY
/* pdp11_ng.c: NG, Knight vector display /* pdp11_ng.c: NG, Knight vector display
Copyright (c) 2018, Lars Brinkhoff Copyright (c) 2018, 2022, Lars Brinkhoff
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), copy of this software and associated documentation files (the "Software"),
@ -232,11 +232,9 @@ ng_boot(int32 unit, DEVICE *dptr)
t_stat t_stat
ng_set_type(UNIT *uptr, int32 val, CONST char *cptr, void *desc) ng_set_type(UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{ {
//if ((uptr->flags & DEV_DIS) == 0) if (MATCH_CMD (cptr, "DAZZLE") == 0)
//return SCPE_ALATT;
if (MATCH_CMD (cptr, "DAZZLE"))
ng_type = TYPE_DAZZLE; ng_type = TYPE_DAZZLE;
else if (MATCH_CMD (cptr, "LOGO")) else if (MATCH_CMD (cptr, "LOGO") == 0)
ng_type = TYPE_LOGO; ng_type = TYPE_LOGO;
else else
return SCPE_ARG; return SCPE_ARG;

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

View file

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