diff --git a/src/cmd.c b/src/cmd.c index 9c4739a42..d7303ec18 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -5354,8 +5354,10 @@ dotravel(VOID_ARGS) } #ifdef PORT_DEBUG +#if defined(WIN32) && defined(TTY_GRAPHICS) extern void NDECL(win32con_debug_keystrokes); extern void NDECL(win32con_handler_info); +#endif int wiz_port_debug() @@ -5369,7 +5371,7 @@ wiz_port_debug() char *menutext; void NDECL((*fn)); } menu_selections[] = { -#ifdef WIN32 +#if defined(WIN32) && defined(TTY_GRAPHICS) { "test win32 keystrokes (tty only)", win32con_debug_keystrokes }, { "show keystroke handler information (tty only)", win32con_handler_info }, diff --git a/src/options.c b/src/options.c index e61eaa906..fbe568fb2 100644 --- a/src/options.c +++ b/src/options.c @@ -2651,7 +2651,7 @@ boolean tinitial, tfrom_file; bad_negation(fullname, FALSE); return FALSE; } else if ((op = string_for_opt(opts, negated)) != 0) { -#if defined(WIN32CON) +#if defined(WIN32) && defined(TTY_GRAPHICS) set_altkeyhandler(op); #endif } else @@ -3304,7 +3304,9 @@ boolean tinitial, tfrom_file; op = string_for_opt(opts, 0); if (!op) return FALSE; +#ifdef TTY_GRAPHICS map_subkeyvalue(op); +#endif #endif } return retval; diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 1b38ab951..cfb7dbf8a 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -310,7 +310,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #endif #ifdef WIN32 save_getreturn_status = getreturn_enabled; +#ifdef TTY_GRAPHICS raw_clear_screen(); +#endif getreturn_enabled = TRUE; check_recordfile((char *) 0); #endif @@ -484,6 +486,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ NHWinMainInit(); else */ +#ifdef TTY_GRAPHICS if (!strncmpi(windowprocs.name, "tty", 3)) { iflags.use_background_glyph = FALSE; nttty_open(1); @@ -492,6 +495,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ } #endif #endif +#endif #if defined(MSDOS) || defined(WIN32) /* Player didn't specify any symbol set so use IBM defaults */ @@ -510,7 +514,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ process_options(argc, argv); #endif -#ifdef WIN32 +#if defined(WIN32) && defined(TTY_GRAPHICS) toggle_mouse_support(); /* must come after process_options */ #endif @@ -791,14 +795,11 @@ char *argv[]; #endif #ifdef WIN32 case 'w': /* windowtype */ +#ifdef TTY_GRAPHICS if (strncmpi(&argv[0][2], "tty", 3)) { nttty_open(1); } - /* - else { - NHWinMainInit(); - } - */ +#endif config_error_init(FALSE, "command line", FALSE); choose_windows(&argv[0][2]); config_error_done(); diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index 71b62c6e0..cb5650af6 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -501,6 +501,15 @@ int code; exit(code); } +#ifdef WIN32 +#ifndef TTY_GRAPHICS +void +synch_cursor() +{ +} +#endif +#endif + /* Chdir back to original directory */ #ifdef TOS diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index 72daafe10..22bc4ae4e 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -15,9 +15,10 @@ #if defined(WIN32) || defined(MSDOS) extern char orgdir[]; -#ifdef WIN32 -extern void NDECL(backsp); #endif + +#if defined(WIN32) && defined(TTY_GRAPHICS) +extern void NDECL(backsp); extern void NDECL(clear_screen); #endif @@ -196,7 +197,7 @@ getlock() if (c == 'y' || c == 'Y') #ifndef SELF_RECOVER if (eraseoldlocks()) { -#if defined(WIN32) +#if defined(WIN32) && defined(TTY_GRAPHICS) if (!strncmpi(windowprocs.name, "tty", 3)) clear_screen(); /* display gets fouled up otherwise */ #endif @@ -210,7 +211,7 @@ getlock() } #else /*SELF_RECOVER*/ if (recover_savefile()) { -#if defined(WIN32) +#if defined(WIN32) && defined(TTY_GRAPHICS) if (!strncmpi(windowprocs.name, "tty", 3)) clear_screen(); /* display gets fouled up otherwise */ #endif diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index f7417adbe..e983d36fb 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -13,6 +13,7 @@ * */ + #ifdef WIN32 #define NEED_VARARGS /* Uses ... */ #include "hack.h" @@ -21,6 +22,10 @@ #include #include "win32api.h" +extern boolean getreturn_enabled; /* from sys/share/pcsys.c */ +extern int redirect_stdout; + +#ifdef TTY_GRAPHICS /* * Console Buffer Flipping Support * @@ -84,9 +89,6 @@ INPUT_RECORD ir; /* Support for changing console font if existing glyph widths are too wide */ -extern boolean getreturn_enabled; /* from sys/share/pcsys.c */ -extern int redirect_stdout; - /* Flag for whether NetHack was launched via the GUI, not the command line. * The reason we care at all, is so that we can get * a final RETURN at the end of the game when launched from the GUI @@ -1078,40 +1080,6 @@ void set_altkeyhandler(const char * inName) return; } -/* this is used as a printf() replacement when the window - * system isn't initialized yet - */ -void msmsg -VA_DECL(const char *, fmt) -{ - char buf[ROWNO * COLNO]; /* worst case scenario */ - VA_START(fmt); - VA_INIT(fmt, const char *); - Vsprintf(buf, fmt, VA_ARGS); - if (redirect_stdout) - fprintf(stdout, "%s", buf); - else { - if(!init_ttycolor_completed) - init_ttycolor(); - - /* if we have generated too many messages ... ask the user to - * confirm and then clear. - */ - if (console.cursor.Y > console.height - 4) { - xputs("Hit to continue."); - while (pgetchar() != '\n') - ; - raw_clear_screen(); - set_console_cursor(1, 0); - } - - xputs(buf); - if (ttyDisplay) - curs(BASE_WINDOW, console.cursor.X + 1, console.cursor.Y); - } - VA_END(); - return; -} /* fatal error */ /*VARARGS1*/ @@ -1912,5 +1880,43 @@ void nethack_enter_nttty() error("Unable to load nhraykey.dll"); } } +#endif TTY_GRAPHICS + +/* this is used as a printf() replacement when the window + * system isn't initialized yet + */ +void msmsg +VA_DECL(const char *, fmt) +{ + char buf[ROWNO * COLNO]; /* worst case scenario */ + VA_START(fmt); + VA_INIT(fmt, const char *); + Vsprintf(buf, fmt, VA_ARGS); + if (redirect_stdout) + fprintf(stdout, "%s", buf); + else { +#ifdef TTY_GRAPHICS + if(!init_ttycolor_completed) + init_ttycolor(); + /* if we have generated too many messages ... ask the user to + * confirm and then clear. + */ + if (console.cursor.Y > console.height - 4) { + xputs("Hit to continue."); + while (pgetchar() != '\n') + ; + raw_clear_screen(); + set_console_cursor(1, 0); + } + xputs(buf); + if (ttyDisplay) + curs(BASE_WINDOW, console.cursor.X + 1, console.cursor.Y); +#else + fprintf(stdout, "%s", buf); +#endif + } + VA_END(); + return; +} #endif /* WIN32 */ diff --git a/sys/winnt/stubs.c b/sys/winnt/stubs.c index ef161ae9b..2a0d10e79 100644 --- a/sys/winnt/stubs.c +++ b/sys/winnt/stubs.c @@ -96,11 +96,13 @@ clear_screen() return; } +#ifdef TTY_GRAPHICS void backsp() { return; } +#endif int has_color(int color) @@ -158,11 +160,13 @@ VA_DECL(const char *, s) return; } +#ifdef TTY_GRAPHICS void synch_cursor() { return; } +#endif void more() diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 067ba5abd..451aae2f0 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -17,7 +17,9 @@ #endif #include #include "win32api.h" +#ifdef TTY_GRAPHICS #include "wintty.h" +#endif #ifdef WIN32 /* @@ -227,7 +229,14 @@ Delay(int ms) (void) Sleep(ms); } +#ifdef TTY_GRAPHICS extern void NDECL(backsp); +#else +void +backsp() +{ +} +#endif void win32_abort() @@ -481,11 +490,10 @@ void ntassert_failed(const char * exp, const char * file, int line) /* nethack_enter_winnt() is the first thing called from main */ void nethack_enter_winnt() { -#ifdef WIN32CON +#ifdef TTY_GRAPHICS nethack_enter_nttty(); #endif } - #endif /* WIN32 */ /*winnt.c*/