MCPcopy Create free account
hub / github.com/NetHack/NetHack / vesa_Init

Function vesa_Init

sys/msdos/vidvesa.c:1035–1234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1033#endif
1034
1035DISABLE_WARNING_FORMAT_NONLITERAL
1036
1037/*
1038 * Open tile files,
1039 * initialize the SCREEN, switch it to graphics mode,
1040 * initialize the pointers to the fonts, clear
1041 * the screen.
1042 *
1043 */
1044void
1045vesa_Init(void)
1046{
1047 static boolean inited = FALSE;
1048 const struct Pixel *paletteptr;
1049 unsigned i;
1050 unsigned num_pixels, num_oview_pixels;
1051 const char *tile_file;
1052 const char *font_name;
1053 int tilefailure = 0;
1054
1055 if (inited) return;
1056 inited = TRUE;
1057
1058#ifdef TILES_IN_GLYPHMAP
1059 /*
1060 * Attempt to open the required tile files. If we can't
1061 * don't perform the video mode switch, use TTY code instead.
1062 *
1063 */
1064 tile_file = iflags.wc_tile_file;
1065 if (tile_file == NULL || *tile_file == '\0') {
1066 tile_file = "nhtiles.bmp";
1067 }
1068 if (!read_tiles(tile_file, vesa_pixel_size > 8))
1069 tilefailure |= 1;
1070 if (vesa_pixel_size == 8 && get_palette() == NULL)
1071 tilefailure |= 4;
1072
1073 if (tilefailure) {
1074 raw_printf("Reverting to TTY mode, tile initialization failure (%d).",
1075 tilefailure);
1076 wait_synch();
1077 iflags.usevga = 0;
1078 iflags.tile_view = FALSE;
1079 iflags.over_view = FALSE;
1080 CO = 80;
1081 LI = 25;
1082 /* term_clear_screen() */ /* not vesa_clear_screen() */
1083 return;
1084 }
1085#endif
1086
1087 vesa_mode = 0xFFFF; /* might want an 8 bit mode after loading tiles */
1088 vesa_detect();
1089 if (vesa_mode == 0xFFFF || (vesa_pixel_size == 8 && get_palette() == NULL)) {
1090 raw_printf("%s (%d)", "Reverting to TTY mode, no VESA mode available.",
1091 tilefailure);
1092 wait_synch();

Callers 1

gr_initFunction · 0.85

Calls 15

read_tilesFunction · 0.85
get_paletteFunction · 0.85
wait_synchFunction · 0.85
vesa_detectFunction · 0.85
vesa_SwitchModeFunction · 0.85
vesa_SetViewPortFunction · 0.85
vesa_SetPaletteFunction · 0.85
vesa_FontPtrsFunction · 0.85
free_fontFunction · 0.85
load_fontFunction · 0.85
set_tile_typeFunction · 0.85
get_tileFunction · 0.85

Tested by

no test coverage detected