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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <mach.h>
include <gki.h>
include "iis.h"
include "../lib/ids.h"
# ZCURSOR_READ -- Read cursor from display. This assumes that the cursor
# is centered at (31,31)
procedure zcursor_read (cnum, xcur, ycur, key)
int cnum # cursor number
int xcur, ycur # cursor position...GKI coordinates
int key # key pressed
short cursor[2] # local storage
real x,y
int frame
real zm
int mod(), and()
define exit_ 10
include "iis.com"
begin
# Computations must be done in floating point when zoomed
# or values are off by a pixel. Also, want fractional
# pixel returned values in the zoomed case.
call iishdr(IREAD, 2, COMMAND+CURSOR, 1+ADVXONTC, 0,0,0)
call iisio (cursor, 2 * SZB_CHAR)
# which frame is the cursor relative to? We assume that cnum
# mod IDS_CSET refers to the image plane (graphics fits in
# here as an image plane for iism70), and cnum / IDS_CSET
# sets which cursor.
# If cursor is #0, then take lowest numbered frame that is
# being displayed.
# Return frame number as the "key".
if (cnum == 0) {
frame = i_frame_on
if ((frame == ERR) || (frame < 1) ) {
key = ERR
return
}
} else if (cnum != IDS_CRAW) {
frame = mod(cnum-1, IDS_CSET) + 1
} else {
zm = 1.
frame = 0 # return unusual frame num. if raw read
}
# deal with cursor offset--hardware fault sometimes adds extra
# bit, so chop it off with and().
x = mod (and (int(cursor[1]), 777B)+ 31, 512)
y = mod (and (int(cursor[2]), 777B)+ 31, 512)
if (cnum == IDS_CRAW)
goto exit_
# x,y now in device coordinates for screen but not world.
# next, we determine number of pixels from screen center.
zm = zoom[frame]
x = x/zm - IIS_XCEN./zm
y = y/zm - IIS_YCEN_INV./zm
# Now add in scroll offsets, which are to screen center.
x = x + xscroll[frame]
# Note that the Y one is inverted
y = y + (IIS_YDIM-1) - yscroll[frame]
if (x < 0)
x = x + IIS_XDIM
else if (x > IIS_XDIM)
x = x - IIS_XDIM
if (y < 0)
y = y + IIS_YDIM
else if (y > IIS_YDIM)
y = y - IIS_YDIM
exit_
# invert y for user
y = (IIS_YDIM -1) - y
# The Y inversion really complicates things...
y = y + 1.0 - (1.0/zm)
# convert to GKI
xcur = x * MCXSCALE
ycur = y * MCYSCALE
key = frame
end
|