#
# Vic-20 exporter, raw *.VIC data
# 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 ".VIC format"

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
