home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / SCRESTPG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  2.5 KB  |  88 lines

  1. /**
  2. *
  3. * Name        SCRESTPG - Restore the current display page.
  4. *
  5. * Synopsis    error = screstpg(ppage_state);
  6. *
  7. *        int error         Returned error code.
  8. *        PAGE_STATE *ppage_state  Pointer to structure in
  9. *                     which the state of the
  10. *                     current display page is
  11. *                     stored.
  12. *
  13. * Description    This function restores the image and cursor coordinates
  14. *        of the current display page, taking them from the
  15. *        structure pointed to by ppage_state.  The page's
  16. *        image should be stored in the compressed format used by
  17. *        UTSQZSCN.
  18. *
  19. *        An error is returned if there is not enough memory to
  20. *        allocate a temporary internal buffer for the
  21. *        uncompressed page image, or if the current display page
  22. *        is a different size than the page whose compressed image
  23. *        is held in ppage_state.
  24. *
  25. * Returns    int error   Possible values:
  26. *                SC_NO_ERROR  - no errors occured.
  27. *                SC_RANGE     - current page is not the same
  28. *                       size as the compressed page.
  29. *                SC_NO_MEMORY - insufficient memory for the
  30. *                       uncompressed page image.
  31. *
  32. * Version    6.00 (C)Copyright Blaise Computing Inc.  1989
  33. *
  34. **/
  35. #include <bscreens.h>
  36. #include <bvideo.h>
  37.  
  38. int cdecl screstpg(ppage_state)
  39. const PAGE_STATE *ppage_state;
  40. {
  41.     int   color_or_mono;
  42.     int   mode, act_page;
  43.     int   rows, columns;
  44.     int   raw_image_length;
  45.     char *praw_image;
  46.  
  47.         /* First get the screen size.                */
  48.     color_or_mono = scmode(&mode, &columns, &act_page);
  49.     rows = scrows();
  50.  
  51.     raw_image_length = columns * rows * 2;
  52.  
  53.         /* If the current adapter is a CGA and b_vifast is  */
  54.         /* zero, then we need to first uncompress the        */
  55.         /* screen into a temporary buffer, then write it to */
  56.         /* the screen using viwrrect, to prevent snow.        */
  57.         /* Otherwise, uncompress it to the screen directly. */
  58.     if (!b_vifast && (b_cga == color_or_mono))
  59.     {
  60.     praw_image = malloc(raw_image_length);
  61.     if (praw_image == NIL)
  62.         return(SC_NO_MEMORY);
  63.  
  64.     if (utunsqz(ppage_state->pimage, praw_image,
  65.             ppage_state->image_length, raw_image_length) !=
  66.         raw_image_length)
  67.     {
  68.         free(praw_image);
  69.         return(SC_RANGE);
  70.     }
  71.  
  72.     viwrrect(0, 0, rows - 1, columns - 1, praw_image, -1, -1,
  73.          CHAR_ATTR);
  74.     free(praw_image);
  75.     }
  76.     else
  77.     if (utunsqz(ppage_state->pimage, viptr(0, 0),
  78.             ppage_state->image_length, raw_image_length) !=
  79.         raw_image_length)
  80.     {
  81.         return(SC_RANGE);
  82.     }
  83.  
  84.     sccurset(ppage_state->curs_row, ppage_state->curs_column);
  85.  
  86.     return(SC_NO_ERROR);
  87. }
  88.