home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name viptr -- Convert screen location into memory address
- *
- * Synopsis pcell = viptr(row,col);
- *
- * char far *pcell Computed address.
- * int row Row (0 = top of screen)
- * int col Column (0 = left edge)
- *
- * 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 pcell The computed address, or NIL if an error
- * occurred.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986,1987,1989
- *
- **/
-
- #include <dos.h>
-
- #include <bscreens.h>
- #include <bvideo.h>
-
- int b_vifast = 0; /* Nonzero if interference is */
- /* to be ignored -- use fastest*/
- /* possible method. */
-
- char far *viptr(row,col)
- int row,col;
- {
- int mode,act_page,columns;
-
- #define CRT_LEN_SEG 0x0000 /* Address of BIOS variable */
- #define CRT_LEN_OFFSET 0x044c /* CRT_LEN which contains */
- /* length of video page */
-
- 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 (char far *) NIL;
-
- /* Construct address: segment is beginning of screen buffer, */
- /* offset is based on page length, page number, row, and column. */
-
- /* Note: pg_len may be incorrect for Monochrome Adapter but that */
- /* should have no effect since b_curpage should be 0. */
-
- #define pg_len (*uttofar(CRT_LEN_SEG,CRT_LEN_OFFSET,unsigned))
-
- return uttofar( ((mode == 7) ? 0xb000 : 0xb800),
- ((row * columns) + col) * 2 + b_curpage * pg_len,
- char);
- }