diff -rU2 nethack-3.4.3-setup/include/config.h nethack-3.4.3-tiles/include/config.h --- nethack-3.4.3-setup/include/config.h 2009-12-23 14:09:22.000000000 +0000 +++ nethack-3.4.3-tiles/include/config.h 2009-12-24 12:29:12.000000000 +0000 @@ -49,4 +49,6 @@ /* #define MSWIN_GRAPHICS */ /* Windows NT, CE, Graphics */ +#define VTILES /* TTY-based tiles */ + /* * Define the default window system. This should be one that is compiled @@ -83,4 +85,10 @@ #endif +#ifdef TTY_GRAPHICS +# ifdef VTILES +# define DEFAULT_WC_TILED_MAP +# endif +#endif + #ifdef QT_GRAPHICS # define DEFAULT_WC_TILED_MAP /* Default to tiles if users doesn't say wc_ascii_map */ diff -rU2 nethack-3.4.3-setup/include/global.h nethack-3.4.3-tiles/include/global.h --- nethack-3.4.3-setup/include/global.h 2009-12-23 14:09:22.000000000 +0000 +++ nethack-3.4.3-tiles/include/global.h 2009-12-24 00:00:32.000000000 +0000 @@ -258,5 +258,5 @@ #endif -#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS) +#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS) || defined(VTILES) # ifndef USE_TILES # define USE_TILES /* glyph2tile[] will be available */ diff -rU2 nethack-3.4.3-setup/sys/unix/Makefile.src nethack-3.4.3-tiles/sys/unix/Makefile.src --- nethack-3.4.3-setup/sys/unix/Makefile.src 2009-12-23 14:09:22.000000000 +0000 +++ nethack-3.4.3-tiles/sys/unix/Makefile.src 2009-12-24 17:12:41.000000000 +0000 @@ -44,6 +44,6 @@ # for UNIX systems SYSSRC = ../sys/share/ioctl.c ../sys/share/unixtty.c ../sys/unix/unixmain.c \ - ../sys/unix/unixunix.c ../sys/unix/unixres.c -SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o unixres.o + ../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/unix/vtiles.c +SYSOBJ = ioctl.o unixmain.o unixtty.o unixunix.o unixres.o vtiles.o # # for Systos @@ -172,6 +172,6 @@ # files for a straight tty port using no native windowing system WINTTYSRC = ../win/tty/getline.c ../win/tty/termcap.c ../win/tty/topl.c \ - ../win/tty/wintty.c -WINTTYOBJ = getline.o termcap.o topl.o wintty.o + ../win/tty/wintty.c tile.c +WINTTYOBJ = getline.o termcap.o topl.o wintty.o tile.o # # files for an X11 port @@ -229,8 +229,8 @@ # libraries for tty ports # WINTTYLIB = -ltermcap -# WINTTYLIB = -lcurses +WINTTYLIB = -lncurses # WINTTYLIB = -lcurses16 # WINTTYLIB = -lncurses -WINTTYLIB = -ltermlib +# WINTTYLIB = -ltermlib # # libraries for X11 @@ -333,5 +333,6 @@ ../sys/share/pctty.c ../sys/share/pcunix.c ../sys/share/random.c \ ../sys/share/ioctl.c ../sys/share/unixtty.c ../sys/unix/unixmain.c \ - ../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/be/bemain.c + ../sys/unix/unixunix.c ../sys/unix/unixres.c ../sys/be/bemain.c \ + ../sys/unix/vtiles.c # generated source files (tile.c is handled separately via WINxxxSRC) @@ -595,4 +596,6 @@ unixres.o: ../sys/unix/unixres.c $(CONFIG_H) $(CC) $(CFLAGS) -c ../sys/unix/unixres.c +vtiles.o: ../sys/unix/vtiles.c $(HACK_H) $(CONFIG_H) + $(CC) $(CFLAGS) -c ../sys/unix/vtiles.c bemain.o: ../sys/be/bemain.c $(HACK_H) ../include/dlb.h $(CC) $(CFLAGS) -c ../sys/be/bemain.c diff -rU2 nethack-3.4.3-setup/sys/unix/vtiles.c nethack-3.4.3-tiles/sys/unix/vtiles.c --- nethack-3.4.3-setup/sys/unix/vtiles.c 2009-12-25 00:27:26.000000000 +0000 +++ nethack-3.4.3-tiles/sys/unix/vtiles.c 2009-12-24 18:36:01.000000000 +0000 @@ -0,0 +1,95 @@ +/* Copyright (c) Jack Whitham, 2009 */ + +#include "hack.h" +#include "dlb.h" +#include "config.h" + +#ifdef SHORT_FILENAMES +#include "patchlev.h" +#else +#include "patchlevel.h" +#endif + +#include +#include +#include + +#if defined(USE_TILES) && defined(VTILES) && defined(TTY_GRAPHICS) + + +extern short glyph2tile[]; + + +int +vtiles_enabled() +{ + const char * t; + static int result = 0; + + if (result == 0) { + result = -1; + t = getenv("TERM"); + if ((t != NULL) + && (strcmp(t, "tilehack") == 0)) { + result = 1; + } + } + + return (result == 1); +} + +void +vtiles_move(window) +winid window; +{ + int hp100, danger = 9; + static int old_danger; + + if (!vtiles_enabled()) return; + + if ((window == WIN_MAP) && !( +#ifdef REINCARNATION + Is_rogue_level(&u.uz) || +#endif + iflags.wc_ascii_map)) { + /* When the cursor is in the map window, its colour is + * set by the player's health, like in the Qt version: + * unless we're using an ASCII map, in which case you get a + * black cursor which is easy to see. */ + if (u.mtimedone) { + hp100=u.mhmax ? u.mh*100/u.mhmax : 100; + } else { + hp100=u.uhpmax ? u.uhp*100/u.uhpmax : 100; + } + if (hp100 > 75) danger = 4; + else if (hp100 > 50) danger = 3; + else if (hp100 > 25) danger = 2; + else if (hp100 > 10) danger = 1; + else if (hp100 > 0) danger = 0; + } + if (danger != old_danger) { + printf("\e[%dy", danger); + old_danger = danger; + } +} + +void +vtiles_put_glyph(glyph, special) + int glyph; + int special; +{ + int i, n = glyph2tile[glyph]; + int flag = ((special & MG_PET) ? 1 : 0); + + putchar(flag | 0x1c); + for (i = 0; i < 2; i++) { + int out = ((n >> ((1 - i) * 6)) & 0x3f); + if (out < 0x30) { + out |= 0x40; + } + putchar(out); + } +} +#endif + + Binary files nethack-3.4.3-setup/util/dgn_comp and nethack-3.4.3-tiles/util/dgn_comp differ Binary files nethack-3.4.3-setup/util/dlb and nethack-3.4.3-tiles/util/dlb differ Binary files nethack-3.4.3-setup/util/lev_comp and nethack-3.4.3-tiles/util/lev_comp differ Binary files nethack-3.4.3-setup/util/makedefs and nethack-3.4.3-tiles/util/makedefs differ Binary files nethack-3.4.3-setup/util/makedefs.o and nethack-3.4.3-tiles/util/makedefs.o differ diff -rU2 nethack-3.4.3-setup/win/tty/wintty.c nethack-3.4.3-tiles/win/tty/wintty.c --- nethack-3.4.3-setup/win/tty/wintty.c 2009-12-23 14:09:22.000000000 +0000 +++ nethack-3.4.3-tiles/win/tty/wintty.c 2009-12-24 18:36:13.000000000 +0000 @@ -3,4 +3,5 @@ /* NetHack may be freely redistributed. See license for details. */ + /* * Neither a standard out nor character-based control codes should be @@ -47,4 +48,7 @@ WC_TILED_MAP|WC_ASCII_MAP| #endif +#ifdef VTILES + WC_TILED_MAP|WC_ASCII_MAP| +#endif #if defined(WIN32CON) WC_MOUSE_SUPPORT| @@ -168,4 +172,9 @@ STATIC_DCL void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */ +#if defined(USE_TILES) && defined(VTILES) +extern void vtiles_move(winid); +extern int vtiles_enabled(); +extern void vtiles_put_glyph(int, int); +#endif /* * A string containing all the default commands -- to add to a list @@ -187,4 +196,5 @@ + /* clean up and quit */ STATIC_OVL void @@ -297,4 +307,7 @@ ttyDisplay->lastwin = WIN_ERR; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(WIN_ERR); +#endif #if defined(SIGWINCH) && defined(CLIPPING) @@ -778,4 +791,7 @@ winid i; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(WIN_ERR); +#endif tty_suspend_nhwindows(str); /* Just forget any windows existed, since we're about to exit anyway. @@ -976,4 +992,7 @@ panic(winpanicstr, window); ttyDisplay->lastwin = window; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(window); +#endif switch(cw->type) { @@ -1499,4 +1518,7 @@ ttyDisplay->lastwin = window; ttyDisplay->rawprint = 0; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(window); +#endif switch(cw->type) { @@ -1618,4 +1640,5 @@ } + void tty_curs(window, x, y) @@ -1631,6 +1654,9 @@ panic(winpanicstr, window); ttyDisplay->lastwin = window; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(window); +#endif -#if defined(USE_TILES) && defined(MSDOS) +#if defined(USE_TILES) && defined(MSDOS) adjust_cursor_flags(cw); #endif @@ -1772,4 +1798,7 @@ ttyDisplay->lastwin = window; +#if defined(USE_TILES) && defined(VTILES) + vtiles_move(window); +#endif switch(cw->type) { @@ -2436,4 +2465,19 @@ #endif +#if defined(USE_TILES) && defined(VTILES) + if (!( +#ifdef REINCARNATION + Is_rogue_level(&u.uz) || +#endif + iflags.wc_ascii_map) && vtiles_enabled()) { + /* VTILES compiled in, vtiles enabled, + * and not Rogue Level */ + vtiles_put_glyph(glyph, special); + goto done; + } else { + /* Fall through to normal rendering */ + } +#endif /* VTILES */ + #ifdef TEXTCOLOR if (color != ttyDisplay->color) { @@ -2458,5 +2502,5 @@ else #endif - g_putch(ch); /* print the character */ + g_putch(ch); /* print the character */ if (reverse_on) { @@ -2471,4 +2515,5 @@ } +done: wins[window]->curx++; /* one character over */ ttyDisplay->curx++; /* the real cursor moved too */