DISPLAY: Latest version of display code from Phil Budne and Doug Gwyn including initial pdp1_dpy and pdp11_vt

This commit is contained in:
Mark Pizzolato 2013-10-16 01:02:12 -07:00
parent 026dd98d83
commit 1e3586ec91
42 changed files with 21636 additions and 8327 deletions

1
.gitattributes vendored
View file

@ -3,5 +3,6 @@
*.vcproj binary
*.exe binary
*.bin binary
*.rim binary
sim_rev.h export-subst

View file

@ -25,13 +25,14 @@
cpu PDP-1 central processor
210Mar-12 RMS Fixed & vs && in Ea_ch (Michael Bloom)
21-Mar-12 RMS Fixed & vs && in Ea_ch (Michael Bloom)
30-May-07 RMS Fixed typo in SBS clear (Norm Lastovica)
28-Dec-06 RMS Added 16-channel SBS support, PDP-1D support
28-Jun-06 RMS Fixed bugs in MUS and DIV
22-Sep-05 RMS Fixed declarations (Sterling Garwood)
16-Aug-05 RMS Fixed C++ declaration and cast problems
09-Nov-04 RMS Added instruction history
08-Feb-04 PLB Added display device spacewar/test switches
07-Sep-03 RMS Added additional explanation on I/O simulation
01-Sep-03 RMS Added address switches for hardware readin
23-Jul-03 RMS Revised to detect I/O wait hang
@ -360,6 +361,10 @@ extern int32 dt (int32 inst, int32 dev, int32 dat);
extern int32 drm (int32 inst, int32 dev, int32 dat);
extern int32 clk (int32 inst, int32 dev, int32 dat);
extern int32 dcs (int32 inst, int32 dev, int32 dat);
#ifdef USE_DISPLAY
extern int32 dpy (int32 inst, int32 dev, int32 dat, int32 dat2);
extern int32 spacewar (int32 inst, int32 dev, int32 dat);
#endif
const int32 sc_map[512] = {
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 */
io_data = ptp (IR, dev, IO);
break;
#ifdef USE_DISPLAY
case 007: /* display */
io_data = dpy (IR, dev, IO, AC);
break;
#endif
case 010: /* leave ring mode */
if (cpu_unit.flags & UNIT_1D)
PF = PF & ~PF_RNG;
@ -1212,7 +1222,12 @@ while (reason == 0) { /* loop until halted */
case 011: /* enter ring mode */
if (cpu_unit.flags & UNIT_1D)
PF = PF | PF_RNG;
else reason = stop_inst;
else
#ifdef USE_DISPLAY
io_data = spacewar (IR, dev, IO);
#else
reason = stop_inst;
#endif
break;
case 022: /* data comm sys */
@ -1685,3 +1700,19 @@ for (k = 0; k < lnt; k++) { /* print specified */
} /* end for */
return SCPE_OK;
}
#ifdef USE_DISPLAY
/* set "test switches"; from display code */
void
cpu_set_switches(unsigned long bits)
{
/* just what we want; smaller CPUs might want to shift down? */
TW = bits;
}
unsigned long
cpu_get_switches(void)
{
return TW;
}
#endif

153
PDP1/pdp1_dpy.c Normal file
View file

@ -0,0 +1,153 @@
/* pdp1_dpy.c: PDP-1 display simulator
Copyright (c) 2004, Philip L. Budne
Copyright (c) 1993-2003, Robert M. Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the names of the authors shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the authors.
dpy Type 30 Display for the PDP-1
02-Feb-04 PLB Revamp intensity levels
02-Jan-04 DAG Provide dummy global when display not supported
16-Sep-03 PLB Update for SIMH 3.0-2
12-Sep-03 PLB Add spacewar switch support
04-Sep-03 PLB Start from pdp1_lp.c
*/
#ifdef USE_DISPLAY
#include "pdp1_defs.h"
#include "display/display.h"
extern int32 ios, cpls, iosta, PF;
extern int32 stop_inst;
t_stat dpy_svc (UNIT *uptr);
t_stat dpy_reset (DEVICE *dptr);
/* DPY data structures
dpy_dev DPY device descriptor
dpy_unit DPY unit
dpy_reg DPY register list
*/
#define CYCLE_TIME 5 /* 5us memory cycle */
#define DPY_WAIT (50/CYCLE_TIME) /* 50us */
UNIT dpy_unit = {
UDATA (&dpy_svc, UNIT_ATTABLE, 0), DPY_WAIT };
DEVICE dpy_dev = {
"DPY", &dpy_unit, NULL, NULL,
1, 10, 31, 1, 8, 8,
NULL, NULL, &dpy_reset,
NULL, NULL, NULL,
NULL, DEV_DIS | DEV_DISABLE };
/* Display IOT routine */
int32 dpy (int32 inst, int32 dev, int32 io, int32 ac)
{
int32 x, y;
int level;
if (dpy_dev.flags & DEV_DIS) /* disabled? */
return (stop_inst << IOT_V_REASON) | io; /* stop if requested */
if (GEN_CPLS (inst)) { /* comp pulse? */
ios = 0; /* clear flop */
cpls = cpls | CPLS_DPY; } /* request completion */
else cpls = cpls & ~CPLS_DPY;
x = (ac >> 8) & 01777; /* high ten bits of ac */
y = (io >> 8) & 01777; /* high ten bits of io */
/*
* convert one's complement -511..+511 center origin
* to 0..1022 (lower left origin)
*/
if (x & 01000)
x ^= 01000;
else
x += 511;
if (y & 01000)
y ^= 01000;
else
y += 511;
/* intensity, from values seen in spacewar (40,00,01,02,03) */
switch ((inst >> 6) & 077) {
case 01: level = DISPLAY_INT_MAX-5; break;
case 02: level = DISPLAY_INT_MAX-4; break;
case 03: level = DISPLAY_INT_MAX-2; break;
case 040: /* super bright? */
default: level = DISPLAY_INT_MAX; break;
}
if (display_point(x,y,level,0)) {
/* here with light pen hit */
PF = PF | 010; /* set prog flag 3 */
iosta |= IOS_TTI; /* set io status flag */
}
else
iosta &= ~IOS_TTI; /* clear io status flag */
sim_activate (&dpy_unit, dpy_unit.wait); /* activate */
return io;
}
/*
* Unit service routine
*
* Under X11 this includes polling for events, so it can't be
* call TOO infrequently...
*/
t_stat dpy_svc (UNIT *uptr)
{
if (cpls & CPLS_DPY) { /* completion pulse? */
ios = 1; /* restart */
cpls = cpls & ~CPLS_DPY; } /* clr pulse pending */
display_age(dpy_unit.wait*CYCLE_TIME, 1);
sim_activate (&dpy_unit, dpy_unit.wait); /* requeue! */
return SCPE_OK;
}
/* Reset routine */
t_stat dpy_reset (DEVICE *dptr)
{
if (!(dptr->flags & DEV_DIS)) {
display_reset();
cpls = cpls & ~CPLS_DPY;
iosta = iosta & ~(IOS_PNT | IOS_SPC); /* clear flags */
}
sim_cancel (&dpy_unit); /* deactivate unit */
return SCPE_OK;
}
int32 spacewar (int32 inst, int32 dev, int32 io)
{
if (dpy_dev.flags & DEV_DIS) /* disabled? */
return (stop_inst << IOT_V_REASON) | io; /* stop if requested */
return spacewar_switches;
}
#else /* USE_DISPLAY not defined */
char pdp1_dpy_unused; /* sometimes empty object modules cause problems */
#endif /* USE_DISPLAY not defined */

View file

@ -58,7 +58,9 @@ extern DEVICE dt_dev;
extern DEVICE drm_dev;
extern DEVICE drp_dev;
extern DEVICE dcs_dev, dcsl_dev;
#if defined(USE_DISPLAY)
extern DEVICE dpy_dev;
#endif
extern UNIT cpu_unit;
extern REG cpu_reg[];
extern int32 M[];
@ -95,7 +97,9 @@ DEVICE *sim_devices[] = {
&drp_dev,
&dcs_dev,
&dcsl_dev,
/* &dpy_dev, */
#if defined(USE_DISPLAY)
&dpy_dev,
#endif
NULL
};

64
PDP1/spacewar1/README Normal file
View file

@ -0,0 +1,64 @@
Preliminary PDP-1 Spacewar README
Phil Budne
February 9, 2004
Both spacewar.mac and macro1.c are available from Phil's CVS server.
see http://www.ultimate.com/phil/xy
cvs -d :pserver:anonymous@cvs.ultimate.com:/home/cvs login
Password: anonymous
cvs -d :pserver:anonymous@cvs.ultimate.com:/home/cvs co history/pdp1
README.MIT
readme from MIT
contains history, and instructions
spacewar.mac
spacewar 3.1 (24 sep 62) retyped at MIT from a listing,
originally assembled using a Perl macro-expander and assembler,
and run under a Java PDP-1 emulator.
This version modified by Phil Budne to assemble under his
version of "macro1" (see below)
Note that low memory (locations 6 thru 31) contains various
manifest constants which can be tweaked to alter the game's
behavior!
spacewar.rim
above assembled by Phil Budne's macro1
PDP-1 RIM of "loader" followed by loader blocks:
PDP-1 simulator V4.0
sim> set dpy enable
sim> attach ptr spacewar.rim
sim> boot ptr
controls compatible with MIT Java simulation, see README.LCS
or display/README from your SIMH distribution
munch.mac
"munching squares" display hack, reconstructed
from world.std.com/~dpbsmith/munch.html
munch.rim
binary of munching squares.
reads console switches:
Upto 18 simulated console switches, toggled by hitting keys:
123 456 789 qwe rty uio
space bar clears all switches.
assembled with '-r' option, so it can be "loaded" directly:
PDP-1 simulator V4.0
sim> set dpy enable
sim> load munch.rim
sim> run
macro1.c
Phil Budne's version of the MACRO cross-assembler

25
PDP1/spacewar1/README.MIT Normal file
View file

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

3068
PDP1/spacewar1/macro1.c Normal file

File diff suppressed because it is too large Load diff

21
PDP1/spacewar1/munch.mac Normal file
View file

@ -0,0 +1,21 @@
munching squares
1000/
// from dpbsmith's web page:
// http://world.std.com/~dpbsmith/munch.html
// classic: 04000
// fun: 1, 4014, 4016, 100000
foo, lat
add \v
dac v
rcl 9s
xor v
dpy-4000
jmp foo
variables
start foo

BIN
PDP1/spacewar1/munch.rim Normal file

Binary file not shown.

1857
PDP1/spacewar1/spacewar.mac Normal file

File diff suppressed because it is too large Load diff

BIN
PDP1/spacewar1/spacewar.rim Normal file

Binary file not shown.

52
PDP11/lunar11/README.txt Normal file
View file

@ -0,0 +1,52 @@
VT11/GT40 Lunar Lander files
preliminary README phil
Phil Budne
February 9, 2004
Lunar lander startup can take forever (lander uses spin loop to count
down time for display of starting screen. This may be due to the fact
that SIMH only tracks cycles in terms of instructions, not execution
time). To speed up display of the startup screen, deposit a 1 in
location 32530 after loading the lander program, and before starting
it;
sim> ! Set CPU to a Unibus system type
sim> set cpu 11/70
sim> ! Enable DLI device so VT device autoconfigures
sim> ! with a starting vector of 320
sim> set dli enable
sim> set dli line=2
sim> ! Enable VT device
sim> set vt enable
sim> load lunar.lda
sim> dep 32530 1
sim> run
Lunar lander only needs a small screen area, and can run using a
simulated "VR14" display, which can fit on many computer screens
without scaling:
sim> set vt crt=vr14
sim> set vt scale=1
For more information on the VT11/GT40 see
http://www.brouhaha.com/~eric/retrocomputing/dec/gt40/
lunar.txt
Lunar lander instructions
(from ???)
lunar.lda
PDP-11 Paper Tape (LDA) format
http://www.brouhaha.com/~eric/retrocomputing/dec/gt40/software/moonlander/lunar.lda
lunar.dag
PDP-11 Paper Tape (LDA) format
above(?) as patched by Doug Gwyn to fix a spelling error?
load fails with bad checksum under 3.2-preview2?
gtlem.mac
Does not match above binaries??
http://www.brouhaha.com/~eric/retrocomputing/dec/gt40/software/moonlander/gtlem.mac

5102
PDP11/lunar11/gtlem.mac Normal file

File diff suppressed because it is too large Load diff

BIN
PDP11/lunar11/lunar.dag Normal file

Binary file not shown.

BIN
PDP11/lunar11/lunar.lda Normal file

Binary file not shown.

114
PDP11/lunar11/lunar.txt Normal file
View file

@ -0,0 +1,114 @@
PLAYING MOONLANDER (LEM)
The object of moonlander is to land a lunar module on the
surface of the moon. The program will run on any 8K GT40
with a light pen and a clock. If you are attached to a PDP-10
you may use the ROM bootstrap to bring over the assembled
binary. If you are not "talking" to a PDP-10, you may load
in the binary loader (absolute loader) and load in the paper
tape version of the program. Note: the program will destroy
the binary loader when it starts running.
When the program is loaded, it will automatically start and
display an "introductory message" on the screen. Future
restart of the program will not cause this message to be
displayed. Should any problems occur, the program may be
restarted at any time at location zero (000000). Power fail
protection is also provided. After starting (or restarting),
you then start playing the actual game. All numbers, speeds,
weights, etc., are actual numbers. They are for real. To
make the game more possible for an average person to play, I
have given him about 25 to 50% more fuel in the final stages
of landing than he would actually have.
What the user sees on the screen is a broad and extremely
mountainous view of the moon. On the right is a list of data
parameters which the user may examine. They are height,
altitude, angle, fuel left, thrust, weight, horizontal velocity,
vertical velocity, horizontal acceleration, vertical accelera-
tion, distance and seconds. At the top of the screen, any
four of the values may be displayed. To display an item, the
user points the light pen at the item he wishes to display.
The item will then start blinking, to indicate that this is the
item to be displayed. The user then points the light pen at
one of the previously displayed items at the top of the screen.
The old item disappears and is replaced by the new item.
Note that it is possible to display any item anywhere, and even
possible to display one item four times at the top. Anyway,
the parameters mean the following. Height is the height in
feet above the surface (terrain) of the moon. It is the "radar"
height. Altitude is the height above the "mean" height of the
moon ( I guess you would call it "mare" level). Thus altitude
is not affected by terrain. Angle is the angle of the ship in
relationship to the vertical. 10 degrees, -70 degrees, etc.
Fuel left is the amount of fuel left in pounds. Thrust is the
amount of thrust (pounds) currently being produced by the engine.
Weight is the current earth weight of the ship. As fuel is
burned off, the acceleration will increase due to a lessening of
weight. The horizontal velocity is the current horizontal speed
of the ship, in feet per second. It is necessary to land at
under 10 fps horizontal, or else the ship will tip over.
Vertical velocity is the downward speed of the ship. Try to
keep it under 30 for the first few landings, until you get
better. A perfect landing is under 8 fps. The horizontal
and vertical accelerations are just those, in f/sec/sec.
With no power, the vertical acceleration is about 5 fp/s/s
down (-5). Distance is the horizontal distance (X direction)
you are from the projected landing site. Try to stay within
500 feet of this distance, because there are not too many
spots suitable for landing on the moon. Seconds is just the
time since you started trying to land. Thus you now know how
to display information and what they mean.
To control the ship, two controls are provided. The first
controls the rolling or turning of the ship. This is accom-
plished by four arrows just above the display menu. Two point
left and two point right. The two pointing left mean rotate
left and the two pointing right mean rotate right. There is
a big and a little one in each direction. The big one means
to rotate "fast" and the small one means to rotate "slow".
Thus to rotate fast left, you point the light pen at
left arrow. To rotate slow right, you point the light pen at
the small arrow pointing to the right. The arrow will get
slightly brighter to indicate you have chosen it. Above the
arrow there is a bright, solid bar. This bar is your throttle
bar. To its left there is a number in percent (say 50%). This
number indicates the percentage of full thrust your rocket
engine is developing. The engine can develop anywhere from
10% to 100% thrust - full thrust is 10,500 pounds. The
engine thrust cannot fall below 10%. That is the way Grumman
built it (actually the subcontractor). To increase or decrease
your thrust, you merely slide the light pen up and down the bar.
The indicated percentage thrust will change accordingly.
Now we come to actually flying the beast. The module appears
in the upper left hand corner of the screen and is traveling
down and to the right. Your job is to land at the correct
spot (for the time being, we will say this is when the
distance and height both reach zero). The first picture you
see, with the module in the upper left hand corner, is not
drawn to scale (the module appears too big in relationship
to the mountains). Should you successfully get below around
400 feet altitude, the view will now change to a closeup
view of the landing site, and everything will be in scale.
Remember, it is not easy to land the first few times, but
don't be disappointed, you'll do it. Be careful, the game
is extremely addictive. It is also quite dynamic.
Incorporated in the game are just about everything the GT40
can do. Letters, italics, light pen letters, a light bar,
dynamic motion, various line types and intensities (the moon
is not all the same brightness you know). It also shows that
the GT40 can do a lot of calculations while maintaining a
reasonable display.
There are three possible landing sites on the Moon:
1. On the extreme left of the landscape
2. A small flat area to the right of the mountains
3. In the large "flat" area on the right
Good Luck!

View file

@ -620,6 +620,14 @@ typedef struct pdp_dib DIB;
#define INT_V_DLO 10
#define INT_V_DCI 11
#define INT_V_DCO 12
/* VT simulation is sequential, so only
one interrupt is posted at a time. */
#define INT_V_VTLP 13 /* XXX - Manual says VTLP, VTST have opposite */
#define INT_V_VTST 14 /* XXX precedence, but that breaks LUNAR! */
/* XXX How this happens is an utter mystery. */
#define INT_V_VTCH 15
#define INT_V_VTNM 16
#define INT_V_LK 17
#define INT_V_PIR3 0 /* BR3 */
#define INT_V_PIR2 0 /* BR2 */
@ -667,6 +675,11 @@ typedef struct pdp_dib DIB;
#define INT_DLO (1u << INT_V_DLO)
#define INT_DCI (1u << INT_V_DCI)
#define INT_DCO (1u << INT_V_DCO)
#define INT_VTLP (1u << INT_V_VTLP)
#define INT_VTST (1u << INT_V_VTST)
#define INT_VTCH (1u << INT_V_VTCH)
#define INT_VTNM (1u << INT_V_VTNM)
#define INT_LK (1u << INT_V_LK)
#define INT_PIR3 (1u << INT_V_PIR3)
#define INT_PIR2 (1u << INT_V_PIR2)
#define INT_PIR1 (1u << INT_V_PIR1)
@ -717,6 +730,11 @@ typedef struct pdp_dib DIB;
#define IPL_DLO 4
#define IPL_DCI 4
#define IPL_DCO 4
#define IPL_VTLP 4
#define IPL_VTST 4
#define IPL_VTCH 4
#define IPL_VTNM 4
#define IPL_LK 4 /* XXX just a guess */
#define IPL_PIR7 7
#define IPL_PIR6 6

View file

@ -528,8 +528,8 @@ AUTO_CON auto_tab[] = {/*c #v am vm fxa fxv */
{ { NULL }, 1, 2, 0, 8, { 0 } }, /* DLV11J - fx CSRs */
{ { NULL }, 1, 2, 8, 8 }, /* DJ11 */
{ { NULL }, 1, 2, 16, 8 }, /* DH11 */
{ { NULL }, 1, 4, 0, 8,
{012000, 012010, 012020, 012030} }, /* GT40 */
{ { "VT" }, 1, 4, 0, 8,
{012000, 012010, 012020, 012030} }, /* VT11/GT40 - fx CSRs */
{ { NULL }, 1, 2, 0, 8,
{010400} }, /* LPS11 */
{ { NULL }, 1, 2, 8, 8 }, /* DQ11 */

View file

@ -41,6 +41,7 @@
22-Jul-05 RMS Fixed missing , in initializer (Doug Gwyn)
22-Dec-03 RMS Added second DEUNA/DELUA support
18-Oct-03 RMS Added DECtape off reel message
14-Sep-03 PLB Added VT11 support
06-May-03 RMS Added support for second DEQNA/DELQA
09-Jan-03 RMS Added DELUA/DEUNA support
17-Oct-02 RMS Fixed bugs in branch, SOB address parsing
@ -100,6 +101,9 @@ extern DEVICE tq_dev;
extern DEVICE ts_dev;
extern DEVICE tu_dev;
extern DEVICE ta_dev;
#ifdef USE_DISPLAY
extern DEVICE vt_dev;
#endif
extern DEVICE xq_dev, xqb_dev;
extern DEVICE xu_dev, xub_dev;
extern DEVICE ke_dev;
@ -167,6 +171,9 @@ DEVICE *sim_devices[] = {
&tq_dev,
&tu_dev,
&ta_dev,
#ifdef USE_DISPLAY
&vt_dev,
#endif
&xq_dev,
&xqb_dev,
&xu_dev,

433
PDP11/pdp11_vt.c Normal file
View file

@ -0,0 +1,433 @@
#ifdef USE_DISPLAY
/* pdp11_vt.c: PDP-11 VT11/VS60 Display Processor Simulation
Copyright (c) 2003-2004, Philip L. Budne, Douglas A. Gwyn
Copyright (c) 1993-2003, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the names of the authors shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the authors.
vt VT11/VS60 Display Processor
05-Feb-04 DAG Improved VT11 emulation
Added VS60 support
14-Sep-03 PLB Start from pdp11_lp.c
*/
/*
* this file is just a thin layer of glue to the simulator-
* independent XY Display simulation
*/
#if defined (VM_VAX) /* VAX version */
#include "vax_defs.h"
#elif defined(VM_PDP11) /* PDP-11 version */
#include "pdp11_defs.h"
#else
#error "VT11/VS60 is supported only on the PDP-11 and VAX"
#endif
#include "display/display.h"
#include "display/vt11.h"
/*
* Timing parameters. Should allow some runtime adjustment,
* since several different configurations were shipped, including:
*
* GT40: PDP-11/05 with VT11 display processor
* GT44: PDP-11/40 with VT11 display processor
* GT46: PDP-11/34 with VT11 display processor
* GT62: PDP-11/34a with VS60 display system
*/
/*
* run a VT11/VS60 cycle every this many PDP-11 "cycle" times;
*
* Under the X Window System (X11), this includes polling
* for events (mouse movement)!
*/
#define VT11_DELAY 1
/*
* memory cycle time
*/
#define MEMORY_CYCLE 1 /* either .98 or 1.2 us? */
/*
* delay in microseconds between VT11/VS60 cycles:
* VT11/VS60 and PDP-11 CPU's share the same memory bus,
* and each VT11/VS60 instruction requires a memory reference;
* figure each PDP11 instruction requires two memory references
*/
#define CYCLE_US (MEMORY_CYCLE*(VT11_DELAY*2+1))
extern int32 int_req[IPL_HLVL];
extern int32 int_vec[IPL_HLVL][32];
DEVICE vt_dev;
t_stat vt_rd(int32 *data, int32 PA, int32 access);
t_stat vt_wr(int32 data, int32 PA, int32 access);
t_stat vt_svc(UNIT *uptr);
t_stat vt_reset(DEVICE *dptr);
t_stat vt_boot(int32 unit, DEVICE *dptr);
t_stat vt_set_crt(UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat vt_show_crt(FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat vt_set_scale(UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat vt_show_scale(FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat vt_set_hspace(UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat vt_show_hspace(FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat vt_set_vspace(UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat vt_show_vspace(FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat vt_help (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, char *cptr);
char *vt_description (DEVICE *dptr);
/* VT11/VS60 data structures
vt_dev VT11 device descriptor
vt_unit VT11 unit descriptor
vt_reg VT11 register list
vt_mod VT11 modifier list
*/
#define IOLN_VT11 010 /* VT11 */
#define IOLN_VS60 040 /* VS60 */
DIB vt_dib = { IOBA_AUTO, IOLN_VT11, &vt_rd, &vt_wr,
4, IVCL(VTST), VEC_AUTO, {NULL} };
/* (VT11 uses only the first 3 interrupt vectors) */
UNIT vt_unit = {
UDATA (&vt_svc, UNIT_SEQ, 0), VT11_DELAY};
REG vt_reg[] = {
{ GRDATA (DEVADDR, vt_dib.ba, DEV_RDX, 32, 0), REG_HRO },
{ GRDATA (DEVVEC, vt_dib.vec, DEV_RDX, 16, 0), REG_HRO },
{ NULL } };
MTAB vt_mod[] = {
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "CRT", "CRT={VR14|VR17|VR48}",
&vt_set_crt, &vt_show_crt, NULL, "CRT Type" },
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "SCALE", "SCALE={1|2|4|8}",
&vt_set_scale, &vt_show_scale, NULL, "Pixel Scale Factor" },
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "HSPACE", "HSPACE={NARROW|NORMAL}",
&vt_set_hspace, &vt_show_hspace, NULL, "Horizontal Spacing" },
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "VSPACE", "VSPACE={TALL|NORMAL}",
&vt_set_vspace, &vt_show_vspace, NULL, "Vertical Spacing" },
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 020, "ADDRESS", "ADDRESS",
&set_addr, &show_addr, NULL, "Bus address" },
{ MTAB_XTD|MTAB_VDV|MTAB_VALR, 0, "VECTOR", "VECTOR",
&set_vec, &show_vec, NULL, "Interrupt vector" },
{ MTAB_XTD|MTAB_VDV, 0, NULL, "AUTOCONFIGURE",
&set_addr_flt, NULL, NULL, "Enable autoconfiguration of address & vector" },
{ 0 } };
DEVICE vt_dev = {
"VT", &vt_unit, vt_reg, vt_mod,
1, 8, 31, 1, DEV_RDX, 16,
NULL, NULL, &vt_reset,
&vt_boot, NULL, NULL,
&vt_dib, DEV_DIS | DEV_DISABLE | DEV_UBUS | DEV_Q18,
0, 0, NULL, NULL, NULL, NULL, NULL,
&vt_description
};
/* VT11/VS60 routines
vt_rd I/O page read
vt_wr I/O page write
vt_svc process event
vt_reset process reset
vt_boot bootstrap device
*/
t_stat
vt_rd(int32 *data, int32 PA, int32 access)
{
switch (PA & 036) {
case 000: *data = vt11_get_dpc(); return SCPE_OK;
case 002: *data = vt11_get_mpr(); return SCPE_OK;
case 004: *data = vt11_get_xpr(); return SCPE_OK;
case 006: *data = vt11_get_ypr(); return SCPE_OK;
case 010: if (!VS60) break; *data = vt11_get_rr(); return SCPE_OK;
case 012: if (!VS60) break; *data = vt11_get_spr(); return SCPE_OK;
case 014: if (!VS60) break; *data = vt11_get_xor(); return SCPE_OK;
case 016: if (!VS60) break; *data = vt11_get_yor(); return SCPE_OK;
case 020: if (!VS60) break; *data = vt11_get_anr(); return SCPE_OK;
case 022: if (!VS60) break; *data = vt11_get_scr(); return SCPE_OK;
case 024: if (!VS60) break; *data = vt11_get_nr(); return SCPE_OK;
case 026: if (!VS60) break; *data = vt11_get_sdr(); return SCPE_OK;
case 030: if (!VS60) break; *data = vt11_get_str(); return SCPE_OK;
case 032: if (!VS60) break; *data = vt11_get_sar(); return SCPE_OK;
case 034: if (!VS60) break; *data = vt11_get_zpr(); return SCPE_OK;
case 036: if (!VS60) break; *data = vt11_get_zor(); return SCPE_OK;
}
return SCPE_NXM;
}
t_stat
vt_wr(int32 data, int32 PA, int32 access)
{
uint16 d = data & 0177777; /* mask just in case */
switch (PA & 037) {
case 000: /* DPC */
/* set the simulator PC */
vt11_set_dpc(d);
/* clear interrupt request (only one will be simulated at a time) */
CLR_INT (VTST);
CLR_INT (VTLP);
CLR_INT (VTCH);
CLR_INT (VTNM);
/* start the display processor by running a cycle */
return vt_svc(&vt_unit);
case 002: vt11_set_mpr(d); return SCPE_OK;
case 004: vt11_set_xpr(d); return SCPE_OK;
case 006: vt11_set_ypr(d); return SCPE_OK;
case 010: if (!VS60) break; vt11_set_rr(d); return SCPE_OK;
case 012: if (!VS60) break; vt11_set_spr(d); return SCPE_OK;
case 014: if (!VS60) break; vt11_set_xor(d); return SCPE_OK;
case 016: if (!VS60) break; vt11_set_yor(d); return SCPE_OK;
case 020: if (!VS60) break; vt11_set_anr(d); return SCPE_OK;
case 022: if (!VS60) break; vt11_set_scr(d); return SCPE_OK;
case 024: if (!VS60) break; vt11_set_nr(d); return SCPE_OK;
case 026: if (!VS60) break; vt11_set_sdr(d); return SCPE_OK;
case 030: if (!VS60) break; vt11_set_str(d); return SCPE_OK;
case 032: if (!VS60) break; vt11_set_sar(d); return SCPE_OK;
case 034: if (!VS60) break; vt11_set_zpr(d); return SCPE_OK;
case 036: if (!VS60) break; vt11_set_zor(d); return SCPE_OK;
}
return SCPE_NXM;
}
/*
* here to run a display processor cycle, called as a SIMH
* "device service routine".
*
* Under X11 this includes polling for events, so it can't be
* call TOO infrequently...
*/
t_stat
vt_svc(UNIT *uptr)
{
if (vt11_cycle(CYCLE_US, 1))
sim_activate (&vt_unit, vt_unit.wait); /* running; reschedule */
return SCPE_OK;
}
t_stat
vt_reset(DEVICE *dptr)
{
if (!(dptr->flags & DEV_DIS))
vt11_reset();
CLR_INT (VTST);
CLR_INT (VTLP);
CLR_INT (VTCH);
CLR_INT (VTNM);
sim_cancel (&vt_unit); /* deactivate unit */
return auto_config ("VT", (dptr->flags & DEV_DIS) ? 0 : 1);
}
/*
* GT4x/GT62 bootstrap (acts as remote terminal)
*/
t_stat
vt_boot(int32 unit, DEVICE *dptr)
{
/* XXX should do something like vt11_set_dpc(&appropriate_ROM_image) */
return SCPE_NOFNC; /* not yet implemented */
}
/* SET/SHOW VT options: */
t_stat
vt_set_crt(UNIT *uptr, int32 val, char *cptr, void *desc)
{
char gbuf[CBUFSIZE];
if (vt11_init)
return SCPE_ALATT; /* should be "changes locked out" */
if (cptr == NULL)
return SCPE_ARG;
get_glyph(cptr, gbuf, 0);
if (strcmp(gbuf, "VR14") == 0)
vt11_display = DIS_VR14;
else if (strcmp(gbuf, "VR17") == 0)
vt11_display = DIS_VR17;
else if (strcmp(gbuf, "VR48") == 0)
vt11_display = DIS_VR48;
else
return SCPE_ARG;
vt_dib.lnt = (VS60) ? IOLN_VS60 : IOLN_VT11;
return SCPE_OK;
}
t_stat
vt_show_crt(FILE *st, UNIT *uptr, int32 val, void *desc)
{
fprintf(st, "crt=VR%d", (int)vt11_display);
return SCPE_OK;
}
t_stat
vt_set_scale(UNIT *uptr, int32 val, char *cptr, void *desc)
{
t_stat r;
t_value v;
if (vt11_init)
return SCPE_ALATT; /* should be "changes locked out" */
if (cptr == NULL)
return SCPE_ARG;
v = get_uint(cptr, 10, 8, &r);
if (r != SCPE_OK)
return r;
if (v != 1 && v != 2 && v != 4 && v != 8)
return SCPE_ARG;
vt11_scale = v;
return SCPE_OK;
}
t_stat
vt_show_scale(FILE *st, UNIT *uptr, int32 val, void *desc)
{
fprintf(st, "scale=%d", (int)vt11_scale);
return SCPE_OK;
}
t_stat
vt_set_hspace(UNIT *uptr, int32 val, char *cptr, void *desc)
{
char gbuf[CBUFSIZE];
if (vt11_init)
return SCPE_ALATT; /* should be "changes locked out" */
if (cptr == NULL)
return SCPE_ARG;
get_glyph(cptr, gbuf, 0);
if (strcmp(gbuf, "NARROW") == 0)
vt11_csp_w = 12;
else if (strcmp(gbuf, "NORMAL") == 0)
vt11_csp_w = 14;
else
return SCPE_ARG;
return SCPE_OK;
}
t_stat
vt_show_hspace(FILE *st, UNIT *uptr, int32 val, void *desc)
{
fprintf(st, "hspace=%s", vt11_csp_w==12 ? "narrow" : "normal");
return SCPE_OK;
}
t_stat
vt_set_vspace(UNIT *uptr, int32 val, char *cptr, void *desc)
{
char gbuf[CBUFSIZE];
if (vt11_init)
return SCPE_ALATT; /* should be "changes locked out" */
if (cptr == NULL)
return SCPE_ARG;
get_glyph(cptr, gbuf, 0);
if (strcmp(gbuf, "TALL") == 0)
vt11_csp_h = 26;
else if (strcmp(gbuf, "NORMAL") == 0)
vt11_csp_h = 24;
else
return SCPE_ARG;
return SCPE_OK;
}
t_stat
vt_show_vspace(FILE *st, UNIT *uptr, int32 val, void *desc)
{
fprintf(st, "vspace=%s", vt11_csp_h==26 ? "tall" : "normal");
return SCPE_OK;
}
/* interface routines (called from display simulator) */
void
vt_stop_intr(void)
{
SET_INT (VTST);
}
void
vt_lpen_intr(void)
{
SET_INT (VTLP);
}
void
vt_char_intr(void)
{
SET_INT (VTCH);
}
void
vt_name_intr(void)
{
SET_INT (VTNM);
}
/* fetch memory */
int
vt_fetch(uint32 addr, vt11word *wp)
{
/* On PDP-11 Unibus 22-bit systems, the VT11/VS60 behaves as
an 18-bit Unibus peripheral and must go through the I/O map. */
/* apply Unibus map, when appropriate */
if (Map_ReadW(addr, 2, wp) == 0)
return 0; /* no problem */
/* else mapped address lies outside configured memory range */
*wp = 0164000; /* DNOP; just updates DPC if used */
/* which shouldn't happen */
return 1; /* used to set "time_out" flag */
}
char *vt_description (DEVICE *dptr)
{
return (VS60) ? "VS60 Display processor"
: "VT11 Display processor";
}
#ifdef VM_PDP11
/* PDP-11 simulation provides this */
extern int32 SR; /* switch register */
#else
int32 SR; /* switch register */
#endif
void
cpu_set_switches(unsigned long val)
{
SR = val;
}
unsigned long
cpu_get_switches(void)
{
return SR;
}
#else /* USE_DISPLAY not defined */
char pdp11_vt_unused; /* sometimes empty object modules cause problems */
#endif /* USE_DISPLAY not defined */

View file

@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../PDP1/"
PreprocessorDefinitions="_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID"
PreprocessorDefinitions="_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;USE_DISPLAY"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -128,7 +128,7 @@
InlineFunctionExpansion="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="./;../;../PDP1/"
PreprocessorDefinitions="_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID"
PreprocessorDefinitions="_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;SIM_NEED_GIT_COMMIT_ID;USE_DISPLAY"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@ -189,6 +189,10 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
>
<File
RelativePath="..\display\display.c"
>
</File>
<File
RelativePath="..\PDP1\pdp1_clk.c"
>
@ -201,6 +205,10 @@
RelativePath="..\PDP1\pdp1_dcs.c"
>
</File>
<File
RelativePath="..\PDP1\pdp1_dpy.c"
>
</File>
<File
RelativePath="..\PDP1\pdp1_drm.c"
>
@ -261,11 +269,19 @@
RelativePath="..\sim_tmxr.c"
>
</File>
<File
RelativePath="..\display\win32.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"
>
<File
RelativePath="..\display\display.h"
>
</File>
<File
RelativePath="..\PDP1\pdp1_defs.h"
>
@ -318,6 +334,10 @@
RelativePath="..\sim_tmxr.h"
>
</File>
<File
RelativePath="..\display\ws.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View file

@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="./;../;../PDP11/;&quot;../../windows-build/winpcap/Wpdpack/Include&quot;;&quot;../../windows-build/pthreads&quot;"
PreprocessorDefinitions="USE_SHARED;VM_PDP11;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;PTW32_STATIC_LIB;SIM_ASYNCH_IO;USE_READER_THREAD;SIM_NEED_GIT_COMMIT_ID"
PreprocessorDefinitions="USE_SHARED;USE_DISPLAY;VM_PDP11;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;PTW32_STATIC_LIB;SIM_ASYNCH_IO;USE_READER_THREAD;SIM_NEED_GIT_COMMIT_ID"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@ -129,7 +129,7 @@
InlineFunctionExpansion="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="./;../;../PDP11/;&quot;../../windows-build/winpcap/Wpdpack/Include&quot;;&quot;../../windows-build/pthreads&quot;"
PreprocessorDefinitions="USE_SHARED;VM_PDP11;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;PTW32_STATIC_LIB;SIM_ASYNCH_IO;USE_READER_THREAD;SIM_NEED_GIT_COMMIT_ID"
PreprocessorDefinitions="USE_SHARED;USE_DISPLAY;VM_PDP11;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;PTW32_STATIC_LIB;SIM_ASYNCH_IO;USE_READER_THREAD;SIM_NEED_GIT_COMMIT_ID"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
@ -191,6 +191,10 @@
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
>
<File
RelativePath="..\display\display.c"
>
</File>
<File
RelativePath="..\PDP11\pdp11_cis.c"
>
@ -339,6 +343,10 @@
RelativePath="..\PDP11\pdp11_vh.c"
>
</File>
<File
RelativePath="..\PDP11\pdp11_vt.c"
>
</File>
<File
RelativePath="..\PDP11\pdp11_xq.c"
>
@ -407,11 +415,23 @@
RelativePath="..\sim_tmxr.c"
>
</File>
<File
RelativePath="..\display\vt11.c"
>
</File>
<File
RelativePath="..\display\win32.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"
>
<File
RelativePath="..\display\display.h"
>
</File>
<File
RelativePath="..\PDP11\pdp11_cpumod.h"
>
@ -504,6 +524,14 @@
RelativePath="..\sim_tmxr.h"
>
</File>
<File
RelativePath="..\display\vt11.h"
>
</File>
<File
RelativePath="..\display\ws.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View file

@ -483,7 +483,8 @@ PDP1_LIB = $(LIB_DIR)PDP1-$(ARCH).OLB
PDP1_SOURCE = $(PDP1_DIR)PDP1_LP.C,$(PDP1_DIR)PDP1_CPU.C,\
$(PDP1_DIR)PDP1_STDDEV.C,$(PDP1_DIR)PDP1_SYS.C,\
$(PDP1_DIR)PDP1_DT.C,$(PDP1_DIR)PDP1_DRM.C,\
$(PDP1_DIR)PDP1_CLK.C,$(PDP1_DIR)PDP1_DCS.C
$(PDP1_DIR)PDP1_CLK.C,$(PDP1_DIR)PDP1_DCS.C, \
$(PDP1_DIR)PDP1_DPY.C
PDP1_OPTIONS = /INCL=($(SIMH_DIR),$(PDP1_DIR))/DEF=($(CC_DEFS))
#
@ -535,7 +536,7 @@ PDP11_SOURCE1 = $(PDP11_DIR)PDP11_FP.C,$(PDP11_DIR)PDP11_CPU.C,\
$(PDP11_DIR)PDP11_CPUMOD.C,$(PDP11_DIR)PDP11_CR.C,\
$(PDP11_DIR)PDP11_TA.C,$(PDP11_DIR)PDP11_DMC.C,\
$(PDP11_DIR)PDP11_DUP.C,$(PDP11_DIR)PDP11_RS.C,\
$(PDP11_DIR)PDP11_IO_LIB.C
$(PDP11_DIR)PDP11_VT.C,$(PDP11_DIR)PDP11_IO_LIB.C
PDP11_LIB2 = $(LIB_DIR)PDP11L2-$(ARCH).OLB
PDP11_SOURCE2 = $(PDP11_DIR)PDP11_TM.C,$(PDP11_DIR)PDP11_TS.C,\
$(PDP11_DIR)PDP11_IO.C,$(PDP11_DIR)PDP11_RQ.C,\

328
display/carbon.c Normal file
View file

@ -0,0 +1,328 @@
/*
* $Id: carbon.c,v 1.2 2005/08/06 21:09:03 phil Exp $
* Mac OS X Carbon support for XY display simulator
* John Dundas <dundas@caltech.edu>
* December 2004
*
* This is a simplistic driver under Mac OS Carbon for the XY display
* simulator.
*
* A more interesting driver would use OpenGL directly.
*/
#include <Carbon/Carbon.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ws.h"
#include "xy.h"
#include <sys/types.h>
#include <sys/time.h>
#define ARRAYLEN(a) (sizeof (a) / sizeof (a[0]))
#ifndef PIX_SIZE
#define PIX_SIZE 1
#endif
/*
* light pen location
* see ws.h for full description
*/
int ws_lp_x = -1;
int ws_lp_y = -1;
static RGBColor blckColor = { 0x0000, 0x0000, 0x0000 };
static RGBColor whteColor = { 0xFFFF, 0xFFFF, 0xFFFF };
static WindowRef mainWind;
static RgnHandle rgn;
static MouseTrackingRef mouseRef;
static int xpixels, ypixels;
static int buttons = 0; /* tracks state of all buttons */
static EventTargetRef EventDispatchTarget;
void MyEventWait ( EventTimeout timeout ) /* double */
{
EventRef theEvent;
if (ReceiveNextEvent (0, NULL, timeout, true, &theEvent) == noErr) {
SendEventToEventTarget (theEvent, EventDispatchTarget);
ReleaseEvent (theEvent);
}
}
static pascal OSStatus doMouseEvent ( EventHandlerCallRef handlerRef,
EventRef event,
void *userData )
{
OSStatus err = eventNotHandledErr;
Point start;
GrafPtr prevPort;
/* make sure the display is the current grafport */
if (!QDSwapPort (GetWindowPort (mainWind), &prevPort))
prevPort = NULL;
switch (GetEventKind (event)) {
case kEventMouseEntered:
if (ActiveNonFloatingWindow () != mainWind)
break;
SetThemeCursor (kThemeCrossCursor);
break;
case kEventMouseExited:
if (ActiveNonFloatingWindow () != mainWind)
break;
SetThemeCursor (kThemeArrowCursor);
break;
case kEventMouseDown:
GetEventParameter (event, kEventParamMouseLocation,
typeQDPoint, NULL, sizeof (typeQDPoint), NULL, &start);
GlobalToLocal (&start);
ws_lp_x = start.h;
ws_lp_y = ypixels - start.v;
display_lp_sw = 1;
break;
case kEventMouseUp:
display_lp_sw = 0;
ws_lp_x = ws_lp_y = -1;
break;
default:
break;
}
if (prevPort)
SetPort (prevPort);
return (err);
}
static pascal OSStatus updateWindow ( EventHandlerCallRef handlerRef,
EventRef event,
void *userData )
{
OSStatus err = eventNotHandledErr;
switch (GetEventKind (event)) {
case kEventWindowActivated:
/* update menus */
break;
case kEventWindowClose: /* Override window close */
err = noErr;
break;
case kEventWindowDrawContent:
display_repaint ();
err = noErr;
default:
break;
}
return (err);
}
static pascal OSStatus doKbdEvent ( EventHandlerCallRef handlerRef,
EventRef event,
void *userData )
{
UInt32 c, m;
char key;
GetEventParameter (event, kEventParamKeyCode,
typeUInt32, NULL, sizeof (typeUInt32), NULL, &c);
GetEventParameter (event, kEventParamKeyMacCharCodes,
typeChar, NULL, sizeof (typeChar), NULL, &key);
GetEventParameter (event, kEventParamKeyModifiers,
typeUInt32, NULL, sizeof (typeUInt32), NULL, &m);
/* Keys with meta-modifiers are not allowed at this time. */
#define KEY_MODIFIERS (cmdKey | optionKey | kEventKeyModifierFnMask)
if (m & KEY_MODIFIERS)
return (eventNotHandledErr);
switch (GetEventKind (event)) {
case kEventRawKeyRepeat:
case kEventRawKeyDown:
display_keydown (key);
break;
case kEventRawKeyUp:
display_keyup (key);
break;
default:
break;
}
return (noErr);
}
int ws_init ( char *crtname, /* crt type name */
int xp, /* screen size in pixels */
int yp,
int colors ) /* colors to support (not used) */
{
WindowAttributes windowAttrs;
Rect r;
CFStringRef str;
static MouseTrackingRegionID mouseID = { 'AAPL', 0 };
static const EventTypeSpec moEvent[] = {
{ kEventClassMouse, kEventMouseEntered },
{ kEventClassMouse, kEventMouseExited },
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseUp },
};
static const EventTypeSpec wuEvent[] = {
{ kEventClassWindow, kEventWindowDrawContent },
{ kEventClassWindow, kEventWindowClose },
{ kEventClassWindow, kEventWindowActivated},
};
static const EventTypeSpec kdEvent[] = {
{ kEventClassKeyboard, kEventRawKeyDown },
{ kEventClassKeyboard, kEventRawKeyRepeat },
{ kEventClassKeyboard, kEventRawKeyUp},
};
xpixels = xp; /* save screen size */
ypixels = yp;
r.top = 100; r.left = 100; r.bottom = r.top + yp; r.right = r.left + xp;
/* should check this r against GetQDGlobalsScreenBits (&screen); */
windowAttrs = kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute;
if (CreateNewWindow (kDocumentWindowClass, windowAttrs, &r, &mainWind) != noErr)
return (0);
if (str = CFStringCreateWithCString (kCFAllocatorDefault, crtname,
kCFStringEncodingASCII)) {
SetWindowTitleWithCFString (mainWind, str);
CFRelease (str);
}
SetPortWindowPort (mainWind);
/*
* Setup to handle events
*/
EventDispatchTarget = GetEventDispatcherTarget ();
InstallEventHandler (GetWindowEventTarget (mainWind),
NewEventHandlerUPP (doMouseEvent), ARRAYLEN(moEvent),
(EventTypeSpec *) &moEvent, NULL, NULL);
InstallEventHandler (GetWindowEventTarget (mainWind),
NewEventHandlerUPP (updateWindow), ARRAYLEN(wuEvent),
(EventTypeSpec *) &wuEvent, NULL, NULL);
InstallEventHandler (GetWindowEventTarget (mainWind),
NewEventHandlerUPP (doKbdEvent), ARRAYLEN(kdEvent),
(EventTypeSpec *) &kdEvent, NULL, NULL);
/* create region to track cursor shape */
r.top = 0; r.left = 0; r.bottom = yp; r.right = xp;
rgn = NewRgn ();
RectRgn (rgn, &r);
CloseRgn (rgn);
CreateMouseTrackingRegion (mainWind, rgn, NULL,
kMouseTrackingOptionsLocalClip, mouseID, NULL, NULL, &mouseRef);
ShowWindow (mainWind);
RGBForeColor (&blckColor);
PaintRect (&r);
RGBBackColor (&blckColor);
return (1);
}
void *ws_color_black (void)
{
return (&blckColor);
}
void *ws_color_white (void)
{
return (&whteColor);
}
void *ws_color_rgb ( int r,
int g,
int b )
{
RGBColor *color;
if ((color = malloc (sizeof (RGBColor))) != NULL) {
color->red = r;
color->green = g;
color->blue = b;
}
return (color);
}
/* put a point on the screen */
void ws_display_point ( int x,
int y,
void *color )
{
#if PIX_SIZE != 1
Rect r;
#endif
if (x > xpixels || y > ypixels)
return;
y = ypixels - y /* - 1 */;
#if PIX_SIZE == 1
SetCPixel (x, y, (color == NULL) ? &blckColor : color);
#else
r.top = y * PIX_SIZE;
r.left = x * PIX_SIZE;
r.bottom = (y + 1) * PIX_SIZE;
r.right = (x + 1) * PIX_SIZE;
RGBForeColor ((color == NULL) ? &blckColor : color);
PaintRect (&r);
#endif
}
void ws_sync (void)
{
;
}
/*
* elapsed wall clock time since last call
* +INF on first call
*/
struct elapsed_state {
struct timeval tvs[2];
int new;
};
static unsigned long
elapsed(struct elapsed_state *ep)
{
unsigned long val;
gettimeofday(&ep->tvs[ep->new], NULL);
if (ep->tvs[!ep->new].tv_sec == 0)
val = ~0L;
else
val = ((ep->tvs[ep->new].tv_sec - ep->tvs[!ep->new].tv_sec) * 1000000 +
(ep->tvs[ep->new].tv_usec - ep->tvs[!ep->new].tv_usec));
ep->new = !ep->new;
return val;
}
/* called periodically */
int ws_poll ( int *valp,
int maxusec )
{
static struct elapsed_state es; /* static to avoid clearing! */
elapsed(&es); /* start clock */
do {
unsigned long e;
MyEventWait (maxusec * kEventDurationMicrosecond);
e = elapsed(&es);
maxusec -= e;
} while (maxusec > 10000); /* 10ms */
return (1);
}
void ws_beep (void)
{
SysBeep (3);
}
/* public version, used by delay code */
unsigned long os_elapsed (void)
{
static struct elapsed_state es;
return (elapsed (&es));
}

View file

@ -545,9 +545,11 @@ display_delay(int t, int slowdown)
#endif /* DEBUG_DELAY defined */
}
}
else if ((elapsed < MINELAPSED) || (slowdown && (delay < MINDELAY))) {
else
if ((elapsed < MINELAPSED) || (slowdown && (delay < MINDELAY))) {
/* too little elapsed time passed, or delta very small */
int gain = delay_check>>GAINSHIFT;
if (gain == 0)
gain = 1; /* make sure some change made! */
delay_check += gain;
@ -686,7 +688,9 @@ intensify(int x, /* 0..xpixels */
/* EXP: doesn't work... yet */
/* if "recently" drawn, same or brighter, same color, make even brighter */
if (p->ttl >= MAXTTL*2/3 && level >= p->level && p->color == color &&
if (p->ttl >= MAXTTL*2/3 &&
level >= p->level &&
p->color == color &&
level < MAXLEVEL)
level++;
@ -767,6 +771,7 @@ phosphor_init(struct phosphor *phosphors, int nphosphors, int color)
rr = rg = rb = 0.0;
for (pp = phosphors, p = 0; p < nphosphors; pp++, p++) {
double decay = pow(pp->level, t/pp->t_level);
rr += decay * pp->red;
rg += decay * pp->green;
rb += decay * pp->blue;
@ -815,6 +820,7 @@ find_type(enum display_type type)
{
int i;
struct display *dp;
for (i = 0, dp = displays; i < ELEMENTS(displays); i++, dp++)
if (dp->type == type)
return dp;

View file

@ -1,4 +1,4 @@
# $Id: gmakefile,v 1.17 2004/01/24 08:31:56 phil Exp - revised by DAG
# $Id: gmakefile,v 1.24 2005/11/05 02:06:14 phil Exp $
# (GNU) Makefile for test programs under Unix/X11 and Win32
#
@ -8,8 +8,11 @@
# or if GNU make is the default:
# make -f gmakefile
#
# OS X (Carbon)
# make -f gmakefile OSX=1
#
# Win32 (Cygwin)
# make WIN32=1
# make -f gmakefile WIN32=1
#
# Win32 (MINGW):
# mingw32-make -f gmakefile WIN32=1
@ -17,6 +20,7 @@
DISP_DEFS=-DTEST_DIS=DIS_VR48 -DTEST_RES=RES_HALF # -DDEBUG_VT11
ifeq ($(WIN32),)
ifeq ($(OSX),)
#Unix environments
X11BASE=/usr/X11R6
X11LIBDIR=$(X11BASE)/lib
@ -26,6 +30,10 @@ OSFLAGS=-I$(X11INCDIR)
DRIVER=x11.o
EXT=
else
DRIVER=carbon.o
LIBS=-framework Carbon
endif
else
#Win32 environments
LIBS=-lgdi32
OSFLAGS=
@ -45,20 +53,21 @@ ALL: $(ALL)
# munching squares; see README file for
# how to use console switches
MUNCH=$(DRIVER) display.o test.o
MUNCH=$(DRIVER) xy.o test.o
munch$(EXT): $(MUNCH)
$(CC) $(LDFLAGS) -o munch$(EXT) $(MUNCH) $(LIBS)
VT11=$(DRIVER) vt11.o vttest.o display.o
VT11=$(DRIVER) vt11.o vttest.o xy.o
vt11$(EXT): $(VT11)
$(CC) $(LDFLAGS) -o vt11$(EXT) $(VT11) $(LIBS)
display.o: display.h ws.h
vt11.o: display.h vt11.h
x11.o: ws.h display.h
xy.o: xy.h ws.h
vt11.o: xy.h vt11.h
x11.o: ws.h xy.h
carbon.o: ws.h
win32.o: ws.h
test.o: display.h vt11.h
vttest.o: display.h vt11.h vtmacs.h
test.o: xy.h vt11.h
vttest.o: xy.h vt11.h vtmacs.h
clean:
ifeq ($(WIN32),)

View file

@ -1,15 +1,19 @@
# $Id: smakefile,v 1.17 2004/01/24 08:31:56 phil Exp - revised by DAG
# $Id: smakefile,v 1.6 2005/11/05 02:06:14 phil Exp $
# Makefile for test programs (standard Unix "make" version)
# Unix:
# comment out Windows defs, uncomment Unix defs,
# comment out OS X, Windows defs, uncomment Unix defs,
# edit Unix defs to fit your compiler/library environment, then
# (g)make
# make -f smakefile
#
# OS X (Carbon)
# comment out Unix, Windows defs, uncomment OS X defs
# make -f smakefile
#
# Win32 (Cygwin)
# comment out Unix defs, uncomment Windows defs, then
# make
# make -f smakefile
#
# Win32 (MINGW)
# comment out Unix defs, uncomment Windows defs, then
@ -18,7 +22,8 @@
DISP_DEFS=-DTEST_DIS=DIS_VR48 -DTEST_RES=RES_HALF # -DDEBUG_VT11
#Unix environments
CC=cc # gcc -Wunused
CC=cc
#CC=gcc -Wunused
#X11BASE=/usr/X11R6
#X11LIBDIR=$(X11BASE)/lib
#X11INCDIR=$(X11BASE)/include
@ -29,9 +34,19 @@ EXT=
PROF=-g # -pg
OPT=-O # -O2
CFLAGS=$(OPT) $(PROF) $(OSFLAGS) $(DISP_DEFS)
CC=cc # gcc -Wunused
LDFLAGS=$(PROF)
##OS X
#CC=cc -Wunused
#LIBS=-framework Carbon
#OSFLAGS=
#DRIVER=carbon.o
#EXT=
#PROF=-g # -pg
#OPT=-O # -O2
#CFLAGS=$(OPT) $(PROF) $(OSFLAGS) $(DISP_DEFS)
#LDFLAGS=$(PROF)
##Win32 environments
#LIBS=-lgdi32
#OSFLAGS=
@ -49,20 +64,21 @@ ALL: $(ALL)
# munching squares; see README file for
# how to use console switches
MUNCH=$(DRIVER) display.o test.o
MUNCH=$(DRIVER) xy.o test.o
munch$(EXT): $(MUNCH)
$(CC) $(LDFLAGS) -o munch$(EXT) $(MUNCH) $(LIBS)
VT11=$(DRIVER) vt11.o vttest.o display.o
VT11=$(DRIVER) vt11.o vttest.o xy.o
vt11$(EXT): $(VT11)
$(CC) $(LDFLAGS) -o vt11$(EXT) $(VT11) $(LIBS)
display.o: display.h ws.h
vt11.o: display.h vt11.h
x11.o: ws.h display.h
xy.o: xy.h ws.h
vt11.o: xy.h vt11.h
x11.o: ws.h xy.h
carbon.o: ws.h
win32.o: ws.h
test.o: display.h vt11.h
vttest.o: display.h vt11.h vtmacs.h
test.o: xy.h vt11.h
vttest.o: xy.h vt11.h vtmacs.h
clean:
rm -f *.o *~ .#* # Unix

View file

@ -1,5 +1,5 @@
/*
* $Id: test.c,v 1.23 2004/02/07 06:31:20 phil Exp $
* $Id: test.c,v 1.24 2005/01/14 18:58:00 phil Exp $
* XY Display simulator test program (PDP-1 Munching Squares)
* Phil Budne <phil@ultimate.com>
* September 2003
@ -52,7 +52,7 @@
#define EXIT_FAILURE 1
#endif
#include "display.h"
#include "xy.h"
static unsigned long test_switches = 0;

View file

@ -1,5 +1,5 @@
/*
* $Id: type340.c,v 1.5 2004/01/24 20:52:16 phil Exp $
* $Id: type340.c,v 1.6 2005/01/14 18:58:00 phil Exp $
* Simulator Independent DEC Type 340 Graphic Display Processor Simulation
* Phil Budne <phil@ultimate.com>
* September 20, 2003
@ -35,7 +35,7 @@
* from the authors.
*/
#include "display.h" /* XY plot interface */
#include "xy.h" /* XY plot interface */
/*
* The Type 340 was used on the PDP-{4,6,7,9,10}

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,11 @@
/*
* $Id: vt11.h,v 1.7 2004/01/25 17:20:51 phil Exp $
* $Id: vt11.h,v 1.8 2005/01/14 18:58:02 phil Exp $
* interface to VT11 simulator
* Phil Budne <phil@ultimate.com>
* September 16, 2003
* Substantially revised by Douglas A. Gwyn, 14 Jan. 2004
*
* prerequisite: display.h
* prerequisite: xy.h
*/
/*

View file

@ -1,8 +1,9 @@
/*
* $Id: vtmacs.h,v 1.4 2004/02/07 06:26:47 phil Exp $
* $Id: vtmacs.h,v 1.5 2005/01/12 18:10:13 phil Exp $
* macros for coding a VT11/VS60 display file (instructions and data)
* for standalone use of vt11.c (not embedded in PDP-11 simulator)
* Douglas A. Gwyn <gwyn@arl.army.mil>
* January 31, 2004
* September 03, 2004
*
* XXX -- assumes ASCII host character set
*/
@ -10,6 +11,11 @@
/* helper macros (not for use outside this header): */
#define SGN_(x) ((x) < 0)
#define MAG_(x) ((x) >= 0 ? (x) : -(x)) /* -0 not expressible directly in C */
#if 0 /* manual seems to say this; wrong! */
#define JDL_(x) ((SGN_(raddr) << 8) | MAG_(raddr))
#else /* sign extend, 9-bit twos complement */
#define JDL_(x) ((x) >= 0 ? (x) : ((~(unsigned)-(x))+1) & 0777)
#endif
/* control instructions: */
@ -160,18 +166,18 @@
0160000, \
(addr) & ~1
/* display jump relative (VS60): */
/* display jump relative (VS60) [raddr in words]: */
#define DJMP_REL(raddr) \
0161000 | (SGN_(raddr) << 8) | MAG_(raddr)
0161000 | JDL_(raddr)
/* display jump to subroutine absolute (VS60): */
#define DJSR_ABS(addr) \
0162000, \
(addr) & ~1
/* display jump to subroutine relative (VS60): */
/* display jump to subroutine relative (VS60) [raddr in words]: */
#define DJSR_REL(raddr) \
0163000 | (SGN_(raddr) << 8) | MAG_(raddr)
0163000 | JDL_(raddr)
/* display no-op: */
#define DNOP \

View file

@ -1,9 +1,9 @@
/*
* $Id: vttest.c,v 1.10 2004/02/07 06:31:21 phil Exp $
* $Id: vttest.c,v 1.15 2005/08/06 21:09:05 phil Exp $
* VT11 test
* Phil Budne <phil@ultimate.com>
* September 13, 2003
* Substantially revised by Douglas A. Gwyn, 27 Jan. 2004
* Substantially revised by Douglas A. Gwyn, 05 Aug 2005
*
* XXX -- assumes ASCII host character set
*
@ -32,11 +32,12 @@
#define TEST_RES RES_HALF
#endif
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "ws.h" /* for ws_beep() */
#include "display.h"
#include "xy.h"
#include "vt11.h"
#include "vtmacs.h"
@ -850,25 +851,26 @@ unsigned short LP[] = {
LVECT(I_ON, 0, 0), /* tracking object center */
SGM(GM_SVECT, IN_7, LP_ENA, BL_SAME, LT_SOLID),
SVECT(I_OFF, 1, -31),
SVECT(I_ON, -2, 0),
SVECT(I_OFF, 2, 0),
SVECT(I_ON, 0, 62),
SVECT(I_ON, -2, 0),
SVECT(I_OFF, 2, 0),
SVECT(I_ON, 30, -30),
SVECT(I_OFF, 0, -2),
SVECT(I_ON, 0, 2),
SVECT(I_ON, -62, 0),
SVECT(I_OFF, 0, -2),
SVECT(I_ON, 0, 2),
SVECT(I_OFF, 0, 30),
SVECT(I_ON, 0, -60),
SVECT(I_OFF, 30, 30),
SVECT(I_ON, -60, 0),
SVECT(I_ON, 30, 30),
SVECT(I_ON, 0, -62),
SVECT(I_ON, -30, 30),
SVECT(I_ON, 62, 0),
SVECT(I_ON, 30, -30),
SVECT(I_ON, -30, -30),
SVECT(I_ON, -30, 30),
SVECT(I_OFF, 10, 0),
SVECT(I_ON, 20, 20),
SVECT(I_ON, 20, -20),
SVECT(I_ON, -20, -20),
SVECT(I_ON, -20, 20),
SVECT(I_OFF, 10, 0),
SVECT(I_ON, 10, 10),
SVECT(I_ON, 10, -10),
SVECT(I_ON, -10, -10),
SVECT(I_ON, -10, 10),
#if 0 /* not needed for this app */
SVECT(I_OFF, -1, 31), /* "flyback" vector */
SVECT(I_OFF, 0, -10), /* "flyback" vector */
#endif
ENDSECT
@ -929,7 +931,7 @@ unsigned short VS[] = {
CHAR('/','2'),
LSRC(RO_SAME, CS_CHANGE, 3, VS_SAME, 0),
CHAR(' ',' '), CHAR('L','a'), CHAR('r','g'), CHAR('e',':'), CHAR(' ','2'),
CHAR('\r','\n'), CHAR('\r','\n'),
CHAR('\r','\n'),
CHAR(' ',' '), CHAR('A',SUBSCR), CHAR('B',SUBSCR), CHAR('C',SUBSCR),
CHAR('D',ENDSUB), CHAR(ENDSUB,ENDSUB), CHAR('W',SUPSCR),
CHAR('X',SUPSCR), CHAR('Y',SUPSCR), CHAR('Z',ENDSUP),
@ -951,7 +953,7 @@ unsigned short VS[] = {
CHAR('/','2'),
LSRC(RO_SAME, CS_CHANGE, 3, VS_SAME, 0),
CHAR(' ',' '), CHAR('L','a'), CHAR('r','g'), CHAR('e',':'), CHAR(' ','2'),
CHAR('\r','\n'), CHAR('\r','\n'),
CHAR('\r','\n'),
CHAR(' ',' '), CHAR('A',SUBSCR), CHAR('B',SUBSCR), CHAR('C',SUBSCR),
CHAR('D',ENDSUB), CHAR(ENDSUB,ENDSUB), CHAR('W',SUPSCR),
CHAR('X',SUPSCR), CHAR('Y',SUPSCR), CHAR('Z',ENDSUP),
@ -1137,7 +1139,79 @@ unsigned short VS[] = {
/* SECTION 7. Offset, vector scale, and clipping. */
/* XXX need test for offset, vector scale, and clipping */
LSRA(ST_SAME, SI_SAME, LI_BRIGHTDOWN, IT_NORMAL, RF_UNSYNC, MN_MAIN),
LSRC(RO_HORIZONTAL, CS_CHANGE, 1, VS_CHANGE, 4),
SGM(GM_APOINT, IN_3, LP_ENA, BL_OFF, LT_SOLID),
OFFSET(0, 0),
APOINT(I_ON, 01040, 01040),
APOINT(I_ON, 01040, 0740),
APOINT(I_ON, 0740, 01040),
APOINT(I_ON, 0740, 0740),
SGM(GM_APOINT, IN_5, LP_SAME, BL_ON, LT_SAME),
OFFSET(06, 010),
APOINT(I_ON, 01040, 01040),
APOINT(I_ON, 01040, 0740),
APOINT(I_ON, 0740, 01040),
APOINT(I_ON, 0740, 0740),
OFFSET(014, 020),
LSRC(RO_HORIZONTAL, CS_SAME, 0, VS_CHANGE, 8),
SGM(GM_APOINT, IN_7, LP_ENA, BL_SAME, LT_SAME),
APOINT(I_ON, 0420, 0420),
SGM(GM_RPOINT, IN_7, LP_SAME, BL_SAME, LT_SAME),
RPOINT(I_ON, 0, -040),
RPOINT(I_ON, -040, 040),
RPOINT(I_ON, 0, -040),
/* XXX need test for clipping */
ENDSECT
/* END OF TEST SECTIONS. */
ENDFILE
};
/* FILE WF. Rotating wire-frame display that works only for VS60. */
unsigned short WF[] = {
/* SECTION 1. 3D data, with depth cueing enabled. */
LSRBB(ZD_YES, ED_ENA, DQ_ON, ES_NO),
LSRA(ST_SAME, SI_SAME, LI_BRIGHTDOWN, IT_SAME, RF_40, MN_MAIN),
SGM(GM_APOINT, IN_4, LP_ENA, BL_OFF, LT_DDASH),
APOINT3(I_OFF, 0, 0, 0), /* cube coords filled in by wf_update() */
SGM(GM_AVECT, IN_SAME, LP_SAME, BL_SAME, LT_SAME),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_OFF, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
SGM(GM_AVECT, IN_SAME, LP_SAME, BL_SAME, LT_SOLID),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_OFF, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_OFF, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
AVECT3(I_OFF, 0, 0, 0),
AVECT3(I_ON, 0, 0, 0),
LSRA(ST_SAME, SI_SAME, LI_SAME, IT_SAME, RF_SAME, MN_MENU),
SGM(GM_APOINT, IN_7, LP_ENA, BL_OFF, LT_SAME),
APOINT3(I_OFF, 0, 1000, 0200),
SGM(GM_CHAR, IN_SAME, LP_SAME, BL_SAME, LT_SAME),
CHAR('4','0'), CHAR('H','z'), CHAR(' ','S'), CHAR('y','n'), CHAR('c',0),
ENDSECT
/* END OF TEST SECTIONS. */
@ -1148,6 +1222,68 @@ static unsigned short *df; /* -> start of current display file */
static uint16 start; /* initial DPC for section of d.file */
static int more; /* set until end of d.file seen */
static void
wf_update(int first_time) {
double c, s; /* cosine, sine of rotation angle */
int x, y, z; /* rotated coordinates */
static int xc = 01000, yc = 01000, zc = 0; /* cube center coords */
static int vp = 010000; /* distance to vanishing point */
static struct {
int offset; /* WF[] offset (words) of vector data */
int i; /* I_ON or I_OFF */
int x, y, z; /* coords of cube corner point */
} *dp, data[] = {
3, I_OFF, 00400, 00400, 0400,
7, I_ON, 01400, 00400, 0400,
10, I_ON, 01400, 01400, 0400,
13, I_ON, 00400, 01400, 0400,
16, I_ON, 00400, 00400, 0400,
19, I_OFF, 00400, 00400, -0400,
22, I_ON, 01400, 00400, -0400,
25, I_ON, 01400, 01400, -0400,
28, I_ON, 00400, 01400, -0400,
31, I_ON, 00400, 00400, -0400,
35, I_ON, 00400, 00400, 0400,
38, I_OFF, 01400, 00400, 0400,
41, I_ON, 01400, 00400, -0400,
44, I_OFF, 01400, 01400, -0400,
47, I_ON, 01400, 01400, 0400,
50, I_OFF, 00400, 01400, 0400,
53, I_ON, 00400, 01400, -0400,
-1 /* end-of-data marker */
};
static double rot = 0.0; /* total amount of rotation, degrees */
if (first_time) {
/* tilt cube toward viewer */
c = cos(30.0 * 3.14159/180.0);
s = sin(30.0 * 3.14159/180.0);
for (dp = data; dp->offset >= 0; ++dp) {
z = zc + ((dp->z - zc) * c + (dp->y - yc) * s);
y = yc + ((dp->y - yc) * c - (dp->z - zc) * s);
WF[dp->offset ] = dp->i | (SGN_(dp->x) << 13) | MAG_(dp->x);
WF[dp->offset + 1] = (SGN_(y) << 13) | MAG_(y);
WF[dp->offset + 2] = (SGN_(z) << 13) | (MAG_(z) << 2);
/* X coord. unchanged because rotation is parallel to X axis */
dp->y = y;
dp->z = z;
}
} else
if ((rot += 1.0) >= 360.0) /* rotation increment */
rot -= 360.0;
c = cos(rot * 3.14159/180.0);
s = sin(rot * 3.14159/180.0);
for (dp = data; dp->offset >= 0; ++dp) {
x = xc + ((dp->x - xc) * c + (dp->z - zc) * s);
z = zc + ((dp->z - zc) * c - (dp->x - xc) * s);
/* apply (approximate) perspective */
x = x * (1.0 + (double)z / vp );
y = dp->y * (1.0 + (double)z / vp );
WF[dp->offset ] = dp->i | (SGN_(x) << 13) | MAG_(x);
WF[dp->offset + 1] = (SGN_(y) << 13) | MAG_(y);
WF[dp->offset + 2] = (SGN_(z) << 13) | (MAG_(z) << 2);
}
}
int
main(void) {
int c;
@ -1216,6 +1352,26 @@ main(void) {
}
/* end of display file */
/* VS60 rotating wire-frame display */
puts("press and release tip switch (button 1) for next display");
fflush(stdout);
wf_update(1); /* do first-time init */
for (df = WF, start = 0, more = 1; more; ) {
vt11_reset(); /* reset everything */
vt11_set_dpc(start); /* start section */
c = 0;
while (vt11_cycle(USEC, 1)) {
display_sync(); /* XXX push down? */
if (display_lp_sw) /* tip switch activated */
c = 1; /* flag: break requested */
if (c && !display_lp_sw) /* wait for switch release */
break;
}
/* end of section */
}
/* end of display file */
/* XXX would be nice to have an example of animation */
return 0;
@ -1249,19 +1405,25 @@ vt_stop_intr(void) {
if (df[dpc/2] == 0) { /* ENDSECT */
#ifdef FRAME1STOP
int c;
puts("end of first pass through this test pattern; display frozen");
puts("end of pass through this test pattern; display frozen");
puts("enter newline to refresh this section or EOF to quit");
fflush(stdout);
while ((c = getchar()) != '\n')
if (c == EOF)
exit(0); /* user aborted test */
#endif
if (df == WF) {
wf_update(0);
vt11_set_dpc(0); /* restart modified display */
start = dpc + 2; /* save start of next section */
} else {
df[dpc/2 - 1] = JMPA;
df[dpc/2] = start;
start = dpc + 2; /* save start of next section */
vt11_set_dpc(dpc - 2); /* reset; then JMPA to old start */
puts("press and release tip switch (mouse button 1) for next display");
puts("press and release tip switch (button 1) for next display");
fflush(stdout);
}
} else /* ENDFILE */
more = 0;
}
@ -1279,8 +1441,9 @@ vt_lpen_intr(void) {
df[4] = dx | I_ON; /* visible */
df[5] = dy;
} else {
printf("VT11 lightpen interrupt (%d,%d)\n",
(int)vt11_get_xpr() & 01777, (int)vt11_get_ypr() & 01777);
printf("VT11 lightpen interrupt (0%o,0%o)\n",
(unsigned)vt11_get_xpr() & 01777,
(unsigned)vt11_get_ypr() & 01777);
fflush(stdout);
}
vt11_set_dpc((uint16)1); /* resume */
@ -1299,3 +1462,4 @@ vt_name_intr(void) {
fflush(stdout);
vt11_set_dpc((uint16)1); /* resume */
}

View file

@ -1,5 +1,5 @@
/*
* $Id: win32.c,v 1.38 2004/02/07 06:32:01 phil Exp $
* $Id: win32.c,v 1.39 2005/01/14 18:58:03 phil Exp $
* Win32 support for XY display simulator
* Phil Budne <phil@ultimate.com>
* September 2003
@ -47,7 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "ws.h"
#include "display.h"
#include "xy.h"
#ifndef PIX_SIZE
#define PIX_SIZE 1
@ -311,7 +311,7 @@ ws_thread_init(void)
/* XXX use a mutex; don't wait forever!! */
while (!init_done)
;
Sleep(200);
}
#endif /* THREADS */

View file

@ -32,7 +32,6 @@
/* unless you're writing a new driver, you shouldn't be looking here! */
extern int ws_init(char *, int, int, int);
extern void ws_close(void); // 2006-07-19 SAI
extern void *ws_color_rgb(int, int, int);
extern void *ws_color_black(void);
extern void *ws_color_white(void);

View file

@ -1,5 +1,5 @@
/*
* $Id: x11.c,v 1.29 2004/02/03 21:23:51 phil Exp $
* $Id: x11.c,v 1.32 2005/01/14 18:58:03 phil Exp $
* X11 support for XY display simulator
* Phil Budne <phil@ultimate.com>
* September 2003
@ -42,7 +42,7 @@
#include <stdlib.h>
#include <string.h>
#include "ws.h"
#include "display.h"
#include "xy.h"
#include <X11/X.h>
#include <X11/Xlib.h>
@ -59,10 +59,6 @@
#define PIX_SIZE 1
#endif
//#define FULL_SCREEN 1
#define NO_CURSOR 1
#define NO_BORDER 1
/*
* light pen location
* see ws.h for full description
@ -101,6 +97,7 @@ handle_button_press(w, d, e, b)
x = e->xbutton.x;
y = e->xbutton.y;
#ifdef FULL_SCREEN
/* untested! */
x -= xoffset;
y -= yoffset;
#endif
@ -109,12 +106,10 @@ handle_button_press(w, d, e, b)
y *= PIX_SIZE;
#endif
#ifndef NO_CURSUR
if (!display_tablet)
/* crosshair cursor to indicate tip of active pen */
XDefineCursor(dpy, XtWindow(crt),
(Cursor) XCreateFontCursor(dpy, XC_crosshair));
#endif
y = ypixels - y - 1;
/*printf("lightpen at %d,%d\n", x, y); fflush(stdout);*/
@ -142,12 +137,10 @@ handle_button_release(w, d, e, b)
Boolean *b;
{
if ((buttons &= ~e->xbutton.button) == 0) { /* all buttons released */
#ifndef NO_CURSOR
if (!display_tablet)
/* pencil cursor (close to a pen!) to indicate inactive pen posn */
XDefineCursor(dpy, XtWindow(crt),
(Cursor) XCreateFontCursor(dpy, XC_pencil));
#endif
/* XXX change cursor back?? */
ws_lp_x = ws_lp_y = -1;
@ -237,11 +230,7 @@ ws_init(char *crtname, /* crt type name */
crtshell = XtAppCreateShell( crtname, /* app name */
crtname, /* app class */
#ifdef NO_BORDER
overrideShellWidgetClass,
#else
applicationShellWidgetClass, /* wclass */
#endif
dpy, /* display */
NULL, /* arglist */
0); /* nargs */
@ -271,6 +260,7 @@ ws_init(char *crtname, /* crt type name */
crt = XtCreateWidget( crtname, widgetClass, crtshell, arg, n);
XtManageChild(crt);
XtPopup(crtshell, XtGrabNonexclusive);
XtSetKeyboardFocus(crtshell, crt); /* experimental? */
/*
* Create black and white Graphics Contexts
@ -285,13 +275,11 @@ ws_init(char *crtname, /* crt type name */
whiteGC = XCreateGC(dpy, XtWindow(crt),
GCForeground | GCBackground, &gcvalues);
#ifndef NO_CURSOR
if (!display_tablet) {
/* pencil cursor */
XDefineCursor(dpy, XtWindow(crt),
(Cursor) XCreateFontCursor(dpy, XC_pencil));
}
#endif
/*
* Setup to handle events
@ -310,17 +298,6 @@ ws_init(char *crtname, /* crt type name */
return 1;
} /* ws_init */
/* Added 2006-07-19 SAI */
void ws_close(void)
{
XtCloseDisplay(dpy);
}
void *
ws_color_black(void)
{

1036
display/xy.c Normal file

File diff suppressed because it is too large Load diff

142
display/xy.h Normal file
View file

@ -0,0 +1,142 @@
/*
* $Id: xy.h,v 1.13 2004/01/24 08:34:33 phil Exp $
* interface to O/S independent layer of XY display simulator
* Phil Budne <phil@ultimate.com>
* September 2003
*
* Changes from Douglas A. Gwyn, Jan 12, 2004
*/
/*
* Copyright (c) 2003-2004, Philip L. Budne
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the authors shall
* not be used in advertising or otherwise to promote the sale, use or
* other dealings in this Software without prior written authorization
* from the authors.
*/
/*
* known display types
*/
enum display_type {
DIS_VR14 = 14,
DIS_VR17 = 17,
DIS_VR20 = 20,
DIS_TYPE30 = 30,
DIS_VR48 = 48,
DIS_TYPE340 = 340
};
/*
* display scale factors
*/
#define RES_FULL 1
#define RES_HALF 2
#define RES_QUARTER 4
#define RES_EIGHTH 8
/*
* must be called before first call to display_age()
* (but called implicitly by display_point())
*/
extern int display_init(enum display_type, int scale);
/* return size of virtual display */
extern int display_xpoints(void);
extern int display_ypoints(void);
/* virtual points between display and menu sections */
#define VR48_GUTTER 8 /* just a guess */
/* conversion factor from virtual points and displayed pixels */
extern int display_scale(void);
/*
* simulate passage of time; first argument is simulated microseconds elapsed,
* second argument is flag to slow down simulated speed
* see comments in display.c for why you should call it often!!
* Under X11 polls for window events!!
*/
extern int display_age(int,int);
/*
* display intensity levels.
* always at least 8 (for VT11/VS60) -- may be mapped internally
*/
#define DISPLAY_INT_MAX 7
#define DISPLAY_INT_MIN 0 /* lowest "on" level */
/*
* plot a point; arguments are x, y, intensity, color (0/1)
* returns true if light pen active (mouse button down)
* at (or very near) this location.
*
* Display initialized on first call.
*/
extern int display_point(int,int,int,int);
/*
* force window system to output bits to screen;
* call after adding points, or aging the screen
*/
extern void display_sync(void);
/*
* currently a noop
*/
extern void display_reset(void);
/*
* ring the bell
*/
extern void display_beep(void);
/*
* Set light-pen radius; maximum radius in display coordinates
* from a "lit" location that the light pen will see.
*/
extern void display_lp_radius(int);
/*
* set by simulated spacewar switch box switches
* 18 bits (only high 4 and low 4 used)
*/
extern unsigned long spacewar_switches;
/*
* light pen "tip switch" activated (for VS60 emulation etc.)
* should only be set from "driver" (window system layer)
*/
extern unsigned char display_lp_sw;
/*
* deactivates light pen
* (SIMH DR11-C simulation when initialized sets this and
* then reports mouse coordinates as Talos digitizer data)
*/
extern unsigned char display_tablet;
/*
* users of this library are expected to provide these calls.
* simulator will set 18 simulated switches.
*/
extern unsigned long cpu_get_switches(void); /* get current switch state */
extern void cpu_set_switches(unsigned long); /* set switches */

View file

@ -677,6 +677,22 @@ SIM = scp.c sim_console.c sim_fio.c sim_timer.c sim_sock.c \
sim_tmxr.c sim_ether.c sim_tape.c sim_disk.c sim_serial.c \
sim_video.c
DISPLAYD = display
ifeq ($(WIN32),)
ifeq (x11,$(shell if $(TEST) -e /usr/include/X11/Intrinsic.h ; then echo x11; fi))
DISPLAYL = ${DISPLAYD}/display.c $(DISPLAYD)/x11.c
DISPLAYVT = ${DISPLAYD}/vt11.c
DISPLAY_OPT = -DUSE_DISPLAY -I/usr/X11/include -lXt -lX11 -lm
else
DISPLAYL =
DISPLAYVT =
DISPLAY_OPT =
endif
else
DISPLAYL = ${DISPLAYD}/display.c $(DISPLAYD)/win32.c
DISPLAYVT = ${DISPLAYD}/vt11.c
DISPLAY_OPT = -DUSE_DISPLAY -lgdi32
endif
#
# Emulator source files and compile time options
@ -684,8 +700,8 @@ SIM = scp.c sim_console.c sim_fio.c sim_timer.c sim_sock.c \
PDP1D = PDP1
PDP1 = ${PDP1D}/pdp1_lp.c ${PDP1D}/pdp1_cpu.c ${PDP1D}/pdp1_stddev.c \
${PDP1D}/pdp1_sys.c ${PDP1D}/pdp1_dt.c ${PDP1D}/pdp1_drm.c \
${PDP1D}/pdp1_clk.c ${PDP1D}/pdp1_dcs.c
PDP1_OPT = -I ${PDP1D}
${PDP1D}/pdp1_clk.c ${PDP1D}/pdp1_dcs.c ${PDP1D}/pdp1_dpy.c ${DISPLAYL}
PDP1_OPT = -I ${PDP1D} $(DISPLAY_OPT)
NOVAD = NOVA
@ -727,8 +743,9 @@ PDP11 = ${PDP11D}/pdp11_fp.c ${PDP11D}/pdp11_cpu.c ${PDP11D}/pdp11_dz.c \
${PDP11D}/pdp11_cr.c ${PDP11D}/pdp11_rf.c ${PDP11D}/pdp11_dl.c \
${PDP11D}/pdp11_ta.c ${PDP11D}/pdp11_rc.c ${PDP11D}/pdp11_kg.c \
${PDP11D}/pdp11_ke.c ${PDP11D}/pdp11_dc.c ${PDP11D}/pdp11_dmc.c \
${PDP11D}/pdp11_dup.c ${PDP11D}/pdp11_rs.c ${PDP11D}/pdp11_io_lib.c
PDP11_OPT = -DVM_PDP11 -I ${PDP11D} ${NETWORK_OPT}
${PDP11D}/pdp11_dup.c ${PDP11D}/pdp11_rs.c ${PDP11D}/pdp11_vt.c \
${PDP11D}/pdp11_io_lib.c $(DISPLAYL) $(DISPLAYVT)
PDP11_OPT = -DVM_PDP11 -I ${PDP11D} ${NETWORK_OPT} $(DISPLAY_OPT)
VAXD = VAX
@ -978,20 +995,6 @@ SWTP6800MP-A2 = ${SWTP6800C}/mp-a2.c ${SWTP6800C}/m6800.c ${SWTP6800C}/m6810.c \
${SWTP6800C}/mp-b2.c ${SWTP6800C}/mp-8m.c ${SWTP6800C}/i2716.c
SWTP6800_OPT = -I ${SWTP6800D}
DISPLAYD = display
ifeq ($(WIN32),)
ifeq (x11,$(shell if $(TEST) -e /usr/include/X11/Intrinsic.h ; then echo x11; fi))
DISPLAYL = ${DISPLAYD}/display.c $(DISPLAYD)/x11.c
DISPLAY_OPT = -DUSE_DISPLAY -I/usr/X11/include -lXt -lX11 -lm
else
DISPLAYL =
DISPLAY_OPT =
endif
else
DISPLAYL = ${DISPLAYD}/display.c $(DISPLAYD)/win32.c
DISPLAY_OPT = -DUSE_DISPLAY
endif
TX0D = TX-0
TX0 = ${TX0D}/tx0_cpu.c ${TX0D}/tx0_dpy.c ${TX0D}/tx0_stddev.c \
${TX0D}/tx0_sys.c ${TX0D}/tx0_sys_orig.c ${DISPLAYL}