#
# Atari ST Degas .PI1 (lowres 320x200 bitmap) exporter
# A Multipaint internal script
#

XREM "Degas header"

XBYTE 0
XBYTE 0

XREM "Palette"

A=256
FOR I=0 TO 15
	R=PEEK A
	A=A+1
	G=PEEK A
	A=A+1
	B=PEEK A
	A=A+1

	R=R/32
	G=G/32
	B=B/32

	V=B
	M=G*16
	V=V+M
	M=R*256
	V=V+M
	XWORD V
NEXT I

XREM "Bitmap"

H=199
W=319/16

FOR Y=0 TO H
	FOR X=0 TO W
		T=$8000
		a=0
		b=0
		c=0
		d=0
		FOR B=0 TO 15
			P=GETPOINT X*16+B,Y
			M=P&1
			IF M<>0
				a=a+T
			ENDIF
			M=P&2
			IF M<>0
				b=b+T
			ENDIF
			M=P&4
			IF M<>0
				c=c+T
			ENDIF
			M=P&8
			IF M<>0
				d=d+T
			ENDIF
			T=T/2
		NEXT B
		XWORD a
		XWORD b
		XWORD c
		XWORD d			
	NEXT X
NEXT Y

# Write to file

SAVE
