summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/scrnmacs.h
blob: 7caa4a49688ed935f0f778a22048fe95cfa6ee54 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
**  Macros for managing direct video writes by Jerry Houston
**
**  prototypes for SCROLL.C and VIDPORT.C functions added by Bob Stout
*/

#if defined(__TURBOC__)
 #define FAR far
#else
 #define FAR _far
#endif
 
#ifndef MK_FP
 #define MK_FP(seg,off) ((void far *)(((long)(seg) << 16)|(unsigned)(off)))
#endif

/*
**  Text screen scrolling function from SCROLL.C in SNIPPETS
*/
 
#define SCROLL_UP 0
#define SCROLL_DN 1

void scroll(int direction,
            int num_lines,
            int vattrib,
            int ulrow,
            int ulcomumn,
            int lrrow,
            int lrcolumn);

/*
**  Functions in VIDPORT.C in SNIPPETS
*/
 
void GotoXY(int col, int row);
void ClrScrn(int vattrib);
void GetCurPos(int *col, int *row);
int  GetCurAtr(void);
void ClrEol(void);
void ClrEop(void);
void Repaint(int vattrib);

#if !defined(COLORMODE)
 #define COLORMODE  ((*(char FAR *)0x0449) != 7)
 #define EXT_KBD    (*(char FAR *)0x0496 & 16)
 #define VIDPAGE    (*((unsigned char far *)0x0462))
 #define ROWSIZE    (*(int FAR *)0x044A)
 #define SCANLINES  ((int)*(char FAR*)0x0461)
 #define SCRBUFF    ((unsigned FAR *)((COLORMODE)?0xB8000000:0xB0000000))
 #define SCREENSEG  ((unsigned)((COLORMODE)?0xB800:0xB000))
 #define SCREENSIZE ((*(int FAR *)0x044C) >> 1)
 #define SCREENCOLS (*(int FAR *)0x044A)
 #define SCREENROWS ((*(char FAR *)0x0484)?1+(*(char FAR *)0x0484):25)
#endif

/*
     COLORMODE  = true/false, are we using color?
     EXT_KBD    = true/false, extended keyboard in use?
     VIDPAGE    = current video page in use
     SCANLINES  = number of scan lines in a character.
     SCRBUFF    = returns B800:0000 if using color, B000:0000 if mono.
     SCREENSEG  = when you just need the segment portion.
     SCREENSIZE = number of (2-byte) cells required to save screen.
     SCREENCOLS = number of columns, often 80.
     SCREENROWS = number of rows, usually defaults to 25.
*/

/*
** colors -- Use as is for foreground colors
**           For background, shift left by 4 and OR with
**           foreground and possible video attributes
*/

#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define WHITE 7
#define GRAY 8
#define LTBLUE 9
#define LTGREEN 10
#define LTCYAN 11
#define LTRED 12
#define LTMAGENTA 13
#define YELLOW 14
#define HIWHITE 15    /* hi-intensity white */

#define BG_(a) (((a) & 0x7f) << 4)