introduce support for coloring the frame behind a map location

Also includes support by paxed for polearm targeting using the
frame color.

Also renames USE_TILES to TILES_IN_GLYPHMAP which is a more
accurate description.

Not all window interfaces have full support for the color framing
of the background square yet.

MS-DOS needs further work (to bring it to both VESA and VGA, with
and without tiles.

Windows GUI is missing support.

X11 and Qt have been started, but may require further refinement.
This commit is contained in:
nhmall
2023-01-01 19:55:02 -05:00
parent 1972c8447f
commit 2fc0d25d45
38 changed files with 365 additions and 133 deletions

View File

@@ -106,7 +106,7 @@ altmeta For unix and VMS, treat two character sequence
"ESC c" as M-c (Meta+c, 8th bit set) when nethack [False] "ESC c" as M-c (Meta+c, 8th bit set) when nethack [False]
obtains a command from player's keyboard. obtains a command from player's keyboard.
Boolean option if USE_TILES was set at compile time (MSDOS protected mode): Boolean option if TILES_IN_GLYPHMAP set at compile time (MSDOS):
preload_tiles control whether tiles get pre-loaded into RAM at [True] preload_tiles control whether tiles get pre-loaded into RAM at [True]
the start of the game. Doing so enhances performance the start of the game. Doing so enhances performance
of the tile graphics, but uses more memory. of the tile graphics, but uses more memory.

View File

@@ -669,8 +669,8 @@ typedef unsigned char uchar;
/* End of Section 4 */ /* End of Section 4 */
#ifdef TTY_TILES_ESCCODES #ifdef TTY_TILES_ESCCODES
# ifndef USE_TILES # ifndef TILES_IN_GLYPHMAP
# define USE_TILES # define TILES_IN_GLYPHMAP
# endif # endif
#endif #endif

View File

@@ -830,7 +830,7 @@ struct instance_globals_c {
char *config_section_current; char *config_section_current;
boolean chosen_symset_start; boolean chosen_symset_start;
boolean chosen_symset_end; boolean chosen_symset_end;
/* invent.c */ /* invent.c */
/* for perm_invent when operating on a partial inventory display, so that /* for perm_invent when operating on a partial inventory display, so that
persistent one doesn't get shrunk during filtering for item selection persistent one doesn't get shrunk during filtering for item selection
@@ -1603,6 +1603,9 @@ struct instance_globals_w {
/* mkmaze.c */ /* mkmaze.c */
struct trap *wportal; struct trap *wportal;
/* new */
struct win_settings wsettings; /* wintype.h */
boolean havestate; boolean havestate;
unsigned long magic; /* validate that structure layout is preserved */ unsigned long magic; /* validate that structure layout is preserved */
}; };

View File

@@ -1003,9 +1003,9 @@ extern const int explodecolors[];
extern int wallcolors[]; extern int wallcolors[];
#endif #endif
/* If USE_TILES is defined during build, this comes from the generated /* If TILES_IN_GLYPHMAP is defined during build, this is defined
* tile.c, complete with appropriate tile references in the initialization. * in the generated tile.c, complete with appropriate tile references in
* Otherwise, it comes from display.c. * the initialization. Otherwise, it gets defined in display.c.
*/ */
extern const glyph_info nul_glyphinfo; extern const glyph_info nul_glyphinfo;

View File

@@ -545,6 +545,7 @@ extern const char *pmname(struct permonst *, int);
#endif #endif
extern const char *mon_pmname(struct monst *); extern const char *mon_pmname(struct monst *);
extern const char *obj_pmname(struct obj *); extern const char *obj_pmname(struct obj *);
boolean mapxy_valid(coordxy x, coordxy y);
/* ### do_wear.c ### */ /* ### do_wear.c ### */
@@ -2775,7 +2776,7 @@ extern boolean u_teleport_mon(struct monst *, boolean);
/* ### tile.c ### */ /* ### tile.c ### */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern void substitute_tiles(d_level *); extern void substitute_tiles(d_level *);
#endif #endif

View File

@@ -256,15 +256,15 @@ typedef uchar nhsym;
#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) \ #if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) \
|| defined(MSWIN_GRAPHICS) || defined(MSWIN_GRAPHICS)
#ifndef NO_TILE_C #ifndef NO_TILE_C
#ifndef USE_TILES #ifndef TILES_IN_GLYPHMAP
#define USE_TILES /* glyphmap[] with prefilled tile mappings will be available */ #define TILES_IN_GLYPHMAP
#endif #endif
#endif #endif
#endif #endif
#if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS) #if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS)
#ifndef NO_TILE_C #ifndef NO_TILE_C
#ifndef USE_TILES #ifndef TILES_IN_GLYPHMAP
#define USE_TILES #define TILES_IN_GLYPHMAP
#endif #endif
#endif #endif
#endif #endif

View File

@@ -78,9 +78,9 @@ static int optfn_##a(int, int, boolean, char *, char *);
{ m, OptS_##sec, 0, b, opt_##a, s, OthrOpt, n, v, d, No, c, \ { m, OptS_##sec, 0, b, opt_##a, s, OthrOpt, n, v, d, No, c, \
(boolean *) 0, &optfn_##a, al, z, (const char *) 0, On, On, 0 }, (boolean *) 0, &optfn_##a, al, z, (const char *) 0, On, On, 0 },
/* this is not reliable because USE_TILES might be defined in a /* this is not reliable because TILES_IN_GLYPHMAP might be defined
multi-interface binary but not apply to the current interface */ * in a multi-interface binary but not apply to the current interface */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
#define tiled_map_Def On #define tiled_map_Def On
#define ascii_map_Def Off #define ascii_map_Def Off
#else #else

View File

@@ -75,7 +75,7 @@
*/ */
#ifndef SUPPRESS_GRAPHICS #ifndef SUPPRESS_GRAPHICS
#if (defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST)) && !defined(PC9800) #if (defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST)) && !defined(PC9800)
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
#define SCREEN_VGA /* Include VGA graphics routines in the build */ #define SCREEN_VGA /* Include VGA graphics routines in the build */
#define SCREEN_VESA #define SCREEN_VESA
#endif #endif

View File

@@ -51,6 +51,8 @@ struct text_map_info_t {
X11_map_symbol text[ROWNO][COLNO]; /* Actual displayed screen. */ X11_map_symbol text[ROWNO][COLNO]; /* Actual displayed screen. */
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
X11_color colors[ROWNO][COLNO]; /* Color of each character. */ X11_color colors[ROWNO][COLNO]; /* Color of each character. */
X11_color framecolors[ROWNO][COLNO]; /* Color of background
behind text */
GC color_gcs[CLR_MAX], /* GC for each color */ GC color_gcs[CLR_MAX], /* GC for each color */
inv_color_gcs[CLR_MAX]; /* GC for each inverse color */ inv_color_gcs[CLR_MAX]; /* GC for each inverse color */
#define copy_gc color_gcs[NO_COLOR] #define copy_gc color_gcs[NO_COLOR]
@@ -74,6 +76,7 @@ struct tile_glyph_info_t {
unsigned short glyph; unsigned short glyph;
unsigned short tileidx; unsigned short tileidx;
unsigned glyphflags; unsigned glyphflags;
uint32 framecolor;
}; };
struct tile_map_info_t { struct tile_map_info_t {

View File

@@ -129,10 +129,10 @@ extern void curs_destroy_all_wins(void);
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
extern void curses_putch(winid wid, int x, int y, int ch, extern void curses_putch(winid wid, int x, int y, int ch,
struct unicode_representation *u, int color, struct unicode_representation *u, int color,
int attrs); int framecolor, int attrs);
#else #else
extern void curses_putch(winid wid, int x, int y, int ch, int color, extern void curses_putch(winid wid, int x, int y, int ch, int color,
int attrs); int framecolor, int attrs);
#endif #endif
extern void curses_get_window_size(winid wid, int *height, int *width); extern void curses_get_window_size(winid wid, int *height, int *width);
extern boolean curses_window_has_border(winid wid); extern boolean curses_window_has_border(winid wid);

View File

@@ -92,6 +92,7 @@ struct DisplayDesc {
short curx, cury; /* current cursor position on the screen */ short curx, cury; /* current cursor position on the screen */
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
int color; /* current color */ int color; /* current color */
uint32 framecolor; /* current background color */
#endif #endif
int attrs; /* attributes in effect */ int attrs; /* attributes in effect */
int toplin; /* flag for topl stuff */ int toplin; /* flag for topl stuff */
@@ -153,8 +154,8 @@ E void tty_shutdown(void);
#endif #endif
E int xputc(int); E int xputc(int);
E void xputs(const char *); E void xputs(const char *);
#if defined(SCREEN_VGA) || defined(SCREEN_8514) #if defined(SCREEN_VGA) || defined(SCREEN_8514) || defined(SCREEN_VESA)
E void xputg(const glyph_info *); E void xputg(const glyph_info *, const glyph_info *);
#endif #endif
E void cl_end(void); E void cl_end(void);
E void clear_screen(void); E void clear_screen(void);
@@ -188,6 +189,7 @@ E void term_end_raw_bold(void);
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
E void term_end_color(void); E void term_end_color(void);
E void term_start_color(int color); E void term_start_color(int color);
E void term_start_bgcolor(int color);
#endif /* TEXTCOLOR */ #endif /* TEXTCOLOR */
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
extern void term_start_24bitcolor(struct unicode_representation *); extern void term_start_24bitcolor(struct unicode_representation *);

View File

@@ -101,6 +101,7 @@ typedef struct glyph_map_entry {
typedef struct gi { typedef struct gi {
int glyph; /* the display entity */ int glyph; /* the display entity */
int ttychar; int ttychar;
uint32 framecolor;
glyph_map gm; glyph_map gm;
} glyph_info; } glyph_info;
#define GLYPH_INFO_P struct gi #define GLYPH_INFO_P struct gi
@@ -213,6 +214,22 @@ typedef struct win_request_info_t win_request_info;
/* #define CORE_INVENT */ /* #define CORE_INVENT */
/* In a binary with multiple window interfaces linked in, this is
* a structure to track certain interface capabilities that cannot be
* statically done at compile time. Some of them can be toggled and
* the core needs to know if they are active or not at the time.
*/
enum win_display_modes {
wdmode_traditional = 0,
wdmode_tiled
};
struct win_settings {
enum win_display_modes wdmode;
uint32 map_frame_color;
};
/* clang-format on */ /* clang-format on */
#endif /* WINTYPE_H */ #endif /* WINTYPE_H */

View File

@@ -63,7 +63,7 @@ void MyFreeBitMap(struct BitMap *bmp);
extern void display_map(struct Window *); extern void display_map(struct Window *);
#endif #endif
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern int maxmontile, maxobjtile, maxothtile; /* from tile.c */ extern int maxmontile, maxobjtile, maxothtile; /* from tile.c */
#define MAXMONTILE maxmontile #define MAXMONTILE maxmontile
#define MAXOBJTILE maxobjtile #define MAXOBJTILE maxobjtile

View File

@@ -363,7 +363,7 @@ DLBFLG =
# #
! IF ("$(TILESUPPORT)"=="Y") ! IF ("$(TILESUPPORT)"=="Y")
TILFLG = $(CDEFINE)USE_TILES TILFLG = $(CDEFINE)TILES_IN_GLYPHMAP
! ELSE ! ELSE
TILFLG = TILFLG =
! ENDIF ! ENDIF

View File

@@ -114,12 +114,12 @@ GAMEFILE = $(GAMEDIR)\$(GAME).exe
# Flags. # Flags.
# #
# Debugging # Debugging
#CFLAGS = /Zi /DFUNCTION_LEVEL_LINKING /DUSE_TILES /DDLB #CFLAGS = /Zi /DFUNCTION_LEVEL_LINKING /DTILES_IN_GLYPHMAP /DDLB
#LFLAGS = /CODEVIEW /NOI/MAP /CPARM:1 /INFO #LFLAGS = /CODEVIEW /NOI/MAP /CPARM:1 /INFO
# Normal # Normal
LFLAGS = /NOI/MAP /CPARM:1 /INFO LFLAGS = /NOI/MAP /CPARM:1 /INFO
CFLAGS = /DFUNCTION_LEVEL_LINKING /DUSE_TILES /DDLB CFLAGS = /DFUNCTION_LEVEL_LINKING /DTILES_IN_GLYPHMAP /DDLB
SPECOPTS = SPECOPTS =
# #
# Leaving MACHINE_CODE undefined will allow it to run # Leaving MACHINE_CODE undefined will allow it to run

View File

@@ -139,7 +139,7 @@ override TARGET_STUBEDIT=
override TARGET_CFLAGS = -c -O $(TOOLARCH) \ override TARGET_CFLAGS = -c -O $(TOOLARCH) \
-I../include -I../outdated/include \ -I../include -I../outdated/include \
-I../outdated/sys/amiga -I../win/share \ -I../outdated/sys/amiga -I../win/share \
$(LUAINCL) -DAMIGA -DUSE_TILES $(PDCURSESDEF) \ $(LUAINCL) -DAMIGA -DTILES_IN_GLYPHMAP $(PDCURSESDEF) \
-DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_AMIGA \ -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_AMIGA \
-DAMIGA_VERSION_STRING=\""VER: NetHack 3.7.0\"" -DAMIGA_VERSION_STRING=\""VER: NetHack 3.7.0\""
# -DMICRO -DPATHLEN=31 -DFILENAME=80 # -DMICRO -DPATHLEN=31 -DFILENAME=80

View File

@@ -360,6 +360,7 @@ const struct instance_globals_g g_init_g = {
{ { { 0 } } }, /* gbuf */ { { { 0 } } }, /* gbuf */
UNDEFINED_VALUES, /* gbuf_start */ UNDEFINED_VALUES, /* gbuf_start */
UNDEFINED_VALUES, /* gbug_stop */ UNDEFINED_VALUES, /* gbug_stop */
/* do_name.c */ /* do_name.c */
UNDEFINED_PTR, /* gloc_filter_map */ UNDEFINED_PTR, /* gloc_filter_map */
UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */ UNDEFINED_VALUE, /* gloc_filter_floodfill_match_glyph */
@@ -834,6 +835,9 @@ const struct instance_globals_w g_init_w = {
UNDEFINED_VALUE, /* wc */ UNDEFINED_VALUE, /* wc */
/* mkmaze.c */ /* mkmaze.c */
UNDEFINED_PTR, /* wportal */ UNDEFINED_PTR, /* wportal */
/* new */
{ wdmode_traditional, NO_COLOR }, /* wsettings */
TRUE, /* havestate*/ TRUE, /* havestate*/
IVMAGIC /* w_magic used to validate that structure layout has been preserved */ IVMAGIC /* w_magic used to validate that structure layout has been preserved */
}; };

View File

@@ -129,7 +129,7 @@ static int swallow_to_glyph(int, int);
static void display_warning(struct monst *); static void display_warning(struct monst *);
static int check_pos(coordxy, coordxy, int); static int check_pos(coordxy, coordxy, int);
static int get_bk_glyph(coordxy x, coordxy y); static void get_bkglyph_and_framecolor(coordxy x, coordxy y, int *, uint32 *);
static int tether_glyph(coordxy, coordxy); static int tether_glyph(coordxy, coordxy);
static void mimic_light_blocking(struct monst *); static void mimic_light_blocking(struct monst *);
#ifdef UNBUFFERED_GLYPHINFO #ifdef UNBUFFERED_GLYPHINFO
@@ -1444,7 +1444,7 @@ see_traps(void)
/* glyph, ttychar, { glyphflags, { sym.color, sym.symidx }, /* glyph, ttychar, { glyphflags, { sym.color, sym.symidx },
tileidx, u } */ tileidx, u } */
static glyph_info no_ginfo = { static glyph_info no_ginfo = {
NO_GLYPH, ' ', { MG_BADXY, { NO_COLOR, 0 }, 0 NO_GLYPH, ' ', NO_COLOR, { MG_BADXY, { NO_COLOR, 0 }, 0
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
, 0 , 0
#endif #endif
@@ -1459,13 +1459,13 @@ static glyph_info ginfo;
#define Glyphinfo_at(x, y, glyph) glyphinfo_at(x, y, glyph) #define Glyphinfo_at(x, y, glyph) glyphinfo_at(x, y, glyph)
#endif #endif
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern const glyph_info nul_glyphinfo; /* tile.c */ extern const glyph_info nul_glyphinfo; /* tile.c */
#else #else
/* glyph, ttychar, { glyphflags, { sym.color, sym.symidx }, /* glyph, ttychar, { glyphflags, { sym.color, sym.symidx },
tileidx, 0} */ tileidx, 0} */
const glyph_info nul_glyphinfo = { const glyph_info nul_glyphinfo = {
NO_GLYPH, ' ', NO_GLYPH, ' ', NO_COLOR,
{ /* glyph_map */ { /* glyph_map */
MG_UNEXPL, MG_UNEXPL,
{ NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X }, { NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X },
@@ -1477,7 +1477,7 @@ const glyph_info nul_glyphinfo = {
}; };
#endif #endif
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern glyph_map glyphmap[MAX_GLYPH]; /* from tile.c */ extern glyph_map glyphmap[MAX_GLYPH]; /* from tile.c */
#else #else
glyph_map glyphmap[MAX_GLYPH] = { glyph_map glyphmap[MAX_GLYPH] = {
@@ -1590,7 +1590,7 @@ redraw_map(void)
for (y = 0; y < ROWNO; ++y) for (y = 0; y < ROWNO; ++y)
for (x = 1; x < COLNO; ++x) { for (x = 1; x < COLNO; ++x) {
glyph = glyph_at(x, y); /* not levl[x][y].glyph */ glyph = glyph_at(x, y); /* not levl[x][y].glyph */
bkglyphinfo.glyph = get_bk_glyph(x, y); get_bkglyph_and_framecolor(x, y, &bkglyphinfo.glyph, &bkglyphinfo.framecolor);
print_glyph(WIN_MAP, x, y, print_glyph(WIN_MAP, x, y,
Glyphinfo_at(x, y, glyph), &bkglyphinfo); Glyphinfo_at(x, y, glyph), &bkglyphinfo);
} }
@@ -1826,7 +1826,7 @@ show_glyph(coordxy x, coordxy y, int glyph)
static gbuf_entry nul_gbuf = { static gbuf_entry nul_gbuf = {
0, /* gnew */ 0, /* gnew */
{ GLYPH_UNEXPLORED, (unsigned) ' ', /* glyphinfo.glyph */ { GLYPH_UNEXPLORED, (unsigned) ' ', NO_COLOR, /* glyphinfo.glyph */
/* glyphinfo.gm */ /* glyphinfo.gm */
{ MG_UNEXPL, { (unsigned) NO_COLOR, 0 }, 0 { MG_UNEXPL, { (unsigned) NO_COLOR, 0 }, 0
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
@@ -1906,8 +1906,10 @@ row_refresh(coordxy start, coordxy stop, coordxy y)
for (x = start; x <= stop; x++) { for (x = start; x <= stop; x++) {
gptr = &gg.gbuf[y][x]; gptr = &gg.gbuf[y][x];
glyph = gptr->glyphinfo.glyph; glyph = gptr->glyphinfo.glyph;
if (force || glyph != GLYPH_UNEXPLORED) { get_bkglyph_and_framecolor(x, y, &bkglyphinfo.glyph,
bkglyphinfo.glyph = get_bk_glyph(x, y); &bkglyphinfo.framecolor);
if (force || glyph != GLYPH_UNEXPLORED
|| bkglyphinfo.framecolor != NO_COLOR) {
print_glyph(WIN_MAP, x, y, print_glyph(WIN_MAP, x, y,
Glyphinfo_at(x, y, glyph), &bkglyphinfo); Glyphinfo_at(x, y, glyph), &bkglyphinfo);
} }
@@ -1943,6 +1945,7 @@ flush_screen(int cursor_on_u)
static int delay_flushing = 0; static int delay_flushing = 0;
register coordxy x, y; register coordxy x, y;
glyph_info bkglyphinfo = nul_glyphinfo; glyph_info bkglyphinfo = nul_glyphinfo;
int bkglyph;
/* 3.7: don't update map, status, or perm_invent during save/restore */ /* 3.7: don't update map, status, or perm_invent during save/restore */
if (suppress_map_output()) if (suppress_map_output())
@@ -1969,13 +1972,16 @@ flush_screen(int cursor_on_u)
for (y = 0; y < ROWNO; y++) { for (y = 0; y < ROWNO; y++) {
register gbuf_entry *gptr = &gg.gbuf[y][x = gg.gbuf_start[y]]; register gbuf_entry *gptr = &gg.gbuf[y][x = gg.gbuf_start[y]];
for (; x <= gg.gbuf_stop[y]; gptr++, x++) for (; x <= gg.gbuf_stop[y]; gptr++, x++) {
if (gptr->gnew) { get_bkglyph_and_framecolor(x, y, &bkglyph, &bkglyphinfo.framecolor);
map_glyphinfo(x, y, get_bk_glyph(x, y), 0, &bkglyphinfo); if (gptr->gnew
|| (gw.wsettings.map_frame_color != NO_COLOR && bkglyphinfo.framecolor != NO_COLOR)) {
map_glyphinfo(x, y, bkglyph, 0, &bkglyphinfo); /* won't touch framecolor */
print_glyph(WIN_MAP, x, y, print_glyph(WIN_MAP, x, y,
Glyphinfo_at(x, y, gptr->glyph), &bkglyphinfo); Glyphinfo_at(x, y, gptr->glyph), &bkglyphinfo);
gptr->gnew = 0; gptr->gnew = 0;
} }
}
} }
reset_glyph_bbox(); reset_glyph_bbox();
@@ -2204,22 +2210,21 @@ glyphinfo_at(coordxy x, coordxy y, int glyph)
#endif #endif
/* /*
* This will be used to get the glyph for the background so that * Get the glyph for the background so that it can potentially
* it can potentially be merged into graphical window ports to * be merged into graphical window ports to improve the appearance
* improve the appearance of stuff on dark room squares and the * of stuff on dark room squares and the plane of air etc.
* plane of air etc.
*
* Until that is working correctly in the branch, however, for now
* we just return NO_GLYPH as an indicator to ignore it.
*
* [This should be using background as recorded for #overview rather * [This should be using background as recorded for #overview rather
* than current data from the map.] * than current data from the map.]
*
* Also get the frame color to use for highlighting the map location
* for some purpose.
*
*/ */
static int static void
get_bk_glyph(coordxy x, coordxy y) get_bkglyph_and_framecolor(coordxy x, coordxy y, int *bkglyph, uint32 *framecolor)
{ {
int idx, bkglyph = GLYPH_UNEXPLORED; int idx, tmp_bkglyph = GLYPH_UNEXPLORED;
struct rm *lev = &levl[x][y]; struct rm *lev = &levl[x][y];
if (iflags.use_background_glyph && lev->seenv != 0 if (iflags.use_background_glyph && lev->seenv != 0
@@ -2267,14 +2272,18 @@ get_bk_glyph(coordxy x, coordxy y)
idx = (flags.dark_room && iflags.use_color) idx = (flags.dark_room && iflags.use_color)
? DARKROOMSYM : S_stone; ? DARKROOMSYM : S_stone;
} }
if (idx != S_room) if (idx != S_room)
bkglyph = cmap_to_glyph(idx); tmp_bkglyph = cmap_to_glyph(idx);
} }
return bkglyph; if (gw.wsettings.map_frame_color != NO_COLOR && framecolor && mapxy_valid(x, y))
*framecolor = gw.wsettings.map_frame_color;
else
*framecolor = NO_COLOR;
*bkglyph = tmp_bkglyph;
} }
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
#define HAS_ROGUE_IBM_GRAPHICS \ #define HAS_ROGUE_IBM_GRAPHICS \
(gc.currentgraphics == ROGUESET && SYMHANDLING(H_IBM) && !iflags.grmode) (gc.currentgraphics == ROGUESET && SYMHANDLING(H_IBM) && !iflags.grmode)
#else #else

View File

@@ -6,6 +6,8 @@
#include "hack.h" #include "hack.h"
static char *nextmbuf(void); static char *nextmbuf(void);
static void getpos_getvalids_selection(struct selectionvar *, boolean (*)(coordxy, coordxy));
static void selection_force_newsyms(struct selectionvar *);
static void getpos_help_keyxhelp(winid, const char *, const char *, int); static void getpos_help_keyxhelp(winid, const char *, const char *, int);
static void getpos_help(boolean, const char *); static void getpos_help(boolean, const char *);
static int QSORTCALLBACK cmp_coord_distu(const void *, const void *); static int QSORTCALLBACK cmp_coord_distu(const void *, const void *);
@@ -50,8 +52,50 @@ getpos_sethilite(
void (*gp_hilitef)(int), void (*gp_hilitef)(int),
boolean (*gp_getvalidf)(coordxy, coordxy)) boolean (*gp_getvalidf)(coordxy, coordxy))
{ {
boolean was_valid = (getpos_getvalid != NULL);
struct selectionvar *sel = selection_new();
getpos_getvalids_selection(sel, getpos_getvalid);
getpos_hilitefunc = gp_hilitef; getpos_hilitefunc = gp_hilitef;
getpos_getvalid = gp_getvalidf; getpos_getvalid = gp_getvalidf;
getpos_getvalids_selection(sel, getpos_getvalid);
gw.wsettings.map_frame_color = (getpos_getvalid != NULL) ? CLR_BLUE : NO_COLOR;
if ((boolean) (getpos_getvalid != NULL) != was_valid)
selection_force_newsyms(sel);
selection_free(sel, TRUE);
}
boolean
mapxy_valid(coordxy x, coordxy y)
{
if (getpos_getvalid)
return (*getpos_getvalid)(x, y);
return FALSE;
}
static void
getpos_getvalids_selection(struct selectionvar *sel, boolean (*validf)(coordxy, coordxy))
{
coordxy x, y;
if (!sel || !validf)
return;
for (x = 1; x < sel->wid; x++)
for (y = 0; y < sel->hei; y++)
if ((*validf)(x, y))
selection_setpoint(x, y, sel, 1);
}
static void
selection_force_newsyms(struct selectionvar *sel)
{
coordxy x, y;
for (x = 1; x < sel->wid; x++)
for (y = 0; y < sel->hei; y++)
if (selection_getpoint(x, y, sel))
newsym_force(x, y);
} }
static const char *const gloc_descr[NUM_GLOCS][4] = { static const char *const gloc_descr[NUM_GLOCS][4] = {
@@ -1058,8 +1102,7 @@ getpos(coord *ccp, boolean force, const char *goal)
for (i = 0; i < NUM_GLOCS; i++) for (i = 0; i < NUM_GLOCS; i++)
if (garr[i]) if (garr[i])
free((genericptr_t) garr[i]); free((genericptr_t) garr[i]);
getpos_hilitefunc = (void (*)(int)) 0; getpos_sethilite(NULL, NULL);
getpos_getvalid = (boolean (*)(coordxy, coordxy)) 0;
u.dx = udx, u.dy = udy, u.dz = udz; u.dx = udx, u.dy = udy, u.dz = udz;
return result; return result;
} }

View File

@@ -107,7 +107,7 @@ struct win_information {
static struct win_information window_opts[] = { static struct win_information window_opts[] = {
#ifdef TTY_GRAPHICS #ifdef TTY_GRAPHICS
{ "tty", { "tty",
/* testing 'USE_TILES' here would bring confusion because it could /* testing 'TILES_IN_GLYPHMAP' here would bring confusion because it could
apply to another interface such as X11, so check MSDOS explicitly apply to another interface such as X11, so check MSDOS explicitly
instead; even checking TTY_TILES_ESCCODES would probably be instead; even checking TTY_TILES_ESCCODES would probably be
confusing to most users (and it will already be listed separately confusing to most users (and it will already be listed separately

View File

@@ -11,7 +11,7 @@ static void shuffle_all(void);
static int QSORTCALLBACK discovered_cmp(const genericptr, const genericptr); static int QSORTCALLBACK discovered_cmp(const genericptr, const genericptr);
static char *oclass_to_name(char, char *); static char *oclass_to_name(char, char *);
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern glyph_map glyphmap[MAX_GLYPH]; extern glyph_map glyphmap[MAX_GLYPH];
static void shuffle_tiles(void); static void shuffle_tiles(void);
@@ -39,7 +39,7 @@ shuffle_tiles(void)
glyphmap[i + GLYPH_OBJ_PILETOP_OFF].tileidx = tmp_tilemap[1][i]; glyphmap[i + GLYPH_OBJ_PILETOP_OFF].tileidx = tmp_tilemap[1][i];
} }
} }
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
static void static void
setgemprobs(d_level* dlev) setgemprobs(d_level* dlev)
@@ -208,7 +208,7 @@ init_objects(void)
/* shuffle descriptions */ /* shuffle descriptions */
shuffle_all(); shuffle_all();
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
shuffle_tiles(); shuffle_tiles();
#endif #endif
objects[WAN_NOTHING].oc_dir = rn2(2) ? NODIR : IMMEDIATE; objects[WAN_NOTHING].oc_dir = rn2(2) ? NODIR : IMMEDIATE;
@@ -403,7 +403,7 @@ restnames(NHFILE* nhfp)
} }
} }
} }
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
shuffle_tiles(); shuffle_tiles();
#endif #endif
} }

View File

@@ -229,7 +229,7 @@ assign_graphics(int whichset)
gs.showsyms[i] = go.ov_rogue_syms[i] ? go.ov_rogue_syms[i] gs.showsyms[i] = go.ov_rogue_syms[i] ? go.ov_rogue_syms[i]
: gr.rogue_syms[i]; : gr.rogue_syms[i];
#if defined(MSDOS) && defined(USE_TILES) #if defined(MSDOS) && defined(TILES_IN_GLYPHMAP)
if (iflags.grmode) if (iflags.grmode)
tileview(FALSE); tileview(FALSE);
#endif #endif
@@ -242,7 +242,7 @@ assign_graphics(int whichset)
gs.showsyms[i] = go.ov_primary_syms[i] ? go.ov_primary_syms[i] gs.showsyms[i] = go.ov_primary_syms[i] ? go.ov_primary_syms[i]
: gp.primary_syms[i]; : gp.primary_syms[i];
#if defined(MSDOS) && defined(USE_TILES) #if defined(MSDOS) && defined(TILES_IN_GLYPHMAP)
if (iflags.grmode) if (iflags.grmode)
tileview(TRUE); tileview(TRUE);
#endif #endif

View File

@@ -460,11 +460,11 @@ cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS
LFLAGS = LFLAGS =
# Debugging # Debugging
#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES #cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DTILES_IN_GLYPHMAP
#LFLAGS = -g #LFLAGS = -g
# Normal # Normal
cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DTILES_IN_GLYPHMAP
LFLAGS = LFLAGS =
#========================================== #==========================================

View File

@@ -58,7 +58,7 @@ unsigned long sys_random_seed(void);
static char *getdta(void); static char *getdta(void);
#endif #endif
static unsigned int dos_ioctl(int, int, unsigned); static unsigned int dos_ioctl(int, int, unsigned);
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern boolean pckeys(unsigned char, unsigned char); /* pckeys.c */ extern boolean pckeys(unsigned char, unsigned char); /* pckeys.c */
#endif #endif
@@ -281,7 +281,7 @@ BIOSgetch(void)
else else
ch = kpad[scan - KEYPADLO].normal; ch = kpad[scan - KEYPADLO].normal;
} }
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
/* Check for special interface manipulation keys */ /* Check for special interface manipulation keys */
if (pckeys(scan, shift)) { if (pckeys(scan, shift)) {
ch = 0xFF; ch = 0xFF;

View File

@@ -9,7 +9,7 @@
#include "hack.h" #include "hack.h"
#ifdef MSDOS #ifdef MSDOS
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
#include "wintty.h" #include "wintty.h"
#include "pcvideo.h" #include "pcvideo.h"
@@ -126,7 +126,7 @@ refresh(void)
vesa_refresh(); vesa_refresh();
#endif #endif
} }
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
#endif /* MSDOS */ #endif /* MSDOS */
/*pckeys.c*/ /*pckeys.c*/

View File

@@ -12,7 +12,7 @@
#include "hack.h" #include "hack.h"
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
#if defined(__GO32__) || defined(__DJGPP__) #if defined(__GO32__) || defined(__DJGPP__)
#include <unistd.h> #include <unistd.h>
@@ -247,6 +247,6 @@ ReadPackedTileFile(int tilenum, char (*pta)[TILE_X])
return 0; return 0;
} }
#endif #endif
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
/* pctiles.c */ /* pctiles.c */

View File

@@ -10,7 +10,7 @@
* *
*/ */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
#ifndef TILE_X #ifndef TILE_X
#define TILE_X 16 #define TILE_X 16
#endif #endif
@@ -59,6 +59,6 @@ extern int ReadPlanarTileFile_O(int, struct overview_planar_cell_struct **);
#ifdef PACKED_FILE #ifdef PACKED_FILE
extern int ReadPackedTileFile(int, char (*)[TILE_X]); extern int ReadPackedTileFile(int, char (*)[TILE_X]);
#endif #endif
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
/* pctiles.h */ /* pctiles.h */

View File

@@ -276,7 +276,7 @@ extern void vga_tty_end_screen(void);
extern void vga_tty_startup(int *, int *); extern void vga_tty_startup(int *, int *);
extern void vga_xputs(const char *, int, int); extern void vga_xputs(const char *, int, int);
extern void vga_xputc(char, int); extern void vga_xputc(char, int);
extern void vga_xputg(const glyph_info *); extern void vga_xputg(const glyph_info *, const glyph_info *);
extern void vga_userpan(enum vga_pan_direction); extern void vga_userpan(enum vga_pan_direction);
extern void vga_overview(boolean); extern void vga_overview(boolean);
extern void vga_traditional(boolean); extern void vga_traditional(boolean);
@@ -305,7 +305,7 @@ extern void vesa_tty_end_screen(void);
extern void vesa_tty_startup(int *, int *); extern void vesa_tty_startup(int *, int *);
extern void vesa_xputs(const char *, int, int); extern void vesa_xputs(const char *, int, int);
extern void vesa_xputc(char, int); extern void vesa_xputc(char, int);
extern void vesa_xputg(const glyph_info *); extern void vesa_xputg(const glyph_info *, const glyph_info *);
extern void vesa_userpan(enum vga_pan_direction); extern void vesa_userpan(enum vga_pan_direction);
extern void vesa_overview(boolean); extern void vesa_overview(boolean);
extern void vesa_traditional(boolean); extern void vesa_traditional(boolean);

View File

@@ -132,6 +132,7 @@ int attrib_text_normal; /* text mode normal attribute */
int attrib_gr_normal; /* graphics mode normal attribute */ int attrib_gr_normal; /* graphics mode normal attribute */
int attrib_text_intense; /* text mode intense attribute */ int attrib_text_intense; /* text mode intense attribute */
int attrib_gr_intense; /* graphics mode intense attribute */ int attrib_gr_intense; /* graphics mode intense attribute */
uint32 curframecolor = NO_COLOR; /* current background text color */
boolean traditional = FALSE; /* traditonal TTY character mode */ boolean traditional = FALSE; /* traditonal TTY character mode */
boolean inmap = FALSE; /* in the map window */ boolean inmap = FALSE; /* in the map window */
#ifdef TEXTCOLOR #ifdef TEXTCOLOR
@@ -165,7 +166,7 @@ clear_screen(void)
#endif #endif
#ifdef SCREEN_VESA #ifdef SCREEN_VESA
} else if (iflags.usevesa) { } else if (iflags.usevesa) {
vesa_clear_screen(BACKGROUND_VGA_COLOR); vesa_clear_screen(BACKGROUND_VESA_COLOR);
#endif #endif
} }
} }
@@ -302,12 +303,14 @@ term_end_attr(int attr)
default: default:
g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal; g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
} }
curframecolor = NO_COLOR;
} }
void void
term_end_color(void) term_end_color(void)
{ {
g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal; g_attribute = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
curframecolor = NO_COLOR;
} }
void void
@@ -370,6 +373,19 @@ term_start_color(int color)
#endif #endif
} }
void
term_start_bgcolor(int bgcolor)
{
// pline("before bgcolor = %d, curframecolor = %d", bgcolor, curframecolor);
#ifdef TEXTCOLOR
if (!monoflag) {
if (bgcolor >= 0 && bgcolor < CLR_MAX)
curframecolor = bgcolor;
}
#endif
// pline("after bgcolor = %d, curframecolor = %d", bgcolor, curframecolor);
}
void void
term_start_raw_bold(void) term_start_raw_bold(void)
{ {
@@ -577,8 +593,12 @@ xputc(int ch) /* write out character (and attribute) */
char attribute; char attribute;
i = iflags.grmode ? attrib_gr_normal : attrib_text_normal; i = iflags.grmode ? attrib_gr_normal : attrib_text_normal;
attribute = (char) ((g_attribute == 0) ? i : g_attribute); attribute = (char) ((g_attribute == 0) ? i : g_attribute);
if (curframecolor != NO_COLOR) {
attribute |= ((ttycolors[curframecolor]) << 4);
}
if (!iflags.grmode) { if (!iflags.grmode) {
txt_xputc(ch, attribute); txt_xputc(ch, attribute);
#ifdef SCREEN_VGA #ifdef SCREEN_VGA
@@ -594,17 +614,17 @@ xputc(int ch) /* write out character (and attribute) */
} }
/* write out a glyph picture at current location */ /* write out a glyph picture at current location */
void xputg(const glyph_info *glyphinfo) void xputg(const glyph_info *glyphinfo, const glyph_info *bkglyphinfo)
{ {
if (!iflags.grmode || !iflags.tile_view) { if (!iflags.grmode || !iflags.tile_view) {
(void) xputc((char) glyphinfo->ttychar); (void) xputc((char) glyphinfo->ttychar);
#ifdef SCREEN_VGA #ifdef SCREEN_VGA
} else if (iflags.grmode && iflags.usevga) { } else if (iflags.grmode && iflags.usevga) {
vga_xputg(glyphinfo); vga_xputg(glyphinfo, bkglyphinfo);
#endif #endif
#ifdef SCREEN_VESA #ifdef SCREEN_VESA
} else if (iflags.grmode && iflags.usevesa) { } else if (iflags.grmode && iflags.usevesa) {
vesa_xputg(glyphinfo); vesa_xputg(glyphinfo, bkglyphinfo);
#endif #endif
} }
} }

View File

@@ -22,7 +22,7 @@
extern int total_tiles_used, Tile_corr, Tile_unexplored; /* from tile.c */ extern int total_tiles_used, Tile_corr, Tile_unexplored; /* from tile.c */
struct VesaCharacter { struct VesaCharacter {
uint32 colour; uint32 colour, bgcolour;
uint32 chr; uint32 chr;
}; };
@@ -86,6 +86,7 @@ static struct map_struct {
uint32 attr; uint32 attr;
unsigned special; unsigned special;
short int tileidx; short int tileidx;
int framecolor;
} map[ROWNO][COLNO]; /* track the glyphs */ } map[ROWNO][COLNO]; /* track the glyphs */
#define vesa_clearmap() \ #define vesa_clearmap() \
@@ -95,6 +96,7 @@ static struct map_struct {
for (x = 0; x < COLNO; ++x) { \ for (x = 0; x < COLNO; ++x) { \
map[y][x].glyph = GLYPH_UNEXPLORED; \ map[y][x].glyph = GLYPH_UNEXPLORED; \
map[y][x].ch = glyph2ttychar(GLYPH_UNEXPLORED); \ map[y][x].ch = glyph2ttychar(GLYPH_UNEXPLORED); \
map[y][x].framecolor = NO_COLOR; \
map[y][x].attr = 0; \ map[y][x].attr = 0; \
map[y][x].special = 0; \ map[y][x].special = 0; \
map[y][x].tileidx = Tile_unexplored; \ map[y][x].tileidx = Tile_unexplored; \
@@ -667,10 +669,10 @@ vesa_xputc(char ch, int attr)
vesa_gotoloc(col, row); vesa_gotoloc(col, row);
} }
#if defined(USE_TILES) #if defined(TILES_IN_GLYPHMAP)
/* Place tile represent. a glyph at current location */ /* Place tile represent. a glyph at current location */
void void
vesa_xputg(const glyph_info *glyphinfo) vesa_xputg(const glyph_info *glyphinfo, const glyph_info *bkglyphinfo UNUSED)
{ {
int glyphnum = glyphinfo->glyph; int glyphnum = glyphinfo->glyph;
uint32 ch = (uchar) glyphinfo->ttychar; uint32 ch = (uchar) glyphinfo->ttychar;
@@ -701,6 +703,11 @@ vesa_xputg(const glyph_info *glyphinfo)
map[ry][col].special = special; map[ry][col].special = special;
map[ry][col].tileidx = glyphinfo->gm.tileidx; map[ry][col].tileidx = glyphinfo->gm.tileidx;
map[ry][col].attr = attr; map[ry][col].attr = attr;
if (bkglyphinfo->framecolor != NO_COLOR) {
map[ry][col].framecolor = bkglyphinfo->framecolor;
}
if (iflags.traditional_view) { if (iflags.traditional_view) {
vesa_WriteChar(ch, col, row, attr); vesa_WriteChar(ch, col, row, attr);
} else { } else {
@@ -717,7 +724,7 @@ vesa_xputg(const glyph_info *glyphinfo)
++col; ++col;
vesa_gotoloc(col, row); vesa_gotoloc(col, row);
} }
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
/* /*
* Cursor location manipulation, and location information fetching * Cursor location manipulation, and location information fetching
@@ -738,7 +745,7 @@ vesa_gotoloc(int col, int row)
currow = min(row, LI - 1); currow = min(row, LI - 1);
} }
#if defined(USE_TILES) && defined(CLIPPING) #if defined(TILES_IN_GLYPHMAP) && defined(CLIPPING)
static void static void
vesa_cliparound(int x, int y) vesa_cliparound(int x, int y)
{ {
@@ -857,7 +864,8 @@ vesa_redrawmap(void)
free(p_row); free(p_row);
} }
#endif /* USE_TILES && CLIPPING */ #endif /* TILES_IN_GLYPHMAP && CLIPPING */
void void
vesa_userpan(enum vga_pan_direction pan) vesa_userpan(enum vga_pan_direction pan)
@@ -1030,7 +1038,7 @@ vesa_Init(void)
if (inited) return; if (inited) return;
inited = TRUE; inited = TRUE;
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
/* /*
* Attempt to open the required tile files. If we can't * Attempt to open the required tile files. If we can't
* don't perform the video mode switch, use TTY code instead. * don't perform the video mode switch, use TTY code instead.
@@ -1082,7 +1090,7 @@ vesa_Init(void)
windowprocs.wincap2 |= WC2_U_24BITCOLOR; windowprocs.wincap2 |= WC2_U_24BITCOLOR;
} }
#endif #endif
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
paletteptr = get_palette(); paletteptr = get_palette();
iflags.tile_view = TRUE; iflags.tile_view = TRUE;
iflags.over_view = FALSE; iflags.over_view = FALSE;
@@ -1626,6 +1634,8 @@ vesa_flush_text(void)
chr_cache_size = 0; chr_cache_size = 0;
} }
extern uint32 curframecolor; /* video.c */
static void static void
vesa_WriteTextRow(int pixx, int pixy, struct VesaCharacter const *t_row, vesa_WriteTextRow(int pixx, int pixy, struct VesaCharacter const *t_row,
unsigned t_row_width) unsigned t_row_width)
@@ -1637,6 +1647,7 @@ vesa_WriteTextRow(int pixx, int pixy, struct VesaCharacter const *t_row,
unsigned long offset = pixy * (unsigned long)vesa_scan_line + pixx * vesa_pixel_bytes; unsigned long offset = pixy * (unsigned long)vesa_scan_line + pixx * vesa_pixel_bytes;
unsigned char fg[4], bg[4]; unsigned char fg[4], bg[4];
#if 0
/* Preprocess the background color */ /* Preprocess the background color */
if (vesa_pixel_bytes == 1) { if (vesa_pixel_bytes == 1) {
bg[0] = BACKGROUND_VESA_COLOR; bg[0] = BACKGROUND_VESA_COLOR;
@@ -1647,6 +1658,7 @@ vesa_WriteTextRow(int pixx, int pixy, struct VesaCharacter const *t_row,
bg[2] = (pix >> 16) & 0xFF; bg[2] = (pix >> 16) & 0xFF;
bg[3] = (pix >> 24) & 0xFF; bg[3] = (pix >> 24) & 0xFF;
} }
#endif
/* First loop: draw one raster line of all row entries */ /* First loop: draw one raster line of all row entries */
for (py = 0; py < (int) vesa_char_height; ++py) { for (py = 0; py < (int) vesa_char_height; ++py) {
@@ -1655,6 +1667,17 @@ vesa_WriteTextRow(int pixx, int pixy, struct VesaCharacter const *t_row,
for (i = 0; i < t_row_width; ++i) { for (i = 0; i < t_row_width; ++i) {
uint32 chr = t_row[i].chr; uint32 chr = t_row[i].chr;
uint32 colour = t_row[i].colour; uint32 colour = t_row[i].colour;
/* background color */
if (vesa_pixel_bytes == 1) {
bg[0] = BACKGROUND_VESA_COLOR;
} else {
unsigned long pix = vesa_palette[t_row[i].bgcolour];
bg[0] = pix & 0xFF;
bg[1] = (pix >> 8) & 0xFF;
bg[2] = (pix >> 16) & 0xFF;
bg[3] = (pix >> 24) & 0xFF;
}
/* Preprocess the foreground color */ /* Preprocess the foreground color */
if (colour & 0x80000000) { if (colour & 0x80000000) {
fg[0] = colour & 0xFF; fg[0] = colour & 0xFF;
@@ -1910,7 +1933,7 @@ vesa_SetHardPalette(const struct Pixel *palette)
/* First, try the VESA palette function */ /* First, try the VESA palette function */
/* Set the tile set and text colors */ /* Set the tile set and text colors */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
for (i = 0; i < FIRST_TEXT_COLOR; ++i) { for (i = 0; i < FIRST_TEXT_COLOR; ++i) {
p2[i*4 + 0] = palette[i].b >> shift; p2[i*4 + 0] = palette[i].b >> shift;
p2[i*4 + 1] = palette[i].g >> shift; p2[i*4 + 1] = palette[i].g >> shift;
@@ -1937,7 +1960,7 @@ vesa_SetHardPalette(const struct Pixel *palette)
/* If that didn't work, use the original BIOS function */ /* If that didn't work, use the original BIOS function */
if (regs.x.ax != 0x004F) { if (regs.x.ax != 0x004F) {
/* Set the tile set and text colors */ /* Set the tile set and text colors */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
for (i = 0; i < FIRST_TEXT_COLOR; ++i) { for (i = 0; i < FIRST_TEXT_COLOR; ++i) {
p2[i*3 + 0] = palette[i].r >> shift; p2[i*3 + 0] = palette[i].r >> shift;
p2[i*3 + 1] = palette[i].g >> shift; p2[i*3 + 1] = palette[i].g >> shift;
@@ -1976,7 +1999,7 @@ vesa_SetSoftPalette(const struct Pixel *palette)
unsigned i; unsigned i;
/* Set the tile set and text colors */ /* Set the tile set and text colors */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
if (palette != NULL) { if (palette != NULL) {
p = palette; p = palette;
for (i = 0; i < FIRST_TEXT_COLOR; ++i) { for (i = 0; i < FIRST_TEXT_COLOR; ++i) {

View File

@@ -143,7 +143,7 @@ extern int attrib_gr_normal; /* graphics mode normal attribute */
extern int attrib_text_intense; /* text mode intense attribute */ extern int attrib_text_intense; /* text mode intense attribute */
extern int attrib_gr_intense; /* graphics mode intense attribute */ extern int attrib_gr_intense; /* graphics mode intense attribute */
extern boolean inmap; /* in the map window */ extern boolean inmap; /* in the map window */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
extern glyph_map glyphmap[MAX_GLYPH]; extern glyph_map glyphmap[MAX_GLYPH];
#endif #endif
@@ -162,6 +162,7 @@ static struct map_struct {
int attr; int attr;
unsigned special; unsigned special;
short int tileidx; short int tileidx;
uint32 framecolor;
} map[ROWNO][COLNO]; /* track the glyphs */ } map[ROWNO][COLNO]; /* track the glyphs */
extern int total_tiles_used, Tile_corr, Tile_unexplored; /* from tile.c */ extern int total_tiles_used, Tile_corr, Tile_unexplored; /* from tile.c */
@@ -173,6 +174,7 @@ extern int total_tiles_used, Tile_corr, Tile_unexplored; /* from tile.c */
for (x = 0; x < COLNO; ++x) { \ for (x = 0; x < COLNO; ++x) { \
map[y][x].glyph = GLYPH_UNEXPLORED; \ map[y][x].glyph = GLYPH_UNEXPLORED; \
map[y][x].ch = glyph2ttychar(GLYPH_UNEXPLORED); \ map[y][x].ch = glyph2ttychar(GLYPH_UNEXPLORED); \
map[y][x].framecolor = NO_COLOR; \
map[y][x].attr = 0; \ map[y][x].attr = 0; \
map[y][x].special = 0; \ map[y][x].special = 0; \
map[y][x].tileidx = Tile_unexplored; \ map[y][x].tileidx = Tile_unexplored; \
@@ -361,10 +363,11 @@ void vga_xputc(char ch, int attr)
vga_gotoloc(col, row); vga_gotoloc(col, row);
} }
#if defined(USE_TILES) #if defined(TILES_IN_GLYPHMAP)
/* Place tile represent. a glyph at current location */ /* Place tile represent. a glyph at current location */
void void
vga_xputg(const glyph_info *glyphinfo) vga_xputg(const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo)
{ {
int glyphnum = glyphinfo->glyph; int glyphnum = glyphinfo->glyph;
uint32 ch = glyphinfo->ttychar; uint32 ch = glyphinfo->ttychar;
@@ -399,6 +402,10 @@ vga_xputg(const glyph_info *glyphinfo)
attr = (g_attribute == 0) ? attrib_gr_normal : g_attribute; attr = (g_attribute == 0) ? attrib_gr_normal : g_attribute;
map[ry][col].attr = attr; map[ry][col].attr = attr;
map[ry][col].tileidx = glyphinfo->gm.tileidx; map[ry][col].tileidx = glyphinfo->gm.tileidx;
if (bkglyphinfo->framecolor != NO_COLOR) {
map[ry][col].framecolor = bkglyphinfo->framecolor;
}
if (iflags.traditional_view) { if (iflags.traditional_view) {
vga_WriteChar(ch, col, row, attr); vga_WriteChar(ch, col, row, attr);
} else if (!iflags.over_view) { } else if (!iflags.over_view) {
@@ -416,7 +423,7 @@ vga_xputg(const glyph_info *glyphinfo)
++col; ++col;
vga_gotoloc(col, row); vga_gotoloc(col, row);
} }
#endif /* USE_TILES */ #endif /* TILES_IN_GLYPHMAP */
/* /*
* Cursor location manipulation, and location information fetching * Cursor location manipulation, and location information fetching
@@ -437,7 +444,7 @@ vga_gotoloc(int col, int row)
currow = min(row, LI - 1); currow = min(row, LI - 1);
} }
#if defined(USE_TILES) && defined(CLIPPING) #if defined(TILES_IN_GLYPHMAP) && defined(CLIPPING)
static void static void
vga_cliparound(int x, int y UNUSED) vga_cliparound(int x, int y UNUSED)
{ {
@@ -506,7 +513,7 @@ vga_redrawmap(boolean clearfirst)
} }
} }
} }
#endif /* USE_TILES && CLIPPING */ #endif /* TILES_IN_GLYPHMAP && CLIPPING */
void void
vga_userpan(enum vga_pan_direction pan) vga_userpan(enum vga_pan_direction pan)
@@ -736,7 +743,7 @@ vga_Init(void)
int i; int i;
const char *font_name; const char *font_name;
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
const char *tile_file; const char *tile_file;
int tilefailure = 0; int tilefailure = 0;
/* /*
@@ -776,7 +783,7 @@ vga_Init(void)
windowprocs.win_cliparound = vga_cliparound; windowprocs.win_cliparound = vga_cliparound;
/* vga_NoBorder(BACKGROUND_VGA_COLOR); */ /* Not needed after palette /* vga_NoBorder(BACKGROUND_VGA_COLOR); */ /* Not needed after palette
mod */ mod */
#ifdef USE_TILES #ifdef TILES_IN_GLYPHMAP
paletteptr = get_palette(); paletteptr = get_palette();
iflags.tile_view = TRUE; iflags.tile_view = TRUE;
iflags.over_view = FALSE; iflags.over_view = FALSE;
@@ -930,6 +937,8 @@ vga_detect(void)
return 0; return 0;
} }
extern int curframecolor; /* video.c */
/* /*
* Write character 'ch', at (x,y) and * Write character 'ch', at (x,y) and
* do it using the colour 'colour'. * do it using the colour 'colour'.
@@ -944,16 +953,21 @@ vga_WriteChar(uint32 chr, int col, int row, int colour)
char __far *cp; char __far *cp;
unsigned char fnt; unsigned char fnt;
int actual_colour = vgacmap[colour]; int actual_colour = vgacmap[colour];
int bgcolor;
int vplane; int vplane;
unsigned char bitmap[ROWS_PER_CELL]; unsigned char bitmap[ROWS_PER_CELL];
/* if (chr < ' ') chr = ' '; */ /* assumes ASCII set */ /* if (chr < ' ') chr = ' '; */ /* assumes ASCII set */
vga_GetBitmap(chr, bitmap); vga_GetBitmap(chr, bitmap);
if (curframecolor != NO_COLOR)
bgcolor = vgacmap[curframecolor];
else
bgcolor = BACKGROUND_VGA_COLOR;
x = min(col, (CO - 1)); /* min() used protection from callers */ x = min(col, (CO - 1)); /* min() used protection from callers */
pixy = min(row, (LI - 1)) * 16; /* assumes 8 x 16 char set */ pixy = min(row, (LI - 1)) * 16; /* assumes 8 x 16 char set */
vplane = ~actual_colour & ~bgcolor & 0xF;
vplane = ~actual_colour & ~BACKGROUND_VGA_COLOR & 0xF;
if (vplane != 0) { if (vplane != 0) {
egawriteplane(vplane); egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) { for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
@@ -961,7 +975,7 @@ vga_WriteChar(uint32 chr, int col, int row, int colour)
WRITE_ABSOLUTE(cp, (char) 0x00); WRITE_ABSOLUTE(cp, (char) 0x00);
} }
} }
vplane = actual_colour & ~BACKGROUND_VGA_COLOR & 0xF; vplane = actual_colour & ~bgcolor & 0xF;
if (vplane != 0) { if (vplane != 0) {
egawriteplane(vplane); egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) { for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
@@ -970,7 +984,7 @@ vga_WriteChar(uint32 chr, int col, int row, int colour)
WRITE_ABSOLUTE(cp, (char) fnt); WRITE_ABSOLUTE(cp, (char) fnt);
} }
} }
vplane = ~actual_colour & BACKGROUND_VGA_COLOR & 0xF; vplane = ~actual_colour & bgcolor & 0xF;
if (vplane != 0) { if (vplane != 0) {
egawriteplane(vplane); egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) { for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {
@@ -979,7 +993,7 @@ vga_WriteChar(uint32 chr, int col, int row, int colour)
WRITE_ABSOLUTE(cp, (char) fnt); WRITE_ABSOLUTE(cp, (char) fnt);
} }
} }
vplane = actual_colour & BACKGROUND_VGA_COLOR & 0xF; vplane = actual_colour & bgcolor & 0xF;
if (vplane != 0) { if (vplane != 0) {
egawriteplane(vplane); egawriteplane(vplane);
for (i = 0; i < MAX_ROWS_PER_CELL; ++i) { for (i = 0; i < MAX_ROWS_PER_CELL; ++i) {

View File

@@ -155,7 +155,8 @@ override TARGET_AR = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc-ar
override TARGET_STUBEDIT = ../lib/djgpp/i586-pc-msdosdjgpp/bin/stubedit override TARGET_STUBEDIT = ../lib/djgpp/i586-pc-msdosdjgpp/bin/stubedit
MSDOS_TARGET_CFLAGS = -c -O -I../include -I../sys/msdos -I../win/share \ MSDOS_TARGET_CFLAGS = -c -O -I../include -I../sys/msdos -I../win/share \
$(LUAINCL) -DDLB $(PDCURSESDEF) \ $(LUAINCL) -DDLB $(PDCURSESDEF) \
-DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET -DCROSS_TO_MSDOS \ -DTILES_IN_GLYPHMAP -DCROSSCOMPILE -DCROSSCOMPILE_TARGET \
-DCROSS_TO_MSDOS \
-Wall -Wextra -Wno-missing-field-initializers -Wreturn-type -Wunused \ -Wall -Wextra -Wno-missing-field-initializers -Wreturn-type -Wunused \
-Wformat -Wswitch -Wshadow -Wwrite-strings \ -Wformat -Wswitch -Wshadow -Wwrite-strings \
-Wimplicit -Wimplicit-function-declaration -Wimplicit-int \ -Wimplicit -Wimplicit-function-declaration -Wimplicit-int \

View File

@@ -2003,6 +2003,7 @@ clean:
# * -c (which is included in cflagsBuild) substituted with -Fo$@ # * -c (which is included in cflagsBuild) substituted with -Fo$@
# * "-o $@ " is removed # * "-o $@ " is removed
# * win/X11/Window.o commented due to conflict with pdcurses # * win/X11/Window.o commented due to conflict with pdcurses
# * win/share/cppregex.o commented out due to earlier rule
# * commented out $(TARGETPFX)tile.o: tile.c $(HACK_H) # * commented out $(TARGETPFX)tile.o: tile.c $(HACK_H)
# * commented out $(TARGETPFX)cppregex.o because it has its own rule already # * commented out $(TARGETPFX)cppregex.o because it has its own rule already
# * $(TARGETPFX) becomes $(OTTY) in 1st batch with $(TTYDEF) # * $(TARGETPFX) becomes $(OTTY) in 1st batch with $(TTYDEF)

View File

@@ -86,6 +86,7 @@ typedef struct {
WORD attr; WORD attr;
long color24; long color24;
int color256idx; int color256idx;
const char *bkcolorseq;
const char *colorseq; const char *colorseq;
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
} cell_t; } cell_t;
@@ -170,6 +171,7 @@ struct console_t {
WORD foreground; WORD foreground;
WORD attr; WORD attr;
int current_nhcolor; int current_nhcolor;
int current_nhbkcolor;
int current_nhattr[ATR_INVERSE+1]; int current_nhattr[ATR_INVERSE+1];
COORD cursor; COORD cursor;
HANDLE hConOut; HANDLE hConOut;
@@ -210,6 +212,7 @@ struct console_t {
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */ (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED), /* foreground */
0, /* attr */ 0, /* attr */
0, /* current_nhcolor */ 0, /* current_nhcolor */
0, /* current_nhbkcolor */
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}, {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
#ifndef VIRTUAL_TERMINAL_SEQUENCES #ifndef VIRTUAL_TERMINAL_SEQUENCES
@@ -313,6 +316,7 @@ static INPUT_RECORD bogus_key;
#ifdef VIRTUAL_TERMINAL_SEQUENCES #ifdef VIRTUAL_TERMINAL_SEQUENCES
long customcolors[CLR_MAX]; long customcolors[CLR_MAX];
const char *esc_seq_colors[CLR_MAX]; const char *esc_seq_colors[CLR_MAX];
const char *esc_seq_bkcolors[CLR_MAX];
struct rgbvalues { struct rgbvalues {
int idx; int idx;
@@ -471,6 +475,8 @@ rgbtable_to_long(struct rgbvalues *tbl)
static void static void
init_custom_colors(void) init_custom_colors(void)
{ {
char bkcolorbuf[32];
customcolors[CLR_BLACK] = rgbtable_to_long(&rgbtable[131]); customcolors[CLR_BLACK] = rgbtable_to_long(&rgbtable[131]);
customcolors[CLR_RED] = rgbtable_to_long(&rgbtable[5]); customcolors[CLR_RED] = rgbtable_to_long(&rgbtable[5]);
customcolors[CLR_GREEN] = rgbtable_to_long(&rgbtable[31]); customcolors[CLR_GREEN] = rgbtable_to_long(&rgbtable[31]);
@@ -507,6 +513,40 @@ init_custom_colors(void)
esc_seq_colors[CLR_BRIGHT_BLUE] = "\x1b[34m\x1b[94m"; esc_seq_colors[CLR_BRIGHT_BLUE] = "\x1b[34m\x1b[94m";
esc_seq_colors[CLR_BRIGHT_MAGENTA] = "\x1b[35m\x1b[95m"; esc_seq_colors[CLR_BRIGHT_MAGENTA] = "\x1b[35m\x1b[95m";
esc_seq_colors[CLR_BRIGHT_CYAN] = "\x1b[36m\x1b[96m"; esc_seq_colors[CLR_BRIGHT_CYAN] = "\x1b[36m\x1b[96m";
/* Sprintf(tmp, "\033[%dm", ((color % 8) + 40)); */
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BLACK % 8) + 40));
esc_seq_bkcolors[CLR_BLACK] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_RED % 8) + 40));
esc_seq_bkcolors[CLR_RED] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_GREEN % 8) + 40));
esc_seq_bkcolors[CLR_GREEN] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_YELLOW % 8) + 40));
esc_seq_bkcolors[CLR_YELLOW] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BLUE % 8) + 40));
esc_seq_bkcolors[CLR_BLUE] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_MAGENTA % 8) + 40));
esc_seq_bkcolors[CLR_MAGENTA] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_CYAN % 8) + 40));
esc_seq_bkcolors[CLR_CYAN] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_WHITE % 8) + 40));
esc_seq_bkcolors[CLR_WHITE] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BROWN % 8) + 40));
esc_seq_bkcolors[CLR_BROWN] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_GRAY % 8) + 40));
esc_seq_bkcolors[CLR_GRAY] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((NO_COLOR % 8) + 40));
esc_seq_bkcolors[NO_COLOR] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_ORANGE % 8) + 40));
esc_seq_bkcolors[CLR_ORANGE] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BRIGHT_BLUE % 8) + 40));
esc_seq_bkcolors[CLR_BRIGHT_BLUE] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BRIGHT_GREEN % 8) + 40));
esc_seq_bkcolors[CLR_BRIGHT_GREEN] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BRIGHT_MAGENTA % 8) + 40));
esc_seq_bkcolors[CLR_BRIGHT_MAGENTA] = dupstr(bkcolorbuf);
Snprintf(bkcolorbuf, sizeof bkcolorbuf, "\x1b[%dm", ((CLR_BRIGHT_CYAN % 8) + 40));
esc_seq_bkcolors[CLR_BRIGHT_CYAN] = dupstr(bkcolorbuf);
} }
void emit_start_bold(void); void emit_start_bold(void);
@@ -715,18 +755,20 @@ DWORD error_result;
/* Console buffer flipping support */ /* Console buffer flipping support */
#ifdef VIRTUAL_TERMINAL_SEQUENCES #ifdef VIRTUAL_TERMINAL_SEQUENCES
enum do_flags { enum do_flags {
do_utf8_content = 1, do_utf8_content = 0x01,
do_wide_content = 2, do_wide_content = 0x02,
do_colorseq = 4, do_colorseq = 0x04,
do_color24 = 8, do_color24 = 0x08,
do_newattr = 16 do_newattr = 0x10,
do_bkcolorseq = 0x20,
}; };
enum did_flags { enum did_flags {
did_utf8_content = 1, did_utf8_content = 0x01,
did_wide_content = 2, did_wide_content = 0x02,
did_colorseq = 4, did_colorseq = 0x04,
did_color24 = 8, did_color24 = 0x08,
did_newattr = 16 did_newattr = 0x10,
did_bkcolorseq = 0x20,
}; };
static void static void
@@ -753,6 +795,8 @@ back_buffer_flip(void)
do_anything |= do_colorseq; do_anything |= do_colorseq;
if (back->attr != front->attr) if (back->attr != front->attr)
do_anything |= do_newattr; do_anything |= do_newattr;
if (back->bkcolorseq != front->bkcolorseq)
do_anything |= do_bkcolorseq;
#ifdef UTF8_FROM_CORE #ifdef UTF8_FROM_CORE
if (!SYMHANDLING(H_UTF8)) { if (!SYMHANDLING(H_UTF8)) {
if (console.has_unicode if (console.has_unicode
@@ -800,7 +844,15 @@ back_buffer_flip(void)
WriteConsoleA(console.hConOut, back->colorseq, WriteConsoleA(console.hConOut, back->colorseq,
(int) strlen(back->colorseq), &unused, (int) strlen(back->colorseq), &unused,
&reserved); &reserved);
} else { }
if (back->bkcolorseq) {
did_anything |= did_bkcolorseq;
WriteConsoleA(console.hConOut, back->bkcolorseq,
(int) strlen(back->bkcolorseq), &unused,
&reserved);
}
if ((did_anything | (did_colorseq | did_bkcolorseq | did_color24)) == 0) {
did_anything &= ~(did_bkcolorseq | did_color24);
did_anything |= did_colorseq; did_anything |= did_colorseq;
emit_default_color(); emit_default_color();
} }
@@ -1276,6 +1328,7 @@ xputc_core(int ch)
/* this causes way too much performance degradation */ /* this causes way too much performance degradation */
/* cell.color24 = customcolors[console.current_nhcolor]; */ /* cell.color24 = customcolors[console.current_nhcolor]; */
cell.colorseq = esc_seq_colors[console.current_nhcolor]; cell.colorseq = esc_seq_colors[console.current_nhcolor];
cell.bkcolorseq = esc_seq_bkcolors[console.current_nhbkcolor];
cell.attr = console.attr; cell.attr = console.attr;
// if (console.color24) // if (console.color24)
// __debugbreak(); // __debugbreak();
@@ -1370,6 +1423,7 @@ g_putch(int in_ch)
#else #else
cell.attr = console.attr; cell.attr = console.attr;
cell.colorseq = esc_seq_colors[console.current_nhcolor]; cell.colorseq = esc_seq_colors[console.current_nhcolor];
cell.bkcolorseq = esc_seq_bkcolors[console.current_nhbkcolor];
cell.color24 = console.color24 ? console.color24 : 0L; cell.color24 = console.color24 ? console.color24 : 0L;
cell.color256idx = 0; cell.color256idx = 0;
wch[1] = 0; wch[1] = 0;
@@ -1416,6 +1470,7 @@ g_pututf8(uint8 *sequence)
cell_t cell; cell_t cell;
cell.attr = console.attr; cell.attr = console.attr;
cell.colorseq = esc_seq_colors[console.current_nhcolor]; cell.colorseq = esc_seq_colors[console.current_nhcolor];
cell.bkcolorseq = esc_seq_bkcolors[console.current_nhbkcolor];
cell.color24 = console.color24 ? console.color24 : 0L; cell.color24 = console.color24 ? console.color24 : 0L;
cell.color256idx =console.color256idx ? console.color256idx : 0; cell.color256idx =console.color256idx ? console.color256idx : 0;
Snprintf((char *) cell.utf8str, sizeof cell.utf8str, "%s", Snprintf((char *) cell.utf8str, sizeof cell.utf8str, "%s",
@@ -1718,6 +1773,17 @@ term_start_color(int color)
console.current_nhcolor = NO_COLOR; console.current_nhcolor = NO_COLOR;
} }
void
term_start_bgcolor(int color)
{
#ifdef TEXTCOLOR
if (color >= 0 && color < CLR_MAX) {
console.current_nhbkcolor = color;
} else
#endif
console.current_nhbkcolor = NO_COLOR;
}
void void
term_end_color(void) term_end_color(void)
{ {
@@ -1728,6 +1794,7 @@ term_end_color(void)
console.attr = (console.foreground | console.background); console.attr = (console.foreground | console.background);
#endif /* ! VIRTUAL_TERMINAL_SEQUENCES */ #endif /* ! VIRTUAL_TERMINAL_SEQUENCES */
console.current_nhcolor = NO_COLOR; console.current_nhcolor = NO_COLOR;
console.current_nhbkcolor = NO_COLOR;
} }
void void
@@ -1849,7 +1916,7 @@ tty_utf8graphics_fixup(void)
/* the locale */ /* the locale */
if (console.localestr) if (console.localestr)
free(console.localestr); free(console.localestr);
console.localestr = strdup(setlocale(LC_ALL, ".UTF8")); console.localestr = dupstr(setlocale(LC_ALL, ".UTF8"));
/* the code page */ /* the code page */
SetConsoleOutputCP(65001); SetConsoleOutputCP(65001);
console.code_page = GetConsoleOutputCP(); console.code_page = GetConsoleOutputCP();
@@ -1917,7 +1984,7 @@ tty_ibmgraphics_fixup(void)
if (localestr) { if (localestr) {
if (console.localestr) if (console.localestr)
free(console.localestr); free(console.localestr);
console.localestr = strdup(localestr); console.localestr = dupstr(localestr);
} }
set_known_good_console_font(); set_known_good_console_font();
/* the console mode */ /* the console mode */
@@ -2201,7 +2268,7 @@ restore_original_console_font(void)
if (tmplocalestr) { if (tmplocalestr) {
if (console.localestr) if (console.localestr)
free(console.localestr); free(console.localestr);
console.localestr = strdup(tmplocalestr); console.localestr = dupstr(tmplocalestr);
} }
success = SetConsoleOutputCP(console.orig_code_page); success = SetConsoleOutputCP(console.orig_code_page);
#endif /* VIRTUAL_TERMINAL_SEQUENCES */ #endif /* VIRTUAL_TERMINAL_SEQUENCES */
@@ -2455,7 +2522,7 @@ void nethack_enter_consoletty(void)
if (localestr) { if (localestr) {
if (console.localestr) if (console.localestr)
free(console.localestr); free(console.localestr);
console.localestr = strdup(localestr); console.localestr = dupstr(localestr);
} }
console.code_page = console.orig_code_page; console.code_page = console.orig_code_page;
if (console.has_unicode) { if (console.has_unicode) {

View File

@@ -200,10 +200,10 @@ static struct grep_var grep_vars[] = { { "0", 0 },
#else #else
{ "USER_SOUNDS", 0 }, { "USER_SOUNDS", 0 },
#endif #endif
#if defined(USE_TILES) #if defined(TILES_IN_GLYPHMAP)
{ "USE_TILES", 1 }, { "TILES_IN_GLYPHMAP", 1 },
#else #else
{ "USE_TILES", 0 }, { "TILES_IN_GLYPHMAP", 0 },
#endif #endif
#if defined(VAR_PLAYGROUND) #if defined(VAR_PLAYGROUND)
{ "VAR_PLAYGROUND", 1 }, { "VAR_PLAYGROUND", 1 },

View File

@@ -17,7 +17,7 @@
QT_GRAPHICS GNOME_GRAPHICS GEM_GRAPHICS/; QT_GRAPHICS GNOME_GRAPHICS GEM_GRAPHICS/;
# Game Features: # Game Features:
@feature = qw/ZEROCOMP USE_TILES ASCIIGRAPH CLIPPING TEXTCOLOR @feature = qw/ZEROCOMP TILES_IN_GLYPHMAP ASCIIGRAPH CLIPPING TEXTCOLOR
COMPRESS ZLIB_COMP RANDOM SECURE USER_SOUNDS COMPRESS ZLIB_COMP RANDOM SECURE USER_SOUNDS
SAFERHANGUP MFLOPPY NOCWD_ASSUMPTIONS SAFERHANGUP MFLOPPY NOCWD_ASSUMPTIONS
VAR_PLAYGROUND DLB SHELL SUSPEND NOSAVEONHANGUP HANGUPHANDLING VAR_PLAYGROUND DLB SHELL SUSPEND NOSAVEONHANGUP HANGUPHANDLING

View File

@@ -1438,6 +1438,14 @@ term_start_color(int color)
if (color < CLR_MAX && hilites[color] && *hilites[color]) if (color < CLR_MAX && hilites[color] && *hilites[color])
xputs(hilites[color]); xputs(hilites[color]);
} }
void
term_start_bgcolor(int color)
{
char tmp[8];
Sprintf(tmp, "\033[%dm", ((color % 8) + 40));
xputs(tmp);
}
#endif /* TEXTCOLOR */ #endif /* TEXTCOLOR */
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS

View File

@@ -185,7 +185,7 @@ static char winpanicstr[] = "Bad window id %d";
char defmorestr[] = "--More--"; char defmorestr[] = "--More--";
#ifdef CLIPPING #ifdef CLIPPING
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
boolean clipping = FALSE; /* clipping on? */ boolean clipping = FALSE; /* clipping on? */
int clipx = 0, clipxmax = 0; int clipx = 0, clipxmax = 0;
int clipy = 0, clipymax = 0; int clipy = 0, clipymax = 0;
@@ -196,7 +196,7 @@ static int clipy = 0, clipymax = 0;
#endif #endif
#endif /* CLIPPING */ #endif /* CLIPPING */
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
extern void adjust_cursor_flags(struct WinDesc *); extern void adjust_cursor_flags(struct WinDesc *);
#endif #endif
@@ -835,7 +835,7 @@ tty_create_nhwindow(int type)
iflags.wc2_statuslines = 2; iflags.wc2_statuslines = 2;
newwin->offx = 0; newwin->offx = 0;
rowoffset = ttyDisplay->rows - iflags.wc2_statuslines; rowoffset = ttyDisplay->rows - iflags.wc2_statuslines;
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
if (iflags.grmode) { if (iflags.grmode) {
newwin->offy = rowoffset; newwin->offy = rowoffset;
} else } else
@@ -1946,7 +1946,7 @@ tty_curs(winid window,
print_vt_code2(AVTC_SELECT_WINDOW, window); print_vt_code2(AVTC_SELECT_WINDOW, window);
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
adjust_cursor_flags(cw); adjust_cursor_flags(cw);
#endif #endif
cw->curx = --x; /* column 0 is never used */ cw->curx = --x; /* column 0 is never used */
@@ -3291,7 +3291,7 @@ docorner(register int xmin, register int ymax, int ystart_between_menu_pages)
#ifdef CLIPPING #ifdef CLIPPING
if (y < (int) cw->offy || y + clipy > ROWNO) if (y < (int) cw->offy || y + clipy > ROWNO)
continue; /* only refresh board */ continue; /* only refresh board */
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
if (iflags.tile_view) if (iflags.tile_view)
row_refresh((xmin / 2) + clipx - ((int) cw->offx / 2), COLNO - 1, row_refresh((xmin / 2) + clipx - ((int) cw->offx / 2), COLNO - 1,
y + clipy - (int) cw->offy); y + clipy - (int) cw->offy);
@@ -3441,7 +3441,7 @@ tty_print_glyph(
winid window, winid window,
coordxy x, coordxy y, coordxy x, coordxy y,
const glyph_info *glyphinfo, const glyph_info *glyphinfo,
const glyph_info *bkglyphinfo UNUSED) const glyph_info *bkglyphinfo)
{ {
boolean inverse_on = FALSE, colordone = FALSE, glyphdone = FALSE; boolean inverse_on = FALSE, colordone = FALSE, glyphdone = FALSE;
int ch, color; int ch, color;
@@ -3508,7 +3508,13 @@ tty_print_glyph(
BW_LAVA and BW_ICE won't ever be set when color is on; BW_LAVA and BW_ICE won't ever be set when color is on;
(tried bold for ice but it didn't look very good; inverse is easier (tried bold for ice but it didn't look very good; inverse is easier
to see although the Valkyrie quest ends up being hard on the eyes) */ to see although the Valkyrie quest ends up being hard on the eyes) */
if (((special & MG_PET) != 0 && iflags.hilite_pet) if (iflags.use_color
&& bkglyphinfo && bkglyphinfo->framecolor != NO_COLOR) {
#ifdef TEXTCOLOR
ttyDisplay->framecolor = bkglyphinfo->framecolor;
term_start_bgcolor(bkglyphinfo->framecolor);
#endif
} else if (((special & MG_PET) != 0 && iflags.hilite_pet)
|| ((special & MG_OBJPILE) != 0 && iflags.hilite_pile) || ((special & MG_OBJPILE) != 0 && iflags.hilite_pile)
|| ((special & MG_FEMALE) != 0 && wizard && iflags.wizmgender) || ((special & MG_FEMALE) != 0 && wizard && iflags.wizmgender)
|| ((special & (MG_DETECT | MG_BW_LAVA | MG_BW_ICE | MG_BW_SINK)) != 0 || ((special & (MG_DETECT | MG_BW_LAVA | MG_BW_ICE | MG_BW_SINK)) != 0
@@ -3517,9 +3523,9 @@ tty_print_glyph(
inverse_on = TRUE; inverse_on = TRUE;
} }
#if defined(USE_TILES) && defined(MSDOS) #if defined(TILES_IN_GLYPHMAP) && defined(MSDOS)
if (iflags.grmode && iflags.tile_view) { if (iflags.grmode && iflags.tile_view) {
xputg(glyphinfo); xputg(glyphinfo, bkglyphinfo);
glyphdone = TRUE; glyphdone = TRUE;
} }
#endif #endif
@@ -3542,9 +3548,9 @@ tty_print_glyph(
/* turn off color as well, turning off ATR_INVERSE may have done /* turn off color as well, turning off ATR_INVERSE may have done
this already and if so, we won't know the current state unless this already and if so, we won't know the current state unless
we do it explicitly */ we do it explicitly */
if (ttyDisplay->color != NO_COLOR) { if (ttyDisplay->color != NO_COLOR || ttyDisplay->framecolor != NO_COLOR) {
term_end_color(); term_end_color();
ttyDisplay->color = NO_COLOR; ttyDisplay->color = ttyDisplay->framecolor = NO_COLOR;
} }
#endif #endif
#ifdef ENHANCED_SYMBOLS #ifdef ENHANCED_SYMBOLS
@@ -3558,6 +3564,16 @@ tty_print_glyph(
ttyDisplay->curx++; /* the real cursor moved too */ ttyDisplay->curx++; /* the real cursor moved too */
} }
#ifdef NO_TERMS /* termcap.o isn't linked in */
#if !defined(MSDOS) && !defined(WIN32)
void
term_start_bgcolor(int color)
{
/* placeholder for now */
}
#endif /* !MSDOS && !WIN32 */
#endif /* NO_TERMS */
void void
tty_raw_print(const char *str) tty_raw_print(const char *str)
{ {