#
# Commodore Plus/4 Botticelli hires importer
# A Multipaint internal script
#
# Thanks to KiCHY
#

LOAD

# Error check

A = LENGTH

IF A<10050
	ALERT 1
	STOP
ENDIF
IF A>10064
	ALERT 1
	STOP
ENDIF

# header

READ A
READ A

# luminance

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

# padding

FOR I=0 TO 23
	READ A
NEXT I

# add color

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*320
		J=65536+X+Y*320+8000
		FOR V=0 TO 7
			M=PEEK P
			M=M+H
			POKE P,M
			M=PEEK J
			M=M+L			
			POKE J,M
			P=P+40
			J=J+40
		NEXT V
	NEXT X
NEXT Y

# padding

FOR I=0 TO 23
	READ A
NEXT I

# 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
