home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / bpos2api.zip / COMPATIB.PAS next >
Pascal/Delphi Source File  |  1993-11-17  |  2KB  |  91 lines

  1. Unit Compatib;
  2.  
  3. Interface
  4.  
  5. uses
  6.   Os2Def, DosTypes, DosProcs, OS2Subs;
  7.  
  8. Const
  9.   FCarry     = $0001;
  10.   FParity    = $0004;
  11.   FAuxiliary = $0010;
  12.   FZero      = $0040;
  13.   FSign      = $0080;
  14.   FOverflow  = $0800;
  15.  
  16. Type
  17.   Registers = Record
  18.                 Case Integer of
  19.                   0: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Word);
  20.                   1: (AL,AH,BL,BH,CL,CH,DL,DH          : Byte);
  21.               End;
  22.  
  23.   { Only the interrupt vectors for INT 0,4,5,6,7,$10 can }
  24.   { be accessed easily.                                  }
  25.  
  26.   Procedure GetIntVec(IntNo : Byte;Var Vector : Pointer);
  27.   Procedure SetIntVec(IntNo : Byte;Vector : Pointer);
  28.   Procedure Intr(IntNo : Byte;Var Regs : Registers);
  29.   Procedure MsDos(Var Regs : Registers);
  30.  
  31. Implementation
  32.  
  33.   Procedure GetIntVec(IntNo : Byte;Var Vector : Pointer);
  34.   Var
  35.     p : Pointer;
  36.   Begin
  37.     Vector := Nil;
  38.     If DosSetVec(IntNo,Nil,p) = 0 then
  39.       Begin
  40.         Vector := p;
  41.         DosSetVec(IntNo,p,p);
  42.       End;
  43.   End;
  44.  
  45.   Procedure SetIntVec(IntNo : Byte;Vector : Pointer);
  46.   Var
  47.     p : Pointer;
  48.   Begin
  49.     DosSetVec(IntNo,Vector,p);
  50.   End;
  51.  
  52.   Procedure Intr(IntNo : Byte;Var Regs : Registers);
  53.   Var
  54.     w : Word;
  55.     KeyInfo : TKbdKeyInfo;
  56.   Begin
  57.     Case IntNo of
  58.       $16 : Case Regs.AH of
  59.               $01 : Begin  { Check for keystroke. }
  60.                       KbdPeek(KeyInfo,0);
  61.                       If (KeyInfo.fbStatus And $40) <> 0 then
  62.                         Begin
  63.                           Regs.Flags := Regs.Flags And Not(FZero);
  64.                           Regs.AL    := Ord(KeyInfo.chChar);
  65.                           Regs.AH    := Ord(KeyInfo.chScan);
  66.                         End
  67.                       else
  68.                         Regs.Flags := Regs.Flags Or FZero;
  69.                       Exit;
  70.                     End;
  71.             End;
  72.       $21 : Case Regs.AH of
  73.               $09 : Begin  { Write string to standard output. }
  74.                       w := 0;
  75.                       While Mem[Regs.DS:Regs.DX + w] <> Ord('$') do Inc(w);
  76.                       DosWrite(1,Ptr(Regs.DS,Regs.DX)^,w,w);
  77.                       Exit;
  78.                     End;
  79.             End;
  80.     End;
  81.     VioWrtTTY('Unsupported INT'^M^J,17,0);
  82.     RunError(99);
  83.   End;
  84.  
  85.   Procedure MsDos(Var Regs : Registers);
  86.   Begin
  87.     Intr($21,Regs);
  88.   End;
  89.  
  90. End.
  91.