	SUBROUTINE SAODOT(IX,IY,NPIC,IVAL)
C
C  Note:  This is the UNIX version
C
C       This subroutine lights a single pixel in SAOimage.  It is assumed
C  that a file has previously been loaded, or that SAOCATPION was called,
C  so that SAOimage is properly initialized.
C
C				Donald H. Gudehus, August, 1993
C				Version 1U, D. Gudehus, September, 23, 1994
C				Converted code to UNIX
C				Version 2, D. Gudehus, August 29, 2006
C				Incorporated changes from saofacts.for
C				and added SYS_ENDIAN common block
C
C	IX	(C)	The desired X map location of the pixel.  
C	IY	(C)	Same as IX but in the Y direction.
C	NPIC	(C)	The number of the picture (1 to 16) loaded into the
C			frame
C	IVAL	(C)	The intensity value applied to the pixel.  Numbers
C			from 0 to 255 are possible.  Some assignments are:
C
C Signed byte  Unsigned byte or integer  Color
C      -55             201               green
C      -54             202               black
C      -53             203               white
C      -52             204               red
C      -51             205               green
C      -50             206               blue
C      -49             207               yellow
C      -48             208               black
C      -47             209               white
C      -46             210               yellow
C      -45             211               red
C      -44             212               yellow
C      -43             213               white
C      -42             214               red
C      -41             215               green
C      -40             216               blue
C      -39             217               white
C
	INCLUDE 'saofacts.for'
C
	CHARACTER*1 SYSTEM_ENDIAN
	COMMON /SYS_ENDIAN/ SYSTEM_ENDIAN
C
	INTEGER*4 NPIC
C
	IXLOC=XLOC_SAO(NPIC)  ! Converts to I4
	IYLOC=YLOC_SAO(NPIC)  ! Converts to I4
	IMIN=IMSX_SAO(NFRAME_SAO,NPIC)
	JMIN=IMSY_SAO(NFRAME_SAO,NPIC)
C  We use the auxilliary buffer so that it doesn't have to be reloaded every
C  row.
	IHDBUFFER_SAO(1)='71000'O  ! = 29184
	IHDBUFFER_SAO(2)=-1  ! imhead.thingct
	IHDBUFFER_SAO(3)=1  ! imhead.subunit = MEMORY
	IHDBUFFER_SAO(4)=0
	I2=IX-IMIN+IXLOC
	IHDBUFFER_SAO(5)=IOR(I2,'100000'O)  ! x
	IHDBUFFER_SAO(7)=1
	IHDBUFFER_SAO(8)=IOR(63,'300'O)
	J2=JMIN+IYLOC-IY
	IHDBUFFER_SAO(6)=IOR(J2,'100000'O)  ! y
	CALL IMTOOLCHECKSUM(IHDBUFFER_SAO)
	NBYTES=16
	CALL SI_WRITE(HDBUFFER_SAO,NBYTES)
	NBYTES=1
	IBUFFER_TEMP_SAO=IVAL
	IF (SYSTEM_ENDIAN.EQ.'L') THEN
	  BUFFER_SAO(1)=BUFFER_TEMP_SAO(1)
	ELSE IF (SYSTEM_ENDIAN.EQ.'B') THEN
	  BUFFER_SAO(1)=BUFFER_TEMP_SAO(2)
	END IF
C  Send the row of data to SAOimage
	CALL SI_WRITE(BUFFER_SAO,NBYTES)
	RETURN
	END
