aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/tv/display/t_dcontrol.x
blob: 8b68a66bd4992da8b241a2972cf99966edec0ab7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <syserr.h>
include <fset.h>
include "display.h"
include "zdisplay.h"
include "iis.h"

# DCONTROL -- Control functions for the image display device.  This has been
# cleaned up to eliminate unecessary operations and make it more efficient,
# but is only a throwaway program which breaks a few rules.  This file contains
# some explicitly IIS dependent code.

procedure t_dcontrol()

real	rate
int	zoom, type, status
pointer	sp, device, devinfo, tty
bool	erase, window, rgb_window, blink, match, roam
int	red_frame, green_frame, blue_frame, prim_frame, alt_frame, nframes
int	red_chan[2], green_chan[2], blue_chan[2], prim_chan[2], alt_chan[2]
char	type_string[SZ_FNAME], map_string[SZ_FNAME]
int	chan[2], alt1[2], alt2[2] alt3[2] alt4[2]

real	clgetr()
pointer	ttygdes()
bool	clgetb(), streq(), ttygetb()
int	clgeti(), clscan(), nscan(), envgets(), ttygets(), ttygeti(), btoi()
string	stdimage "stdimage"
include	"iis.com"
define	err_ 91

begin
	call smark (sp)
	call salloc (device, SZ_FNAME, TY_CHAR)
	call salloc (devinfo, SZ_LINE, TY_CHAR)

	# Get display parameters.

	call clgstr ("type", type_string, SZ_FNAME)
	call clgstr ("map",  map_string,  SZ_FNAME)

	red_frame   = clgeti ("red_frame")
	green_frame = clgeti ("green_frame")
	blue_frame  = clgeti ("blue_frame")
	prim_frame  = clgeti ("frame")
	alt_frame   = clgeti ("alternate")

	zoom        = clgeti ("zoom")
	rate        = clgetr ("rate")
	erase       = clgetb ("erase")
	window      = clgetb ("window")
	rgb_window  = clgetb ("rgb_window")
	blink       = clgetb ("blink")
	match       = clgetb ("match")
	roam        = clgetb ("roam")

	# Remember current frame.
	call clputi ("frame", prim_frame)
	call iis_setframe (prim_frame)

	# Get device information.
	call clgstr ("device", Memc[device], SZ_FNAME)
	if (streq (device, stdimage)) {
	    if (envgets (stdimage, Memc[device], SZ_FNAME) <= 0)
		call syserrs (SYS_ENVNF, stdimage)
	}
	tty = ttygdes (Memc[device])
	if (ttygets (tty, "DD", Memc[devinfo], SZ_LINE) <= 0)
	    call error (1, "no `DD' entry in graphcap entry for device")

	# Pick up the frame size and configuration number.
	iis_xdim   = ttygeti (tty, "xr")
	iis_ydim   = ttygeti (tty, "yr")
	iis_config = ttygeti (tty, "cn")
	iis_server = btoi (ttygetb (tty, "LC"))

	# Verify operation is legal on device.
	if (iis_server == YES) {
	    if (!streq (type_string, "frame"))
		goto err_
	    if (!streq (map_string, "mono"))
		goto err_
	    if (erase)
		;
	    if (roam)
		goto err_
	    if (window)
		goto err_
	    if (rgb_window)
		goto err_
	    if (blink)
		goto err_
	    if (match) {
err_		call eprintf ("operation not supported for display device %s\n")
		    call pargstr (Memc[device])
		call ttycdes (tty)
		call sfree (sp)
		return
	    }
	}

	# Access display.
	call strpak (Memc[devinfo], Memc[devinfo], SZ_LINE)
	call iisopn (Memc[devinfo], READ_WRITE, chan)
	if (chan[1] == ERR)
	    call error (2, "cannot open display")

	call fseti (STDOUT, F_FLUSHNL, YES)

	red_chan[1]   = FRTOCHAN(red_frame)
	green_chan[1] = FRTOCHAN(green_frame)
	blue_chan[1]  = FRTOCHAN(blue_frame)
	prim_chan[1]  = FRTOCHAN(prim_frame)
	alt_chan[1]   = FRTOCHAN(alt_frame)

	red_chan[2]   = MONO
	green_chan[2] = MONO
	blue_chan[2]  = MONO
	prim_chan[2]  = MONO
	alt_chan[2]   = MONO

	# Execute the selected control functions.
	if (streq (type_string, "rgb")) {
	    type = RGB
	    call zrgbim (red_chan, green_chan, blue_chan)
	} else if (streq (type_string, "frame")) {
	    type = FRAME
	    call zfrmim (prim_chan)
	} else
	    call error (3, "unknown display type")

	# Set display mapping.
	call zmapim (prim_chan, map_string)

	if (erase) {
	    switch (type) {
	    case RGB:
	        call zersim (red_chan)
	        call zersim (green_chan)
	        call zersim (blue_chan)
	    case FRAME:
		call zersim (prim_chan)
	    }

	} else {
	    if (roam) {
		call printf ("Roam display and exit by pushing any button\n")
		call zrmim (prim_chan, zoom)
	    }

	    if (window) {
	        call printf ("Window display and exit by pushing any button\n")
	        call zwndim (prim_chan)
	    }

	    if (rgb_window) {
	        call printf ("Window display and exit by pushing any button\n")
		call zwndim3 (red_chan, green_chan, blue_chan)
	    }

	    if (match)
		call zmtcim (alt_chan, prim_chan)

	    if (blink) {
		if (clscan ("alternate") != EOF) {
		    call gargi (alt1[1])
		    call gargi (alt2[1])
		    call gargi (alt3[1])
		    call gargi (alt4[1])
		    nframes = nscan()

		    alt1[1] = FRTOCHAN(alt1[1])
		    alt2[1] = FRTOCHAN(alt2[1])
		    alt3[1] = FRTOCHAN(alt3[1])
		    alt4[1] = FRTOCHAN(alt4[1])

		    alt1[2] = MONO
		    alt2[2] = MONO
		    alt3[2] = MONO
		    alt4[2] = MONO

		    call printf ("Exit by pushing any button\n")
		    call zblkim (alt1, alt2, alt3, alt4, nframes, rate)
		}
	    }
	}

	# Close display.
	call zclsim (chan[1], status)
	call ttycdes (tty)
	call sfree (sp)
end