OSDN Git Service

Initial Import
[nethackexpress/trunk.git] / sys / msdos / pcvideo.h
1 /*   SCCS Id: @(#)pcvideo.h   3.4     1994/06/07                      */
2 /*   Copyright (c) NetHack PC Development Team 1993, 1994           */
3 /*   NetHack may be freely redistributed.  See license for details. */
4 /*                                                                  */
5 /*
6  * pcvideo.h - Hardware video support definitions and prototypes
7  *                                                  
8  *Edit History:
9  *     Initial Creation              M. Allison      93/10/30
10  *
11  */
12
13 #ifndef PCVIDEO_H
14 #define PCVIDEO_H
15
16 #include "portio.h"
17
18 # ifdef SCREEN_BIOS
19 #  if !defined(PC9800)
20 # define MONO_CHECK             /* Video BIOS can do the check       */ 
21 #  endif
22 # endif
23
24 # ifdef SCREEN_DJGPPFAST
25 /*# define MONO_CHECK           /* djgpp should be able to do check  */
26 # endif
27
28 /*
29  * PC interrupts
30  */
31 # ifdef PC9800
32 #define CRT_BIOS        0x18
33 #define DOS_EXT_FUNC    0xdc
34 #define DIRECT_CON_IO   0x10
35 # else
36 #define VIDEO_BIOS  0x10
37 # endif
38 #define DOSCALL     0x21
39
40
41 /*
42  * Video BIOS functions
43  */
44 # if defined(PC9800)
45 #define SENSEMODE       0x0b    /* Sense CRT Mode */
46
47 #define PUTCHAR         0x00    /* Put Character */
48 #define SETATT          0x02    /* Set Attribute */
49 #define SETCURPOS       0x03    /* Set Cursor Position */
50 #define CURSOR_RIGHT    0x08    /* Move Cursor Right */
51 #define CURSOR_LEFT     0x09    /* Move Cursor Left */
52 #define SCREEN_CLEAR    0x0a    /* Clear Screen */
53 #define LINE_CLEAR      0x0b    /* Clear Line */
54 # else
55 #define SETCURPOS   0x02    /* Set Cursor Position */
56 # endif
57
58 #define GETCURPOS   0x03    /* Get Cursor Position */
59 #define GETMODE     0x0f    /* Get Video Mode */
60 #define SETMODE     0x00    /* Set Video Mode */
61 #define SETPAGE     0x05    /* Set Video Page */
62 #define FONTINFO    0x1130  /* Get Font Info */
63 #define SCROLL      0x06    /* Scroll or initialize window */
64 #define PUTCHARATT  0x09    /* Write attribute & char at cursor */
65
66 /*
67  * VGA Specific Stuff
68  */
69 # ifdef SCREEN_VGA
70 /* #define HW_PANNING           /* Hardware panning enabled */
71 #define USHORT          unsigned short
72 #define MODE640x480     0x0012  /* Switch to VGA 640 x 480 Graphics mode */
73 #define MODETEXT        0x0003  /* Switch to Text mode 3 */
74
75 #ifdef HW_PANNING
76 #define PIXELINC 16     /* How much to increment by when panning */
77 /*#define PIXELINC 1    /* How much to increment by when panning */
78 #define SCREENBYTES   128
79 #define CharRows  30
80 #define VERT_RETRACE      {while (!(inportb(crt_status) & 0x08)); }
81 #define VERT_RETRACE_END  {while ( (inportb(crt_status) & 0x08)); }
82 #else
83 #define SCREENBYTES     80
84 #endif
85
86 #define CharacterWidth 8
87 #define SCREENHEIGHT    480
88 #define SCREENWIDTH (SCREENBYTES * CharacterWidth)
89 #define VIDEOSEG        0xa000
90 #define FONT_PTR_SEGMENT 0x0000
91 #define FONT_PTR_OFFSET  0x010C
92 #define SCREENPLANES    4
93 #define COLORDEPTH      16
94 #define egawriteplane(n)        { outportb(0x3c4,2); outportb(0x3c5,n); }
95 #define egareadplane(n)         { outportb(0x3ce,4); outportb(0x3cf,n); }
96 #define col2x8(c)       ((c) * 8) 
97 #define col2x16(c)      ((c) * 16)
98 #define col2x(c)        ((c) * 2)
99 #define row2y(c)        ((c) * 16)
100 #define MAX_ROWS_PER_CELL 16
101 #define MAX_COLS_PER_CELL 16
102 #define MAX_BYTES_PER_CELL 2            /* MAX_COLS_PER_CELL/8 */
103 #define ROWS_PER_CELL  MAX_ROWS_PER_CELL
104 #define COLS_PER_CELL  MAX_COLS_PER_CELL
105 #define BYTES_PER_CELL MAX_BYTES_PER_CELL
106
107 struct cellplane {
108         char image[MAX_ROWS_PER_CELL][MAX_BYTES_PER_CELL];
109 };
110         
111 struct planar_cell_struct {
112         struct cellplane plane[SCREENPLANES];
113 };
114
115 struct overview_cellplane {
116         char image[MAX_ROWS_PER_CELL][1];
117 };
118
119 struct overview_planar_cell_struct {
120         struct overview_cellplane plane[SCREENPLANES];
121 };
122
123
124
125 # endif /* SCREEN_VGA */
126
127
128 /*
129  * Default color Indexes for hardware palettes
130  * 
131  * Do not change the values below.
132  * These are the color mappings defined by the particular video 
133  * hardware/mode.  You can rearrange the NetHack color mappings at
134  * run-time via the defaults.nh "videocolors" and "videoshades"
135  * settings.
136  *
137  */
138
139 # if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) 
140 #define M_BLACK                8
141 #define M_WHITE                15
142 #define M_GRAY                 7       /* low-intensity white */
143 #define M_RED                  4
144 #define M_GREEN                2
145 #define M_BROWN                6       /* low-intensity yellow */
146 #define M_BLUE                 1
147 #define M_MAGENTA              5
148 #define M_CYAN                 3
149 #define M_ORANGE               12
150 #define M_BRIGHTGREEN          10
151 #define M_YELLOW               14
152 #define M_BRIGHTBLUE           9
153 #define M_BRIGHTMAGENTA        13
154 #define M_BRIGHTCYAN           11
155
156 #define M_TEXT                M_GRAY
157 #define BACKGROUND_COLOR      0
158 #define ATTRIB_NORMAL         M_TEXT    /* Normal attribute */
159 #define ATTRIB_INTENSE        M_WHITE   /* Intense White */
160 #define ATTRIB_MONO_NORMAL    0x01      /* Underlined,white */
161 #define ATTRIB_MONO_UNDERLINE 0x01      /* Underlined,white */
162 #define ATTRIB_MONO_BLINK     0x87      /* Flash bit, white */
163 #define ATTRIB_MONO_REVERSE   0x70      /* Black on white */
164 # endif /*SCREEN_BIOS || SCREEN_DJGPPFAST */
165
166 # if  defined(SCREEN_VGA) || defined(SCREEN_8514)
167 #define BACKGROUND_VGA_COLOR   0
168 #define ATTRIB_VGA_NORMAL     CLR_GRAY  /* Normal attribute */
169 #define ATTRIB_VGA_INTENSE    13        /* Intense White 94/06/07 palette chg*/
170 # endif /*SCREEN_VGA || SCREEN_8514*/
171
172 # if defined(PC9800)
173 static unsigned char attr98[CLR_MAX] = {
174         0xe1,  /*  0 white            */
175         0x21,  /*  1 blue             */
176         0x81,  /*  2 green            */
177         0xa1,  /*  3 cyan             */
178         0x41,  /*  4 red              */
179         0x61,  /*  5 magenta          */
180         0xc1,  /*  6 yellow           */
181         0xe1,  /*  7 white            */
182         0xe1,  /*  8 white            */
183         0x25,  /*  9 reversed blue    */
184         0x85,  /* 10 reversed green   */
185         0xa5,  /* 11 reversed cyan    */
186         0x45,  /* 12 reversed red     */
187         0x65,  /* 13 reversed magenta */
188         0xc5,  /* 14 reversed yellow  */
189         0xe5,  /* 15 reversed white   */
190 };
191 # endif
192
193 # ifdef SIMULATE_CURSOR
194 #define CURSOR_HEIGHT    3      /* this should go - MJA */
195 /* cursor styles */
196 #define CURSOR_INVIS     0      /* cursor not visible at all            */
197 #define CURSOR_FRAME     1      /* block around the current tile        */
198 #define CURSOR_UNDERLINE 2      /* thin line at bottom of the tile      */
199 #define CURSOR_CORNER    3      /* cursor visible at the 4 tile corners */
200 #define NUM_CURSOR_TYPES 4      /* number of different cursor types     */
201 #define CURSOR_DEFAULT_STYLE CURSOR_CORNER 
202 #define CURSOR_DEFAULT_COLOR M_GRAY
203 /* global variables for cursor */
204 extern int cursor_type;
205 extern int cursor_flag;
206 extern int cursor_color;
207 # endif
208
209
210 /*
211  *   Function Prototypes
212  *
213  */
214
215 #define E extern
216
217 /* ### video.c ### */
218
219 # ifdef SIMULATE_CURSOR
220 E void NDECL(DrawCursor);
221 E void NDECL(HideCursor);
222 # endif
223
224 /* ### vidtxt.c ### */
225
226 # ifdef NO_TERMS
227 E void NDECL(txt_backsp);
228 E void NDECL(txt_clear_screen);
229 E void FDECL(txt_cl_end,(int,int));
230 E void NDECL(txt_cl_eos);
231 E void NDECL(txt_get_scr_size);
232 E void FDECL(txt_gotoxy,(int,int));
233 E int  NDECL(txt_monoadapt_check);
234 E void NDECL(txt_nhbell);
235 E void FDECL(txt_startup,(int*,int*));
236 E void FDECL(txt_xputs, (const char *, int, int));
237 E void FDECL(txt_xputc, (CHAR_P, int));
238
239 /* ### vidvga.c ### */
240
241 #  ifdef SCREEN_VGA
242 E void NDECL(vga_backsp);
243 E void FDECL(vga_clear_screen,(int));
244 E void FDECL(vga_cl_end,(int,int));
245 E void FDECL(vga_cl_eos,(int));
246 E int  NDECL(vga_detect);
247 #   ifdef SIMULATE_CURSOR
248 E void NDECL(vga_DrawCursor);
249 #   endif
250 E void FDECL(vga_DisplayCell, (struct planar_cell_struct *, int, int));
251 E void FDECL(vga_DisplayCell_O, 
252                         (struct overview_planar_cell_struct *, int, int));
253 E void NDECL(vga_Finish);
254 E char __far *NDECL(vga_FontPtrs);
255 E void NDECL(vga_get_scr_size);
256 E void FDECL(vga_gotoloc,(int,int));
257 #   ifdef POSITIONBAR
258 E void FDECL(vga_update_positionbar, (char *));
259 #   endif
260 #   ifdef SIMULATE_CURSOR
261 E void NDECL(vga_HideCursor);
262 #   endif
263 E void NDECL(vga_Init);
264 E void FDECL(vga_SwitchMode, (unsigned int));
265 E void FDECL(vga_SetPalette, (char *));
266 E void NDECL(vga_tty_end_screen);
267 E void FDECL(vga_tty_startup,(int*,int*));
268 E void FDECL(vga_WriteChar, (int, int, int, int));
269 E void FDECL(vga_WriteStr, (char *, int, int, int, int));
270 E void FDECL(vga_xputs, (const char *, int, int));
271 E void FDECL(vga_xputc, (CHAR_P, int));
272 E void FDECL(vga_xputg, (int, int, unsigned));
273 E void FDECL(vga_userpan, (BOOLEAN_P));
274 E void FDECL(vga_overview, (BOOLEAN_P));
275 E void FDECL(vga_traditional, (BOOLEAN_P));
276 E void NDECL(vga_refresh);
277 #  endif /* SCREEN_VGA */
278 # endif /* NO_TERMS   */
279
280 #undef E
281
282 #endif /* PCVIDEO_H  */
283 /* pcvideo.h */