daniel 27 роки тому
батько
коміт
792c3bfd7e
5 змінених файлів з 1159 додано та 193 видалено
  1. 78 98
      rtl/os2/dos.pas
  2. 65 10
      rtl/os2/kbdcalls.pas
  3. 271 0
      rtl/os2/moncalls.pas
  4. 686 66
      rtl/os2/moucalls.pas
  5. 59 19
      rtl/os2/viocalls.pas

+ 78 - 98
rtl/os2/dos.pas

@@ -20,7 +20,7 @@ unit dos;
 
 
 {$I os.inc}
 {$I os.inc}
 
 
-{$I386_DIRECT}
+{$ASMMODE ATT}
 
 
 {***************************************************************************}
 {***************************************************************************}
 
 
@@ -72,35 +72,8 @@ type    {Some string types:}
             name:string;            {Filenames can be long in OS/2!}
             name:string;            {Filenames can be long in OS/2!}
         end;
         end;
 
 
-        {File record for untyped files:}
-        filerec = record
-            handle:word;
-            mode:word;
-            recsize:word;
-            _private:array[1..26] of byte;
-            userdata:array[1..16] of byte;
-            name:array[0..79] of char;
-        end;
-
-        {File record for text files:}
-        textbuf=array[0..127] of char;
-
-        textrec = record
-            handle:word;
-            mode:word;
-            bufSize:word;
-            _private:word;
-            bufpos:word;
-            bufend:word;
-            bufptr:^textbuf;
-            openfunc:pointer;
-            inoutfunc:pointer;
-            flushfunc:pointer;
-            closefunc:pointer;
-            userdata:array[1..16] of byte;
-            name:array[0..79] of char;
-            buffer:textbuf;
-        end;
+{$i filerec.inc}
+{$i textrec.inc}
 
 
         {Data structure for the registers needed by msdos and intr:}
         {Data structure for the registers needed by msdos and intr:}
        registers=record
        registers=record
@@ -195,9 +168,9 @@ implementation
 
 
 uses    doscalls;
 uses    doscalls;
 
 
-{Import ___SYSCALL to call it nicely from assembler procedures.
+{Import syscall to call it nicely from assembler procedures.}
 
 
-procedure syscall;external name '___SYSCALL';}
+procedure syscall;external name '___SYSCALL';
 
 
 
 
 function fsearch(path:pathstr;dirlist:string):pathstr;
 function fsearch(path:pathstr;dirlist:string):pathstr;
@@ -249,13 +222,13 @@ begin
         movw (%ebx),%bx
         movw (%ebx),%bx
         {Get date}
         {Get date}
         movw $0x5700,%ax
         movw $0x5700,%ax
-        call ___SYSCALL
+        call syscall
         shll $16,%edx
         shll $16,%edx
         movw %cx,%dx
         movw %cx,%dx
         movl time,%ebx
         movl time,%ebx
         movl %edx,(%ebx)
         movl %edx,(%ebx)
         xorb %ah,%ah
         xorb %ah,%ah
-        movw %ax,U_DOS_DOSERROR
+        movw %ax,doserror
     end;
     end;
 end;
 end;
 
 
@@ -270,9 +243,9 @@ begin
         shldl $16,%ecx,%edx
         shldl $16,%ecx,%edx
         {Set date}
         {Set date}
         movw $0x5701,%ax
         movw $0x5701,%ax
-        call ___SYSCALL
+        call syscall
         xorb %ah,%ah
         xorb %ah,%ah
-        movw %ax,U_DOS_DOSERROR
+        movw %ax,doserror
     end;
     end;
 end;
 end;
 
 
@@ -284,6 +257,8 @@ begin
     intr($21,regs);
     intr($21,regs);
 end;
 end;
 
 
+{$ASMMODE DIRECT}
+
 procedure intr(intno:byte;var regs:registers);
 procedure intr(intno:byte;var regs:registers);
 
 
 {Not recommended for EMX. Only works in DOS mode, not in OS/2 mode.}
 {Not recommended for EMX. Only works in DOS mode, not in OS/2 mode.}
@@ -343,6 +318,8 @@ begin
     end;
     end;
 end;
 end;
 
 
+{$ASMMODE ATT}
+
 procedure exec(const path:pathstr;const comline:comstr);
 procedure exec(const path:pathstr;const comline:comstr);
 
 
 {Execute a program.}
 {Execute a program.}
@@ -424,6 +401,8 @@ begin
      Oh boy, I always had the opinion that executing a program under Dos
      Oh boy, I always had the opinion that executing a program under Dos
      was a hard job!}
      was a hard job!}
 
 
+    {$ASMMODE DIRECT}
+
     asm
     asm
         movl env,%edi       {Setup destination pointer.}
         movl env,%edi       {Setup destination pointer.}
         movl _envc,%ecx     {Load number of arguments in edx.}
         movl _envc,%ecx     {Load number of arguments in edx.}
@@ -445,6 +424,8 @@ begin
         movl %edx,(24)es    {Store environment size.}
         movl %edx,(24)es    {Store environment size.}
     end;
     end;
 
 
+    {$ASMMODE ATT}
+
     {Environtment ready, now set-up exec structure.}
     {Environtment ready, now set-up exec structure.}
     es.argofs:=args;
     es.argofs:=args;
     es.envofs:=env;
     es.envofs:=env;
@@ -457,9 +438,9 @@ begin
     end;
     end;
     es.nameofs:=pointer(longint(@path)+1);
     es.nameofs:=pointer(longint(@path)+1);
     asm
     asm
-        movw %ss,(12)es     {Compiler doesn't like record elems in asm.}
-        movw %ss,(14)es
-        movw %ss,(16)es
+        movw %ss,es.argseg
+        movw %ss,es.envseg
+        movw %ss,es.nameseg
     end;
     end;
     es.sizearg:=j;
     es.sizearg:=j;
     es.numenv:=0;
     es.numenv:=0;
@@ -471,14 +452,14 @@ begin
     asm
     asm
         leal es,%edx
         leal es,%edx
         mov $0x7f06,%ax
         mov $0x7f06,%ax
-        call ___SYSCALL
+        call syscall
         xorl %edi,%edi
         xorl %edi,%edi
-        jnc exprg1
+        jnc .Lexprg1
         xchgl %eax,%edi
         xchgl %eax,%edi
         xorl %eax,%eax
         xorl %eax,%eax
         decl %eax
         decl %eax
-    exprg1:
-        movl %edi,U_DOS_DOSERROR
+    .Lexprg1:
+        movw %di,doserror
         movl %eax,__RESULT
         movl %eax,__RESULT
     end;
     end;
 
 
@@ -493,7 +474,7 @@ function dosversion:word;assembler;
 {Returns DOS version in DOS and OS/2 version in OS/2}
 {Returns DOS version in DOS and OS/2 version in OS/2}
 asm
 asm
     movb $0x30,%ah
     movb $0x30,%ah
-    call ___SYSCALL
+    call syscall
 end;
 end;
 
 
 procedure getdate(var year,month,day,dayofweek:word);
 procedure getdate(var year,month,day,dayofweek:word);
@@ -501,7 +482,7 @@ procedure getdate(var year,month,day,dayofweek:word);
 begin
 begin
     asm
     asm
         movb $0x2a,%ah
         movb $0x2a,%ah
-        call ___SYSCALL
+        call syscall
         xorb %ah,%ah
         xorb %ah,%ah
         movl 20(%ebp),%edi
         movl 20(%ebp),%edi
         stosw
         stosw
@@ -526,9 +507,9 @@ begin
         movb 10(%ebp),%dh
         movb 10(%ebp),%dh
         movb 12(%ebp),%dl
         movb 12(%ebp),%dl
         movb $0x2b,%ah
         movb $0x2b,%ah
-        call ___SYSCALL
+        call syscall
         xorb %ah,%ah
         xorb %ah,%ah
-        movw %ax,U_DOS_DOSERROR
+        movw %ax,doserror
     end;
     end;
 end;
 end;
 
 
@@ -537,7 +518,7 @@ procedure gettime(var hour,minute,second,sec100:word);
 begin
 begin
     asm
     asm
         movb $0x2c,%ah
         movb $0x2c,%ah
-        call ___SYSCALL
+        call syscall
         xorb %ah,%ah
         xorb %ah,%ah
         movl 20(%ebp),%edi
         movl 20(%ebp),%edi
         movb %dl,%al
         movb %dl,%al
@@ -563,9 +544,9 @@ begin
         movb 12(%ebp),%dh
         movb 12(%ebp),%dh
         movb 14(%ebp),%dl
         movb 14(%ebp),%dl
         movb $0x2d,%ah
         movb $0x2d,%ah
-        call ___SYSCALL
+        call syscall
         xorb %ah,%ah
         xorb %ah,%ah
-        movw %ax,U_DOS_DOSERROR
+        movw %ax,doserror
     end;
     end;
 end;
 end;
 
 
@@ -576,7 +557,7 @@ begin
         signal handling instead.}
         signal handling instead.}
     asm
     asm
         movw $0x3300,%ax
         movw $0x3300,%ax
-        call ___SYSCALL
+        call syscall
         movl 8(%ebp),%eax
         movl 8(%ebp),%eax
         movb %dl,(%eax)
         movb %dl,(%eax)
     end;
     end;
@@ -589,8 +570,8 @@ begin
        signal handling instead.}
        signal handling instead.}
     asm
     asm
         movb 8(%ebp),%dl
         movb 8(%ebp),%dl
-        movl $0x3301,%ax
-        call ___SYSCALL
+        movw $0x3301,%ax
+        call syscall
     end;
     end;
 end;
 end;
 
 
@@ -600,7 +581,7 @@ begin
     {! Do not use in OS/2.}
     {! Do not use in OS/2.}
     asm
     asm
         movb $0x54,%ah
         movb $0x54,%ah
-        call ___SYSCALL
+        call syscall
         movl 8(%ebp),%edi
         movl 8(%ebp),%edi
         stosb
         stosb
     end;
     end;
@@ -613,7 +594,7 @@ begin
     asm
     asm
         movb 8(%ebp),%al
         movb 8(%ebp),%al
         movb $0x2e,%ah
         movb $0x2e,%ah
-        call ___SYSCALL
+        call syscall
     end;
     end;
 end;
 end;
 
 
@@ -627,9 +608,9 @@ begin
         asm
         asm
             movb 8(%ebp),%dl
             movb 8(%ebp),%dl
             movb $0x36,%ah
             movb $0x36,%ah
-            call ___SYSCALL
+            call syscall
             cmpw $-1,%ax
             cmpw $-1,%ax
-            je LDISKFREE1
+            je .LDISKFREE1
             mulw %cx
             mulw %cx
             mulw %bx
             mulw %bx
             shll $16,%edx
             shll $16,%edx
@@ -637,7 +618,7 @@ begin
             xchgl %edx,%eax
             xchgl %edx,%eax
             leave
             leave
             ret
             ret
-         LDISKFREE1:
+         .LDISKFREE1:
             cwde
             cwde
             leave
             leave
             ret
             ret
@@ -664,10 +645,10 @@ begin
         asm
         asm
             movb 8(%ebp),%dl
             movb 8(%ebp),%dl
             movb $0x36,%ah
             movb $0x36,%ah
-            call ___SYSCALL
+            call syscall
             movw %dx,%bx
             movw %dx,%bx
             cmpw $-1,%ax
             cmpw $-1,%ax
-            je LDISKSIZE1
+            je .LDISKSIZE1
             mulw %cx
             mulw %cx
             mulw %bx
             mulw %bx
             shll $16,%edx
             shll $16,%edx
@@ -675,7 +656,7 @@ begin
             xchgl %edx,%eax
             xchgl %edx,%eax
             leave
             leave
             ret
             ret
-        LDISKSIZE1:
+        .LDISKSIZE1:
             cwde
             cwde
             leave
             leave
             ret
             ret
@@ -734,10 +715,10 @@ procedure findfirst(const path:pathstr;attr:word;var f:searchRec);
             {No need to set DTA in EMX. Just give a pointer in ESI.}
             {No need to set DTA in EMX. Just give a pointer in ESI.}
             movl 18(%ebp),%esi
             movl 18(%ebp),%esi
             movb $0x4e,%ah
             movb $0x4e,%ah
-            call ___SYSCALL
-            jnc LFF
-            movw %ax,U_DOS_DOSERROR
-        LFF:
+            call syscall
+            jnc .LFF
+            movw %ax,doserror
+        .LFF:
         end;
         end;
     end;
     end;
 
 
@@ -759,10 +740,10 @@ procedure findnext(var f:searchRec);
         asm
         asm
             movl 12(%ebp),%esi
             movl 12(%ebp),%esi
             movb $0x4f,%ah
             movb $0x4f,%ah
-            call ___SYSCALL
-            jnc LFN
-            movw %ax,U_DOS_DOSERROR
-        LFN:
+            call syscall
+            jnc .LFN
+            movw %ax,doserror
+        .LFN:
         end;
         end;
     end;
     end;
 
 
@@ -783,6 +764,8 @@ end;
 
 
 type    PPchar=^Pchar;
 type    PPchar=^Pchar;
 
 
+{$ASMMODE DIRECT}
+
 function envs:PPchar;assembler;
 function envs:PPchar;assembler;
 
 
 asm
 asm
@@ -797,6 +780,8 @@ asm
     movl _envc,%eax
     movl _envc,%eax
 end ['EAX'];
 end ['EAX'];
 
 
+{$ASMMODE ATT}
+
 function envstr(index : longint) : string;
 function envstr(index : longint) : string;
 
 
 var hp:PPchar;
 var hp:PPchar;
@@ -863,8 +848,8 @@ begin
     for i:=length(path) downto 1 do
     for i:=length(path) downto 1 do
         if path[i]='.' then
         if path[i]='.' then
             begin
             begin
-                ext:=copy(path,p1,high(extstr));
-                delete(path,p1,length(path)-p1+1);
+                ext:=copy(path,i,high(extstr));
+                delete(path,i,length(path)-i+1);
                 break;
                 break;
             end;
             end;
     name:=path;
     name:=path;
@@ -876,7 +861,7 @@ function fexpand(const path:pathstr):pathstr;
 
 
     asm
     asm
         movb $0x19,%ah
         movb $0x19,%ah
-        call ___SYSCALL
+        call syscall
     end;
     end;
 
 
 var s,pa:string;
 var s,pa:string;
@@ -969,41 +954,36 @@ begin
     d.year:=time+1980;
     d.year:=time+1980;
 end;
 end;
 
 
-procedure getfattr(var f;var attr : word);
-
-var      n:array[0..255] of char;
+procedure getfattr(var f;var attr : word);assembler;
 
 
-begin
-    strpcopy(n,filerec(f).name);
-    {Alas, msdos(r) doesn't work when we are running in OS/2.}
-    asm
-        movw $0x4300,%ax
-        leal n,%edx
-        call ___SYSCALL
-        movl attr,%ebx
-        movw %cx,(%ebx)
-    end;
+asm
+    movw $0x4300,%ax
+    movl f,%edx
+    {addl $filerec.name,%edx Doesn't work!!}
+    addl $60,%edx
+    call syscall
+    movl attr,%ebx
+    movw %cx,(%ebx)
 end;
 end;
 
 
-procedure setfattr(var f;attr : word);
-
-var n:array[0..255] of char;
+procedure setfattr(var f;attr : word);assembler;
 
 
-begin
-    strpcopy(n,filerec(f).name);
-    {Alas, msdos(r) doesn't work when we are running in OS/2.}
-    asm
-        movw $0x4301,%ax
-        leal n,%edx
-        movw attr,%cx
-        call ___SYSCALL
-    end;
+asm
+    movw $0x4301,%ax
+    movl f,%edx
+    {addl $filerec.name,%edx Doesn't work!!}
+    addl $60,%edx
+    movw attr,%cx
+    call syscall
 end;
 end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1998-07-08 14:44:11  daniel
+  Revision 1.8  1998-10-16 14:18:02  daniel
+  * Updates
+
+  Revision 1.7  1998/07/08 14:44:11  daniel
   + Added moucalls and viocalls written by Tomas Hajny.
   + Added moucalls and viocalls written by Tomas Hajny.
   + Final routines in doscalls implemented.
   + Final routines in doscalls implemented.
   * Fixed bugs in dos.pas.
   * Fixed bugs in dos.pas.

+ 65 - 10
rtl/os2/kbdcalls.pas

@@ -36,6 +36,9 @@ unit KbdCalls;
 
 
 { Interface library to KBDCALLS.DLL (through EMXWRAP.DLL)
 { Interface library to KBDCALLS.DLL (through EMXWRAP.DLL)
 
 
+Variant records and aliases for some record types created to maintain highest
+possible level of compatibility with other existing OS/2 compilers.
+
 Changelog:
 Changelog:
 
 
     People:
     People:
@@ -71,7 +74,8 @@ uses    strings;
 {$endif FPK}
 {$endif FPK}
 
 
 const
 const
-{return codes / error constants (those marked with * shouldn't occur)}
+{return codes / error constants (those marked with * shouldn't occur under
+normal conditions)}
     NO_ERROR                        =  0;
     NO_ERROR                        =  0;
     ERROR_SEM_TIMEOUT               =121;
     ERROR_SEM_TIMEOUT               =121;
     ERROR_KBD_PARAMETER             =373;
     ERROR_KBD_PARAMETER             =373;
@@ -171,6 +175,16 @@ const
     KBDTRF_FINAL_CHAR_IN        =$40;   {either $40 or $80 or both}
     KBDTRF_FINAL_CHAR_IN        =$40;   {either $40 or $80 or both}
     KBDTRF_INTERIM_CHAR_IN      =$80;   {must be present          }
     KBDTRF_INTERIM_CHAR_IN      =$80;   {must be present          }
 
 
+{TKbdHWID.idKbd}
+    Keyboard_Undetermined   =$0000; {undetermined keyboard type}
+    Keyboard_AT_Compatible  =$0001; {PC-AT Standard Keyboard}
+    Keyboard_Enhanced_101   =$AB41; {101 Key Enhanced Keyboard}
+    Keyboard_Enhanced_102   =$AB41; {102 Key Enhanced Keyboard}
+    Keyboard_Enhanced_88_89 =$AB54; {88 and 89 Key Enhanced Keyboards}
+    Keyboard_Enhanced_122   =$AB85; {122 Key Enhanced Keyboard}
+    Keyboard_AT_Compatable=Keyboard_AT_Compatible;
+    Keyboard_SpaceSaver=Keyboard_Enhanced_88_89;
+
 
 
 type
 type
 
 
@@ -183,22 +197,30 @@ type
         chChar:char;    {ASCII character code; the scan code received}
         chChar:char;    {ASCII character code; the scan code received}
                         {from the keyboard is translated to the ASCII}
                         {from the keyboard is translated to the ASCII}
                         {character code                              }
                         {character code                              }
+        case boolean of
+        false:(
         chScan:byte;    {scan Code received from the keyboard}
         chScan:byte;    {scan Code received from the keyboard}
         fbStatus:byte;  {state of the keystroke event, see KBDTRF_*}
         fbStatus:byte;  {state of the keystroke event, see KBDTRF_*}
         bNlsShift:byte; {NLS shift status (always 0?)}
         bNlsShift:byte; {NLS shift status (always 0?)}
         fsState:word;   {shift key status, see KBDSTF_*}
         fsState:word;   {shift key status, see KBDSTF_*}
-        Time:cardinal;  {time stamp indicating when a key was pressed,}
+        Time:cardinal); {time stamp indicating when a key was pressed,}
                         {specified in milliseconds from the time      }
                         {specified in milliseconds from the time      }
                         {the system was started                       }
                         {the system was started                       }
+        true:(
+        chScan2:char;   (* should be chScan and bNlsShift, but this *)
+        fbStatus2:byte; (* construct is unsupported currently       *)
+        bNlsShift2:char);
     end;
     end;
     PKbdKeyInfo=^TKbdKeyInfo;
     PKbdKeyInfo=^TKbdKeyInfo;
+    KbdKeyInfo=TKbdKeyInfo; {for better compatibility with other compilers}
 
 
 {record type for KbdStringIn}
 {record type for KbdStringIn}
     TStringInBuf=record
     TStringInBuf=record
         cb:word;    {length of the input buffer, maximum length is 255}
         cb:word;    {length of the input buffer, maximum length is 255}
         cchIn:word; {number of bytes actually read into the buffer}
         cchIn:word; {number of bytes actually read into the buffer}
     end;
     end;
-    PStringInBuf=TStringInBuf;
+    PStringInBuf=^TStringInBuf;
+    StringInBuf=TStringInBuf;
 
 
 {TKbdInfo record type, for KbdSet/GetStatus}
 {TKbdInfo record type, for KbdSet/GetStatus}
     TKbdInfo=record
     TKbdInfo=record
@@ -209,7 +231,7 @@ type
                         {and extended-ASCII format, the turn-around character}
                         {and extended-ASCII format, the turn-around character}
                         {is defined as the carriage return, in ASCII format  }
                         {is defined as the carriage return, in ASCII format  }
                         {only, the turn-around character is defined in the   }
                         {only, the turn-around character is defined in the   }
-                        {low-order byte; usually $000D                       }
+                        {low-order byte; usually $000D                                }
         fsInterim,      {interim character flags: bits 0-4 and 6 - reserved   }
         fsInterim,      {interim character flags: bits 0-4 and 6 - reserved   }
                         {                                        and set to 0,}
                         {                                        and set to 0,}
                         {                         bit 5          - application}
                         {                         bit 5          - application}
@@ -224,6 +246,7 @@ type
         fsState:word;   {shift state, see TKbdInfo.fsState constants}
         fsState:word;   {shift state, see TKbdInfo.fsState constants}
     end;
     end;
     PKbdInfo=^TKbdInfo;
     PKbdInfo=^TKbdInfo;
+    KbdInfo=TKbdInfo;
 
 
 {record type for KbdGetHWID}
 {record type for KbdGetHWID}
     TKbdHWID=record
     TKbdHWID=record
@@ -237,10 +260,12 @@ type
                             {               $AB54 = 88 and 89 Key Enhanced    }
                             {               $AB54 = 88 and 89 Key Enhanced    }
                             {                        Keyboards                }
                             {                        Keyboards                }
                             {               $AB85 = 122 Key Enhanced Keyboard }
                             {               $AB85 = 122 Key Enhanced Keyboard }
+                            {- see KEYBOARD_* constants                       }
         usReserved1,        {reserved, returned set to zero (secondary ID?)}
         usReserved1,        {reserved, returned set to zero (secondary ID?)}
         usReserved2:word;   {reserved, returned set to zero}
         usReserved2:word;   {reserved, returned set to zero}
     end;
     end;
     PKbdHWID=^TKbdHWID;
     PKbdHWID=^TKbdHWID;
+    KbdHWID=TKbdHWID;
 
 
 {record type for KbdXlate}
 {record type for KbdXlate}
 (*   #pragma pack(2) ???*)
 (*   #pragma pack(2) ???*)
@@ -252,15 +277,17 @@ type
             chChar:char;    {ASCII character code; the scan code received}
             chChar:char;    {ASCII character code; the scan code received}
                             {from the keyboard is translated to the ASCII}
                             {from the keyboard is translated to the ASCII}
                             {character code                              }
                             {character code                              }
-            chScan:byte;    {scan Code received from the keyboard}
-            fbStatus:byte;  {state of the keystroke event, see KBDTRF_*}
+            case boolean of
+            false:(
+            chScan,         {scan Code received from the keyboard}
+            fbStatus,       {state of the keystroke event, see KBDTRF_*}
             bNlsShift:byte; {NLS shift status (always 0?)}
             bNlsShift:byte; {NLS shift status (always 0?)}
             fsState:word;   {shift key status, see KBDSTF_*}
             fsState:word;   {shift key status, see KBDSTF_*}
             Time:cardinal;  {time stamp indicating when a key was pressed,}
             Time:cardinal;  {time stamp indicating when a key was pressed,}
                             {specified in milliseconds from the time      }
                             {specified in milliseconds from the time      }
                             {the system was started                       }
                             {the system was started                       }
-            fsDD:word;      {device driver returned flag,}
-                            {see KbdDDFlagWord notes     }
+            fsDD:word;      {device driver returned flag, }
+                            {see KbdDDFlagWord notes below}
             fsXlate:word;   {translation flag: 0 - translation incomplete,}
             fsXlate:word;   {translation flag: 0 - translation incomplete,}
                             {                  1 - translation complete   }
                             {                  1 - translation complete   }
             fsShift:word;   {identifies the state of translation across    }
             fsShift:word;   {identifies the state of translation across    }
@@ -270,8 +297,13 @@ type
                             {should not be changed unless a new translation}
                             {should not be changed unless a new translation}
                             {is required (that is, reset value to zero)    }
                             {is required (that is, reset value to zero)    }
             sZero:word);    {reserved, set to 0}
             sZero:word);    {reserved, set to 0}
+            true:(
+            chScan2,        (* should be chScan, fbStatus and bNlsShift,   *)
+            fbStatus2,      (* but this construct is unsupported currently *)
+            bNlsShift2:char));
     end;
     end;
     PKbdTrans=^TKbdTrans;
     PKbdTrans=^TKbdTrans;
+    KbdTrans=TKbdTrans;
 
 
 {KbdDDFlagWord notes:
 {KbdDDFlagWord notes:
   bits 15-14    Available. These bits are available for communication between
   bits 15-14    Available. These bits are available for communication between
@@ -1317,6 +1349,8 @@ default keyboard (0) or a logical keyboard.}
   (focus), or is equal to zero and no other handle has the focus.}
   (focus), or is equal to zero and no other handle has the focus.}
 function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
 function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
                                                           KbdHandle:word):word;
                                                           KbdHandle:word):word;
+function KbdStringIn(CharBuf:PChar;LenInOutP:PStringInBuf;WaitFlag:word;
+                                                          KbdHandle:word):word;
 
 
 {Clear the keystroke buffer.}
 {Clear the keystroke buffer.}
 {KbdHandle is the default keyboard (0) or a logical keyboard.}
 {KbdHandle is the default keyboard (0) or a logical keyboard.}
@@ -1520,6 +1554,7 @@ function KbdGetHWID(var HWID:TKbdHWID;KbdHandle:word):word;
 
 
 {Undocumented in official IBM documentation}
 {Undocumented in official IBM documentation}
 function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word;
 function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word;
+function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word;
 
 
 {Translate scan codes with shift states into ASCII codes.}
 {Translate scan codes with shift states into ASCII codes.}
 {TransData - see TKbdTransData, KbdHandle is the default keyboard (0) or a
 {TransData - see TKbdTransData, KbdHandle is the default keyboard (0) or a
@@ -1545,8 +1580,9 @@ function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word;
 {Install, on the specified handle, the translate table which this call points
 {Install, on the specified handle, the translate table which this call points
 to. This translate table affects only this handle.}
 to. This translate table affects only this handle.}
 {XLateTbl is the translation table used to translate scan code to ASCII code
 {XLateTbl is the translation table used to translate scan code to ASCII code
-for a specified handle, KbdHandle is the default keyboard (0) or a logical
-keyboard.}
+for a specified handle (the format of the translation table is documented in
+the Set Code Page IOCTL 50h), KbdHandle is the default keyboard (0) or a
+logical keyboard.}
 {Possible return codes:
 {Possible return codes:
     0         NO_ERROR
     0         NO_ERROR
     377       ERROR_KBD_INVALID_ECHO_MASK
     377       ERROR_KBD_INVALID_ECHO_MASK
@@ -1564,6 +1600,8 @@ keyboard.}
   the caller for the translate table and is freed before the KbdSetCp is
   the caller for the translate table and is freed before the KbdSetCp is
   performed, KbdSetCp and future translations may fail.}
   performed, KbdSetCp and future translations may fail.}
 function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word;
 function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word;
+function KbdSetCustXt(var CodePage:word;KbdHandle:word):word;
+function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word;
 
 
 
 
 (* Following routines are not supported
 (* Following routines are not supported
@@ -1612,6 +1650,11 @@ function KbdStringIn(var CharBuf;var LenInOut:TStringInBuf;WaitFlag:word;
 external 'EMXWRAP' index 209;
 external 'EMXWRAP' index 209;
 {external 'KBDCALLS' index 9;}
 {external 'KBDCALLS' index 9;}
 
 
+function KbdStringIn(CharBuf:PChar;LenInOutP:PStringInBuf;WaitFlag:word;
+                                                          KbdHandle:word):word;
+external 'EMXWRAP' index 209;
+{external 'KBDCALLS' index 9;}
+
 function KbdFlushBuffer(KbdHandle:word):word;
 function KbdFlushBuffer(KbdHandle:word):word;
 external 'EMXWRAP' index 213;
 external 'EMXWRAP' index 213;
 {external 'KBDCALLS' index 13;}
 {external 'KBDCALLS' index 13;}
@@ -1664,6 +1707,10 @@ function KbdSetHWID(var HWID:TKbdHWID;KbdHandle:word):word;
 external 'EMXWRAP' index 225;
 external 'EMXWRAP' index 225;
 {external 'KBDCALLS' index 25;}
 {external 'KBDCALLS' index 25;}
 
 
+function KbdSetHWID(HWIDP:PKbdHWID;KbdHandle:word):word;
+external 'EMXWRAP' index 225;
+{external 'KBDCALLS' index 25;}
+
 function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word;
 function KbdXlate(var TransData:TKbdTrans;KbdHandle:word):word;
 external 'EMXWRAP' index 214;
 external 'EMXWRAP' index 214;
 {external 'KBDCALLS' index 14;}
 {external 'KBDCALLS' index 14;}
@@ -1672,6 +1719,14 @@ function KbdSetCustXt(var XLateTbl:TXLateTbl;KbdHandle:word):word;
 external 'EMXWRAP' index 201;
 external 'EMXWRAP' index 201;
 {external 'KBDCALLS' index 1;}
 {external 'KBDCALLS' index 1;}
 
 
+function KbdSetCustXt(var CodePage:word;KbdHandle:word):word;
+external 'EMXWRAP' index 201;
+{external 'KBDCALLS' index 1;}
+
+function KbdSetCustXt(var XLateTblP:pointer;KbdHandle:word):word;
+external 'EMXWRAP' index 201;
+{external 'KBDCALLS' index 1;}
+
 
 
 end.
 end.
 
 

+ 271 - 0
rtl/os2/moncalls.pas

@@ -0,0 +1,271 @@
+{Set tabsize to 4.}
+{****************************************************************************
+
+                           MONCALLS interface unit
+                     FPK-Pascal Runtime Library for OS/2
+                   Copyright (c) 1993,94 by Florian Kl„mpfl
+                    Copyright (c) 1997 by Dani‰l Mantione
+                      Copyright (c) 1998 by Tomas Hajny
+
+ The FPK-Pascal runtime library is distributed under the Library GNU Public
+ License v2. So is this unit. The Library GNU Public License requires you to
+ distribute the source code of this unit with any product that uses it.
+ Because the EMX library isn't under the LGPL, we grant you an exception to
+ this, and that is, when you compile a program with the FPK Pascal compiler,
+ you do not need to ship source code with that program, AS LONG AS YOU ARE
+ USING UNMODIFIED CODE! If you modify this code, you MUST change the next
+ line:
+
+ <This is an official, unmodified FPK Pascal source code file.>
+
+ Send us your modified files, we can work together if you want!
+
+ FPK-Pascal is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ Library GNU General Public License for more details.
+
+ You should have received a copy of the Library GNU General Public License
+ along with FPK-Pascal; see the file COPYING.LIB.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+****************************************************************************}
+
+unit MonCalls;
+
+{ Interface library to MONCALLS.DLL (through EMXWRAP.DLL)
+
+Please, note, that monitors are supported for OS/2 v2.1 and above only
+(not for v2.0) and that they cannot be used in PM applications.
+
+Changelog:
+
+    People:
+
+        TH - Tomas Hajny
+
+    Date:           Description of change:              Changed by:
+
+     -              First released version 1.0          TH
+
+Coding style:
+
+    I have tried to use the same coding style as Dani‰l Mantione in unit
+    DOSCALLS, although I can't say I would write it the same way otherwise
+    (I would write much more spaces myself, at least). Try to use it as well,
+    please. Original note by Dani‰l Mantione follows:
+
+
+    It may be well possible that coding style feels a bit strange to you.
+    Nevertheless I friendly ask you to try to make your changes not look all
+    to different. To make life easier, set your IDE to use tab characters,
+    turn optimal fill, autoindent and backspace unindents on and set a
+    tabsize of 4.}
+
+{***************************************************************************}
+interface
+{***************************************************************************}
+
+uses    strings;
+
+{$ifdef FPK}
+    {$packrecords 1}
+{$endif FPK}
+
+const
+{return codes / error constants (those marked with * shouldn't occur)}
+    NO_ERROR                        =     0;
+    ERROR_NOT_ENOUGH_MEMORY         =     8;
+    ERROR_OPEN_FAILED               =   110;
+    ERROR_MONITORS_NOT_SUPPORTED    =   165;
+    ERROR_MON_INVALID_PARMS         =   379;
+    ERROR_MON_INVALID_DEVNAME       =   380;
+    ERROR_MON_INVALID_HANDLE        =   381;
+    ERROR_MON_BUFFER_TOO_SMALL      =   382;
+    ERROR_MON_BUFFER_EMPTY          =   383;
+    ERROR_MON_DATA_TOO_LARGE        =   384;
+    ERROR_MON_BAD_BUFFER            =   730; {*}
+    ERROR_MON_CHAIN_HANDLE          = 32784; {*}
+    ERROR_MON_NOT_REGISTERED        = 32785; {*}
+
+{WaitFlag}
+    IO_WAIT     =0; {The monitor thread that issues DosMonRead wishes to block}
+                    {until a data record is available in its input buffer.}
+    IO_NOWAIT   =1; {The monitor thread that issues DosMonRead does not wish}
+                    {to block when its input buffer is empty.}
+
+
+{Terminate character device monitoring.  All monitor buffers associated with
+this process are flushed and closed.}
+{MonHandle - device handle returned from a previous DosMonOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    381       ERROR_MON_INVALID_HANDLE}
+{Remarks:
+* A single process may register one or more monitors with a character device
+  using the same device handle returned from a previous DosMonOpen call.
+  When DosMonClose is issued for a specific, opened device handle, all
+  monitors for the current process registered with this handle terminate.
+* When DosMonClose is issued, the monitor loses access to the device data
+  stream. Before issuing DosMonClose, monitor threads calling DosMonRead and
+  DosMonWrite should be terminated. After DosMonClose has been called,
+  DosMonRead calls return an ERROR_MON_BUFFER_EMPTY return code and
+  DosMonWrite calls return an ERROR_NOT_ENOUGH_MEMORY return code.
+* Data area containing monitor buffers should not be freed until after
+  DosMonClose is called. If data area containing monitor buffers is freed
+  before DosMonClose is called, a GP fault occurs when DosMonClose is called
+  and the process is terminated.
+* For a detailed description of this call see the chapter "Character Device
+  Monitors" in the IBM Operating System/2 Version 1.2 I/O Subsystems And
+  Device Support Volume 1.}
+function DosMonClose(MonHandle:word):word;
+
+{Gain access to a character device data stream.}
+{DevName - device name, monitor handle returned in MonHandle.}
+{Possible return codes:
+    0         NO_ERROR
+    110       ERROR_OPEN_FAILED
+    379       ERROR_MON_INVALID_PARMS
+    380       ERROR_MON_INVALID_DEVNAME}
+{Remarks:
+* Only one DosMonOpen call is necessary per device per process. That is,
+  several DosMonReg calls can be made using the same monitor handle to the
+  same device. This allows monitors to be registered using different values
+  for Index from the same process and going to the same device. When the
+  DosMonClose is issued, all of the monitors registered on the handle are
+  closed.
+* For a detailed description of this call see the chapter "Character Device
+  Monitors" in the IBM Operating System/2 Version 1.2 I/O Subsystems And
+  Device Support Volume 1.}
+function DosMonOpen(DevName:PChar;var MonHandle:word):word;
+function DosMonOpen(DevName:string;var MonHandle:word):word;
+
+{Wait for a data record, move it from the input buffer of a registered
+character device monitor and place it in a private data area where the monitor
+can freely access it.}
+{InBuf - monitor input buffer, WaitFlag - see IO_WAIT and IO_NOWAIT constants,
+DataBuf - data area in the calling process address space that the data from the
+monitor's input buffer is read into, ByteCount - on input size of the DataBuf,
+on return number of bytes of data moved.}
+{Possible return codes:
+    0         NO_ERROR
+    379       ERROR_MON_INVALID_PARMS
+    382       ERROR_MON_BUFFER_TOO_SMALL
+    383       ERROR_MON_BUFFER_EMPTY}
+{Remarks:
+* For a detailed description of this call see the chapter "Character Device
+  Monitors" in the IBM Operating System/2 Version 1.2 I/O Subsystems And
+  Device Support Volume 1.}
+function DosMonRead(var InBuf;WaitFlag:byte;var DataBuf;
+                                                      var ByteCount:word):word;
+
+{Establish an input and output buffers to monitor an I/O stream for a character
+device.}
+{MonHandle - device handle returned from a previous DosMonOpen call, InBuf -
+monitor input buffer, the monitor dispatcher moves data records into this
+buffer from the device driver (if the monitor is the first one in the monitor
+chain) or from the previous monitor in the chain, monitor then takes data from
+this buffer for filtering by calling DosMonRead, OutBuf - monitor output
+buffer, monitor places filtered data into this buffer by calling DosMonWrite,
+the monitor dispatcher moves data records from this buffer to the device driver
+(if the monitor is the last one in the monitor chain) or to the next monitor in
+the chain, PosCode - used to specify placement of a monitor's buffers with the
+monitor chain (FIRST, LAST or DEFAULT) and whether one or two threads are
+created by the monitor dispatcher to handle data movement (see explanation
+bellow), Index - device specific value, for the keyboard it pertains to the
+session you wish to register a monitor on, for the printer it pertains to the
+data or code page monitor chain.}
+{Possible return codes:
+    0         NO_ERROR
+    8         ERROR_NOT_ENOUGH_MEMORY
+    165       ERROR_MONITORS_NOT_SUPPORTED
+    379       ERROR_MON_INVALID_PARMS
+    381       ERROR_MON_INVALID_HANDLE
+    382       ERROR_MON_BUFFER_TOO_SMALL}
+{Remarks:
+* PosCode meaning:
+    0   DEFAULT (no position preference) and one thread for data movement
+    1   FIRST (monitor placed at beginning of monitor chain) and one thread for
+        data movement
+    2   LAST (monitor placed at the end of monitor chain) and one thread for
+        data movement
+    3   DEFAULT with two threads for data movement
+    4   FIRST with two threads for data movement
+    5   LAST with two threads for data movement
+  The first monitor in a monitor chain that registers as FIRST is placed at the
+  head of the monitor chain. The next monitor that registers as FIRST follows
+  the last monitor registered as FIRST, and so on. Similarly, the first monitor
+  that registers as LAST is placed at the end of the monitor chain. The next
+  monitor that registers as LAST is placed before the last monitor that
+  registered as LAST, and so on. The first monitor that registers as DEFAULT is
+  placed before the last monitor, if any, that registered as LAST. The next
+  monitor that registers as DEFAULT is placed before the last monitor that
+  registered as DEFAULT, and so on.
+* For a detailed description of this call see the chapter "Character Device
+  Monitors" in the IBM Operating System/2 Version 1.2 I/O Subsystems And
+  Device Support Volume 1.}
+function DosMonReg(MonHandle:word;var InBuf,OutBuf;PosCode,Index:word):word;
+
+{Move a filtered data record from the monitor's private data area into the
+monitor's output buffer.}
+{OutBuf - monitor output buffer, DataBuf - monitor's private data area
+containing a filtered data record of length ByteCount, this filtered data
+record is moved into the monitor's output buffer by this call, ByteCount - size
+of the data record.}
+{Possible return codes:
+    0         NO_ERROR
+    8         ERROR_NOT_ENOUGH_MEMORY
+    379       ERROR_MON_INVALID_PARMS
+    384       ERROR_MON_DATA_TOO_LARGE}
+{Remarks:
+* For a detailed description of the use of this call see the chapter
+  "Character Device Monitors" in the IBM Operating System/2 Version 1.2 I/O
+  Subsystems And Device Support Volume 1.}
+function DosMonWrite(var OutBuf,DataBuf;ByteCount:word):word;
+
+
+{***************************************************************************}
+implementation
+{***************************************************************************}
+
+
+function DosMonClose(MonHandle:word):word;
+external 'EMXWRAP' index 403;
+{external 'MONCALLS' index 3;}
+
+function DosMonOpen(DevName:PChar;var MonHandle:word):word;
+external 'EMXWRAP' index 404;
+{external 'MONCALLS' index 4;}
+
+function DosMonOpen(DevName:string;var MonHandle:word):word;
+begin
+    if DevName[0]=#255 then
+    begin
+        I:=byte(DevName[0]);
+        Move(DevName[1],DevName[0],255);
+        DevName[255]:=#0;
+        DosMonOpen:=DosMonOpen(@DevName,MonHandle);
+    end else
+    begin
+        DevName[Succ(byte(DevName[0]))]:=#0;
+        DosMonOpen:=DosMonOpen(@DevName[1],MonHandle);
+    end;
+end;
+
+function DosMonRead(var InBuf;WaitFlag:word;var DataBuf;
+                                                      var ByteCount:word):word;
+external 'EMXWRAP' index 402;
+{external 'MONCALLS' index 2;}
+
+function DosMonReg(MonHandle:word;var InBuf,OutBuf;PosCode,Index:word):word;
+external 'EMXWRAP' index 405;
+{external 'MONCALLS' index 5;}
+
+function DosMonWrite(var OutBuf,DataBuf;ByteCount:word):word;
+external 'EMXWRAP' index 401;
+{external 'MONCALLS' index 1;}
+
+
+end.
+

+ 686 - 66
rtl/os2/moucalls.pas

@@ -36,15 +36,18 @@ unit MouCalls;
 
 
 { Interface library to MOUCALLS.DLL (through EMXWRAP.DLL)
 { Interface library to MOUCALLS.DLL (through EMXWRAP.DLL)
 
 
+Variant records and aliases for some record types created to maintain highest
+possible level of compatibility with other existing OS/2 compilers.
+
 Changelog:
 Changelog:
 
 
     People:
     People:
 
 
-        TH - Tomas Hajny
+        TH - Tomas Hajny ([email protected] on Internet)
 
 
     Date:           Description of change:              Changed by:
     Date:           Description of change:              Changed by:
 
 
-     -              First released version 0.50         TH
+     -              First released version 1.0          TH
 
 
 Coding style:
 Coding style:
 
 
@@ -71,30 +74,33 @@ uses    strings;
 {$endif FPK}
 {$endif FPK}
 
 
 const
 const
-{return codes / error constants}
+{return codes / error constants (those marked with * shouldn't occur under
+normal conditions)}
+    NO_ERROR                        =  0;
+    ERROR_SEM_TIMEOUT               =121;
     ERROR_MOUSE_NO_DEVICE           =385;
     ERROR_MOUSE_NO_DEVICE           =385;
-    ERROR_MOUSE_INV_HANDLE          =386;
+    ERROR_MOUSE_INV_HANDLE          =386; {*}
     ERROR_MOUSE_INV_PARMS           =387;
     ERROR_MOUSE_INV_PARMS           =387;
-    ERROR_MOUSE_CANT_RESET          =388;
-    ERROR_MOUSE_DISPLAY_PARMS       =389;
+    ERROR_MOUSE_CANT_RESET          =388; {*}
+    ERROR_MOUSE_DISPLAY_PARMS       =389; {*}
     ERROR_MOUSE_INV_MODULE          =390;
     ERROR_MOUSE_INV_MODULE          =390;
-    ERROR_MOUSE_INV_ENTRY_PT        =391;
-    ERROR_MOUSE_INV_MASK            =392;
+    ERROR_MOUSE_INV_ENTRY_PT        =391; {*}
+    ERROR_MOUSE_INV_MASK            =392; {*}
     NO_ERROR_MOUSE_NO_DATA          =393;
     NO_ERROR_MOUSE_NO_DATA          =393;
-    NO_ERROR_MOUSE_PTR_DRAWN        =394;
+    NO_ERROR_MOUSE_PTR_DRAWN        =394; {*}
     ERROR_MOUSE_SMG_ONLY            =412;
     ERROR_MOUSE_SMG_ONLY            =412;
     ERROR_MOUSE_INVALID_ASCIIZ      =413;
     ERROR_MOUSE_INVALID_ASCIIZ      =413;
     ERROR_MOUSE_INVALID_MASK        =414;
     ERROR_MOUSE_INVALID_MASK        =414;
     ERROR_MOUSE_REGISTER            =415;
     ERROR_MOUSE_REGISTER            =415;
     ERROR_MOUSE_DEREGISTER          =416;
     ERROR_MOUSE_DEREGISTER          =416;
-    ERROR_MOUSE_INVALID_IOWAIT      =435;
+    ERROR_MOUSE_INVALID_IOWAIT      =435; {*}
     ERROR_MOU_DETACHED              =466;
     ERROR_MOU_DETACHED              =466;
     ERROR_MOUSE_NO_CONSOLE          =501;
     ERROR_MOUSE_NO_CONSOLE          =501;
-    ERROR_MOUSE_INVALID_HANDLE      =502;
+    ERROR_MOUSE_INVALID_HANDLE      =502; {*}
     ERROR_MOU_EXTENDED_SG           =505;
     ERROR_MOU_EXTENDED_SG           =505;
-    ERROR_MOU_NOT_INITIALIZED       =530;
-    ERROR_MOUINITREAL_DONE          =531;
-    ERROR_MOUSE_CALLER_NOT_SUBSYS   =533;
+    ERROR_MOU_NOT_INITIALIZED       =530; {*}
+    ERROR_MOUINITREAL_DONE          =531; {*}
+    ERROR_MOUSE_CALLER_NOT_SUBSYS   =533; {*}
 
 
 {constants for FnMask in MouRegister}
 {constants for FnMask in MouRegister}
     MR_MOUGETNUMBUTTONS =$00000001;
     MR_MOUGETNUMBUTTONS =$00000001;
@@ -123,25 +129,39 @@ const
     MHK_BUTTON3 =4;
     MHK_BUTTON3 =4;
 
 
 {MouGetDevStatus/MouSetDevStatus device status constants}
 {MouGetDevStatus/MouSetDevStatus device status constants}
-    MOUSE_QUEUEBUSY         =$0001;
-    MOUSE_BLOCKREAD         =$0002;
-    MOUSE_FLUSH             =$0004;
-    MOUSE_UNSUPPORTED_MODE  =$0008;
-    MOUSE_DISABLED          =$0100;
-    MOUSE_MICKEYS           =$0200;
-
-{constants for WaitFlag in MouReadEventQue}
-    MOU_NOWAIT   =$0000;
-    MOU_WAIT     =$0001;
+    MOUSE_QUEUEBUSY         =$0001; {event queue busy with I/O}
+    MOUSE_BLOCKREAD         =$0002; {block read in progress}
+    MOUSE_FLUSH             =$0004; {flush in progress}
+    MOUSE_UNSUPPORTED_MODE  =$0008; {pointer draw routine disabled}
+                                    {by unsupported mode          }
+    MOUSE_DISABLED          =$0100; {drawing operations for pointer}
+                                    {draw routine are disabled     }
+    MOUSE_MICKEYS           =$0200; {mouse data returned in mickeys, not pels}
+
+{constants for WaitFlag in MouReadEventQue and MouSynch}
+    MOU_NOWAIT   =$0000;    {MouReadEventQue: don't wait for data    }
+                            {   on empty queue (return a null record)}
+                            {MouSynch: control immediately}
+                            {   returned to requestor     }
+    MOU_WAIT     =$0001;    {MouReadEventQue: wait for data on empty queue}
+                            {MouSynch: requestor waits until}
+                            {   mouse device driver is free }
 
 
 {constants for MouGetEventMask/MouSetEventMask events}
 {constants for MouGetEventMask/MouSetEventMask events}
-    MOUSE_MOTION                =$0001;
-    MOUSE_MOTION_WITH_BN1_DOWN  =$0002;
-    MOUSE_BN1_DOWN              =$0004;
-    MOUSE_MOTION_WITH_BN2_DOWN  =$0008;
-    MOUSE_BN2_DOWN              =$0010;
-    MOUSE_MOTION_WITH_BN3_DOWN  =$0020;
-    MOUSE_BN3_DOWN              =$0040;
+    MOUSE_MOTION                =$0001; {report mouse motion events with}
+                                        {no button press/release events }
+    MOUSE_MOTION_WITH_BN1_DOWN  =$0002; {report button 1 press/release}
+                                        {events, with mouse motion    }
+    MOUSE_BN1_DOWN              =$0004; {report button 1 press/release}
+                                        {events, without mouse motion }
+    MOUSE_MOTION_WITH_BN2_DOWN  =$0008; {report button 2 press/release}
+                                        {events, with mouse motion    }
+    MOUSE_BN2_DOWN              =$0010; {report button 2 press/release}
+                                        {events, without mouse motion }
+    MOUSE_MOTION_WITH_BN3_DOWN  =$0020; {report button 3 press/release}
+                                        {events, with mouse motion    }
+    MOUSE_BN3_DOWN              =$0040; {report button 3 press/release}
+                                        {events, without mouse motion }
 
 
 {constants for Status in MouSetDevStatus}
 {constants for Status in MouSetDevStatus}
     MOU_DRAW    =0;
     MOU_DRAW    =0;
@@ -159,119 +179,708 @@ type
     THMOU=word;
     THMOU=word;
     PHMOU=^THMOU;
     PHMOU=^THMOU;
 
 
-{record type for MouGetPos/SetPtrPos}
+{record type for MouGetPtrPos/MouSetPtrPos}
     TPtrLoc=record
     TPtrLoc=record
-        Row:word;
-        Col:word;
+        Row,        {mouse pointer row coordinate (in pels or characters)}
+        Col:word;   {mouse pointer column coordinate (in pels or characters)}
     end;
     end;
     PPtrLoc=^TPtrLoc;
     PPtrLoc=^TPtrLoc;
+    PtrLoc=TPtrLoc;
 
 
-{record type for MouGetShape/SetPtrShape}
+{record type for MouGetPtrShape/MouSetPtrShape}
     TPtrShape=record
     TPtrShape=record
-        cb:word;        {length of image buffer in bytes}
-        Col:word;       {pointer width in characters or pixels}
-        Row:word;       {pointer height in characters or pixels}
-        ColHot:word;    {hotspot offset from the left side}
-        RowHot:word;    {hotspot offset from the top}
+        cb,             {length of image buffer in bytes}
+        Col,            {pointer width in characters (in text}
+                        {modes; always 1) or pixels (>= 1)   }
+        Row,            {pointer height in characters (in text}
+                        {modes; always 1) or pixels (>=1)     }
+        ColHot,         {hotspot offset from the left}
+                        {side, in characters or pels }
+                        {(must be 0 in text modes)   }
+        RowHot:word;    {hotspot offset from the top,}
+                        {in characters or pels       }
+                        {(must be 0 in text modes)   }
      end;
      end;
      PPtrShape=^TPtrShape;
      PPtrShape=^TPtrShape;
+     PtrShape=TPtrShape;
 
 
 {record type for MouReadEventQue}
 {record type for MouReadEventQue}
 (*   #pragma pack(2) ??? *)
 (*   #pragma pack(2) ??? *)
     TMouEventInfo=record
     TMouEventInfo=record
-        fs:word;        {event bits}
+        fs:word;        {event bits (state of the mouse at the time     }
+                        {of the event) - see MOUSE_MOTION,              }
+                        {MOUSE_MOTION_WITH_BN1_DOWN, MOUSE_BN1_DOWN,    }
+                        {MOUSE_MOTION_WITH_BN2_DOWN, MOUSE_BN2_DOWN,    }
+                        {MOUSE_MOTION_WITH_BN3_DOWN and MOUSE_BN3_DOWN  }
+                        {constants (other bits reserved and set to zero)}
         Time:cardinal;  {event timestamp - unique number of milliseconds}
         Time:cardinal;  {event timestamp - unique number of milliseconds}
-        Row:integer;    {pointer current row position}
+                        {(since the system was started                  }
+        Row,            {pointer current row position (absolute or relative)}
         Col:integer;    {pointer current column position}
         Col:integer;    {pointer current column position}
+                        {(absolute or relative)         }
     end;
     end;
     PMouEventInfo=^TMouEventInfo;
     PMouEventInfo=^TMouEventInfo;
+    MouEventInfo=TMouEventInfo;
 
 
 {record type for MouGetNumQueEl}
 {record type for MouGetNumQueEl}
     TMouQueInfo=record
     TMouQueInfo=record
-        cEvents:word;       {number of elements in event queue}
-        cmaxEvents:word;    {maximum queue size in elements}
+        cEvents,            {current number of elements in event}
+                            {queue, between 0 and cmaxEvents    }
+        cmaxEvents:word;    {maximum queue size in elements, as specified    }
+                            {in the QSIZE=NN parameter in DEVICE=MOUSExxx.SYS}
+                            {statement in CONFIG.SYS                         }
     end;
     end;
     PMouQueInfo=^TMouQueInfo;
     PMouQueInfo=^TMouQueInfo;
+    MouQueInfo=TMouQueInfo;
 
 
 {record type for MouGetScaleFact/MouSetScaleFact}
 {record type for MouGetScaleFact/MouSetScaleFact}
     TScaleFact=record
     TScaleFact=record
-        RowScale:word;  {scaling factor of current row}
-        ColScale:word;  {scaling factor of current column}
+        RowScale,       {current row scaling factor}
+        ColScale:word;  {current column scaling factor}
     end;
     end;
     PScaleFact=^TScaleFact;
     PScaleFact=^TScaleFact;
+    ScaleFact=TScaleFact;
 
 
 {record type for MouRemovePtr}
 {record type for MouRemovePtr}
     TNoPtrRect=record
     TNoPtrRect=record
-        Row:word;   {row of the top of the rectangle}
-        Col:word;   {column of the left edge}
-        cRow:word;  {row of the bottom}
-        cCol:word;  {column of the right edge}
+        Row,        {upper row of the rectangle (pels or characters)}
+        Col,        {column of the left edge (pels or characters)}
+        cRow,       {bottom row of the rectangle (pels or characters)}
+        cCol:word;  {column of the right edge (pels or characters)}
     end;
     end;
     PNoPtrRect=^TNoPtrRect;
     PNoPtrRect=^TNoPtrRect;
+    NoPtrRect=TNoPtrRect;
 
 
     TThreshold=record
     TThreshold=record
-        Length:word;
-        Level1:word;    {first movement level}
-        Lev1Mult:word;  {first level multiplier}
-        Level2:word;    {second movement level}
-        Lev2Mult:word;  {second level multiplier}
+        case boolean of
+        false:(Length:word;     {length of data in bytes}
+        Level1,                 {first movement level}
+        Lev1Mult,               {first level multiplier}
+        Level2,                 {second movement level}
+        Lev2Mult:word);         {second level multiplier}
+        true:(aLength:word);
     end;
     end;
     PThreshold=^TThreshold;
     PThreshold=^TThreshold;
-
-
+    Threshold=TThreshold;
+
+
+{Register a mouse subsystem within a session.}
+{ModuleName is name of the dynamic link module (the maximum length
+is 8 characters - plus the final #0 character in the PChar version of this
+call), ProcName is the dynamic link entry point name of a routine that receives
+control when any of the registered functions are called (the maximum length
+is 32 bytes - plus the final #0 character in the PChar version of this call),
+FnMask is a mask of bits, where each bit set to 1 identifies a mouse function
+being registered - see MR_MOU* constants.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    413       ERROR_MOUSE_INVALID_ASCIIZ
+    414       ERROR_MOUSE_INVALID_MASK
+    415       ERROR_MOUSE_REGISTER
+    466       ERROR_MOU_DETACHED
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The Base Mouse Subsystem is the default mouse subsystem. There can be only
+  one MouRegister outstanding for each session without an intervening
+  MouDeRegister. MouDeRegister must be issued by the same process that issued
+  MouRegister.
+* When any registered function is called, control is routed to EntryName.
+  When this routine is entered, four additional values are pushed onto the
+  stack. The first is the index number (Word) of the function being called.
+  The second is a near pointer (Word). The third is the caller's DS register
+  (Word). The fourth is the return address (DWord) to the mouse router. For
+  example, if MouGetNumMickeys were called and control routed to EntryName,
+  the stack would appear as if the following instructions were executed:
+
+  PUSH@ WORD    MickeyCnt
+  PUSH  WORD    MouHandle
+  CALL  FAR     MouGetNumMickeys
+  PUSH  WORD    Function Code
+  CALL  NEAR    Entry point in Mouse Router
+  PUSH  DS
+  CALL  FAR     EntryName
+
+
+* When a registered function returns to the Mouse Router, AX is interpreted
+  as follows:
+    AX = 0 - no error, do not invoke the Base Mouse Subsystem routine,
+            return AX = 0
+    AX = -1 - invoke the BaseMouse Subsystem routine, return AX = return code
+            from the Base Mouse Subsystem
+    AX = error (if not 0 or -1) - do not invoke the Base Mouse Subsystem
+            Routine, return AX = error
+* When the mouse router receives a mouse call, it routes it to the Base Mouse
+  Subsystem unless an application or other mouse subsystem has previously
+  issued MouRegister for that call. If the call was registered, the subsystem
+  is entered at the EntryName specified, and provided with the applicable
+  function code.
+* The registered function mask is used to determine whether a requested
+  function is performed by the registered mouse subsystem or default to the
+  Base Mouse Subsystem.
+* The following list shows the relationship of the mouse API calls and the
+  Function Code passed to either the Base Mouse Subsystem or a registered
+  mouse subsystem.
+
+  MOU API calls               Function Code
+  MouGetNumButtons            00h
+  MouGetNumMickeys            01h
+  MouGetDevStatus             02h
+  MouGetNumQueEl              03h
+  MouReadEventQue             04h
+  MouGetScaleFact             05h
+  MouGetEventMask             06h
+  MouSetScaleFact             07h
+  MouSetEventMask             08h
+  Reserved                    09h
+  Reserved                    0Ah
+  MouOpen                     0Bh
+  MouClose                    0Ch
+  MouGetPtrShape              0Dh
+  MouSetPtrShape              0Eh
+  MouDrawPtr                  0Fh
+  MouRemovePtr                10h
+  MouGetPtrPos                11h
+  MouSetPtrPos                12h
+  MouInitReal                 13h
+  MouFlushQue                 14h
+  MouSetDevStatus             15h
+* A registered mouse sybsystem must leave the stack, on exit, in the exact
+  state it was received.}
 function MouRegister(ModuleName,ProcName:PChar;FnMask:cardinal):word;
 function MouRegister(ModuleName,ProcName:PChar;FnMask:cardinal):word;
-
 function MouRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
 function MouRegister(ModuleName,ProcName:string;FnMask:cardinal):word;
 
 
+{Deregister a mouse subsystem previously registered within a session.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    416       ERROR_MOUSE_DEREGISTER
+    466       ERROR_MOU_DETACHED
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The process that issued the MouRegister must release the session
+  (by a MouDeRegister call) from the registered subsystem before another PID
+  may issue MouRegister.
+* The process that issued the MouRegister is the only process that may
+  issue MouDeRegister against the currently registered subsystem.
+* After the owning process has released the subsystem with a MouDeRegister
+  call, any other process in the session may issue a MouRegister and therefore
+  modify the mouse support for the entire session.}
 function MouDeRegister:word;
 function MouDeRegister:word;
 
 
+{Direct the mouse driver to flush (empty) the mouse event queue and the monitor
+chain data for the session.}
+{MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
 function MouFlushQue(MouHandle:word):word;
 function MouFlushQue(MouHandle:word):word;
 
 
+{Query the mouse driver to determine the current row and column coordinate
+position of the mouse pointer.}
+{Mouse pointer position returned in MouPtr, MouHandle is the mouse device
+handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* For a text window (VIO) application, the text window is a view on the
+  larger logical video buffer (LVB). The mouse pointer can be outside that
+  view and still be within the extent of the LVB. MouGetPtrPos then returns
+  the coordinates of the cell under the mouse pointer. If the pointer is
+  outside the LVB image extent, the coordinates of the nearest LVB cell are
+  returned. In either case, the LVB is scrolled until the reported LVB cell
+  appears within the view window.}
 function MouGetPtrPos(var MouPtr:TPtrLoc;MouHandle:word):word;
 function MouGetPtrPos(var MouPtr:TPtrLoc;MouHandle:word):word;
 
 
-function MouSetPtrPos(var MouPtr:TPtrLoc;MouHandle:word):word;
-
+{Direct the mouse driver to set a new row and column coordinate position for
+the mouse pointer.}
+{MouPtr contains the new pointer coordinates, MouHandle is the mouse device
+handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The application must ensure that the coordinate position specified conforms
+  to the current display mode orientation for the session. Pel values must
+  be used for graphics modes and character values for text modes.
+* This function has no effect on the display's current collision area
+  definition as specified by the MouDrawPtr call. If the mouse pointer image
+  is directed into a defined collision area, the pointer image is not drawn
+  until either the pointer is moved outside the collision area or the collision
+  area is released by the MouDrawPtr call.}
+function MouSetPtrPos(const MouPtr:TPtrLoc;MouHandle:word):word;
+
+{Set the pointer shape and size to be used as the mouse device pointer image
+for all applications in a session.}
+{ImageBuf contains the bit image used by the mouse device driver as the pointer
+shape for that session. The buffer consists of AND and XOR pointer masks
+in a format meaningful to the pointer draw device driver (see remarks bellow),
+ImageInfo contains the necessary data for the pointer draw device driver to
+build a row-by-column image for each bit plan for the current display mode,
+MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* An application passes a data image to the mouse device driver that the mouse
+  driver applies to the screen whenever the logical pointer position is not
+  located in the application-defined collision area. The application
+  synchronizes use of the screen with the mouse driver by way of MouRemovePtr
+  and MouDrawPtr.
+* The pointer shape is dependent on the display device driver used to support
+  the display device. OS/2 supports text and graphics modes. These modes are
+  restricted to modes 0 through 7, depending on the display device. Character
+  modes (modes 0, 1, 2, 3, and 7) support the pointer cursor only as a reverse
+  block character. This reverse block character has a character height
+  and width equal to 1.
+* The pointer shape is mapped by the Pointer Draw Device Driver and determined
+  completely by the application. The height and width may vary from 1 through
+  the pel size of the display screen. For restrictions concerning the Pointer
+  Draw Device Driver, see IBM Operating System/2 Version 1.2 I/O Subsystems And
+  Device Support Volume 1.
+* For CGA compatible text modes (0, 1, 2, and 3) the following describes
+  the AND and XOR pointer mask bit definitions for each character cell
+  of the masks. Bit values are:
+    Bit       Description
+    15        Blinking
+    14-12     Background color
+    11        Intensity
+    10-8      Foreground color
+    7-0       Character}
+* For other custom displays and for the extended modes of the EGA attachment,
+  it is possible to set the display to modes that require multiple bit planes.
+  In these cases, the area sized by the row and column limits must be repeated
+  for each bit plane supported in that mode. Consequently, the calling process
+  must supply enough data to allow the mouse device driver to draw the pointer
+  shape on all currently supported bit planes in that session. For text modes,
+  row and column offset must equal 0.}
+function MouSetPtrShape(var ImageBuf;var ImageInfo:TPtrShape;
+                                                          MouHandle:word):word;
 function MouSetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
 function MouSetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
                                                           MouHandle:word):word;
                                                           MouHandle:word):word;
 
 
+{Get (copy) the mouse pointer shape for the session.}
+{The pointer bit image is returned in ImageBuf (see MouSetPtrShape description
+for information about the resulting content of this buffer), the size of the
+pointer image buffer must be supplied in ImageInfo.cb (if the value is too
+small, the true length is placed in this field and an error is returned),
+on return, ImageInfo is filled with mouse pointer information, MouHandle is
+the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The application passes a parameter list with the same meaning as defined
+  for MouSetPtrShape to the mouse device driver. The mouse device driver
+  copies the parameters that describe the pointer shape and attributes into
+  the pointer definition control block pointed to by the PtrDefRec parameter.
+  The word 0 (buffer length = cb) pointer definition record parameter field
+  must contain the size in bytes of the application buffer where the device
+  driver is to insert the session's pointer image. All other words in
+  the parameter list are returned to the application by MouGetPtrShape.
+* For all OS/2 system-supported modes, size of the pointer image buffer
+  is specified in bytes and is equal to:
+    1) Mono & Text Modes:
+        For text mode, height and width must be 1, so length is always 4.
+
+        size = (height in chars) * (width in chars) * 2 * 2 = 1 * 1 * 2 * 2 = 4
+
+    2) Graphics Mode:
+        Width-in-pels must be a multiple of 8.
+
+        size = (height in pels) * (width in pels) * (bits per pel) * 2 / 8
+
+        a) Modes 4 and 5 (320 X 200)
+
+            size = (height) * (width) * 2 * 2 / 8
+
+        b) Mode 6 (640 X 200)
+
+            size = (height) * (width) * 1 * 2 / 8
+* If the buffer size is insufficient, the cb field contains the actual size
+  in bytes of the returned pointer image.
+* The pointer shape may be set by the application with MouSetPtrShape or may
+  be the default image provided by the installed Pointer Device Driver.}
+function MouGetPtrShape(var ImageBuf;var ImageInfo:TPtrShape;
+                                                          MouHandle:word):word;
 function MouGetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
 function MouGetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
                                                           MouHandle:word):word;
                                                           MouHandle:word):word;
 
 
+{Return status flags for the installed mouse device driver.}
+{The current status flag settings for the installed mouse device driver are
+returned in Status - see MOUSE_QUEUEBUSY, MOUSE_BLOCKREAD, MOUSE_FLUSH,
+MOUSE_UNSUPPORTED_MODE, MOUSE_DISABLED and MOUSE_MICKEYS constants (other bits
+are reserved and set to zero), MouHandle is the mouse device handle from
+a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
 function MouGetDevStatus(var Status:word;MouHandle:word):word;
 function MouGetDevStatus(var Status:word;MouHandle:word):word;
 
 
+{Return the number of buttons supported on the installed mouse driver.}
+{Number of physical buttons (1..3) returned in ButtonCount, MouHandle is
+the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
 function MouGetNumButtons(var ButtonCount:word;MouHandle:word):word;
 function MouGetNumButtons(var ButtonCount:word;MouHandle:word):word;
 
 
+{Return the number of mickeys in each centimeter for the installed mouse
+driver.}
+{Number of physical mouse motion units (mickeys) in each centimeter (a constant
+based upon the attached mouse device) returned in MickeyCnt, MouHandle is
+the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
 function MouGetNumMickeys(var MickeyCnt:word;MouHandle:word):word;
 function MouGetNumMickeys(var MickeyCnt:word;MouHandle:word):word;
 
 
+{Read an event from the mouse device FIFO event queue.}
+{The mouse event queue is returned in Event, WaitFlag determines the action to
+take when MouReadEventQue is issued and no event is available (the mouse event
+queue is empty) - see MOU_NOWAIT and MOU_WAIT constants, MouHandle is the mouse
+device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    393       ERROR_MOUSE_NO_DATA
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The types of queued events are directly affected by the current value of
+  the Mouse EventMask. MouSetEventMask is used to indicate the types of events
+  desired, and MouGetEventMask is used to query the current value of the mask.
+  Refer to these functions for further explanation of the masking of events.
+  Recognition of the mouse transition depends on the use of MouState returned
+  in the event record. The application should focus on bit transitions that
+  occur in this word. It is important to properly set the event mask with
+  MouSetEventMask for reporting the state transitions.
+  Event.fs reports the state of the mouse that resulted from the action that
+  caused the event. The action can be pressing or releasing a button, and/or
+  moving the mouse. All status is given, regardless of the EventMask that
+  was used to determine whether or not to report the event.
+  For example, assume the EventMask indicates that the application wishes only
+  button 1 events. The EventMask has only bits 1 and 2 set in this case. Also
+  assume the current state of the mouse is no buttons down, and mouse is not
+  moving. At this point, button 1 is pressed causing an event; the status shows
+  button 1 down (bit 2 set). Next the mouse is moved, thereby causing more
+  events; status shows bit 1 set. Finally, mouse is stopped and button 1 is
+  released. The event shows status with no bits set.
+  Next, button 2 is pressed. No event occurs. Mouse is then moved; again,
+  no event. Then, while mouse is still in motion, button 1 is pressed; an event
+  is generated with bits 1 and 3 set in the state word. While mouse is still
+  in motion, both buttons are released. Because button 1 changes states,
+  an event occurs. The state word has bit 0 set. Finally, mouse is stopped.
+  No event occurs, again because no button 1 transition has taken place.
+* The Event.Row and Event.Col fields may contain either absolute display
+  coordinates or relative mouse motion in mickeys. See MouSetDevStatus for
+  additional information.}
 function MouReadEventQue(var Event:TMouEventInfo;var WaitFlag:word;
 function MouReadEventQue(var Event:TMouEventInfo;var WaitFlag:word;
                                                           MouHandle:word):word;
                                                           MouHandle:word):word;
 
 
+{Return the current status for the mouse device driver event queue.}
+{Mouse queue status returned in MouseQInfo, MouHandle is the mouse device
+handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
 function MouGetNumQueEl(var MouseQInfo:TMouQueInfo;MouHandle:word):word;
 function MouGetNumQueEl(var MouseQInfo:TMouQueInfo;MouHandle:word):word;
 
 
+{Return the current value of the mouse event queue mask.}
+{The current mouse device driver's event mask (as previously set by
+MouSetEventMask call) is returned in EventMask - see MOUSE_MOTION,
+MOUSE_MOTION_WITH_BN1_DOWN, MOUSE_BN1_DOWN, MOUSE_MOTION_WITH_BN2_DOWN,
+MOUSE_BN2_DOWN, MOUSE_MOTION_WITH_BN3_DOWN and MOUSE_BN3_DOWN constants (other
+bits are reserved and set to zero, MouHandle is the mouse device handle from
+a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* Buttons are logically numbered from left to right.}
 function MouGetEventMask(var EventMask:word;MouHandle:word):word;
 function MouGetEventMask(var EventMask:word;MouHandle:word):word;
 
 
+{Assign a new event mask to the current mouse device driver.}
+{EventMask contains the mask indicating what mouse events are to be placed on
+the event queue (see MouReadEventQue) and which events are to be ignored - see
+MOUSE_MOTION, MOUSE_MOTION_WITH_BN1_DOWN, MOUSE_BN1_DOWN,
+MOUSE_MOTION_WITH_BN2_DOWN, MOUSE_BN2_DOWN, MOUSE_MOTION_WITH_BN3_DOWN and
+MOUSE_BN3_DOWN constants (other bits reserved and set to zero; a bit set to
+zero means that the associated type of event is not reported to the
+application, mouse buttons are always numbered from left to right - when the
+mouse is properly positioned for use, the left-hand button is button 1),
+MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* Setting a bit in the event mask means that the associated event is reported
+  on the mouse FIFO event queue. See MouReadEventQue for examples of event
+  mask use.}
 function MouSetEventMask(var EventMask:word;MouHandle:word):word;
 function MouSetEventMask(var EventMask:word;MouHandle:word):word;
 
 
+{Return scaling factors for the current mouse device (a pair of 1-word
+values).}
+{Current row and column coordinate scaling factors (1 <= factor <= 32767)
+returned in Scale (see MouSetScaleFact for more information), MouHandle is
+the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The units of the scale factor depend on the mode of the display screen
+  for the session. If the screen is operating in text mode, the scaling units
+  are relative to characters. If the screen is operating in graphics mode,
+  the scaling units are relative to pels.}
 function MouGetScaleFact(var Scale:TScaleFact;MouHandle:word):word;
 function MouGetScaleFact(var Scale:TScaleFact;MouHandle:word):word;
 
 
-function MouSetScaleFact(var Scale:TScaleFact;MouHandle:word):word;
-
+{Assign to the current mouse device driver a new pair of 1-word scaling
+factors.}
+{Scale contains the new row and column coordinate scaling factors (1 <= factor
+<= 32767), MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouSetScaleFact sets the mickey-to-pixel ratio for mouse motion. The row
+  scale and column scale ratios specify a number of mickeys for each 8 pixels.
+  The default value for the row scale is 16 mickeys for each 8 pixels. The
+  default value for the column scale is 8 mickeys to 8 pixels.
+* The number of pixels moved does not have to correspond 1-to-1 with the number
+  of mickeys the mouse moves. The scaling factor defines a sensitivity
+  for the mouse that is a ratio of the number of mickeys required to move
+  the cursor 8 pixels on the screen. The sensitivity determines at what rate
+  the cursor moves on the screen.}
+function MouSetScaleFact(const Scale:TScaleFact;MouHandle:word):word;
+
+{Open the mouse device for the current session.}
+{DriverName contains the name of the pointer draw device driver to be used as
+the pointer-image drawing routine for this session (such device driver must be
+included in the CONFIG.SYS file at system start-up time) or is nil (the default
+pointer draw device driver supplied by the system is used then), mouse device
+handle is returned in MouHandle.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    390       ERROR_MOUSE_INV_MODULE_PT
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouOpen initializes the mouse functions to a known state. The application
+  may have to issue additional mouse functions to establish the environment
+  it desires. For example, after the MouOpen, the collision area is defined
+  to be the size of the entire display. Therefore, to get the pointer to be
+  displayed, the application must issue a MouDrawPtr to remove the collision
+  area.
+* The state of the mouse after the first MouOpen is:
+  - Row/Col scale factors set to 16/8 (see MouSetScaleFact)
+  - all events reported (see MouSetEventMask)
+  - empty event queue (see MouReadEventQue and MouGetNumQueEl)
+  - all user settable Device Status bits reset (set to zero;
+    see MouSetDevStatus)
+  - pointer set to center of screen if valid display mode is set (see
+    MouSetPtrPos)
+  - pointer shape set to the default for the pointer device driver currently
+    registered in the session (see MouSetPtrShape)
+  - collision area equal to full screen (see MouDrawPtr and MouRemovePtr)
+* DriverName has a different definition when the caller is the Base Video
+  Subsystem (BVS). However, this implies direct calling of the 16-bit routine,
+  which is not supported currently. In such case the selector portion
+  of the pointer is zero, the offset portion is non-zero and contains a display
+  configuration number (sequentially numbered where 1 is the first display
+  configuration). The MouOpen call issued by BVS is executed on the VioSetMode
+  path. Using the display configuration number passed on the MouOpen call, the
+  Base Mouse Subsystem can detect a change in display configurations. This form
+  of the MouOpen call is not recommended for applications. Applications should
+  either send the name of the pointer draw device driver or nil.}
 function MouOpen(DriverName:PChar;var MouHandle:word):word;
 function MouOpen(DriverName:PChar;var MouHandle:word):word;
-
 function MouOpen(DriverName:string;var MouHandle:word):word;
 function MouOpen(DriverName:string;var MouHandle:word):word;
 
 
+{Close the mouse device for the current session.}
+{MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouClose closes the mouse device for the current session and removes the
+  mouse device driver handle from the list of valid open mouse device
+  handles.}
 function MouClose(MouHandle:word):word;
 function MouClose(MouHandle:word):word;
 
 
+{Notify the mouse device driver that the area defined by the passed parameters
+if for exclusive use of the application. This area is defined as the
+"collision" area and is not available to the mouse device driver when drawing
+pointer images.}
+{ProtectArea is the pointer shape collision area, MouHandle is the mouse device
+handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouRemovePtr may be issued by any process in the session. However, only one
+  collision area is active at a time. Each MouRemovePtr command has the effect
+  of resetting the collision area to the location and area specified
+  by the current command.
+* If the logical pointer position is outside of the collision area specified
+  by the latest MouRemovePtr command, the pointer image is drawn.
+* The MouDrawPtr command effectively cancels the MouRemovePtr command
+  and allows the pointer to be drawn anywhere on the screen, until a new
+  MouRemovePtr command is issued.}
 function MouRemovePtr(var ProtectArea:TNoPtrRect;MouHandle:word):word;
 function MouRemovePtr(var ProtectArea:TNoPtrRect;MouHandle:word):word;
 
 
+{Notify the mouse device driver that an area previously restricted
+to the pointer image is now available to the mouse device driver.}
+{MouHandle is the mouse device handle from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* The collision area (the pointer image restricted area) is established by
+  MouOpen and by MouRemovePtr. MouDrawPtr nullifies the effect of the
+  MouRemovePtr command. If there was no previous MouDrawPtr command or if a
+  previous  MouDrawPtr command has already nullified the collision area, the
+  MouRemovePtr command is effectively a null operation.
+* This call is required to begin session pointer image drawing. Immediately
+  after MouOpen is issued, the collision area is defined as the size of the
+  display. A MouDrawPtr is issued to begin pointer drawing after the
+  MouOpen.}
 function MouDrawPtr(MouHandle:word):word;
 function MouDrawPtr(MouHandle:word):word;
 
 
+{Set the mouse device driver status flags for the installed mouse device
+driver.}
+{Status contains the desired status flag settings (2-byte set, only the
+high-order byte has meaning - see MOUSE_DISABLED and MOUSE_MICKEYS constants;
+other bits are reserved and set to zero). MouHandle is the mouse device handle
+from a previous MouOpen call.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    387       ERROR_MOUSE_INV_PARMS
+    466       ERROR_MOU_DETACHED
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouSetDevStatus is the complement to MouGetDevStatus. However, not all status
+  flags may be set with MouSetDevStatus. Only the flags corresponding
+  to the following functions may be modified:
+  - Return data in mickeys
+    Normally, mouse data is returned to the application with the absolute
+    display mode coordinates of the pointer image position on the display
+    screen. By setting this status flag, mouse data is returned in relative
+    mickeys, a unit of mouse movement.
+  - Don't call pointer draw device
+    Normally, the pointer draw device driver is called for all drawing
+    operations. By setting this status flag, the mouse device driver does not
+    call the pointer draw device driver. The application must draw any required
+    pointer image on the screen.}
 function MouSetDevStatus(var Status:word;MouHandle:word):word;
 function MouSetDevStatus(var Status:word;MouHandle:word):word;
 
 
+{Initialize mouse pointer draw support for DOS mode.}
+{Name of the Pointer Draw Device Driver used as the pointer-image drawing
+routine for the DOS mode session must sent in DriverName; the name of the
+device driver must be included in the CONFIG.SYS file at system start-up time.}
+{Possible return codes:
+    0         NO_ERROR
+    385       ERROR_MOUSE_NO_DEVICE
+    466       ERROR_MOU_DETACHED
+    412       ERROR_MOUSE_SMG_ONLY
+    501       ERROR_MOUSE_NO_CONSOLE
+    505       ERROR_MOU_EXTENDED_SG}
+{Remarks:
+* MouInitReal is issued by the Base Video Subsystem at system initialization
+  time.
+* The DOS mode mouse API (INT 33h), in contrast to the OS/2 mode Mouse API,
+  does not contain an OPEN command. In addition, there is only one session
+  for DOS mode.
+* The default pointer draw routine for DOS mode is located in the same pointer
+  draw device driver, POINTER$, that is used for OS/2 mode. Establishing
+  addressability to the pointer draw routine must be done during system
+  initialization. This requires passing the entry point of the DOS mode pointer
+  draw routine to the mouse device driver. This is the purpose
+  of the MouInitReal call. It passes the address of the default, power-up
+  pointer draw routine for DOS mode to the mouse device driver. This
+  initialization is transparent to applications.
+* This call is for use only by the Base Video Subsystem when invoked during
+  system initialization under the shell/session manager PID.
+* The error code ERROR_MOUSE_SMG_ONLY is valid from shell process only.
+* When using direct calls to the 16-bit routine, another version of this call
+  is supported as well - if the selector part of the far pointer is zero
+  and the offset portion is non-zero, the offset portion identifies the
+  power-up display configuration. However, this isn't possible in the current
+  implementation (using 32-bit wrap-around function supplied in EMXWRAP.DLL).}
 function MouInitReal(DriverName:PChar):word;
 function MouInitReal(DriverName:PChar):word;
-
 function MouInitReal(DriverName:string):word;
 function MouInitReal(DriverName:string):word;
 
 
+{Synchronize the mouse subsystem with the mouse device driver.}
+{WaitFlag specifies whether the routine should wait for the mouse device driver
+being free - see MOU_NOWAIT and MOU_WAIT constants.}
+{Possible return codes:
+    0         NO_ERROR
+    121       ERROR_SEM_TIMEOUT}
+{Remarks:
+* MouSynch blocks all other threads within a session until the semaphore
+  clears (returns from the subsystem to the router). To ensure proper
+  synchronization, MouSynch should be issued by a mouse subsystem if it intends
+  to access dynamically modifiable shared data for each session or if it
+  intends to issue a DosDevIOCtl. MouSynch does not protect globally shared
+  data from threads in other sessions.}
 function MouSynch(WaitFlag:word):word;
 function MouSynch(WaitFlag:word):word;
 
 
 function MouGetThreshold(var MouThreshold:TThreshold;MouHandle:word):word;
 function MouGetThreshold(var MouThreshold:TThreshold;MouHandle:word):word;
@@ -323,7 +932,7 @@ function MouGetPtrPos(var MouPtr:TPtrLoc;MouHandle:word):word;
 external 'EMXWRAP' index 319;
 external 'EMXWRAP' index 319;
 {external 'MOUCALLS' index 19;}
 {external 'MOUCALLS' index 19;}
 
 
-function MouSetPtrPos(var MouPtr:TPtrLoc;MouHandle:word):word;
+function MouSetPtrPos(const MouPtr:TPtrLoc;MouHandle:word):word;
 external 'EMXWRAP' index 321;
 external 'EMXWRAP' index 321;
 {external 'MOUCALLS' index 21;}
 {external 'MOUCALLS' index 21;}
 
 
@@ -332,6 +941,16 @@ function MouSetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
 external 'EMXWRAP' index 302;
 external 'EMXWRAP' index 302;
 {external 'MOUCALLS' index 2;}
 {external 'MOUCALLS' index 2;}
 
 
+function MouSetPtrShape(var ImageBuf;var ImageInfo:TPtrShape;
+                                                          MouHandle:word):word;
+external 'EMXWRAP' index 302;
+{external 'MOUCALLS' index 2;}
+
+function MouGetPtrShape(var ImageBuf;var ImageInfo:TPtrShape;
+                                                          MouHandle:word):word;
+external 'EMXWRAP' index 301;
+{external 'MOUCALLS' index 1;}
+
 function MouGetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
 function MouGetPtrShape(ImageBuf:pointer;var ImageInfo:TPtrShape;
                                                           MouHandle:word):word;
                                                           MouHandle:word):word;
 external 'EMXWRAP' index 301;
 external 'EMXWRAP' index 301;
@@ -370,7 +989,7 @@ function MouGetScaleFact(var Scale:TScaleFact;MouHandle:word):word;
 external 'EMXWRAP' index 306;
 external 'EMXWRAP' index 306;
 {external 'MOUCALLS' index 6;}
 {external 'MOUCALLS' index 6;}
 
 
-function MouSetScaleFact(var Scale:TScaleFact;MouHandle:word):word;
+function MouSetScaleFact(const Scale:TScaleFact;MouHandle:word):word;
 external 'EMXWRAP' index 311;
 external 'EMXWRAP' index 311;
 {external 'MOUCALLS' index 11;}
 {external 'MOUCALLS' index 11;}
 
 
@@ -465,3 +1084,4 @@ external 'MOUCALLS' index 10;
 
 
 
 
 end.
 end.
+

+ 59 - 19
rtl/os2/viocalls.pas

@@ -36,11 +36,14 @@ unit VioCalls;
 
 
 { Interface library to VIOCALLS.DLL (through EMXWRAP.DLL)
 { Interface library to VIOCALLS.DLL (through EMXWRAP.DLL)
 
 
+Variant records and aliases for some record types created to maintain highest
+possible level of compatibility with other existing OS/2 compilers.
+
 Changelog:
 Changelog:
 
 
     People:
     People:
 
 
-        TH - Tomas Hajny
+        TH - Tomas Hajny ([email protected] on Internet)
 
 
     Date:           Description of change:              Changed by:
     Date:           Description of change:              Changed by:
 
 
@@ -74,6 +77,7 @@ uses    strings;
 
 
 const
 const
 {return codes / error constants}
 {return codes / error constants}
+    NO_ERROR                        =  0;
     ERROR_VIO_INVALID_MASK          =349;
     ERROR_VIO_INVALID_MASK          =349;
     ERROR_VIO_PTR                   =350;
     ERROR_VIO_PTR                   =350;
     ERROR_VIO_APTR                  =351;
     ERROR_VIO_APTR                  =351;
@@ -364,39 +368,55 @@ type
         Attr:word;      {Cursor colour attribute (-1=hidden)}
         Attr:word;      {Cursor colour attribute (-1=hidden)}
     end;
     end;
     PVioCursorInfo=^TVioCursorInfo;
     PVioCursorInfo=^TVioCursorInfo;
+    VioCursorInfo=TVioCursorInfo;
 
 
 {record type for VioSetMode/GetMode}
 {record type for VioSetMode/GetMode}
     TVioModeInfo=record
     TVioModeInfo=record
         cb:word;                    {Size of the record}
         cb:word;                    {Size of the record}
-        fbType:byte;                {8-bit mask identifying the mode}
+        case boolean of
+        false:(
+        fbType,                     {8-bit mask identifying the mode}
                                     {- see VGMT_* constants         }
                                     {- see VGMT_* constants         }
         Color:byte;                 {Number of colour bits available}
         Color:byte;                 {Number of colour bits available}
                                     {(1=>2 colours, 2=>4,...) - see }
                                     {(1=>2 colours, 2=>4,...) - see }
                                     {COLORS_* constants             }
                                     {COLORS_* constants             }
-        Col:word;                   {Number of text character columns}
-        Row:word;                   {Number of text character rows}
-        HRes:word;                  {Display width in pixels}
+        Col,                        {Number of text character columns}
+        Row,                        {Number of text character rows}
+        HRes,                       {Display width in pixels}
         VRes:word;                  {Display height in pixels}
         VRes:word;                  {Display height in pixels}
-        fmt_ID:byte;                {Format of the attributes}
+        fmt_ID,                     {Format of the attributes}
         Attrib:byte;                {Number of attributes in fmt_ID field}
         Attrib:byte;                {Number of attributes in fmt_ID field}
-        Buf_Addr:cardinal;          {Address of the physical display buffer}
-        Buf_Length:cardinal;        {Length of the physical display buffer}
-        Full_Length:cardinal;       {Size of the buffer needed to save}
+        Buf_Addr,                   {Address of the physical display buffer}
+        Buf_Length,                 {Length of the physical display buffer}
+        Full_Length,                {Size of the buffer needed to save}
                                     {the whole physical buffer        }
                                     {the whole physical buffer        }
         Partial_Length:cardinal;    {Size of the buffer needed to save}
         Partial_Length:cardinal;    {Size of the buffer needed to save}
                                     {the part of the physical buffer  }
                                     {the part of the physical buffer  }
                                     {overwritten with VioPopup        }
                                     {overwritten with VioPopup        }
-        Ext_Data_Addr:pointer;      {Address of an extended-mode data}
+        Ext_Data_Addr:pointer);     {Address of an extended-mode data}
+        true:(
+        fbType2,                (* should be fbType, Color, etc., but this *)
+        Color2:char;            (* construct is unsupported currently      *)
+        Col2,
+        Row2,
+        HRes2,
+        VRes2:word;
+        fmt_ID2,
+        Attrib2:char);
     end;
     end;
     PVioModeInfo=^TVioModeInfo;
     PVioModeInfo=^TVioModeInfo;
+    VioModeInfo=TVioModeInfo;
 
 
 {record type for VioGetPhysBuf}
 {record type for VioGetPhysBuf}
     TVioPhysBuf=record
     TVioPhysBuf=record
-        pBuf:pointer;   {Absolute screen address}
-        cb:cardinal;    {Length of the buffer in bytes}
-        Sel:word;       {Selector for video access}
+        pBuf:pointer;       {Absolute screen address}
+        cb:cardinal;        {Length of the buffer in bytes}
+        case boolean of
+        false:(Sel:word);   {Selector for video access}
+        true:(aSel:array[0..0] of word);
     end;
     end;
     PVioPhysBuf=^TVioPhysBuf;
     PVioPhysBuf=^TVioPhysBuf;
+    VioPhysBuf=TVioPhysBuf;
 
 
 {record type for VioGetConfig}
 {record type for VioGetConfig}
 (*   #pragma pack(2) ??? *)
 (*   #pragma pack(2) ??? *)
@@ -425,17 +445,27 @@ type
                                     {about emulated display types}
                                     {about emulated display types}
        end;
        end;
        PVioConfigInfo=^TVioConfigInfo;
        PVioConfigInfo=^TVioConfigInfo;
+       VioConfigInfo=TVioConfigInfo;
 
 
 {record type for VioGetFont/VioSetFont}
 {record type for VioGetFont/VioSetFont}
     TVioFontInfo=record
     TVioFontInfo=record
-        cb:word;        {Size of the record}
-        rType:word;     {Request type}
-        cxCell:word;    {Columns per cell (cell width)}
-        cyCell:word;    {Rows per cell (cell height)}
-        pbData:pointer; {Address of caller's buffer}
-        cbData:word;    {Size of caller's buffer in bytes}
+        cb:word;            {Size of the data record}
+        case byte of
+        1:(
+        rType,              {Request type}
+        cxCell,             {Columns per cell (cell width)}
+        cyCell:word;        {Rows per cell (cell height)}
+        pbData:pointer;     {Address of caller's buffer}
+        cbData:word);       {Size of caller's buffer in bytes}
+        2:(
+        aType,
+        cxCell2,
+        cyCell2:word;
+        pbData2:longint);   (* should be pbData, but this construct *)
+        3:(_type:word);     (* is not supported currently           *)
     end;
     end;
     PVioFontInfo=^TVioFontInfo;
     PVioFontInfo=^TVioFontInfo;
+    VioFontInfo=TVioFontInfo;  (* *)
 
 
 {record types for VioGetState/VioSetState}
 {record types for VioGetState/VioSetState}
     TVioPalState=record
     TVioPalState=record
@@ -445,6 +475,7 @@ type
         AColor:array[0..15] of word;    {Up to 16 register values}
         AColor:array[0..15] of word;    {Up to 16 register values}
     end;
     end;
     PVioPalState=^TVioPalState;
     PVioPalState=^TVioPalState;
+    VioPalState=TVioPalState;
 
 
     TVioOverscan=record
     TVioOverscan=record
         cb:word;    {Size of the record}
         cb:word;    {Size of the record}
@@ -452,6 +483,7 @@ type
         Color:word; {The colour of the border area}
         Color:word; {The colour of the border area}
     end;
     end;
     PVioOverscan=^TVioOverscan;
     PVioOverscan=^TVioOverscan;
+    VioOverScan=TVioOverScan;
 
 
     TVioIntensity=record
     TVioIntensity=record
         cb:word;    {Size of the record}
         cb:word;    {Size of the record}
@@ -459,6 +491,7 @@ type
         fs:word;    {The flink/bold background switch}
         fs:word;    {The flink/bold background switch}
     end;
     end;
     PVioIntensity=^TVioIntensity;
     PVioIntensity=^TVioIntensity;
+    VioIntensity=TVioIntensity;
 
 
     TVioColorReg=record
     TVioColorReg=record
         cb:word;                {Size of the record}
         cb:word;                {Size of the record}
@@ -468,6 +501,7 @@ type
         ColorRegAddr:pointer;   {pointer to an array with colour values}
         ColorRegAddr:pointer;   {pointer to an array with colour values}
     end;
     end;
     PVioColorReg=^TVioColorReg;
     PVioColorReg=^TVioColorReg;
+    VioColorReg=TVioColorReg;
 
 
     TVioSetULineLoc=record
     TVioSetULineLoc=record
         cb:word;        {Size of the record}
         cb:word;        {Size of the record}
@@ -475,6 +509,7 @@ type
         ScanLine:word;  {Location of the underline (32=no underline)}
         ScanLine:word;  {Location of the underline (32=no underline)}
     end;
     end;
     PVioSetULineLoc=^TVioSetULineLoc;
     PVioSetULineLoc=^TVioSetULineLoc;
+    VioSetULineLoc=TVioSetULineLoc;
 
 
     TVioSetTarget=record
     TVioSetTarget=record
         cb:word;                {Size of the record}
         cb:word;                {Size of the record}
@@ -483,6 +518,7 @@ type
                                 {(see VIO_CONFIG_* constants)}
                                 {(see VIO_CONFIG_* constants)}
     end;
     end;
     PVioSetTarget=^TVioSetTarget;
     PVioSetTarget=^TVioSetTarget;
+    VioSetTarget=TVioSetTarget;
 
 
     TStr8=array[0..7] of char;
     TStr8=array[0..7] of char;
     PStr8=^TStr8;
     PStr8=^TStr8;
@@ -501,6 +537,7 @@ type
         fsFontUse:word;
         fsFontUse:word;
     end;
     end;
     PFAttrs=^TFAttrs;
     PFAttrs=^TFAttrs;
+    FAttrs=TFAttrs;
 
 
 {font metrics returned by GpiQueryFonts and others}
 {font metrics returned by GpiQueryFonts and others}
     TPanose=record
     TPanose=record
@@ -517,6 +554,7 @@ type
         fbPassedISO:byte;
         fbPassedISO:byte;
         fbFailedISO:byte;
         fbFailedISO:byte;
     end;
     end;
+    PPanose=^TPanose;
 
 
     TFontMetrics=record
     TFontMetrics=record
         szFamilyname:array[0..FACESIZE-1] of char;
         szFamilyname:array[0..FACESIZE-1] of char;
@@ -573,6 +611,7 @@ type
         Panose:TPanose;
         Panose:TPanose;
     end;
     end;
     PFontMetrics=^TFontMetrics;
     PFontMetrics=^TFontMetrics;
+    FontMetrics=TFontMetrics;
 
 
 
 
 function VioRegister(ModuleName,ProcName:PChar;FnMask1,FnMask2:cardinal):word;
 function VioRegister(ModuleName,ProcName:PChar;FnMask1,FnMask2:cardinal):word;
@@ -1058,3 +1097,4 @@ external 'EMXWRAP' index 30;
 {external 'PMVIOP' index 30;}
 {external 'PMVIOP' index 30;}
 
 
 end.
 end.
+