program Display_multicolor_image;
@use "screen"
var
/*
	Open your ".flf" 320x200 image and click "export", then type in the "base name" of the files to output.
	The first file (.. _data.bin) contains pixel data, while the second file (..._color.bin) contains color data. 
	
	Image by The Diad / Proxima ^ Hokuto Force
*/

// Exports flf image directly to binary with each build. Select between image 1 or 2
@define img 1
var i:byte;

@if img=1
	@export "resources/images/neo_rider_by_the_diad.flf" "resources/images/neo_rider.bin" 0
@endif
@if img=2
	@export "resources/images/jack.flf" "resources/images/neo_rider.bin" 0
@endif

	image_color: IncBin("resources/images/neo_rider_color.bin", $5000);
	image_data: IncBin("resources/images/neo_rider_data.bin", $6000);

var
  zp:pointer;

// basically the same as the built-in method copyimagecolordatamanually
procedure CopyImageColordataManually();
begin
	zp:=image_color;
	screen_bg_col:=zp[0]; // first byte is border color
	zp:=zp+1;
	screen_fg_col:=zp[0]; // 2nd byte is foreground color 
	zp:=zp+1;
	copyfullscreen(zp,$4400); // Copy first 1000 bytes (1 screen worth of data) to bank 1
	zp:=zp+1000; // point to next screen 
	copyfullscreen(zp,screen_col_loc); // copy 1 screen worth of data to color ram
end;


begin
	// Turn off multicolor if you want hires! 
	Screen::Init();
	Screen::EnableVIC4();
	Screen::Set40ColumnMode();


	setmulticolormode();
	setbitmapmode();
	// Set data pointer to $6000
	vic_data_loc:=$18;
	setbank(vic_bank1);
	zp:=$6000;
	for i:=0 to 32 do
	begin
//		fill(zp,%10,0);
		zp+=256;
	end;
//	clearscreen(0,^$4000);	
//	clearbitmap(^$6000,8);	
	// Copy image color data from $5000 to $4400 (on bank 1) and $D800 
	copyimagecolordata(#image_color,1);
	screen_fg_col:=black;
	/*
	// Example of how to copy the color data manually
	CopyImageColordataManually();
	*/
	Loop();

end.
