OSDN Git Service

upgrade to 3.6.1
[jnethack/source.git] / sys / msdos / pcvideo.h
1 /* NetHack 3.6  pcvideo.h       $NHDT-Date: 1457207040 2016/03/05 19:44:00 $  $NHDT-Branch: chasonr $:$NHDT-Revision: 1.9 $ */
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  * Video BIOS functions
42  */
43 #if defined(PC9800)
44 #define SENSEMODE 0x0b /* Sense CRT Mode */
45
46 #define PUTCHAR 0x00      /* Put Character */
47 #define SETATT 0x02       /* Set Attribute */
48 #define SETCURPOS 0x03    /* Set Cursor Position */
49 #define CURSOR_RIGHT 0x08 /* Move Cursor Right */
50 #define CURSOR_LEFT 0x09  /* Move Cursor Left */
51 #define SCREEN_CLEAR 0x0a /* Clear Screen */
52 #define LINE_CLEAR 0x0b   /* Clear Line */
53 #else
54 #define SETCURPOS 0x02 /* Set Cursor Position */
55 #endif
56
57 #define GETCURPOS 0x03  /* Get Cursor Position */
58 #define GETMODE 0x0f    /* Get Video Mode */
59 #define SETMODE 0x00    /* Set Video Mode */
60 #define SETPAGE 0x05    /* Set Video Page */
61 #define FONTINFO 0x1130 /* Get Font Info */
62 #define SCROLL 0x06     /* Scroll or initialize window */
63 #define PUTCHARATT 0x09 /* Write attribute & char at cursor */
64
65 /*
66  * VGA Specific Stuff
67  */
68 #ifdef SCREEN_VGA
69 /* #define HW_PANNING           /* Hardware panning enabled */
70 #define USHORT unsigned short
71 #define MODE640x480 0x0012 /* Switch to VGA 640 x 480 Graphics mode */
72 #define MODETEXT 0x0003    /* Switch to Text mode 3 */
73
74 #ifdef HW_PANNING
75 #define PIXELINC 16 /* How much to increment by when panning */
76 /*#define PIXELINC 1    /* How much to increment by when panning */
77 #define SCREENBYTES 128
78 #define CharRows 30
79 #define VERT_RETRACE                          \
80     {                                         \
81         while (!(inportb(crt_status) & 0x08)) \
82             ;                                 \
83     }
84 #define VERT_RETRACE_END                     \
85     {                                        \
86         while ((inportb(crt_status) & 0x08)) \
87             ;                                \
88     }
89 #else
90 #define SCREENBYTES 80
91 #endif
92
93 #define CharacterWidth 8
94 #define SCREENHEIGHT 480
95 #define SCREENWIDTH (SCREENBYTES * CharacterWidth)
96 #define VIDEOSEG 0xa000
97 #define FONT_PTR_SEGMENT 0x0000
98 #define FONT_PTR_OFFSET 0x010C
99 #define SCREENPLANES 4
100 #define COLORDEPTH 16
101 #define egawriteplane(n)    \
102     {                       \
103         outportb(0x3c4, 2); \
104         outportb(0x3c5, n); \
105     }
106 #define egareadplane(n)     \
107     {                       \
108         outportb(0x3ce, 4); \
109         outportb(0x3cf, n); \
110     }
111 #define col2x8(c) ((c) *8)
112 #define col2x16(c) ((c) *16)
113 #define col2x(c) ((c) *2)
114 #define row2y(c) ((c) *16)
115 #define MAX_ROWS_PER_CELL 16
116 #define MAX_COLS_PER_CELL 16
117 #define MAX_BYTES_PER_CELL 2 /* MAX_COLS_PER_CELL/8 */
118 #define ROWS_PER_CELL MAX_ROWS_PER_CELL
119 #define COLS_PER_CELL MAX_COLS_PER_CELL
120 #define BYTES_PER_CELL MAX_BYTES_PER_CELL
121
122 struct cellplane {
123     char image[MAX_ROWS_PER_CELL][MAX_BYTES_PER_CELL];
124 };
125
126 struct planar_cell_struct {
127     struct cellplane plane[SCREENPLANES];
128 };
129
130 struct overview_cellplane {
131     char image[MAX_ROWS_PER_CELL][1];
132 };
133
134 struct overview_planar_cell_struct {
135     struct overview_cellplane plane[SCREENPLANES];
136 };
137
138 #endif /* SCREEN_VGA */
139
140 /*
141  * Default color Indexes for hardware palettes
142  *
143  * Do not change the values below.
144  * These are the color mappings defined by the particular video
145  * hardware/mode.  You can rearrange the NetHack color mappings at
146  * run-time via the defaults.nh "videocolors" and "videoshades"
147  * settings.
148  *
149  */
150
151 #if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST)
152 #define M_BLACK 8
153 #define M_WHITE 15
154 #define M_GRAY 7 /* low-intensity white */
155 #define M_RED 4
156 #define M_GREEN 2
157 #define M_BROWN 6 /* low-intensity yellow */
158 #define M_BLUE 1
159 #define M_MAGENTA 5
160 #define M_CYAN 3
161 #define M_ORANGE 12
162 #define M_BRIGHTGREEN 10
163 #define M_YELLOW 14
164 #define M_BRIGHTBLUE 9
165 #define M_BRIGHTMAGENTA 13
166 #define M_BRIGHTCYAN 11
167
168 #define M_TEXT M_GRAY
169 #define BACKGROUND_COLOR 1
170 #define ATTRIB_NORMAL M_TEXT       /* Normal attribute */
171 #define ATTRIB_INTENSE M_WHITE     /* Intense White */
172 #define ATTRIB_MONO_NORMAL 0x01    /* Underlined,white */
173 #define ATTRIB_MONO_UNDERLINE 0x01 /* Underlined,white */
174 #define ATTRIB_MONO_BLINK 0x87     /* Flash bit, white */
175 #define ATTRIB_MONO_REVERSE 0x70   /* Black on white */
176 #endif                             /*SCREEN_BIOS || SCREEN_DJGPPFAST */
177
178 #if defined(SCREEN_VGA) || defined(SCREEN_8514)
179 #define BACKGROUND_VGA_COLOR 1
180 #define ATTRIB_VGA_NORMAL CLR_GRAY /* Normal attribute */
181 #define ATTRIB_VGA_INTENSE 14      /* Intense White 94/06/07 palette chg*/
182 #endif                             /*SCREEN_VGA || SCREEN_8514*/
183
184 #if defined(PC9800)
185 static unsigned char attr98[CLR_MAX] = {
186     0xe1, /*  0 white            */
187     0x21, /*  1 blue             */
188     0x81, /*  2 green            */
189     0xa1, /*  3 cyan             */
190     0x41, /*  4 red              */
191     0x61, /*  5 magenta          */
192     0xc1, /*  6 yellow           */
193     0xe1, /*  7 white            */
194     0xe1, /*  8 white            */
195     0x25, /*  9 reversed blue    */
196     0x85, /* 10 reversed green   */
197     0xa5, /* 11 reversed cyan    */
198     0x45, /* 12 reversed red     */
199     0x65, /* 13 reversed magenta */
200     0xc5, /* 14 reversed yellow  */
201     0xe5, /* 15 reversed white   */
202 };
203 #endif
204
205 #ifdef SIMULATE_CURSOR
206 #define CURSOR_HEIGHT 3 /* this should go - MJA */
207 /* cursor styles */
208 #define CURSOR_INVIS 0     /* cursor not visible at all            */
209 #define CURSOR_FRAME 1     /* block around the current tile        */
210 #define CURSOR_UNDERLINE 2 /* thin line at bottom of the tile      */
211 #define CURSOR_CORNER 3    /* cursor visible at the 4 tile corners */
212 #define NUM_CURSOR_TYPES 4 /* number of different cursor types     */
213 #define CURSOR_DEFAULT_STYLE CURSOR_CORNER
214 #define CURSOR_DEFAULT_COLOR M_GRAY
215 /* global variables for cursor */
216 extern int cursor_type;
217 extern int cursor_flag;
218 extern int cursor_color;
219 #endif
220
221 /*
222  *   Function Prototypes
223  *
224  */
225
226 #define E extern
227
228 /* ### video.c ### */
229
230 #ifdef SIMULATE_CURSOR
231 E void NDECL(DrawCursor);
232 E void NDECL(HideCursor);
233 #endif
234
235 /* ### vidtxt.c ### */
236
237 #ifdef NO_TERMS
238 E void NDECL(txt_backsp);
239 E void NDECL(txt_clear_screen);
240 E void FDECL(txt_cl_end, (int, int));
241 E void NDECL(txt_cl_eos);
242 E void NDECL(txt_get_scr_size);
243 E void FDECL(txt_gotoxy, (int, int));
244 E int NDECL(txt_monoadapt_check);
245 E void NDECL(txt_nhbell);
246 E void FDECL(txt_startup, (int *, int *));
247 E void FDECL(txt_xputs, (const char *, int, int));
248 E void FDECL(txt_xputc, (CHAR_P, int));
249
250 /* ### vidvga.c ### */
251
252 #ifdef SCREEN_VGA
253 E void NDECL(vga_backsp);
254 E void FDECL(vga_clear_screen, (int));
255 E void FDECL(vga_cl_end, (int, int));
256 E void FDECL(vga_cl_eos, (int));
257 E int NDECL(vga_detect);
258 #ifdef SIMULATE_CURSOR
259 E void NDECL(vga_DrawCursor);
260 #endif
261 E void NDECL(vga_Finish);
262 E char __far *NDECL(vga_FontPtrs);
263 E void NDECL(vga_get_scr_size);
264 E void FDECL(vga_gotoloc, (int, int));
265 #ifdef POSITIONBAR
266 E void FDECL(vga_update_positionbar, (char *));
267 #endif
268 #ifdef SIMULATE_CURSOR
269 E void NDECL(vga_HideCursor);
270 #endif
271 E void NDECL(vga_Init);
272 E void NDECL(vga_tty_end_screen);
273 E void FDECL(vga_tty_startup, (int *, int *));
274 E void FDECL(vga_xputs, (const char *, int, int));
275 E void FDECL(vga_xputc, (CHAR_P, int));
276 E void FDECL(vga_xputg, (int, int, unsigned));
277 E void FDECL(vga_userpan, (BOOLEAN_P));
278 E void FDECL(vga_overview, (BOOLEAN_P));
279 E void FDECL(vga_traditional, (BOOLEAN_P));
280 E void NDECL(vga_refresh);
281 #endif /* SCREEN_VGA */
282 #ifdef SCREEN_VESA
283 E void NDECL(vesa_backsp);
284 E void FDECL(vesa_clear_screen, (int));
285 E void FDECL(vesa_cl_end, (int, int));
286 E void FDECL(vesa_cl_eos, (int));
287 E int NDECL(vesa_detect);
288 #ifdef SIMULATE_CURSOR
289 E void NDECL(vesa_DrawCursor);
290 #endif
291 E void NDECL(vesa_Finish);
292 E void NDECL(vesa_get_scr_size);
293 E void FDECL(vesa_gotoloc, (int, int));
294 #ifdef POSITIONBAR
295 E void FDECL(vesa_update_positionbar, (char *));
296 #endif
297 #ifdef SIMULATE_CURSOR
298 E void NDECL(vesa_HideCursor);
299 #endif
300 E void NDECL(vesa_Init);
301 E void NDECL(vesa_tty_end_screen);
302 E void FDECL(vesa_tty_startup, (int *, int *));
303 E void FDECL(vesa_xputs, (const char *, int, int));
304 E void FDECL(vesa_xputc, (CHAR_P, int));
305 E void FDECL(vesa_xputg, (int, int, unsigned));
306 E void FDECL(vesa_userpan, (BOOLEAN_P));
307 E void FDECL(vesa_overview, (BOOLEAN_P));
308 E void FDECL(vesa_traditional, (BOOLEAN_P));
309 E void NDECL(vesa_refresh);
310 #endif /* SCREEN_VESA */
311 #endif /* NO_TERMS   */
312
313 #undef E
314
315 #endif /* PCVIDEO_H  */
316 /* pcvideo.h */