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.
96 lines
1.9 KiB
C
96 lines
1.9 KiB
C
/* NetHack 5.0 pctty.c $NHDT-Date: 1596498284 2020/08/03 23:44:44 $ $NHDT-Branch: NetHack-5.0 $:$NHDT-Revision: 1.13 $ */
|
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/*-Copyright (c) Michael Allison, 2005. */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/* tty.c - (PC) version */
|
|
|
|
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers \
|
|
*/
|
|
#include "hack.h"
|
|
#include "wintty.h"
|
|
|
|
char erase_char, kill_char;
|
|
|
|
/*
|
|
* Get initial state of terminal, set ospeed (for termcap routines)
|
|
* and switch off tab expansion if necessary.
|
|
* Called by startup() in termcap.c and after returning from ! or ^Z
|
|
*/
|
|
void
|
|
gettty(void)
|
|
{
|
|
erase_char = '\b';
|
|
kill_char = 21; /* cntl-U */
|
|
iflags.cbreak = TRUE;
|
|
#if !defined(TOS)
|
|
disable_ctrlP(); /* turn off ^P processing */
|
|
#endif
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
gr_init();
|
|
#endif
|
|
}
|
|
|
|
/* reset terminal to original state */
|
|
void
|
|
settty(const char *s)
|
|
{
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
gr_finish();
|
|
#endif
|
|
term_end_screen();
|
|
if (s)
|
|
raw_print(s);
|
|
#if !defined(TOS)
|
|
enable_ctrlP(); /* turn on ^P processing */
|
|
#endif
|
|
}
|
|
|
|
/* called by init_nhwindows() and resume_nhwindows() */
|
|
void
|
|
setftty(void)
|
|
{
|
|
term_start_screen();
|
|
}
|
|
|
|
#ifdef ENHANCED_SYMBOLS
|
|
void
|
|
tty_utf8graphics_fixup(void)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#if defined(TIMED_DELAY) && defined(_MSC_VER)
|
|
void
|
|
msleep(unsigned mseconds)
|
|
{
|
|
/* now uses clock() which is ANSI C */
|
|
clock_t goal;
|
|
|
|
goal = mseconds + clock();
|
|
while (goal > clock()) {
|
|
/* do nothing */
|
|
}
|
|
}
|
|
#endif
|
|
|
|
/* fatal error */
|
|
/*VARARGS1*/
|
|
|
|
void error
|
|
VA_DECL(const char *, s)
|
|
{
|
|
VA_START(s);
|
|
VA_INIT(s, const char *);
|
|
/* error() may get called before tty is initialized */
|
|
if (iflags.window_inited)
|
|
term_end_screen();
|
|
putchar('\n');
|
|
Vprintf(s, VA_ARGS);
|
|
putchar('\n');
|
|
VA_END();
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
/*pctty.c*/
|