SCREEN.CPP
上传用户:xr_qian
上传日期:2007-01-05
资源大小:443k
文件大小:4k
源码类别:

通讯/手机编程

开发平台:

DOS

  1. // ******************************************************************** //
  2. //                                                                      //
  3. //      SCREEN.CPP                                                      //
  4. //      Copyright (c) 1993, Michael Holmes and Bob Flanders             //
  5. //      C++ Communication Utilities                                     //
  6. //                                                                      //
  7. //      This file contains the routines for moving to and from          //
  8. //      the window buffers for saving and restoring the screen.         //
  9. //                                                                      //
  10. // ******************************************************************** //
  11. char    huge *vid_seg =                     // video adapter address
  12.             (char huge *) MK_FP(0xb800, 0);
  13. /* ******************************************************************** *
  14.  *
  15.  *  screen_move() -- move between the video adapter and work buffer
  16.  *
  17.  * ******************************************************************** */
  18. void    screen_move(int  left,  int top,    // left and top corner
  19.                     int  right, int bottom, // right and bottom corner
  20.                     char *buffer,           // work buffer
  21.                     int  dir)               // direction (0=to screen)
  22. {
  23. char    huge *p1, huge *p2;                 // work pointers
  24. int     y,                                  // loop variable
  25.         p1size, p2size, size;               // bytes per line
  26. size = (right - left + 1) * 2;              // length of window line
  27. y = ((top - 1) * 160) + ((left - 1) * 2);   // offset into video buffer
  28. if (dir)                                    // q. moving to buffer?
  29.     {
  30.     p1 = buffer;                            // a. yes .. dest is buffer
  31.     p1size = size;                          // ..and line length
  32.     p2 = &vid_seg[y];                       // source is video ram
  33.     p2size = 160;                           // ..and length is 80 * 2
  34.     }
  35.  else
  36.     {
  37.     p1 = &vid_seg[y];                       // else .. source is video ram
  38.     p1size = 160;                           // ..and length is 80 * 2
  39.     p2 = buffer;                            // destination is buffer
  40.     p2size = size;                          // ..and line length
  41.     }
  42. for (y = bottom - top + 1; y--;             // loop thru for whole
  43.            p1 += p1size, p2 += p2size)      // ..screen window moving
  44.     memcpy((void *) p1, (void *) p2, size); // ..from one to the other
  45. }
  46. /* ******************************************************************** *
  47.  *
  48.  *  gettext() -- get text data from the video memory
  49.  *
  50.  * ******************************************************************** */
  51. void    gettext(int  left, int top,         // left and top corner
  52.                 int  right, int bottom,     // right and bottom corner
  53.                 char *buffer)               // work buffer
  54. {
  55. screen_move(left, top, right, bottom,       // set up common call
  56.         buffer, 1);                         // ..to screen move routine
  57. }
  58. /* ******************************************************************** *
  59.  *
  60.  *  puttext() -- put text data from a work buffer into the video memory
  61.  *
  62.  * ******************************************************************** */
  63. void    puttext(int  left, int top,         // left and top corner
  64.                 int  right, int bottom,     // right and bottom corner
  65.                 char *buffer)               // work buffer
  66. {
  67. screen_move(left, top, right, bottom,       // set up common call
  68.         buffer, 0);                         // ..to screen move routine
  69. }