aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/tv/iis/iism70
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/images/tv/iis/iism70')
-rw-r--r--pkg/images/tv/iis/iism70/README5
-rw-r--r--pkg/images/tv/iis/iism70/idsexpand.x30
-rw-r--r--pkg/images/tv/iis/iism70/iis.com12
-rw-r--r--pkg/images/tv/iis/iism70/iis.h120
-rw-r--r--pkg/images/tv/iis/iism70/iisbutton.x44
-rw-r--r--pkg/images/tv/iis/iism70/iiscls.x27
-rw-r--r--pkg/images/tv/iis/iism70/iiscursor.x108
-rw-r--r--pkg/images/tv/iis/iism70/iishdr.x31
-rw-r--r--pkg/images/tv/iis/iism70/iishisto.x53
-rw-r--r--pkg/images/tv/iis/iism70/iisifm.x51
-rw-r--r--pkg/images/tv/iis/iism70/iisio.x35
-rw-r--r--pkg/images/tv/iis/iism70/iislut.x67
-rw-r--r--pkg/images/tv/iis/iism70/iismatch.x76
-rw-r--r--pkg/images/tv/iis/iism70/iisminmax.x87
-rw-r--r--pkg/images/tv/iis/iism70/iisoffset.x67
-rw-r--r--pkg/images/tv/iis/iism70/iisofm.x53
-rw-r--r--pkg/images/tv/iis/iism70/iisopn.x35
-rw-r--r--pkg/images/tv/iis/iism70/iispack.x21
-rw-r--r--pkg/images/tv/iis/iism70/iispio.x65
-rw-r--r--pkg/images/tv/iis/iism70/iisrange.x97
-rw-r--r--pkg/images/tv/iis/iism70/iisrd.x51
-rw-r--r--pkg/images/tv/iis/iism70/iisscroll.x101
-rw-r--r--pkg/images/tv/iis/iism70/iissplit.x68
-rw-r--r--pkg/images/tv/iis/iism70/iistball.x41
-rw-r--r--pkg/images/tv/iis/iism70/iiswr.x51
-rw-r--r--pkg/images/tv/iis/iism70/iiswt.x18
-rw-r--r--pkg/images/tv/iis/iism70/iiszoom.x98
-rw-r--r--pkg/images/tv/iis/iism70/mkpkg58
-rw-r--r--pkg/images/tv/iis/iism70/zardim.x16
-rw-r--r--pkg/images/tv/iis/iism70/zawrim.x14
-rw-r--r--pkg/images/tv/iis/iism70/zawtim.x16
-rw-r--r--pkg/images/tv/iis/iism70/zclear.x33
-rw-r--r--pkg/images/tv/iis/iism70/zclsim.x13
-rw-r--r--pkg/images/tv/iis/iism70/zcontrol.x116
-rw-r--r--pkg/images/tv/iis/iism70/zcursor_read.x96
-rw-r--r--pkg/images/tv/iis/iism70/zcursor_set.x100
-rw-r--r--pkg/images/tv/iis/iism70/zdisplay_g.x91
-rw-r--r--pkg/images/tv/iis/iism70/zdisplay_i.x124
-rw-r--r--pkg/images/tv/iis/iism70/zinit.x45
-rw-r--r--pkg/images/tv/iis/iism70/zopnim.x17
-rw-r--r--pkg/images/tv/iis/iism70/zreset.x164
-rw-r--r--pkg/images/tv/iis/iism70/zrestore.x30
-rw-r--r--pkg/images/tv/iis/iism70/zsave.x30
-rw-r--r--pkg/images/tv/iis/iism70/zseek.x21
-rw-r--r--pkg/images/tv/iis/iism70/zsetup.x34
-rw-r--r--pkg/images/tv/iis/iism70/zsnap.com26
-rw-r--r--pkg/images/tv/iis/iism70/zsnap.x239
-rw-r--r--pkg/images/tv/iis/iism70/zsnapinit.x314
-rw-r--r--pkg/images/tv/iis/iism70/zsttim.x14
49 files changed, 3123 insertions, 0 deletions
diff --git a/pkg/images/tv/iis/iism70/README b/pkg/images/tv/iis/iism70/README
new file mode 100644
index 00000000..05f01307
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/README
@@ -0,0 +1,5 @@
+IISM70 -- Device dependent interface subroutines for the IIS Model 70 image
+display device. This package uses the ZFIOGD device driver, which is
+responsible for physical i/o to the device. The source for the ZFIOGD driver
+is in host$gdev; this driver must be compiled and installed in a system library
+(libsys.a) before i/o to the IIS will work correctly.
diff --git a/pkg/images/tv/iis/iism70/idsexpand.x b/pkg/images/tv/iis/iism70/idsexpand.x
new file mode 100644
index 00000000..da2a172d
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/idsexpand.x
@@ -0,0 +1,30 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gki.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# IDS_EXPAND -- expand FRAME/BITPL if first element is IDS_EOD
+# if the frames are not counted in order, as on the Model 75,
+# that should be dealt with here (use the "flag" boolean).
+
+procedure ids_expand(data, max, flag)
+
+short data[ARB] # data
+short max # max number of frames/bitplanes
+bool flag # true if frames ... e.g. for Model 75
+
+int i
+
+begin
+ if ( data[1] != IDS_EOD )
+ return
+ do i = 1, max {
+ data[i] = i
+ }
+ if ( flag) {
+ data[1+max] = GRCHNUM
+ data[2+max] = IDS_EOD
+ } else
+ data[1+max] = IDS_EOD
+end
diff --git a/pkg/images/tv/iis/iism70/iis.com b/pkg/images/tv/iis/iism70/iis.com
new file mode 100644
index 00000000..25a69d38
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iis.com
@@ -0,0 +1,12 @@
+# Common for IIS display
+
+int iischan # The device channel used by FIO
+int iisnopen # Number of times the display has been opened
+int iframe, iplane # frame, bitplanes to read/write
+int i_frame_on # Which frame is on...cursor readback
+short hdr[LEN_IISHDR] # Header
+short zoom[16] # zoom for each plane
+short xscroll[16] # scroll position for each plane
+short yscroll[16]
+common /iiscom/iischan, iisnopen, iframe, iplane, i_frame_on,
+ hdr, zoom, xscroll, yscroll
diff --git a/pkg/images/tv/iis/iism70/iis.h b/pkg/images/tv/iis/iism70/iis.h
new file mode 100644
index 00000000..96bb8b39
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iis.h
@@ -0,0 +1,120 @@
+# This file contains the hardware definitions for the iis model 70/f
+# at Kitt Peak.
+
+# Define header
+define LEN_IISHDR 8 # Length of IIS header
+
+define XFERID $1[1] # transfer id
+define THINGCT $1[2] # thing count
+define SUBUNIT $1[3] # subuint select
+define CHECKSUM $1[4] # check sum
+define XREG $1[5] # x register
+define YREG $1[6] # y register
+define ZREG $1[7] # z register
+define TREG $1[8] # t register
+
+# Transfer ID definitions
+define IREAD 100000B
+define IWRITE 0B
+define PACKED 40000B
+define BYPASSIFM 20000B
+define BYTE 10000B
+define ADDWRITE 4000B
+define ACCUM 2000B
+define BLOCKXFER 1000B
+define VRETRACE 400B
+define MUX32 200B
+
+# Subunits
+define REFRESH 1
+define LUT 2
+define OFM 3
+define IFM 4
+define FEEDBACK 5
+define SCROLL 6
+define VIDEOM 7
+define SUMPROC 8
+define GRAPHICS 9
+define CURSOR 10
+define ALU 11
+define ZOOM 12
+define IPB 15
+
+# Command definitions
+define COMMAND 100000B
+define ADVXONTC 100000B # Advance x on thing count
+define ADVXONYOV 40000B # Advance x on y overflow
+define ADVYONXOV 100000B # Advance y on x overflow
+define ADVYONTC 40000B # Advance y on thing count
+define ERASE 100000B # Erase
+
+# 4 - Button Trackball
+define PUSH 40000B
+define BUTTONA 400B
+define BUTTONB 1000B
+define BUTTONC 2000B
+define BUTTOND 4000B
+
+# Display channels
+define CHAN1 1B
+define CHAN2 2B
+define CHAN3 4B
+define CHAN4 10B
+define ALLCHAN 17B
+define GRCHAN 100000B
+define GRCHNUM 16
+
+define LEN_IISFRAMES 4
+define IISFRAMES CHAN1, CHAN2, CHAN3, CHAN4
+
+# Center coordinates for zoom/scroll
+define IIS_XCEN 256
+define IIS_YCEN 255
+# Inverted Y center is just IIS_YDIM - IIS_YCEN
+define IIS_YCEN_INV 256
+
+# Colors
+
+# these are bit plane mappings
+define BLUE 1B
+define GREEN 2B
+define RED 4B
+define MONO 7B
+# next colors used by snap code ... used as array indexes.
+define BLU 1
+define GR 2
+define RD 3
+
+
+# Bit plane selections
+define BITPL0 1B
+define BITPL1 2B
+define BITPL2 4B
+define BITPL3 10B
+define BITPL4 20B
+define BITPL5 40B
+define BITPL6 100B
+define BITPL7 200B
+define ALLBITPL 377B
+
+# IIS Sizes
+define IIS_XDIM 512
+define IIS_YDIM 512
+define MCXSCALE 64 # Metacode x scale
+define MCYSCALE 64 # Metacode y scale
+define SZB_IISHDR 16 # Size of IIS header in bytes
+define LEN_ZOOM 3 # Zoom parameters
+define LEN_CURSOR 3 # Cursor parameters
+define LEN_SELECT 12 # frame select
+define LEN_LUT 256 # Look up table
+define LEN_OFM 1024 # Output function look up table
+define LEN_IFM 8192 # Input function look up table
+define LEN_VIDEOM 2048 # videometer output memory
+define LEN_GRAM 256 # graphics ram
+define MAXX 512 # maximum x register + 1
+
+# IIS Status Words
+define IIS_FILSIZE (IIS_XDIM * IIS_YDIM * SZB_CHAR)
+define IIS_BLKSIZE 1
+define IIS_OPTBUFSIZE 32768
+define IIS_MAXBUFSIZE 32768
diff --git a/pkg/images/tv/iis/iism70/iisbutton.x b/pkg/images/tv/iis/iism70/iisbutton.x
new file mode 100644
index 00000000..50dfff7b
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisbutton.x
@@ -0,0 +1,44 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# IISBUTTON -- Read, button status
+
+procedure iisbutton (cnum, x, y, key)
+
+int cnum # cursor number
+int x,y # coordinates
+int key # key pressed
+
+short status
+int and()
+
+include "iis.com"
+
+begin
+ call iishdr (IREAD, 1, CURSOR+COMMAND, 0, 0, 0, 0)
+ call iisio (status, 1 * SZB_CHAR)
+
+ if ( cnum == IDS_BUT_WT ) {
+ while ( and (int(status), PUSH) == 0 ) {
+ call tsleep(1)
+ call iisio (status, 1 * SZB_CHAR)
+ }
+ }
+
+ if ( and ( int(status), PUSH) == 0 )
+ key = 0
+ else {
+ status = and ( int(status), 7400B) / 256
+ switch(status) {
+ case 4:
+ status = 3
+
+ case 8:
+ status = 4
+ }
+ key = status
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iiscls.x b/pkg/images/tv/iis/iism70/iiscls.x
new file mode 100644
index 00000000..c717f636
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iiscls.x
@@ -0,0 +1,27 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <knet.h>
+include "iis.h"
+
+define LEN_HID 5
+
+# IISCLS -- Close IIS display.
+
+procedure iiscls (chan, status)
+
+int chan[ARB]
+int status
+
+include "iis.com"
+
+begin
+ # first we need to tuck away the constants for zoom and scroll
+ # as we cannot read them on the model 70. Would that there were
+ # somewhere to put them. Alas not. So just drop them on the floor.
+
+ if (iisnopen == 1) {
+ call zclsgd (iischan, status)
+ iisnopen = 0
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iiscursor.x b/pkg/images/tv/iis/iism70/iiscursor.x
new file mode 100644
index 00000000..5ffc9131
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iiscursor.x
@@ -0,0 +1,108 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# cscale makes 0-32767 range from 0-62. The 62 results from the need
+# to describe a cursor with a center, and hence an ODD number of points.
+# Thus, we pretend the cursor ranges from 0-62 rather than 0-63, and
+# the center is at (31,31).
+# cwidth describes the (cursor) ram width, which is 64 ( by 64).
+
+define CSCALE 528
+define CWIDTH 64
+define CSIZE 4096
+
+# IISCURSOR -- Read, Write cursor shape, turn cursor on/off
+
+procedure iiscursor (rw, cur, n, data)
+
+short rw # read or write
+short cur # cursor number ... ignored for IIS M70
+short n # number of data values
+short data[ARB] # the data
+
+short command, len
+short shape[CSIZE]
+short status
+int rate
+int i,j,index
+int mod(), and(), or(), andi()
+
+include "iis.com"
+
+begin
+ len = 1
+ if (data[1] != IDS_CSHAPE) {
+ call iishdr (IREAD, len, CURSOR+COMMAND, 0, 0, 0, 0)
+ call iisio (status, len * SZB_CHAR)
+ }
+
+ if (rw == IDS_WRITE)
+ command = andi (IWRITE+VRETRACE, 177777B)
+ else
+ command = andi (IREAD+VRETRACE, 177777B)
+
+ if (data[1] != IDS_CSHAPE){
+ if (rw == IDS_WRITE) {
+ switch (data[1]) {
+ case IDS_OFF:
+ status = and(int(status), 177776B)
+
+ case IDS_ON:
+ status = or (int(status), 1)
+
+ case IDS_CBLINK:
+ rate = mod (int(data[2])-1, 4) * 8
+ status = or (rate, and (int(status),177747B))
+ }
+ call iishdr (command, len, CURSOR+COMMAND, 0, 0, 0, 0)
+ call iisio (status, len * SZB_CHAR)
+ } else {
+ if ( data[1] == IDS_CBLINK )
+ data[2] = ( and (int(status), 30B) / 8 ) + 1
+ else if ( and ( int(status), 1) == 0 )
+ data[1] = IDS_OFF
+ else
+ data[1] = IDS_ON
+ }
+
+ } else {
+ # deal with cursor shape.
+
+ len = CSIZE
+ if ( rw == IDS_WRITE) {
+ call aclrs (shape, CSIZE)
+ for ( i = 2 ; i <= n-1 ; i = i + 2 ) {
+ # given GKI data pairs for x,y cursor_on bits, set shape datum
+ # the first value is x, then y
+ if (data[i] == IDS_EOD)
+ break
+ j = data[i]/CSCALE
+ index = (data[i+1]/CSCALE) * CWIDTH + j + 1
+ shape[index] = 1
+ }
+ }
+
+ call iishdr (command, len, CURSOR, ADVXONTC, ADVYONXOV, 0, 0)
+ call iisio (shape, len * SZB_CHAR)
+
+ # if read command, return all set bits as GKI x,y pairs
+ if ( rw != IDS_WRITE) {
+ i = 2
+ for ( j = 1 ; j <= CSIZE ; j = j + 1 ) {
+ if ( shape[j] != 0 ) {
+ data[i] = mod(j,CWIDTH) * CSCALE
+ data[i+1] = (j/CWIDTH) * CSCALE
+ i = i + 2
+ if ( i > n-1 )
+ break
+ }
+ }
+ if ( i <= n )
+ data[i] = IDS_EOD
+ n = i
+ }
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iishdr.x b/pkg/images/tv/iis/iism70/iishdr.x
new file mode 100644
index 00000000..bf22d493
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iishdr.x
@@ -0,0 +1,31 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+
+# IISHDR -- Form IIS header.
+
+procedure iishdr (id, count, subunit, x, y, z, t)
+
+int id, count, subunit, x, y, z, t
+int i, sum
+include "iis.com"
+
+begin
+ XFERID(hdr) = id
+ THINGCT(hdr) = count
+ SUBUNIT(hdr) = subunit
+ XREG(hdr) = x
+ YREG(hdr) = y
+ ZREG(hdr) = z
+ TREG(hdr) = t
+ CHECKSUM(hdr) = 1
+
+ if (THINGCT(hdr) > 0)
+ THINGCT(hdr) = -THINGCT(hdr)
+
+ sum = 0
+ for (i = 1; i <= LEN_IISHDR; i = i + 1)
+ sum = sum + hdr[i]
+ CHECKSUM(hdr) = -sum
+end
diff --git a/pkg/images/tv/iis/iism70/iishisto.x b/pkg/images/tv/iis/iism70/iishisto.x
new file mode 100644
index 00000000..374342a0
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iishisto.x
@@ -0,0 +1,53 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# IISHISTO -- Activate, Read histogram.
+
+procedure iishisto (rw, color, offset, a_n, data)
+
+short rw # read or write
+short color[ARB] # color(s) to write
+short offset # offset into histogram table
+short a_n # number of data values
+short data[ARB] # the data
+
+int n, command, off, len, x, y, z
+include "iis.com"
+
+begin
+ n = a_n
+ if (n < 1)
+ return
+
+ # set the area to be histogrammed ... in data[1], currently
+ # device very specific ( 2 == whole region) . Need to fix this
+ # perhaps via specific graph plane filled with gkifill command to
+ # depict area desired.
+ # n must be twice the number of datum values. Upper level code
+ # must know this to leave enough room. Would be better if upper
+ # code could ignore this (fact).
+
+ if (rw == IDS_WRITE) {
+ command = IWRITE+VRETRACE
+ x = 0
+ y = 0
+ z = 0
+ len = 1
+ data[1] = 2
+ call iishdr (command, len, VIDEOM+COMMAND, x, y, z, 0)
+ call iisio (data[1], len * SZB_CHAR)
+ return
+ }
+
+ off = offset
+ command = IREAD+VRETRACE
+ len = min (n, LEN_VIDEOM-off+1)
+ off = min (LEN_VIDEOM, off) - 1
+ y = off/MAXX + ADVYONXOV
+ x = mod (off, MAXX) + ADVXONTC
+ call iishdr (command, len, VIDEOM, x, y, z, 0)
+ call iisio (data, len * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/iisifm.x b/pkg/images/tv/iis/iism70/iisifm.x
new file mode 100644
index 00000000..ef04a1be
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisifm.x
@@ -0,0 +1,51 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LUT_IMAX 255
+
+# IISIFM -- Read and Write INPUT look up table.
+# Written data is from line end points, read data
+# is full array.
+
+procedure iisifm (rw, offset, n, data)
+
+short rw # read or write
+short offset # offset into lut
+short n # number of data values
+short data[ARB] # the data
+
+int command,len,x,y
+pointer sp, idata
+
+include "iis.com"
+
+begin
+ if ( rw == IDS_WRITE) {
+ if (n < 4)
+ return
+
+ call smark (sp)
+ call salloc (idata, LEN_IFM, TY_SHORT)
+ call aclrs (Mems[idata], LEN_IFM)
+
+ command = IWRITE+VRETRACE
+ call idslfill (data, int(n), Mems[idata], LEN_IFM, 0, LUT_IMAX)
+ len = LEN_IFM
+ } else {
+ len = n
+ command = IREAD+VRETRACE
+ }
+
+ y = ADVYONXOV
+ x = ADVXONTC
+ call iishdr (command, len, IFM, x, y, 0, 0)
+
+ if (rw == IDS_WRITE) {
+ call iisio (Mems[idata], len * SZB_CHAR)
+ call sfree (sp)
+ } else
+ call iisio (data, len * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/iisio.x b/pkg/images/tv/iis/iism70/iisio.x
new file mode 100644
index 00000000..f8e005c6
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisio.x
@@ -0,0 +1,35 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <knet.h>
+include "iis.h"
+
+# IISIO -- Read/Write to IIS.
+
+procedure iisio (buf, nbytes)
+
+short buf[ARB]
+int nbytes
+
+int nbites
+int and()
+
+include "iis.com"
+
+begin
+ call iiswt (iischan, nbites)
+ if (nbites == ERR)
+ return
+
+ call zawrgd (iischan, hdr, SZB_IISHDR, 0)
+ call iiswt (iischan, nbites)
+ if (nbites == ERR)
+ return
+
+ if (and (int(XFERID(hdr)), IREAD) != 0)
+ call zardgd (iischan, buf, nbytes, 0)
+ else
+ call zawrgd (iischan, buf, nbytes, 0)
+
+ call iiswt (iischan, nbites)
+end
diff --git a/pkg/images/tv/iis/iism70/iislut.x b/pkg/images/tv/iis/iism70/iislut.x
new file mode 100644
index 00000000..07819247
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iislut.x
@@ -0,0 +1,67 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LUT_LMAX 255
+
+# IISLUT -- Read and Write look up table.
+# NOTE the ASYMMETRY ... written data is derived from end
+# points, but read data is the full array (see zsnapinit,
+# for instance, for read usage.)
+
+procedure iislut (rw, frame, color, offset, n, data)
+
+short rw # read or write
+short frame[ARB] # frame array
+short color[ARB] # color array
+short offset # offset into lut
+short n # number of data values
+short data[ARB] # the data
+
+int command,len,x,y,z,t
+short iispack()
+int mapcolor()
+pointer sp, ldata
+
+include "iis.com"
+
+begin
+ z = mapcolor (color)
+ t = iispack(frame)
+ if (t == GRCHAN) {
+ return
+ }
+
+ if ( rw == IDS_WRITE) {
+ if ( n < 4)
+ return
+ command = IWRITE+VRETRACE
+
+ # data space for manipulating lut information
+
+ call smark (sp)
+ call salloc (ldata, LEN_LUT, TY_SHORT)
+ call aclrs (Mems[ldata], LEN_LUT)
+
+ # We could have negative lut values, but don't bother for now
+ call idslfill (data, int(n), Mems[ldata], LEN_LUT, 0, LUT_LMAX)
+
+ len = LEN_LUT
+ } else {
+ len = n
+ command = IREAD+VRETRACE
+ }
+
+ x = ADVXONTC
+ y = 0
+
+ call iishdr (command, len, LUT, x, y, z, t)
+
+ if ( rw == IDS_WRITE) {
+ call iisio (Mems[ldata], len * SZB_CHAR)
+ call sfree (sp)
+ } else
+ call iisio (data, len * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/iismatch.x b/pkg/images/tv/iis/iism70/iismatch.x
new file mode 100644
index 00000000..a2435fdc
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iismatch.x
@@ -0,0 +1,76 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# IISMATCH -- copy (match) a set of look up tables to a given table;
+# frames/color specify the given table, data gives frame/color for
+# set to be changed.
+
+procedure iismatch (code, frames, color, n, data)
+
+short code # which table type
+short frames[ARB] # reference frame
+short color[ARB] # reference color
+short n # count of data items
+short data[ARB] # frame/color to be changed.
+
+pointer sp, ldata
+int len, x,y,z,t
+int unit, i
+int mapcolor(), ids_dcopy()
+short temp[IDS_MAXIMPL+1]
+short iispack()
+
+include "../lib/ids.com"
+
+begin
+ switch (code) {
+ case IDS_FRAME_LUT:
+ len = LEN_LUT
+ x = ADVXONTC
+ y = 0
+ z = mapcolor (color)
+ t = iispack (frames)
+ if (t == GRCHAN)
+ return
+ unit = LUT
+
+ case IDS_OUTPUT_LUT:
+ len = LEN_OFM
+ x = ADVXONTC
+ y = ADVYONXOV
+ z = mapcolor (color)
+ t = 0
+
+ default:
+ return
+ }
+
+ call smark (sp)
+ call salloc (ldata, len, TY_SHORT)
+
+ call iishdr (IREAD+VRETRACE, len, unit, x, y, z, t)
+ call iisio (Mems[ldata], len * SZB_CHAR)
+
+ i = ids_dcopy (data, temp)
+ switch (code) {
+ case IDS_FRAME_LUT:
+ call ids_expand (temp, i_maxframes, true)
+ t = iispack (temp)
+ i = ids_dcopy (data[i+1], temp)
+ call ids_expand (temp, 3, false) # 3...max colors
+ z = mapcolor (temp)
+
+ case IDS_OUTPUT_LUT:
+ i = ids_dcopy (data[i+1], temp)
+ call ids_expand (temp, 3, false)
+ z = mapcolor (temp)
+ }
+
+ call iishdr (IWRITE+VRETRACE, len, unit, x, y, z, t)
+ call iisio (Mems[ldata], len * SZB_CHAR)
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/iis/iism70/iisminmax.x b/pkg/images/tv/iis/iism70/iisminmax.x
new file mode 100644
index 00000000..22a3062e
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisminmax.x
@@ -0,0 +1,87 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LEN_MM 6
+
+# IISMIN -- Read minimum registers
+
+procedure iismin (rw, color, n, data)
+
+short rw # read or write
+short color[ARB] # color
+short n # number of data values
+short data[ARB] # the data
+
+int command,x
+short const[LEN_MM]
+int i,j
+
+include "iis.com"
+
+begin
+ if ( rw == IDS_WRITE)
+ return
+ command = IREAD+VRETRACE
+ x = ADVXONTC
+ call iishdr(command, LEN_MM, SUMPROC+COMMAND, x, 0, 0, 0)
+ call iisio (const, LEN_MM * SZB_CHAR)
+ j = 1
+ for ( i = 1 ; i <= n ; i = i + 1 ) {
+ switch(color[j]) {
+ case IDS_RED:
+ data[i] = const[5]
+
+ case IDS_GREEN:
+ data[i] = const[3]
+
+ case IDS_BLUE:
+ data[i] = const[1]
+ }
+ j = j+1
+ if ( color[j] == IDS_EOD )
+ j = j - 1
+ }
+end
+
+# IISMAX -- Read maximum registers
+
+procedure iismax (rw, color, n, data)
+
+short rw # read or write
+short color[ARB] # color
+short n # number of data values
+short data[ARB] # the data
+
+int command,x
+short const[LEN_MM]
+int i,j
+
+include "iis.com"
+
+begin
+ if ( rw == IDS_WRITE)
+ return
+ command = IREAD+VRETRACE
+ x = ADVXONTC
+ call iishdr(command, LEN_MM, SUMPROC+COMMAND, x, 0, 0, 0)
+ call iisio (const, LEN_MM * SZB_CHAR)
+ j = 1
+ for ( i = 1 ; i <= n ; i = i + 1 ) {
+ switch(color[j]) {
+ case IDS_RED:
+ data[i] = const[6]
+
+ case IDS_GREEN:
+ data[i] = const[4]
+
+ case IDS_BLUE:
+ data[i] = const[2]
+ }
+ j = j+1
+ if ( color[j] == IDS_EOD )
+ j = j - 1
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iisoffset.x b/pkg/images/tv/iis/iism70/iisoffset.x
new file mode 100644
index 00000000..d7f618dc
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisoffset.x
@@ -0,0 +1,67 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LEN_CONST 3
+
+# IISOFFSET -- Read and Write output bias registers
+
+procedure iisoffset (rw, color, n, data)
+
+short rw # read or write
+short color[ARB] # color
+short n # number of data values
+short data[ARB] # the data
+
+int command,len,x
+short const[3]
+int i,j
+
+include "iis.com"
+
+begin
+ command = IREAD+VRETRACE
+ x = 8 + ADVXONTC
+ len = LEN_CONST
+ call iishdr(command, len, SUMPROC+COMMAND, x, 0, 0, 0)
+ call iisio (const, len * SZB_CHAR)
+ if ( rw == IDS_WRITE) {
+ command = IWRITE+VRETRACE
+ j = 1
+ for ( i =1 ; color[i] != IDS_EOD ; i = i + 1) {
+ switch(color[i]) {
+ case IDS_RED:
+ const[3] = data[j]
+
+ case IDS_GREEN:
+ const[2] = data[j]
+
+ case IDS_BLUE:
+ const[1] = data[j]
+ }
+ if ( j < n)
+ j = j + 1
+ }
+ call iishdr (command, len, SUMPROC+COMMAND, x, 0, 0, 0)
+ call iisio (const, len * SZB_CHAR)
+ } else {
+ j = 1
+ for ( i = 1 ; i <= n ; i = i + 1 ) {
+ switch(color[j]) {
+ case IDS_RED:
+ data[i] = const[3]
+
+ case IDS_GREEN:
+ data[i] = const[2]
+
+ case IDS_BLUE:
+ data[i] = const[1]
+ }
+ j = j+1
+ if ( color[j] == IDS_EOD )
+ j = j - 1
+ }
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iisofm.x b/pkg/images/tv/iis/iism70/iisofm.x
new file mode 100644
index 00000000..0c19c117
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisofm.x
@@ -0,0 +1,53 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LUT_OMAX 1023
+
+# IISOFM -- Read and Write OUTPUT look up table.
+# Written data is from end points, read data is full
+# array.
+
+procedure iisofm (rw, color, offset, n, data)
+
+short rw # read or write
+short color[ARB] # color(s) to write
+short offset # offset into lut
+short n # number of data values
+short data[ARB] # the data
+
+int command,len,x,y,z
+int mapcolor()
+pointer sp, odata
+
+include "iis.com"
+
+begin
+ z = mapcolor (color)
+ if ( rw == IDS_WRITE) {
+ if (n < 4)
+ return
+
+ call smark (sp)
+ call salloc (odata, LEN_OFM, TY_SHORT)
+ call aclrs (Mems[odata], LEN_OFM)
+
+ command = IWRITE+VRETRACE
+ call idslfill (data, int(n), Mems[odata], LEN_OFM, 0, LUT_OMAX)
+ len = LEN_OFM
+ }
+ else {
+ len = n
+ command = IREAD+VRETRACE
+ }
+ y = ADVYONXOV
+ x = ADVXONTC
+ call iishdr (command, len, OFM, x, y, z, 0)
+ if (rw == IDS_WRITE) {
+ call iisio (Mems[odata], len * SZB_CHAR)
+ call sfree (sp)
+ } else
+ call iisio (data, len * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/iisopn.x b/pkg/images/tv/iis/iism70/iisopn.x
new file mode 100644
index 00000000..29335c62
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisopn.x
@@ -0,0 +1,35 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <knet.h>
+include "iis.h"
+
+# IISOPN -- Open IIS display.
+
+procedure iisopn (devinfo, mode, chan)
+
+char devinfo[ARB] # device info for zopen
+int mode # access mode
+int chan[ARB] # receives IIS descriptor
+
+bool first_time
+data first_time /true/
+include "iis.com"
+
+begin
+ if (first_time) {
+ iisnopen = 0
+ first_time = false
+ }
+
+ # We permit multiple opens but only open the physical device once.
+ if (iisnopen == 0)
+ call zopngd (devinfo, mode, iischan)
+
+ if (iischan == ERR)
+ chan[1] = ERR
+ else {
+ iisnopen = iisnopen + 1
+ chan[1] = iischan
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iispack.x b/pkg/images/tv/iis/iism70/iispack.x
new file mode 100644
index 00000000..4c2c70f3
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iispack.x
@@ -0,0 +1,21 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "../lib/ids.h"
+
+# IISPACK -- Pack color or frame data into a single word.
+
+short procedure iispack (data)
+
+short data[ARB]
+int value, bit, i
+int or()
+
+begin
+ value = 0
+ for (i=1; data[i] != IDS_EOD; i=i+1) {
+ bit = data[i] - 1
+ value = or (value, 2 ** bit)
+ }
+
+ return (value)
+end
diff --git a/pkg/images/tv/iis/iism70/iispio.x b/pkg/images/tv/iis/iism70/iispio.x
new file mode 100644
index 00000000..f8c57138
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iispio.x
@@ -0,0 +1,65 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <knet.h>
+include "iis.h"
+
+# IISPIO -- Pixel i/o to the IIS.
+
+procedure iispio (buf, ny)
+
+short buf[IIS_XDIM,ny] # Cell array
+int ny # number of image lines
+
+pointer iobuf
+bool first_time
+int xferid, status, npacked, szline, i
+int and()
+include "iis.com"
+data first_time /true/
+
+begin
+ if (first_time) {
+ call malloc (iobuf, IIS_MAXBUFSIZE, TY_CHAR)
+ first_time = false
+ }
+
+ # Wait for the last i/o transfer.
+ call iiswt (iischan, status)
+ if (status == ERR)
+ return
+
+ # Transmit the packet header.
+ call zawrgd (iischan, hdr, SZB_IISHDR, 0)
+ call iiswt (iischan, status)
+ if (status == ERR)
+ return
+
+ # Read or write the data block.
+ npacked = ny * IIS_XDIM
+ szline = IIS_XDIM / (SZ_SHORT * SZB_CHAR)
+
+ # Transmit the data byte-packed to increase the i/o bandwith
+ # when using network i/o.
+
+ xferid = XFERID(hdr)
+ if (and (xferid, IREAD) != 0) {
+ # Read from the IIS.
+
+ call zardgd (iischan, Memc[iobuf], npacked, 0)
+ call iiswt (iischan, status)
+
+ # Unpack and line flip the packed data.
+ do i = 0, ny-1
+ call achtbs (Memc[iobuf+i*szline], buf[1,ny-i], IIS_XDIM)
+
+ } else {
+ # Write to the IIS.
+
+ # Bytepack the image lines, doing a line flip in the process.
+ do i = 0, ny-1
+ call achtsb (buf[1,ny-i], Memc[iobuf+i*szline], IIS_XDIM)
+
+ call zawrgd (iischan, Memc[iobuf], npacked, 0)
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iisrange.x b/pkg/images/tv/iis/iism70/iisrange.x
new file mode 100644
index 00000000..8fad856b
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisrange.x
@@ -0,0 +1,97 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define LEN_RANGE 1
+
+# IISRANGE -- Read and write range scaling registers
+# Input data is of form 1-->range "0", 2,3 --> "1", 4-7 --> "2"
+# and anything beyond 7 --> "4". This is just like zoom.
+# However, on readback, the actual range values are returned. If
+# this should change, the zsnapinit code must change too (the only
+# place where a range read is done).
+
+procedure iisrange (rw, color, n, data)
+
+short rw # read or write
+short color[ARB] # color
+short n # number of data values
+short data[ARB] # the data
+
+short range
+int i, j
+int command, x, itemp, ival
+int and(), or()
+include "iis.com"
+
+begin
+ if (data[1] == IDS_EOD)
+ return
+
+ command = IREAD
+ x = ADVXONTC
+
+ call iishdr (command, LEN_RANGE, OFM+COMMAND, x, 0, 0, 0)
+ call iisio (range, LEN_RANGE * SZB_CHAR)
+
+ if (rw == IDS_WRITE) {
+ command = IWRITE+VRETRACE
+ j = 1
+ for (i=1; color[i] != IDS_EOD; i=i+1) {
+ switch (data[j]) {
+ case 1,2:
+ ival = data[j]-1
+ case 3:
+ ival = 1
+ case 4,5,6,7:
+ ival = 2
+
+ default:
+ if (ival < 0)
+ ival = 0
+ else
+ ival = 3
+ }
+
+ itemp = range
+ switch(color[i]) {
+ case IDS_RED:
+ range = or (ival*16, and (itemp, 17B))
+
+ case IDS_GREEN:
+ range = or (ival*4, and (itemp, 63B))
+
+ case IDS_BLUE:
+ range = or (ival, and (itemp, 74B))
+ }
+
+ if ( j < n)
+ j = j + 1
+ }
+
+ call iishdr (command, LEN_RANGE, OFM+COMMAND, x, 0, 0, 0)
+ call iisio (range, LEN_RANGE * SZB_CHAR)
+
+ } else {
+ # Return a range value
+ j = 1
+ for (i=1; i <= n; i=i+1) {
+ itemp = range
+ switch (color[j]) {
+ case IDS_RED:
+ data[i] = and (itemp, 60B) / 16
+
+ case IDS_GREEN:
+ data[i] = and (itemp, 14B) / 4
+
+ case IDS_BLUE:
+ data[i] = and (itemp, 3B)
+ }
+ j = j+1
+ if (color[j] == IDS_EOD)
+ j = j - 1
+ }
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iisrd.x b/pkg/images/tv/iis/iism70/iisrd.x
new file mode 100644
index 00000000..20e99cb2
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisrd.x
@@ -0,0 +1,51 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+
+# IISRD -- Read data from IIS. Reads are packed when can.
+# The data is line-flipped.
+
+procedure iisrd (chan, buf, nbytes, offset)
+
+int chan[ARB]
+short buf[ARB]
+int nbytes
+long offset
+
+long off1, off2
+int nchars, thing_count, tid, y1, y2, x
+int or()
+include "iis.com"
+
+begin
+ # Convert to chars and clip at the top of the display.
+ off1 = (offset - 1) / SZB_CHAR + 1
+ off2 = min (IIS_XDIM * IIS_YDIM, (offset + nbytes - 1) / SZB_CHAR) + 1
+ nchars = off2 - off1
+
+ y1 = (off1-1 ) / IIS_XDIM
+ y2 = (off2-1 - IIS_XDIM) / IIS_XDIM
+ y2 = max (y1,y2)
+
+ # Pack only if start at x=0
+ x = (off1 - 1) - y1 * IIS_XDIM
+ if ( x == 0 )
+ tid = IREAD+PACKED
+ else
+ tid = IREAD
+
+ # If only a few chars, don't pack...have trouble with count of 1
+ # and this maeks code same as iiswr.x
+ if ( nchars < 4 )
+ tid = IREAD
+
+ thing_count = nchars
+
+ call iishdr (tid, thing_count, REFRESH,
+ or (x, ADVXONTC), or (IIS_YDIM-1-y2, ADVYONXOV), iframe, iplane)
+ if ( tid == IREAD)
+ call iisio (buf, nbytes)
+ else
+ call iispio (buf, y2 - y1 + 1)
+end
diff --git a/pkg/images/tv/iis/iism70/iisscroll.x b/pkg/images/tv/iis/iism70/iisscroll.x
new file mode 100644
index 00000000..a583e4a4
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iisscroll.x
@@ -0,0 +1,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
diff --git a/pkg/images/tv/iis/iism70/iissplit.x b/pkg/images/tv/iis/iism70/iissplit.x
new file mode 100644
index 00000000..2badb7cb
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iissplit.x
@@ -0,0 +1,68 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define X_SPLIT 12
+
+# IISSPLIT -- Read and Write split screen coordinates
+
+procedure iissplit (rw, n, data)
+
+short rw # read or write
+short n # number of data values
+short data[ARB] # the data
+
+int command,len,x
+short coord[2]
+
+include "iis.com"
+
+begin
+ len = min (int(n), 2)
+ if ( len < 1) {
+ data[1] = IDS_EOD
+ return
+ }
+
+ if (rw == IDS_WRITE) {
+ if (data[1] == IDS_EOD)
+ return
+ command = IWRITE+VRETRACE
+ coord[1] = data[1] / MCXSCALE
+
+
+ # Split screen will display the full screen from one lut ONLY
+ # if the split coordinate is zero. Setting the split to 511
+ # means that all the screen BUT the last pixel is from one lut.
+ # Hence the y coordinate for full screen in one quad is
+ # (device) 0 , (user) 511. If the user requests split at (0,0),
+ # we honor this as a (device) (0,0). This will remove the
+ # ability to split the screen with just the bottom line
+ # in the "other" lut, which shouldn't bother anyone.
+
+ if (len == 2)
+ coord[2] = (IIS_YDIM - 1) - data[2]/MCYSCALE
+
+ if (coord[2] == IIS_YDIM - 1)
+ coord[2] = 0
+
+ } else
+ command = IREAD+VRETRACE
+
+ # at most, read/write the x,y registers
+ x = X_SPLIT + ADVXONTC
+
+ call iishdr (command, len, LUT+COMMAND, x, 0, 0, 0)
+ call iisio (coord, len * SZB_CHAR)
+
+ if ( rw != IDS_WRITE ) {
+ data[1] = coord[1] * MCXSCALE
+ if ( len == 2 ) {
+ if ( coord[2] == 0)
+ coord[2] = IIS_YDIM - 1
+ data[2] = (IIS_YDIM - 1 - coord[2] ) * MCYSCALE
+ }
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iistball.x b/pkg/images/tv/iis/iism70/iistball.x
new file mode 100644
index 00000000..ebcc6566
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iistball.x
@@ -0,0 +1,41 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# IISTBALL -- Read, Write tball status to turn tball on/off
+
+procedure iistball (rw, data)
+
+short rw # read or write
+short data[ARB] # the data
+
+int command,len
+short status
+int and(), or()
+
+include "iis.com"
+
+begin
+ len = 1
+ call iishdr (IREAD, len, CURSOR+COMMAND, 0, 0, 0, 0)
+ call iisio (status, len * SZB_CHAR)
+ if ( rw == IDS_WRITE) {
+ command = IWRITE+VRETRACE
+ switch (data[1]) {
+ case IDS_OFF:
+ status = and (int(status), 177771B)
+
+ case IDS_ON:
+ status = or ( int(status), 6)
+ }
+ call iishdr (command, 1, CURSOR+COMMAND, 0, 0, 0, 0)
+ call iisio (status, 1 * SZB_CHAR)
+ } else {
+ if ( and ( int(status), 6) == 0 )
+ data[2] = IDS_OFF
+ else
+ data[2] = IDS_ON
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/iiswr.x b/pkg/images/tv/iis/iism70/iiswr.x
new file mode 100644
index 00000000..11bb2803
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iiswr.x
@@ -0,0 +1,51 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+
+# IISWR -- Write pixel data to IIS. Writes are packed with full lines only.
+# The data is line-flipped, causing the first line to be displayed at the bottom
+# of the screen.
+
+procedure iiswr (chan, buf, nbytes, offset)
+
+int chan[ARB]
+short buf[ARB]
+int nbytes
+long offset
+
+long off1, off2
+int nchars, thing_count, tid, y1, y2, x
+int or()
+include "iis.com"
+
+begin
+ # Convert to chars and clip at the top of the display.
+ off1 = (offset - 1) / SZB_CHAR + 1
+ off2 = min (IIS_XDIM * IIS_YDIM, (offset + nbytes - 1) / SZB_CHAR) + 1
+ nchars = off2 - off1
+
+ y1 = (off1-1 ) / IIS_XDIM
+ y2 = (off2-1 - IIS_XDIM) / IIS_XDIM
+ y2 = max (y1,y2)
+
+ # Pack only if full lines
+ x = (off1 - 1) - y1 * IIS_XDIM
+ if ( x == 0 )
+ tid = IWRITE+BYPASSIFM+PACKED+BLOCKXFER+BYTE
+ else
+ tid = IWRITE+BYPASSIFM
+
+ # If only a few chars, don't pack (BLOCKXFER needs nchar>=4)
+ if ( nchars < 4 )
+ tid = IWRITE+BYPASSIFM
+
+ thing_count = nchars
+
+ call iishdr (tid, thing_count, REFRESH,
+ or (x, ADVXONTC), or (IIS_YDIM-1-y2, ADVYONXOV), iframe, iplane)
+ if ( tid == IWRITE+BYPASSIFM)
+ call iisio (buf, nbytes)
+ else
+ call iispio (buf, y2 - y1 + 1)
+end
diff --git a/pkg/images/tv/iis/iism70/iiswt.x b/pkg/images/tv/iis/iism70/iiswt.x
new file mode 100644
index 00000000..93f1e04a
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iiswt.x
@@ -0,0 +1,18 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <knet.h>
+include "iis.h"
+
+# IISWT -- Wait for IIS display.
+
+procedure iiswt (chan, nbytes)
+
+int chan[ARB]
+int nbytes
+include "iis.com"
+
+begin
+ call zawtgd (iischan, nbytes)
+ nbytes = nbytes * SZB_CHAR
+end
diff --git a/pkg/images/tv/iis/iism70/iiszoom.x b/pkg/images/tv/iis/iism70/iiszoom.x
new file mode 100644
index 00000000..d703beec
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/iiszoom.x
@@ -0,0 +1,98 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# IISZOOM -- Read and Write zoom magnification and coordinates.
+# the zoom coordinates give the point that should appear in the
+# center of the screen. For the I2S model 70, this requires a
+# scroll. In order for the scroll to be "determinable", we always
+# set the I2S "zoom center" to (IIS_XCEN,IIS_YCEN_INV). The IIS_YCEN_INV
+# results from specifying IIS_YCEN for y center and then having to "invert" y
+# to put GKI(y) = 0 at bottom.
+# This routine implements a command of the form "zoom these frames
+# to the coordinates given, with each triple of data setting a
+# zoom factor and a zoom center for the corresponding frame".
+# If there are excess frames (rel. to "n"), use the last triple.
+
+procedure iiszoom (rw, frames, n, data)
+
+short rw # read or write
+short frames[ARB] # which frames to zoom
+short n # number of data values
+short data[ARB] # the data
+
+int command,x
+int i, total,pl,index
+short zm,temp[4]
+short scroll[2*IDS_MAXIMPL + 1]
+short center[3]
+# magnification, and "zoom center"
+data temp /0,IIS_XCEN,IIS_YCEN_INV, 0/
+# center in GKI x=256 y=255
+data center/ 16384, 16320, 0/
+
+include "iis.com"
+
+begin
+ total = n/3
+
+ if ( rw != IDS_WRITE) {
+ # hardware is write only
+ do i = 1, total {
+ index = (i-1) * 3 + 1
+ pl = frames[i]
+ if ( pl == IDS_EOD)
+ break
+ data[index] = zoom[pl]
+ data[index+1] = xscroll[pl] * MCXSCALE
+ data[index+2] = yscroll[pl] * MCYSCALE
+ }
+ if ( 3*total < n)
+ data[index+3] = IDS_EOD
+ return
+ }
+
+ # can't have in data statements as IDS_EOD == (-2) and
+ # fortran won't allow () in data statements!!!
+
+ temp[4] = IDS_EOD
+ center[3] = IDS_EOD
+ command = IWRITE+VRETRACE
+ x = ADVXONTC
+
+ # the model 70 zooms all frames together. So ignore "frames"
+ # argument here, though needed for subsequent scroll.
+
+ zm = data[1]
+ if ( zm <= 1 )
+ zm = 0
+ else if (zm >= 8)
+ zm = 3
+ else
+ switch(zm) {
+ case 2,3:
+ zm = 1
+
+ case 4,5,6,7:
+ zm = 2
+ }
+ call amovks(short(2**zm), zoom, 16)
+ temp[1] = zm
+ call iishdr (command, 3, ZOOM, x, 0, 0, 0)
+ call iisio (temp, 3 * SZB_CHAR)
+
+ # now we have to scroll to the desired location (in GKI).
+ # If zoom is zero, don't do anything: this will leave the
+ # various images panned to some previously set place, but
+ # that is what is wanted when doing split screen and we pan
+ # some of the images.
+
+ if (zm != 0) {
+ do i = 1, total
+ call amovs (data[i * 3 - 1 ], scroll[i*2-1], 2)
+ scroll[total*2+1] = IDS_EOD
+ call iisscroll(short(IDS_WRITE), frames, short(total*2+1), scroll)
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/mkpkg b/pkg/images/tv/iis/iism70/mkpkg
new file mode 100644
index 00000000..9944d732
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/mkpkg
@@ -0,0 +1,58 @@
+# Makelib file for the image display interface. An image display device is
+# accessed by high level code via the GKI interface.
+
+$checkout libpkg.a ../
+$update libpkg.a
+$checkin libpkg.a ../
+$exit
+
+libpkg.a:
+ idsexpand.x <gki.h> ../lib/ids.h iis.h
+ iisbutton.x <mach.h> iis.h ../lib/ids.h iis.com
+ iiscls.x <mach.h> iis.h iis.com <knet.h>
+ iiscursor.x <mach.h> iis.h ../lib/ids.h iis.com
+ iishdr.x <mach.h> iis.h iis.com
+ iishisto.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisifm.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisio.x <mach.h> iis.h iis.com <knet.h>
+ iislut.x <mach.h> iis.h ../lib/ids.h iis.com
+ iismatch.x <mach.h> iis.h ../lib/ids.h ../lib/ids.com
+ iisminmax.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisoffset.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisofm.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisopn.x <mach.h> iis.h iis.com <knet.h>
+ iispack.x ../lib/ids.h
+ iispio.x <mach.h> iis.h <knet.h> iis.com
+ iisrange.x <mach.h> iis.h ../lib/ids.h iis.com
+ iisrd.x <mach.h> iis.h iis.com
+ iisscroll.x <gki.h> <mach.h> iis.h ../lib/ids.h iis.com
+ iissplit.x <mach.h> iis.h ../lib/ids.h iis.com
+ iistball.x <mach.h> iis.h ../lib/ids.h iis.com
+ iiswr.x <mach.h> iis.h iis.com
+ iiswt.x <mach.h> iis.h iis.com <knet.h>
+ iiszoom.x <mach.h> iis.h ../lib/ids.h iis.com
+ zardim.x iis.h
+ zawrim.x
+ zawtim.x <mach.h> iis.h iis.com
+ zclear.x <mach.h> ../lib/ids.h iis.h
+ zclsim.x
+ zcontrol.x ../lib/ids.h iis.h
+ zcursor_read.x <gki.h> <mach.h> iis.h ../lib/ids.h iis.com
+ zcursor_set.x <gki.h> <mach.h> iis.h ../lib/ids.h iis.com
+ zdisplay_g.x <mach.h> iis.h ../lib/ids.h
+ zdisplay_i.x <mach.h> iis.h ../lib/ids.h ../lib/ids.com iis.com
+ zinit.x <mach.h> iis.h ../lib/ids.h ../lib/ids.com iis.com
+ zopnim.x
+ zreset.x <gki.h> <mach.h> ../lib/ids.h iis.h iis.com
+ zrestore.x <mach.h> ../lib/ids.h iis.h
+ zsave.x <mach.h> ../lib/ids.h iis.h
+ zseek.x <fset.h> <mach.h> ../lib/ids.h iis.h
+
+ zsetup.x <fset.h> <mach.h> ../lib/ids.h iis.h ../lib/ids.com\
+ iis.com
+ zsnap.x <fset.h> <mach.h> iis.h ../lib/ids.h zsnap.com iis.com\
+ ../lib/ids.com
+ zsnapinit.x <fset.h> <mach.h> iis.h ../lib/ids.h zsnap.com iis.com\
+ ../lib/ids.com
+ zsttim.x <knet.h>
+ ;
diff --git a/pkg/images/tv/iis/iism70/zardim.x b/pkg/images/tv/iis/iism70/zardim.x
new file mode 100644
index 00000000..e6811840
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zardim.x
@@ -0,0 +1,16 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "iis.h"
+
+# ZARDIM -- Read data from a binary file display device.
+
+procedure zardim (chan, buf, nbytes, offset)
+
+int chan[ARB]
+short buf[ARB]
+int nbytes
+long offset
+
+begin
+ call iisrd (chan, buf, nbytes, offset)
+end
diff --git a/pkg/images/tv/iis/iism70/zawrim.x b/pkg/images/tv/iis/iism70/zawrim.x
new file mode 100644
index 00000000..7e5fa266
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zawrim.x
@@ -0,0 +1,14 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# ZAWRIM -- Write data to a binary file display device.
+
+procedure zawrim (chan, buf, nbytes, offset)
+
+int chan[ARB]
+short buf[ARB]
+int nbytes
+long offset
+
+begin
+ call iiswr (chan, buf, nbytes, offset)
+end
diff --git a/pkg/images/tv/iis/iism70/zawtim.x b/pkg/images/tv/iis/iism70/zawtim.x
new file mode 100644
index 00000000..ef857bdd
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zawtim.x
@@ -0,0 +1,16 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "iis.h"
+
+# ZAWTIM -- Wait for an image display frame which is addressable as
+# a binary file.
+
+procedure zawtim (chan, nbytes)
+
+int chan[ARB], nbytes
+include "iis.com"
+
+begin
+ call iiswt (chan, nbytes)
+end
diff --git a/pkg/images/tv/iis/iism70/zclear.x b/pkg/images/tv/iis/iism70/zclear.x
new file mode 100644
index 00000000..a03d429c
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zclear.x
@@ -0,0 +1,33 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZCLEAR -- Erase IIS frame.
+
+procedure zclear (frame, bitplane, flag)
+
+short frame[ARB] # frame array
+short bitplane[ARB] # bitplane array
+bool flag # true if image plane
+
+int z, t
+short erase
+int and(), andi()
+short iispack()
+
+begin
+ if (flag) {
+ z = iispack (frame)
+ z = and (z, ALLCHAN)
+ } else
+ z = GRCHAN
+
+ t = iispack (bitplane)
+ erase = andi (ERASE, 177777B)
+
+ call iishdr (IWRITE+BYPASSIFM+BLOCKXFER, 1, FEEDBACK,
+ ADVXONTC, ADVYONXOV, z, t)
+ call iisio (erase, SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/zclsim.x b/pkg/images/tv/iis/iism70/zclsim.x
new file mode 100644
index 00000000..a2bd2029
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zclsim.x
@@ -0,0 +1,13 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# ZCLSIM -- Close an image display frame which is addressable as
+# a binary file.
+
+procedure zclsim (chan, status)
+
+int chan[ARB]
+int status
+
+begin
+ call iiscls (chan, status)
+end
diff --git a/pkg/images/tv/iis/iism70/zcontrol.x b/pkg/images/tv/iis/iism70/zcontrol.x
new file mode 100644
index 00000000..56d8caeb
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zcontrol.x
@@ -0,0 +1,116 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "../lib/ids.h"
+include "iis.h"
+
+# ZCONTROL -- call the device dependent control routines
+
+procedure zcontrol(device, rw, frame, color, offset, n, data)
+
+short device # which device/register to control
+short rw # write/read/wait,read
+short frame[ARB] # array of image frames
+short color[ARB] # array of color
+short offset # generalized offset or datum
+short n # count of items in data array
+short data[ARB] # data array
+
+begin
+ switch(device) {
+ case IDS_FRAME_LUT:
+ call iislut(rw, frame, color, offset, n, data)
+
+ case IDS_GR_MAP:
+ # for now, nothing
+
+ case IDS_INPUT_LUT:
+ call iisifm(rw, offset, n, data)
+
+ case IDS_OUTPUT_LUT:
+ call iisofm(rw, color, offset, n, data)
+
+ case IDS_SPLIT:
+ call iissplit(rw, n, data)
+
+ case IDS_SCROLL:
+ call iisscroll(rw, frame, n, data)
+
+ case IDS_ZOOM:
+ call iiszoom(rw, frame, n, data)
+
+ case IDS_OUT_OFFSET:
+ call iisoffset(rw, color, n, data)
+
+ case IDS_MIN:
+ call iismin(rw, color, n, data)
+
+ case IDS_MAX:
+ call iismax(rw, color, n, data)
+
+ case IDS_RANGE:
+ call iisrange(rw, color, n, data)
+
+ case IDS_HISTOGRAM:
+ call iishisto(rw, color, offset, n, data)
+
+ case IDS_ALU_FCN:
+ # for now, nothing
+
+ case IDS_FEEDBACK:
+ # for now, nothing
+
+ case IDS_SLAVE:
+ # for now, nothing
+
+ case IDS_CURSOR:
+ call iiscursor(rw, offset, n, data)
+
+ case IDS_TBALL:
+ call iistball(rw, data)
+
+ case IDS_DIGITIZER:
+ # for now, nothing
+
+ case IDS_BLINK:
+ # for now, nothing
+
+ case IDS_SNAP:
+ call zsnap_init(data[1])
+
+ case IDS_MATCH:
+ call iismatch (rw, frame, color, n, data)
+ }
+end
+
+
+# MAPCOLOR - modify the color array to map rgb for iis
+
+int procedure mapcolor(color)
+
+short color[ARB] # input data
+
+int i
+int val, result
+int or()
+
+begin
+ result = 0
+ for ( i = 1; color[i] != IDS_EOD ; i = i + 1 ) {
+ val = color[i]
+ switch (val) {
+ case IDS_RED:
+ val = RED
+
+ case IDS_GREEN:
+ val = GREEN
+
+ case IDS_BLUE:
+ val = BLUE
+
+ default:
+ val = 2**(val-1)
+ }
+ result = or (result, val)
+ }
+ return (result)
+end
diff --git a/pkg/images/tv/iis/iism70/zcursor_read.x b/pkg/images/tv/iis/iism70/zcursor_read.x
new file mode 100644
index 00000000..6de5bc8e
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zcursor_read.x
@@ -0,0 +1,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
diff --git a/pkg/images/tv/iis/iism70/zcursor_set.x b/pkg/images/tv/iis/iism70/zcursor_set.x
new file mode 100644
index 00000000..50b1d446
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zcursor_set.x
@@ -0,0 +1,100 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <gki.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZCURSOR_SET -- Write cursor to display. This code assumes the standard
+# cursor which is centered on (31,31).
+
+procedure zcursor_set (cnum, xcur, ycur)
+
+int cnum # cursor number
+int xcur, ycur # GKI x,y cursor position
+
+short cursor[2] # local storage
+real x,y,zm
+int xedge
+int yedge, frame
+int mod()
+define output 10
+
+include "iis.com"
+
+begin
+ # which frame does cursor refer to? ( see zcursor_read() for
+ # more information. )
+
+ if (cnum == IDS_CRAW) {
+ x = real(xcur)/MCXSCALE
+ y = real(ycur)/MCYSCALE
+ zm = 1
+ xedge = 0
+ yedge = 0
+ goto output
+ }
+
+ if (cnum == 0) {
+ frame = i_frame_on
+ if ((frame == ERR) || (frame < 1))
+ return # WHAT SHOULD WE DO?
+ } else
+ frame = mod( cnum-1, IDS_CSET) + 1
+ zm = zoom[frame]
+
+ # Find the left/upper edge of the display
+ # xedge is real as we can't drop the fraction of IIS_XCEN/zm
+ # (This was true when XCEN was 255; now is 256 so can use int
+ # since 256 is a multiple of all possible values of zm.)
+
+ xedge = xscroll[frame] - IIS_XCEN/zm
+ if (xedge < 0)
+ xedge = xedge + IIS_XDIM
+ yedge = ( (IIS_YDIM-1) - yscroll[frame]) - int(IIS_YCEN_INV/zm)
+ if (yedge < 0)
+ yedge = yedge + IIS_YDIM
+
+ # xcur, ycur are in gki. Check if value too big...this will
+ # happen if NDC = 1.0, for instance which should be acceptable
+ # but will be "out of range".
+
+ x = real(xcur)/MCXSCALE
+ if ( x > (IIS_XDIM - 1.0/zm) )
+ x = IIS_XDIM - 1.0/zm
+ y = real(ycur)/MCYSCALE
+ if ( y > (IIS_YDIM - 1.0/zm) )
+ y = IIS_YDIM - 1.0/zm
+
+ # Invert y value to get device orientation; account for
+ # fractional pixels
+
+output
+ y = (IIS_YDIM - 1.0/zm) - y
+
+ # Account for the mod 512 nature of the display
+
+ if (x < xedge)
+ x = x + IIS_XDIM
+ if (y < yedge)
+ y = y + IIS_YDIM
+
+ # Are we still on screen ?
+
+ if ((x >= (xedge + IIS_XDIM/zm)) || (y >= (yedge + IIS_YDIM/zm)) ) {
+ call eprintf("cursor set off screen -- ignored\n")
+ return
+ }
+
+ # Calculate cursor positioning coordinates.
+
+ cursor[1] = int ((x-real(xedge)) * zm ) - 31
+ if ( cursor[1] < 0 )
+ cursor[1] = cursor[1] + IIS_XDIM
+ cursor[2] = int ((y-real(yedge)) * zm ) - 31
+ if ( cursor[2] < 0 )
+ cursor[2] = cursor[2] + IIS_YDIM
+
+ call iishdr (IWRITE+VRETRACE, 2, COMMAND+CURSOR, 1+ADVXONTC, 0,0,0)
+ call iisio (cursor, 2 * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/zdisplay_g.x b/pkg/images/tv/iis/iism70/zdisplay_g.x
new file mode 100644
index 00000000..21cf9e09
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zdisplay_g.x
@@ -0,0 +1,91 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+define INSERT 100000B
+
+# ZDISPLAY_G -- Display the referenced graphics bitplanes in the given color(s)
+
+procedure zdisplay_g (sw, bitpl, color, quad )
+
+short sw # on or off
+short bitpl[ARB] # bitpl list
+short color[ARB] # color list
+short quad[ARB] # quadrants to activate
+
+short gram[LEN_GRAM]
+bool off
+int i, lbound, val
+short mask[7]
+short fill
+# red a bit weak so have contrast with cursor
+#colors of graph: blue grn red yellow rd-bl gn-bl white
+data mask /37B, 1740B, 74000B, 77740B, 74037B, 1777B, 77777B/
+
+begin
+ if ( sw == IDS_OFF )
+ off = true
+ else {
+ off = false
+ }
+
+ # ignore bitpl argument since only one set of them and "color"
+ # fully specifies them.
+ # ignore quad for now
+ # much manipulation of color graphics ram table required!!
+ # strictly speaking, when we turn a plane off, we ought to be
+ # sure that any plane which is on, and "beneath", is turned on;
+ # this is a lot of trouble, so for starters, we don't.
+ # first find out what is on
+
+ call iishdr(IREAD+VRETRACE, LEN_GRAM, GRAPHICS, ADVXONTC, 0, 0, 0)
+ call iisio (gram, LEN_GRAM * SZB_CHAR)
+
+ # Check for red graphics plane for cursor
+
+ if ( gram[LEN_GRAM/2+1] != 176000B )
+ call amovks ( short(176000B), gram[LEN_GRAM/2+1], LEN_GRAM/2)
+
+ for ( i = 1 ; color[i] != IDS_EOD ; i = i + 1 ) {
+ # Bit plane 8 reserved for cursor
+ if ( color[i] > 7 )
+ next
+ # map IDS colors to IIS bit planes -- one-based.
+ switch (color[i]) {
+ case IDS_RED:
+ val = RD
+ case IDS_GREEN:
+ val = GR
+ case IDS_BLUE:
+ val = BLU
+ default:
+ val = color[i]
+ }
+ lbound = 2 ** (val - 1)
+ if ( off )
+ call aclrs ( gram[lbound+1], lbound)
+ else
+ call amovks ( short(INSERT+mask[val]), gram[lbound+1], lbound)
+ }
+ gram[1] = 0
+
+ # If a bit plane is off, reset it with next "lower" one, thus
+ # uncovering any planes masked by the one turned off.
+
+ if (off) {
+ fill = 0
+ do i = 2, LEN_GRAM/2 {
+ if (gram[i] == 0 )
+ gram[i] = fill
+ else
+ fill = gram[i]
+ }
+ }
+
+ # Write out the data
+
+ call iishdr(IWRITE+VRETRACE, LEN_GRAM, GRAPHICS, ADVXONTC, 0, 0, 0)
+ call iisio (gram, LEN_GRAM * SZB_CHAR)
+end
diff --git a/pkg/images/tv/iis/iism70/zdisplay_i.x b/pkg/images/tv/iis/iism70/zdisplay_i.x
new file mode 100644
index 00000000..e08db8c3
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zdisplay_i.x
@@ -0,0 +1,124 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZDISPLAY_I -- Display the referenced image planes in the given color(s)
+# and in the given quadrants of the screen.
+
+procedure zdisplay_i (sw, frames, color, quad)
+
+short sw # on or off
+short frames[ARB] # frame list
+short color[ARB] # color list
+short quad[ARB] # quadrant list
+
+
+bool off
+short channels
+short select[LEN_SELECT]
+int q,c,index, temp
+int mq # mapped quadrant
+int mapquad()
+short iispack()
+int and(), or(), xor()
+
+include "iis.com"
+include "../lib/ids.com" # for i_maxframes! only
+
+begin
+ if ( sw == IDS_ON ) {
+ off = false
+ } else
+ off = true
+
+ # first find out what is on
+ call iishdr(IREAD+VRETRACE, LEN_SELECT, COMMAND+LUT, ADVXONTC, 0,0,0)
+ call iisio (select, LEN_SELECT * SZB_CHAR)
+
+ # then add in/remove frames
+ channels = iispack(frames)
+
+ for ( q = 1 ; quad[q] != IDS_EOD ; q = q + 1 ) {
+ mq = mapquad(quad[q])
+ if ( ! off ) {
+ for ( c =1 ; color[c] != IDS_EOD ; c = c + 1 ) {
+ switch ( color[c] ) {
+ case IDS_RED:
+ index = mq + 8
+
+ case IDS_GREEN:
+ index = mq + 4
+
+ case IDS_BLUE:
+ index = mq
+ }
+ select[index] = or ( int(channels), int(select[index]) )
+ }
+ } else {
+ for ( c =1 ; color[c] != IDS_EOD ; c = c + 1 ) {
+ switch ( color[c] ) {
+ case IDS_RED:
+ index = mq + 8
+
+ case IDS_GREEN:
+ index = mq + 4
+
+ case IDS_BLUE:
+ index = mq
+ }
+ select[index] = and ( xor ( 177777B, int(channels)),
+ int(select[index]))
+ }
+ }
+ }
+
+ # Record which frame is being displayed for cursor readback.
+ temp = 0
+ do q = 1, LEN_SELECT
+ temp = or (temp, int(select[q]))
+
+ if ( temp == 0)
+ i_frame_on = ERR
+ else {
+ do q = 1, i_maxframes {
+ if (and (temp, 2**(q-1)) != 0) {
+ i_frame_on = q
+ break
+ }
+ }
+ }
+ call iishdr(IWRITE+VRETRACE, LEN_SELECT, COMMAND+LUT, ADVXONTC, 0,0,0)
+ call iisio (select, LEN_SELECT * SZB_CHAR)
+end
+
+
+# MAPQUAD -- map user quadrant to device ... returns ONE-based quadrant
+# if prefer ZERO-based, add one to "index" computation above.
+
+int procedure mapquad (quadrant)
+
+short quadrant
+
+int mq
+
+begin
+ switch ( quadrant ) {
+ case 1:
+ mq = 2
+
+ case 2:
+ mq = 1
+
+ case 3:
+ mq = 3
+
+ case 4:
+ mq = 4
+
+ default:
+ mq = 1 # should never happen
+ }
+ return (mq)
+end
diff --git a/pkg/images/tv/iis/iism70/zinit.x b/pkg/images/tv/iis/iism70/zinit.x
new file mode 100644
index 00000000..e03fd57c
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zinit.x
@@ -0,0 +1,45 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZINIT -- initialize for IIS operation
+# in general case, would use nfr and ngr to determine maximum file size
+# which would encompass all the images and graphics planes and all the
+# devices too. Then, file mapped i/o could move most of the device indep.
+# code to the reading and writing routines.
+# not done for IIS
+
+procedure zinit (nfr, ngr, filesize)
+
+short nfr # maximum number of image frames
+short ngr # maximum number of graphics bit planes
+long filesize # returned value
+
+short pl[IDS_MAXIMPL+2]
+short zm[4]
+
+include "../lib/ids.com"
+include "iis.com"
+
+begin
+ i_snap = false
+ # we have no place to store all the zoom and scroll information.
+ # so we initialize to zoom = 1 and scroll = center for all planes
+ pl[1] = IDS_EOD
+ call ids_expand(pl, i_maxframes, true)
+ zm[1] = 1
+ zm[2] = IIS_XCEN * MCXSCALE
+ zm[3] = IIS_YCEN * MCYSCALE
+ zm[4] = IDS_EOD
+ call iiszoom(short(IDS_WRITE), pl, short(4), zm)
+ call iisscroll(short(IDS_WRITE), pl, short(3), zm[2])
+
+ # We also need to set the i_frame_on variable (iis.com), which
+ # we do with a "trick": We call zdisplay_i with quad == EOD;
+ # this is a "nop" for the display code, but will set the variable.
+
+ call zdisplay_i (short(IDS_ON), short(IDS_EOD), short(IDS_EOD),
+ short(IDS_EOD))
+end
diff --git a/pkg/images/tv/iis/iism70/zopnim.x b/pkg/images/tv/iis/iism70/zopnim.x
new file mode 100644
index 00000000..25df2f21
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zopnim.x
@@ -0,0 +1,17 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# ZOPNIM -- Open an image display frame which is addressable as
+# a binary file.
+
+procedure zopnim (devinfo, mode, chan)
+
+char devinfo[ARB] # packed devinfo string
+int mode # access mode
+int chan
+
+int iischan[2] # Kludge
+
+begin
+ call iisopn (devinfo, mode, iischan)
+ chan = iischan[1]
+end
diff --git a/pkg/images/tv/iis/iism70/zreset.x b/pkg/images/tv/iis/iism70/zreset.x
new file mode 100644
index 00000000..3d067d04
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zreset.x
@@ -0,0 +1,164 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <gki.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# cfactor is conversion from integer to NDC coordinates (max 32767) for cursor
+# see iiscursor.x
+# The "hardness" notion is now somewhat obsolete...a range of reset values
+# would be better, especially if better named.
+
+define CFACTOR 528
+
+# ZRESET -- reset IIS
+
+procedure zreset (hardness)
+
+short hardness # soft, medium, hard
+
+short data[LEN_IFM]
+short frames[IDS_MAXIMPL+1]
+short colors[IDS_MAXGCOLOR+1]
+short quad[5]
+int i,j
+
+include "iis.com"
+
+begin
+ if ( hardness == IDS_R_SNAPDONE ) {
+ call zsnap_done
+ return
+ }
+
+ # mark all frames
+ do i = 1,IDS_MAXIMPL
+ frames[i] = i
+ frames[IDS_MAXIMPL+1] = IDS_EOD
+ # mark all colors
+ do i = 1, IDS_MAXGCOLOR
+ colors[i] = i
+ colors[IDS_MAXGCOLOR+1] = IDS_EOD
+ # all quadrants
+ do i = 1,4
+ quad[i] = i
+ quad[5] = IDS_EOD
+
+ if ( hardness == IDS_R_SOFT) {
+ # all coordinates are NDC ( 0 - 32767 )
+ # Reseting the "soft" parameters: scroll, constant offsets,
+ # split point, alu, zoom; turn cursor and tball on.
+
+ # constants
+ call aclrs (data,3)
+ call iisoffset(short(IDS_WRITE), colors, short(3), data)
+
+ # range
+ data[1] = 1
+ call iisrange (short(IDS_WRITE), colors, short(1), data)
+
+ # split point
+ call aclrs ( data, 2)
+ call iissplit(short(IDS_WRITE), short(2), data)
+
+ # alu
+ data[1] = 0
+ call iishdr(IWRITE, 1, ALU+COMMAND, 0, 0, 0, 0)
+ call iisio (data, 1 * SZB_CHAR)
+
+ # graphics status register
+ data[1] = 0
+ call iishdr(IWRITE, 1, GRAPHICS+COMMAND, 0, 0, 0, 0)
+ call iisio (data, 1 * SZB_CHAR)
+
+ # zoom
+ data[1] = 1
+ data[2] = IIS_XCEN * MCXSCALE # gki mid point
+ data[3] = IIS_YCEN * MCYSCALE
+ data[4] = IDS_EOD
+ call iiszoom(short(IDS_WRITE), frames, short(4), data)
+
+ # scroll -- screen center to be centered
+ # zoom does affect scroll if zoom not power==1
+ # so to be safe, do scroll after zoom.
+ data[1] = IIS_XCEN * MCXSCALE
+ data[2] = IIS_YCEN * MCYSCALE
+ data[3] = IDS_EOD
+ call iisscroll(short(IDS_WRITE), frames, short(3), data)
+
+ # cursor and tball; no blink for cursor
+ data[1] = IDS_ON
+ call iiscursor(short(IDS_WRITE), short(1), short(1), data)
+ call iistball (short(IDS_WRITE), data)
+ data[1] = IDS_CBLINK
+ data[2] = IDS_CSTEADY
+ call iiscursor(short(IDS_WRITE), short(1), short(1), data)
+
+ # standard cursor shape
+ data[1] = IDS_CSHAPE
+ j = 2
+ # don't use last line/column so have a real center
+ for ( i = 0 ; i <= 62 ; i = i + 1 ) {
+ # make the puka in the middle
+ if ( (i == 30) || (i == 31) || (i == 32) )
+ next
+ # fill in the lines
+ data[j] = 31 * CFACTOR
+ data[j+1] = i * CFACTOR
+ j = j + 2
+ data[j] = i * CFACTOR
+ data[j+1] = 31 * CFACTOR
+ j = j + 2
+ }
+ data[j] = IDS_EOD
+ call iiscursor ( short(IDS_WRITE), short(1), short(j), data)
+
+ return
+ }
+
+ if ( hardness == IDS_R_MEDIUM) {
+ # reset all tables to linear--ofm, luts, ifm
+ # ofm (0,0) to (0.25,1.0) to (1.0,1.0)
+ data[1] = 0
+ data[2] = 0
+ data[3] = 0.25 * GKI_MAXNDC
+ data[4] = GKI_MAXNDC
+ data[5] = GKI_MAXNDC
+ data[6] = GKI_MAXNDC
+ call iisofm(short(IDS_WRITE), colors, short(1), short(6), data)
+
+ # luts
+ data[1] = 0
+ data[2] = 0
+ data[3] = GKI_MAXNDC
+ data[4] = GKI_MAXNDC
+ call iislut(short(IDS_WRITE), frames, colors, short(1),
+ short(4), data)
+
+ # ifm (0,0) to (1/32, 1.0) to (1.,1.)
+ # ifm is length 8192, but output is only 255. So map linearly for
+ # first 256, then flat. Other possibility is ifm[i] = i-1 ( for
+ # i = 1,8192) which relies on hardware dropping high bits.
+
+ data[1] = 0
+ data[2] = 0
+ data[3] = (1./32.) * GKI_MAXNDC
+ data[4] = GKI_MAXNDC
+ data[5] = GKI_MAXNDC
+ data[6] = GKI_MAXNDC
+ call iisifm(short(IDS_WRITE), short(1), short(6), data)
+
+ return
+ }
+
+ if (hardness == IDS_R_HARD) {
+ # clear all image/graph planes, and set channel selects to
+ # mono
+ call zclear(frames, frames, true)
+ call zclear(frames, frames, false)
+ # reset all to no display
+ call zdisplay_i(short(IDS_OFF), frames, colors, quad)
+ call zdisplay_g(short(IDS_OFF), frames, colors, quad)
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/zrestore.x b/pkg/images/tv/iis/iism70/zrestore.x
new file mode 100644
index 00000000..ed478a20
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zrestore.x
@@ -0,0 +1,30 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# restore device, image, graphics data
+
+procedure zdev_restore(fd)
+
+int fd # file descriptor to read from
+
+begin
+end
+
+procedure zim_restore(fd, frame)
+
+int fd
+short frame[ARB] # frame numbers to restore
+
+begin
+end
+
+procedure zgr_restore(fd, plane)
+
+int fd
+short plane[ARB]
+
+begin
+end
diff --git a/pkg/images/tv/iis/iism70/zsave.x b/pkg/images/tv/iis/iism70/zsave.x
new file mode 100644
index 00000000..666f1b1f
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsave.x
@@ -0,0 +1,30 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# save device, image, graphics data
+
+procedure zdev_save(fd)
+
+int fd # file descriptor to write to
+
+begin
+end
+
+procedure zim_save(fd, frame)
+
+int fd
+short frame[ARB] # frame numbers to save
+
+begin
+end
+
+procedure zgr_save(fd, plane)
+
+int fd
+short plane[ARB]
+
+begin
+end
diff --git a/pkg/images/tv/iis/iism70/zseek.x b/pkg/images/tv/iis/iism70/zseek.x
new file mode 100644
index 00000000..6f3fed25
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zseek.x
@@ -0,0 +1,21 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <fset.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZSEEK -- Seek for an image frame
+
+procedure zseek (fd, x, y)
+
+int fd # file to write
+int x, y # device coordinates
+
+long offset
+
+begin
+ offset = max (1, 1 + (x + y * IIS_XDIM) * SZ_SHORT)
+
+ call seek (fd, offset)
+end
diff --git a/pkg/images/tv/iis/iism70/zsetup.x b/pkg/images/tv/iis/iism70/zsetup.x
new file mode 100644
index 00000000..0803ac3a
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsetup.x
@@ -0,0 +1,34 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <fset.h>
+include "../lib/ids.h"
+include "iis.h"
+
+# ZSETUP -- Setup up common block information for read/write
+
+procedure zsetup (frame, bitpl, flag)
+
+short frame[ARB] # frame information
+short bitpl[ARB] # bitplane information
+bool flag # true if image, false if graphics
+
+short iispack()
+int mapcolor()
+
+include "iis.com"
+include "../lib/ids.com"
+
+begin
+ # If don't flush, then last line of "previous" frame
+ # may get steered to wrong image plane
+ call flush (i_out)
+ call fseti (i_out, F_CANCEL, OK)
+ if ( flag ) {
+ iframe = iispack ( frame )
+ iplane = iispack ( bitpl )
+ } else {
+ iframe = GRCHAN
+ iplane = mapcolor( bitpl )
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/zsnap.com b/pkg/images/tv/iis/iism70/zsnap.com
new file mode 100644
index 00000000..8dd6796c
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsnap.com
@@ -0,0 +1,26 @@
+# snap common block
+int sn_fd # device file descriptor
+int sn_frame, sn_bitpl # save current iframe, iplane
+int zbufsize # fio buffer size--save here
+pointer lutp[3,LEN_IISFRAMES] # look up table storage
+pointer ofmp[3] # rgb ofm tables
+pointer grp[3] # graphics tables
+pointer result[3] # rgb results
+pointer answer # final answer
+pointer input # input data
+pointer zs # zoom/scrolled data; scratch
+pointer grbit_on # graphics bit on
+bool gr_in_use # graphics RAM not all zeroes
+bool on[LEN_IISFRAMES] # if frames on at all
+bool multi_frame # snap using >1 frame
+short range[3] # range and offset for rgb
+short offset[3]
+short left[3,2,LEN_IISFRAMES] # left boundary of line
+short right[3,2,LEN_IISFRAMES] # right boundary of line
+short ysplit # split point for y
+short prev_y # previous line read
+short sn_start, sn_end # color range to snap
+
+common / zsnap / sn_fd, sn_frame, sn_bitpl, zbufsize, lutp, ofmp, grp,
+ result, answer, input, zs, grbit_on, gr_in_use, on, multi_frame,
+ range, offset, left, right, ysplit, prev_y, sn_start, sn_end
diff --git a/pkg/images/tv/iis/iism70/zsnap.x b/pkg/images/tv/iis/iism70/zsnap.x
new file mode 100644
index 00000000..c0f9b230
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsnap.x
@@ -0,0 +1,239 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <fset.h>
+include "iis.h"
+include "../lib/ids.h"
+
+# DO_SNAP -- Return a line of the active image display, as seen
+# by the viewer.
+
+procedure do_snap (buf, nchar, xpos, ypos)
+
+short buf[ARB] # buffer to read into
+int nchar # how many to read
+int xpos, ypos # and from where
+
+int y, yindex, xs, xe
+int line, previous
+int i,j
+int yedge
+int zm, count
+bool first
+
+include "../lib/ids.com"
+include "iis.com"
+include "zsnap.com"
+
+begin
+ # Check if read is for one line only
+
+ if (nchar > IIS_XDIM) {
+ call eprintf("ZSNAP -- too many pixels (%d) requested.\n")
+ call pargi (nchar)
+ call aclrs (buf, nchar)
+ return
+ }
+
+ # Determine x and y coordinates on screen.
+
+ y = IIS_YDIM - 1 - ypos
+ xs = xpos
+ xe = xs + nchar - 1
+ count = nchar
+
+ # See if we are dealing with (a part of only) one line
+
+ if (xe >= IIS_XDIM) {
+ call eprintf("ZSNAP -- line overlap error (xend is %d).\n")
+ call pargi (xe)
+ call aclrs (buf, nchar)
+ return
+ }
+
+ # Determine whether above or below split point.
+
+ if (y < ysplit)
+ yindex = 1
+ else
+ yindex = 2
+
+ # Clear accumulators
+
+ do j = sn_start, sn_end
+ call aclrs (Mems[result[j]], IIS_XDIM)
+
+ # Fetch and massage data for each active frame
+
+ first = true
+ previous = -1 # a bit of safety if no frames on
+ do i = 1, i_maxframes {
+ if (on[i]) {
+ # If frame not active in any color for this half of screen,
+ # ignore it
+ if (sn_start != sn_end) {
+ if ((left[BLU, yindex, i] == -1) &&
+ (left[GR , yindex, i] == -1) &&
+ (left[RD , yindex, i] == -1) )
+ next
+ } else if (left[sn_start, yindex, i] == -1)
+ next
+
+ zm = zoom[i]
+ iplane = 377B # all bit planes
+ iframe = 2**(i-1)
+
+ # y edge of frame (top) [ see zcursor_set for more information]
+ yedge = IIS_YCEN - yscroll[i] + IIS_YCEN_INV - IIS_YCEN_INV/zm
+ if (yedge < 0)
+ yedge = yedge + IIS_YDIM
+
+ # Desired y (screen) coordinate
+ line = yedge + y/zm
+ if (line >= IIS_YDIM)
+ line = line - IIS_YDIM
+ # If have done this line before, just return the same answer
+
+ if (first) {
+ if (line == prev_y) {
+ call amovs (Mems[answer], buf, nchar)
+ return
+ }
+ previous = line
+ first = false
+ }
+
+ # Turn line into file position.
+ line = IIS_YDIM - 1 - line
+ if (multi_frame)
+ call fseti (sn_fd, F_CANCEL, OK)
+ call zseek (sn_fd, xs, line)
+ call read (sn_fd, Mems[input], count)
+ call zmassage (zm, xscroll[i], yindex, i, xs, xe)
+ }
+ }
+
+ # Apply scaling
+
+ do j = sn_start, sn_end {
+ # Note...xs, xe are zero-based indices
+ if ( offset[j] != 0)
+ call aaddks (Mems[result[j]+xs], offset[j],
+ Mems[result[j]+xs], count)
+ if ( range[j] != 1)
+ call adivks (Mems[result[j]+xs], range[j],
+ Mems[result[j]+xs], count)
+ call aluts (Mems[result[j]+xs], Mems[result[j]+xs], count,
+ Mems[ofmp[j]])
+ }
+
+ # Or in the graphics ... use of "select" (asel) depends on design
+ # decision in zdisplay_g.x
+
+ if (gr_in_use) {
+ iframe = GRCHAN
+ iplane = 177B # ignore cursor plane
+ zm = zoom[GRCHNUM]
+
+ yedge = IIS_YCEN - yscroll[GRCHNUM] + IIS_YCEN_INV - IIS_YCEN_INV/zm
+ if (yedge < 0)
+ yedge = yedge + IIS_YDIM
+
+ line = yedge + y/zm
+ if (line >= IIS_YDIM)
+ line = line - IIS_YDIM
+ line = IIS_YDIM - 1 - line
+
+ if (multi_frame)
+ call fseti (sn_fd, F_CANCEL, OK)
+
+ call zseek (sn_fd, xs, line)
+ call read (sn_fd, Mems[input], count)
+ call zmassage (zm, xscroll[GRCHNUM], yindex, GRCHNUM, xs, xe)
+
+ do j = sn_start, sn_end {
+ call aluts (Mems[input+xs], Mems[zs], count, Mems[grp[j]])
+
+ # Build boolean which says if have graphics on
+ call abneks (Mems[zs], short(0), Memi[grbit_on], count)
+
+ # With INSERT on: replace data with graphics.
+ call asels (Mems[zs], Mems[result[j]+xs], Mems[result[j]+xs],
+ Memi[grbit_on], count)
+ }
+ }
+
+ # The answer is:
+
+ if (sn_start != sn_end) {
+ call aadds (Mems[result[BLU]], Mems[result[GR]],
+ Mems[answer], IIS_XDIM)
+ call aadds (Mems[answer], Mems[result[RD]], Mems[answer], IIS_XDIM)
+ call adivks (Mems[answer], short(3), Mems[answer], IIS_XDIM)
+ } else {
+ # Put in "answer" so repeated lines are in known location
+ call amovs (Mems[result[sn_start]], Mems[answer], nchar)
+ }
+
+ # Set the previous line and return the answer
+
+ prev_y = previous
+ call amovs (Mems[answer], buf, nchar)
+end
+
+
+# ZMASSAGE --- do all the boring massaging of the data: zoom, scroll, look
+# up tables.
+
+procedure zmassage (zm, xscr, yi, i, xstart, xend)
+
+int zm # zoom factor
+short xscr # x scroll
+int yi # y-index
+int i # frame index
+int xstart, xend # indices for line start and end
+
+int lb, count # left bound, count of number of items
+int j, x1, x2, itemp
+include "zsnap.com"
+
+begin
+ if ( (xscr != IIS_XCEN) || (zm != 1)) {
+ if (xscr == IIS_XCEN)
+ # Scrolling not needed
+ call amovs (Mems[input], Mems[zs], IIS_XDIM)
+ else {
+ # Scroll the data
+ lb = xscr - IIS_XCEN
+ if ( lb < 0 )
+ lb = lb + IIS_XDIM
+ count = IIS_XDIM - lb
+ call amovs (Mems[input+lb], Mems[zs], count)
+ call amovs (Mems[input], Mems[zs+count], lb)
+ }
+ # Now zoom it
+ if (zm == 1)
+ call amovs (Mems[zs], Mems[input], IIS_XDIM)
+ else
+ call ids_blockit (Mems[zs+IIS_XCEN-IIS_XCEN/zm], Mems[input],
+ IIS_XDIM, real(zm))
+ }
+
+ if (i == GRCHNUM)
+ return
+
+ # With the aligned data, perform the lookup. Note that left is
+ # 0 based, right is (0-based) first excluded value.
+
+ do j = sn_start, sn_end {
+ if (left[j, yi, i] == -1)
+ next
+ itemp = left[j,yi,i]
+ x1 = max (itemp, xstart)
+ itemp = right[j,yi,i]
+ x2 = min (itemp - 1, xend)
+ call aluts (Mems[input+x1], Mems[zs], x2-x1+1, Mems[lutp[j,i]])
+ call aadds (Mems[zs], Mems[result[j]+x1], Mems[result[j]+x1],
+ x2-x1+1)
+ }
+end
diff --git a/pkg/images/tv/iis/iism70/zsnapinit.x b/pkg/images/tv/iis/iism70/zsnapinit.x
new file mode 100644
index 00000000..48ed083c
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsnapinit.x
@@ -0,0 +1,314 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include <fset.h>
+include "iis.h"
+include "../lib/ids.h"
+
+define XSPLIT LEN_SELECT+1
+define YSPLIT LEN_SELECT+2
+
+# ZSNAP_INIT -- initialize snap data structures.
+
+procedure zsnap_init(kind)
+
+short kind
+
+pointer ptr
+short gram[LEN_GRAM]
+short select[LEN_SELECT+2] # include split points
+short color[4]
+short frame[2]
+short cds, off, num
+short xsplit, x_right
+
+int i, j, k, temp
+int khp, val, frame_count
+bool used, mono
+int and(), or(), fstati()
+
+include "zsnap.com"
+include "iis.com"
+include "../lib/ids.com"
+
+begin
+ i_snap = true
+ sn_frame = iframe
+ sn_bitpl = iplane
+ sn_fd = i_out
+ call flush(sn_fd)
+ call fseti(sn_fd, F_CANCEL, OK)
+ prev_y = -1
+
+ # Determine what snap range to do
+ if (kind == IDS_SNAP_MONO)
+ mono= true
+ else
+ mono = false
+
+ switch (kind) {
+ case IDS_SNAP_RGB:
+ # Note: BLU < RD and covers full color range
+ sn_start = BLU
+ sn_end = RD
+
+ case IDS_SNAP_MONO, IDS_SNAP_BLUE:
+ sn_start = BLU
+ sn_end = BLU
+
+ case IDS_SNAP_GREEN:
+ sn_start = GR
+ sn_end = GR
+
+ case IDS_SNAP_RED:
+ sn_start = RD
+ sn_end = RD
+ }
+
+ # Find out which planes are active -- any quadrant
+
+ call iishdr (IREAD, LEN_SELECT+2, COMMAND+LUT, ADVXONTC, 0, 0, 0)
+ call iisio (select, (LEN_SELECT+2)*SZB_CHAR)
+
+ # record split point. Adjust x_split so 511 becomes
+ # 512. This is so the "right" side of a quadrant is given by one
+ # plus the last used point.
+
+ ysplit = select[YSPLIT]
+ xsplit = select[XSPLIT]
+ x_right = xsplit
+ if (x_right == IIS_XDIM-1)
+ x_right = IIS_XDIM
+
+
+ # For certain split positions, some quadrants don't appear at all.
+
+ if (xsplit == 0)
+ call nullquad (0, 2, select)
+ else if (xsplit == IIS_XDIM-1)
+ call nullquad (1, 3, select)
+ if (ysplit == 0)
+ call nullquad (0, 1, select)
+ else if (ysplit == IIS_YDIM-1)
+ call nullquad (2, 3, select)
+
+ # Which frames are active, in any quadrant?
+
+ temp = 0
+ do i = 1, LEN_SELECT
+ temp = or (temp, int(select[i]))
+ do i = 1, i_maxframes {
+ if ( and (temp, 2**(i-1)) != 0)
+ on[i] = true
+ else
+ on[i] = false
+ }
+
+ # Find out where each active plane starts and stops. Split points
+ # are screen coordinates, not picture coordinates. Graphics does
+ # not split (!). left coord is inclusive, right is one beyond end.
+ # left/right dimensions: color, above/below_ysplit, image_plane.
+ # Frame_count counts frames in use. Could be clever and only count
+ # active frames whose pixels are on the screen (pan/zoom effects).
+
+ frame_count = 0
+ do i = 1, i_maxframes {
+ if ( !on[i] )
+ next
+ else
+ frame_count = frame_count + 1
+ do j = sn_start, sn_end { # implicit BLUE (GREEN RED)
+ # quadrants for IIS are UL:0, UR:1, LL:2, LR:3
+ do k = 0, 3 {
+ temp = select[(j-1)*4 + k + 1]
+ used = (and(temp, 2**(i-1)) != 0)
+ khp = k/2 + 1
+ switch (k) {
+ case 0, 2:
+ if (used) {
+ left[j,khp,i] = 0
+ right[j,khp,i] = x_right
+ } else {
+ left[j,khp,i] = -1
+ }
+
+ case 1, 3:
+ if (used) {
+ if ( left[j,khp,i] == -1)
+ left[j,khp,i] = xsplit
+ right[j,khp,i] = IIS_XDIM
+ }
+ } # end switch
+ } # end k ( quad loop)
+ } # end j ( color loop)
+ } # end i ( frame loop)
+
+ # now do range and offset
+
+ cds = IDS_READ
+ num = 3
+ color[1] = IDS_BLUE
+ color[2] = IDS_GREEN
+ color[3] = IDS_RED
+ color[4] = IDS_EOD
+ call iisrange(cds, color, num, range)
+ call iisoffset(cds, color, num, offset)
+ do i = sn_start, sn_end
+ range[i] = 2**range[i]
+
+ # now allocate memory for all the various tables
+
+ call malloc (input, IIS_XDIM, TY_SHORT)
+ call malloc (answer, IIS_XDIM, TY_SHORT)
+ call malloc (zs, IIS_XDIM, TY_SHORT)
+ # for each color:
+ do j = sn_start, sn_end {
+ call malloc (result[j], IIS_XDIM, TY_SHORT)
+ call malloc (ofmp[j], LEN_OFM, TY_SHORT)
+ call malloc (grp[j], LEN_GRAM/2, TY_SHORT)
+ do i = 1, i_maxframes {
+ if ( on[i] )
+ call malloc (lutp[j,i], LEN_LUT, TY_SHORT)
+ }
+ }
+ call malloc (grbit_on, IIS_XDIM, TY_INT)
+
+ # fill these up
+
+ cds = IDS_READ
+ off = 1
+ frame[2] = IDS_EOD
+ color[2] = IDS_EOD
+ do j = sn_start, sn_end {
+ if (j == BLU)
+ color[1] = IDS_BLUE
+ else if ( j == GR)
+ color[1] = IDS_GREEN
+ else
+ color[1] = IDS_RED
+ num = LEN_OFM
+ call iisofm (cds, color, off, num, Mems[ofmp[j]])
+ do i = 1, i_maxframes {
+ if (on[i]) {
+ frame[1] = i
+ num = LEN_LUT
+ call iislut (cds, frame, color, off, num, Mems[lutp[j,i]])
+ }
+ }
+ }
+
+ # the graphics planes ... assume insert mode!!
+ # Note if any graphics mapping ram is in use...if no graphics on,
+ # snap can run faster.
+
+ call iishdr (IREAD, LEN_GRAM, GRAPHICS, ADVXONTC, 0, 0, 0)
+ call iisio (gram, LEN_GRAM * SZB_CHAR)
+
+ gr_in_use = false
+ do j = sn_start, sn_end
+ call aclrs(Mems[grp[j]], LEN_GRAM/2)
+ # Leave first one 0; don't mess with cursor plane
+ do i = 2, LEN_GRAM/2 {
+ temp = and (77777B, int(gram[i]))
+ if (temp != 0)
+ gr_in_use = true
+ if (! mono) {
+ do j = sn_start, sn_end
+ switch (j) {
+ case RD:
+ Mems[grp[RD]+i-1] = and (temp,76000B)/32
+ case GR:
+ Mems[grp[GR]+i-1] = and (temp, 1740B)
+ case BLU:
+ Mems[grp[BLU]+i-1] = and (temp, 37B)*32
+ }
+ } else {
+ # All graphics planes
+ val = or ( and (temp, 76000B)/32, and (temp, 1740B))
+ val = or ( and (temp, 37B)*32, val)
+ Mems[grp[sn_start]+i-1] = val
+ }
+ }
+
+ if (gr_in_use)
+ frame_count = frame_count + 1
+ if (frame_count > 1) {
+ multi_frame = true
+ # set buffer to size of one line
+ zbufsize = fstati (sn_fd, F_BUFSIZE)
+ call fseti (sn_fd, F_BUFSIZE, IIS_XDIM)
+ } else
+ multi_frame = false
+
+ # Now adjust look up tables for fact that they do 9 bit 2's complement
+ # arithmetic!
+ do j = sn_start, sn_end {
+ do i = 1, i_maxframes {
+ if (on[i]) {
+ ptr = lutp[j,i]
+ do k = 1, LEN_LUT {
+ if (Mems[ptr+k-1] > 255 )
+ Mems[ptr+k-1] = Mems[ptr+k-1] - 512
+ }
+ }
+ }
+ }
+end
+
+
+# NULLQUAD -- zero out lut mapping for quadrants that cannot appear on
+# screen
+
+procedure nullquad (q, p, sel)
+
+int q, p # two quadrants to eliminate, zero based
+short sel[ARB] # the mapping array
+
+int i
+
+begin
+ do i = 0,2 {
+ sel[i*4 + q + 1] = 0
+ sel[i*4 + p + 1] = 0
+ }
+end
+
+
+# ZSNAP_DONE -- reset paramters
+
+procedure zsnap_done()
+
+int i,j
+
+include "iis.com"
+include "zsnap.com"
+include "../lib/ids.com"
+
+begin
+ if ( ! i_snap )
+ return
+ i_snap = false
+ call fseti(sn_fd, F_CANCEL, OK)
+ if (multi_frame) {
+ # restore buffering
+ call fseti (sn_fd, F_BUFSIZE, zbufsize)
+ }
+ iframe = sn_frame
+ iplane = sn_bitpl
+
+ # release storage
+ call mfree (grbit_on, TY_INT)
+ do j = sn_start, sn_end {
+ call mfree (result[j], TY_SHORT)
+ call mfree (ofmp[j], TY_SHORT)
+ call mfree (grp[j], TY_SHORT)
+ do i = 1, i_maxframes {
+ if ( on[i] )
+ call mfree (lutp[j,i], TY_SHORT)
+ }
+ }
+
+ call mfree (zs, TY_SHORT)
+ call mfree (answer, TY_SHORT)
+ call mfree (input, TY_SHORT)
+end
diff --git a/pkg/images/tv/iis/iism70/zsttim.x b/pkg/images/tv/iis/iism70/zsttim.x
new file mode 100644
index 00000000..2f441ed7
--- /dev/null
+++ b/pkg/images/tv/iis/iism70/zsttim.x
@@ -0,0 +1,14 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <knet.h>
+
+# ZSTTIM -- Return status on binary file display device.
+
+procedure zsttim (chan, what, lvalue)
+
+int chan[ARB], what
+long lvalue
+
+begin
+ call zsttgd (chan, what, lvalue)
+end