#
# Amstrad CPC mode 1 (320x200 bitmap) exporter
# A Multipaint internal script
#
# Based on CPC formats in Pixel Polizei by MarQ
#

XREM "CPC Machine code header"

XBYTE $3E,$01,$CD,$0E,$BC,$CD,$19,$BD,$3A,$49,$A0,$47,$4F,$CD,$38,$BC
XBYTE $21,$4A,$A0,$CD,$31,$60,$CD,$19,$BD,$21,$45,$60,$11,$00,$C0,$01
XBYTE $00,$40,$ED,$B0,$CD,$19,$BD,$21,$45,$A0,$CD,$31,$60,$CD,$18,$BB
XBYTE $C9,$06,$04,$3E,$00,$4E,$23,$E5,$C5,$F5,$41,$CD,$32,$BC,$F1,$C1
XBYTE $E1,$3C,$10,$F1,$C9

XREM "Bitmap"

FOR W=0 TO 7
	FOR Y=0 TO 24
		FOR X=0 TO 79
			R = X*4
			L = Y*8
			L = L+W

			P = GETPOINT R,L

			IF P=0
				H=0
				D=0
			ENDIF
			IF P=1
				H=1
				D=0
			ENDIF
			IF P=2
				H=0
				D=1
			ENDIF
			IF P=3
				H=1
				D=1
			ENDIF						

			R = R+1
			P = GETPOINT R,L

			IF P=0
				G=0
				C=0
			ENDIF
			IF P=1
				G=1
				C=0
			ENDIF
			IF P=2
				G=0
				C=1
			ENDIF
			IF P=3
				G=1
				C=1
			ENDIF	

			R = R+1
			P = GETPOINT R,L

			IF P=0
				F=0
				B=0
			ENDIF
			IF P=1
				F=1
				B=0
			ENDIF
			IF P=2
				F=0
				B=1
			ENDIF
			IF P=3
				F=1
				B=1
			ENDIF	

			R = R+1
			P = GETPOINT R,L

			IF P=0
				E=0
				A=0
			ENDIF
			IF P=1
				E=1
				A=0
			ENDIF
			IF P=2
				E=0
				A=1
			ENDIF
			IF P=3
				E=1
				A=1
			ENDIF	

			O = A
			O = O+B*2
			O = O+C*4
			O = O+D*8
			O = O+E*16
			O = O+F*32
			O = O+G*64
			O = O+H*128

			XBYTE O

		NEXT X
	NEXT Y

	# padding

	FOR I=0 TO 47
		XBYTE 0
	NEXT I

NEXT W


XREM "Palette order"

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

	H = SCALERGB G,3
	L = SCALERGB R,3
	M = SCALERGB B,3

	O = M
	O = O+L*3
	O = O+H*9

	XBYTE O
NEXT I

XREM "Border"

	A = PEEK 0
	A = A*3
	A = A+256

	R = PEEK A
	A = A+1
	G = PEEK A
	A = A+1
	B = PEEK A

	H = SCALERGB G,3
	L = SCALERGB R,3
	M = SCALERGB B,3

	O = M
	O = O+L*3
	O = O+H*9

	XBYTE O

XREM "Padding"

FOR I=0 TO 3
	XBYTE 0
NEXT I

# Write to file

L = 16486

SAVE
