#
# ZX Next NXI importer
# A Multipaint internal script
#

LOAD

# error checking 
# only 512-length PAL palette
# not NPL 513 palettes

A = LENGTH

IF A<>512
	ALERT 1
	STOP
ENDIF

# 9-bit palette

# RRRGGGBB .......B

A=256
R=0
G=0
B=0

FOR I=0 TO 255
	READ H
	READ L

	R=H&$E0
	R=R/32
	G=H&$1C
	G=G/4
	B=H&$03
	B=B*2
	B=B+L

	#0 0
	#1 0
	#2 1
	#3 1
	#4 2
	#5 2
	#6 3
	#7 3

	P=R/2
	R=R*36
	R=R+P

	P=G/2
	G=G*36
	G=G+P	

	P=B/2
	B=B*36
	B=B+P	

	POKE A,R
	A=A+1
	POKE A,G
	A=A+1
	POKE A,B
	A=A+1
NEXT I

REFRESH
