some tty updates
Add a note about NO_TERMS to include/wintty.h for clarity. Rename tty_startup and tty_shutdown to term_startup() and term_shutdown(). They are found in termcap.c for !NO_TERMS like most of the other term_ routines, as well as having versions for several of the NO_TERMS platforms. They aren't part of the tty_interface called from the core. The tty implementation does call and rely on them. Remove some conditional #ifdef's around term_shutdown() (formerly tty_shutdown()) and just ensure that all the tty platforms have an implementation that they can link with, even if it is just a stub presently. Put the protype for nethack_exit in extern.h to reduce maintenance to a single spot, and remove it from other locations. A warning in the msdos cross-compile led to this change.
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#endif
|
||||
|
||||
#define GETCURPOS 0x03 /* Get Cursor Position */
|
||||
#define SETCURTYP 0x01 /* Set Cursor Type */
|
||||
#define GETMODE 0x0f /* Get Video Mode */
|
||||
#define SETMODE 0x00 /* Set Video Mode */
|
||||
#define SETPAGE 0x05 /* Set Video Page */
|
||||
@@ -248,6 +249,8 @@ extern void txt_nhbell(void);
|
||||
extern void txt_startup(int *, int *);
|
||||
extern void txt_xputs(const char *, int, int);
|
||||
extern void txt_xputc(char, int);
|
||||
extern void txt_hide_cursor(void);
|
||||
extern void txt_show_cursor(void);
|
||||
|
||||
/* ### vidvga.c ### */
|
||||
|
||||
@@ -258,6 +261,8 @@ extern void vga_clear_screen(int);
|
||||
extern void vga_cl_end(int, int);
|
||||
extern void vga_cl_eos(int);
|
||||
extern int vga_detect(void);
|
||||
extern void vga_hide_cursor(void);
|
||||
extern void vga_show_cursor(void);
|
||||
#ifdef SIMULATE_CURSOR
|
||||
extern void vga_DrawCursor(void);
|
||||
#endif
|
||||
@@ -273,7 +278,7 @@ extern void vga_HideCursor(void);
|
||||
#endif
|
||||
extern void vga_Init(void);
|
||||
extern void vga_tty_end_screen(void);
|
||||
extern void vga_tty_startup(int *, int *);
|
||||
extern void vga_term_startup(int *, int *);
|
||||
extern void vga_xputs(const char *, int, int);
|
||||
extern void vga_xputc(char, int);
|
||||
extern void vga_xputg(const glyph_info *, const glyph_info *);
|
||||
@@ -288,6 +293,8 @@ extern void vesa_clear_screen(int);
|
||||
extern void vesa_cl_end(int, int);
|
||||
extern void vesa_cl_eos(int);
|
||||
extern int vesa_detect(void);
|
||||
extern void vesa_hide_cursor(void);
|
||||
extern void vesa_show_cursor(void);
|
||||
#ifdef SIMULATE_CURSOR
|
||||
extern void vesa_DrawCursor(void);
|
||||
#endif
|
||||
@@ -302,7 +309,7 @@ extern void vesa_HideCursor(void);
|
||||
#endif
|
||||
extern void vesa_Init(void);
|
||||
extern void vesa_tty_end_screen(void);
|
||||
extern void vesa_tty_startup(int *, int *);
|
||||
extern void vesa_term_startup(int *, int *);
|
||||
extern void vesa_xputs(const char *, int, int);
|
||||
extern void vesa_xputc(char, int);
|
||||
extern void vesa_xputg(const glyph_info *, const glyph_info *);
|
||||
|
||||
@@ -146,6 +146,61 @@ boolean traditional = FALSE; /* traditional TTY character mode */
|
||||
boolean inmap = FALSE; /* in the map window */
|
||||
char ttycolors[CLR_MAX]; /* also used/set in options.c */
|
||||
|
||||
/* for linkage from wintty.c */
|
||||
|
||||
void
|
||||
term_shutdown(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef ASCIIGRAPH
|
||||
void
|
||||
graph_on(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
graph_off(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
term_curs_set(int visibility)
|
||||
{
|
||||
static int vis = -1;
|
||||
|
||||
if (vis == visibility)
|
||||
return;
|
||||
|
||||
if (!visibility) {
|
||||
if (!iflags.grmode) {
|
||||
txt_hide_cursor();
|
||||
#ifdef SCREEN_VGA
|
||||
} else if (iflags.usevga) {
|
||||
vga_hide_cursor();
|
||||
#endif
|
||||
#ifdef SCREEN_VESA
|
||||
} else if (iflags.usevesa) {
|
||||
vesa_hide_cursor();
|
||||
}
|
||||
#endif
|
||||
} else if (visibility) {
|
||||
if (!iflags.grmode) {
|
||||
txt_show_cursor();
|
||||
#ifdef SCREEN_VGA
|
||||
} else if (iflags.usevga) {
|
||||
vga_show_cursor();
|
||||
#endif
|
||||
#ifdef SCREEN_VESA
|
||||
} else if (iflags.usevesa) {
|
||||
vesa_show_cursor();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
vis = visibility;
|
||||
}
|
||||
|
||||
void
|
||||
backsp(void)
|
||||
{
|
||||
@@ -447,7 +502,7 @@ tty_number_pad(int state)
|
||||
}
|
||||
|
||||
void
|
||||
tty_startup(int *wid, int *hgt)
|
||||
term_startup(int *wid, int *hgt)
|
||||
{
|
||||
/* code to sense display adapter is required here - MJA */
|
||||
|
||||
@@ -461,12 +516,12 @@ tty_startup(int *wid, int *hgt)
|
||||
|
||||
#ifdef SCREEN_VGA
|
||||
if (iflags.usevga) {
|
||||
vga_tty_startup(wid, hgt);
|
||||
vga_term_startup(wid, hgt);
|
||||
} else
|
||||
#endif
|
||||
#ifdef SCREEN_VESA
|
||||
if (iflags.usevesa) {
|
||||
vesa_tty_startup(wid, hgt);
|
||||
vesa_term_startup(wid, hgt);
|
||||
} else
|
||||
#endif
|
||||
txt_startup(wid, hgt);
|
||||
|
||||
@@ -38,6 +38,14 @@ extern int attrib_gr_normal; /* graphics mode normal attribute */
|
||||
extern int attrib_text_intense; /* text mode intense attribute */
|
||||
extern int attrib_gr_intense; /* graphics mode intense attribute */
|
||||
|
||||
#if defined(SCREEN_BIOS) && !defined(PC9800)
|
||||
static unsigned char cursor_info = 0,
|
||||
cursor_start_scanline = 6, cursor_end_scanline = 7;
|
||||
|
||||
static void get_cursinfo(unsigned char *start, unsigned char *end,
|
||||
unsigned char *flg);
|
||||
#endif
|
||||
|
||||
void
|
||||
txt_get_scr_size(void)
|
||||
{
|
||||
@@ -80,6 +88,7 @@ txt_get_scr_size(void)
|
||||
|
||||
LI = regs.h.dl + 1;
|
||||
CO = regs.h.ah;
|
||||
|
||||
#endif /* PC9800 */
|
||||
}
|
||||
|
||||
@@ -260,6 +269,9 @@ txt_startup(int *wid, int *hgt)
|
||||
attrib_gr_normal = attrib_text_normal;
|
||||
attrib_gr_intense = attrib_text_intense;
|
||||
g_attribute = attrib_text_normal; /* Give it a starting value */
|
||||
get_cursinfo(&cursor_start_scanline,
|
||||
&cursor_end_scanline,
|
||||
&cursor_info);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -400,6 +412,61 @@ void txt_get_cursor(int *x, int *y)
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Cursor Position */
|
||||
*x = regs.h.dl;
|
||||
*y = regs.h.dh;
|
||||
if (!cursor_info) {
|
||||
cursor_start_scanline = regs.h.ch;
|
||||
cursor_end_scanline = regs.h.cl;
|
||||
cursor_info = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void txt_hide_cursor(void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.x.dx = 0;
|
||||
regs.h.ah = SETCURTYP; /* set cursor type */
|
||||
regs.h.ch = 0x3F; /* starting scanline */
|
||||
regs.h.cl = 0; /* ending scanline */
|
||||
regs.x.bx = 0;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
}
|
||||
|
||||
void txt_show_cursor(void)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.x.dx = 0;
|
||||
regs.h.ah = SETCURTYP; /* set cursor type */
|
||||
if (cursor_info) {
|
||||
regs.h.ch = cursor_start_scanline; /* starting scanline */
|
||||
regs.h.cl = cursor_end_scanline; /* ending scanline */
|
||||
} else {
|
||||
regs.h.ch = 6; /* starting scanline */
|
||||
regs.h.cl = 7; /* ending scanline */
|
||||
}
|
||||
regs.x.bx = 0;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s);
|
||||
}
|
||||
|
||||
static void
|
||||
get_cursinfo(uchar *start, uchar *end, uchar *flg)
|
||||
{
|
||||
union REGS regs;
|
||||
|
||||
regs.x.dx = 0;
|
||||
regs.h.ah = GETCURPOS; /* get cursor position */
|
||||
regs.x.cx = 0;
|
||||
regs.x.bx = 0;
|
||||
(void) int86(VIDEO_BIOS, ®s, ®s); /* Get Cursor Position */
|
||||
|
||||
if (regs.h.ch != 0x3f) {
|
||||
*start = regs.h.ch;
|
||||
*end = regs.h.cl;
|
||||
} else {
|
||||
*start = 6;
|
||||
*end = 7;
|
||||
}
|
||||
*flg = 1;
|
||||
}
|
||||
#endif /* SCREEN_BIOS && !PC9800 */
|
||||
|
||||
|
||||
@@ -603,7 +603,7 @@ vesa_tty_end_screen(void)
|
||||
}
|
||||
|
||||
void
|
||||
vesa_tty_startup(int *wid, int *hgt)
|
||||
vesa_term_startup(int *wid, int *hgt)
|
||||
{
|
||||
/* code to sense display adapter is required here - MJA */
|
||||
|
||||
@@ -2042,6 +2042,16 @@ vesa_SetSoftPalette(const struct Pixel *palette)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
vesa_hide_cursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
vesa_show_cursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef POSITIONBAR
|
||||
|
||||
#define PBAR_ROW (LI - 4)
|
||||
|
||||
@@ -297,7 +297,7 @@ vga_tty_end_screen(void)
|
||||
}
|
||||
|
||||
void
|
||||
vga_tty_startup(int *wid, int *hgt)
|
||||
vga_term_startup(int *wid, int *hgt)
|
||||
{
|
||||
/* code to sense display adapter is required here - MJA */
|
||||
|
||||
@@ -1159,6 +1159,16 @@ vga_SetPalette(const struct Pixel *p)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vga_hide_cursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
vga_show_cursor(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*static unsigned char colorbits[]={0x01,0x02,0x04,0x08}; */ /* wrong */
|
||||
static unsigned char colorbits[] = { 0x08, 0x04, 0x02, 0x01 };
|
||||
|
||||
|
||||
@@ -22,12 +22,6 @@
|
||||
#include <unistd.h> /* for getcwd() prototype */
|
||||
#endif
|
||||
|
||||
#if defined(MICRO) || defined(OS2)
|
||||
ATTRNORETURN void nethack_exit(int) NORETURN;
|
||||
#else
|
||||
#define nethack_exit exit
|
||||
#endif
|
||||
|
||||
char *exepath(char *);
|
||||
char orgdir[PATHLEN]; /* also used in pcsys.c, amidos.c */
|
||||
|
||||
|
||||
@@ -27,11 +27,6 @@
|
||||
#define filesize filesize_nh
|
||||
#endif
|
||||
|
||||
#if defined(MICRO) || defined(OS2)
|
||||
ATTRNORETURN void nethack_exit(int) NORETURN;
|
||||
#else
|
||||
#define nethack_exit exit
|
||||
#endif
|
||||
static void msexit(void);
|
||||
|
||||
#ifdef MOVERLAY
|
||||
@@ -276,6 +271,7 @@ msexit(void)
|
||||
restore_colors();
|
||||
#endif
|
||||
wait_synch();
|
||||
term_curs_set(1);
|
||||
return;
|
||||
}
|
||||
#endif /* MICRO || OS2 */
|
||||
|
||||
@@ -235,8 +235,8 @@ ifeq "$(WANT_DEBUG)" "1"
|
||||
GDBEXE=$(dostargetexes)gdb.exe
|
||||
GDBBAT=NHGDB.BAT
|
||||
GDBCMDLINE=directory nhsrc/src nhsrc/include nhsrc/sys/msdos \
|
||||
nhsrc/sys/share nhsrc/win/share nhsrc/win/curses \
|
||||
nhsrc/win/tty nhsrc/util
|
||||
nhsrc/sys/share nhsrc/win/curses \
|
||||
nhsrc/win/tty
|
||||
else
|
||||
GDBEXE=
|
||||
GDBBAT=
|
||||
|
||||
@@ -1079,7 +1079,7 @@ setftty(void)
|
||||
}
|
||||
|
||||
void
|
||||
tty_startup(int *wid, int *hgt)
|
||||
term_startup(int *wid, int *hgt)
|
||||
{
|
||||
*wid = console.width;
|
||||
*hgt = console.height;
|
||||
@@ -1092,6 +1092,36 @@ tty_number_pad(int state UNUSED)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/* stub tcap replacements for linkage from wintty.c */
|
||||
|
||||
void
|
||||
term_shutdown(void)
|
||||
{
|
||||
consoletty_exit();
|
||||
}
|
||||
|
||||
#ifdef ASCIIGRAPH
|
||||
void
|
||||
graph_on(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
graph_off(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
tty_end_screen(void)
|
||||
{
|
||||
term_clear_screen();
|
||||
really_move_cursor();
|
||||
buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0);
|
||||
back_buffer_flip();
|
||||
FlushConsoleInputBuffer(console.hConIn);
|
||||
}
|
||||
|
||||
void
|
||||
tty_start_screen(void)
|
||||
{
|
||||
@@ -1107,16 +1137,6 @@ tty_start_screen(void)
|
||||
#endif /* VIRTUAL_TERMINAL_SEQUENCES */
|
||||
}
|
||||
|
||||
void
|
||||
tty_end_screen(void)
|
||||
{
|
||||
term_clear_screen();
|
||||
really_move_cursor();
|
||||
buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0);
|
||||
back_buffer_flip();
|
||||
FlushConsoleInputBuffer(console.hConIn);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
CtrlHandler(DWORD ctrltype)
|
||||
{
|
||||
@@ -1251,6 +1271,7 @@ console_poskey(coordxy *x, coordxy *y, int *mod)
|
||||
if (gc.Cmd.swap_yz)
|
||||
numberpad |= 0x10;
|
||||
#endif
|
||||
term_curs_set(1);
|
||||
ch = (program_state.done_hup)
|
||||
? '\033'
|
||||
: keyboard_handling.pCheckInput(
|
||||
@@ -1262,6 +1283,7 @@ console_poskey(coordxy *x, coordxy *y, int *mod)
|
||||
*x = cc.x;
|
||||
*y = cc.y;
|
||||
}
|
||||
term_curs_set(0);
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1484,7 @@ xputc_core(int ch)
|
||||
*/
|
||||
#endif
|
||||
void
|
||||
g_putch(int in_ch)
|
||||
console_g_putch(int in_ch)
|
||||
{
|
||||
unsigned char ch;
|
||||
cell_t cell;
|
||||
@@ -1644,6 +1666,25 @@ term_clear_screen(void)
|
||||
home();
|
||||
}
|
||||
|
||||
void
|
||||
term_curs_set(int visibility)
|
||||
{
|
||||
static int vis = -1;
|
||||
|
||||
if (vis == visibility)
|
||||
return;
|
||||
|
||||
static CONSOLE_CURSOR_INFO cursorinfo = { 0, 0 };
|
||||
|
||||
if (!cursorinfo.dwSize) {
|
||||
GetConsoleCursorInfo(console.hConOut, &cursorinfo);
|
||||
vis = cursorinfo.bVisible ? 1 : 0;
|
||||
}
|
||||
cursorinfo.bVisible = visibility ? (BOOL) TRUE : (BOOL) FALSE;
|
||||
SetConsoleCursorInfo(console.hConOut, &cursorinfo);
|
||||
vis = visibility;
|
||||
}
|
||||
|
||||
void
|
||||
home(void)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@ char *translate_path_variables(const char *, char *);
|
||||
char *exename(void);
|
||||
boolean fakeconsole(void);
|
||||
void freefakeconsole(void);
|
||||
ATTRNORETURN extern void nethack_exit(int) NORETURN;
|
||||
#if defined(MSWIN_GRAPHICS)
|
||||
extern void mswin_destroy_reg(void);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user