home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_11 / watson / vds.c < prev    next >
C/C++ Source or Header  |  1993-09-03  |  2KB  |  94 lines

  1. /*
  2. listing 3
  3. vds.c - VDS interface functions
  4. Written by Robert Watson
  5. (C) Copyright Robert Watson 1993
  6. */
  7.  
  8. #include <dos.h>
  9.  
  10. #include "vds.h"
  11.  
  12. /* IsVDSAvailable - Returns non-zero if VDS services
  13.    are available */
  14.  
  15. int IsVDSAvailable (void) {
  16.    return (0x20 & *((char *)MK_FP(0x40,0x7B)));
  17. }
  18.  
  19. /* RequestVDSBuffer - Request the DMA buffer
  20.    maintained by VDS services */
  21.  
  22. int RequestVDSBuffer (VDS_DDS * DDS) {
  23.    struct REGPACK regs;
  24.  
  25.    regs.r_ax = 0x8107;
  26.    regs.r_dx = 0;
  27.    regs.r_es = FP_SEG (DDS);
  28.    regs.r_di = FP_OFF (DDS);
  29.    intr (0x4B, ®s);
  30.    if (regs.r_flags & 1) return (regs.r_ax);
  31.    return (0);
  32. }
  33.  
  34. /* ReleaseVDSBuffer - Release a buffer allocated
  35.    by RequestVDSBuffer */
  36.  
  37. int ReleaseVDSBuffer (VDS_DDS * DDS) {
  38.    struct REGPACK regs;
  39.  
  40.    regs.r_ax = 0x8108;
  41.    regs.r_dx = 0;
  42.    regs.r_es = FP_SEG (DDS);
  43.    regs.r_di = FP_OFF (DDS);
  44.    intr (0x4B, ®s);
  45.    if (regs.r_flags & 1) return (regs.r_ax);
  46.    return (0);
  47. }
  48.  
  49. /* DisableVDSTranslation - Disable automatic
  50.    address translation on a DMA channel. */
  51.  
  52. int DisableVDSTranslation (int Channel) {
  53.    struct REGPACK regs;
  54.  
  55.    regs.r_ax = 0x810B;
  56.    regs.r_bx = Channel;
  57.    regs.r_dx = 0;
  58.    intr (0x4B, ®s);
  59.    if (regs.r_flags & 1) return (regs.r_ax);
  60.    return (0);
  61. }
  62.  
  63. /* Enable automatic translation that was disabled
  64.    by DisableVDSTranslation. */
  65.  
  66. int EnableVDSTranslation (int Channel) {
  67.    struct REGPACK regs;
  68.  
  69.    regs.r_ax = 0x810C;
  70.    regs.r_bx = Channel;
  71.    regs.r_dx = 0;
  72.    intr (0x4B, ®s);
  73.    if (regs.r_flags & 1) return (regs.r_ax);
  74.    return (0);
  75. }
  76.  
  77. /* CopyFromDMABuffer - Copy data from a DMA buffer
  78.    to a malloc'd buffer */
  79.  
  80. int CopyFromDMABuffer (VDS_DDS * DDS,
  81.                        long BufferOffset) {
  82.     struct REGPACK regs;
  83.  
  84.     regs.r_ax = 0x810A;
  85.     regs.r_dx = 0;
  86.     regs.r_es = FP_SEG (DDS);
  87.     regs.r_di = FP_OFF (DDS);
  88.     regs.r_bx = BufferOffset >> 16;
  89.     regs.r_cx = BufferOffset;
  90.     intr (0x4B, ®s);
  91.     if (regs.r_flags & 1) return (regs.r_ax);
  92.     return (0);
  93. }
  94.