home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / bcfamily / source / vioread.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  2.0 KB  |  84 lines

  1. //
  2. //      *******************************************************************
  3. //        JdeBP C++ Library Routines          General Public Licence v1.00
  4. //            Copyright (c) 1991,1992     Jonathan de Boyne Pollard
  5. //      *******************************************************************
  6. //
  7. // Part of FamAPI.LIB
  8. //
  9.  
  10. #include "famapi.h"
  11. #include "vio.h"
  12.  
  13. #pragma argsused
  14. //
  15. //    Read a string of character/attribute pairs
  16. //
  17. USHORT _APICALL
  18. VioReadCellStr      ( char far *PtrCellStr,
  19.                     unsigned short far *PtrBufferLength,
  20.                     unsigned short Row,
  21.                     unsigned short Col,
  22.                     unsigned short VioHandle )
  23. {
  24.     unsigned short far *screen = VioDosPointer(Row, Col) ;
  25.     unsigned short StringLen = *PtrBufferLength ;
  26.  
  27.     ++StringLen;        // Round upwards
  28.     StringLen >>= 1 ;    // Convert byte count to word count
  29.     if (!screen) {
  30.         unsigned short savepos = VioDosGetCurPos() ;
  31.         unsigned short pos = (Row << 8) + (Col & 0xFF) ;
  32.  
  33.         while (StringLen--) {
  34.             VioDosSetCurPos (pos++) ;
  35.             _AH = 0x08 ;
  36.             _BH = 0x00 ;
  37.             geninterrupt(0x10) ;        // Read character at cursor
  38.             *((unsigned short far *)PtrCellStr)++ = _AX ;
  39.         }
  40.         VioDosSetCurPos (savepos) ;
  41.     } else {
  42.         while (StringLen--)
  43.             *((unsigned short far *)PtrCellStr)++ = *screen++ ;
  44.     }
  45.  
  46.     return NO_ERROR ;
  47. }
  48.  
  49. #pragma argsused
  50. //
  51. //    Read a string of characters
  52. //
  53. USHORT _APICALL
  54. VioReadCharStr      ( char far *PtrCharStr,
  55.                     unsigned short far *PtrBufferLength,
  56.                     unsigned short Row,
  57.                     unsigned short Col,
  58.                     unsigned short VioHandle)
  59. {
  60.     unsigned short far *screen = VioDosPointer(Row, Col) ;
  61.     unsigned short StringLen = *PtrBufferLength ;
  62.  
  63.     if (!screen) {
  64.         unsigned short savepos = VioDosGetCurPos() ;
  65.         unsigned short pos = (Row << 8) + (Col & 0xFF) ;
  66.  
  67.         while (StringLen--) {
  68.             VioDosSetCurPos (pos++) ;
  69.             _AH = 0x08 ;
  70.             _BH = 0x00 ;
  71.             geninterrupt(0x10) ;        // Read character at cursor
  72.             *(PtrCharStr)++ = _AL ;
  73.         }
  74.         VioDosSetCurPos (savepos) ;
  75.     } else {
  76.         while (StringLen--) {
  77.             *(PtrCharStr)++ = *screen ;
  78.             screen += 2;
  79.         }
  80.     }
  81.  
  82.     return NO_ERROR ;
  83. }
  84.