home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name SCRESTPG - Restore the current display page.
- *
- * Synopsis error = screstpg(ppage_state);
- *
- * int error Returned error code.
- * PAGE_STATE *ppage_state Pointer to structure in
- * which the state of the
- * current display page is
- * stored.
- *
- * Description This function restores the image and cursor coordinates
- * of the current display page, taking them from the
- * structure pointed to by ppage_state. The page's
- * image should be stored in the compressed format used by
- * UTSQZSCN.
- *
- * An error is returned if there is not enough memory to
- * allocate a temporary internal buffer for the
- * uncompressed page image, or if the current display page
- * is a different size than the page whose compressed image
- * is held in ppage_state.
- *
- * Returns int error Possible values:
- * SC_NO_ERROR - no errors occured.
- * SC_RANGE - current page is not the same
- * size as the compressed page.
- * SC_NO_MEMORY - insufficient memory for the
- * uncompressed page image.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
- #include <bscreens.h>
- #include <bvideo.h>
-
- int cdecl screstpg(ppage_state)
- const PAGE_STATE *ppage_state;
- {
- int color_or_mono;
- int mode, act_page;
- int rows, columns;
- int raw_image_length;
- char *praw_image;
-
- /* First get the screen size. */
- color_or_mono = scmode(&mode, &columns, &act_page);
- rows = scrows();
-
- raw_image_length = columns * rows * 2;
-
- /* If the current adapter is a CGA and b_vifast is */
- /* zero, then we need to first uncompress the */
- /* screen into a temporary buffer, then write it to */
- /* the screen using viwrrect, to prevent snow. */
- /* Otherwise, uncompress it to the screen directly. */
- if (!b_vifast && (b_cga == color_or_mono))
- {
- praw_image = malloc(raw_image_length);
- if (praw_image == NIL)
- return(SC_NO_MEMORY);
-
- if (utunsqz(ppage_state->pimage, praw_image,
- ppage_state->image_length, raw_image_length) !=
- raw_image_length)
- {
- free(praw_image);
- return(SC_RANGE);
- }
-
- viwrrect(0, 0, rows - 1, columns - 1, praw_image, -1, -1,
- CHAR_ATTR);
- free(praw_image);
- }
- else
- if (utunsqz(ppage_state->pimage, viptr(0, 0),
- ppage_state->image_length, raw_image_length) !=
- raw_image_length)
- {
- return(SC_RANGE);
- }
-
- sccurset(ppage_state->curs_row, ppage_state->curs_column);
-
- return(SC_NO_ERROR);
- }