Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-04 - decus/20-0110/define.req
There are 2 other files named define.req in the archive. Click here to see a list.
COMMENT
.SEC(DEFINE.REQ - MACRO DEFINITIONS)
.INDEX(DEFINE.REQ - MACRO DEFINITIONS)
.;
"File: DEFINE.REQ"

COMMENT
.<<          Peter Lemkin, Richard Gordon, Bruce Shapiro
.                     Image Processing Unit
.                   National Cancer Institute
.                 National Institutes of Health
.                     Building 36 Room 4D28
.                 Bethesda, Maryland 20014 USA
.
.                      Phone 301-496-2394
.
.May 24, 1976- Lemkin added additional DEBUG macros
. April 8, 1976- Shapiro- added DEBUG macros
. Feb 2, 1976 - Lemkin, added packed mask macros, to be debugged
. Feb 5, 1976 - Lemkin, debugging PACK2D
. Feb 8, 1976 - Lemkin, fixed mask macro addressing
. Feb 9, 1976 - Lemkin, Shapiro  added boundary macros
. Feb 12, 1976 - Lemkin, Shapiro  fixed boundary macros
. Feb 17, 1976 - Lemkin, added FETCH1D and PACK2D
. Feb 27, 1976 - Lemkin, added TICTACI1, TICTACI2, TICTACI3
. March 8, 1976 - Gordon and Lemkin, fixed PACK1D
.March 10,1976 - Shapiro, Lemkin changed macros so arguments 
.		expand correctly, added PUB stuff
.>>
	DEFINE.REQ is a set of SAIL macro definitions  used  by
most of the programs in PROC10 and other IPU group programs. It
contains macros to fetch and store 1 and 2-D images, masks  and
boundaries in addition to commonly used values

COMMENT
.ss(Delimiters used in DEFINE.REQ)
.index(Delimiters used in DEFINE.REQ)
.;
Require "{}{}" Delimiters;

COMMENT
.SS(Commonly used macro constants)
.index(Commonly used macro constants)
.;
Define crlf={('15&'12)};

Define pi={(3.14159265)};

Define twopi={(6.28318530)};

Define maxreal={(1.7@38)};

Define minreal={(-1.7@38)};

Define maxinteger={(34359738367)};

Define mininteger={(-34359738367)};

Define #={comment};
Define DEBUGR(X)={Outstr("(X)= "&cvf((X))&crlf)};
Define DEBUGI(X)={Outstr("(X)= "&CVS((X))&crlf)};
Define DEBUGO(X)={Outstr("(X)= "&CVOS((X))&crlf)};
Define DEBUGS(X)={Outstr("(X)= "&X&crlf)};
COMMENT
.SS(PPAK macros)
.index(PPAK macros)
.;
Comment variables for image macros;
Integer
	m!l!a,
	n!l!a,
	l!s!a;
Comment Variables for new 1D macros;
Integer
	word!with!pixel,
	linear!address,
	leftshift!in!word,
	pixel!mod,
	octal!digit,rotation;


COMMENT
.SSS(I!LOC)
.index(I!LOC)
.;
"       The following macro returns word of the array (r,c)"
Define I!LOC(image,r,c) =
                {(image[(n!l!a_((r) Lsh imshift)+(c)) Lsh -2])};

COMMENT
.SSS(L!MASK!OUT!BYTE)
.index(L!MASK!OUT!BYTE)
.;
"       The following macro returns the word of the  array(r,c)  with
the selected byte zeroed"
Define L!MASK!OUT!BYTE =
            {('777777777777 - ('777 Lsh 
                        (l!s!a_(27-9*(m!l!a Land 3))) ))};

COMMENT
.SSS(FETCH2D)
.index(FETCH2D)
.;
"       The following macro  fetches  a  9-bit  byte  from  an  image
specified by (r,c)"
Define FETCH2D(image,r,c) = 
   {('777 Land (I!LOC(image,(r),(c)) Lsh (-27+(9*(n!l!a Land '3))) ) )};

COMMENT
.SSS(FETCH1D)
.index(FETCH1D)
.;
Define FETCH1D(image,p) = 
   {('777 Land (image[(p) Lsh -2] Lsh (-27+(9*((p) Land '3))) ) )};

COMMENT
.SSS(PACK2D)
.index(PACK2D)
.;
"       The following macro  packs  a  9-bit  byte  into  an  image
specified by (r,c). Note that it will eval the left  (sink)  subcript
first so that that computation can be used on the fetch."
Define PACK2D(image,r,c,data) =
         {image[(((r) Lsh imshift)+(c)) Lsh -2]_
                    ((image[(m!l!a_((r) Lsh imshift)+(c)) Lsh -2] Land
                          L!MASK!OUT!BYTE) Lor 
                                (('777 Land data) Lsh l!s!a) )};

COMMENT
.SSS(TICTACI1)
.index(TICTACI1)
.;
"	OUTSTR a tic tac toe image of I1"
Define TICTACI1 = "Outstr(
	CVS(I13)&"" ""&CVS(I12)&"" ""&CVS(I11)&crlf&
	CVS(I14)&"" ""&CVS(I18)&"" ""&CVS(I10)&crlf&
	CVS(I15)&"" ""&CVS(I16)&"" ""&CVS(I17)&crlf&crlf)";

COMMENT
.SSS(TICTACI2)
.index(TICTACI2)
.;
"	OUTSTR a tic tac toe image of I2"
Define TICTACI2 = "Outstr(
	CVS(I23)&"" ""&CVS(I22)&"" ""&CVS(I21)&crlf&
	CVS(I24)&"" ""&CVS(I28)&"" ""&CVS(I20)&crlf&
	CVS(I25)&"" ""&CVS(I26)&"" ""&CVS(I27)&crlf&crlf)";

COMMENT
.SSS(TICTACI2)
.index(TICTACI2)
.;
"	OUTSTR a tic tac toe image of I3"
Define TICTACI3 = "Outstr(
	CVS(I33)&"" ""&CVS(I32)&"" ""&CVS(I31)&crlf&
	CVS(I34)&"" ""&CVS(I38)&"" ""&CVS(I30)&crlf&
	CVS(I35)&"" ""&CVS(I36)&"" ""&CVS(I37)&crlf&crlf)";

Comment New versions of 1D macros:

COMMENT
.SSS(PACK1D)
.index(PACK1D)
.;
Comment PACK1D is not protected against data outside of 0 leq data
leq 255;
Define PACK1D(image,pixel!1D!address,data)=
	{image[word!with!pixel_
	    (pixel!1D!address) Lsh -2]_(image[word!with!pixel] 
			Land ( '777777777777-('777 Lsh
			(leftshift!in!word_9*((pixel!1D!address) 
			Land 3)-27)))) Lor ((data) Lsh
			leftshift!in!word))};

COMMENT
.SSS(PRFTCH)
.index(PRFTCH)
.;
comment PRPACK and PRFTCH are very fast one dimensional packing
and unpacking routines.  The  order  of  the  9  bit  bytes  is
reversed  from  that  of  the  other macros. Consecutive bytes,
according to one dimensional addressing, are #'s 3, 2, 1, and 0
instead of 0, 1, 2, 3 (assuming bits are numbered from right to
left). To prepare a picture  for  use  of  these  macros,  call
PREVERSE.  To  restore  a  picture  to  the  usual  order, call
PREVERSE again. PRPACK and PRFTCH avoid a multiplication of the
byte  position by 9 by noting that 0, 9, 18, and 27 = '00, '11,
'22, and '33.;
Define PRFTCH(image,pixel!1D!address)=
	{('777 Land (image[(pixel!1D!address) Lsh -2] rot
		-((octal!digit_(pixel!1D!address) Land 3) Lor
		(octal!digit Lsh 3))))};

COMMENT
.SSS(PRPACK)
.index(PRPACK)
.;
Define PRPACK(image,pixel!1D!address,data)=
	{image[word!with!pixel_ (pixel!1D!address) Lsh -2] _
		image[word!with!pixel] Land ((
		'777777777000 rot (rotation_((octal!digit_
		(pixel!1D!address) Land 3) lor (octal!digit Lsh
		3)))) lor ((data) rot rotation))};
COMMENT
.SS(Mask macros)
.index(Mask macros)
.;
Integer
	ms!word!addr,
	ms!linear!addr,
	ms!shift;

COMMENT
.SSS(MSK!LOC)
.index(MSK!LOC)
.;
"       The following macro returns word of the mask array (r,c)"
Define MSK!LOC(mask!image,r,c) =
                {mask!image[(ms!word!addr_((ms!linear!addr_
                        ((r) Lsh imshift)+(c)) %36))]};

COMMENT
.SSS(L!MASK!OUT!BIT)
.index(L!MASK!OUT!BIT)
.;
"       The following macro returns the word of the  array(r,c)
with the selected bit zeroed"
Define L!MASK!OUT!BIT =
                    {('777777777777 - (1 Lsh (ms!shift_35-
                              (ms!linear!addr-36*ms!word!addr))))};

COMMENT
.SSS(MSK!FETCH2D)
.index(MSK!FETCH2D)
.;
"       The following macro fetches a 1-bit byte  from  a  mask
image specified by (r,c)"
Define MSK!FETCH2D(mask!image,r,c) = 
                   {(1 Land (MSK!LOC(mask!image,(r),(c)) Lsh
                         (-35+(ms!linear!addr-36*ms!word!addr))) )};

COMMENT
.SSS(MSK!PACK2D)
.index(MSK!PACK2D)
.;
" The following macro packs a 1-bit byte into a mask image
specified by (r,c)."
Define MSK!PACK2D(mask!image,r,c,data!bit) =
                {MSK!LOC(mask!image,(r),(c))_
                        (MSK!LOC(mask!image,(r),(c)) Land 
				L!MASK!OUT!BIT)
                        Lor ((data!bit) Lsh ms!shift) };

COMMENT
.SSS(MSK!BOOL)
.index(MSK!BOOL)
.;
"       The following macro boolean is used to determine
        if a pixel is inside of a legal mask by returning true if
        it is and false if it isn't"
Define MSK!BOOL(r,c) = {(If usemask
                        Then 
                        MSK!FETCH2D({Datum(mskimage)},(r),(c))
                        Else true)};
COMMENT
.SS(Boundary macros)
.index(Boundary macros)
.;
Integer
	bs!word!addr,
	bs!linear!addr,
	bs!shift;

COMMENT
.SSS(BND!LOC)
.index(BND!LOC)
.;
"       The following macro returns word of the boundary array (r,c)"
Define BND!LOC(boundary,point) =
                {boundary[(bs!word!addr_((point) Lsh -1))]};

COMMENT
.SSS(BND!MASK!OUT!BYTE)
.index(BND!MASK!OUT!BYTE)
.;
"       The following macro returns the mask of the  array(point)
with the selected 9-bits  zeroed. note x!or!y is 1 for x, 0 for y"
Define BND!MASK!OUT!BYTE(point,x!or!y) =
                    {('777777777777 - ('777 Lsh (bs!shift_
                                (27-9*((((point) Lsh 1) Land '2)+
                                  (x!or!y))) )))};

COMMENT
.SSS(X!BND!FETCH)
.index(X!BND!FETCH)
.;
"       The following macro fetches a 9-bit X-byte from a boundary
image specified by (point)"
Define X!BND!FETCH(boundary,point) = 
           {('777 Land (BND!LOC(boundary,(point)) Lsh (-27+9*( 
                                (((point) Lsh 1) Land '2) +
                                0) )))};

COMMENT
.SSS(Y!BND!FETCH)
.index(Y!BND!FETCH)
.;
Define Y!BND!FETCH(boundary,point) = 
           {('777 Land (BND!LOC(boundary,(point)) Lsh (-27+9*( 
                                (((point) Lsh 1) Land '2) +
                                1) )))};

COMMENT
.SSS(X!BND!PACK)
.index(X!BND!PACK)
.;
"       The  following macro packs a 9-bit byte into a boundary image
specified by (point)."
Define X!BND!PACK(boundary,point,data!byte) =
               {BND!LOC(boundary,(point))_
                       (BND!LOC(boundary,(point)) Land
                        BND!MASK!OUT!BYTE((point),0)) Lor
                          (('777 Land (data!byte)) Lsh bs!shift) };

COMMENT
.SSS(Y!BND!PACK)
.index(Y!BND!PACK)
.;
Define Y!BND!PACK(boundary,point,data!byte) =
                {BND!LOC(boundary,(point))_
                        (BND!LOC(boundary,(point)) Land
                         BND!MASK!OUT!BYTE((point),1)) Lor
                          (('777 Land (data!byte)) Lsh bs!shift) };