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 # ifdef ALLEG_FX 172 long colorpal[16]; 173 # define BACKGROUND_ALLEGRO_COLOR colorpal[8] 174 # endif 175 176 # if defined(PC9800) 177 static unsigned char attr98[CLR_MAX] = { 178 0xe1, /* 0 white */ 179 0x21, /* 1 blue */ 180 0x81, /* 2 green */ 181 0xa1, /* 3 cyan */ 182 0x41, /* 4 red */ 183 0x61, /* 5 magenta */ 184 0xc1, /* 6 yellow */ 185 0xe1, /* 7 white */ 186 0xe1, /* 8 white */ 187 0x25, /* 9 reversed blue */ 188 0x85, /* 10 reversed green */ 189 0xa5, /* 11 reversed cyan */ 190 0x45, /* 12 reversed red */ 191 0x65, /* 13 reversed magenta */ 192 0xc5, /* 14 reversed yellow */ 193 0xe5, /* 15 reversed white */ 194 }; 195 # endif 196 197 # ifdef SIMULATE_CURSOR 198 #define CURSOR_HEIGHT 3 /* this should go - MJA */ 199 /* cursor styles */ 200 #define CURSOR_INVIS 0 /* cursor not visible at all */ 201 #define CURSOR_FRAME 1 /* block around the current tile */ 202 #define CURSOR_UNDERLINE 2 /* thin line at bottom of the tile */ 203 #define CURSOR_CORNER 3 /* cursor visible at the 4 tile corners */ 204 #define NUM_CURSOR_TYPES 4 /* number of different cursor types */ 205 #define CURSOR_DEFAULT_STYLE CURSOR_CORNER 206 #define CURSOR_DEFAULT_COLOR M_GRAY 207 /* global variables for cursor */ 208 extern int cursor_type; 209 extern int cursor_flag; 210 extern int cursor_color; 211 # endif 212 213 214 /* 215 * Function Prototypes 216 * 217 */ 218 219 #define E extern 220 221 /* ### video.c ### */ 222 223 # ifdef SIMULATE_CURSOR 224 E void NDECL(DrawCursor); 225 E void NDECL(HideCursor); 226 # endif 227 228 /* ### vidtxt.c ### */ 229 230 # ifdef NO_TERMS 231 E void NDECL(txt_backsp); 232 E void NDECL(txt_clear_screen); 233 E void FDECL(txt_cl_end,(int,int)); 234 E void NDECL(txt_cl_eos); 235 E void NDECL(txt_get_scr_size); 236 E void FDECL(txt_gotoxy,(int,int)); 237 E int NDECL(txt_monoadapt_check); 238 E void NDECL(txt_nhbell); 239 E void FDECL(txt_startup,(int*,int*)); 240 E void FDECL(txt_xputs, (const char *, int, int)); 241 E void FDECL(txt_xputc, (CHAR_P, int)); 242 243 /* ### vidvga.c ### */ 244 245 # ifdef SCREEN_VGA 246 E void NDECL(vga_backsp); 247 E void FDECL(vga_clear_screen,(int)); 248 E void FDECL(vga_cl_end,(int,int)); 249 E void FDECL(vga_cl_eos,(int)); 250 E int NDECL(vga_detect); 251 # ifdef SIMULATE_CURSOR 252 E void NDECL(vga_DrawCursor); 253 # endif 254 E void FDECL(vga_DisplayCell, (struct planar_cell_struct *, int, int)); 255 E void FDECL(vga_DisplayCell_O, 256 (struct overview_planar_cell_struct *, int, int)); 257 E void NDECL(vga_Finish); 258 E char __far *NDECL(vga_FontPtrs); 259 E void NDECL(vga_get_scr_size); 260 E void FDECL(vga_gotoloc,(int,int)); 261 # ifdef POSITIONBAR 262 E void FDECL(vga_update_positionbar, (char *)); 263 # endif 264 # ifdef SIMULATE_CURSOR 265 E void NDECL(vga_HideCursor); 266 # endif 267 E void NDECL(vga_Init); 268 E void FDECL(vga_SwitchMode, (unsigned int)); 269 E void FDECL(vga_SetPalette, (char *)); 270 E void NDECL(vga_tty_end_screen); 271 E void FDECL(vga_tty_startup,(int*,int*)); 272 E void FDECL(vga_WriteChar, (int, int, int, int)); 273 E void FDECL(vga_WriteStr, (char *, int, int, 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 283 # ifdef ALLEG_FX 284 E void NDECL(alleg_backsp); 285 E void FDECL(alleg_clear_screen,(int)); 286 E void FDECL(alleg_cl_end,(int,int)); 287 E void FDECL(alleg_cl_eos,(int)); 288 E int NDECL(alleg_detect); 289 # ifdef SIMULATE_CURSOR 290 E void NDECL(alleg_DrawCursor); 291 # endif 292 E void NDECL(alleg_Finish); 293 E void NDECL(alleg_get_scr_size); 294 E void FDECL(alleg_gotoloc,(int,int)); /* This should be made a macro */ 295 # ifdef POSITIONBAR 296 E void FDECL(alleg_update_positionbar, (char *)); 297 # endif 298 # ifdef SIMULATE_CURSOR 299 E void NDECL(alleg_HideCursor); 300 # endif 301 E void NDECL(alleg_Init); 302 E void NDECL(alleg_tty_end_screen); 303 E void FDECL(alleg_tty_startup,(int*,int*)); 304 E void FDECL(alleg_WriteChar, (int, int, int, int)); 305 E void FDECL(alleg_xputs, (char *, int, int)); 306 E void FDECL(alleg_xputc, (CHAR_P, int)); 307 E void FDECL(alleg_xputg, (int, int)); 308 E void FDECL(alleg_userpan, (BOOLEAN_P)); 309 E void FDECL(alleg_overview, (BOOLEAN_P)); 310 E void FDECL(alleg_traditional, (BOOLEAN_P)); 311 E void NDECL(alleg_refresh); 312 E void NDECL(alleg_screenshot); 313 314 # endif /* ALLEG_FX */ 315 # endif /* NO_TERMS */ 316 317 #undef E 318 319 #endif /* PCVIDEO_H */ 320 /* pcvideo.h */ 321