#
# MSX SC2 importer
# A Multipaint internal script
#
# fail if less than 14343

LOAD

# Error checking

A = LENGTH

IF A<14343
	ALERT 1
	STOP
ENDIF
IF A>14512
	ALERT 1
	STOP
ENDIF

# header

READ A
READ A
READ A
READ A
READ A
READ A
READ A

# bitmap

FOR Y=0 TO 23
	FOR X=0 TO 31
		FOR V=0 TO 7
			P=1024+X*8+Y*2048+V*256
			C=128
			READ L
			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

# order

FOR I=0 TO 255
	READ A
NEXT I

FOR I=0 TO 255
	READ A
NEXT I

FOR I=0 TO 255
	READ A
NEXT I

# Empty for some reason

FOR I=0 TO 1279
	READ A
NEXT I

# Attributes

FOR Y=0 TO 23
	FOR X=0 TO 31
		D=65536+X+Y*256
		J=65536+X+Y*256+6144
		FOR V=0 TO 7
			READ A
			H=A&$F0
			L=A&$0F
			H=H/16
			POKE D,H
			POKE J,L
			LET D=D+32
			LET J=J+32
		NEXT V
	NEXT X
NEXT Y


