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

include	<ctotok.h>
include	<ctype.h>
include	"../lib/ids.h"

# OFFSET -- Change the bias (offset) for certain colors

procedure offset()

int	tok, i, nchar, ip
char	token[SZ_LINE]
short	color[IDS_MAXGCOLOR+1]
short	offsetdata[4]			# extra space for cvmove EOD
int	count, ctoi()

include "cv.com"

begin
	# In principle, we should be able to accept input for color group
	# followed by offset value(s) or "vice versa" or for a series of
	# color/offset pairs.  We try for most of that.
	color[1] = ERR
	offsetdata[1] = ERR
	count = 1
	# anything but TOK_NEWLINE
	tok = TOK_NUMBER
	repeat {
	    if (tok == TOK_NEWLINE) {
		call eprintf ("Insufficient offset specification\n")
		return
	    }
	    call gargtok (tok, token, SZ_LINE)
	    call strlwr (token)
	    if (token[1] == 'c') {
		call cv_color (token[2], color)
		if (color[1] == ERR)
		    return
	    } else if (tok == TOK_NUMBER) {
		ip = 1
		nchar = ctoi (token, ip, i)
		if ( count <= 3) {
		    offsetdata[count] = i
		    count = count + 1
		}
	    }
	} until ( (color[1] != ERR) && (offsetdata[1] != ERR) &&
		  (tok == TOK_NEWLINE) )

	offsetdata[count] = IDS_EOD		# mark end

	call cvoffset (color, offsetdata)
end