home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name viads -- Convert screen location into memory address
- *
- * Synopsis pstruct = viads(row,col,pads);
- *
- * ADS *pstruct Returned value of pads,
- * or NIL if error.
- * int row Row (0 = top of screen)
- * int col Column (0 = left edge)
- * ADS *pads Pointer to ADS structure to receive
- * computed address.
- *
- * Description This function computes the physical address in video
- * memory of the specified location on the current display
- * page. (The current display page is defined by the
- * global variable b_curpage.)
- *
- * An error will occur and NIL will be returned as the
- * value of the function if the screen is not in a standard
- * text mode (0, 1, 2, 3, or 7), or if row or col is beyond
- * the edge of the screen.
- *
- * Returns pstruct Returned pointer to the ADS structure
- * which contains the computed address,
- * or NIL if an error occurred.
- * *pads ADS structure containing the computed
- * address.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <bscreen.h>
- #include <bvideo.h>
-
- ADS *viads(row,col,pads)
- int row,col;
- ADS *pads;
- {
- int mode,columns,act_page;
- static ADS CRT_LEN_ads = {0x44c,0}; /* Address of BIOS variable */
- /* CRT_LEN which contains */
- /* length of video page */
-
- int pg_len = 0;
- ADS pg_len_ads; /* Address of pg_len */
-
- scmode(&mode,&columns,&act_page);
- if ((mode > 3 && mode != 7) /* Quit if graphics mode or */
- || col < 0 /* if col or row out of range */
- || col >= columns
- || row < 0
- || row >= scrows())
- return NIL;
-
- pads->s = ((mode == 7) ? 0xb000 : 0xb800); /* Start of screen */
- /* buffer */
- pads->r = ((row * columns) + col) * 2;
-
- if (b_curpage)
- {
- utabsptr((char *) &pg_len,&pg_len_ads);
- utslmove(&CRT_LEN_ads,&pg_len_ads,2); /* Extract page length */
- pads->r += b_curpage * pg_len;
- } /* Note: pg_len may be */
- /* incorrect for Monochrome */
- /* Adapter but that should have */
- /* no effect since b_curpage */
- /* should be 0. */
- return pads;
- }