aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/tv/iis/iism70/iisscroll.x
blob: a583e4a4a249aa8568fb72a371ded1a21e4db284 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include <mach.h>
include <gki.h>
include "iis.h"
include "../lib/ids.h"

# IISSCROLL -- Read and Write scroll registers
# We scroll multiple frames to multiple centers; if there are not
# enough data pairs to match the number of frames, use the last
# pair repeatedly.

procedure iisscroll (rw, frame, n, data)

short	rw			# read or write
short	frame[ARB]		# frame data
short	n			# number of data values
short	data[ARB]		# the data

int	z
short	iispack()
int	i,total, pl, index

include "iis.com"

begin
	total = n/2
	if ( rw != IDS_WRITE) {
	    # Scroll registers are write only
	    do i = 1, total {
		pl = frame[i]
		if (pl == IDS_EOD)
		    break
		data[2*i-1] = xscroll[pl] * MCXSCALE
		data[2*i]   = yscroll[pl] * MCYSCALE
	    }

	    if (2*total < n)
		data[2*total+1] = IDS_EOD
	    return
	}

	# Set all the scroll offsets.
	index = 1
	for (i=1;  frame[i] != IDS_EOD;  i=i+1) {
	    pl = frame[i]
	    xscroll[pl] = data[2*index-1] / MCXSCALE
	    yscroll[pl] = data[2*index  ] / MCYSCALE
	    if (i < total)
		index = index + 1
	}

	# Now do the scrolling.
	for (i=1;  frame[i] != IDS_EOD;  i=i+1) {
	    pl = frame[i]
	    if (i == total) {
		z = iispack (frame[i])
		call do_scroll (z, xscroll[pl], yscroll[pl])
		break
	    } else
		call do_scroll (short(2**(pl-1)), xscroll[pl], yscroll[pl])
	}
end


procedure do_scroll (planes, x, y)

short	planes				# bit map for planes
short	x,y				# where to scroll

short	command
short	scr[2]
short	xs,ys

include	"iis.com"

begin
	xs = x
	ys = y
	command = IWRITE+VRETRACE
	scr[1] = xs
	scr[2] = ys

	# If x/y scroll at "center", scr[1/2] are now IIS_[XY]CEN
	# y = 0 is at top for device while y = 1 is bottom for user
	# so for y, center now moves to IIS_YCEN_INV !!

	scr[2] = IIS_YDIM - 1 - scr[2]

	# Scroll is given for center, but hardware wants corner coords.
	scr[1] = scr[1] - IIS_XCEN
	scr[2] = scr[2] - IIS_YCEN_INV

	if (scr[1] < 0)
	    scr[1] = scr[1] + IIS_XDIM
	if (scr[2] < 0)
	    scr[2] = scr[2] + IIS_YDIM

	call iishdr (command, 2, SCROLL, ADVXONTC, 0, int(planes), 0)
	call iisio (scr, 2 * SZB_CHAR)
end