%include "inc:util.imp"
%include "iffinc.imp"

!J. Butler Jan 87

!Trivial IFF utilities demo - takes nominated file and superimposes cross hairs
%begin
%record (iffhdr fm) iffhdr, iffout
%owninteger a,i,k,rc,xdiv2,ydiv2

a=0
rc = iff readin(cli param, iffhdr, a)
!If we opened the file successfully...
printline("IFF connect: ".iff error(rc)) %and %stop %if rc#0

iff show header(iffhdr, 1)  ;!display it
!Plant cross-hairs
xdiv2 = iffhdr_wid//2; ydiv2 = iffhdr_ht//2
%for i=0, 1, iffhdr_ht-1 %cycle
   byteinteger(a+i * iffhdr_wid + xdiv2) = 0
%repeat
%for i=0, 1, iffhdr_wid-1 %cycle
   byteinteger(a+ydiv2 * iffhdr_wid + i) = 0
%repeat
printstring("Cross-hairs planted "); phex(a); newline

!Now write the modified picture back to file "junk.iff"
iffout=0; iffout_wid=iffhdr_wid; iffout_ht=iffhdr_ht
iffout_title = iffhdr_title." with crosshairs"

rc = iff writeout("junk", iffout, a)
heapput(a)
printline(iff error(rc)) %if rc#0
%endofprogram
         
   
