home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / MCC Utils / MCCompatibility.p next >
Encoding:
Text File  |  1994-05-04  |  1.0 KB  |  50 lines  |  [TEXT/PJMM]

  1. unit MCCompatibility;
  2. {from page 3-8 of IM VI}
  3. interface
  4.  
  5.     function NumToolboxTraps: integer;
  6.     function GetTrapType (theTrap: integer): TrapType;
  7.     function TrapAvailable (theTrap: integer): boolean;
  8.     function WNEAvailable: boolean;
  9.  
  10. implementation
  11.  
  12.     function NumToolboxTraps;
  13.     begin
  14.         if NGetTrapAddress($A86E, ToolTrap) = NGetTrapAddress($AA6E, Tooltrap) then
  15.             NumToolBoxTraps := $200
  16.         else
  17.             NumToolBoxTraps := $400;
  18.     end;
  19.  
  20.     function GetTrapType;
  21.         const
  22.             TrapMask = $0800;
  23.     begin
  24.         if BAnd(theTrap, TrapMask) > 0 then
  25.             GetTrapType := ToolTrap
  26.         else
  27.             GetTrapType := OSTrap;
  28.     end;
  29.  
  30.     function TrapAvailable;
  31.         var
  32.             tType: TrapType;
  33.     begin
  34.         tType := GetTrapType(theTrap);
  35.         if tType = ToolTrap then
  36.             begin
  37.                 theTrap := BAnd(theTrap, $07FF);
  38.                 if theTrap >= NumToolboxTraps then
  39.                     theTrap := $A89F; {Unimplemented}
  40.             end;
  41.         TrapAvailable := NGetTrapAddress(theTrap, tType) <> NGetTrapAddress($A89F, ToolTrap);
  42.     end;
  43.  
  44.     function WNEAvailable;
  45.         const
  46.             _WaitNextEvent = $A860;
  47.     begin
  48.         WNEAvailable := TrapAvailable(_WaitNextEvent);
  49.     end;
  50. end.