#
# Commodore 64 OCP multicolor importer
# A Multipaint internal script
#

# input file

LOAD

# Error check, fail if less than 9900

A = LENGTH

IF A<9900
	ALERT 1
	STOP
ENDIF
IF A>10018
	ALERT 1
	STOP
ENDIF

# header

READ A
READ A

# bitmap

P=1024

FOR Y=0 TO 24
	FOR X=0 TO 39
		FOR V=0 TO 7
			READ L
			C=128
			P=1024+X*8+Y*2560+V*320
			FOR B=0 TO 7
				A=L&C				
				IF A=0
					POKE P,0
				ENDIF
				IF A<>0
					POKE P,1
				ENDIF
				P=P+1
				C=C/2
			NEXT B
		NEXT V
	NEXT X
NEXT Y

# color RAM 1 & 2

FOR Y=0 TO 24
	FOR X=0 TO 39
		READ A
		H=A&$F0
		L=A&$0F
		H=H/16
		P=65536+X+Y*40
		J=65536+X+Y*40+1000
		POKE P,L
		POKE J,H
	NEXT X
NEXT Y


# Border

READ B
B=B&$0F
POKE 0,B

# Background

READ B
B=B&$0F
POKE 1,B

# filler

FOR I=0 TO 13
	READ B
NEXT I

# color RAM 3

FOR Y=0 TO 24
	FOR X=0 TO 39
		READ A
		P=65536+X+Y*40+2000
		A=A&$0F
		POKE P,A
	NEXT X
NEXT Y

REFRESH

