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 config.h $NHDT-Date: 1428084467 2015/04/03 18:07:47 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.76 $ */
/* NetHack 3.5 config.h $NHDT-Date: 1429675530 2015/04/22 04:05:30 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.81 $ */
/* NetHack 3.5 config.h $Date: 2012/01/27 20:15:26 $ $Revision: 1.37 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -109,9 +109,6 @@
#endif
#ifdef MSWIN_GRAPHICS
# ifdef TTY_GRAPHICS
# undef TTY_GRAPHICS
# endif
# ifndef DEFAULT_WINDOW_SYS
# define DEFAULT_WINDOW_SYS "mswin"
# endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 extern.h $NHDT-Date: 1429135323 2015/04/15 22:02:03 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.464 $ */
/* NetHack 3.5 extern.h $NHDT-Date: 1429675537 2015/04/22 04:05:37 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.471 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1500,10 +1500,10 @@ E void FDECL(regex_free, (struct nhregex *));
/* ### nttty.c ### */
#ifdef WIN32CON
#ifdef WIN32
E void NDECL(get_scr_size);
E int NDECL(nttty_kbhit);
E void NDECL(nttty_open);
E void FDECL(nttty_open,(int));
E void NDECL(nttty_rubout);
E int NDECL(tgetch);
E int FDECL(ntposkey,(int *, int *, int *));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 flag.h $NHDT-Date: 1425081976 2015/02/28 00:06:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */
/* NetHack 3.5 flag.h $NHDT-Date: 1429675538 2015/04/22 04:05:38 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.78 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -305,7 +305,7 @@ struct instance_flags {
struct autopickup_exception *autopickup_exceptions[2];
#define AP_LEAVE 0
#define AP_GRAB 1
#ifdef WIN32CON
#ifdef WIN32
#define MAX_ALTKEYHANDLER 25
char altkeyhandler[MAX_ALTKEYHANDLER];
#endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 global.h $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 global.h $NHDT-Date: 1429675538 2015/04/22 04:05:38 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.41 $ */
/* NetHack 3.5 global.h $Date: 2012/01/29 03:00:14 $ $Revision: 1.31 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -197,13 +197,6 @@ typedef uchar nhsym;
# endif
# ifdef WIN32
# define PORT_ID "Windows"
# ifndef PORT_SUB_ID
# ifdef MSWIN_GRAPHICS
# define PORT_SUB_ID "graphical"
# else
# define PORT_SUB_ID "tty"
# endif
# endif
# endif
#endif
@@ -234,7 +227,7 @@ typedef uchar nhsym;
# define EXIT_FAILURE 1
#endif
#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS)
#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(WIN32)
# ifndef USE_TILES
# define USE_TILES /* glyph2tile[] will be available */
# endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 ntconf.h $NHDT-Date: 1426966690 2015/03/21 19:38:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.37 $ */
/* NetHack 3.5 ntconf.h $NHDT-Date: 1429675540 2015/04/22 04:05:40 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.44 $ */
/* SCCS Id: @(#)ntconf.h 3.5 2002/03/10 */
/* Copyright (c) NetHack PC Development Team 1993, 1994. */
/* NetHack may be freely redistributed. See license for details. */
@@ -13,9 +13,8 @@
#define EXEPATH /* Allow .exe location to be used as HACKDIR */
#define TRADITIONAL_GLYPHMAP /* Store glyph mappings at level change time */
#ifdef WIN32CON
#define LAN_FEATURES /* Include code for lan-aware features. Untested in 3.4.0*/
#endif
#define PC_LOCKING /* Prevent overwrites of aborted or in-progress games */
/* without first receiving confirmation. */
@@ -29,10 +28,8 @@
#define USER_SOUNDS
#ifdef WIN32CON
#define CHANGE_COLOR /* allow palette changes in win32 console */
/*#define CHANGE_COLOR*/ /* allow palette changes */
#define SELECTSAVED /* Provide menu of saved games to choose from at start */
#endif
/*
* -----------------------------------------------------------------
@@ -56,18 +53,12 @@
#ifdef OPTIONS_USED
#undef OPTIONS_USED
#endif
#ifdef MSWIN_GRAPHICS
#define OPTIONS_USED "guioptions"
#else
#define OPTIONS_USED "ttyoptions"
#endif
#define OPTIONS_USED "options"
#define OPTIONS_FILE OPTIONS_USED
#define PORT_HELP "porthelp"
#ifdef WIN32CON
#define PORT_DEBUG /* include ability to debug international keyboard issues */
#endif
#define SAFERHANGUP /* Define SAFERHANGUP to delay hangup processing
* until the main command loop. 'safer' because it
@@ -199,13 +190,11 @@ extern char hackdir[];
#define getuid() 1
#define getlogin() ((char *)0)
extern void NDECL(win32_abort);
#ifdef WIN32CON
extern void FDECL(nttty_preference_update, (const char *));
extern void NDECL(toggle_mouse_support);
extern void FDECL(map_subkeyvalue, (char *));
extern void NDECL(load_keyboard_handler);
extern void NDECL(raw_clear_screen);
#endif
#include <fcntl.h>
#ifndef __BORLANDC__
@@ -237,7 +226,6 @@ int _RTLENTRY _EXPFUNC read (int __handle, void _FAR *__buf, unsigned __len);
#endif
extern int FDECL(set_win32_option, (const char *, const char *));
#ifdef WIN32CON
#define LEFTBUTTON FROM_LEFT_1ST_BUTTON_PRESSED
#define RIGHTBUTTON RIGHTMOST_BUTTON_PRESSED
#define MIDBUTTON FROM_LEFT_2ND_BUTTON_PRESSED
@@ -245,6 +233,5 @@ extern int FDECL(set_win32_option, (const char *, const char *));
#ifdef CHANGE_COLOR
extern int FDECL(alternative_palette, (char *));
#endif
#endif /* WIN32CON */
#endif /* NTCONF_H */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 wintty.h $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 wintty.h $NHDT-Date: 1429675543 2015/04/22 04:05:43 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.18 $ */
/* NetHack 3.5 wintty.h $Date: 2012/01/23 10:45:26 $ $Revision: 1.12 $ */
/* Copyright (c) David Cohrs, 1991,1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -241,15 +241,15 @@ E int FDECL(term_putc, (int c));
E int FDECL(term_flush, (void *desc));
E int FDECL(term_puts, (const char *str));
# endif /* MAC */
# if defined(MSDOS) || defined(WIN32CON)
# if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32CON)
# if defined(MSDOS) || defined(WIN32)
# if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32)
# undef putchar
# undef putc
# undef puts
# define putchar(x) xputc(x) /* these are in video.c, nttty.c */
# define putc(x) xputc(x)
# define puts(x) xputs(x)
# endif/*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32CON */
# endif/*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32 */
# ifdef POSITIONBAR
E void FDECL(video_update_positionbar, (char *));
# endif

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 cmd.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 cmd.c $NHDT-Date: 1429675557 2015/04/22 04:05:57 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.187 $ */
/* NetHack 3.5 cmd.c $Date: 2013/03/16 01:44:28 $ $Revision: 1.162 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3718,10 +3718,8 @@ dotravel(VOID_ARGS)
}
#ifdef PORT_DEBUG
# ifdef WIN32CON
extern void NDECL(win32con_debug_keystrokes);
extern void NDECL(win32con_handler_info);
# endif
int
wiz_port_debug()
@@ -3735,9 +3733,9 @@ wiz_port_debug()
char *menutext;
void NDECL((*fn));
} menu_selections[] = {
#ifdef WIN32CON
{"test win32 keystrokes", win32con_debug_keystrokes},
{"show keystroke handler information", win32con_handler_info},
#ifdef WIN32
{"test win32 keystrokes (tty only)", win32con_debug_keystrokes},
{"show keystroke handler information (tty only)", win32con_handler_info},
#endif
{(char *)0, (void NDECL((*)))0} /* array terminator */
};

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 files.c $NHDT-Date: 1429136302 2015/04/15 22:18:22 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.166 $ */
/* NetHack 3.5 files.c $NHDT-Date: 1429675565 2015/04/22 04:06:05 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.169 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1070,7 +1070,7 @@ get_saved_games()
#if defined(SELECTSAVED)
int n, j = 0;
char **result = 0;
# ifdef WIN32CON
# ifdef WIN32
{
char *foundfile;
const char *fq_save;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 options.c $NHDT-Date: 1428088105 2015/04/03 19:08:25 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.182 $ */
/* NetHack 3.5 options.c $NHDT-Date: 1429675568 2015/04/22 04:06:08 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.187 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -206,7 +206,7 @@ static struct Bool_Opt
{"toptenwin",&iflags.toptenwin, FALSE, SET_IN_GAME},
{"travel", &flags.travelcmd, TRUE, SET_IN_GAME},
{"use_darkgray", &iflags.wc2_darkgray, TRUE, SET_IN_FILE},
#ifdef WIN32CON
#ifdef WIN32
{"use_inverse", &iflags.wc_inverse, TRUE, SET_IN_GAME}, /*WC*/
#else
{"use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME}, /*WC*/
@@ -311,7 +311,7 @@ static struct Comp_Opt
MAXOCLASSES, SET_IN_GAME },
#ifdef CHANGE_COLOR
{ "palette",
# ifndef WIN32CON
# ifndef WIN32
"palette (00c/880/-fff is blue/yellow/reverse white)",
15 , SET_IN_GAME },
# else
@@ -372,7 +372,7 @@ static struct Comp_Opt
{ "videoshades", "gray shades to map to black/gray/white",
32, DISP_IN_GAME },
#endif
#ifdef WIN32CON
#ifdef WIN32
{"subkeyvalue", "override keystroke value", 7, SET_IN_FILE},
#endif
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
@@ -1734,7 +1734,7 @@ boolean tinitial, tfrom_file;
) {
int color_number, color_incr;
# ifndef WIN32CON
# ifndef WIN32
if (duplicate) complain_about_duplicate(opts,1);
# endif
# ifdef MAC
@@ -1756,7 +1756,7 @@ boolean tinitial, tfrom_file;
# ifdef MAC
}
# endif
#ifdef WIN32CON
#ifdef WIN32
op = string_for_opt(opts, TRUE);
if (!alternative_palette(op))
badoption(opts);
@@ -1802,7 +1802,7 @@ boolean tinitial, tfrom_file;
color_number += color_incr;
}
}
# endif /* !WIN32CON */
# endif /* !WIN32 */
if (!initial) {
need_redraw = TRUE;
}
@@ -1923,7 +1923,7 @@ goodfruit:
if (duplicate) complain_about_duplicate(opts,1);
if (negated) bad_negation(fullname, FALSE);
else if ((op = string_for_opt(opts, negated))) {
#ifdef WIN32CON
#ifdef WIN32
(void)strncpy(iflags.altkeyhandler, op, MAX_ALTKEYHANDLER - 5);
load_keyboard_handler();
#endif
@@ -2481,7 +2481,7 @@ goodfruit:
/* no duplicate complaint here */
if (negated) bad_negation(fullname, FALSE);
else {
#if defined(WIN32CON)
#if defined(WIN32)
op = string_for_opt(opts, 0);
map_subkeyvalue(op);
#endif
@@ -3782,7 +3782,7 @@ char *buf;
defopt);
else if (!strcmp(optname,"align"))
Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj));
#ifdef WIN32CON
#ifdef WIN32
else if (!strcmp(optname,"altkeyhandler"))
Sprintf(buf, "%s", iflags.altkeyhandler[0] ?
iflags.altkeyhandler : "default");

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];

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 pcsys.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 pcsys.c $NHDT-Date: 1429675591 2015/04/22 04:06:31 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.24 $ */
/* NetHack 3.5 pcsys.c $Date: 2012/01/22 06:33:47 $ $Revision: 1.18 $ */
/* SCCS Id: @(#)pcsys.c 3.5 2002/01/22 */
/* NetHack may be freely redistributed. See license for details. */
@@ -54,7 +54,7 @@ STATIC_DCL boolean NDECL(comspec_exists);
# endif
#endif
#ifdef WIN32CON
#ifdef WIN32
extern int GUILaunched; /* from nttty.c */
#endif
@@ -411,7 +411,7 @@ const char *str;
return;
}
#ifndef WIN32CON
#ifndef WIN32
void
msmsg VA_DECL(const char *, fmt)
VA_START(fmt);
@@ -529,7 +529,7 @@ STATIC_OVL void msexit()
restore_colors();
# endif
#endif
#ifdef WIN32CON
#ifdef WIN32
/* Only if we started from the GUI, not the command prompt,
* we need to get one last return, so the score board does
* not vanish instantly after being created.

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 pcunix.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 pcunix.c $NHDT-Date: 1429675591 2015/04/22 04:06:31 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.31 $ */
/* NetHack 3.5 pcunix.c $Date: 2009/05/06 10:50:30 $ $Revision: 1.27 $ */
/* SCCS Id: @(#)pcunix.c 3.5 1994/11/07 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -192,8 +192,9 @@ getlock()
if(c == 'y' || c == 'Y')
# ifndef SELF_RECOVER
if(eraseoldlocks()) {
# if defined(WIN32CON)
clear_screen(); /* display gets fouled up otherwise */
# if defined(WIN32)
if (!strncmpi(windowprocs.name, "tty", 3))
clear_screen(); /* display gets fouled up otherwise */
# endif
goto gotlock;
} else {
@@ -205,8 +206,9 @@ getlock()
}
# else /*SELF_RECOVER*/
if(recover_savefile()) {
# if defined(WIN32CON)
clear_screen(); /* display gets fouled up otherwise */
# if defined(WIN32)
if (!strncmpi(windowprocs.name, "tty", 3))
clear_screen(); /* display gets fouled up otherwise */
# endif
goto gotlock;
} else {

View File

@@ -1,5 +1,4 @@
# NetHack 3.5 Makefile.gcc $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$
# NetHack 3.5 Makefile.gcc $Date: 2011/10/11 02:37:22 $ $Revision: 1.38 $
# NetHack 3.5 Makefile.gcc $NHDT-Date: 1429675605 2015/04/22 04:06:45 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.45 $
# Copyright (c) NetHack PC Development Team 1993-2015
#
#==============================================================================
@@ -16,7 +15,7 @@
# This is used for building two versions of NetHack:
#
# A tty port utilizing the Win32 Console I/O subsystem, Console
# NetHack;
# NetHack.
#
# A Win32 native port built on the Windows API, Graphical NetHack or
# NetHackW.
@@ -31,11 +30,17 @@
# If you have any questions read the sys/winnt/Install.nt file included
# with the distribution.
#==============================================================================
#==============================================================================
# BUILD DECISIONS SECTION
#
# There are currently only 3 decisions that you have to make.
# 1. 32-bit or 64-bit?
# 2. Where do you want your build to end up?
# 3. Do you want debug information in the executable?
#
#==============================================================================
# 1. 32-bit or 64-bit?
#
# 64 bit
#TARGET_CPU=x64
#
@@ -43,17 +48,7 @@
TARGET_CPU=x86
#
#---------------------------------------------------------------
# 2. Graphical version or command line version?
#
# Graphical interface
# Set to Y for a graphical version
# Set to anything else (or undefine) for a tty version
#GRAPHICAL = Y
#
#---------------------------------------------------------------
# 3. Where do you want the game to be built (which folder)?
# 2. Where do you want the game to be built (which folder)?
# If not present prior to compilation it gets created.
#
@@ -61,7 +56,7 @@ GAMEDIR = ../binary
#
#---------------------------------------------------------------
# 4. Do you want debug information in the executable?
# 3. Do you want debug information in the executable?
#
DEBUGINFO = Y
@@ -79,14 +74,6 @@ DEBUGINFO = Y
# #
################################################
ifeq "$(GRAPHICAL)" "Y"
# Game Name
GAME = NetHackW
else
# Game Name
GAME = NetHack
endif
#
# Source directories. Makedefs hardcodes these, don't change them.
#
@@ -107,8 +94,8 @@ SSYS = ../sys/share
MSWSYS = ../sys/winnt
# window port files (tty)
TTY = ../win/tty
# window port files (Win32)
WIN32 = ../win/win32
# window port files (WIN32)
MSWIN = ../win/win32
# Tile support files
WSHR = ../win/share
@@ -124,7 +111,7 @@ link = gcc
#
#==========================================
# Exe File Info.
# Level Compiler Info
#==========================================
# Yacc/Lex ... if you got 'em.
@@ -159,6 +146,9 @@ YTABC = y_tab.c
YTABH = y_tab.h
LEXYYC = lexyy.c
#==========================================
# Exe File Info.
#==========================================
#
# Optional high-quality BSD random number generation routines
# (see pcconf.h). Set to nothing if not used.
@@ -167,39 +157,7 @@ LEXYYC = lexyy.c
RANDOM = $(OBJ)/random.o
#RANDOM =
ifeq "$(GRAPHICAL)" "Y"
WINPORT = $(O)tile.o $(O)mhaskyn.o $(O)mhdlg.o \
$(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \
$(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \
$(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o
WINPFLAG = -DTILES -DMSWIN_GRAPHICS -D_WIN32_IE=0x0400
NHRES = $(O)winres.o
WINPINC = -I$(WIN32)
WINPHDR = $(WIN32)/mhaskyn.h $(WIN32)/mhdlg.h $(WIN32)/mhfont.h \
$(WIN32)/mhinput.h $(WIN32)/mhmain.h $(WIN32)/mhmap.h \
$(WIN32)/mhmenu.h $(WIN32)/mhmsg.h $(WIN32)/mhmsgwnd.h \
$(WIN32)/mhrip.h $(WIN32)/mhstatus.h \
$(WIN32)/mhtext.h $(WIN32)/resource.h $(WIN32)/winMS.h
WINPLIBS = -lcomctl32 -lwinmm
else
WINPORT = $(O)nttty.o
WINPFLAG= -DWIN32CON
WINPHDR =
NHRES = $(O)console.o
WINPINC =
WINPLIBS = -lwinmm
endif
TILEUTIL16 = $(UTIL)/tile2bmp.exe
TILEBMP16 = $(SRC)/tiles.bmp
TILEUTIL32 = $(UTIL)/til2bm32.exe
TILEBMP32 = $(SRC)/tiles32.bmp
SOUND = $(OBJ)/ntsound.o
#SOUND =
WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501
# To store all the level files,
# help files, etc. in a single library file.
# USE_DLB = Y is left uncommented
@@ -229,8 +187,11 @@ endif
CFLAGSBASE = -c $(cflags) -I$(INCL) $(WINPINC) $(cdebug)
LFLAGSBASEC = $(linkdebug)
LFLAGSBASEG = $(linkdebug) -mwindows
#LFLAGSBASEC = $(linkdebug)
#LFLAGSBASEG = $(linkdebug) -mwindows
conlibs = -lwinmm
guilibs = -lcomctl32 -lwinmm
#==========================================
# Util builds
@@ -244,12 +205,7 @@ LFLAGSU = $(LFLAGSBASEC)
#==========================================
CFLAGS = $(CFLAGSBASE) $(WINPFLAG) $(DLBFLG)
lflags = $(LFLAGSBASE)
ifeq "$(GRAPHICAL)" "Y"
lflags = $(LFLAGSBASEG)
else
lflags = $(LFLAGSBASEC)
endif
lflags = $(LFLAGSBASEC) $(linkdebuf)
ifeq "$(USE_DLB)" "Y"
DLB = nhdat
@@ -257,76 +213,6 @@ else
DLB =
endif
#==========================================
#================ RULES ==================
#==========================================
.SUFFIXES: .exe .o .til .uu .c .y .l
#==========================================
# Rules for files in src
#==========================================
$(OBJ)/%.o : /%.c
$(cc) $(CFLAGS) -o$@ $<
$(OBJ)/%.o : $(SRC)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
# Rules for files in sys/share
#==========================================
$(OBJ)/%.o : $(SSYS)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(OBJ)/%.o : $(SSYS)/%.cpp
g++ $(CFLAGS) -std=c++11 -o$@ $<
#==========================================
# Rules for files in sys/winnt
#==========================================
$(OBJ)/%.o : $(MSWSYS)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(INCL)/%.h : $(MSWSYS)/%.h
@copy $< $@
#==========================================
# Rules for files in util
#==========================================
$(OBJ)/%.o : $(UTIL)/%.c
$(cc) $(CFLAGSU) -o$@ $<
#==========================================
# Rules for files in win/share
#==========================================
$(OBJ)/%.o : $(WSHR)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(INCL)/%.h : $(WSHR)/%.h
@copy $< $@
#{$(WSHR)}.txt{$(DAT)}.txt:
# @copy $< $@
#==========================================
# Rules for files in win/tty
#==========================================
$(OBJ)/%.o : $(TTY)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
# Rules for files in win/win32
#==========================================
$(OBJ)/%.o : $(WIN32)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
#================ MACROS ==================
#==========================================
@@ -429,17 +315,33 @@ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
$(VOBJ26) $(VOBJ27) $(REGEX)
WINPOBJ = $(WINPORT)
GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \
$(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \
$(O)mhmenu.o $(O)mhmsgwnd.o $(O)mhrip.o $(O)mhsplash.o \
$(O)mhstatus.o $(O)mhtext.o $(O)mswproc.o $(O)winhack.o
VVOBJ = $(O)version.o
GUIHDR = $(MSWIN)/mhaskyn.h $(MSWIN)/mhdlg.h $(MSWIN)/mhfont.h \
$(MSWIN)/mhinput.h $(MSWIN)/mhmain.h $(MSWIN)/mhmap.h \
$(MSWIN)/mhmenu.h $(MSWIN)/mhmsg.h $(MSWIN)/mhmsgwnd.h \
$(MSWIN)/mhrip.h $(MSWIN)/mhstatus.h \
$(MSWIN)/mhtext.h $(MSWIN)/resource.h $(MSWIN)/winMS.h
ALLOBJ = $(WINPOBJ) $(SOBJ) $(DLBOBJ) $(TTYOBJ) $(WOBJ) $(OBJS) $(VVOBJ)
KEYDLLS = $(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll
ifeq "$(GRAPHICAL)" "Y"
OPTIONS_FILE = $(DAT)/guioptions
else
OPTIONS_FILE = $(DAT)/ttyoptions
endif
TILEUTIL16 = $(UTIL)/tile2bmp.exe
TILEBMP16 = $(SRC)/tiles.bmp
TILEUTIL32 = $(UTIL)/til2bm32.exe
TILEBMP32 = $(SRC)/tiles32.bmp
SOUND = $(OBJ)/ntsound.o
#SOUND =
VVOBJ = $(O)version.o
ALLOBJ = $(SOBJ) $(DLBOBJ) $(WOBJ) $(OBJS) $(VVOBJ)
OPTIONS_FILE = $(DAT)\options
#==========================================
# Header file macros
@@ -478,12 +380,75 @@ TILE_H = ../win/share/tile.h
DATABASE = $(DAT)/data.base
#
# The name of the game.
#
#==========================================
#================ RULES ==================
#==========================================
GAMEFILE = $(GAMEDIR)/$(GAME).exe
.SUFFIXES: .exe .o .til .uu .c .y .l
#==========================================
# Rules for files in src
#==========================================
$(OBJ)/%.o : /%.c
$(cc) $(CFLAGS) -o$@ $<
$(OBJ)/%.o : $(SRC)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
# Rules for files in sys/share
#==========================================
$(OBJ)/%.o : $(SSYS)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(OBJ)/%.o : $(SSYS)/%.cpp
g++ $(CFLAGS) -std=c++11 -o$@ $<
#==========================================
# Rules for files in sys/winnt
#==========================================
$(OBJ)/%.o : $(MSWSYS)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(INCL)/%.h : $(MSWSYS)/%.h
@copy $< $@
#==========================================
# Rules for files in util
#==========================================
$(OBJ)/%.o : $(UTIL)/%.c
$(cc) $(CFLAGSU) -o$@ $<
#==========================================
# Rules for files in win/share
#==========================================
$(OBJ)/%.o : $(WSHR)/%.c
$(cc) $(CFLAGS) -o$@ $<
$(INCL)/%.h : $(WSHR)/%.h
@copy $< $@
#{$(WSHR)}.txt{$(DAT)}.txt:
# @copy $< $@
#==========================================
# Rules for files in win/tty
#==========================================
$(OBJ)/%.o : $(TTY)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
# Rules for files in win/win32
#==========================================
$(OBJ)/%.o : $(MSWIN)/%.c
$(cc) $(CFLAGS) -o$@ $<
#==========================================
#=============== TARGETS ==================
@@ -500,20 +465,14 @@ GAMEFILE = $(GAMEDIR)/$(GAME).exe
#
default : install
#
# The game target.
#
$(GAME) : $(O)obj.tag $(O)utility.tag graphicschk $(GAMEFILE)
@echo $(GAME) is up to date.
#
# Everything
#
all : install
install: graphicschk $(GAME) $(O)install.tag
install: graphicschk $(O)obj.tag $(GAMEDIR)/NetHack.exe $(GAMEDIR)/NetHackW.exe $(O)install.tag
@echo NetHack is up to date.
@echo Done.
@@ -587,35 +546,36 @@ $(O)utility.tag: $(INCL)/date.h $(INCL)/onames.h $(INCL)/pm.h \
tileutil: $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe
@echo Optional tile development utilities are up to date.
ifeq "$(GRAPHICAL)" "Y"
$(NHRES): $(TILEBMP16) $(WIN32)/winhack.rc $(WIN32)/mnsel.bmp \
$(WIN32)/mnselcnt.bmp $(WIN32)/mnunsel.bmp \
$(WIN32)/petmark.bmp $(WIN32)/NetHack.ico $(WIN32)/rip.bmp \
$(WIN32)/splash.bmp
@$(rc) -o$@ --include-dir $(WIN32) -i $(WIN32)/winhack.rc
else
$(NHRES): $(MSWSYS)/console.rc $(MSWSYS)/NetHack.ico
$(O)winres.o: $(TILEBMP16) $(MSWIN)/winhack.rc $(MSWIN)/mnsel.bmp \
$(MSWIN)/mnselcnt.bmp $(MSWIN)/mnunsel.bmp \
$(MSWIN)/petmark.bmp $(MSWIN)/NetHack.ico $(MSWIN)/rip.bmp \
$(MSWIN)/splash.bmp
@$(rc) -o$@ --include-dir $(MSWIN) -i $(MSWIN)/winhack.rc
$(O)conres.o: $(MSWSYS)/console.rc $(MSWSYS)/NetHack.ico
@$(rc) -o$@ --include-dir $(MSWSYS) -i $(MSWSYS)/console.rc
endif
#==========================================
# The main target.
# The game targets.
#==========================================
$(O)gamedir.tag:
$(subst /,\,@if not exist $(GAMEDIR)/*.* echo creating directory $(GAMEDIR))
$(subst /,\,@if not exist $(GAMEDIR)/*.* mkdir $(GAMEDIR))
$(subst /,\,@echo directory created > $@)
ifeq "$(GRAPHICAL)" "Y"
$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag
else
$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag \
$(GAMEDIR)/nhdefkey.dll $(GAMEDIR)/nh340key.dll $(GAMEDIR)/nhraykey.dll
endif
@echo Linking....
$(link) $(lflags) -o$@ $(ALLOBJ) $(NHRES) $(WINPLIBS) -static -lstdc++
$(GAMEDIR)/NetHack.exe : $(O)gamedir.tag $(O)tile.o $(O)nttty.o $(O)guistub.o \
$(ALLOBJ) $(TTYOBJ) $(GUIOBJ) $(O)conres.o $(KEYDLLS)
@echo Linking $@...
$(link) $(lflags) -o$@ $(ALLOBJ) $(TTYOBJ) $(O)nttty.o $(O)tile.o \
$(O)guistub.o $(O)conres.o $(conlibs) -static -lstdc++
$(subst /,\,@if exist $(O)install.tag del $(O)install.tag)
$(GAMEDIR)/NetHackW.exe : $(O)gamedir.tag $(O)tile.o $(O)ttystub.o \
$(ALLOBJ) $(TTYOBJ) $(GUIOBJ) $(O)winres.o $(KEYDLLS)
@echo Linking $@...
$(link) $(lflags) -mwindows -o$@ $(ALLOBJ) $(GUIOBJ) $(O)tile.o $(O)ttystub.o \
$(O)winres.o $(guilibs) -static -lstdc++
$(subst /,\,@if exist $(O)install.tag del $(O)install.tag)
$(O)nhdefkey.o:
$(cc) $(CFLAGS) -DBUILD_DLL -o$@ $(MSWSYS)/nhdefkey.c
@@ -649,11 +609,9 @@ $(GAME)_.ico : $(MSWSYS)/$(GAME).ico
#==========================================
graphicschk:
ifeq "$(GRAPHICAL)" "Y"
@echo ----
@echo NOTE: This build will include tile support.
@echo ----
endif
$(subst /,\,@echo graphicschk > graphicschk)
#
@@ -723,36 +681,36 @@ $(MSWSYS)/NetHack.ico : $(U)uudecode.exe $(MSWSYS)/nhico.uu
$(subst /,\,copy NetHack.ico $@)
del NetHack.ico
$(WIN32)/NetHack.ico : $(MSWSYS)/NetHack.ico
$(MSWIN)/NetHack.ico : $(MSWSYS)/NetHack.ico
$(subst /,\,copy $< $@)
$(WIN32)/mnsel.bmp: $(U)uudecode.exe $(WIN32)/mnsel.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/mnsel.uu)
$(MSWIN)/mnsel.bmp: $(U)uudecode.exe $(MSWIN)/mnsel.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/mnsel.uu)
$(subst /,\,copy mnsel.bmp $@)
del mnsel.bmp
$(WIN32)/mnselcnt.bmp: $(U)uudecode.exe $(WIN32)/mnselcnt.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/mnselcnt.uu)
$(MSWIN)/mnselcnt.bmp: $(U)uudecode.exe $(MSWIN)/mnselcnt.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/mnselcnt.uu)
$(subst /,\,copy mnselcnt.bmp $@)
del mnselcnt.bmp
$(WIN32)/mnunsel.bmp: $(U)uudecode.exe $(WIN32)/mnunsel.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/mnunsel.uu)
$(MSWIN)/mnunsel.bmp: $(U)uudecode.exe $(MSWIN)/mnunsel.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/mnunsel.uu)
$(subst /,\,copy mnunsel.bmp $@)
del mnunsel.bmp
$(WIN32)/petmark.bmp: $(U)uudecode.exe $(WIN32)/petmark.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/petmark.uu)
$(MSWIN)/petmark.bmp: $(U)uudecode.exe $(MSWIN)/petmark.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/petmark.uu)
$(subst /,\,copy petmark.bmp $@)
del petmark.bmp
$(WIN32)/rip.bmp: $(U)uudecode.exe $(WIN32)/rip.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/rip.uu)
$(MSWIN)/rip.bmp: $(U)uudecode.exe $(MSWIN)/rip.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/rip.uu)
$(subst /,\,copy rip.bmp $@)
del rip.bmp
$(WIN32)/splash.bmp: $(U)uudecode.exe $(WIN32)/splash.uu
$(subst /,\,$(U)uudecode.exe $(WIN32)/splash.uu)
$(MSWIN)/splash.bmp: $(U)uudecode.exe $(MSWIN)/splash.uu
$(subst /,\,$(U)uudecode.exe $(MSWIN)/splash.uu)
$(subst /,\,copy splash.bmp $@)
del splash.bmp
@@ -993,17 +951,9 @@ $(U)txt2ppm.exe: $(PPMWRITERS) $(TEXT_IO)
@$(link) $(LFLAGSU) -o$@ $(PPMWRITERS) $(TEXT_IO)
ifeq "$(GRAPHICAL)" "Y"
$(TILEBMP16): $(TILEUTIL16) $(TILEFILES)
@echo Creating 16x16 binary tile files (this may take some time)
$(subst /,\,@$(U)tile2bmp $(TILEBMP16))
#$(TILEBMP32): $(TILEUTIL32) $(TILEFILES32)
# @echo Creating 32x32 binary tile files (this may take some time)
# $(subst /,\,@$(U)til2bm32 $(TILEBMP32))
else
$(TILEBMP16):
$(TILEBMP32):
endif
$(U)tile2bmp.exe: $(O)tile2bmp.o $(TEXT_IO)
@echo Linking $@...
@@ -1128,6 +1078,21 @@ $(O)winnt.o: $(HACK_H) $(INCL)/win32api.h $(MSWSYS)/winnt.c
$(O)ntsound.o: $(HACK_H) $(MSWSYS)/ntsound.c
$(cc) $(CFLAGS) -o$@ $(MSWSYS)/ntsound.c
#if you aren't linking in the full gui then
#include the following stub for proper linkage.
$(O)guistub.o: $(HACK_H) $(MSWSYS)/stubs.c
@$(cc) $(CFLAGS) -DGUISTUB -o$@ $(MSWSYS)/stubs.c
#if you aren't linking in the full tty then
#include the following stub for proper linkage.
$(O)ttystub.o: $(HACK_H) $(MSWSYS)/ttystub.c
@$(cc) $(CFLAGS) -DTTYSTUB -o$@ $(MSWSYS)/stubs.c
$(O)tile.o: $(SRC)/tile.c $(HACK_H)
#
# util dependencies
#
@@ -1206,7 +1171,7 @@ $(O)wintext.o: ../win/X11/wintext.c $(HACK_H) $(INCL)/winX.h $(INCL)/xwindow.h
$(cc) $(CFLAGS) -o$@ ../win/X11/wintext.c
$(O)winval.o: ../win/X11/winval.c $(HACK_H) $(INCL)/winX.h
$(cc) $(CFLAGS) -o$@ ../win/X11/winval.c
$(O)tile.o: tile.c $(HACK_H)
$(O)tile.o: $(SRC)/tile.c $(HACK_H)
$(O)gnaskstr.o: ../win/gnome/gnaskstr.c ../win/gnome/gnaskstr.h \
../win/gnome/gnmain.h
$(cc) $(CFLAGS) $(GNOMEINC) -o$@ ../win/gnome/gnaskstr.c
@@ -1258,7 +1223,6 @@ $(O)load_img.o: ../win/gem/load_img.c $(INCL)/load_img.h
$(cc) $(CFLAGS) -o$@ ../win/gem/load_img.c
$(O)gr_rect.o: ../win/gem/gr_rect.c $(INCL)/gr_rect.h
$(cc) $(CFLAGS) -o$@ ../win/gem/gr_rect.c
$(O)tile.o: tile.c $(HACK_H)
$(O)qt_win.o: ../win/Qt/qt_win.cpp $(HACK_H) $(INCL)/func_tab.h \
$(INCL)/dlb.h $(INCL)/patchlevel.h $(INCL)/tile2x11.h \
$(INCL)/qt_win.h $(INCL)/qt_clust.h $(INCL)/qt_kde0.h \

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/* NetHack 3.5 nttty.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 nttty.c $NHDT-Date: 1429675608 2015/04/22 04:06:48 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.59 $ */
/* NetHack 3.5 nttty.c $Date: 2009/05/06 10:53:34 $ $Revision: 1.54 $ */
/* SCCS Id: @(#)nttty.c 3.5 $NHDT-Date$ */
/* SCCS Id: @(#)nttty.c 3.5 $NHDT-Date: 1429675609 2015/04/22 04:06:49 $ */
/* SCCS Id: @(#)nttty.c 3.5 $Date: 2009/05/06 10:53:34 $ */
/* Copyright (c) NetHack PC Development Team 1993 */
/* NetHack may be freely redistributed. See license for details. */
@@ -15,7 +15,7 @@
*
*/
#ifdef WIN32CON
#ifdef WIN32
#define NEED_VARARGS /* Uses ... */
#include "hack.h"
#include "wintty.h"
@@ -273,35 +273,53 @@ DWORD ctrltype;
}
}
/* called by init_tty in wintty.c for WIN32CON port only */
/* called by init_tty in wintty.c for WIN32 port only */
void
nttty_open()
nttty_open(mode)
int mode;
{
HANDLE hStdOut;
DWORD cmode;
long mask;
load_keyboard_handler();
/* Initialize the function pointer that points to
* the kbhit() equivalent, in this TTY case nttty_kbhit()
*/
nt_kbhit = nttty_kbhit;
/* The following 6 lines of code were suggested by
try:
/* The following lines of code were suggested by
* Bob Landau of Microsoft WIN32 Developer support,
* as the only current means of determining whether
* we were launched from the command prompt, or from
* the NT program manager. M. Allison
*/
hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );
GetConsoleScreenBufferInfo( hStdOut, &origcsbi);
GUILaunched = ((origcsbi.dwCursorPosition.X == 0) &&
(origcsbi.dwCursorPosition.Y == 0));
if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0))
GUILaunched = 0;
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOut) {
GetConsoleScreenBufferInfo(hStdOut, &origcsbi);
GUILaunched = ((origcsbi.dwCursorPosition.X == 0) &&
(origcsbi.dwCursorPosition.Y == 0));
if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0))
GUILaunched = 0;
} else if (mode) {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE);
if (!hStdOut && !hStdIn) {
/* Bool rval; */
AllocConsole();
AttachConsole(GetCurrentProcessId());
/* rval = SetStdHandle(STD_OUTPUT_HANDLE, hWrite); */
freopen("CON", "w", stdout);
freopen("CON", "r", stdin);
}
mode = 0;
goto try;
} else return;
load_keyboard_handler();
/* Initialize the function pointer that points to
* the kbhit() equivalent, in this TTY case nttty_kbhit()
*/
nt_kbhit = nttty_kbhit;
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE);
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
#if 0
hConIn = CreateFile("CONIN$",
@@ -1041,7 +1059,7 @@ msmsg VA_DECL(const char *, fmt)
/* fatal error */
/*VARARGS1*/
void
error VA_DECL(const char *,s)
nttty_error VA_DECL(const char *,s)
char buf[BUFSZ];
VA_START(s);
VA_INIT(s, const char *);
@@ -1445,4 +1463,4 @@ GetConsoleHwnd(void)
return hwndFound;
}
# endif /*CHANGE_COLOR*/
#endif /* WIN32CON */
#endif /* WIN32 */

169
sys/winnt/stubs.c Normal file
View File

@@ -0,0 +1,169 @@
#include "hack.h"
#ifdef GUISTUB
# ifdef TTYSTUB
# error You can't compile this with both GUISTUB and TTYSTUB defined.
# endif
int GUILaunched;
struct window_procs mswin_procs = {"guistubs"};
void
mswin_destroy_reg()
{
return;
}
/* MINGW32 has trouble with both a main() and WinMain()
* so we move main for the MINGW tty version into this stub
* so that it is out of sight for the gui linkage.
*/
# ifdef __MINGW32__
extern char default_window_sys[];
int
main(argc,argv)
int argc;
char *argv[];
{
boolean resuming;
sys_early_init();
Strcpy(default_window_sys, "tty");
resuming = pcmain(argc,argv);
moveloop(resuming);
nethack_exit(EXIT_SUCCESS);
/*NOTREACHED*/
return 0;
}
# endif
#endif /* GUISTUB */
/* =============================================== */
#ifdef TTYSTUB
#include "hack.h"
int GUILaunched;
struct window_procs tty_procs = {"ttystubs"};
void
win_tty_init(dir)
int dir;
{
return;
}
void
nttty_open(mode)
int mode;
{
return;
}
void
xputc(ch)
char ch;
{
return;
}
void
xputs(s)
const char *s;
{
return;
}
void
raw_clear_screen()
{
return;
}
void
clear_screen()
{
return;
}
void
backsp()
{
return;
}
int
has_color(int color)
{
return 1;
}
#ifndef NO_MOUSE_ALLOWED
void
toggle_mouse_support()
{
return;
}
#endif
#ifdef PORT_DEBUG
void
win32con_debug_keystrokes()
{
return;
}
void
win32con_handler_info()
{
return;
}
#endif
void
map_subkeyvalue(op)
register char *op;
{
return;
}
void
load_keyboard_handler()
{
return;
}
/* this is used as a printf() replacement when the window
* system isn't initialized yet
*/
void
msmsg VA_DECL(const char *, fmt)
VA_START(fmt);
VA_INIT(fmt, const char *);
VA_END();
return;
}
/*VARARGS1*/
void
nttty_error VA_DECL(const char *,s)
VA_START(s);
VA_INIT(s, const char *);
VA_END();
return;
}
void
synch_cursor()
{
return;
}
void more()
{
return;
}
#endif /* TTYSTUBS */

View File

@@ -1,6 +1,6 @@
/* NetHack 3.5 winnt.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 winnt.c $NHDT-Date: 1429675609 2015/04/22 04:06:49 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.22 $ */
/* NetHack 3.5 winnt.c $Date: 2012/01/15 19:11:41 $ $Revision: 1.18 $ */
/* SCCS Id: @(#)winnt.c 3.5 $NHDT-Date$ */
/* SCCS Id: @(#)winnt.c 3.5 $NHDT-Date: 1429675610 2015/04/22 04:06:50 $ */
/* SCCS Id: @(#)winnt.c 3.5 $Date: 2012/01/15 19:11:41 $ */
/* Copyright (c) NetHack PC Development Team 1993, 1994 */
/* NetHack may be freely redistributed. See license for details. */
@@ -20,9 +20,7 @@
#endif
#include <ctype.h>
#include "win32api.h"
#ifdef WIN32CON
#include "wintty.h"
#endif
#ifdef WIN32
@@ -200,7 +198,7 @@ return &szFullPath[0];
}
# endif
#ifndef WIN32CON
/* fatal error */
/*VARARGS1*/
void
@@ -223,21 +221,17 @@ error VA_DECL(const char *,s)
VA_END();
exit(EXIT_FAILURE);
}
#endif
void Delay(int ms)
{
(void)Sleep(ms);
}
#ifdef WIN32CON
extern void NDECL(backsp);
#endif
void win32_abort()
{
if (wizard) {
# ifdef WIN32CON
int c, ci, ct;
if (!iflags.window_inited)
@@ -260,7 +254,6 @@ void win32_abort()
}
if (c == 'y')
DebugBreak();
# endif
}
abort();
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 makedefs.c $NHDT-Date: 1425083082 2015/02/28 00:24:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */
/* NetHack 3.5 makedefs.c $NHDT-Date: 1429675627 2015/04/22 04:07:07 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.91 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
/* Copyright (c) Dean Luick, 1990. */
@@ -1331,10 +1331,8 @@ static const char *build_opts[] = {
# ifdef SCREEN_VGA
"screen control via VGA graphics",
# endif
# ifndef MSWIN_GRAPHICS
# ifdef WIN32CON
# ifdef WIN32CON
"screen control via WIN32 console I/O",
# endif
# endif
#endif
#ifdef SHELL

View File

@@ -1,4 +1,4 @@
/* NetHack 3.5 wintty.c $NHDT-Date: 1428828474 2015/04/12 08:47:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.85 $ */
/* NetHack 3.5 wintty.c $NHDT-Date: 1429675638 2015/04/22 04:07:18 $ $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.90 $ */
/* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
@@ -111,7 +111,7 @@ struct window_procs tty_procs = {
tty_start_screen,
tty_end_screen,
genl_outrip,
#if defined(WIN32CON)
#if defined(WIN32)
nttty_preference_update,
#else
genl_preference_update,
@@ -2906,7 +2906,7 @@ int dir;
{
if(dir != WININIT) return;
# if defined(WIN32CON)
nttty_open();
if (!strncmpi(windowprocs.name, "tty", 3)) nttty_open(0);
# endif
return;
}