From 35678bafd5d1974dff0cdbc210274f65c60daff1 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Sun, 23 Oct 2022 10:42:00 -0500 Subject: [PATCH] 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. --- PDP11/pdp11_ng.c | 8 +++---- display/ng.c | 54 +++++++++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/PDP11/pdp11_ng.c b/PDP11/pdp11_ng.c index cf0fd35a..d5f1ae27 100644 --- a/PDP11/pdp11_ng.c +++ b/PDP11/pdp11_ng.c @@ -1,7 +1,7 @@ #ifdef USE_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 copy of this software and associated documentation files (the "Software"), @@ -230,11 +230,9 @@ ng_boot(int32 unit, DEVICE *dptr) t_stat ng_set_type(UNIT *uptr, int32 val, CONST char *cptr, void *desc) { - //if ((uptr->flags & DEV_DIS) == 0) - //return SCPE_ALATT; - if (MATCH_CMD (cptr, "DAZZLE")) + if (MATCH_CMD (cptr, "DAZZLE") == 0) ng_type = TYPE_DAZZLE; - else if (MATCH_CMD (cptr, "LOGO")) + else if (MATCH_CMD (cptr, "LOGO") == 0) ng_type = TYPE_LOGO; else return SCPE_ARG; diff --git a/display/ng.c b/display/ng.c index c404550f..a8fbbc61 100644 --- a/display/ng.c +++ b/display/ng.c @@ -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 +#include #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,15 @@ 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; } int32 @@ -90,19 +95,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 +121,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 +226,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 +307,7 @@ ng_cycle(int us, int slowdown) static uint32 usec = 0; static uint32 msec = 0; uint32 new_msec; + int saved; new_msec = (usec += us) / 1000; @@ -307,20 +317,21 @@ 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 + } else if (ng_type != TYPE_DAZZLE) return 1; if (sync_period) goto age_ret; + saved = console; for (console = 0; console < 1; console++) { + if (ng_type == TYPE_DAZZLE && (status[console] & TKRUN) == 0) + continue; + time_out = fetch(dpc[console], &inst); DEBUGF("[%d] PC %06o, INSTR %06o\n", console, dpc[console], inst); dpc[console] += 2; @@ -339,6 +350,7 @@ ng_cycle(int us, int slowdown) break; } } + console = saved; age_ret: display_age(us, slowdown);