aboutsummaryrefslogtreecommitdiff
path: root/pkg/images/tv/tvmark
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /pkg/images/tv/tvmark
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/images/tv/tvmark')
-rw-r--r--pkg/images/tv/tvmark/asciilook.inc19
-rw-r--r--pkg/images/tv/tvmark/mkbmark.x561
-rw-r--r--pkg/images/tv/tvmark/mkcolon.x394
-rw-r--r--pkg/images/tv/tvmark/mkfind.x52
-rw-r--r--pkg/images/tv/tvmark/mkgmarks.x214
-rw-r--r--pkg/images/tv/tvmark/mkgpars.x65
-rw-r--r--pkg/images/tv/tvmark/mkgscur.x87
-rw-r--r--pkg/images/tv/tvmark/mkmag.x20
-rw-r--r--pkg/images/tv/tvmark/mkmark.x482
-rw-r--r--pkg/images/tv/tvmark/mknew.x42
-rw-r--r--pkg/images/tv/tvmark/mkonemark.x392
-rw-r--r--pkg/images/tv/tvmark/mkoutname.x273
-rw-r--r--pkg/images/tv/tvmark/mkpkg27
-rw-r--r--pkg/images/tv/tvmark/mkppars.x40
-rw-r--r--pkg/images/tv/tvmark/mkremove.x98
-rw-r--r--pkg/images/tv/tvmark/mkshow.x95
-rw-r--r--pkg/images/tv/tvmark/mktext.x164
-rw-r--r--pkg/images/tv/tvmark/mktools.x505
-rw-r--r--pkg/images/tv/tvmark/pixelfont.inc519
-rw-r--r--pkg/images/tv/tvmark/t_tvmark.x267
-rw-r--r--pkg/images/tv/tvmark/tvmark.h165
21 files changed, 4481 insertions, 0 deletions
diff --git a/pkg/images/tv/tvmark/asciilook.inc b/pkg/images/tv/tvmark/asciilook.inc
new file mode 100644
index 00000000..68974d34
--- /dev/null
+++ b/pkg/images/tv/tvmark/asciilook.inc
@@ -0,0 +1,19 @@
+data (asciilook[i], i=1,7) / 449, 449, 449, 449, 449, 449, 449 /
+data (asciilook[i], i=8,14) / 449, 449, 449, 449, 449, 449, 449 /
+data (asciilook[i], i=15,21) / 449, 449, 449, 449, 449, 449, 449 /
+data (asciilook[i], i=22,28) / 449, 449, 449, 449, 449, 449, 449 /
+data (asciilook[i], i=29,35) / 449, 449, 449, 449, 001, 008, 015 /
+data (asciilook[i], i=36,42) / 022, 029, 036, 043, 050, 057, 064 /
+data (asciilook[i], i=43,49) / 071, 078, 085, 092, 099, 106, 113 /
+data (asciilook[i], i=50,56) / 120, 127, 134, 141, 148, 155, 162 /
+data (asciilook[i], i=57,63) / 169, 176, 183, 190, 197, 204, 211 /
+data (asciilook[i], i=64,70) / 218, 225, 232, 239, 246, 253, 260 /
+data (asciilook[i], i=71,77) / 267, 274, 281, 288, 295, 302, 309 /
+data (asciilook[i], i=78,84) / 316, 323, 330, 337, 344, 351, 358 /
+data (asciilook[i], i=85,91) / 365, 372, 379, 386, 393, 400, 407 /
+data (asciilook[i], i=92,98) / 414, 421, 428, 435, 442, 449, 232 /
+data (asciilook[i], i=99,105) / 239, 246, 253, 260, 267, 274, 281 /
+data (asciilook[i], i=106,112) / 288, 295, 302, 309, 316, 323, 330 /
+data (asciilook[i], i=113,119) / 337, 344, 351, 358, 365, 372, 379 /
+data (asciilook[i], i=120,126) / 386, 393, 400, 407, 449, 449, 449 /
+data (asciilook[i], i=127,128) / 449, 449/
diff --git a/pkg/images/tv/tvmark/mkbmark.x b/pkg/images/tv/tvmark/mkbmark.x
new file mode 100644
index 00000000..5ece5d4a
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkbmark.x
@@ -0,0 +1,561 @@
+include <imhdr.h>
+include "tvmark.h"
+
+# MK_BMARK -- Procedure to mark symbols in the frame buffer given a coordinate
+# list and a mark type.
+
+procedure mk_bmark (mk, im, iw, cl, ltid, fnt)
+
+pointer mk # pointer to the mark structure
+pointer im # frame image descriptor
+pointer iw # pointer to the wcs structure
+int cl # coordinate file descriptor
+int ltid # current number in the list
+int fnt # font file descriptor
+
+int ncols, nlines, nr, nc, x1, x2, y1, y2
+pointer sp, str, lengths, radii, label
+real x, y, fx, fy, ofx, ofy, xmag, ymag, lmax, lratio, rmax, ratio
+int fscan(), nscan(), mk_stati(), itoc()
+int mk_plimits(), mk_llimits(), mk_rlimits(), mk_climits()
+pointer mk_statp()
+real mk_statr()
+
+begin
+ call smark (sp)
+ call salloc (str, SZ_LINE, TY_CHAR)
+ call salloc (label, SZ_LINE, TY_CHAR)
+
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ # Get the magnification factors.
+ call mk_mag (im, iw, xmag, ymag)
+
+ # Define the rectangles in terms of device coordinates.
+ if (mk_stati (mk, MKTYPE) == MK_RECTANGLE) {
+ nr = mk_stati (mk, NRECTANGLES)
+ call salloc (lengths, nr, TY_REAL)
+ if (xmag <= 0.0) {
+ lmax = 0.0
+ call amovkr (0.0, Memr[lengths], nr)
+ } else {
+ call adivkr (Memr[mk_statp(mk,RLENGTHS)], xmag, Memr[lengths],
+ nr)
+ lmax = Memr[lengths+nr-1]
+ }
+ if (ymag <= 0.)
+ lratio = 0.0
+ else
+ lratio = mk_statr (mk, RATIO) * xmag / ymag
+ }
+
+ # Define the circles in terms of device coordinates.
+ if (mk_stati (mk, MKTYPE) == MK_CIRCLE) {
+ nc = mk_stati (mk, NCIRCLES)
+ call salloc (radii, nc, TY_REAL)
+ if (xmag <= 0) {
+ rmax = 0.0
+ call amovkr (0.0, Memr[radii], nc)
+ } else {
+ call adivkr (Memr[mk_statp(mk,RADII)], xmag, Memr[radii], nc)
+ rmax = Memr[radii+nc-1]
+ }
+ if (ymag <= 0.0)
+ ratio = 0.0
+ else
+ ratio = xmag / ymag
+ }
+
+ # Run through the coordinate list sequentially plotting the
+ # points, circles or rectangles. Speed it up later by reading
+ # all the points in first, sorting and accessing the frame
+ # buffer sequentially instead of randomly.
+
+ ofx = INDEFR
+ ofy = INDEFR
+ while (fscan (cl) != EOF) {
+
+ # Get the x and y coords (possibly add an id number later).
+ call gargr (x)
+ call gargr (y)
+ if (nscan() < 2)
+ next
+ if (IS_INDEFR(x) || IS_INDEFR(y))
+ next
+ call gargwrd (Memc[label], SZ_LINE)
+ call iw_im2fb (iw, x, y, fx, fy)
+
+ switch (mk_stati (mk, MKTYPE)) {
+
+ case MK_POINT:
+ if (mk_plimits (fx, fy, mk_stati (mk, SZPOINT),
+ ncols, nlines, x1, x2, y1, y2) == YES)
+ call mk_drawpt (im, x1, x2, y1, y2, mk_stati (mk,
+ GRAYLEVEL))
+
+ case MK_LINE:
+ if (! IS_INDEFR(ofx) && ! IS_INDEFR(ofy)) {
+ if (mk_llimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2,
+ y1, y2) == YES)
+ call mk_drawline (im, ofx, ofy, fx, fy, x1, x2, y1, y2,
+ mk_stati (mk, GRAYLEVEL))
+ }
+
+ case MK_RECTANGLE:
+ if (mk_rlimits (fx, fy, lmax, lratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawbox (im, fx, fy, x1, x2, y1, y2, Memr[lengths],
+ lratio, nr, mk_stati (mk, GRAYLEVEL))
+ }
+
+ case MK_CIRCLE:
+ if (mk_climits (fx, fy, rmax, ratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawcircles (im, fx, fy, x1, x2, y1, y2,
+ Memr[radii], ratio, nc, mk_stati (mk,
+ GRAYLEVEL))
+ call imflush (im)
+ }
+
+ case MK_PLUS:
+ call mk_textim (im, "+", nint (fx), nint (fy), mk_stati (mk,
+ SIZE), mk_stati (mk, SIZE), mk_stati (mk, GRAYLEVEL), YES)
+ call imflush (im)
+
+ case MK_CROSS:
+ call mk_textim (im, "x", nint (fx), nint (fy), mk_stati (mk,
+ SIZE), mk_stati (mk, SIZE), mk_stati (mk, GRAYLEVEL), YES)
+ call imflush (im)
+
+ default:
+ }
+
+ # Number the text file.
+ ltid = ltid + 1
+ if (mk_stati (mk, LABEL) == YES) {
+ if (Memc[label] != EOS) {
+ call mk_textim (im, Memc[label], nint (fx) +
+ mk_stati(mk, NXOFFSET), nint (fy) + mk_stati (mk,
+ NYOFFSET), mk_stati (mk, SIZE), mk_stati (mk, SIZE),
+ mk_stati (mk, GRAYLEVEL), NO)
+ call imflush (im)
+ }
+ } else if (mk_stati (mk, NUMBER) == YES) {
+ if (itoc (ltid, Memc[str], SZ_FNAME) > 0) {
+ call mk_textim (im, Memc[str], nint (fx) +
+ mk_stati(mk, NXOFFSET), nint (fy) + mk_stati (mk,
+ NYOFFSET), mk_stati (mk, SIZE), mk_stati (mk, SIZE),
+ mk_stati (mk, GRAYLEVEL), NO)
+ call imflush (im)
+ }
+ }
+
+ ofx = fx
+ ofy = fy
+ }
+
+ call imflush (im)
+ call sfree (sp)
+end
+
+
+# MK_DRAWPT -- Procedure to draw a point into the frame buffer.
+
+procedure mk_drawpt (im, x1, x2, y1, y2, graylevel)
+
+pointer im # pointer to the frame image
+int x1, x2 # column limits
+int y1, y2 # line limits
+int graylevel # color of dot to be marked
+
+int i, npix
+pointer vp
+pointer imps2s()
+
+begin
+ npix = (x2 - x1 + 1) * (y2 - y1 + 1)
+ vp = imps2s (im, x1, x2, y1, y2)
+ do i = 1, npix
+ Mems[vp+i-1] = graylevel
+end
+
+
+# MK_PLIMITS -- Compute the extent of a dot.
+
+int procedure mk_plimits (fx, fy, szdot, ncols, nlines, x1, x2, y1, y2)
+
+real fx, fy # frame buffer coordinates of point
+int szdot # size of a dot
+int ncols, nlines # dimensions of the frame buffer
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+begin
+ x1 = nint (fx) - szdot
+ x2 = x1 + 2 * szdot
+ if (x1 > ncols || x2 < 1)
+ return (NO)
+ x1 = max (1, min (ncols, x1))
+ x2 = min (ncols, max (1, x2))
+
+ y1 = nint (fy) - szdot
+ y2 = y1 + 2 * szdot
+ if (y1 > nlines || y2 < 1)
+ return (NO)
+ y1 = max (1, min (nlines, y1))
+ y2 = min (nlines, max (1, y2))
+
+ return (YES)
+end
+
+
+# MK_DRAWLINE -- Procedure to draw lines.
+
+procedure mk_drawline (im, ofx, ofy, fx, fy, x1, x2, y1, y2, graylevel)
+
+pointer im # pointer to the frame buffer image
+real ofx, ofy # previous coordinates
+real fx, fy # current coordinates
+int x1, x2 # column limits
+int y1, y2 # line limits
+int graylevel # picture gray level
+
+int i, j, ix1, ix2, npix, itemp
+pointer vp
+real m, b
+pointer imps2s()
+
+begin
+ # Compute the slope and intercept.
+ if (x2 == x1) {
+ vp = imps2s (im, x1, x2, y1, y2)
+ npix = y2 - y1 + 1
+ do i = 1, npix
+ Mems[vp+i-1] = graylevel
+ } else if (y2 == y1) {
+ vp = imps2s (im, x1, x2, y1, y2)
+ npix = x2 - x1 + 1
+ do i = 1, npix
+ Mems[vp+i-1] = graylevel
+ } else {
+ m = (fy - ofy ) / (fx - ofx)
+ b = ofy - m * ofx
+ #if (m > 0.0)
+ #b = y1 - m * x1
+ #else
+ #b = y2 - m * x1
+ do i = y1, y2 {
+ if (i == y1) {
+ ix1 = nint ((i - b) / m)
+ ix2 = nint ((i + 0.5 - b) / m)
+ } else if (i == y2) {
+ ix1 = nint ((i - 0.5 - b) / m)
+ ix2 = nint ((i - b) / m)
+ } else {
+ ix1 = nint ((i - 0.5 - b) / m)
+ ix2 = nint ((i + 0.5 - b) / m)
+ }
+ itemp = min (ix1, ix2)
+ ix2 = max (ix1, ix2)
+ ix1 = itemp
+ if (ix1 < x1 || ix2 > x2)
+ next
+ vp = imps2s (im, ix1, ix2, i, i)
+ npix = ix2 - ix1 + 1
+ do j = 1, npix
+ Mems[vp+j-1] = graylevel
+ }
+ }
+end
+
+
+# MK_LLIMITS -- Compute the limits of a line segment.
+
+int procedure mk_llimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2, y1, y2)
+
+real ofx, ofy # previous coordinates
+real fx, fy # current coordinates
+int ncols, nlines # number of lines
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+begin
+ x1 = nint (min (ofx, fx))
+ x2 = nint (max (ofx, fx))
+ if (x2 < 1 || x1 > ncols)
+ return (NO)
+ x1 = max (1, min (ncols, x1))
+ x2 = min (ncols, max (1, x2))
+
+ y1 = nint (min (ofy, fy))
+ y2 = nint (max (ofy, fy))
+ if (y2 < 1 || y1 > nlines)
+ return (NO)
+ y1 = max (1, min (nlines, y1))
+ y2 = min (nlines, max (1, y2))
+
+ return (YES)
+end
+
+
+# MK_DRAWCIRCLES -- Draw concentric circles around a point.
+
+procedure mk_drawcircles (im, fx, fy, x1, x2, y1, y2, cradii, ratio, ncircles,
+ graylevel)
+
+pointer im # pointer to frame buffer image
+real fx, fy # center of circle
+int x1, x2 # column limits
+int y1, y2 # line limits
+real cradii[ARB] # sorted list of radii
+real ratio # ratio of the magnifications
+int ncircles # number of circles
+int graylevel # gray level for marking
+
+int i, j, k, ix1, ix2, npix
+pointer ovp
+real dy2, dym, dyp, r2, dx1, dx2
+pointer imps2s()
+
+begin
+ if (ratio <= 0)
+ return
+
+ npix = x2 - x1 + 1
+
+ do i = y1, y2 {
+
+ dy2 = (i - fy) ** 2
+ if (i >= fy) {
+ dym = ((i - .5 - fy) / ratio) ** 2
+ dyp = ((i + .5 - fy) / ratio) ** 2
+ } else {
+ dyp = ((i - .5 - fy) / ratio) ** 2
+ dym = ((i + .5 - fy) / ratio) ** 2
+ }
+
+ do j = 1, ncircles {
+
+ r2 = cradii[j] ** 2
+ if (r2 < dym )
+ next
+
+ dx1 = r2 - dym
+ if (dx1 >= 0.0)
+ dx1 = sqrt (dx1)
+ else
+ dx1 = 0.0
+ dx2 = r2 - dyp
+ if (dx2 >= 0.0)
+ dx2 = sqrt (dx2)
+ else
+ dx2 = 0.0
+
+ ix1 = nint (fx - dx1)
+ ix2 = nint (fx - dx2)
+ if (ix1 <= IM_LEN(im,1) && ix2 >= 1) {
+ ix1 = max (1, ix1)
+ ix2 = min (ix2, IM_LEN(im,1))
+ ovp = imps2s (im, ix1, ix2, i, i)
+ do k = 1, ix2 - ix1 + 1
+ Mems[ovp+k-1] = graylevel
+ }
+
+ ix1 = nint (fx + dx1)
+ ix2 = nint (fx + dx2)
+ if (ix2 <= IM_LEN(im,1) && ix1 >= 1) {
+ ix2 = max (1, ix2)
+ ix1 = min (ix1, IM_LEN(im,1))
+ ovp = imps2s (im, ix2, ix1, i, i)
+ do k = 1, ix2 - ix1 + 1
+ Mems[ovp+k-1] = graylevel
+ }
+ }
+ }
+
+end
+
+
+# MK_CLIMITS -- Compute the extent of a circle.
+
+int procedure mk_climits (fx, fy, rmax, ratio, ncols, nlines, x1, x2, y1, y2)
+
+real fx, fy # center of rectangle
+real rmax # maximum half length of box
+real ratio # ratio of the magnifications
+int ncols, nlines # dimension of the image
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+begin
+ x1 = nint (fx - rmax)
+ x2 = nint (fx + rmax)
+ if (x1 > ncols || x2 < 1)
+ return (NO)
+ x1 = max (1, min (ncols, x1))
+ x2 = min (ncols, max (1, x2))
+
+ y1 = nint (fy - rmax * ratio)
+ y2 = nint (fy + rmax * ratio)
+ if (y1 > nlines || y2 < 1)
+ return (NO)
+ y1 = max (1, min (nlines, y1))
+ y2 = min (nlines, max (1, y2))
+
+ return (YES)
+end
+
+
+# MK_DRAWBOX -- Procedure to draw a box into the frame buffer.
+
+procedure mk_drawbox (im, fx, fy, x1, x2, y1, y2, length, ratio, nbox,
+ graylevel)
+
+pointer im # pointer to frame buffer image
+real fx, fy # center of rectangle
+int x1, x2 # column limits
+int y1, y2 # line limits
+real length[ARB] # list of rectangle lengths
+real ratio # ratio of width/length
+int nbox # number of boxes
+int graylevel # value of graylevel
+
+int i, j, k, npix, ydist, bdist, ix1, ix2
+pointer ovp
+real hlength
+pointer imps2s()
+
+begin
+ if (x1 == x2) {
+ ovp = imps2s (im, x1, x2, y1, y2)
+ npix = y2 - y1 + 1
+ do i = 1, npix
+ Mems[ovp+i-1] = graylevel
+ } else if (y1 == y2) {
+ ovp = imps2s (im, x1, x2, y1, y2)
+ npix = x2 - x1 + 1
+ do i = 1, npix
+ Mems[ovp+i-1] = graylevel
+ } else {
+ npix = x2 - x1 + 1
+ do i = y1, y2 {
+ ydist = nint (abs (i - fy))
+ do j = 1, nbox {
+ hlength = length[j] / 2.0
+ bdist = nint (hlength * ratio)
+ if (ydist > bdist)
+ next
+ ix1 = max (x1, nint (fx - hlength))
+ ix2 = min (x2, nint (fx + hlength))
+ if (ix1 < 1 || ix1 > IM_LEN(im,1) || ix2 < 1 ||
+ ix2 > IM_LEN(im,1))
+ next
+ if (ydist == bdist) {
+ ovp = imps2s (im, ix1, ix2, i, i)
+ do k = 1, ix2 - ix1 + 1
+ Mems[ovp+k-1] = graylevel
+ } else {
+ ovp = imps2s (im, ix1, ix1, i, i)
+ Mems[ovp] = graylevel
+ ovp = imps2s (im, ix2, ix2, i, i)
+ Mems[ovp] = graylevel
+ }
+ }
+ }
+ }
+end
+
+
+# MK_RLIMITS -- Compute the extent of a rectangle.
+
+int procedure mk_rlimits (fx, fy, lmax, lratio, ncols, nlines, x1, x2, y1, y2)
+
+real fx, fy # center of rectangle
+real lmax # maximum half length of box
+real lratio # ratio of width to length
+int ncols, nlines # dimension of the image
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+real hlmax, wmax
+
+begin
+ hlmax = lmax / 2.0
+ wmax = lmax * lratio
+
+ x1 = nint (fx - hlmax)
+ x2 = nint (fx + hlmax)
+ if (x1 > ncols || x2 < 1)
+ return (NO)
+ x1 = max (1, min (ncols, x1))
+ x2 = min (ncols, max (1, x2))
+
+ y1 = fy - wmax
+ y2 = fy + wmax
+ if (y1 > nlines || y2 < 1)
+ return (NO)
+ y1 = max (1, min (nlines, y1))
+ y2 = min (nlines, max (1, y2))
+
+ return (YES)
+end
+
+
+# MK_PBOX -- Plot a box
+
+procedure mk_pbox (im, x1, x2, y1, y2, graylevel)
+
+pointer im # pointer to the image
+int x1, x2 # column limits
+int y1, y2 # line limits
+int graylevel # line value
+
+int i, j, npix
+pointer ovp
+pointer imps2s()
+
+begin
+ do i = y1, y2 {
+ if (i == y1) {
+ npix = x2 - x1 + 1
+ ovp = imps2s (im, x1, x2, i, i)
+ do j = 1, npix
+ Mems[ovp+j-1] = graylevel
+ } else if (i == y2) {
+ npix = x2 - x1 + 1
+ ovp = imps2s (im, x1, x2, i, i)
+ do j = 1, npix
+ Mems[ovp+j-1] = graylevel
+ } else {
+ ovp = imps2s (im, x1, x1, i, i)
+ Mems[ovp] = graylevel
+ ovp = imps2s (im, x2, x2, i, i)
+ Mems[ovp] = graylevel
+ }
+ }
+end
+
+
+# MK_BLIMITS -- Procedure to compute the boundary limits for drawing
+# a box.
+
+procedure mk_blimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2, y1, y2)
+
+real ofx, ofy # first point
+real fx, fy # second point
+int ncols, nlines # dimensions of the image
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+begin
+ x1 = nint (min (ofx, fx))
+ x1 = max (1, min (x1, ncols))
+ x2 = nint (max (ofx, fx))
+ x2 = min (ncols, max (x2, 1))
+
+ y1 = nint (min (ofy, fy))
+ y1 = max (1, min (y1, nlines))
+ y2 = nint (max (ofy, fy))
+ y2 = min (nlines, max (y2, 1))
+end
diff --git a/pkg/images/tv/tvmark/mkcolon.x b/pkg/images/tv/tvmark/mkcolon.x
new file mode 100644
index 00000000..e4dfe01a
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkcolon.x
@@ -0,0 +1,394 @@
+include <imhdr.h>
+include <error.h>
+include <fset.h>
+include "tvmark.h"
+
+# MK_COLON -- Procedure to process immark colon commands.
+
+procedure mk_colon (mk, cmdstr, im, iw, sim, log, cl, ltid, dl)
+
+pointer mk # pointer to the immark structure
+char cmdstr[ARB] # command string
+pointer im # pointer to the frame buffer
+pointer iw # pointer to the wcs information
+pointer sim # pointer to a scratch image
+int log # log file descriptor
+int cl # coords file descriptor
+int ltid # coords file sequence number
+int dl # deletions file descriptor
+
+bool bval
+real rval
+pointer sp, cmd, str, outim, deletions, ext
+int ncmd, mark, font, ival, ip, nchars, wcs_status
+
+real mk_statr()
+bool itob(), streq()
+pointer immap(), imd_mapframe(), iw_open()
+int open(), strdic(), nscan(), mk_stati(), btoi(), ctowrd()
+errchk imd_mapframe(), iw_open(), immap(), imunmap(), open()
+
+begin
+ # Allocate some working memory.
+ call smark (sp)
+ call salloc (cmd, SZ_LINE, TY_CHAR)
+ call salloc (str, SZ_LINE, TY_CHAR)
+ call salloc (deletions, SZ_FNAME, TY_CHAR)
+ call salloc (ext, SZ_FNAME, TY_CHAR)
+
+ # Get the command.
+ ip = 1
+ call sscan (cmdstr)
+ call gargwrd (Memc[cmd], SZ_LINE)
+ if (Memc[cmd] == EOS) {
+ call sfree (sp)
+ return
+ }
+
+ ncmd = strdic (Memc[cmd], Memc[cmd], SZ_LINE, MKCMDS)
+ switch (ncmd) {
+ case MKCMD_IMAGE:
+
+ case MKCMD_OUTIMAGE:
+ call gargstr (Memc[cmd], SZ_LINE)
+ call mk_stats (mk, OUTIMAGE, Memc[str], SZ_FNAME)
+ if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
+ call printf ("%s: %s\n")
+ call pargstr (KY_OUTIMAGE)
+ call pargstr (Memc[str])
+ } else {
+ nchars = ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE)
+ call mk_sets (mk, OUTIMAGE, Memc[str])
+ }
+
+ case MKCMD_DELETIONS:
+ call gargstr (Memc[cmd], SZ_LINE)
+ call mk_stats (mk, DELETIONS, Memc[str], SZ_FNAME)
+ if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
+ call printf ("%s: %s\n")
+ call pargstr (KY_DELETIONS)
+ call pargstr (Memc[str])
+ } else {
+ nchars = ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE)
+ call mk_sets (mk, DELETIONS, Memc[str])
+ }
+
+ case MKCMD_SNAP:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ if (Memc[cmd] == EOS) {
+ call mk_stats (mk, OUTIMAGE, Memc[str], SZ_FNAME)
+ if (Memc[str] == EOS)
+ call mk_stats (mk, IMAGE, Memc[str], SZ_FNAME)
+ call mk_imname (Memc[str], "", "snap", Memc[cmd], SZ_FNAME)
+ }
+
+ iferr {
+ outim = immap (Memc[cmd], NEW_COPY, im)
+ call printf ("Creating image: %s - ")
+ call pargstr (Memc[cmd])
+ call flush (STDOUT)
+ call mk_imcopy (im, outim)
+ call imunmap (outim)
+ } then {
+ call printf ("\n")
+ call erract (EA_WARN)
+ } else {
+ call printf ("done\n")
+ }
+
+ case MKCMD_COORDS:
+ call gargstr (Memc[cmd], SZ_LINE)
+ call mk_stats (mk, COORDS, Memc[str], SZ_FNAME)
+ if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
+ call printf ("%s: %s\n")
+ call pargstr (KY_COORDS)
+ call pargstr (Memc[str])
+ } else {
+ nchars = ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE)
+ if (cl != NULL) {
+ call close( cl)
+ call close (dl)
+ cl = NULL
+ dl = NULL
+ }
+ iferr {
+ if (Memc[str] != EOS) {
+ iferr (cl = open (Memc[str], READ_WRITE, TEXT_FILE)) {
+ cl = open (Memc[str], NEW_FILE, TEXT_FILE)
+ call close (cl)
+ cl = open (Memc[str], READ_WRITE, TEXT_FILE)
+ call mk_stats (mk, DELETIONS, Memc[ext], SZ_FNAME)
+ call sprintf (Memc[deletions], SZ_FNAME, "%s.%s")
+ call pargstr (Memc[str])
+ if (Memc[ext] == EOS)
+ call pargstr ("del")
+ else
+ call pargstr (Memc[ext])
+ }
+ }
+ } then {
+ cl = NULL
+ dl = NULL
+ call erract (EA_WARN)
+ call mk_sets (mk, COORDS, "")
+ } else {
+ call mk_sets (mk, COORDS, Memc[str])
+ }
+ ltid = 0
+ }
+
+ case MKCMD_LOGFILE:
+ call gargstr (Memc[cmd], SZ_LINE)
+ call mk_stats (mk, LOGFILE, Memc[str], SZ_FNAME)
+ if (Memc[cmd] == EOS || streq (Memc[cmd], Memc[str])) {
+ call printf ("%s: %s\n")
+ call pargstr (KY_LOGFILE)
+ call pargstr (Memc[str])
+ } else {
+ nchars = ctowrd (Memc[cmd], ip, Memc[str], SZ_LINE)
+ if (log != NULL) {
+ call close (log)
+ log = NULL
+ }
+ iferr {
+ if (Memc[str] != EOS)
+ log = open (Memc[str], NEW_FILE, TEXT_FILE)
+ } then {
+ log = NULL
+ call erract (EA_WARN)
+ call mk_sets (mk, LOGFILE, "")
+ call printf ("Log file is undefined.\n")
+ } else
+ call mk_sets (mk, LOGFILE, Memc[str])
+ }
+
+ case MKCMD_AUTOLOG:
+ call gargb (bval)
+ if (nscan () == 1) {
+ call printf ("%s = %b\n")
+ call pargstr (KY_AUTOLOG)
+ call pargb (itob (mk_stati (mk, AUTOLOG)))
+ } else
+ call mk_seti (mk, AUTOLOG, btoi (bval))
+
+ case MKCMD_FRAME:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %g\n")
+ call pargstr (KY_FRAME)
+ call pargi (mk_stati (mk, FRAME))
+ } else if (ival != mk_stati (mk, FRAME)) {
+ call iw_close (iw)
+ call imunmap (im)
+ iferr {
+ im = imd_mapframe (ival, READ_WRITE, YES)
+ iw = iw_open (im, ival, Memc[str], SZ_FNAME, wcs_status)
+ call mk_sets (mk, IMAGE, Memc[str])
+ } then {
+ call erract (EA_WARN)
+ im = imd_mapframe (mk_stati(mk,FRAME), READ_WRITE, YES)
+ iw = iw_open (im, mk_stati(mk,FRAME),
+ Memc[str], SZ_FNAME, wcs_status)
+ call mk_sets (mk, IMAGE, Memc[str])
+ } else
+ call mk_seti (mk, FRAME, ival)
+ }
+
+ case MKCMD_FONT:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ if (Memc[cmd] == EOS) {
+ call mk_stats (mk, FONT, Memc[cmd], SZ_LINE)
+ call printf ("%s = %s\n")
+ call pargstr (KY_FONT)
+ call pargstr (Memc[cmd])
+ } else {
+ font = strdic (Memc[cmd], Memc[cmd], SZ_LINE, MKFONTLIST)
+ if (font > 0)
+ call mk_sets (mk, FONT, Memc[cmd])
+ }
+
+ case MKCMD_LABEL:
+ call gargb (bval)
+ if (nscan () == 1) {
+ call printf ("%s = %b\n")
+ call pargstr (KY_LABEL)
+ call pargb (itob (mk_stati (mk, LABEL)))
+ } else
+ call mk_seti (mk, LABEL, btoi (bval))
+
+ case MKCMD_NUMBER:
+ call gargb (bval)
+ if (nscan () == 1) {
+ call printf ("%s = %b\n")
+ call pargstr (KY_NUMBER)
+ call pargb (itob (mk_stati (mk, NUMBER)))
+ } else
+ call mk_seti (mk, NUMBER, btoi (bval))
+
+ case MKCMD_NXOFFSET:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %g\n")
+ call pargstr (KY_NXOFFSET)
+ call pargi (mk_stati (mk, NXOFFSET))
+ } else
+ call mk_seti (mk, NXOFFSET, ival)
+
+ case MKCMD_NYOFFSET:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %g\n")
+ call pargstr (KY_NYOFFSET)
+ call pargi (mk_stati (mk, NYOFFSET))
+ } else
+ call mk_seti (mk, NYOFFSET, ival)
+
+ case MKCMD_GRAYLEVEL:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %d\n")
+ call pargstr (KY_GRAYLEVEL)
+ call pargi (mk_stati (mk, GRAYLEVEL))
+ } else
+ call mk_seti (mk, GRAYLEVEL, ival)
+
+ case MKCMD_SZPOINT:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %d\n")
+ call pargstr (KY_SZPOINT)
+ call pargi (2 * mk_stati (mk, SZPOINT) + 1)
+ } else {
+ if (mod (ival, 2) == 0)
+ ival = ival + 1
+ ival = ival / 2
+ call mk_seti (mk, SZPOINT, ival)
+ }
+
+ case MKCMD_SIZE:
+ call gargi (ival)
+ if (nscan () == 1) {
+ call printf ("%s = %d\n")
+ call pargstr (KY_SIZE)
+ call pargi (mk_stati (mk, SIZE))
+ } else
+ call mk_seti (mk, SIZE, ival)
+
+ case MKCMD_TOLERANCE:
+ call gargr (rval)
+ if (nscan () == 1) {
+ call printf ("%s = %g\n")
+ call pargstr (KY_TOLERANCE)
+ call pargr (mk_statr (mk, TOLERANCE))
+ } else
+ call mk_setr (mk, TOLERANCE, rval)
+
+ case MKCMD_MARK:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ if (Memc[cmd] == EOS) {
+ call mk_stats (mk, MARK, Memc[cmd], SZ_LINE)
+ call printf ("%s = %s\n")
+ call pargstr (KY_MARK)
+ call pargstr (Memc[cmd])
+ } else {
+ mark = strdic (Memc[cmd], Memc[cmd], SZ_LINE, MKTYPELIST)
+ if (mark > 0) {
+ call mk_seti (mk, MKTYPE, mark)
+ call mk_sets (mk, MARK, Memc[cmd])
+ }
+ }
+
+ case MKCMD_CIRCLES:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ if (Memc[cmd] == EOS) {
+ call mk_stats (mk, CSTRING, Memc[cmd], SZ_LINE)
+ call printf ("%s = %s %s\n")
+ call pargstr (KY_CIRCLES)
+ if (Memc[cmd] == EOS)
+ call pargstr ("0")
+ else
+ call pargstr (Memc[cmd])
+ call pargstr ("pixels")
+ } else
+ call mk_sets (mk, CSTRING, Memc[cmd])
+
+ case MKCMD_RECTANGLES:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ call gargr (rval)
+ if (Memc[cmd] == EOS) {
+ call mk_stats (mk, RSTRING, Memc[cmd], SZ_LINE)
+ call printf ("%s = %s %g\n")
+ call pargstr (KY_RECTANGLE)
+ if (Memc[cmd] == EOS)
+ call pargstr ("0")
+ else
+ call pargstr (Memc[cmd])
+ call pargr (mk_statr (mk, RATIO))
+ } else {
+ call mk_sets (mk, RSTRING, Memc[cmd])
+ if (nscan () < 3)
+ call mk_setr (mk, RATIO, 1.0)
+ else
+ call mk_setr (mk, RATIO, rval)
+ }
+
+ case MKCMD_SHOW:
+ call mk_show (mk)
+
+ case MKCMD_SAVE:
+ iferr {
+
+ # Check that the sizes agree.
+ if (sim == NULL) {
+ call mktemp ("scratch", Memc[cmd], SZ_FNAME)
+ sim = immap (Memc[cmd], NEW_COPY, im)
+ } else if (IM_LEN(im,1) != IM_LEN(sim,1) || IM_LEN(im,2) !=
+ IM_LEN(sim,2)) {
+ call strcpy (IM_HDRFILE(sim), Memc[cmd], SZ_FNAME)
+ call imunmap (sim)
+ call imdelete (Memc[cmd])
+ call mktemp ("scratch", Memc[cmd], SZ_FNAME)
+ sim = immap (Memc[cmd], NEW_COPY, im)
+ }
+
+ # Copy the image.
+ call printf ("Saving frame: %d - ")
+ call pargi (mk_stati (mk, FRAME))
+ call flush (STDOUT)
+ call mk_imcopy (im, sim)
+
+ } then {
+ call erract (EA_WARN)
+ call printf ("\n")
+ } else {
+ call printf ("done\n")
+ }
+
+ case MKCMD_RESTORE:
+ if (sim == NULL) {
+ call printf ("Use :save to define a scratch image.\n")
+ } else if (IM_LEN(sim,1) != IM_LEN(im,1) || IM_LEN(sim,2) !=
+ IM_LEN(im,2)) {
+ call printf (
+ "Scatch image and the frame buffer have different sizes.\n")
+ } else {
+ iferr {
+ call printf ("Restoring frame: %d - ")
+ call pargi (mk_stati (mk, FRAME))
+ call flush (STDOUT)
+ call mk_imcopy (sim, im)
+ } then {
+ call erract (EA_WARN)
+ call printf ("\n")
+ } else {
+ call printf ("done\n")
+ }
+ }
+
+
+ default:
+ call printf ("Unrecognized or ambiguous colon command.\7\n")
+ }
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/tvmark/mkfind.x b/pkg/images/tv/tvmark/mkfind.x
new file mode 100644
index 00000000..5824422a
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkfind.x
@@ -0,0 +1,52 @@
+include <mach.h>
+
+# MK_FIND -- Procedure to detect the object in a file closest to the
+# input cursor position.
+
+int procedure mk_find (cl, xcur, ycur, xlist, ylist, label, id, ltid, tol)
+
+int cl # coordinates file descriptor
+real xcur, ycur # x and y cursor position
+real xlist, ylist # x and y list position
+char label[ARB] # label string
+int id # sequence number of detected object in list
+int ltid # current sequence number in the list
+real tol # tolerance for detection
+
+real x, y, dist2, ldist2, tol2
+int fscan(), nscan()
+
+begin
+ if (cl == NULL)
+ return (0)
+ call seek (cl, BOF)
+ ltid = 0
+
+ # Initialize
+ id = 0
+ dist2 = MAX_REAL
+ tol2 = tol ** 2
+
+ # Fetch the coordinates.
+ while (fscan (cl) != EOF) {
+ call gargr (x)
+ call gargr (y)
+ call gargwrd (label, SZ_LINE)
+ if (nscan () < 2)
+ next
+ if (nscan () < 3)
+ label[1] = EOS
+ ltid = ltid + 1
+ ldist2 = (x - xcur) ** 2 + (y - ycur) ** 2
+ if (ldist2 > tol2)
+ next
+ if (ldist2 > dist2)
+ next
+ xlist = x
+ ylist = y
+ dist2 = ldist2
+ id = ltid
+ }
+
+ return (id)
+end
diff --git a/pkg/images/tv/tvmark/mkgmarks.x b/pkg/images/tv/tvmark/mkgmarks.x
new file mode 100644
index 00000000..46e9bf05
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkgmarks.x
@@ -0,0 +1,214 @@
+include <lexnum.h>
+include <ctype.h>
+
+# MK_GMARKS -- Procedure to extract mark values from a string
+
+int procedure mk_gmarks (str, marks, max_nmarks)
+
+char str[ARB] # string
+real marks[ARB] # number of marks
+int max_nmarks # maximum number of marks
+
+int fd, nmarks
+int open(), mk_rdmarks(), mk_decmarks()
+errchk open(), close()
+
+begin
+ nmarks = 0
+
+ iferr {
+ fd = open (str, READ_ONLY, TEXT_FILE)
+ nmarks = mk_rdmarks (fd, marks, max_nmarks)
+ call close (fd)
+ } then {
+ nmarks = mk_decmarks (str, marks, max_nmarks)
+ }
+
+ return (nmarks)
+end
+
+
+# MK_RDMARKS -- Procedure to read out the marks listed one per line
+# from a file.
+
+int procedure mk_rdmarks (fd, marks, max_nmarks)
+
+int fd # aperture list file descriptor
+real marks[ARB] # list of marks
+int max_nmarks # maximum number of apertures
+
+int nmarks
+pointer sp, line
+int getline(), mk_decmarks()
+
+begin
+ call smark (sp)
+ call salloc (line, SZ_LINE, TY_CHAR)
+
+ nmarks = 0
+ while (getline (fd, Memc[line]) != EOF && nmarks < max_nmarks) {
+ nmarks = nmarks + mk_decmarks (Memc[line], marks[1+nmarks],
+ max_nmarks - nmarks)
+ }
+
+ call sfree (sp)
+
+ return (nmarks)
+end
+
+
+# MK_DECAPERTS -- Procedure to decode the mark string.
+
+int procedure mk_decmarks (str, marks, max_nmarks)
+
+char str[ARB] # aperture string
+real marks[ARB] # aperture array
+int max_nmarks # maximum number of apertures
+
+char outstr[SZ_LINE]
+int nmarks, ip, op, ndecode, nmk
+real mkstart, mkend, mkstep
+bool fp_equalr()
+int gctor()
+
+begin
+ nmarks = 0
+
+ for (ip = 1; str[ip] != EOS && nmarks < max_nmarks;) {
+
+ mkstart = 0.0
+ mkend = 0.0
+ mkstep = 0.0
+ ndecode = 0
+
+ # Skip past white space and commas.
+ while (IS_WHITE(str[ip]))
+ ip = ip + 1
+ if (str[ip] == ',')
+ ip = ip + 1
+
+ # Get the number.
+ op = 1
+ while (IS_DIGIT(str[ip]) || str[ip] == '.') {
+ outstr[op] = str[ip]
+ ip = ip + 1
+ op = op + 1
+ }
+ outstr[op] = EOS
+
+ # Decode the starting aperture.
+ op = 1
+ if (gctor (outstr, op, mkstart) > 0) {
+ mkend = mkstart
+ ndecode = 1
+ } else
+ mkstart = 0.0
+
+ # Skip past white space and commas.
+ while (IS_WHITE(str[ip]))
+ ip = ip + 1
+ if (str[ip] == ',')
+ ip = ip + 1
+
+ # Get the ending aperture
+ if (str[ip] == ':') {
+ ip = ip + 1
+
+ # Get the ending aperture.
+ op = 1
+ while (IS_DIGIT(str[ip]) || str[ip] == '.') {
+ outstr[op] = str[ip]
+ ip = ip + 1
+ op = op + 1
+ }
+ outstr[op] = EOS
+
+ # Decode the ending aperture.
+ op = 1
+ if (gctor (outstr, op, mkend) > 0) {
+ ndecode = 2
+ mkstep = mkend - mkstart
+ }
+ }
+
+ # Skip past white space and commas.
+ while (IS_WHITE(str[ip]))
+ ip = ip + 1
+ if (str[ip] == ',')
+ ip = ip + 1
+
+ # Get the step size.
+ if (str[ip] == ':') {
+ ip = ip + 1
+
+ # Get the step size.
+ op = 1
+ while (IS_DIGIT(str[ip]) || str[ip] == '.') {
+ outstr[op] = str[ip]
+ ip = ip + 1
+ op = op + 1
+ }
+ outstr[op] = EOS
+
+ # Decode the step size.
+ op = 1
+ if (gctor (outstr, op, mkstep) > 0) {
+ if (fp_equalr (mkstep, 0.0))
+ mkstep = mkend - mkstart
+ else
+ ndecode = (mkend - mkstart) / mkstep + 1
+ if (ndecode < 0) {
+ ndecode = -ndecode
+ mkstep = - mkstep
+ }
+ }
+ }
+
+ # Negative apertures are not permitted.
+ if (mkstart <= 0.0 || mkend <= 0.0)
+ break
+
+ # Fill in the apertures.
+ if (ndecode == 0) {
+ ;
+ } else if (ndecode == 1) {
+ nmarks = nmarks + 1
+ marks[nmarks] = mkstart
+ } else if (ndecode == 2) {
+ nmarks = nmarks + 1
+ marks[nmarks] = mkstart
+ if (nmarks >= max_nmarks)
+ break
+ nmarks = nmarks + 1
+ marks[nmarks] = mkend
+ } else {
+ for (nmk = 1; nmk <= ndecode && nmarks < max_nmarks;
+ nmk = nmk + 1) {
+ nmarks = nmarks + 1
+ marks[nmarks] = mkstart + (nmk - 1) * mkstep
+ }
+ }
+ }
+
+ return (nmarks)
+end
+
+
+# GCTOR -- Procedure to convert a character variable to a real number.
+# This routine is just an interface routine to the IRAF procedure gctod.
+
+int procedure gctor (str, ip, rval)
+
+char str[ARB] # string to be converted
+int ip # pointer to the string
+real rval # real value
+
+double dval
+int nchars
+int gctod()
+
+begin
+ nchars = gctod (str, ip, dval)
+ rval = dval
+ return (nchars)
+end
diff --git a/pkg/images/tv/tvmark/mkgpars.x b/pkg/images/tv/tvmark/mkgpars.x
new file mode 100644
index 00000000..095ed3f7
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkgpars.x
@@ -0,0 +1,65 @@
+include <ctype.h>
+include "tvmark.h"
+
+# MK_GPARS -- Fetch the parameters required for the imark task from the cl.
+
+procedure mk_gpars (mk)
+
+pointer mk # pointer to the immark structure
+
+int mark, dotsize, ip
+pointer sp, str
+real ratio
+bool clgetb()
+int clgwrd(), clgeti(), nscan(), btoi(), mk_stati()
+real clgetr()
+
+begin
+ # Allocate working space.
+ call smark (sp)
+ call salloc (str, SZ_LINE, TY_CHAR)
+
+ # Initialize the immark structure.
+ call mk_init (mk)
+
+ # Get the mark parameters.
+ mark = clgwrd ("mark", Memc[str], SZ_FNAME, MKTYPELIST)
+ if (mark > 0) {
+ call mk_sets (mk, MARK, Memc[str])
+ call mk_seti (mk, MKTYPE, mark)
+ } else {
+ call mk_sets (mk, MARK, "point")
+ call mk_seti (mk, MKTYPE, MK_POINT)
+ }
+
+ # Get the circles descriptor.
+ call clgstr ("radii", Memc[str], SZ_FNAME)
+ call mk_sets (mk, CSTRING, Memc[str])
+
+ # Get the rectangles descriptor.
+ ip = 1
+ call clgstr ("lengths", Memc[str], SZ_LINE)
+ call sscan (Memc[str])
+ call gargwrd (Memc[str], SZ_LINE)
+ call mk_sets (mk, RSTRING, Memc[str])
+ call gargr (ratio)
+ if (nscan () < 2 || mk_stati (mk, NRECTANGLES) < 1)
+ call mk_setr (mk, RATIO, 1.0)
+ else
+ call mk_setr (mk, RATIO, ratio)
+
+ # Get the rest of the parameters.
+ call mk_seti (mk, NUMBER, btoi (clgetb ("number")))
+ call mk_seti (mk, LABEL, btoi (clgetb ("label")))
+ call mk_seti (mk, SIZE, clgeti ("txsize"))
+ dotsize = clgeti ("pointsize")
+ if (mod (dotsize, 2) == 0)
+ dotsize = dotsize + 1
+ call mk_seti (mk, SZPOINT, dotsize / 2)
+ call mk_seti (mk, GRAYLEVEL, clgeti ("color"))
+ call mk_seti (mk, NXOFFSET, clgeti ("nxoffset"))
+ call mk_seti (mk, NYOFFSET, clgeti ("nyoffset"))
+ call mk_setr (mk, TOLERANCE, clgetr ("tolerance"))
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/tvmark/mkgscur.x b/pkg/images/tv/tvmark/mkgscur.x
new file mode 100644
index 00000000..529ccc9c
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkgscur.x
@@ -0,0 +1,87 @@
+include <gset.h>
+include <fset.h>
+
+# MK_GSCUR -- Procedure to fetch x and y positions from a file and move
+# the cursor to those positions.
+
+int procedure mk_gscur (sl, gd, xcur, ycur, label, prev_num, req_num, num)
+
+pointer sl # pointer to text file containing cursor coords
+pointer gd # pointer to graphics stream
+real xcur, ycur # x cur and y cur
+char label[ARB] # label string
+int prev_num # previous number
+int req_num # requested number
+int num # list number
+
+int stdin, nskip, ncount
+pointer sp, fname
+int fscan(), nscan(), strncmp()
+errchk greactivate, gdeactivate, gscur
+
+begin
+ if (sl == NULL)
+ return (EOF)
+
+ call smark (sp)
+ call salloc (fname, SZ_FNAME, TY_CHAR)
+
+ # Find the number of objects to be skipped.
+ call fstats (sl, F_FILENAME, Memc[fname], SZ_FNAME)
+ if (strncmp ("STDIN", Memc[fname], 5) == 0) {
+ stdin = YES
+ nskip = 1
+ } else {
+ stdin = NO
+ if (req_num <= prev_num) {
+ call seek (sl, BOF)
+ nskip = req_num
+ } else
+ nskip = req_num - prev_num
+ }
+
+ ncount = 0
+ num = prev_num
+ repeat {
+
+ # Print the prompt if file is STDIN.
+ if (stdin == YES) {
+ call printf ("Type object x and y coordinates: ")
+ call flush (STDOUT)
+ }
+
+ # Fetch the coordinates.
+ if (fscan (sl) != EOF) {
+ call gargr (xcur)
+ call gargr (ycur)
+ call gargwrd (label, SZ_LINE)
+ if (nscan () >= 2) {
+ ncount = ncount + 1
+ num = num + 1
+ }
+ } else
+ ncount = EOF
+
+ # Move the cursor.
+ if (gd != NULL && (ncount == nskip || ncount == EOF)) {
+ iferr {
+ call greactivate (gd, 0)
+ call gscur (gd, xcur, ycur)
+ call gdeactivate (gd, 0)
+ } then
+ ;
+ }
+
+ } until (ncount == EOF || ncount == nskip)
+
+ call sfree (sp)
+
+ if (ncount == EOF) {
+ return (EOF)
+ } else if (nskip == req_num) {
+ num = ncount
+ return (ncount)
+ } else {
+ return (num)
+ }
+end
diff --git a/pkg/images/tv/tvmark/mkmag.x b/pkg/images/tv/tvmark/mkmag.x
new file mode 100644
index 00000000..956f50b4
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkmag.x
@@ -0,0 +1,20 @@
+include <imhdr.h>
+
+# MK_MAG -- Procedure to compute the x and y magnification factors.
+
+procedure mk_mag (im, iw, xmag, ymag)
+
+pointer im # pointer to the frame buffer
+pointer iw # pointer to the wcs structure
+real xmag, ymag # x and y magnifications
+
+real xll, yll, xur, yur
+
+begin
+ # Compute the x and y magnification.
+ call iw_fb2im (iw, 1.0, 1.0, xll, yll)
+ call iw_fb2im (iw, real (IM_LEN(im,1)), real (IM_LEN(im,2)), xur, yur)
+
+ xmag = abs (xur - xll) / (IM_LEN(im,1) - 1)
+ ymag = abs (yur - yll) / (IM_LEN(im,2) - 1)
+end
diff --git a/pkg/images/tv/tvmark/mkmark.x b/pkg/images/tv/tvmark/mkmark.x
new file mode 100644
index 00000000..72583fcb
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkmark.x
@@ -0,0 +1,482 @@
+include <fset.h>
+include <imhdr.h>
+include "tvmark.h"
+
+define HELPFILE "iraf$lib/scr/tvmark.key"
+
+# MK_MARK -- Procedure to mark symbols in the frame buffer interactively.
+
+int procedure mk_mark (mk, im, iw, cl, dl, log, fnt, autolog, interactive)
+
+pointer mk # pointer to the mark structure
+pointer im # frame image descriptor
+pointer iw # pointer to the wcs structure
+int cl # coordinate file descriptor
+int dl # pointer to the deletions file
+int log # output log file descriptor
+int fnt # font file descriptor
+int autolog # automatic logging enabled
+int interactive # interactive mode
+
+int ncmd, ncols, nlines, nc, nr
+int wcs, bkey, skey, vkey, ekey, fkey, okey, key
+int id, ltid, ndelete, req_num, lreq_num, prev_num, newlist
+pointer sim, sp, scratchim, cmd, str, keepcmd, label
+real cwx, cwy, wx, wy, owx, owy, fx, fy, ofx, ofy
+real xlist, ylist, oxlist, oylist, rmax
+
+int imd_gcur(), mk_stati(), strdic(), mk_gscur(), nscan(), mk_new()
+int mk_find(), fstati()
+real mk_statr()
+
+begin
+ # Allocate working memory.
+ call smark (sp)
+ call salloc (scratchim, SZ_FNAME, TY_CHAR)
+ call salloc (cmd, SZ_LINE, TY_CHAR)
+ call salloc (keepcmd, SZ_LINE, TY_CHAR)
+ call salloc (str, SZ_LINE, TY_CHAR)
+ call salloc (label, SZ_LINE, TY_CHAR)
+
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ sim = NULL
+
+ # Reinitialize.
+ ekey = ' '
+ fkey = ' '
+ okey = ' '
+ skey = ' '
+ vkey = ' '
+ bkey = ' '
+ ltid = 0
+ ndelete = 0
+ newlist = NO
+ owx = INDEFR
+ owy = INDEFR
+ Memc[cmd] = EOS
+ Memc[keepcmd] = EOS
+
+ while (imd_gcur ("commands", wx,wy,wcs,key,Memc[cmd],SZ_LINE) != EOF) {
+
+ # Save current cursor coordinates.
+ cwx = wx
+ cwy = wy
+
+ # Check for new object.
+ if (mk_new (wx, wy, owx, owy, xlist, ylist, newlist) == YES)
+ ;
+
+ # Transform to frame buffer coordinates.
+ call iw_im2fb (iw, wx, wy, fx, fy)
+
+ switch (key) {
+
+ # Print the help page.
+ case '?':
+ if (interactive == YES)
+ call pagefile (HELPFILE, "Type ? for help, q to quit")
+
+ # Quit the task.
+ case 'q':
+ break
+
+ # Keep the previous cursor command.
+ case 'k':
+ if (log != NULL)
+ if (autolog == YES)
+ call printf ("Automatic logging is already enabled.\n")
+ else
+ call mk_logcmd (log, Memc[keepcmd])
+ else {
+ if (interactive == YES)
+ call printf ("The log file is undefined.\n")
+ }
+
+ # Rewind the coordinate list.
+ case 'o':
+ if (cl != NULL) {
+ call seek (cl, BOF)
+ oxlist = INDEFR
+ oylist = INDEFR
+ ltid = 0
+ } else if (interactive == YES)
+ call printf ("Coordinate list is undefined.\n")
+
+ # Move to the previous object.
+ case '-':
+ if (cl != NULL) {
+ prev_num = ltid
+ req_num = ltid - 1
+ if (req_num < 1) {
+ if (interactive == YES)
+ call printf ("Requested object is less than 1.\n")
+ } else if (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ if (interactive == YES)
+ call printf ("Moved to object: %d %g %g\n")
+ call pargi (ltid)
+ call pargr (xlist)
+ call pargr (ylist)
+ newlist = YES
+ } else if (interactive == YES)
+ call printf (
+ "End of coordinate list, type o to rewind.\n")
+ } else if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+
+ # Mark the previous object.
+ case 'p':
+ if (cl != NULL) {
+ prev_num = ltid
+ req_num = ltid - 1
+ if (req_num < 1) {
+ if (interactive == YES)
+ call printf ("Requested object is less than 1.\n")
+ } else if (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ call mk_onemark (mk, im, iw, xlist, ylist, oxlist,
+ oylist, Memc[label], ltid)
+ newlist = YES
+ } else if (interactive == YES) {
+ call printf (
+ "End of coordinate list, type o to rewind.\n")
+ }
+ } else if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+
+ # Move to the next object.
+ case 'm':
+ if (cl != NULL) {
+ prev_num = ltid
+ req_num = ltid + 1
+ if (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ if (interactive == YES)
+ call printf ("Moved to object: %d %g %g\n")
+ call pargi (ltid)
+ call pargr (xlist)
+ call pargr (ylist)
+ newlist = YES
+ } else if (interactive == YES)
+ call printf (
+ "End of coordinate list, type o to rewind.\n")
+ } else if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+
+ # Mark the next object.
+ case 'n':
+ if (cl != NULL) {
+ prev_num = ltid
+ req_num = ltid + 1
+ if (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ call mk_onemark (mk, im, iw, xlist, ylist, oxlist,
+ oylist, Memc[label], ltid)
+ newlist = YES
+ } else if (interactive == YES)
+ call printf (
+ "End of coordinate list, type o to rewind.\n")
+ } else if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+
+ # Mark the entire list.
+ case 'l':
+ if (cl != NULL) {
+ call seek (cl, BOF)
+ ltid = 0
+ call mk_bmark (mk, im, iw, cl, ltid, fnt)
+ } else if (interactive == YES)
+ call printf ("Coordinate list is undefined.\n")
+
+ # Append to the coordinate list.
+ case 'a':
+ if (cl == NULL) {
+ if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+ } else if (fstati (cl, F_MODE) != READ_WRITE) {
+ if (interactive == YES)
+ call printf (
+ "No write permission on coordinate file.\n")
+ } else {
+
+ # Move to the end of the list.
+ prev_num = ltid
+ req_num = ltid + 1
+ while (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ prev_num = ltid
+ req_num = ltid + 1
+ }
+
+ # Add the object.
+ call fprintf (cl, "%g %g\n")
+ call pargr (wx)
+ call pargr (wy)
+ call flush (cl)
+ ltid = ltid + 1
+ #call seek (cl, EOF)
+
+ # Mark the object.
+ call mk_onemark (mk, im, iw, wx, wy, oxlist, oylist, "",
+ ltid)
+
+ }
+
+ # Delete an object.
+ case 'd':
+ if (cl == NULL) {
+ if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+ } else if (fstati (cl, F_MODE) != READ_WRITE) {
+ if (interactive == YES)
+ call printf (
+ "No write permission on coordinate file.\n")
+ } else {
+
+ # Find the nearest object to the cursor and delete.
+ if (mk_find (cl, wx, wy, xlist, ylist, Memc[label], id,
+ ltid, mk_statr (mk, TOLERANCE)) > 0) {
+ call fprintf (dl, "%d\n")
+ call pargi (id)
+ ndelete = ndelete + 1
+ call mk_onemark (mk, im, iw, xlist, ylist, oxlist,
+ oylist, Memc[label], ltid)
+ } else if (interactive == YES)
+ call printf ("Object not in coordinate list.\n")
+
+ }
+
+ # Draw a dot.
+ case '.':
+ call mk_dmark (mk, im, fx, fy)
+
+ # Draw a plus sign.
+ case '+':
+ call mk_tmark (mk, im, "+", fx, fy, YES)
+
+ # Draw a cross.
+ case 'x':
+ call mk_tmark (mk, im, "x", fx, fy, YES)
+
+ # Mark and erase a region.
+ case 'e':
+ if (sim != NULL) {
+ if ((key == ekey) && (okey == 'e' || okey == 'k')) {
+ call mk_imsection (mk, sim, im, nint (ofx), nint (fx),
+ nint (ofy), nint (fy))
+ ekey = ' '
+ } else {
+ if (interactive == YES)
+ call printf ("Type e again to define region.\n")
+ ekey = key
+ ofx = fx
+ ofy = fy
+ }
+ } else if (interactive == YES)
+ call printf ("Define a scratch image with :save.\n")
+
+ # Fill region
+ case 'f':
+ if ((key == fkey) && (okey == 'f' || okey == 'k')) {
+ call mk_imsection (mk, NULL, im, nint (ofx), nint (fx),
+ nint (ofy), nint (fy))
+ fkey = ' '
+ } else {
+ if (interactive == YES)
+ call printf ("Type f again to define region.\n")
+ fkey = key
+ ofx = fx
+ ofy = fy
+ }
+
+ # Mark a single circle.
+ case 'v':
+ if ((key == vkey) && (okey == 'v' || okey == 'k')) {
+ rmax = sqrt ((fx - ofx) ** 2 + (fy - ofy) ** 2)
+ call mk_ocmark (mk, im, iw, ofx, ofy, rmax)
+ vkey = ' '
+ } else {
+ if (interactive == YES)
+ call printf ("Type v again to draw circle.\n")
+ vkey = key
+ ofx = fx
+ ofy = fy
+ }
+
+ # Draw concentric circles.
+ case 'c':
+ nc = mk_stati (mk, NCIRCLES)
+ if (nc > 0) {
+ call mk_cmark (mk, im, iw, fx, fy)
+ } else if (interactive == YES)
+ call printf ("Use :radii to specifiy radii.\n")
+
+ # Draw concentric rectangles.
+ case 'r':
+ nr = mk_stati (mk, NRECTANGLES)
+ if (nr > 0) {
+ call mk_rmark (mk, im, iw, fx, fy)
+ } else if (interactive == YES)
+ call printf ("Use :lengths to specify box lengths.\n")
+
+ # Draw a vector segment.
+ case 's':
+ if ((skey == key) && (okey == 's' || okey == 'k'))
+ call mk_lmark (mk, im, ofx, ofy, fx, fy)
+ if (interactive == YES)
+ call printf ("Type s again to draw line segment.\n")
+ ofx = fx
+ ofy = fy
+ skey = key
+
+ # Draw a box
+ case 'b':
+ if ((key == bkey) && (okey == 'b' || okey == 'k')) {
+ call mk_xmark (mk, im, ofx, ofy, fx, fy)
+ bkey = ' '
+ } else {
+ if (interactive == YES)
+ call printf ("Type b again to draw box.\n")
+ bkey = key
+ ofx = fx
+ ofy = fy
+ }
+
+ # Execute the colon command.
+ case ':':
+ call sscan (Memc[cmd])
+ call gargwrd (Memc[str], SZ_LINE)
+ ncmd = strdic (Memc[str], Memc[str], SZ_LINE, MKCMDS2)
+
+ if (ncmd <= 0)
+ call mk_colon (mk, Memc[cmd], im, iw, sim, log, cl, ltid,
+ dl)
+
+ else if (ncmd == MKCMD2_WTEXT) {
+ call gargstr (Memc[str], SZ_LINE)
+ if (Memc[str] != EOS)
+ call mk_tmark (mk, im, Memc[str], fx, fy, NO)
+
+ } else if (ncmd == MKCMD2_MOVE) {
+ if (cl != NULL) {
+ call gargi (req_num)
+ prev_num = ltid
+ if (nscan () < 2)
+ req_num = ltid + 1
+ if (req_num < 1) {
+ if (interactive == YES)
+ call printf (
+ "Requested object is less than 1.\n")
+ } else if (mk_gscur (cl, NULL, xlist, ylist,
+ Memc[label], prev_num, req_num, ltid) != EOF) {
+ if (interactive == YES)
+ call printf ("Moved to object: %d %g %g\n")
+ call pargi (ltid)
+ call pargr (xlist)
+ call pargr (ylist)
+ newlist = YES
+ } else if (interactive == YES) {
+ call printf (
+ "End of coordinate list, type o to rewind.\n")
+ }
+ } else if (interactive == YES)
+ call printf ("Coordinate file is undefined.\n")
+
+ } else if (ncmd == MKCMD2_NEXT) {
+ if (cl != NULL) {
+ call gargi (req_num)
+ call gargi (lreq_num)
+ prev_num = ltid
+ if (nscan () < 2) {
+ req_num = ltid + 1
+ lreq_num = req_num
+ } else if (nscan () < 3)
+ lreq_num = req_num
+ while (mk_gscur (cl, NULL, xlist, ylist, Memc[label],
+ prev_num, req_num, ltid) != EOF) {
+ if (ltid > lreq_num)
+ break
+ call mk_onemark (mk, im, iw, xlist, ylist, oxlist,
+ oylist, Memc[label], ltid)
+ newlist = YES
+ prev_num = ltid
+ req_num = ltid + 1
+ }
+ } else if (interactive == YES)
+ call printf ("Coordinate field is undefined.\n")
+ }
+
+ default:
+ call printf ("Unrecognized keystroke command.\7\n")
+ }
+
+ # Encode and log the last cursor command. Do not encode any
+ # keep commands if autologging is turned off.
+
+ if (autolog == YES) {
+ call mk_encodecmd (wx, wy, wcs, key, Memc[cmd], Memc[keepcmd])
+ if (log == NULL) {
+ if (interactive == YES)
+ call printf ("The logfile is undefined.\n")
+ } else
+ call mk_logcmd (log, Memc[keepcmd])
+ } else if (key != 'k')
+ call mk_encodecmd (wx, wy, wcs, key, Memc[cmd], Memc[keepcmd])
+
+ # Get set up for next cursor command.
+ owx = cwx
+ owy = cwy
+ okey = key
+ Memc[cmd] = EOS
+ if (newlist == YES) {
+ oxlist = xlist
+ oylist = ylist
+ }
+ }
+
+ # Delete scratch image.
+ if (sim != NULL) {
+ call strcpy (IM_HDRFILE(sim), Memc[scratchim], SZ_FNAME)
+ call imunmap (sim)
+ call imdelete (Memc[scratchim])
+ }
+
+ call sfree (sp)
+
+ return (ndelete)
+end
+
+
+# MK_ENCODECMD -- Encode the cursor command.
+
+procedure mk_encodecmd (wx, wy, wcs, key, cmd, keepcmd)
+
+real wx, wy # cursor position
+int wcs # world coordinate system
+int key # cursor keystroke command
+char cmd[ARB] # command
+char keepcmd[ARB] # encode cursor command
+
+begin
+ call sprintf (keepcmd, SZ_LINE, "%g %g %d %c %s")
+ call pargr (wx)
+ call pargr (wy)
+ call pargi (wcs)
+ call pargi (key)
+ call pargstr (cmd)
+end
+
+
+# MK_LOGCMD -- Log the command.
+
+procedure mk_logcmd (log, cmd)
+
+int log # logfile descriptor
+char cmd[ARB] # command
+
+begin
+ call fprintf (log, "%s\n")
+ call pargstr (cmd)
+end
diff --git a/pkg/images/tv/tvmark/mknew.x b/pkg/images/tv/tvmark/mknew.x
new file mode 100644
index 00000000..27a5a3af
--- /dev/null
+++ b/pkg/images/tv/tvmark/mknew.x
@@ -0,0 +1,42 @@
+# MK_NEW -- Procedure to determine whether the current star is the same as
+# the previous star and/or whether the current star belongs to the coordinate
+# list or not.
+
+int procedure mk_new (wx, wy, owx, owy, xlist, ylist, newlist)
+
+real wx # x cursor coordinate
+real wy # y cursor coordinate
+real owx # old x cursor coordinate
+real owy # old y cursor coordinate
+real xlist # x list coordinate
+real ylist # y list coordinate
+int newlist # integer new list
+
+int newobject
+real deltaxy
+bool fp_equalr()
+
+begin
+ deltaxy = 1.0
+
+ if (newlist == NO) {
+ if (! fp_equalr (wx, owx) || ! fp_equalr (wy, owy))
+ newobject = YES
+ else
+ newobject = NO
+ } else if ((abs (xlist - wx) <= deltaxy) &&
+ (abs (ylist - wy) <= deltaxy)) {
+ wx = xlist
+ wy = ylist
+ newobject = NO
+ } else if (fp_equalr (wx, owx) && fp_equalr (wy, owy)) {
+ wx = xlist
+ wy = ylist
+ newobject = NO
+ } else {
+ newlist = NO
+ newobject = YES
+ }
+
+ return (newobject)
+end
diff --git a/pkg/images/tv/tvmark/mkonemark.x b/pkg/images/tv/tvmark/mkonemark.x
new file mode 100644
index 00000000..91bd9ee0
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkonemark.x
@@ -0,0 +1,392 @@
+include <imhdr.h>
+include "tvmark.h"
+
+# MK_ONEMARK -- Procedure to mark symbols in the frame buffer given a
+# coordinate list and a mark type.
+
+procedure mk_onemark (mk, im, iw, wx, wy, owx, owy, label, ltid)
+
+pointer mk # pointer to the mark structure
+pointer im # frame image descriptor
+pointer iw # pointer to the wcs structure
+real wx, wy # coordinates of current list object
+real owx, owy # coordinates of previous list member
+char label[ARB] # current label
+int ltid # list sequence number
+
+int ncols, nlines, nr, nc, x1, x2, y1, y2
+pointer sp, str, lengths, radii
+real fx, fy, ofx, ofy, xmag, ymag, lmax, lratio, rmax, ratio
+int mk_stati(), itoc()
+int mk_plimits(), mk_llimits(), mk_rlimits(), mk_climits()
+pointer mk_statp()
+real mk_statr()
+
+begin
+ call smark (sp)
+ call salloc (str, SZ_LINE, TY_CHAR)
+ call salloc (lengths, MAX_NMARKS, TY_REAL)
+ call salloc (radii, MAX_NMARKS, TY_REAL)
+
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ # Convert from image to frame buffer coordinates.
+ if (IS_INDEFR(owx) || IS_INDEFR(owy)) {
+ owx = INDEFR
+ owy = INDEFR
+ } else
+ call iw_im2fb (iw, owx, owy, ofx, ofy)
+ call iw_im2fb (iw, wx, wy, fx, fy)
+ call mk_mag (im, iw, xmag, ymag)
+
+ switch (mk_stati (mk, MKTYPE)) {
+
+ case MK_POINT:
+ if (mk_plimits (fx, fy, mk_stati (mk, SZPOINT),
+ ncols, nlines, x1, x2, y1, y2) == YES) {
+ call mk_drawpt (im, x1, x2, y1, y2, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ case MK_LINE:
+ if (! IS_INDEFR(ofx) && ! IS_INDEFR(ofy)) {
+ if (mk_llimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawline (im, ofx, ofy, fx, fy, x1, x2, y1, y2,
+ mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+ }
+
+ case MK_RECTANGLE:
+ nr = mk_stati (mk, NRECTANGLES)
+ if (xmag <= 0.0) {
+ lmax = 0.0
+ call amovkr (0.0, Memr[lengths], nr)
+ } else {
+ call adivkr (Memr[mk_statp(mk,RLENGTHS)], xmag, Memr[lengths],
+ nr)
+ lmax = Memr[lengths+nr-1]
+ }
+ if (ymag <= 0.0)
+ lratio = 0.0
+ else
+ lratio = mk_statr (mk, RATIO) * xmag / ymag
+ if (mk_rlimits (fx, fy, lmax, lratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawbox (im, fx, fy, x1, x2, y1, y2, Memr[lengths],
+ lratio, nr, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ case MK_CIRCLE:
+ nc = mk_stati (mk, NCIRCLES)
+ if (xmag <= 0.0) {
+ rmax = 0.0
+ call amovkr (0.0, Memr[radii], nc)
+ } else {
+ call adivkr (Memr[mk_statp(mk, RADII)], xmag, Memr[radii], nc)
+ rmax = Memr[radii+nc-1]
+ }
+ if (ymag <= 0.0)
+ ratio = 0.0
+ else
+ ratio = xmag / ymag
+ if (mk_climits (fx, fy, rmax, ratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawcircles (im, fx, fy, x1, x2, y1, y2,
+ Memr[radii], ratio, nc, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ case MK_PLUS:
+ call mk_textim (im, "+", nint (fx), nint (fy), mk_stati (mk, SIZE),
+ mk_stati (mk, SIZE), mk_stati (mk, GRAYLEVEL), YES)
+ call imflush (im)
+
+ case MK_CROSS:
+ call mk_textim (im, "*", nint (fx), nint (fy), mk_stati (mk, SIZE),
+ mk_stati (mk, SIZE), mk_stati (mk, GRAYLEVEL), YES)
+ call imflush (im)
+
+ default:
+ # Do nothing gracefully
+ }
+
+ # Number the text file.
+ if (mk_stati (mk, LABEL) == YES) {
+ if (label[1] != EOS) {
+ call mk_textim (im, label, nint (fx) + mk_stati (mk,
+ NXOFFSET), nint (fy) + mk_stati (mk, NYOFFSET),
+ mk_stati (mk, SIZE), mk_stati (mk, SIZE), mk_stati (mk,
+ GRAYLEVEL), NO)
+ call imflush (im)
+ }
+ } else if (mk_stati (mk, NUMBER) == YES) {
+ if (itoc (ltid, Memc[str], SZ_FNAME) > 0) {
+ call mk_textim (im, Memc[str], nint (fx) + mk_stati (mk,
+ NXOFFSET), nint (fy) + mk_stati (mk, NYOFFSET),
+ mk_stati (mk, SIZE), mk_stati (mk, SIZE), mk_stati (mk,
+ GRAYLEVEL), NO)
+ call imflush (im)
+ }
+ }
+
+ call sfree (sp)
+end
+
+
+# MK_DMARK -- Mark a dot.
+
+procedure mk_dmark (mk, im, fx, fy)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer
+real fx, fy # real coordinates
+
+int ncols, nlines, x1, y1, x2, y2
+int mk_stati(), mk_plimits()
+
+begin
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+ if (mk_plimits (fx, fy, mk_stati (mk, SZPOINT), ncols, nlines,
+ x1, x2, y1, y2) == YES) {
+ call mk_drawpt (im, x1, x2, y1, y2, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, x2)
+end
+
+
+# MK_CMARK -- Mark concentric circle(s).
+
+procedure mk_cmark (mk, im, iw, fx, fy)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer image
+pointer iw # pointer to the wcs structure
+real fx, fy # center of circle
+
+int nc, ncols, nlines, x1, x2, y1, y2
+pointer sp, radii
+real xmag, ymag, rmax, ratio
+int mk_stati(), mk_climits()
+pointer mk_statp()
+
+begin
+ nc = mk_stati (mk, NCIRCLES)
+ if (nc <= 0)
+ return
+
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+ call mk_mag (im, iw, xmag, ymag)
+
+ call smark (sp)
+ call salloc (radii, nc, TY_REAL)
+
+ if (xmag <= 0.0) {
+ rmax = 0.0
+ call amovkr (0.0, Memr[radii], nc)
+ } else {
+ call adivkr (Memr[mk_statp(mk,RADII)], xmag, Memr[radii], nc)
+ rmax = Memr[radii+nc-1]
+ }
+ if (ymag <= 0.0)
+ ratio = 0.0
+ else
+ ratio = xmag / ymag
+
+ if (mk_climits (fx, fy, rmax, ratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawcircles (im, fx, fy, x1, x2, y1, y2, Memr[radii],
+ ratio, nc, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, y2)
+
+ call sfree (sp)
+end
+
+
+# MK_OCMARK -- Mark one circle.
+
+procedure mk_ocmark (mk, im, iw, fx, fy, rmax)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer image
+pointer iw # pointer to the wcs structure
+real fx, fy # center of circle
+real rmax # maximum radius
+
+int ncols, nlines, x1, x2, y1, y2
+int mk_climits(), mk_stati()
+
+begin
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ if (mk_climits (fx, fy, rmax, 1.0, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawcircles (im, fx, fy, x1, x2, y1, y2, rmax,
+ 1.0, 1, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, y2)
+end
+
+
+# MK_LMARK -- Mark s line segment
+
+procedure mk_lmark (mk, im, ofx, ofy, fx, fy)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer
+real ofx, ofy # coords of first point
+real fx, fy # coords of second point
+
+int ncols, nlines, x1, y1, x2, y2
+int mk_stati(), mk_llimits()
+
+begin
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ if (mk_llimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawline (im, ofx, ofy, fx, fy, x1, x2, y1, y2,
+ mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, y2)
+end
+
+
+# MK_TMARK -- Mark a text string
+
+procedure mk_tmark (mk, im, str, fx, fy, center)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer image
+char str[ARB] # character string to be drawn
+real fx, fy # lower left coords of string
+int center # center the string
+
+int ncols, nlines
+#int x1, x2, y1, y2
+int mk_stati()
+
+begin
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ call mk_textim (im, str, nint (fx), nint (fy), mk_stati (mk, SIZE),
+ mk_stati(mk, SIZE), mk_stati (mk, GRAYLEVEL), center)
+ call imflush (im)
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x1)
+ #call mk_seti (mk, Y2, y2)
+end
+
+
+# MK_RMARK -- Mark concentric rectangles.
+
+procedure mk_rmark (mk, im, iw, fx, fy)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer
+pointer iw # pointer to the wcs structure
+real fx, fy # x and y center coordinates
+
+int nr, ncols, nlines, x1, y1, x2, y2
+pointer sp, lengths
+real xmag, ymag, lmax, lratio
+int mk_stati(), mk_rlimits()
+pointer mk_statp()
+real mk_statr()
+
+begin
+ nr = mk_stati (mk, NRECTANGLES)
+ if (nr <= 0)
+ return
+
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+ call mk_mag (im, iw, xmag, ymag)
+
+ call smark (sp)
+ call salloc (lengths, nr, TY_REAL)
+
+ if (xmag <= 0.0) {
+ lmax = 0.0
+ call amovkr (0.0, Memr[lengths], nr)
+ } else {
+ lmax = Memr[mk_statp(mk, RLENGTHS)+nr-1] / xmag
+ call adivkr (Memr[mk_statp(mk,RLENGTHS)], xmag, Memr[lengths], nr)
+ }
+ if (ymag <= 0.0)
+ lratio = 0.0
+ else
+ lratio = mk_statr (mk, RATIO) * xmag / ymag
+
+ if (mk_rlimits (fx, fy, lmax, lratio, ncols, nlines, x1, x2,
+ y1, y2) == YES) {
+ call mk_drawbox (im, fx, fy, x1, x2, y1, y2, Memr[lengths],
+ lratio, nr, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+ }
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, y2)
+
+ call sfree (sp)
+end
+
+
+# MK_XMARK -- Procedure to mark a box.
+
+procedure mk_xmark (mk, im, ofx, ofy, fx, fy)
+
+pointer mk # pointer to the mark structure
+pointer im # pointer to the frame buffer image
+real ofx, ofy # first corner coordinates
+real fx, fy # second corner coordinates
+
+int ncols, nlines, x1, x2, y1, y2
+int mk_stati()
+
+begin
+ ncols = IM_LEN(im,1)
+ nlines = IM_LEN(im,2)
+
+ call mk_blimits (ofx, ofy, fx, fy, ncols, nlines, x1, x2, y1, y2)
+ call mk_pbox (im, x1, x2, y1, y2, mk_stati (mk, GRAYLEVEL))
+ call imflush (im)
+
+ #call mk_seti (mk, X1, x1)
+ #call mk_seti (mk, Y1, y1)
+ #call mk_seti (mk, X2, x2)
+ #call mk_seti (mk, Y2, y2)
+end
diff --git a/pkg/images/tv/tvmark/mkoutname.x b/pkg/images/tv/tvmark/mkoutname.x
new file mode 100644
index 00000000..a4ec4f22
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkoutname.x
@@ -0,0 +1,273 @@
+# MK_OUTNAME -- Procedure to construct an daophot output file name.
+# If output is null or a directory a name is constructed from the root
+# of the image name and the extension. The disk is searched to avoid
+# name collisions.
+#
+#procedure mk_outname (image, output, ext, name, maxch)
+#
+#char image[ARB] # image name
+#char output[ARB] # output directory or name
+#char ext[ARB] # extension
+#char name[ARB] # output name
+#int maxch # maximum size of name
+#
+#int ndir
+#pointer sp, root
+#int fnldir(), strlen(), mk_imroot()
+#
+#begin
+# call smark (sp)
+# call salloc (root, SZ_FNAME, TY_CHAR)
+# call imgimage (image, Memc[root], maxch)
+#
+# ndir = fnldir (output, name, maxch)
+# if (strlen (output) == ndir) {
+# ndir = ndir + mk_imroot (Memc[root], name[ndir+1], maxch)
+# call sprintf (name[ndir+1], maxch, ".%s.*")
+# call pargstr (ext)
+# call mk_version (name, name, maxch)
+# } else
+# call strcpy (output, name, maxch)
+#
+# call sfree (sp)
+#end
+
+
+# MK_IMROOT -- Procedure to fetch the root image name minus the directory
+# specification and the section notation. The length of the root name is
+# returned.
+#
+#int procedure mk_imroot (image, root, maxch)
+#
+#char image[ARB] # image specification
+#char root[ARB] # rootname
+#int maxch # maximum number of characters
+#
+#int nchars
+#pointer sp, str
+#int fnldir(), strlen()
+#
+#begin
+# call smark (sp)
+# call salloc (str, SZ_FNAME, TY_CHAR)
+#
+# call imgimage (image, root, maxch)
+# nchars = fnldir (root, Memc[str], maxch)
+# call strcpy (root[nchars+1], root, maxch)
+#
+# call sfree (sp)
+# return (strlen (root))
+#end
+
+
+# MK_VERSION -- Routine to compute the next available version number of a given
+# file name template and output the new files name.
+#
+#procedure mk_version (template, filename, maxch)
+#
+#char template[ARB] # name template
+#char filename[ARB] # output name
+#int maxch # maximum number of characters
+#
+#char period
+#int newversion, version, len, ip
+#pointer sp, list, name
+#int fntgfnb() strldx(), ctoi()
+#pointer fntopnb()
+#
+#begin
+# # Allocate temporary space
+# call smark (sp)
+# call salloc (name, maxch, TY_CHAR)
+# period = '.'
+# list = fntopnb (template, NO)
+# len = strldx (period, template)
+#
+# # Loop over the names in the list searchng for the highest version.
+# newversion = 0
+# while (fntgfnb (list, Memc[name], maxch) != EOF) {
+# len = strldx (period, Memc[name])
+# ip = len + 1
+# if (ctoi (Memc[name], ip, version) <= 0)
+# next
+# newversion = max (newversion, version)
+# }
+#
+# # Make new output file name.
+# call strcpy (template, filename, len)
+# call sprintf (filename[len+1], maxch, "%d")
+# call pargi (newversion + 1)
+#
+# call fntclsb (list)
+# call sfree (sp)
+#end
+
+
+# MK_IMNAME -- Procedure to construct an output image name.
+# If output is null or a directory a name is constructed from the root
+# of the image name and the extension. The disk is searched to avoid
+# name collisions.
+
+procedure mk_imname (image, output, ext, name, maxch)
+
+char image[ARB] # image name
+char output[ARB] # output directory or name
+char ext[ARB] # extension
+char name[ARB] # output name
+int maxch # maximum size of name
+
+int ndir, nimdir, clindex, clsize
+pointer sp, root, str
+int fnldir(), strlen()
+
+begin
+ call smark (sp)
+ call salloc (root, SZ_FNAME, TY_CHAR)
+ call salloc (str, SZ_FNAME, TY_CHAR)
+
+ ndir = fnldir (output, name, maxch)
+ if (strlen (output) == ndir) {
+ call imparse (image, Memc[root], SZ_FNAME, Memc[str], SZ_FNAME,
+ Memc[str], SZ_FNAME, clindex, clsize)
+ nimdir = fnldir (Memc[root], Memc[str], SZ_FNAME)
+ if (clindex >= 0) {
+ call sprintf (name[ndir+1], maxch, "%s%d.%s.*")
+ call pargstr (Memc[root+nimdir])
+ call pargi (clindex)
+ call pargstr (ext)
+ } else {
+ call sprintf (name[ndir+1], maxch, "%s.%s.*")
+ call pargstr (Memc[root+nimdir])
+ call pargstr (ext)
+ }
+ call mk_oimversion (name, name, maxch)
+ } else
+ call strcpy (output, name, maxch)
+
+ call sfree (sp)
+end
+
+
+# MK_OIMVERSION -- Routine to compute the next available version number of
+# a given file name template and output the new files name.
+
+procedure mk_oimversion (template, filename, maxch)
+
+char template[ARB] # name template
+char filename[ARB] # output name
+int maxch # maximum number of characters
+
+char period
+int newversion, version, len
+pointer sp, list, name
+int imtopen(), imtgetim(), strldx(), ctoi()
+
+begin
+ # Allocate temporary space
+ call smark (sp)
+ call salloc (name, maxch, TY_CHAR)
+ period = '.'
+ list = imtopen (template)
+
+ # Loop over the names in the list searchng for the highest version.
+ newversion = 0
+ while (imtgetim (list, Memc[name], maxch) != EOF) {
+ len = strldx (period, Memc[name])
+ Memc[name+len-1] = EOS
+ len = strldx (period, Memc[name])
+ len = len + 1
+ if (ctoi (Memc[name], len, version) <= 0)
+ next
+ newversion = max (newversion, version)
+ }
+
+ # Make new output file name.
+ len = strldx (period, template)
+ call strcpy (template, filename, len)
+ call sprintf (filename[len+1], maxch, "%d")
+ call pargi (newversion + 1)
+
+ call imtclose (list)
+ call sfree (sp)
+end
+
+
+
+# MK_IMNAME -- Procedure to construct an daophot output image name.
+# If output is null or a directory a name is constructed from the root
+# of the image name and the extension. The disk is searched to avoid
+# name collisions.
+#
+#procedure mk_imname (image, output, ext, name, maxch)
+#
+#char image[ARB] # image name
+#char output[ARB] # output directory or name
+#char ext[ARB] # extension
+#char name[ARB] # output name
+#int maxch # maximum size of name
+#
+#int ndir
+#pointer sp, root
+#int fnldir(), strlen(), mk_imroot()
+#
+#begin
+# call smark (sp)
+# call salloc (root, SZ_FNAME, TY_CHAR)
+# call imgimage (image, Memc[root], maxch)
+#
+# ndir = fnldir (output, name, maxch)
+# if (strlen (output) == ndir) {
+# ndir = ndir + mk_imroot (Memc[root], name[ndir+1], maxch)
+# call sprintf (name[ndir+1], maxch, ".%s.*")
+# call pargstr (ext)
+# call mk_imversion (name, name, maxch)
+# } else
+# call strcpy (output, name, maxch)
+#
+# call sfree (sp)
+#end
+
+
+# MK_VERSION -- Routine to compute the next available version number of a given
+# file name template and output the new files name.
+#
+#procedure mk_imversion (template, filename, maxch)
+#
+#char template[ARB] # name template
+#char filename[ARB] # output name
+#int maxch # maximum number of characters
+#
+#char period
+#int newversion, version, len, ip
+#pointer sp, list, name
+#int fntgfnb() strldx(), ctoi()
+#pointer fntopnb()
+#
+#begin
+# # Allocate temporary space
+# call smark (sp)
+# call salloc (name, maxch, TY_CHAR)
+# period = '.'
+# list = fntopnb (template, NO)
+# len = strldx (period, template)
+#
+# # Loop over the names in the list searchng for the highest version.
+# newversion = 0
+# while (fntgfnb (list, Memc[name], maxch) != EOF) {
+# len = strldx (period, Memc[name])
+# Memc[name+len-1] = EOS
+# len = strldx (period, Memc[name])
+# ip = len + 1
+# if (ctoi (Memc[name], ip, version) <= 0)
+# next
+# newversion = max (newversion, version)
+# }
+#
+# # Make new output file name.
+# call strcpy (template, filename, len)
+# call sprintf (filename[len+1], maxch, "%d")
+# call pargi (newversion + 1)
+#
+# call fntclsb (list)
+# call sfree (sp)
+#end
diff --git a/pkg/images/tv/tvmark/mkpkg b/pkg/images/tv/tvmark/mkpkg
new file mode 100644
index 00000000..0fb0af3b
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkpkg
@@ -0,0 +1,27 @@
+# Make the TVMARK package
+
+$checkout libpkg.a ../
+$update libpkg.a
+$checkin libpkg.a ../
+$exit
+
+
+libpkg.a:
+ mkbmark.x "tvmark.h" <imhdr.h>
+ mkcolon.x "tvmark.h" <imhdr.h> <fset.h> <error.h>
+ mkgmarks.x <ctype.h> <lexnum.h>
+ mkgpars.x <ctype.h> "tvmark.h"
+ mkgscur.x <gset.h> <fset.h>
+ mkremove.x
+ mkfind.x <mach.h>
+ mkppars.x <ctype.h> "tvmark.h"
+ mkmag.x <imhdr.h>
+ mkmark.x <imhdr.h> <fset.h> "tvmark.h"
+ mknew.x
+ mkonemark.x <imhdr.h> "tvmark.h"
+ mkoutname.x
+ mkshow.x "tvmark.h"
+ mktext.x "pixelfont.inc" "asciilook.inc" <imhdr.h> <mach.h>
+ mktools.x <ctype.h> "tvmark.h"
+ t_tvmark.x <imhdr.h> <imset.h> <fset.h> <gset.h> "tvmark.h"
+ ;
diff --git a/pkg/images/tv/tvmark/mkppars.x b/pkg/images/tv/tvmark/mkppars.x
new file mode 100644
index 00000000..16fdf8c5
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkppars.x
@@ -0,0 +1,40 @@
+include <ctype.h>
+include "tvmark.h"
+
+# MK_PPARS -- Store the IMMARK parameters.
+
+procedure mk_ppars (mk)
+
+pointer mk # pointer to the immark structure
+
+pointer sp, str
+bool itob()
+int mk_stati()
+real mk_statr()
+
+begin
+ # Allocate working space.
+ call smark (sp)
+ call salloc (str, SZ_LINE, TY_CHAR)
+
+ # Store the mark type.
+ call mk_stats (mk, MARK, Memc[str], SZ_LINE)
+ call clpstr ("mark", Memc[str])
+
+ # Store the circle and rectangles descriptors.
+ call mk_stats (mk, CSTRING, Memc[str], SZ_LINE)
+ call clpstr ("radii", Memc[str])
+ call mk_stats (mk, RSTRING, Memc[str], SZ_LINE)
+ call clpstr ("lengths", Memc[str])
+
+ call clputb ("number", itob (mk_stati (mk, NUMBER)))
+ call clputb ("label", itob (mk_stati (mk, LABEL)))
+ call clputi ("txsize", mk_stati (mk, SIZE))
+ call clputi ("pointsize", 2 * mk_stati (mk, SZPOINT) + 1)
+ call clputi ("color", mk_stati (mk, GRAYLEVEL))
+ call clputi ("nxoffset", mk_stati (mk, NXOFFSET))
+ call clputi ("nyoffset", mk_stati (mk, NYOFFSET))
+ call clputr ("tolerance", mk_statr (mk, TOLERANCE))
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/tvmark/mkremove.x b/pkg/images/tv/tvmark/mkremove.x
new file mode 100644
index 00000000..589fc039
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkremove.x
@@ -0,0 +1,98 @@
+# MK_REMOVE -- Check the deletions for uniqueness and delete unwanted objects
+# from the coordinates file.
+
+procedure mk_remove (coords, deletions, cl, dl, ndelete)
+
+char coords[ARB] # coordinate file name
+char deletions[ARB] # deletions file name
+int cl # coordinate file descriptor
+int dl # deletions file descriptor
+int ndelete # number of deletions
+
+int i, ndel, nobj, obj, tcl, tdl, stat
+pointer sp, id, tclname, tdlname, line
+real xval, yval
+int fscan(), nscan(), open(), getline()
+
+begin
+ call smark (sp)
+ call salloc (id, ndelete, TY_INT)
+ call salloc (tclname, SZ_FNAME, TY_CHAR)
+ call salloc (tdlname, SZ_FNAME, TY_CHAR)
+ call salloc (line, SZ_LINE, TY_CHAR)
+
+ # Rewind both files to the beginning.
+ call seek (cl, BOF)
+ call seek (dl, BOF)
+
+ # Read in the ids of objects to be deleted.
+ ndel = 0
+ while (fscan (dl) != EOF) {
+ call gargi (Memi[id+ndel])
+ ndel = ndel + 1
+ }
+
+ # Sort the id numbers.
+ call asrti (Memi[id], Memi[id], ndelete)
+
+ # Remove id numbers that are not unique.
+ ndel = 1
+ do i = 2, ndelete {
+ if (Memi[id+i-1] == Memi[id+i-2])
+ next
+ ndel = ndel + 1
+ Memi[id+ndel-1] = Memi[id+i-1]
+ }
+
+ # Open two temporary files.
+ call mktemp ("tcl", Memc[tclname], SZ_FNAME)
+ call mktemp ("tdl", Memc[tdlname], SZ_FNAME)
+ tcl = open (Memc[tclname], NEW_FILE, TEXT_FILE)
+ tdl = open (Memc[tdlname], NEW_FILE, TEXT_FILE)
+
+ nobj = 0
+ do i = 1, ndel {
+
+ obj = Memi[id+i-1]
+
+ repeat {
+
+ stat = getline (cl, Memc[line])
+ if (stat == EOF)
+ break
+
+ call sscan (Memc[line])
+ call gargr (xval)
+ call gargr (yval)
+ if (nscan () < 2) {
+ call putline (tcl, Memc[line])
+ next
+ }
+
+ nobj = nobj + 1
+ if (nobj < obj)
+ call putline (tcl, Memc[line])
+ else
+ call putline (tdl, Memc[line])
+
+ } until (nobj >= obj)
+ }
+
+ # Copy the remainder of the file.
+ while (getline (cl, Memc[line]) != EOF)
+ call putline (tcl, Memc[line])
+
+ # Cleanup the coords file.
+ call close (cl)
+ call close (tcl)
+ call delete (coords)
+ call rename (Memc[tclname], coords)
+
+ # Cleanup the delete file.
+ call close (dl)
+ call close (tdl)
+ call delete (deletions)
+ call rename (Memc[tdlname], deletions)
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/tvmark/mkshow.x b/pkg/images/tv/tvmark/mkshow.x
new file mode 100644
index 00000000..cd48992b
--- /dev/null
+++ b/pkg/images/tv/tvmark/mkshow.x
@@ -0,0 +1,95 @@
+include "tvmark.h"
+
+# MK_SHOW -- Procedure to show the immark parameters
+
+procedure mk_show (mk)
+
+pointer mk # pointer to the immark structure
+
+pointer sp, str
+bool itob()
+int mk_stati()
+real mk_statr()
+
+begin
+ call smark (sp)
+ call salloc (str, SZ_FNAME, TY_CHAR)
+
+ # Print a blank line.
+ call printf ("\n")
+
+ # Print the frame info.
+ call printf ("%s: %d %s: %s\n")
+ call pargstr (KY_FRAME)
+ call pargi (mk_stati (mk, FRAME))
+ call pargstr (KY_COORDS)
+ call mk_stats (mk, COORDS, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+
+ # Print the output info.
+ call printf (" %s: %s %s: %s %s: %b\n")
+ call pargstr (KY_OUTIMAGE)
+ call mk_stats (mk, OUTIMAGE, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+ call mk_stats (mk, LOGFILE, Memc[str], SZ_FNAME)
+ call pargstr (KY_LOGFILE)
+ call pargstr (Memc[str])
+ call pargstr (KY_AUTOLOG)
+ call pargb (itob (mk_stati (mk, AUTOLOG)))
+
+ # Print the deletions file info.
+ call printf (" %s: %s %s: %g\n")
+ call pargstr (KY_DELETIONS)
+ call mk_stats (mk, DELETIONS, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+ call pargstr (KY_TOLERANCE)
+ call pargr (mk_statr (mk, TOLERANCE))
+
+ # Print the font info.
+ call printf (" %s: %s %s: %d\n")
+ call pargstr (KY_FONT)
+ call mk_stats (mk, FONT, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+ call pargstr (KY_GRAYLEVEL)
+ call pargi (mk_stati (mk, GRAYLEVEL))
+
+ # Print the mark type info.
+ call printf (" %s: %s ")
+ call pargstr (KY_MARK)
+ call mk_stats (mk, MARK, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+
+ call printf ("%s: %s ")
+ call pargstr (KY_CIRCLES)
+ call mk_stats (mk, CSTRING, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+
+ call printf ("%s: %s %g\n")
+ call pargstr (KY_RECTANGLE)
+ call mk_stats (mk, RSTRING, Memc[str], SZ_FNAME)
+ call pargstr (Memc[str])
+ call pargr (mk_statr (mk, RATIO))
+
+ call printf (" %s: %d %s: %d\n")
+ call pargstr (KY_SZPOINT)
+ call pargi (2 * mk_stati (mk, SZPOINT) + 1)
+ call pargstr (KY_SIZE)
+ call pargi (mk_stati (mk, SIZE))
+
+ call printf (" %s: %b ")
+ call pargstr (KY_LABEL)
+ call pargb (itob (mk_stati (mk, LABEL)))
+ call printf ("%s: %b ")
+ call pargstr (KY_NUMBER)
+ call pargb (itob (mk_stati (mk, NUMBER)))
+ call printf (" %s: %d %s: %d\n")
+ call pargstr (KY_NXOFFSET)
+ call pargi (mk_stati (mk, NXOFFSET))
+ call pargstr (KY_NYOFFSET)
+ call pargi (mk_stati (mk, NYOFFSET))
+
+ # Print a blank line.
+ call printf ("\n")
+
+ call sfree (sp)
+end
diff --git a/pkg/images/tv/tvmark/mktext.x b/pkg/images/tv/tvmark/mktext.x
new file mode 100644
index 00000000..06a99b37
--- /dev/null
+++ b/pkg/images/tv/tvmark/mktext.x
@@ -0,0 +1,164 @@
+include <mach.h>
+include <imhdr.h>
+
+define FONTWIDE 6
+define FONTHIGH 7
+define SZ_LOOKUP 128
+define SZ_FONT 455
+define SZ_PIXARY 5
+
+# MK_TEXTIM -- Write a text string into an image using a pixel font for speed.
+# Characters are made twice as big as the font by doubling in both axes.
+
+procedure mk_textim (im, s, x, y, xmag, ymag, value, center)
+
+pointer im # image to put the text in.
+char s[ARB] # text to put in the image.
+int x, y # x, y position in the image.
+int xmag, ymag # x, y magnification values.
+int value # value to use in image for text.
+int center # center the string
+
+int numrow, numcol, numchars, fonthigh, fontwide, xinit, yinit
+int i, l, ch, nchar, line, ip, pixary[SZ_PIXARY]
+pointer lineget, lineput
+
+int strlen()
+pointer imgl2s(), impl2s()
+errchk imgl2s, impl2s
+
+begin
+ # Find the length of the string.
+ numchars = strlen (s)
+ if (numchars <= 0)
+ return
+
+ # Calculate height and width of magnified font.
+ fonthigh = FONTHIGH * ymag
+ fontwide = FONTWIDE * xmag
+
+ # Check for row/col out of bounds.
+ numcol= IM_LEN(im,1)
+ numrow = IM_LEN(im,2)
+
+ # Compute the initial position of the string truncating characters
+ # is necessary.
+ if (center == YES)
+ xinit = x - fontwide * numchars / 2
+ else
+ xinit = x
+ for (ip = 1; ip <= numchars; ip = ip + 1) {
+ if (xinit >= 1)
+ break
+ xinit = xinit + fontwide
+ }
+
+ # Return if beginning of string is off image.
+ if (xinit < 1 || xinit > numcol)
+ return
+
+ # Truncate the string.
+ if (xinit > numcol - fontwide * (numchars - ip + 1)) {
+ numchars = int ((numcol - xinit) / fontwide)
+ if (numchars <= 0)
+ return
+ }
+
+ # Return if the text does not fit in the image.
+ if (center == YES)
+ yinit = y - fonthigh * numchars / 2
+ else
+ yinit = y
+ if ((yinit <= 0) || (yinit > numrow - fonthigh))
+ return
+
+ # For each line of the text (backward).
+ for (i = 1; i <= 7; i = i + 1) {
+
+ line = yinit + (i-1) * ymag
+
+ do l = 1, ymag {
+
+ # Get and put the line of the image.
+ lineput = impl2s (im, line+(l-1))
+ lineget = imgl2s (im, line+(l-1))
+ call amovs (Mems[lineget], Mems[lineput], numcol)
+
+ # Put out the font.
+ do ch = ip, numchars {
+ nchar = int (s[ch])
+ call mk_pixbit (nchar, 8 - i, pixary)
+ call mk_putpix (pixary, Mems[lineput], numcol,
+ xinit+(ch-1)*fontwide, value, xmag)
+ }
+
+ }
+ }
+end
+
+
+# MK_PIXBIT -- Look up which bits should be set for this character on this line.
+
+procedure mk_pixbit (code, line, bitarray)
+
+int code # character we are writing
+int line # line of the character we are writing
+int bitarray[ARB] # bit-array to receive data
+
+int pix, i
+short asciilook[SZ_LOOKUP], font[SZ_FONT]
+int bitupk()
+
+include "pixelfont.inc"
+include "asciilook.inc"
+
+begin
+ pix = font[asciilook[code+1]+line-1]
+ bitarray[5] = bitupk (pix, 1, 1)
+ bitarray[4] = bitupk (pix, 4, 1)
+ bitarray[3] = bitupk (pix, 7, 1)
+ bitarray[2] = bitupk (pix, 10, 1)
+ bitarray[1] = bitupk (pix, 13, 1)
+end
+
+
+# MK_PUTPIX -- Put one line of one character into the data array.
+
+procedure mk_putpix (pixary, array, size, position, value, xmag)
+
+int pixary[ARB] # array of pixels in character
+int size, position # size of data array
+short array[size] # data array in which to put character line
+int value # value to use for character pixels
+int xmag # x-magnification of text
+
+int i, k, x
+
+begin
+ do i = 1, 5 {
+ if (pixary[i] == 1) {
+ x = position + (i-1) * xmag
+ do k = 1, xmag
+ array[x+(k-1)] = value
+ }
+ }
+end
+
+
+# MK_TLIMITS -- Compute the column and line limits of a text string.
+
+procedure mk_tlimits (str, x, y, xmag, ymag, ncols, nlines, x1, x2, y1, y2)
+
+char str[ARB] # string to be written to the image
+int x, y # starting position of the string
+int xmag, ymag # magnification factor
+int ncols, nlines # dimensions of the image
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+begin
+ x1 = max (1, min (y, ncols))
+ x2 = min (ncols, max (1, y + 5 * xmag))
+ y1 = max (1, min (y, nlines))
+ y2 = min (nlines, max (1, y + 6 * ymag))
+end
diff --git a/pkg/images/tv/tvmark/mktools.x b/pkg/images/tv/tvmark/mktools.x
new file mode 100644
index 00000000..33f1424b
--- /dev/null
+++ b/pkg/images/tv/tvmark/mktools.x
@@ -0,0 +1,505 @@
+include <ctype.h>
+include "tvmark.h"
+
+# MK_INIT -- Procedure to initialize the image marking code.
+
+procedure mk_init (mk)
+
+pointer mk # pointer to immark structure
+
+begin
+ call malloc (mk, LEN_MARKSTRUCT, TY_STRUCT)
+
+ # Initialize the mark type parameters.
+ MK_MARK(mk) = EOS
+ MK_CSTRING(mk) = EOS
+ MK_RSTRING(mk) = EOS
+ MK_MKTYPE(mk) = 0
+ MK_NCIRCLES(mk) = 0
+ MK_NELLIPSES(mk) = 0
+ MK_NSQUARES(mk) = 0
+ MK_NRECTANGLES(mk) = 0
+ MK_NXOFFSET(mk) = 0
+ MK_NYOFFSET(mk) = 0
+
+ # Initialize the mark shape parameters.
+ MK_RATIO(mk) = 1.0
+ MK_ELLIPTICITY(mk) = 0.0
+ MK_RTHETA(mk) = 0.0
+ MK_ETHETA(mk) = 0.0
+
+ # Initialize the pointers.
+ MK_RADII(mk) = NULL
+ MK_AXES(mk) = NULL
+ MK_SLENGTHS(mk) = NULL
+ MK_RLENGTHS(mk) = NULL
+
+ MK_X1(mk) = INDEFI
+ MK_Y1(mk) = INDEFI
+ MK_X2(mk) = INDEFI
+ MK_Y2(mk) = INDEFI
+
+ # Initialize actual drawing parameters.
+ MK_NUMBER(mk) = NO
+ MK_LABEL(mk) = NO
+ MK_FONT(mk) = EOS
+ MK_GRAYLEVEL(mk) = 0
+ MK_SIZE(mk) = 1
+ MK_SZPOINT(mk) = 1
+
+ # Initialize file parameters strings.
+ MK_IMAGE(mk) = EOS
+ MK_OUTIMAGE(mk) = EOS
+ MK_COORDS(mk) = EOS
+ MK_DELETIONS(mk) = EOS
+ MK_LOGFILE(mk) = EOS
+ MK_AUTOLOG(mk) = NO
+
+ # Initilize the display command parameters.
+ MK_FRAME(mk) = 1
+ MK_TOLERANCE(mk) = 1.0
+
+ # Initialize the buffers.
+ call mk_rinit (mk)
+end
+
+
+# MK_RINIT -- Procedure to initialize the immark structure.
+
+procedure mk_rinit (mk)
+
+pointer mk # pointer to immark structure
+
+begin
+ call mk_rfree (mk)
+ call malloc (MK_RADII(mk), MAX_NMARKS, TY_REAL)
+ call malloc (MK_AXES(mk), MAX_NMARKS, TY_REAL)
+ call malloc (MK_SLENGTHS(mk), MAX_NMARKS, TY_REAL)
+ call malloc (MK_RLENGTHS(mk), MAX_NMARKS, TY_REAL)
+end
+
+
+# MK_INDEFR -- Procedure to reinitialize the size dependent buffers.
+
+procedure mk_indefr (mk)
+
+pointer mk # pointer to immark
+
+int ncircles, nsquares, nellipses, nrectangles
+int mk_stati()
+
+begin
+ ncircles = mk_stati (mk, NCIRCLES)
+ nellipses = mk_stati (mk, NELLIPSES)
+ nsquares = mk_stati (mk, NSQUARES)
+ nrectangles = mk_stati (mk, NRECTANGLES)
+
+ if (ncircles > 0)
+ call amovkr (INDEFR, Memr[MK_RADII(mk)], ncircles)
+ if (nellipses > 0)
+ call amovkr (INDEFR, Memr[MK_AXES(mk)], nellipses)
+ if (nsquares > 0)
+ call amovkr (INDEFR, Memr[MK_SLENGTHS(mk)], nsquares)
+ if (nrectangles > 0)
+ call amovkr (INDEFR, Memr[MK_RLENGTHS(mk)], nrectangles)
+
+end
+
+
+# MK_REALLOC -- Procedure to reallocate regions buffers.
+
+procedure mk_realloc (mk, ncircles, nellipses, nsquares, nrectangles)
+
+pointer mk # pointer to immark structure
+int ncircles # number of circles
+int nellipses # number of ellipses
+int nsquares # number of squares
+int nrectangles # number of rectangles
+
+int nc, ne, ns, nr
+int mk_stati()
+
+begin
+ if (ncircles > 0)
+ call realloc (MK_RADII(mk), ncircles, TY_REAL)
+ else {
+ call mfree (MK_RADII(mk), TY_REAL)
+ MK_RADII(mk) = NULL
+ }
+
+ if (nellipses > 0)
+ call realloc (MK_AXES(mk), nellipses, TY_REAL)
+ else {
+ call mfree (MK_AXES(mk), TY_REAL)
+ MK_AXES(mk) = NULL
+ }
+
+ if (nsquares > 0)
+ call realloc (MK_SLENGTHS(mk), nsquares, TY_REAL)
+ else {
+ call mfree (MK_SLENGTHS(mk), TY_REAL)
+ MK_SLENGTHS(mk) = NULL
+ }
+
+ if (nrectangles > 0)
+ call realloc (MK_RLENGTHS(mk), nrectangles, TY_REAL)
+ else {
+ call mfree (MK_RLENGTHS(mk), TY_REAL)
+ MK_RLENGTHS(mk) = NULL
+ }
+
+ nc = mk_stati (mk, NCIRCLES)
+ ne = mk_stati (mk, NELLIPSES)
+ ns = mk_stati (mk, NSQUARES)
+ nr = mk_stati (mk, NRECTANGLES)
+
+ if (ncircles > nc)
+ call amovkr (INDEFR, Memr[MK_RADII(mk)+nc], ncircles - nc)
+ if (nellipses > ne)
+ call amovkr (INDEFR, Memr[MK_AXES(mk)+ne], nellipses - ne)
+ if (nsquares > ns)
+ call amovkr (INDEFR, Memr[MK_SLENGTHS(mk)+ns], nsquares - ns)
+ if (nrectangles > nr)
+ call amovkr (INDEFR, Memr[MK_RLENGTHS(mk)+nr], nrectangles - nr)
+end
+
+
+# MK_FREE -- Procedure to free the immark structure.
+
+procedure mk_free (mk)
+
+pointer mk # pointer to immark structure
+
+begin
+ call mk_rfree (mk)
+ call mfree (mk, TY_STRUCT)
+end
+
+
+# MK_RFREE -- Procedure to free the regions portion of the immark structure.
+
+procedure mk_rfree (mk)
+
+pointer mk # pointer to immark structure
+
+begin
+ if (MK_RADII(mk) != NULL)
+ call mfree (MK_RADII(mk), TY_REAL)
+ MK_RADII(mk) = NULL
+ if (MK_AXES(mk) != NULL)
+ call mfree (MK_AXES(mk), TY_REAL)
+ MK_AXES(mk) = NULL
+ if (MK_SLENGTHS(mk) != NULL)
+ call mfree (MK_SLENGTHS(mk), TY_REAL)
+ MK_SLENGTHS(mk) = NULL
+ if (MK_RLENGTHS(mk) != NULL)
+ call mfree (MK_RLENGTHS(mk), TY_REAL)
+ MK_RLENGTHS(mk) = NULL
+end
+
+
+# MK_STATI -- Procedure to fetch the value of an immark integer parameter.
+
+int procedure mk_stati (mk, param)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+
+begin
+ switch (param) {
+ case AUTOLOG:
+ return (MK_AUTOLOG(mk))
+ case NUMBER:
+ return (MK_NUMBER(mk))
+ case LABEL:
+ return (MK_LABEL(mk))
+ case GRAYLEVEL:
+ return (MK_GRAYLEVEL(mk))
+ case SIZE:
+ return (MK_SIZE(mk))
+ case SZPOINT:
+ return (MK_SZPOINT(mk))
+ case FRAME:
+ return (MK_FRAME(mk))
+ case NCIRCLES:
+ return (MK_NCIRCLES(mk))
+ case NELLIPSES:
+ return (MK_NELLIPSES(mk))
+ case NSQUARES:
+ return (MK_NSQUARES(mk))
+ case NRECTANGLES:
+ return (MK_NRECTANGLES(mk))
+ case MKTYPE:
+ return (MK_MKTYPE(mk))
+ case X1:
+ return (MK_X1(mk))
+ case Y1:
+ return (MK_Y1(mk))
+ case X2:
+ return (MK_X2(mk))
+ case Y2:
+ return (MK_Y2(mk))
+ case NXOFFSET:
+ return (MK_NXOFFSET(mk))
+ case NYOFFSET:
+ return (MK_NYOFFSET(mk))
+ default:
+ call error (0, "MK_STATI: Unknown integer parameter.")
+ }
+end
+
+
+# MK_STATP -- Procedure to fetch the value of a pointer parameter.
+
+pointer procedure mk_statp (mk, param)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+
+begin
+ switch (param) {
+ case RADII:
+ return (MK_RADII(mk))
+ case AXES:
+ return (MK_AXES(mk))
+ case SLENGTHS:
+ return (MK_SLENGTHS(mk))
+ case RLENGTHS:
+ return (MK_RLENGTHS(mk))
+ default:
+ call error (0, "MK_STATP: Unknown pointer parameter.")
+ }
+end
+
+
+# MK_STATR -- Procedure to fetch the value of a real parameter.
+
+real procedure mk_statr (mk, param)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+
+begin
+ switch (param) {
+ case RATIO:
+ return (MK_RATIO(mk))
+ case ELLIPTICITY:
+ return (MK_ELLIPTICITY(mk))
+ case RTHETA:
+ return (MK_RTHETA(mk))
+ case ETHETA:
+ return (MK_ETHETA(mk))
+ case TOLERANCE:
+ return (MK_TOLERANCE(mk))
+ default:
+ call error (0, "MK_STATR: Unknown real parameter.")
+ }
+end
+
+
+# MK_STATS -- Procedure to fetch the value of a string parameter.
+
+procedure mk_stats (mk, param, str, maxch)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+char str[ARB] # output string
+int maxch # maximum number of characters
+
+begin
+ switch (param) {
+ case IMAGE:
+ call strcpy (MK_IMAGE(mk), str, maxch)
+ case OUTIMAGE:
+ call strcpy (MK_OUTIMAGE(mk), str, maxch)
+ case COORDS:
+ call strcpy (MK_COORDS(mk), str, maxch)
+ case DELETIONS:
+ call strcpy (MK_DELETIONS(mk), str, maxch)
+ case LOGFILE:
+ call strcpy (MK_LOGFILE(mk), str, maxch)
+ case FONT:
+ call strcpy (MK_FONT(mk), str, maxch)
+ case MARK:
+ call strcpy (MK_MARK(mk), str, maxch)
+ case CSTRING:
+ call strcpy (MK_CSTRING(mk), str, maxch)
+ case RSTRING:
+ call strcpy (MK_RSTRING(mk), str, maxch)
+ default:
+ call error (0, "MK_STATS: Unknown string parameter.")
+ }
+end
+
+
+# MK_SETI -- Procedure to set the value of an integer parameter.
+
+procedure mk_seti (mk, param, value)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+int value # value of the integer parameter
+
+begin
+ switch (param) {
+ case AUTOLOG:
+ MK_AUTOLOG(mk) = value
+ case NUMBER:
+ MK_NUMBER(mk) = value
+ case LABEL:
+ MK_LABEL(mk) = value
+ case GRAYLEVEL:
+ MK_GRAYLEVEL(mk) = value
+ case SIZE:
+ MK_SIZE(mk) = value
+ case SZPOINT:
+ MK_SZPOINT(mk) = value
+ case FRAME:
+ MK_FRAME(mk) = value
+ case NCIRCLES:
+ MK_NCIRCLES(mk) = value
+ case NELLIPSES:
+ MK_NELLIPSES(mk) = value
+ case NSQUARES:
+ MK_NSQUARES(mk) = value
+ case NRECTANGLES:
+ MK_NRECTANGLES(mk) = value
+ case MKTYPE:
+ MK_MKTYPE(mk) = value
+ case X1:
+ MK_X1(mk) = value
+ case Y1:
+ MK_Y1(mk) = value
+ case X2:
+ MK_X2(mk) = value
+ case Y2:
+ MK_Y2(mk) = value
+ case NXOFFSET:
+ MK_NXOFFSET(mk) = value
+ case NYOFFSET:
+ MK_NYOFFSET(mk) = value
+ default:
+ call error (0, "MK_SETI: Unknown integer parameter.")
+ }
+end
+
+
+# MK_SETP -- Procedure to set the value of a pointer parameter.
+
+procedure mk_setp (mk, param, value)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+pointer value # value of the pointer parameter
+
+begin
+ switch (param) {
+ case RADII:
+ MK_RADII(mk) = value
+ case AXES:
+ MK_AXES(mk) = value
+ case SLENGTHS:
+ MK_SLENGTHS(mk) = value
+ case RLENGTHS:
+ MK_RLENGTHS(mk) = value
+ default:
+ call error (0, "MK_SETP: Unknown pointer parameter.")
+ }
+end
+
+
+# MK_SETR -- Procedure to set the value of a real parameter.
+
+procedure mk_setr (mk, param, value)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+real value # real parameter
+
+begin
+ switch (param) {
+ case RATIO:
+ MK_RATIO(mk) = value
+ case ELLIPTICITY:
+ MK_ELLIPTICITY(mk) = value
+ case RTHETA:
+ MK_RTHETA(mk) = value
+ case ETHETA:
+ MK_ETHETA(mk) = value
+ case TOLERANCE:
+ MK_TOLERANCE(mk) = value
+ default:
+ call error (0, "MK_SETR: Unknown real parameter.")
+ }
+end
+
+
+# MK_SETS -- Procedure to set the value of a string parameter.
+
+procedure mk_sets (mk, param, str)
+
+pointer mk # pointer to immark structure
+int param # parameter to be fetched
+char str[ARB] # output string
+
+int rp, ntemp
+pointer sp, rtemp
+int fnldir(), mk_gmarks()
+
+begin
+ switch (param) {
+ case IMAGE:
+ call strcpy (str, MK_IMAGE(mk), SZ_FNAME)
+
+ case OUTIMAGE:
+ call strcpy (str, MK_OUTIMAGE(mk), SZ_FNAME)
+
+ case COORDS:
+ rp = fnldir (str, MK_COORDS(mk), SZ_FNAME)
+ call strcpy (str[rp+1], MK_COORDS(mk), SZ_FNAME)
+
+ case DELETIONS:
+ rp = fnldir (str, MK_DELETIONS(mk), SZ_FNAME)
+ call strcpy (str[rp+1], MK_DELETIONS(mk), SZ_FNAME)
+
+ case LOGFILE:
+ rp = fnldir (str, MK_LOGFILE(mk), SZ_FNAME)
+ call strcpy (str[rp+1], MK_LOGFILE(mk), SZ_FNAME)
+
+ case FONT:
+ rp = fnldir (str, MK_FONT(mk), SZ_FNAME)
+ call strcpy (str[rp+1], MK_FONT(mk), SZ_FNAME)
+
+ case MARK:
+ call strcpy (str, MK_MARK(mk), SZ_FNAME)
+
+ case CSTRING:
+ call smark (sp)
+ call salloc (rtemp, MAX_NMARKS, TY_REAL)
+ ntemp = mk_gmarks (str, Memr[rtemp], MAX_NMARKS)
+ if (ntemp > 0) {
+ call strcpy (str, MK_CSTRING(mk), SZ_FNAME)
+ MK_NCIRCLES(mk) = ntemp
+ call realloc (MK_RADII(mk), ntemp, TY_REAL)
+ call amovr (Memr[rtemp], Memr[MK_RADII(mk)], ntemp)
+ call asrtr (Memr[MK_RADII(mk)], Memr[MK_RADII(mk)], ntemp)
+ }
+ call sfree (sp)
+
+ case RSTRING:
+ call smark (sp)
+ call salloc (rtemp, MAX_NMARKS, TY_REAL)
+ ntemp = mk_gmarks (str, Memr[rtemp], MAX_NMARKS)
+ if (ntemp > 0) {
+ call strcpy (str, MK_RSTRING(mk), SZ_FNAME)
+ MK_NRECTANGLES(mk) = ntemp
+ call realloc (MK_RLENGTHS(mk), ntemp, TY_REAL)
+ call amovr (Memr[rtemp], Memr[MK_RLENGTHS(mk)], ntemp)
+ call asrtr (Memr[MK_RLENGTHS(mk)], Memr[MK_RLENGTHS(mk)], ntemp)
+ }
+ call sfree (sp)
+
+ default:
+ call error (0, "MK_SETS: Unknown string parameter.")
+ }
+end
diff --git a/pkg/images/tv/tvmark/pixelfont.inc b/pkg/images/tv/tvmark/pixelfont.inc
new file mode 100644
index 00000000..92216e6d
--- /dev/null
+++ b/pkg/images/tv/tvmark/pixelfont.inc
@@ -0,0 +1,519 @@
+data (font[i], i=1,7) / 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B / # (space)
+
+data (font[i], i=8,14) / 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00000B,
+ 00100B / # !
+
+data (font[i], i=15,21) / 01010B,
+ 01010B,
+ 01010B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B / # "
+
+data (font[i], i=22,28) / 01010B,
+ 01010B,
+ 11111B,
+ 01010B,
+ 11111B,
+ 01010B,
+ 01010B / # #
+
+data (font[i], i=29,35) / 00100B,
+ 01111B,
+ 10100B,
+ 01110B,
+ 00101B,
+ 11110B,
+ 00100B / # $
+
+data (font[i], i=36,42) / 11000B,
+ 11001B,
+ 00010B,
+ 00100B,
+ 01000B,
+ 10011B,
+ 00011B / # %
+
+data (font[i], i=43,49) / 01000B,
+ 10100B,
+ 10100B,
+ 01000B,
+ 10101B,
+ 10010B,
+ 01101B / # &
+
+data (font[i], i=50,56) / 00100B,
+ 00100B,
+ 00100B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B / # '
+
+data (font[i], i=57,63) / 00100B,
+ 01000B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 01000B,
+ 00100B / # (
+
+data (font[i], i=64,70) / 00100B,
+ 00010B,
+ 00001B,
+ 00001B,
+ 00001B,
+ 00010B,
+ 00100B / # )
+
+data (font[i], i=71,77) / 00100B,
+ 10101B,
+ 01110B,
+ 00100B,
+ 01110B,
+ 10101B,
+ 00100B / # *
+
+data (font[i], i=78,84) / 00000B,
+ 00100B,
+ 00100B,
+ 11111B,
+ 00100B,
+ 00100B,
+ 00000B / # +
+
+data (font[i], i=85,91) / 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00100B,
+ 00100B,
+ 01000B / # ,
+
+data (font[i], i=92,98) / 00000B,
+ 00000B,
+ 00000B,
+ 11111B,
+ 00000B,
+ 00000B,
+ 00000B / # -
+
+data (font[i], i=99,105) / 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00100B / # .
+
+data (font[i], i=106,112) / 00000B,
+ 00001B,
+ 00010B,
+ 00100B,
+ 01000B,
+ 10000B,
+ 00000B / # /
+
+data (font[i], i=113,119) / 01110B,
+ 10001B,
+ 10011B,
+ 10101B,
+ 11001B,
+ 10001B,
+ 01110B / # 0
+
+data (font[i], i=120,126) / 00100B,
+ 01100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 01110B / # 1
+
+data (font[i], i=127,133) / 01110B,
+ 10001B,
+ 00001B,
+ 00110B,
+ 01000B,
+ 10000B,
+ 11111B / # 2
+
+data (font[i], i=134,140) / 11111B,
+ 00001B,
+ 00010B,
+ 00110B,
+ 00001B,
+ 10001B,
+ 11111B / # 3
+
+data (font[i], i=141,147) / 00010B,
+ 00110B,
+ 01010B,
+ 11111B,
+ 00010B,
+ 00010B,
+ 00010B / # 4
+
+data (font[i], i=148,154) / 11111B,
+ 10000B,
+ 11110B,
+ 00001B,
+ 00001B,
+ 10001B,
+ 01110B / # 5
+
+data (font[i], i=155,161) / 00111B,
+ 01000B,
+ 10000B,
+ 11110B,
+ 10001B,
+ 10001B,
+ 01110B / # 6
+
+data (font[i], i=162,168) / 11111B,
+ 00001B,
+ 00010B,
+ 00100B,
+ 01000B,
+ 01000B,
+ 01000B / # 7
+
+data (font[i], i=169,175) / 01110B,
+ 10001B,
+ 10001B,
+ 01110B,
+ 10001B,
+ 10001B,
+ 01110B / # 8
+
+data (font[i], i=176,182) / 01110B,
+ 10001B,
+ 10001B,
+ 01111B,
+ 00001B,
+ 00010B,
+ 11100B / # 9
+
+data (font[i], i=183,189) / 00000B,
+ 00000B,
+ 00100B,
+ 00000B,
+ 00100B,
+ 00000B,
+ 00000B / # :
+
+data (font[i], i=190,196) / 00000B,
+ 00000B,
+ 00100B,
+ 00000B,
+ 00100B,
+ 00100B,
+ 01000B / # ;
+
+data (font[i], i=197,203) / 00010B,
+ 00100B,
+ 01000B,
+ 10000B,
+ 01000B,
+ 00100B,
+ 00010B / # <
+
+data (font[i], i=204,210) / 00000B,
+ 00000B,
+ 11111B,
+ 00000B,
+ 11111B,
+ 00000B,
+ 00000B / # =
+
+data (font[i], i=211,217) / 01000B,
+ 00100B,
+ 00010B,
+ 00001B,
+ 00010B,
+ 00100B,
+ 01000B / # >
+
+data (font[i], i=218,224) / 01110B,
+ 10001B,
+ 00010B,
+ 00100B,
+ 00100B,
+ 00000B,
+ 00100B / # ?
+
+data (font[i], i=225,231) / 01110B,
+ 10001B,
+ 10101B,
+ 10111B,
+ 10110B,
+ 10000B,
+ 01111B / # @
+
+data (font[i], i=232,238) / 00100B,
+ 01010B,
+ 10001B,
+ 10001B,
+ 11111B,
+ 10001B,
+ 10001B / # A
+
+data (font[i], i=239,245) / 11110B,
+ 10001B,
+ 10001B,
+ 11110B,
+ 10001B,
+ 10001B,
+ 11110B / # B
+
+data (font[i], i=246,252) / 01110B,
+ 10001B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 10001B,
+ 01110B / # C
+
+data (font[i], i=253,259) / 11110B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 11110B / # D
+
+data (font[i], i=260,266) / 11111B,
+ 10000B,
+ 10000B,
+ 11110B,
+ 10000B,
+ 10000B,
+ 11111B / # E
+
+data (font[i], i=267,273) / 11111B,
+ 10000B,
+ 10000B,
+ 11110B,
+ 10000B,
+ 10000B,
+ 10000B / # F
+
+data (font[i], i=274,280) / 01111B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 10011B,
+ 10001B,
+ 01111B / # G
+
+data (font[i], i=281,287) / 10001B,
+ 10001B,
+ 10001B,
+ 11111B,
+ 10001B,
+ 10001B,
+ 10001B / # H
+
+data (font[i], i=288,294) / 01110B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 01110B / # I
+
+data (font[i], i=295,301) / 00001B,
+ 00001B,
+ 00001B,
+ 00001B,
+ 00001B,
+ 10001B,
+ 01110B / # J
+
+data (font[i], i=302,308) / 10001B,
+ 10010B,
+ 10100B,
+ 11000B,
+ 10100B,
+ 10010B,
+ 10001B / # K
+
+data (font[i], i=309,315) / 10000B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 10000B,
+ 11111B / # L
+
+data (font[i], i=316,322) / 10001B,
+ 11011B,
+ 10101B,
+ 10101B,
+ 10001B,
+ 10001B,
+ 10001B / # M
+
+data (font[i], i=323,329) / 10001B,
+ 10001B,
+ 11001B,
+ 10101B,
+ 10011B,
+ 10001B,
+ 10001B / # N
+
+data (font[i], i=330,336) / 01110B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 01110B / # O
+
+data (font[i], i=337,343) / 11110B,
+ 10001B,
+ 10001B,
+ 11110B,
+ 10000B,
+ 10000B,
+ 10000B / # P
+
+data (font[i], i=344,350) / 01110B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10101B,
+ 10010B,
+ 01101B / # Q
+
+data (font[i], i=351,357) / 11110B,
+ 10001B,
+ 10001B,
+ 11110B,
+ 10100B,
+ 10010B,
+ 10001B / # R
+
+data (font[i], i=358,364) / 01110B,
+ 10001B,
+ 10000B,
+ 01110B,
+ 00001B,
+ 10001B,
+ 01110B / # S
+
+data (font[i], i=365,371) / 11111B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B / # T
+
+data (font[i], i=372,378) / 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 01110B / # U
+
+data (font[i], i=379,385) / 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 10001B,
+ 01010B,
+ 00100B / # V
+
+data (font[i], i=386,392) / 10001B,
+ 10001B,
+ 10001B,
+ 10101B,
+ 10101B,
+ 11011B,
+ 10001B / # W
+
+data (font[i], i=393,399) / 10001B,
+ 10001B,
+ 01010B,
+ 00100B,
+ 01010B,
+ 10001B,
+ 10001B / # X
+
+data (font[i], i=400,406) / 10001B,
+ 10001B,
+ 01010B,
+ 00100B,
+ 00100B,
+ 00100B,
+ 00100B / # Y
+
+data (font[i], i=407,413) / 11111B,
+ 00001B,
+ 00010B,
+ 00100B,
+ 01000B,
+ 10000B,
+ 11111B / # Z
+
+data (font[i], i=414,420) / 11111B,
+ 11000B,
+ 11000B,
+ 11000B,
+ 11000B,
+ 11000B,
+ 11111B / # [
+
+data (font[i], i=421,427) / 00000B,
+ 10000B,
+ 01000B,
+ 00100B,
+ 00010B,
+ 00001B,
+ 00000B / # \
+
+data (font[i], i=428,434) / 11111B,
+ 00011B,
+ 00011B,
+ 00011B,
+ 00011B,
+ 00011B,
+ 11111B / # ]
+
+data (font[i], i=435,441) / 00000B,
+ 00000B,
+ 00100B,
+ 01010B,
+ 10001B,
+ 00000B,
+ 00000B / # ^
+
+data (font[i], i=442,448) / 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 00000B,
+ 11111B / # _
+
+data (font[i], i=449,455) / 11111B,
+ 10001B,
+ 11011B,
+ 10101B,
+ 11011B,
+ 10001B,
+ 11111B / # (unknown)
diff --git a/pkg/images/tv/tvmark/t_tvmark.x b/pkg/images/tv/tvmark/t_tvmark.x
new file mode 100644
index 00000000..d1485ae1
--- /dev/null
+++ b/pkg/images/tv/tvmark/t_tvmark.x
@@ -0,0 +1,267 @@
+include <fset.h>
+include <gset.h>
+include <imhdr.h>
+include <imset.h>
+include "tvmark.h"
+
+define TV_NLINES 128
+
+# T_TVMARK -- Mark dots circles and squares on the image in the image display
+# with optional numbering.
+
+procedure t_tvmark ()
+
+pointer image # pointer to name of the image
+pointer outimage # pointer to output image
+pointer coords # pointer to coordinate file
+pointer deletions # the name of the deletions file
+pointer logfile # pointer to the log file
+pointer font # pointer to the font
+int autolog # automatically log commands
+int interactive # interactive mode
+
+pointer sp, mk, im, iw, outim, cfilename, tmpname
+int cl, dl, log, ft, frame, ltid, wcs_status, ndelete, bufsize
+
+bool clgetb()
+int access(), btoi(), clgeti(), imstati(), mk_mark()
+int imd_wcsver()
+pointer immap(), open(), imd_mapframe(), iw_open()
+
+begin
+ # Set standard output to flush on newline.
+ call fseti (STDOUT, F_FLUSHNL, YES)
+
+ # Allocate working space.
+ call smark (sp)
+ call salloc (image, SZ_FNAME, TY_CHAR)
+ call salloc (coords, SZ_FNAME, TY_CHAR)
+ call salloc (outimage, SZ_FNAME, TY_CHAR)
+ call salloc (deletions, SZ_FNAME, TY_CHAR)
+ call salloc (logfile, SZ_FNAME, TY_CHAR)
+ call salloc (font, SZ_FNAME, TY_CHAR)
+ call salloc (cfilename, SZ_FNAME, TY_CHAR)
+ call salloc (tmpname, SZ_FNAME, TY_CHAR)
+
+ # Query server to get the WCS version, this also tells us whether
+ # we can use the all 16 supported frames.
+ if (imd_wcsver() == 0)
+ call clputi ("tvmark.frame.p_max", 4)
+ else
+ call clputi ("tvmark.frame.p_max", 16)
+
+ frame = clgeti ("frame")
+ call clgstr ("coords", Memc[coords], SZ_FNAME)
+ call clgstr ("outimage", Memc[outimage], SZ_FNAME)
+ call clgstr ("deletions", Memc[deletions], SZ_FNAME)
+ call clgstr ("logfile", Memc[logfile], SZ_FNAME)
+ call clgstr ("font", Memc[font], SZ_FNAME)
+ call clgstr ("commands.p_filename", Memc[cfilename], SZ_FNAME)
+ autolog = btoi (clgetb ("autolog"))
+ interactive = btoi (clgetb ("interactive"))
+
+ # Fetch the marking parameters.
+ call mk_gpars (mk)
+
+ # Open the frame as an image.
+ im = imd_mapframe (frame, READ_WRITE, YES)
+ bufsize = max (imstati (im, IM_BUFSIZE), TV_NLINES *
+ int (IM_LEN(im,1)) * SZ_SHORT)
+ call imseti (im, IM_BUFSIZE, bufsize)
+ iw = iw_open (im, frame, Memc[image], SZ_FNAME, wcs_status)
+ call mk_sets (mk, IMAGE, Memc[image])
+ call mk_seti (mk, FRAME, frame)
+
+ # Open the coordinate file.
+ if (Memc[coords] != EOS) {
+ if ((interactive == NO) && (Memc[cfilename] == EOS)) {
+ cl = open (Memc[coords], READ_ONLY, TEXT_FILE)
+ dl = NULL
+ } else {
+ if (access (Memc[coords], READ_WRITE, TEXT_FILE) == YES)
+ cl = open (Memc[coords], READ_WRITE, TEXT_FILE)
+ else if (access (Memc[coords], READ_ONLY, TEXT_FILE) == YES) {
+ cl = open (Memc[coords], READ_ONLY, TEXT_FILE)
+ call printf ("Warning: File %s is read only.\n")
+ call pargstr (Memc[coords])
+ } else {
+ cl = open (Memc[coords], NEW_FILE, TEXT_FILE)
+ call close (cl)
+ cl = open (Memc[coords], READ_WRITE, TEXT_FILE)
+ }
+ call sprintf (Memc[tmpname], SZ_FNAME, "%s.%s")
+ call pargstr (Memc[coords])
+ if (Memc[deletions] == EOS)
+ call pargstr ("del")
+ else
+ call pargstr (Memc[deletions])
+ dl = open (Memc[tmpname], NEW_FILE, TEXT_FILE)
+ call close (dl)
+ dl = open (Memc[tmpname], READ_WRITE, TEXT_FILE)
+ }
+ } else {
+ cl = NULL
+ dl = NULL
+ }
+ call mk_sets (mk, COORDS, Memc[coords])
+ call mk_sets (mk, DELETIONS, Memc[deletions])
+
+ # Save the output mage name
+ call mk_sets (mk, OUTIMAGE, Memc[outimage])
+
+ # Open the font file.
+ #if (Memc[font] != EOS)
+ #ft = open (Memc[font], READ_ONLY, TEXT_FILE)
+ #else
+ ft = NULL
+ call mk_sets (mk, FONT, Memc[font])
+
+ # Mark the image frame.
+ if (interactive == NO) {
+ if (Memc[cfilename] != EOS)
+ ndelete = mk_mark (mk, im, iw, cl, dl, NULL, ft, autolog, NO)
+
+ else {
+
+ # Open the output image.
+ if (Memc[outimage] != EOS)
+ outim = immap (Memc[outimage], NEW_COPY, im)
+ else
+ outim = NULL
+
+ # Do the marking.
+ ltid = 0
+ if (cl != NULL)
+ call mk_bmark (mk, im, iw, cl, ltid, ft)
+
+ # Copy / close image.
+ if (outim != NULL) {
+ call mk_imcopy (im, outim)
+ call imunmap (outim)
+ }
+
+ ndelete = 0
+ }
+
+ } else {
+
+ # Open the log file.
+ if (Memc[logfile] != EOS)
+ log = open (Memc[logfile], NEW_FILE, TEXT_FILE)
+ else
+ log = NULL
+ call mk_sets (mk, LOGFILE, Memc[logfile])
+ call mk_seti (mk, AUTOLOG, autolog)
+
+ ndelete = mk_mark (mk, im, iw, cl, dl, log, ft, autolog, YES)
+
+ if (log != NULL)
+ call close (log)
+ }
+
+ # Close up the file lists and free memory.
+ call iw_close (iw)
+ call imunmap (im)
+ if (ft != NULL)
+ call close (ft)
+ if (ndelete > 0) {
+ call mk_remove (Memc[coords], Memc[tmpname], cl, dl, ndelete)
+ if (Memc[deletions] == EOS)
+ call delete (Memc[tmpname])
+ } else {
+ if (dl != NULL) {
+ call close (dl)
+ call delete (Memc[tmpname])
+ }
+ if (cl != NULL)
+ call close (cl)
+ }
+
+ # Free immark structure.
+ call mkfree (mk)
+
+ call sfree (sp)
+end
+
+
+# MK_IMCOPY -- Make a snap of the frame buffer.
+
+procedure mk_imcopy (in, out)
+
+pointer in # pointer to the input image
+pointer out # pointe to the output image
+
+int i, ncols, nlines
+pointer sp, vin, vout, inbuf, outbuf
+pointer imgnls(), impnls()
+errchk imgnls(), impnls()
+
+begin
+ call smark (sp)
+ call salloc (vin, IM_MAXDIM, TY_LONG)
+ call salloc (vout, IM_MAXDIM, TY_LONG)
+
+ ncols = IM_LEN(in, 1)
+ nlines = IM_LEN(in, 2)
+ call amovkl (long(1), Meml[vin], IM_MAXDIM)
+ call amovkl (long(1), Meml[vout], IM_MAXDIM)
+
+ do i = 1, nlines {
+ if (impnls (out, outbuf, Meml[vout]) == EOF)
+ call error (0, "Error writing output image.\n")
+ if (imgnls (in, inbuf, Meml[vin]) == EOF)
+ call error (0, "Error reading frame buffer.\n")
+ call amovs (Mems[inbuf], Mems[outbuf], ncols)
+ }
+
+ call imflush (out)
+ call sfree (sp)
+end
+
+
+# MK_IMSECTION -- Restore a section of an image to an image of the same
+# size.
+
+procedure mk_imsection (mk, in, out, x1, x2, y1, y2)
+
+pointer mk # pointer to the mark structure
+pointer in # input image
+pointer out # output image
+int x1, x2 # column limits
+int y1, y2 # line limits
+
+short value
+int i, ix1, ix2, iy1, iy2, ncols, nlines, mk_stati()
+pointer ibuf, obuf
+pointer imps2s(), imgs2s()
+
+begin
+ ncols = IM_LEN(out,1)
+ nlines = IM_LEN(out,2)
+
+ ix1 = min (x1, x2)
+ ix2 = max (x1, x2)
+ ix1 = max (1, min (ncols, ix1))
+ ix2 = min (ncols, max (1, ix2))
+
+ iy1 = min (y1, y2)
+ iy2 = max (y1, y2)
+ iy1 = max (1, min (ncols, iy1))
+ iy2 = min (ncols, max (1, iy2))
+
+ if (in == NULL) {
+ value = mk_stati (mk, GRAYLEVEL)
+ do i = iy1, iy2 {
+ obuf = imps2s (out, ix1, ix2, i, i)
+ call amovks (value, Mems[obuf], ix2 - ix1 + 1)
+ }
+ } else {
+ do i = iy1, iy2 {
+ obuf = imps2s (out, ix1, ix2, i, i)
+ ibuf = imgs2s (in, ix1, ix2, i, i)
+ call amovs (Mems[ibuf], Mems[obuf], ix2 - ix1 + 1)
+ }
+ }
+
+ call imflush (out)
+end
diff --git a/pkg/images/tv/tvmark/tvmark.h b/pkg/images/tv/tvmark/tvmark.h
new file mode 100644
index 00000000..3ff484e2
--- /dev/null
+++ b/pkg/images/tv/tvmark/tvmark.h
@@ -0,0 +1,165 @@
+# IMMARK Task Header File
+
+# define IMMARK structure
+
+define LEN_MARKSTRUCT (40 + 10 * SZ_FNAME + SZ_LINE + 11)
+
+define MK_AUTOLOG Memi[$1] # Enable auto logging
+define MK_NUMBER Memi[$1+1] # Number coordinate list entries
+define MK_LABEL Memi[$1+2] # Label coordinate list entries
+define MK_GRAYLEVEL Memi[$1+3] # Gray level of marks
+define MK_SIZE Memi[$1+4] # Size of numbers and text
+define MK_FRAME Memi[$1+5] # Frame number for display
+define MK_NCIRCLES Memi[$1+6] # Number of circles
+define MK_NELLIPSES Memi[$1+7] # Number of ellipses
+define MK_NSQUARES Memi[$1+8] # Number of squares
+define MK_NRECTANGLES Memi[$1+9] # Number of rectangles
+define MK_MKTYPE Memi[$1+10] # Type of mark
+define MK_SZPOINT Memi[$1+11] # Size of point
+define MK_NXOFFSET Memi[$1+12] # X offset of number
+define MK_NYOFFSET Memi[$1+13] # X offset of number
+
+define MK_RADII Memi[$1+14] # Pointer to list of radii
+define MK_AXES Memi[$1+15] # Pointer to list of semi-major axes
+define MK_SLENGTHS Memi[$1+16] # Pointer to list of square lengths
+define MK_RLENGTHS Memi[$1+17] # Pointer to list of rectangle lengths
+
+define MK_RATIO Memr[P2R($1+18)] # Ratio of width/length rectangles
+define MK_ELLIPTICITY Memr[P2R($1+19)] # Ellipticity of ellipses
+define MK_RTHETA Memr[P2R($1+20)] # Position angle of rectangle
+define MK_ETHETA Memr[P2R($1+21)] # Position angle of ellipse
+
+define MK_X1 Memi[$1+22] # LL corner x coord
+define MK_Y1 Memi[$1+23] # LL corner y coord
+define MK_X2 Memi[$1+24] # UR corner x coord
+define MK_Y2 Memi[$1+25] # UR corner y coord
+
+define MK_TOLERANCE Memr[P2R($1+26)] # Tolerance for deleting objects
+
+define MK_IMAGE Memc[P2C($1+40)] # Image name
+define MK_OUTIMAGE Memc[P2C($1+40+SZ_FNAME+1)] # Output image
+define MK_COORDS Memc[P2C($1+40+2*SZ_FNAME+2)] # Coordinate file
+define MK_DELETIONS Memc[P2C($1+40+3*SZ_FNAME+3)] # Deletions files
+define MK_LOGFILE Memc[P2C($1+40+4*SZ_FNAME+4)] # Log file
+define MK_FONT Memc[P2C($1+40+5*SZ_FNAME+5)] # Font
+define MK_MARK Memc[P2C($1+40+6*SZ_FNAME+6)] # Default mark
+define MK_CSTRING Memc[P2C($1+40+7*SZ_FNAME+7)] # Default circles
+define MK_RSTRING Memc[P2C($1+40+8*SZ_FNAME+8)] # Default rectangles
+
+# define IMMARK ID's
+
+define AUTOLOG 1
+define NUMBER 2
+define GRAYLEVEL 3
+define SIZE 4
+define FRAME 5
+define NCIRCLES 6
+define NELLIPSES 7
+define NSQUARES 8
+define NRECTANGLES 9
+define MKTYPE 10
+define RADII 11
+define AXES 12
+define SLENGTHS 13
+define RLENGTHS 14
+define RATIO 15
+define ELLIPTICITY 16
+define RTHETA 17
+define ETHETA 18
+define IMAGE 19
+define OUTIMAGE 20
+define COORDS 21
+define LOGFILE 22
+define FONT 23
+define MARK 25
+define CSTRING 26
+define RSTRING 27
+define SZPOINT 28
+define X1 29
+define Y1 30
+define X2 31
+define Y2 32
+define NXOFFSET 33
+define NYOFFSET 34
+define LABEL 35
+define TOLERANCE 36
+define DELETIONS 37
+
+# define mark types
+
+define MKTYPELIST "|point|circle|rectangle|line|plus|cross|none|"
+
+define MK_POINT 1
+define MK_CIRCLE 2
+define MK_RECTANGLE 3
+define MK_LINE 4
+define MK_PLUS 5
+define MK_CROSS 6
+define MK_NONE 7
+
+# define the fonts
+
+define MKFONTLIST "|raster|"
+
+# define IMMARK commands
+
+define MKCMD_IMAGE 1
+define MKCMD_OUTIMAGE 2
+define MKCMD_COORDS 3
+define MKCMD_LOGFILE 4
+define MKCMD_AUTOLOG 5
+define MKCMD_FRAME 6
+define MKCMD_FONT 7
+define MKCMD_NUMBER 8
+define MKCMD_GRAYLEVEL 9
+define MKCMD_SIZE 10
+define MKCMD_SZPOINT 11
+define MKCMD_MARK 12
+define MKCMD_CIRCLES 13
+define MKCMD_RECTANGLES 14
+define MKCMD_SHOW 15
+define MKCMD_SNAP 16
+define MKCMD_NXOFFSET 17
+define MKCMD_NYOFFSET 18
+define MKCMD_SAVE 19
+define MKCMD_RESTORE 20
+define MKCMD_LABEL 21
+define MKCMD_TOLERANCE 22
+define MKCMD_DELETIONS 23
+
+define MKCMD2_WTEXT 1
+define MKCMD2_MOVE 2
+define MKCMD2_NEXT 3
+
+
+# define IMMARK keywords
+
+define KY_IMAGE "image"
+define KY_OUTIMAGE "outimage"
+define KY_COORDS "coords"
+define KY_LOGFILE "logfile"
+define KY_AUTOLOG "autolog"
+define KY_FRAME "frame"
+define KY_FONT "font"
+define KY_NUMBER "number"
+define KY_GRAYLEVEL "color"
+define KY_SIZE "txsize"
+define KY_SZPOINT "pointsize"
+define KY_MARK "mark"
+define KY_CIRCLES "radii"
+define KY_RECTANGLE "lengths"
+define KY_NXOFFSET "nxoffset"
+define KY_NYOFFSET "nyoffset"
+define KY_RATIO "ratio"
+define KY_LABEL "label"
+define KY_TOLERANCE "tolerance"
+define KY_DELETIONS "deletions"
+
+
+define MKCMDS "|junk|outimage|coords|logfile|autolog|frame|font|number|color|txsize|pointsize|mark|radii|lengths|show|write|nxoffset|nyoffset|save|restore|label|tolerance|deletions|"
+
+define MKCMDS2 "|text|move|next|"
+
+# miscellaneous
+
+define MAX_NMARKS 100