home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0106.zip / Timur / TARGET.C < prev    next >
Text File  |  1992-05-23  |  2KB  |  64 lines

  1. /* TARGET.C - Targetting routines
  2.  
  3. Copyright (c) 1992 Timur Tabi 
  4. Copyright (c) 1992 Fasa Corporation 
  5.  
  6. The following trademarks are the property of Fasa Corporation:
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.  
  9.  
  10. */
  11.  
  12. #define INCL_DOS
  13. #define INCL_GPIPRIMITIVES
  14. #include <os2.h>
  15. #include "hexes.h"
  16.  
  17. void TgtInitialize(HWND hwnd) {
  18.   target.fActive=FALSE;
  19.   target.hpsLine=WinGetPS(hwnd);
  20.   target.hpsHighlight=WinGetPS(hwnd);
  21.   GpiSetColor(target.hpsLine,CLR_BLUE);
  22.   GpiMove(target.hpsLine,&target.ptlStart);
  23.   GpiSetMix(target.hpsLine,FM_XOR);
  24. }
  25.  
  26. void TgtShutdown(void) {
  27.   WinReleasePS(target.hpsLine);
  28.   WinReleasePS(target.hpsHighlight);
  29. }
  30.  
  31. void TgtStart(HEXINDEX hi) {
  32.   target.fActive=TRUE;                             // Initalize 'target'
  33.   target.hiStart=hi;
  34.   target.hiEnd=hi;
  35.   target.ptlStart=HexMidpoint(hi);
  36.   target.ptlEnd=target.ptlStart;
  37.  
  38.   DosCreateThread(&target.tid,HexHighlight,0UL,0UL,4096UL);
  39. }
  40.  
  41. void TgtEnd(void) {
  42.   target.fActive=FALSE;                 // Automatically terminates HexHighlight
  43.   if (!HI_EQUAL(target.hiStart,target.hiEnd)) {  // Erase the line if it exists
  44.     GpiMove(target.hpsLine,&target.ptlStart);
  45.     GpiLine(target.hpsLine,&target.ptlEnd);
  46.   }
  47. }
  48.  
  49. void TgtMove(HEXINDEX hi) {
  50. // Erase the existing line if it exists
  51.   if (!HI_EQUAL(target.hiStart,target.hiEnd)) {  
  52.     GpiMove(target.hpsLine,&target.ptlStart);
  53.     GpiLine(target.hpsLine,&target.ptlEnd);
  54.   }
  55.  
  56.   target.ptlEnd=HexMidpoint(target.hiEnd=hi);   // Set the new endpoint and draw the line
  57.  
  58. // Draw the new line if it exists
  59.   if (!HI_EQUAL(target.hiStart,target.hiEnd)) {
  60.     GpiMove(target.hpsLine,&target.ptlStart);
  61.     GpiLine(target.hpsLine,&target.ptlEnd);
  62.   }
  63. }
  64.