build both tty NetHack.exe and gui NetHackW.exe

Changes to be committed:
	modified:   include/config.h
	modified:   include/extern.h
	modified:   include/flag.h
	modified:   include/global.h
	modified:   include/ntconf.h
	modified:   include/wintty.h
	modified:   src/cmd.c
	modified:   src/files.c
	modified:   src/options.c
	modified:   sys/share/pcmain.c
	modified:   sys/share/pcsys.c
	modified:   sys/share/pcunix.c
	modified:   sys/winnt/Makefile.gcc
	modified:   sys/winnt/Makefile.msc
	modified:   sys/winnt/nttty.c
	new file:   sys/winnt/stubs.c
	modified:   sys/winnt/winnt.c
	modified:   util/makedefs.c
	modified:   win/tty/wintty.c

Adjust the code and the command line Makefile so that
you no longer have to choose whether to build the tty
version NetHack.exe, or the gui version NetHackW.exe.

Both will now be built in a single 'nmake install' pass.
This commit is contained in:
nhmall
2015-04-22 00:07:46 -04:00
parent 9b63abf2b0
commit aaca36a6d5
19 changed files with 804 additions and 684 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 pcmain.c $NHDT-Date: 1429135416 2015/04/15 22:03:36 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.60 $ */
/* NetHack 3.5 pcmain.c $NHDT-Date: 1429675589 2015/04/22 04:06:29 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.61 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -55,6 +55,8 @@ extern void FDECL(nethack_exit,(int));
#ifdef WIN32
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
extern int redirect_stdout; /* from sys/share/pcsys.c */
char *NDECL(exename);
char default_window_sys[] = "mswin";
#endif
#if defined(MSWIN_GRAPHICS)
@@ -79,7 +81,7 @@ unsigned _stklen = STKSIZ;
* to help MinGW decide which entry point to choose. If both main and
* WinMain exist, the resulting executable won't work correctly.
*/
#ifndef MSWIN_GRAPHICS
#ifndef __MINGW32__
int
main(argc,argv)
int argc;
@@ -88,6 +90,10 @@ char *argv[];
boolean resuming;
sys_early_init();
#ifdef WIN32
Strcpy(default_window_sys, "tty");
#endif
resuming = pcmain(argc,argv);
#ifdef LAN_FEATURES
init_lan_features();
@@ -97,7 +103,7 @@ char *argv[];
/*NOTREACHED*/
return 0;
}
#endif /*MSWIN_GRAPHICS*/
#endif
boolean
pcmain(argc,argv)
@@ -142,7 +148,11 @@ char *argv[];
#endif
hname = "NetHack"; /* used for syntax messages */
#ifndef WIN32
choose_windows(DEFAULT_WINDOW_SYS);
#else
choose_windows(default_window_sys);
#endif
#if !defined(AMIGA) && !defined(GNUDOS)
/* Save current directory and make sure it gets restored when
@@ -217,7 +227,7 @@ char *argv[];
# endif
ami_wininit_data();
#endif
#ifdef WIN32CON
#ifdef WIN32
save_getreturn_status = getreturn_enabled;
raw_clear_screen();
getreturn_enabled = TRUE;
@@ -267,16 +277,14 @@ char *argv[];
* may do a prscore().
*/
if (!strncmp(argv[1], "-s", 2)) {
#if defined(MSWIN_GRAPHICS) || defined(WIN32CON)
#if defined(WIN32)
int sfd = (int)_fileno(stdout);
redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0;
# ifdef MSWIN_GRAPHICS
if (!redirect_stdout) {
raw_printf("-s is not supported for the Graphical Interface\n");
nethack_exit(EXIT_SUCCESS);
}
# endif
#endif
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
@@ -336,11 +344,22 @@ char *argv[];
chdirx(hackdir,1);
#endif
#ifdef MSDOS
/* We do this early for MSDOS because there are several
* display/tile related options that affect init_nhwindows()
#if defined(MSDOS) || defined (WIN32)
/* In 3.6.0, several ports process options before they init
* the window port. This allows settings that impact window
* ports to be specified or read from the sys or user config files.
*/
process_options(argc, argv);
# ifdef WIN32
/*
if (!strncmpi(windowprocs.name, "mswin", 5))
NHWinMainInit();
else
*/
if (!strncmpi(windowprocs.name, "tty", 3))
nttty_open(1);
# endif
#endif
#if defined(MSDOS) || defined(WIN32)
@@ -353,14 +372,14 @@ char *argv[];
}
#endif
#ifdef MSDOS
#if defined(MSDOS) || defined(WIN32)
init_nhwindows(&argc,argv);
#else
init_nhwindows(&argc,argv);
process_options(argc, argv);
#endif
#ifdef WIN32CON
#ifdef WIN32
toggle_mouse_support(); /* must come after process_options */
#endif
@@ -637,6 +656,19 @@ char *argv[];
case 'l':
bigscreen = -1;
break;
#endif
#ifdef WIN32
case 'w': /* windowtype */
if (strncmpi(&argv[0][2],"tty", 3)) {
nttty_open(1);
}
/*
else {
NHWinMainInit();
}
*/
choose_windows(&argv[0][2]);
break;
#endif
case '@':
flags.randomall = 1;
@@ -751,6 +783,32 @@ authorize_wizard_mode()
#define PATH_SEPARATOR '\\'
# endif
#ifdef WIN32
static char exenamebuf[PATHLEN];
char *
exename()
{
int bsize = PATHLEN;
char *tmp = exenamebuf, *tmp2;
# ifdef UNICODE
{
TCHAR wbuf[PATHLEN * 4];
GetModuleFileName((HANDLE)0, wbuf, PATHLEN * 4);
WideCharToMultiByte(CP_ACP, 0, wbuf, -1, tmp, bsize, NULL, NULL);
}
# else
*(tmp + GetModuleFileName((HANDLE)0, tmp, bsize)) = '\0';
# endif
tmp2 = strrchr(tmp, PATH_SEPARATOR);
if (tmp2) *tmp2 = '\0';
tmp2++;
return tmp2;
}
#endif
#define EXEPATHBUFSZ 256
char exepathbuf[EXEPATHBUFSZ];