1- /* pdp18b_dpy.c: PDP-7 Type 340 interface
1+ /* pdp18b_dpy.c: PDP-7 Type 34 and Type 340 interface
22
3- Copyright (c) 2019, Lars Brinkhoff
3+ Copyright (c) 2019, 2026, Lars Brinkhoff
44
55 Permission is hereby granted, free of charge, to any person obtaining a
66 copy of this software and associated documentation files (the "Software"),
3838#define DBG_IOT 001 /* IOT instructions. */
3939#define DBG_IRQ 002 /* Interrupts. */
4040#define DBG_INS 004 /* 340 instructions. */
41+ #define DBG_PLT 010 /* Points plotted. */
42+
43+ #define UNIT_V_TYPE34 (UNIT_V_UF + 0) /* Type 34 */
44+ #define UNIT_TYPE34 (1 << UNIT_V_TYPE34)
45+ #define TYPE34 (dpy_unit[0].flags & UNIT_TYPE34)
4146
4247/*
4348 * Number of microseconds between svc calls. Used to age display and
@@ -63,23 +68,33 @@ DEBTAB dpy_deb[] = {
6368 { "IOT" , DBG_IOT },
6469 { "IRQ" , DBG_IRQ },
6570 { "INS" , DBG_INS },
71+ { "PLT" , DBG_PLT },
6672 { NULL , 0 }
6773 };
6874
75+ MTAB dpy_mod [] = {
76+ { UNIT_TYPE34 , UNIT_TYPE34 , "Type 34" , "TYPE34" , NULL },
77+ { UNIT_TYPE34 , 0 , "Type 340" , "TYPE340" , NULL },
78+ { 0 }
79+ };
80+
6981DEVICE dpy_dev = {
70- "DPY" , dpy_unit , NULL , NULL ,
82+ "DPY" , dpy_unit , NULL , dpy_mod ,
7183 1 , 8 , 12 , 1 , 8 , 18 ,
7284 NULL , NULL , & dpy_reset ,
7385 NULL , NULL , NULL ,
7486 & dpy_dib , DEV_DISABLE | DEV_DIS | DEV_DEBUG , 0 ,
7587 dpy_deb , NULL , NULL
7688 };
7789
90+ static uint16 dpy_x , dpy_y , dpy_i ;
91+
7892t_stat dpy_svc (UNIT * uptr )
7993{
8094 sim_activate_after (uptr , DPY_CYCLE_US );
8195 display_age (DPY_CYCLE_US , 0 );
82- ty340_cycle ();
96+ if (!TYPE34 )
97+ ty340_cycle ();
8398 return SCPE_OK ;
8499}
85100
@@ -95,7 +110,10 @@ t_stat dpy_reset (DEVICE *dptr)
95110 display_reset ();
96111 ty340_reset (dptr );
97112 }
98- sim_cancel (& dpy_unit [0 ]);
113+ if (TYPE34 )
114+ sim_activate_abs (dpy_unit , 0 );
115+ else
116+ sim_cancel (& dpy_unit [0 ]);
99117 return SCPE_OK ;
100118}
101119
@@ -132,18 +150,34 @@ int32 dpy05 (int32 dev, int32 pulse, int32 dat)
132150{
133151 sim_debug (DBG_IOT , & dpy_dev , "7005%02o, %06o\n" , pulse , dat );
134152
135- if (pulse & 001 ) {
153+ if (( pulse & 001 ) != 0 && ! TYPE34 ) {
136154 if (ty340_sense (ST340_VEDGE ))
137155 dat |= IOT_SKP ;
138156 }
139157
140158 if (pulse & 002 ) {
141- dat |= ty340_get_dac ();
159+ if (TYPE34 ) {
160+ sim_debug (DBG_IOT , & dpy_dev , "Clear X\n" );
161+ dpy_x = 0 ;
162+ } else {
163+ dat |= ty340_get_dac ();
164+ }
142165 }
143166
144167 if (pulse & 004 ) {
145- ty340_clear (ST340_LPHIT );
146- sim_activate_abs (dpy_unit , 0 );
168+ if (TYPE34 ) {
169+ dpy_x |= dat & 01777 ;
170+ sim_debug (DBG_IOT , & dpy_dev , "Set X to %04o\n" , dpy_x );
171+ } else {
172+ ty340_clear (ST340_LPHIT );
173+ sim_activate_abs (dpy_unit , 0 );
174+ }
175+ }
176+
177+ if ((pulse & 040 ) != 0 && TYPE34 ) {
178+ sim_debug (DBG_PLT , & dpy_dev , "Plot %04o,%04o intensity %o\n" ,
179+ dpy_x , dpy_y , dpy_i );
180+ display_point (dpy_x , dpy_y , (dpy_i * DISPLAY_INT_MAX ) / 7 , 0 );
147181 }
148182
149183 return dat ;
@@ -153,20 +187,36 @@ int32 dpy06 (int32 dev, int32 pulse, int32 dat)
153187{
154188 sim_debug (DBG_IOT , & dpy_dev , "7006%02o, %06o\n" , pulse , dat );
155189
156- if (pulse & 001 ) {
190+ if (( pulse & 001 ) != 0 && ! TYPE34 ) {
157191 if (ty340_sense (ST340_STOPPED ))
158192 dat |= IOT_SKP ;
159193 }
160194
161195 if (pulse & 002 ) {
162- ty340_set_dac (0 );
196+ if (TYPE34 ) {
197+ sim_debug (DBG_IOT , & dpy_dev , "Clear Y\n" );
198+ dpy_y = 0 ;
199+ } else {
200+ ty340_set_dac (0 );
201+ }
163202 }
164203
165204 if (pulse & 004 ) {
166- if ((pulse & 010 ) == 0 )
167- ty340_set_dac (dat & 07777 );
168- ty340_clear (ST340_STOPPED |ST340_STOP_INT );
169- sim_activate_abs (dpy_unit , 0 );
205+ if (TYPE34 ) {
206+ dpy_y |= dat & 01777 ;
207+ sim_debug (DBG_IOT , & dpy_dev , "Set Y to %04o\n" , dpy_y );
208+ } else {
209+ if ((pulse & 010 ) == 0 )
210+ ty340_set_dac (dat & 07777 );
211+ ty340_clear (ST340_STOPPED |ST340_STOP_INT );
212+ sim_activate_abs (dpy_unit , 0 );
213+ }
214+ }
215+
216+ if ((pulse & 040 ) != 0 && TYPE34 ) {
217+ sim_debug (DBG_PLT , & dpy_dev , "Plot %04o,%04o intensity %o\n" ,
218+ dpy_x , dpy_y , dpy_i );
219+ display_point (dpy_x , dpy_y , (dpy_i * DISPLAY_INT_MAX ) / 7 , 0 );
170220 }
171221
172222 return dat ;
@@ -176,6 +226,15 @@ int32 dpy07 (int32 dev, int32 pulse, int32 dat)
176226{
177227 sim_debug (DBG_IOT , & dpy_dev , "7007%02o, %06o\n" , pulse , dat );
178228
229+ if (TYPE34 ) {
230+ if (dat & 4 )
231+ dpy_i = 7 - (dat & 7 );
232+ else
233+ dpy_i = (dat & 3 ) + 4 ;
234+ sim_debug (DBG_IOT , & dpy_dev , "Set intensity to %06o\n" , dpy_i );
235+ return dat ;
236+ }
237+
179238 if (pulse & 001 ) {
180239 if (ty340_sense (ST340_LPHIT ))
181240 dat |= IOT_SKP ;
@@ -196,6 +255,9 @@ int32 dpy10 (int32 dev, int32 pulse, int32 dat)
196255{
197256 sim_debug (DBG_IOT , & dpy_dev , "7010%02o, %06o\n" , pulse , dat );
198257
258+ if (TYPE34 )
259+ return dat ;
260+
199261 if (pulse & 001 ) {
200262 if (ty340_sense (ST340_HEDGE ))
201263 dat |= IOT_SKP ;
0 commit comments