Kave
2008-05-14 20:37:34
I decided to fix some broken functions in Bank.scar.
{*******************************************************************************
Function MSPointToBankPoint(P: TPoint): TPoint;
by: Wizzup? and Kave
Description: Converts a point on the Mainscreen to the point in the Bank.
First Row and Col are (0,0).
*******************************************************************************}
function MSPointToBankPoint(P: TPoint): TPoint;
var
sx,ex,sy,ey,i,z: Integer;
begin
sx := 79;
sy := 62;
ex := 110;
ey := 93;
i := 0;
z := 0;
for i := 0 to 7 do
begin
if (P.x > sx) and (P.x < ex) then
Break
else
begin
IncEx(sx,47);
IncEx(ex,47);
end;
end;
if i > 7 then Exit;
for z := 0 to 5 do
begin
if (P.y > sy) and (P.y < ey) then
Break
else
begin
IncEx(sy,37);
IncEx(ey,37);
end;
end;
if z > 5 then Exit;
Result := Point(i,z);
end;
{*******************************************************************************
function BankPointToBankIndex(P: TPoint): Integer;
by: Wizzup? and Kave
Description: Converts a Bank Point (Row,Col) to Bank Index (spot in bank).
*******************************************************************************}
function BankPointToBankIndex(P: TPoint): Integer;
begin
Result := P.x + P.y * 8;
end;
{*******************************************************************************
function BankIndexToBankPoint(ind: Integer): TPoint;
by: Wizzup? and Kave
Description: Converts the Bank Index (spot in bank) to a Bank Point (Row,Col).
*******************************************************************************}
function BankIndexToBankPoint(ind: Integer): TPoint;
begin
Result.x := Ind mod 7;
Result.y := Ind div 7;
if Ind = 0 then Result.x := 0;
if Ind = 7 then
begin
Result.x := 0;
Dec(Result.y);
end;
end;
{*******************************************************************************
function BankIndexToMSBox(ind:Integer): TBox;
by: Wizzup? and Kave
Description: Converts the Bank Index (spot in bank) to a Mainscreen TBox of
the Index.
*******************************************************************************}
function BankIndexToMSBox(ind:Integer): TBox;
var
P: TPoint;
begin
P := BankIndexToBankPoint(ind);
Result.X1 := 79 + P.x * 47;
Result.X2 := Result.X1 + 31;
Result.Y1 := 62 + P.y * 38;
Result.Y2 := Result.Y1 + 32;
end;