fix github issue 361 to make user_sounds useful even if MSGTYPE is hidden

fixes #361

Also, experminental introduction of vt_sounddata to enable tty to pass
a sound file index to the terminal side of things where perhaps someone
can add code to something like hterm to take the information relayed by
NetHack to trigger user_sounds locally even if playing on a server.

Compile time option TTY_SOUND_ESCCODES required to build that support in.

It should be independent of TTY_TILE_ESCCODES.
This commit is contained in:
nhmall
2020-07-02 15:49:45 -04:00
parent 3a94f0a9f8
commit e4b18f0545
13 changed files with 151 additions and 32 deletions

View File

@@ -474,7 +474,10 @@ typedef unsigned char uchar;
*/
/* TTY_TILES_ESCCODES: Enable output of special console escape codes
* which act as hints for external programs such as EbonHack.
* which act as hints for external programs such as EbonHack, or hterm.
*
* TTY_SOUND_ESCCODES: Enable output of special console escape codes
* which act as hints for theoretical external programs to play sound effect.
*
* Only for TTY_GRAPHICS.
*
@@ -482,12 +485,14 @@ typedef unsigned char uchar;
* one or more positive integer values, separated by semicolons.
* For example ESC [ 1 ; 0 ; 120 z
*
* Possible codes are:
* Possible TTY_TILES_ESCCODES codes are:
* ESC [ 1 ; 0 ; n ; m z Start a glyph (aka a tile) number n, with flags m
* ESC [ 1 ; 1 z End a glyph.
* ESC [ 1 ; 2 ; n z Select a window n to output to.
* ESC [ 1 ; 3 z End of data. NetHack has finished sending data,
* and is waiting for input.
* Possible TTY_SOUND_ESCCODES codes are:
* ESC [ 1 ; 4 ; n ; m z Play specified sound n, volume m
*
* Whenever NetHack outputs anything, it will first output the "select window"
* code. Whenever NetHack outputs a tile, it will first output the "start
@@ -496,9 +501,10 @@ typedef unsigned char uchar;
*
* To compile NetHack with this, add tile.c to WINSRC and tile.o to WINOBJ
* in the hints file or Makefile.
* Set boolean option vt_tiledata in your config file to turn this on.
* Set boolean option vt_xdata in your config file to turn either of these on.
* Note that gnome-terminal at least doesn't work with this. */
/* #define TTY_TILES_ESCCODES */
/* #define TTY_SOUND_ESCCODES */
/* NetHack will execute an external program whenever a new message-window
* message is shown. The program to execute is given in environment variable

View File

@@ -326,6 +326,9 @@ struct instance_flags {
#endif
#ifdef TTY_TILES_ESCCODES
boolean vt_tiledata; /* output console codes for tile support in TTY */
#endif
#ifdef TTY_SOUND_ESCCODES
boolean vt_sounddata; /* output console codes for sound support in TTY*/
#endif
boolean clicklook; /* allow right-clicking for look */
boolean cmdassist; /* provide detailed assistance for some comnds */

View File

@@ -29,6 +29,7 @@
#define DUMPLOG_MSG_COUNT 50
#define USER_SOUNDS
#define TTY_SOUND_ESCCODES
/*#define CHANGE_COLOR*/ /* allow palette changes */
#define SELECTSAVED /* Provide menu of saved games to choose from at start */

View File

@@ -516,6 +516,13 @@ pfx_##a,
#else
NHOPTB(vt_tiledata, 0, opt_in, set_in_config, Off, Yes, No, No, NoAlias,
(boolean *) 0)
#endif
#ifdef TTY_SOUND_ESCCODES
NHOPTB(vt_sounddata, 0, opt_in, set_in_config, Off, Yes, No, No, NoAlias,
&iflags.vt_sounddata)
#else
NHOPTB(vt_sounddata, 0, opt_in, set_in_config, Off, Yes, No, No, NoAlias,
(boolean *) 0)
#endif
NHOPTC(warnings, 10, opt_in, set_in_config, No, Yes, No, No, NoAlias,
"display characters for warnings")