Skip to content

Commit 1e3586e

Browse files
committed
DISPLAY: Latest version of display code from Phil Budne and Doug Gwyn including initial pdp1_dpy and pdp11_vt
1 parent 026dd98 commit 1e3586e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+21636
-8327
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
*.vcproj binary
44
*.exe binary
55
*.bin binary
6+
*.rim binary
67
sim_rev.h export-subst
78

PDP1/pdp1_cpu.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
2626
cpu PDP-1 central processor
2727
28-
210Mar-12 RMS Fixed & vs && in Ea_ch (Michael Bloom)
28+
21-Mar-12 RMS Fixed & vs && in Ea_ch (Michael Bloom)
2929
30-May-07 RMS Fixed typo in SBS clear (Norm Lastovica)
3030
28-Dec-06 RMS Added 16-channel SBS support, PDP-1D support
3131
28-Jun-06 RMS Fixed bugs in MUS and DIV
3232
22-Sep-05 RMS Fixed declarations (Sterling Garwood)
3333
16-Aug-05 RMS Fixed C++ declaration and cast problems
3434
09-Nov-04 RMS Added instruction history
35+
08-Feb-04 PLB Added display device spacewar/test switches
3536
07-Sep-03 RMS Added additional explanation on I/O simulation
3637
01-Sep-03 RMS Added address switches for hardware readin
3738
23-Jul-03 RMS Revised to detect I/O wait hang
@@ -360,6 +361,10 @@ extern int32 dt (int32 inst, int32 dev, int32 dat);
360361
extern int32 drm (int32 inst, int32 dev, int32 dat);
361362
extern int32 clk (int32 inst, int32 dev, int32 dat);
362363
extern int32 dcs (int32 inst, int32 dev, int32 dat);
364+
#ifdef USE_DISPLAY
365+
extern int32 dpy (int32 inst, int32 dev, int32 dat, int32 dat2);
366+
extern int32 spacewar (int32 inst, int32 dev, int32 dat);
367+
#endif
363368

364369
const int32 sc_map[512] = {
365370
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, /* 00000xxxx */
@@ -1203,6 +1208,11 @@ while (reason == 0) { /* loop until halted */
12031208
io_data = ptp (IR, dev, IO);
12041209
break;
12051210

1211+
#ifdef USE_DISPLAY
1212+
case 007: /* display */
1213+
io_data = dpy (IR, dev, IO, AC);
1214+
break;
1215+
#endif
12061216
case 010: /* leave ring mode */
12071217
if (cpu_unit.flags & UNIT_1D)
12081218
PF = PF & ~PF_RNG;
@@ -1212,7 +1222,12 @@ while (reason == 0) { /* loop until halted */
12121222
case 011: /* enter ring mode */
12131223
if (cpu_unit.flags & UNIT_1D)
12141224
PF = PF | PF_RNG;
1215-
else reason = stop_inst;
1225+
else
1226+
#ifdef USE_DISPLAY
1227+
io_data = spacewar (IR, dev, IO);
1228+
#else
1229+
reason = stop_inst;
1230+
#endif
12161231
break;
12171232

12181233
case 022: /* data comm sys */
@@ -1685,3 +1700,19 @@ for (k = 0; k < lnt; k++) { /* print specified */
16851700
} /* end for */
16861701
return SCPE_OK;
16871702
}
1703+
1704+
#ifdef USE_DISPLAY
1705+
/* set "test switches"; from display code */
1706+
void
1707+
cpu_set_switches(unsigned long bits)
1708+
{
1709+
/* just what we want; smaller CPUs might want to shift down? */
1710+
TW = bits;
1711+
}
1712+
1713+
unsigned long
1714+
cpu_get_switches(void)
1715+
{
1716+
return TW;
1717+
}
1718+
#endif

PDP1/pdp1_dpy.c

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/* pdp1_dpy.c: PDP-1 display simulator
2+
3+
Copyright (c) 2004, Philip L. Budne
4+
Copyright (c) 1993-2003, Robert M. Supnik
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
Except as contained in this notice, the names of the authors shall not be
24+
used in advertising or otherwise to promote the sale, use or other dealings
25+
in this Software without prior written authorization from the authors.
26+
27+
dpy Type 30 Display for the PDP-1
28+
02-Feb-04 PLB Revamp intensity levels
29+
02-Jan-04 DAG Provide dummy global when display not supported
30+
16-Sep-03 PLB Update for SIMH 3.0-2
31+
12-Sep-03 PLB Add spacewar switch support
32+
04-Sep-03 PLB Start from pdp1_lp.c
33+
*/
34+
35+
#ifdef USE_DISPLAY
36+
#include "pdp1_defs.h"
37+
#include "display/display.h"
38+
39+
extern int32 ios, cpls, iosta, PF;
40+
extern int32 stop_inst;
41+
42+
t_stat dpy_svc (UNIT *uptr);
43+
t_stat dpy_reset (DEVICE *dptr);
44+
45+
/* DPY data structures
46+
47+
dpy_dev DPY device descriptor
48+
dpy_unit DPY unit
49+
dpy_reg DPY register list
50+
*/
51+
52+
#define CYCLE_TIME 5 /* 5us memory cycle */
53+
#define DPY_WAIT (50/CYCLE_TIME) /* 50us */
54+
55+
UNIT dpy_unit = {
56+
UDATA (&dpy_svc, UNIT_ATTABLE, 0), DPY_WAIT };
57+
58+
DEVICE dpy_dev = {
59+
"DPY", &dpy_unit, NULL, NULL,
60+
1, 10, 31, 1, 8, 8,
61+
NULL, NULL, &dpy_reset,
62+
NULL, NULL, NULL,
63+
NULL, DEV_DIS | DEV_DISABLE };
64+
65+
/* Display IOT routine */
66+
67+
int32 dpy (int32 inst, int32 dev, int32 io, int32 ac)
68+
{
69+
int32 x, y;
70+
int level;
71+
72+
if (dpy_dev.flags & DEV_DIS) /* disabled? */
73+
return (stop_inst << IOT_V_REASON) | io; /* stop if requested */
74+
if (GEN_CPLS (inst)) { /* comp pulse? */
75+
ios = 0; /* clear flop */
76+
cpls = cpls | CPLS_DPY; } /* request completion */
77+
else cpls = cpls & ~CPLS_DPY;
78+
79+
x = (ac >> 8) & 01777; /* high ten bits of ac */
80+
y = (io >> 8) & 01777; /* high ten bits of io */
81+
/*
82+
* convert one's complement -511..+511 center origin
83+
* to 0..1022 (lower left origin)
84+
*/
85+
if (x & 01000)
86+
x ^= 01000;
87+
else
88+
x += 511;
89+
if (y & 01000)
90+
y ^= 01000;
91+
else
92+
y += 511;
93+
94+
/* intensity, from values seen in spacewar (40,00,01,02,03) */
95+
switch ((inst >> 6) & 077) {
96+
case 01: level = DISPLAY_INT_MAX-5; break;
97+
case 02: level = DISPLAY_INT_MAX-4; break;
98+
case 03: level = DISPLAY_INT_MAX-2; break;
99+
case 040: /* super bright? */
100+
default: level = DISPLAY_INT_MAX; break;
101+
}
102+
103+
if (display_point(x,y,level,0)) {
104+
/* here with light pen hit */
105+
PF = PF | 010; /* set prog flag 3 */
106+
iosta |= IOS_TTI; /* set io status flag */
107+
}
108+
else
109+
iosta &= ~IOS_TTI; /* clear io status flag */
110+
sim_activate (&dpy_unit, dpy_unit.wait); /* activate */
111+
112+
return io;
113+
}
114+
115+
/*
116+
* Unit service routine
117+
*
118+
* Under X11 this includes polling for events, so it can't be
119+
* call TOO infrequently...
120+
*/
121+
t_stat dpy_svc (UNIT *uptr)
122+
{
123+
if (cpls & CPLS_DPY) { /* completion pulse? */
124+
ios = 1; /* restart */
125+
cpls = cpls & ~CPLS_DPY; } /* clr pulse pending */
126+
127+
display_age(dpy_unit.wait*CYCLE_TIME, 1);
128+
sim_activate (&dpy_unit, dpy_unit.wait); /* requeue! */
129+
return SCPE_OK;
130+
}
131+
132+
/* Reset routine */
133+
134+
t_stat dpy_reset (DEVICE *dptr)
135+
{
136+
if (!(dptr->flags & DEV_DIS)) {
137+
display_reset();
138+
cpls = cpls & ~CPLS_DPY;
139+
iosta = iosta & ~(IOS_PNT | IOS_SPC); /* clear flags */
140+
}
141+
sim_cancel (&dpy_unit); /* deactivate unit */
142+
return SCPE_OK;
143+
}
144+
145+
int32 spacewar (int32 inst, int32 dev, int32 io)
146+
{
147+
if (dpy_dev.flags & DEV_DIS) /* disabled? */
148+
return (stop_inst << IOT_V_REASON) | io; /* stop if requested */
149+
return spacewar_switches;
150+
}
151+
#else /* USE_DISPLAY not defined */
152+
char pdp1_dpy_unused; /* sometimes empty object modules cause problems */
153+
#endif /* USE_DISPLAY not defined */

PDP1/pdp1_sys.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ extern DEVICE dt_dev;
5858
extern DEVICE drm_dev;
5959
extern DEVICE drp_dev;
6060
extern DEVICE dcs_dev, dcsl_dev;
61+
#if defined(USE_DISPLAY)
6162
extern DEVICE dpy_dev;
63+
#endif
6264
extern UNIT cpu_unit;
6365
extern REG cpu_reg[];
6466
extern int32 M[];
@@ -95,7 +97,9 @@ DEVICE *sim_devices[] = {
9597
&drp_dev,
9698
&dcs_dev,
9799
&dcsl_dev,
98-
/* &dpy_dev, */
100+
#if defined(USE_DISPLAY)
101+
&dpy_dev,
102+
#endif
99103
NULL
100104
};
101105

PDP1/spacewar1/README

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Preliminary PDP-1 Spacewar README
2+
Phil Budne
3+
February 9, 2004
4+
5+
Both spacewar.mac and macro1.c are available from Phil's CVS server.
6+
see http://www.ultimate.com/phil/xy
7+
8+
cvs -d :pserver:[email protected]:/home/cvs login
9+
Password: anonymous
10+
cvs -d :pserver:[email protected]:/home/cvs co history/pdp1
11+
12+
13+
README.MIT
14+
readme from MIT
15+
contains history, and instructions
16+
17+
spacewar.mac
18+
spacewar 3.1 (24 sep 62) retyped at MIT from a listing,
19+
originally assembled using a Perl macro-expander and assembler,
20+
and run under a Java PDP-1 emulator.
21+
22+
This version modified by Phil Budne to assemble under his
23+
version of "macro1" (see below)
24+
25+
Note that low memory (locations 6 thru 31) contains various
26+
manifest constants which can be tweaked to alter the game's
27+
behavior!
28+
29+
spacewar.rim
30+
above assembled by Phil Budne's macro1
31+
32+
PDP-1 RIM of "loader" followed by loader blocks:
33+
34+
PDP-1 simulator V4.0
35+
sim> set dpy enable
36+
sim> attach ptr spacewar.rim
37+
sim> boot ptr
38+
39+
controls compatible with MIT Java simulation, see README.LCS
40+
or display/README from your SIMH distribution
41+
42+
munch.mac
43+
"munching squares" display hack, reconstructed
44+
from world.std.com/~dpbsmith/munch.html
45+
46+
munch.rim
47+
binary of munching squares.
48+
49+
reads console switches:
50+
Upto 18 simulated console switches, toggled by hitting keys:
51+
52+
123 456 789 qwe rty uio
53+
54+
space bar clears all switches.
55+
56+
assembled with '-r' option, so it can be "loaded" directly:
57+
58+
PDP-1 simulator V4.0
59+
sim> set dpy enable
60+
sim> load munch.rim
61+
sim> run
62+
63+
macro1.c
64+
Phil Budne's version of the MACRO cross-assembler

PDP1/spacewar1/README.MIT

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Spacewar! was conceived in 1961 by Martin Graetz, Stephen Russell, and
3+
Wayne Wiitanen. It was first realized on the PDP-1 in 1962 by Stephen
4+
Russell, Peter Samson, Dan Edwards, and Martin Graetz, together with
5+
Alan Kotok, Steve Piner, and Robert A Saunders. Spacewar! is in the
6+
public domain, but this credit paragraph must accompany all
7+
distributed versions of the program.
8+
9+
This is the original version! Martin Graetz provided us with a printed
10+
version of the source. We typed in in again - it was about 40 pages
11+
long - and re-assembled it with a PDP-1 assembler written in PERL. The
12+
resulting binary runs on a PDP-1 emulator written as a Java applet.
13+
The code is extremely faithful to the original. There are only two
14+
changes. 1)The spaceships have been made bigger and 2) The overall
15+
timing has been special cased to deal with varying machine speeds.
16+
17+
The sources are available in a subdirectory called "sources".
18+
19+
The "a", "s", "d", "f" keys control one of the spaceships. The "k",
20+
"l", ";", "'" keys control the other. The controls are spin one way,
21+
spin the other, thrust, and fire.
22+
23+
Barry Silverman
24+
Brian Silverman
25+
Vadim Gerasimov

0 commit comments

Comments
 (0)