unit CustomUnit;
// Unit file for example 12!

var
	// Variables here will be accessible by any .ras file that uses it
	number : integer = 10000;
	x, y, a, b,value, color, screen  : byte; // some global variables with shared use in various procedure declarations
	zp : pointer; // Internal pointer
	i, j, k, c : byte; // varaibles used internally 
	// Some random constant definition
	// Constants keep their original name 
	const SomeUnitConstant : byte = 50;
	
/* 	

We define x, y, a, and b as being global variables. This way, these variables 
can be reused as later procedure parameters. Just make sure that the procedures don't call
each other nested.

*/


/*
  By using these special comments, you can
  provide help text for the next defined procedure. This will automatically
  be compiled into the help text system on pressing "F1"

*/
/**
	Draws a box at position (x,y) with size (a,b) filled with screen value [value] and color [color]

**/
procedure DrawBox(x, y, a, b, value, color, screen : global byte);
begin
	// zp points to color ram
	zp:=$D800 + x + y*screen_width;
	// point to screen
	moveto(x,y, screen);
	for i:=0 to a do
	begin
		for j:=0 to b do
		begin
			screenmemory[j]:=value;
			zp[j]:=color;
		end;
		zp+= screen_width;
		screenmemory+= screen_width;
	end;
end;

/**
	Draws a triangle at position (x,y) with size (a) filled with screen value [value] and color [color]
**/


procedure DrawTri(x, y, a, value, color, c : global byte);
begin
	// zp points to color ram
	zp:=$D800 + x + y*screen_width;
	// point to screen
	moveto(x,y, screen);
	c := a;
	k:=1;
	for i:=0 to a do
	begin
		for j:=c-k to c+k-1 do
		begin
			screenmemory[j]:=value;
			zp[j]:=color;
		end;
		zp+= screen_width;
		screenmemory+= screen_width;
		if (k<c) then inc(k);
	end;
end;


end.


