aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/ncarutil/sysint/gbytes.x
blob: b129ffbcb02c9631a16449d521a4c411b0e73640 (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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# GBYTES -- Locally implemented bit unpacker for the NCAR extended metacode
# translator.   3 may 84 cliff stoll
# Required for the ncar/gks vdi metacode generator.
#
# Essentially this routine accepts an array which is a packed series of bits. 
# [array BUFIN], and unpacks them into an array [array BUFOUT].  Received
# integer INDEX is the beginning bit in BUFIN  where information is to be 
# placed.  INDEX is zero indexed.  Received integer argument SIZE is the 
# number of bits in each "information packet".  Received argument SKIP is the 
# number of bits to skip between bit packets.  For more info, see page 4 of 
# the NCAR "Implementaton details for the new metafile translator, version 1.0"

procedure gbytes (bufin, bufout, index, size, skip, count)

int	bufout[ARB], bufin[ARB], index, size, skip, count
int	pack
int	offset
int	bitupk()	# Iraf function to unpack bits

begin
	for (pack = 1; pack <= count ; pack = pack+1) {
	    # Offset is a bit offset into the input buffer bufin.
	    # (offset is 1- indexed; INDEX is zero indexed)

	    offset = (size + skip) * (pack - 1) + index + 1
	    bufout(pack) = bitupk(bufin, offset, size)
	}
end