MS-DOS: Support no-tiles and no-graphics builds

In previous versions of NetHack, setting -DUSE_TILES enabled the tile
support, while setting -DSUPPRESS_GRAPHICS produced a NetHack that
would write its TTY output to standard output, and rely on ANSI.SYS or
similar to do screen control. (USE_TILES is now TILES_IN_GLYPHMAP.)

This change ensures that the current NetHack can be built the same
ways.

One twist is that previous NetHacks would drop all support for graphical
modes when tiles were not supported. Thus sys/msdos/vid{vga,vesa}.c have
very disordered use of TILES_IN_GLYPHMAP. There was no need to check
this. But now, the graphical modes also support Unicode. A non-tiled
build should have the graphical modes, with only the text functions
present, provided that ENHANCED_SYMBOLS is defined.

Some unused and locally used symbols were cleaned up along the way.
This commit is contained in:
Ray Chason
2026-07-09 23:48:14 -04:00
parent 05d1ed365f
commit 7889eedfa5
21 changed files with 248 additions and 72 deletions
+5
View File
@@ -3,6 +3,9 @@
/* NetHack may be freely redistributed. See license for details. */
#include "config.h"
#ifdef TILES_IN_GLYPHMAP
#include "tileset.h"
/* First BMP file header */
@@ -592,3 +595,5 @@ pixel_element(uint32 mask, uint32 color)
color &= mask;
return color * 255 / mask;
}
#endif /* TILES_IN_GLYPHMAP */
+5
View File
@@ -7,6 +7,9 @@
* http://www.w3.org/Graphics/GIF/spec-gif89a.txt */
#include "config.h"
#ifdef TILES_IN_GLYPHMAP
#include "tileset.h"
#define MIN_LZW_BITS 3
@@ -497,3 +500,5 @@ free_data_block(struct DataBlock *block)
block->size = 0;
block->data = NULL;
}
#endif /* TILES_IN_GLYPHMAP */
+5
View File
@@ -3,6 +3,9 @@
/* NetHack may be freely redistributed. See license for details. */
#include "config.h"
#ifdef TILES_IN_GLYPHMAP
#include "objclass.h"
#include "flag.h"
#include "tileset.h"
@@ -348,3 +351,5 @@ read_png_tiles(const char *filename UNUSED, struct TileSetImage *image UNUSED)
/* stub */
return FALSE;
}
#endif /* TILES_IN_GLYPHMAP */
+7 -7
View File
@@ -27,11 +27,13 @@ void term_end_extracolor(void);
#if (!defined(UNIX) || !defined(TERMINFO)) && !defined(TOS)
static void analyze_seq(char *, int *, int *);
#endif
#if defined(UNIX) && defined(TERMINFO)
static int indexed_color_count(void);
#endif
#endif
#if (defined(TERMLIB) || defined(ANSI_DEFAULT))
static void init_hilite(void);
static void kill_hilite(void);
static int indexed_color_count(void);
#endif
/* (see tcap.h) -- nh_CM, nh_ND, nh_CD, nh_HI,nh_HE, nh_US,nh_UE, ul_hack */
@@ -40,12 +42,16 @@ struct tc_lcl_data tc_lcl_data = { 0, 0, 0, 0, 0, 0, 0, FALSE };
static char *nh_VI = (char *) 0; /* cursor_invisible */
static char *nh_VE = (char *) 0; /* cursor_normal */
/*static char *nh_VS = (char *) 0;*/ /* cursor_visible (highlighted cursor) */
#if defined(TERMLIB) || defined(CHANGE_COLOR)
static char *nh_Ic = (char *) 0; /* initialize_color */
#endif
#if !defined(__NetBSD__)
static char *UP, *BC;
#ifdef TERMLIB
static char PC = '\0';
#endif
#endif
static char *HO, *CL, *CE, *XD, *SO, *SE, *TI, *TE;
static char *VS, *VE;
@@ -1580,13 +1586,7 @@ tty_change_color(int color, long rgb, int reverse UNUSED)
#ifndef SEP2
#define tcfmtstr "\033[38;2;%ld;%ld;%ldm"
#ifdef UNIX
#define tcfmtstr24bit "\033[38;2;%u;%u;%um"
#define tcfmtstr256 "\033[38;5;%dm"
#else
#define tcfmtstr24bit "\033[38;2;%lu;%lu;%lum"
#define tcfmtstr256 "\033[38:5:%lum"
#endif
#endif
static void emit24bit(long mcolor);
+3 -3
View File
@@ -182,7 +182,7 @@ static const char winpanicstr[] = "Bad window Id %d (%s)";
char defmorestr[] = "--More--";
#ifdef CLIPPING
#if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
#if (defined(TILES_IN_GLYPHMAP) || defined(ENHANCED_SYMBOLS)) && defined(MSDOS)
boolean clipping = FALSE; /* clipping on? */
int clipx = 0, clipxmax = 0;
int clipy = 0, clipymax = 0;
@@ -193,7 +193,7 @@ static int clipy = 0, clipymax = 0;
#endif
#endif /* CLIPPING */
#if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
#if defined(NO_TERMS) && defined(MSDOS)
extern void adjust_cursor_flags(struct WinDesc *);
#endif
@@ -2072,7 +2072,7 @@ tty_curs(
print_vt_code2(AVTC_SELECT_WINDOW, window);
#if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
#if defined(NO_TERMS) && defined(MSDOS)
adjust_cursor_flags(cw);
#endif