summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/prtscrn.c
blob: b22bad62864fcdb6c0e21ef3aa58fe1443328950 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
**  PRTSC.C - Access the BIOS print screen function
**
**  public domain demo by Bob Stout
*/

#include <dos.h>

#ifdef __TURBOC__
 #define FAR far
#else
 #define FAR _far
#endif

/*
**  Get screen printing status
**
**  0 - Ready
**  1 - Screen printing in process
**  2 - Error occurred last time
*/

int PrtScrnStat(void)
{
      return ((int)*((char FAR *)(0x00500000)));
}

/*
**  Print the current screen
*/

int PrtScrn(void)
{

      union REGS regs;                    /* Dummy for use by int86()   */

      if (1 == PrtScrnStat())             /* Can we print now?          */
            return -1;                    /* Nope, return with error    */
      int86(5, &regs, &regs);             /* Issue Int 5                */
      return 0;
}

#ifdef TEST

#include <stdio.h>

void main(void)
{
      printf("PrtScrn() returned %d\n", PrtScrn());
      printf("PrtScrnStat() returned %d\n", PrtScrnStat());
}

#endif