home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Pascal / BPASCAL.700 / D12 / CHESSTV.ZIP / CHESSUTL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-01  |  831 b   |  37 lines

  1. unit ChessUtl;
  2.  
  3. interface
  4.  
  5. {$IFDEF DLL}
  6. uses ChessDLL, Objects, Views;
  7. {$ELSE}
  8. uses ChessInf, Objects, Views;
  9. {$ENDIF}
  10.  
  11. procedure SquareToLocal(ALocation: TLocation; var P: TPoint; Size: Integer);
  12. procedure PointInSquare(P: TPoint; var ALocation: TLocation);
  13.  
  14. implementation
  15.  
  16. function MaxI(I1, I2: Integer): Integer; inline (
  17.   $58/$5B/$3B/$C3/$7D/$01/$93
  18.   );
  19.  
  20. function MinI(I1, I2: Integer): Integer; inline (
  21.   $58/$5B/$3B/$C3/$7E/$01/$93
  22.   );
  23.  
  24. procedure SquareToLocal(ALocation: TLocation; var P: TPoint; Size: Integer);
  25. begin
  26.   P.X := (ALocation.X - 1) * 6 + 2;
  27.   P.Y := Size - ALocation.Y * 3;
  28. end;
  29.  
  30. procedure PointInSquare(P: TPoint; var ALocation: TLocation);
  31. begin
  32.   ALocation.X := MinI(MaxI(1, ((P.X - 2) div 6) + 1), 8);
  33.   ALocation.Y := MinI(MaxI(1, 8 - (P.Y div 3)), 8);
  34. end;
  35.  
  36. end.
  37.