#
# Vic-20 exporter, *.PRG exporter for Unexpanded Vic
# A Multipaint internal script
#
# Uses Aleksi Eeben's source & format
#

# is this hires (22) or multicolor (222)
# if mode is 222, set bit 3 in color data

M=PEEK 3

XREM "MC Header"

XBYTE $01,$10,$0B,$10,$14,$00,$9E,$34,$31,$30,$39,$00,$00,$00,$78,$A0
XBYTE $78,$A2,$F6,$B9,$72,$1F,$48,$20,$47,$10,$68,$4A,$4A,$4A,$4A,$20
XBYTE $47,$10,$88,$10,$EE,$AD,$70,$1F,$8D,$0E,$90,$AD,$71,$1F,$8D,$0F
XBYTE $90,$A9,$8C,$8D,$05,$90,$A9,$17,$8D,$03,$90,$A9,$EF,$8D,$20,$91
XBYTE $4E,$21,$91,$B0,$FB,$4C,$22,$FD,$9D,$FB,$95,$8A,$9D,$FB,$01,$CA,$60

XREM "Bitmap"

FOR Y=0 TO 10
	FOR X=0 TO 21
		FOR V=0 TO 15
			L = GRAB X,Y*16+V	
			XBYTE L
		NEXT V
	NEXT X
NEXT Y

XREM "Aux in high nybble"

A = PEEK 2
A = A & 15
A = A * 16
XBYTE A

XREM "Back and Border in nybbles"

A = PEEK 0
A = A & 15

A = A | 8

B = PEEK 1
B = B & 15

B = B * 16

C = A + B

XBYTE C

XREM "Colors as nybbles"

S = 65536
FOR P=0 TO 120
	A = PEEK S
	A = A & 15

	IF M=222
		A = A | 8
	ENDIF

	S = S + 1

	B = PEEK (S)
	B = B & 15
	
	IF M=222
		B = B | 8
	ENDIF

	S = S + 1

	A = A * 16
	C = B + A
	XBYTE C
NEXT P

# Write to file (XBYTEs)

SAVE
