home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l040 / 10.ddi / CHESS.ZIP / TVCHSUTL.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-10-27  |  1.1 KB  |  44 lines

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