]> granicus.if.org Git - nethack/commitdiff
build both tty NetHack.exe and gui NetHackW.exe
authornhmall <mjnh@persona.ca>
Wed, 22 Apr 2015 04:07:46 +0000 (00:07 -0400)
committernhmall <mjnh@persona.ca>
Wed, 22 Apr 2015 04:07:46 +0000 (00:07 -0400)
 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.

19 files changed:
include/config.h
include/extern.h
include/flag.h
include/global.h
include/ntconf.h
include/wintty.h
src/cmd.c
src/files.c
src/options.c
sys/share/pcmain.c
sys/share/pcsys.c
sys/share/pcunix.c
sys/winnt/Makefile.gcc
sys/winnt/Makefile.msc
sys/winnt/nttty.c
sys/winnt/stubs.c [new file with mode: 0644]
sys/winnt/winnt.c
util/makedefs.c
win/tty/wintty.c

index 5fc3d0d8fd1c297e0b2fe83fb869615600aaea10..d633286bae7cfaa26480366589a90d01e054afe8 100644 (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. */
 #endif
 
 #ifdef MSWIN_GRAPHICS
-# ifdef TTY_GRAPHICS
-# undef TTY_GRAPHICS
-# endif
 # ifndef DEFAULT_WINDOW_SYS
 #  define DEFAULT_WINDOW_SYS "mswin"
 # endif
index b6d6d407bd34bcae09582e1c59739bfe32adbb0a..fe808d110e05cf72a4467b723377743610481bd4 100644 (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 *));
index 1bbf5ff2a70054c042234737de30676da43e75a3..902ec9cadc0e08969455924829137c82aba0ad41 100644 (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
index 50479b97e84188fae41e9e200b8f9bf9c3614baa..9c9b0338f2faa8a869c43f391f66675bf7b4774d 100644 (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
index 826e36b66ba5c56a6fb16c97bfec5dac6a83ec9b..d67ad677e5140f79455934d19e0cb83d0e056e55 100644 (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. */
 
 #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
 
 /*
  * -----------------------------------------------------------------
 #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 */
index 76007ed3fc65eba5c76880cdc9d241f0d6eba145..e1a8a82e28c76c0ea62b010ac7a1768434ca5e72 100644 (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
index 24b1791c5c567ac13e851301ab86ad3788fb5d2d..4565424fdaf22a309581cfacf86fb7a57e14914e 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -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 */
        };
index 57ed8ef1b177b28604a46c3add0c99f1e98f625e..c3aacb9af761e0b8fb7c3f7a3d79f5fc3274a1ee 100644 (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;
index 2354f1b03997080b2e6a8ca3805c626a4b6a889b..1b5c6bca046d0e7f822a4c78f7905b8e31e2bec0 100644 (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");
index 8e54f078ac41b67130ba01bb3f8b9075db21ecae..788525783d1facb78724f9314d339d9ae301c4b2 100644 (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];
 
index 6aea59998dce5e5d31819b98376bb8546b3c9b0f..d839768381e413fcac8d0f91343bc16ad4ff4e20 100644 (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.
index e5ce95e8911afe51cfa19e1c567cb9fed85003f8..1f7c44576ac9020f59f88f1885a06950dcb05399 100644 (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 {
index e08ace82eead8c1881fc6075af670e224688e7e1..73618e48c6f0b251661fd2b26ac359152cd1caa3 100644 (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.
 #   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
 #
 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 ==================
+#==========================================
+
+.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 $< $@
 
-GAMEFILE = $(GAMEDIR)/$(GAME).exe
+#==========================================
+# 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 \
index 3a5bc767c4e2696e234ed44864adf5776dab26be..7a5efaad8e56ba0948901b2717c55cc01c2404f9 100644 (file)
@@ -1,4 +1,4 @@
-# NetHack 3.5  Makefile.msc    $NHDT-Date: 1428973004 2015/04/14 00:56:44 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.84 $ */
+# NetHack 3.5  Makefile.msc    $NHDT-Date: 1429675607 2015/04/22 04:06:47 $  $NHDT-Branch: win32-x64-working $:$NHDT-Revision: 1.87 $ */
 #       Copyright (c) NetHack PC Development Team 1993-2015
 #
 #==============================================================================
 #   This is used for building two versions of NetHack:
 #
 #   A tty port utilizing the Win32 Console I/O subsystem, Console
-#       NetHack;
+#       NetHack.exe
 #
 #   A Win32 native port built on the Windows API, Graphical NetHack or
-#       NetHackW.
+#       NetHackW.exe
 #
 #       In addition to your C compiler,
 #
 #   If you have any questions read the sys/winnt/Install.nt file included 
 #   with the distribution.
 #==============================================================================
-#==============================================================================
-# This section is used to determine the version of Visual Studio we are using.
-# We set VSVER to 0000 to flag any version that is too old or untested.
+# Before we get started, this section is used to determine the version of 
+# Visual Studio we are using.  We set VSVER to 0000 to flag any version that 
+# is too old or untested.
 #
+
 !IF "$(_NMAKE_VER)" == "14.00.22310.1"
 VSVER=2015
 !ELSEIF "$(_NMAKE_VER)" == "12.00.21005.1"
@@ -43,21 +44,28 @@ VSVER=2010
 !ELSE
 VSVER=0000             #untested version
 !ENDIF
-#
+
 #==============================================================================
 # BUILD DECISIONS SECTION
 #
-# 1. 32-bit or 64-bit?
+# 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? (comment/uncomment appropriate TARGET_CPU line)
+#
+
 !IF ($(VSVER) >= 2013)
-# Set your desired target to x86 (32-bit) or x64 (64-bit) here by
-# uncommenting the appropriate target size.
 #
 # 64 bit
 #TARGET_CPU=x64
 #
 # 32 bit
 TARGET_CPU=x86
+
 !ELSE
 # For VS2010 use "setenv /x86" or "setenv /x64" before invoking make process
 # DO NOT DELETE THE FOLLOWING LINE
@@ -65,27 +73,19 @@ TARGET_CPU=x86
 !ENDIF
 #
 #---------------------------------------------------------------
-# 2. Graphical version or command line version?
-#
-# Graphical interface
-# Uncomment below to set to Y for a graphical 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)?
 #
 
 GAMEDIR = ..\binary               # Game directory
 
 #
 #---------------------------------------------------------------
-# 4. Do you want debug information in the executable?
+# 3. Do you want debug information in the executable?
 #
-
+  
 DEBUGINFO = Y
 
+#==============================================================================
 # This marks the end of the BUILD DECISIONS section.
 #==============================================================================
 #
@@ -99,15 +99,12 @@ DEBUGINFO = Y
 #                                              #
 ################################################
 
+#
+#==============================================================================
+
 #  Set the gamedir according to your preference.  
 #  If not present prior to compilation it gets created.
 
-!IF "$(GRAPHICAL)" == "Y"
-GAME    = NetHackW                # Game Name
-!ELSE
-GAME    = NetHack                 # Game Name
-!ENDIF
-
 #
 #  Source directories.    Makedefs hardcodes these, don't change them.
 #
@@ -120,7 +117,7 @@ SRC   = ..\src       # Main source
 SSYS  = ..\sys\share # Shared system files
 MSWSYS= ..\sys\winnt # mswin specific files
 TTY   = ..\win\tty   # window port files (tty)
-WIN32 = ..\win\win32 # window port files (Win32)
+MSWIN = ..\win\win32 # window port files (WIN32)
 WSHR  = ..\win\share # Tile support files 
 
 #
@@ -133,63 +130,6 @@ cc=cl
 link=link
 rc=Rc
 
-#
-#=============================================
-# Visual Studio versions >= 2013 specific stuff
-#=============================================
-
-!IF "$(TARGET_CPU)" == ""
-TARGET_CPU=x86
-!ENDIF
-
-# Common compiler flags:
-#   -c   - compile without linking
-#   -W3  - Set warning level to level 3    (-W4 for 64-bit compilations)
-#   -Zi  - generate debugging information
-#   -Od  - disable all optimizations
-#   -Ox  - use maximum optimizations
-#   -Zd  - generate only public symbols and line numbers for debugging
-#   -GS  - enable security checks
-#
-ccommon=-c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -c
-lflags=/INCREMENTAL:NO /NOLOGO
-
-!IF "$(TARGET_CPU)" == "x86"
-cflags = $(ccommon) -D_X86_=1  -DWIN32 -D_WIN32 -W3
-scall  = -Gz
-
-!ELSEIF "$(TARGET_CPU)" == "x64"
-cflags = $(ccommon) -D_AMD64_=1 -DWIN64 -D_WIN64  -DWIN32 -D_WIN32
-cflags = $(cflags) -W4
-scall  =
-!ENDIF
-
-# declarations for use on Intel x86 systems
-!IF "$(TARGET_CPU)" == "x86"
-DLLENTRY = @12
-!ENDIF
-
-# declarations for use on AMD64 systems
-!IF "$(TARGET_CPU)" == "x64"
-DLLENTRY =
-!ENDIF
-
-# for Windows applications
-conlflags = $(lflags) -subsystem:console,$(EXEVER)
-guilflags = $(lflags) -subsystem:windows,$(EXEVER)
-dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll
-
-# basic subsystem specific libraries, less the C Run-Time
-baselibs    = kernel32.lib $(optlibs) $(winsocklibs) advapi32.lib
-winlibs     = $(baselibs) user32.lib gdi32.lib comdlg32.lib winspool.lib
-
-# for Windows applications that use the C Run-Time libraries
-conlibs     = $(baselibs)
-guilibs     = $(winlibs)
-#
-# End of VS2013 and greater stuff
-#=============================================
-
 #
 #==========================================
 # Exe File Info.
@@ -204,50 +144,7 @@ guilibs     = $(winlibs)
 RANDOM = $(OBJ)\random.o
 #RANDOM        =
 
-PRECOMPHEAD = N                        # set to Y if you want to use precomp. headers
-
-#
-# If you defined ZLIB_COMP in include/config.h and you need
-# to link with the zlib.lib library, uncomment the line below.
-# If necessary, prefix explicit path information to the file name
-# otherwise it assumes the NetHack src directory.
-#
-
-#ZLIB = zlib.lib
-
-!IF "$(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
-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
-WINDLLS =
-WINPFLAG= -DTILES -DMSWIN_GRAPHICS
-NHRES  = $(O)winhack.res
-WINPINC        = -I$(WIN32)
-COMCTRL = comctl32.lib
-!ELSE
-WINPORT        = $(O)nttty.o    
-WINPHDR        =
-WINDLLS        = $(GAMEDIR)\nhdefkey.dll $(GAMEDIR)\nh340key.dll $(GAMEDIR)\nhraykey.dll
-WINPFLAG= -DWIN32CON
-NHRES  = $(O)console.res
-WINPINC        =
-COMCTRL = 
-!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
 
 # To store all the level files,
 # help files, etc. in a single library file.
@@ -261,6 +158,15 @@ DLBFLG = -DDLB
 DLBFLG =
 ! ENDIF
 
+#
+# If you defined ZLIB_COMP in include/config.h and you need
+# to link with the zlib.lib library, uncomment the line below.
+# If necessary, prefix explicit path information to the file name
+# otherwise it assumes the NetHack src directory.
+#
+
+#ZLIB = zlib.lib
+
 #==========================================
 #==========================================
 # Setting up the compiler and linker
@@ -322,11 +228,13 @@ cflags = $(cflags:-W4=-W3)
 # declarations for use on Intel x86 systems
 !IF "$(TARGET_CPU)" == "x86"
 DLLENTRY = @12
+EXEVER=5.01
 !ENDIF
 
 # declarations for use on AMD64 systems
 !IF "$(TARGET_CPU)" == "x64"
 DLLENTRY =
+EXEVER=5.02
 !ENDIF
 
 # for Windows applications
@@ -349,108 +257,21 @@ INCLDIR= /I..\include
 # Util builds
 #==========================================
 
-cflagsUtil = $(cflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG)
-lflagsUtil = $(lflags) $(conlibs)
+cflagsBuild = $(cflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG)
+lflagsBuild = $(lflags) $(conlibs)
 
 #==========================================
 # - Game build
 #==========================================
 
-GAMEPDBFILE= /PDB:"$(O)$(GAME).PDB"
-GAMEMAPFILE= /MAP:"$(O)$(GAME).MAP"
 LIBS= user32.lib winmm.lib $(ZLIB)
 
-!IF ("$(GRAPHICAL)"=="Y")
-
-cflagsGame = $(cflags) $(guiflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG)
-lflagsGame = $(lflags) $(guilibs) $(GAMEPDBFILE) $(GAMEMAPFILE)
-
-!ELSE
-
-cflagsGame = $(cflags) $(conflags) $(INCLDIR) $(WINPFLAG) $(DLBFLG)
-lflagsGame = $(lflags) $(conlibs) $(GAMEPDBFILE) $(GAMEMAPFILE)
-
-!ENDIF
-
-GAMEFILE = $(GAMEDIR)\$(GAME).exe # whole thing
-
 ! IF ("$(USE_DLB)"=="Y")
 DLB = nhdat
 ! ELSE
 DLB =
 ! ENDIF
 
-#==========================================
-#================ RULES ==================
-#==========================================
-
-.SUFFIXES: .exe .o .til .uu .c .y .l
-
-#==========================================
-# Rules for files in src
-#==========================================
-
-.c{$(OBJ)}.o:
-        @$(cc) $(cflagsUtil)  -Fo$@ $<
-
-{$(SRC)}.c{$(OBJ)}.o:
-        @$(CC) $(cflagsUtil)   -Fo$@  $<
-
-#==========================================
-# Rules for files in sys\share
-#==========================================
-
-{$(SSYS)}.c{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil)  -Fo$@  $<
-
-{$(SSYS)}.cpp{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil)  -Fo$@  $<
-
-#==========================================
-# Rules for files in sys\winnt
-#==========================================
-
-{$(MSWSYS)}.c{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil)  -Fo$@  $<
-
-{$(MSWSYS)}.h{$(INCL)}.h:
-       @copy $< $@
-
-#==========================================
-# Rules for files in util
-#==========================================
-
-{$(UTIL)}.c{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil) -Fo$@ $<
-
-#==========================================
-# Rules for files in win\share
-#==========================================
-
-{$(WSHR)}.c{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil)  -Fo$@ $<
-
-{$(WSHR)}.h{$(INCL)}.h:
-       @copy $< $@
-
-#{$(WSHR)}.txt{$(DAT)}.txt:
-#      @copy $< $@
-
-#==========================================
-# Rules for files in win\tty
-#==========================================
-
-{$(TTY)}.c{$(OBJ)}.o:
-       @$(CC) $(cflagsUtil)  -Fo$@  $<
-
-
-#==========================================
-# Rules for files in win\win32
-#==========================================
-
-{$(WIN32)}.c{$(OBJ)}.o:
-       @$(cc) $(cflagsUtil)  -Fo$@  $<
-
 #==========================================
 #================ MACROS ==================
 #==========================================
@@ -531,6 +352,7 @@ VOBJ24 = $(O)track.o    $(O)trap.o     $(O)u_init.o   $(O)uhitm.o
 VOBJ25 = $(O)vault.o    $(O)vis_tab.o  $(O)vision.o   $(O)weapon.o
 VOBJ26 = $(O)were.o     $(O)wield.o    $(O)windows.o  $(O)wizard.o
 VOBJ27 = $(O)worm.o     $(O)worn.o     $(O)write.o    $(O)zap.o     
+
 DLBOBJ = $(O)dlb.o
 
 REGEX  = $(O)cppregex.o
@@ -547,17 +369,34 @@ OBJS   = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
          $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
          $(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(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
+
+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
+
+COMCTRL = comctl32.lib
+
+KEYDLLS        = $(GAMEDIR)\nhdefkey.dll $(GAMEDIR)\nh340key.dll $(GAMEDIR)\nhraykey.dll
+
+TILEUTIL16  = $(UTIL)\tile2bmp.exe
+TILEBMP16   = $(SRC)\tiles.bmp
+
+TILEUTIL32  = $(UTIL)\til2bm32.exe
+TILEBMP32   = $(SRC)\tiles32.bmp
+
+SOUND = $(OBJ)\ntsound.o
 
 VVOBJ  = $(O)version.o
 
-ALLOBJ  = $(WINPOBJ) $(SOBJ) $(DLBOBJ)  $(TTYOBJ) $(WOBJ) $(OBJS) $(VVOBJ)
+ALLOBJ  = $(SOBJ) $(DLBOBJ)  $(WOBJ) $(OBJS) $(VVOBJ)
+
+OPTIONS_FILE = $(DAT)\options
 
-!IF "$(GRAPHICAL)" == "Y"
-OPTIONS_FILE = $(DAT)\guioptions
-!ELSE
-OPTIONS_FILE = $(DAT)\ttyoptions
-!ENDIF
 #==========================================
 # Header file macros
 #==========================================
@@ -595,11 +434,76 @@ TILE_H      = ..\win\share\tile.h
 
 DATABASE = $(DAT)\data.base
 
-#
-#  The name of the game.
-#
+#==========================================
+#================ RULES ==================
+#==========================================
+
+.SUFFIXES: .exe .o .til .uu .c .y .l
+
+#==========================================
+# Rules for files in src
+#==========================================
+
+.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@ $<
+
+{$(SRC)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)   -Fo$@  $<
+
+#==========================================
+# Rules for files in sys\share
+#==========================================
 
-GAMEFILE = $(GAMEDIR)\$(GAME).exe
+{$(SSYS)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@  $<
+
+{$(SSYS)}.cpp{$(OBJ)}.o:
+       @$(CC) $(cflagsBuild) /EHsc -Fo$@  $<
+
+#==========================================
+# Rules for files in sys\winnt
+#==========================================
+
+{$(MSWSYS)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@  $<
+
+{$(MSWSYS)}.h{$(INCL)}.h:
+       @copy $< $@
+
+#==========================================
+# Rules for files in util
+#==========================================
+
+{$(UTIL)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild) -Fo$@ $<
+
+#==========================================
+# Rules for files in win\share
+#==========================================
+
+{$(WSHR)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@ $<
+
+{$(WSHR)}.h{$(INCL)}.h:
+       @copy $< $@
+
+#{$(WSHR)}.txt{$(DAT)}.txt:
+#      @copy $< $@
+
+#==========================================
+# Rules for files in win\tty
+#==========================================
+
+{$(TTY)}.c{$(OBJ)}.o:
+       $(cc) $(cflagsBuild)  -Fo$@  $<
+
+
+#==========================================
+# Rules for files in win\win32
+#==========================================
+
+{$(MSWIN)}.c{$(OBJ)}.o:
+       @$(cc) $(cflagsBuild)  -Fo$@  $<
 
 #==========================================
 #=============== TARGETS ==================
@@ -614,19 +518,15 @@ default : install
 #  The game target.
 #
 
-$(GAME): $(O)obj.tag $(O)utility.tag envchk $(GAMEFILE)
-       @echo $(GAME) is up to date.
-
 #
 #  Everything
 #
 
 all :  install
 
-install: envchk $(GAME) $(O)install.tag
+install: envchk $(O)obj.tag $(O)utility.tag $(GAMEDIR)\NetHack.exe $(GAMEDIR)\NetHackW.exe $(O)install.tag
         @echo Done.
 
-
 $(O)install.tag:       $(DAT)\data     $(DAT)\rumors    $(DAT)\dungeon \
                $(DAT)\oracles  $(DAT)\quest.dat $(O)sp_lev.tag $(DLB)
 ! IF ("$(USE_DLB)"=="Y")
@@ -693,26 +593,25 @@ $(O)sp_lev.tag: $(O)utility.tag $(DAT)\bigroom.des  $(DAT)\castle.des \
 $(O)utility.tag: $(INCL)\date.h $(INCL)\onames.h $(INCL)\pm.h \
                $(SRC)\monstr.c         $(SRC)\vis_tab.c  \
                $(U)levcomp.exe $(INCL)\vis_tab.h \
-               $(U)dgncomp.exe
+               $(U)dgncomp.exe $(TILEUTIL16)
              @echo utilities made >$@
             @echo utilities made.
 
 tileutil: $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe
        @echo Optional tile development utilities are up to date.
 
-!IF "$(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) -r -fo$@ -i$(WIN32) -dNDEBUG $(WIN32)\winhack.rc
-!ELSE
-$(NHRES): $(MSWSYS)\console.rc $(MSWSYS)\NetHack.ico
+$(O)winhack.res: $(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) -r -fo$@ -i$(MSWIN) -dNDEBUG $(MSWIN)\winhack.rc
+
+$(O)console.res: $(MSWSYS)\console.rc $(MSWSYS)\NetHack.ico
        @$(rc) -r -fo$@ -i$(MSWSYS) -dNDEBUG $(MSWSYS)\console.rc
-!ENDIF
+
 
 #==========================================
-#  The main target.
+#  The game targets.
 #==========================================
 
 #  The section for linking the NetHack image looks a little strange at 
@@ -736,16 +635,60 @@ $(NHRES): $(MSWSYS)\console.rc $(MSWSYS)\NetHack.ico
 #                       with ^ as we have done below.  Every occurence
 #                       of a <tab> in $(ALLOBJ) is replaced by 
 #                       <+><return><tab>.
+
+GAMEOBJ=$(ALLOBJ:^     =^
+)
+GAMEOBJ=$(GAMEOBJ:^ =^
+)
+
 #
 #  DO NOT INDENT THE << below!
 #
 
-$(GAMEFILE) : $(ALLOBJ) $(NHRES) $(O)gamedir.tag $(WINDLLS)
+# NetHack
+# full gui linkage libs:
+#    libs: $(LIBS) $(conlibs) $(guilibs) $(COMCTRL)
+#    objs: $(GAMEOBJ) $(TTYOBJ) $(O)nttty.o $(O)tile.o $(GUIOBJ)
+# otherwise:
+#    libs: $(LIBS) $(conlibs) 
+#    objs: $(GAMEOBJ) $(TTYOBJ) $(O)tile.o $(O)guistub.o
+
+
+$(GAMEDIR)\NetHack.exe : $(O)gamedir.tag $(O)tile.o $(O)nttty.o $(O)guistub.o \
+                       $(ALLOBJ) $(TTYOBJ) $(GUIOBJ) $(O)console.res $(KEYDLLS)
        @if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
-       @echo Linking $@
-       $(link) $(lflagsGame) /STACK:2048 $(LIBS) $(COMCTRL) -out:$@ @<<$(GAME).lnk
-               $(ALLOBJ:^      =^
-               ) $(NHRES)
+       @echo   Linking $@ ...
+       $(link) $(lflagsBuild) $(conlflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB /MAP:$(O)$(AB).MAP \
+               $(LIBS) $(conlibs) -out:$@ @<<$(@B).lnk
+               $(GAMEOBJ)
+               $(TTYOBJ)
+               $(O)nttty.o
+               $(O)tile.o
+               $(O)guistub.o
+               $(O)console.res
+<<
+       @if exist $(O)install.tag del $(O)install.tag
+       @if exist $(GAMEDIR)\$(GAME).bak del $(GAMEDIR)\$(GAME).bak
+
+# NetHackW
+# full tty linkage libs:
+#    libs: $(LIBS) $(guilibs) $(COMCTRL)
+#    objs: $(GAMEOBJ) $(GUIOBJ) $(TTYOBJ) $(O)tile.o $(O)nttty.o
+# otherwise:
+#    libs: $(LIBS) $(guilibs) $(COMCTRL)
+#    objs: $(GAMEOBJ) $(GUIOBJ) $(O)tile.o $(O)ttystub.o
+
+$(GAMEDIR)\NetHackW.exe : $(O)gamedir.tag $(O)tile.o $(O)ttystub.o \
+                       $(ALLOBJ) $(TTYOBJ) $(GUIOBJ) $(O)winhack.res $(O)gamedir.tag $(KEYDLLS)
+       @if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
+       @echo   Linking $@
+       $(link) $(lflagsBuild) $(guilflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB \
+               /MAP:$(O)$(AB).MAP $(LIBS) $(guilibs) $(COMCTRL) -out:$@ @<<$(@B).lnk
+               $(GAMEOBJ)
+               $(GUIOBJ)
+               $(O)tile.o
+               $(O)ttystub.o
+               $(O)winhack.res
 <<
        @if exist $(O)install.tag del $(O)install.tag
        @if exist $(GAMEDIR)\$(GAME).bak del $(GAMEDIR)\$(GAME).bak
@@ -821,21 +764,21 @@ $(GAMEDIR)\nhraykey.dll : $(O)$(@B).o $(O)gamedir.tag $(O)$(@B).def
 #==========================================
 $(U)nhsizes.exe: $(O)nhsizes.o
        @echo Linking $@
-       $(link) $(lflagsUtil) -out:$@ $(O)nhsizes.o $(O)panic.o $(O)alloc.o
+       $(link) $(lflagsBuild) -out:$@ $(O)nhsizes.o $(O)panic.o $(O)alloc.o
 
 $(O)nhsizes.o: $(CONFIG_H) nhsizes.c
-       @$(CC) $(cflagsUtil) -Fo$@ nhsizes.c
+       @$(cc) $(cflagsBuild) -Fo$@ nhsizes.c
 
 $(U)makedefs.exe:      $(MAKEOBJS)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(MAKEOBJS)
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(MAKEOBJS)
 
 $(O)makedefs.o: $(CONFIG_H)    $(INCL)\monattk.h $(INCL)\monflag.h   $(INCL)\objclass.h \
                 $(INCL)\monsym.h    $(INCL)\qtext.h    $(INCL)\patchlevel.h \
                 $(U)makedefs.c
        @if not exist $(OBJ)\*.* echo creating directory $(OBJ)
        @if not exist $(OBJ)\*.* mkdir $(OBJ)
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)makedefs.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)makedefs.c
 
 #
 #  date.h should be remade every time any of the source or include
@@ -877,48 +820,48 @@ $(DAT)\bogusmon: $(DAT)\bogusmon.txt $(U)makedefs.exe
 
 $(U)uudecode.exe: $(O)uudecode.o
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)uudecode.o
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)uudecode.o
 
 $(O)uudecode.o: $(SSYS)\uudecode.c
-       @$(CC) $(cflagsUtil) /D_CRT_SECURE_NO_DEPRECATE -Fo$@ $(SSYS)\uudecode.c
+       @$(cc) $(cflagsBuild) /D_CRT_SECURE_NO_DEPRECATE -Fo$@ $(SSYS)\uudecode.c
 
 $(MSWSYS)\NetHack.ico : $(U)uudecode.exe $(MSWSYS)\nhico.uu 
        chdir $(MSWSYS)
        ..\..\util\uudecode.exe nhico.uu
        chdir ..\..\src
 
-$(WIN32)\NetHack.ico : $(U)uudecode.exe $(MSWSYS)\nhico.uu 
-       chdir $(WIN32)
+$(MSWIN)\NetHack.ico : $(U)uudecode.exe $(MSWSYS)\nhico.uu 
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe ../../sys/winnt/nhico.uu
        chdir ..\..\src
 
-$(WIN32)\mnsel.bmp: $(U)uudecode.exe $(WIN32)\mnsel.uu
-       chdir $(WIN32)
+$(MSWIN)\mnsel.bmp: $(U)uudecode.exe $(MSWIN)\mnsel.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe mnsel.uu
        chdir ..\..\src
 
-$(WIN32)\mnselcnt.bmp: $(U)uudecode.exe $(WIN32)\mnselcnt.uu
-       chdir $(WIN32)
+$(MSWIN)\mnselcnt.bmp: $(U)uudecode.exe $(MSWIN)\mnselcnt.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe mnselcnt.uu
        chdir ..\..\src
 
-$(WIN32)\mnunsel.bmp: $(U)uudecode.exe $(WIN32)\mnunsel.uu
-       chdir $(WIN32)
+$(MSWIN)\mnunsel.bmp: $(U)uudecode.exe $(MSWIN)\mnunsel.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe mnunsel.uu
        chdir ..\..\src
 
-$(WIN32)\petmark.bmp: $(U)uudecode.exe $(WIN32)\petmark.uu
-       chdir $(WIN32)
+$(MSWIN)\petmark.bmp: $(U)uudecode.exe $(MSWIN)\petmark.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe petmark.uu
        chdir ..\..\src
 
-$(WIN32)\rip.bmp: $(U)uudecode.exe $(WIN32)\rip.uu
-       chdir $(WIN32)
+$(MSWIN)\rip.bmp: $(U)uudecode.exe $(MSWIN)\rip.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe rip.uu
        chdir ..\..\src
 
-$(WIN32)\splash.bmp: $(U)uudecode.exe $(WIN32)\splash.uu
-       chdir $(WIN32)
+$(MSWIN)\splash.bmp: $(U)uudecode.exe $(MSWIN)\splash.uu
+       chdir $(MSWIN)
        ..\..\util\uudecode.exe splash.uu
        chdir ..\..\src
 
@@ -933,18 +876,18 @@ $(U)lev_yacc.c $(INCL)\lev_comp.h: $(U)lev_comp.y
        nmake -nologo -f ..\win\win32\levstuff.mak default
 
 $(O)lev_yacc.o: $(HACK_H)   $(SP_LEV_H) $(INCL)\lev_comp.h $(U)lev_yacc.c
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)lev_yacc.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)lev_yacc.c
 
 $(O)lev_lex.o: $(HACK_H) $(INCL)\lev_comp.h $(SP_LEV_H) \
                $(U)lev_lex.c
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)lev_lex.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)lev_lex.c
 
 $(O)lev_main.o:        $(U)lev_main.c $(HACK_H) $(SP_LEV_H)
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)lev_main.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)lev_main.c
 
 $(U)levcomp.exe: $(LEVCOMPOBJS)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(LEVCOMPOBJS:^ =^
                )
 <<
@@ -959,18 +902,18 @@ $(U)dgn_yacc.c $(INCL)\dgn_comp.h : $(U)dgn_comp.y
        nmake -nologo -f ..\win\win32\dgnstuff.mak default
 
 $(O)dgn_yacc.o:        $(HACK_H)   $(DGN_FILE_H) $(INCL)\dgn_comp.h $(U)dgn_yacc.c
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)dgn_yacc.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)dgn_yacc.c
 
 $(O)dgn_lex.o: $(HACK_H)   $(DGN_FILE_H)  $(INCL)\dgn_comp.h \
        $(U)dgn_lex.c
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)dgn_lex.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)dgn_lex.c
 
 $(O)dgn_main.o:        $(HACK_H) $(U)dgn_main.c
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)dgn_main.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)dgn_main.c
 
 $(U)dgncomp.exe: $(DGNCOMPOBJS)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(DGNCOMPOBJS:^ =^
                )
 <<
@@ -1004,11 +947,9 @@ envchk:
 #         @echo Warning, the CL Environment variable is defined:
 #         @echo CL=$(CL)
 !      ENDIF
-!   IF "$(GRAPHICAL)"=="Y"
           @echo ----
           @echo NOTE: This build will include tile support.
           @echo ----
-!      ENDIF
 
 #==========================================
 #=========== SECONDARY TARGETS ============
@@ -1028,7 +969,7 @@ $(INCL)\win32api.h: $(MSWSYS)\win32api.h
 
 $(U)dlb_main.exe: $(DLBOBJ) $(O)dlb.o
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(O)dlb_main.o
                $(O)dlb.o
                $(O)alloc.o
@@ -1036,10 +977,10 @@ $(U)dlb_main.exe: $(DLBOBJ) $(O)dlb.o
 <<
 
 $(O)dlb.o:     $(O)dlb_main.o $(O)alloc.o $(O)panic.o $(INCL)\dlb.h
-       @$(CC) $(cflagsUtil) /Fo$@ $(SRC)\dlb.c
+       @$(cc) $(cflagsBuild) /Fo$@ $(SRC)\dlb.c
        
 $(O)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h
-       @$(CC) $(cflagsUtil) /Fo$@ $(UTIL)\dlb_main.c
+       @$(cc) $(cflagsBuild) /Fo$@ $(UTIL)\dlb_main.c
 
 $(DAT)\porthelp: $(MSWSYS)\porthelp
        @copy $(MSWSYS)\porthelp $@ >nul
@@ -1047,7 +988,7 @@ $(DAT)\porthelp: $(MSWSYS)\porthelp
 nhdat: $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \
        $(DAT)\quest.dat $(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp \
        $(DAT)\history $(DAT)\opthelp $(DAT)\wizhelp $(DAT)\dungeon $(DAT)\porthelp \
-       $(DAT)\license $(DAT)\engrave $(DAT)\epitaph $(DAT)\bogusmon $(DAT)\tribute $(O)sp_lev.tag
+       $(DAT)\license $(DAT)\engrave $(DAT)\epitaph $(DAT)\bogusmon $(O)sp_lev.tag
        cd $(DAT)
        echo data >dlb.lst
        echo oracles >>dlb.lst
@@ -1060,7 +1001,6 @@ nhdat:    $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \
        echo engrave >>dlb.lst
        echo epitaph >>dlb.lst
        echo bogusmon >>dlb.lst
-       echo tribute >>dlb.lst
        echo help >>dlb.lst
        echo hh >>dlb.lst
        echo cmdhelp >>dlb.lst
@@ -1079,10 +1019,10 @@ nhdat:  $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \
 
 $(U)recover.exe: $(RECOVOBJS)
        @echo Linking $@
-       $(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(RECOVOBJS)
+       $(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(RECOVOBJS)
 
 $(O)recover.o: $(CONFIG_H) $(U)recover.c $(INCL)\win32api.h
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)recover.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)recover.c
 
 #==========================================
 #  Tile Mapping
@@ -1094,31 +1034,31 @@ $(SRC)\tile.c: $(U)tilemap.exe
 
 $(U)tilemap.exe: $(O)tilemap.o
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)tilemap.o
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)tilemap.o
 
 $(O)tilemap.o: $(WSHR)\tilemap.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ $(WSHR)\tilemap.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(WSHR)\tilemap.c
 
 $(O)tiletx32.o: $(WSHR)\tilemap.c $(HACK_H)
-       @$(CC) $(cflagsUtil) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c
+       @$(cc) $(cflagsBuild) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c
 
 $(O)tiletxt.o: $(WSHR)\tilemap.c $(HACK_H)
-       @$(CC) $(cflagsUtil) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c
+       @$(cc) $(cflagsBuild) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c
 
 $(O)gifread.o: $(WSHR)\gifread.c  $(CONFIG_H) $(TILE_H)
-       @$(CC) $(cflagsUtil) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c
 
 $(O)gifrd32.o: $(WSHR)\gifread.c  $(CONFIG_H) $(TILE_H)
-       @$(CC) $(cflagsUtil) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c
 
 $(O)ppmwrite.o: $(WSHR)\ppmwrite.c $(CONFIG_H) $(TILE_H)
-       @$(CC) $(cflagsUtil) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c
 
 $(O)tiletext.o: $(WSHR)\tiletext.c  $(CONFIG_H) $(TILE_H)
-       @$(CC) $(cflagsUtil) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c
 
 $(O)tilete32.o: $(WSHR)\tiletext.c  $(CONFIG_H) $(TILE_H)
-       @$(CC) $(cflagsUtil) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c
 
 #==========================================
 # Optional Tile Utilities
@@ -1126,7 +1066,7 @@ $(O)tilete32.o: $(WSHR)\tiletext.c  $(CONFIG_H) $(TILE_H)
 
 $(U)gif2txt.exe: $(GIFREADERS) $(TEXT_IO)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(GIFREADERS:^  =^
                )
                $(TEXT_IO:^     =^
@@ -1135,7 +1075,7 @@ $(U)gif2txt.exe: $(GIFREADERS) $(TEXT_IO)
 
 $(U)gif2tx32.exe: $(GIFREADERS32) $(TEXT_IO32)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(GIFREADERS32:^        =^
                )
                $(TEXT_IO32:^   =^
@@ -1144,14 +1084,13 @@ $(U)gif2tx32.exe: $(GIFREADERS32) $(TEXT_IO32)
 
 $(U)txt2ppm.exe: $(PPMWRITERS) $(TEXT_IO)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(PPMWRITERS:^  =^
                )
                $(TEXT_IO:^     =^
                )
 <<
 
-!IF "$(GRAPHICAL)"=="Y"
 $(TILEBMP16): $(TILEUTIL16) $(TILEFILES)
        @echo Creating 16x16 binary tile files (this may take some time)
        @$(U)tile2bmp $(TILEBMP16)
@@ -1159,14 +1098,10 @@ $(TILEBMP16): $(TILEUTIL16) $(TILEFILES)
 #      @echo Creating 32x32 binary tile files (this may take some time)
 #      @$(U)til2bm32 $(TILEBMP32)
 
-!ELSE
-$(TILEBMP16):
-$(TILEBMP32):
-!ENDIF
 
 $(U)tile2bmp.exe: $(O)tile2bmp.o $(TEXT_IO)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(O)tile2bmp.o
                $(TEXT_IO:^  =^
                )
@@ -1174,17 +1109,17 @@ $(U)tile2bmp.exe: $(O)tile2bmp.o $(TEXT_IO)
 
 $(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32)
        @echo Linking $@
-       @$(link) $(lflagsUtil) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
+       @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ @<<$(@B).lnk
                $(O)til2bm32.o
                $(TEXT_IO32:^  =^
                )
 <<
 
 $(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
-       @$(CC) $(cflagsUtil) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c
 
 $(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
-       @$(CC) $(cflagsUtil) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c
 
 #==========================================
 # Housekeeping
@@ -1305,10 +1240,8 @@ clean:
        rem
        nmake -nologo -f ..\win\win32\dgnstuff.mak clean
 
-! IF ("$(WINPFLAG)"!="")
        if exist $(TILEBMP16)        del $(TILEBMP16)
        if exist $(TILEBMP32)        del $(TILEBMP32)
-! ENDIF
 
 #===================================================================
 # OTHER DEPENDENCIES
@@ -1341,27 +1274,37 @@ $(DAT)\dungeon: $(O)utility.tag  $(DAT)\dungeon.def
 #
 
 $(O)nttty.o:   $(HACK_H) $(TILE_H) $(INCL)\win32api.h $(MSWSYS)\nttty.c
-       @$(CC) $(cflagsUtil) -I$(WSHR) -Fo$@  $(MSWSYS)\nttty.c
-$(O)nhkeys.o:   $(HACK_H) $(TILE_H) $(INCL)\win32api.h $(MSWSYS)\nhkeys.c
-       @$(CC) $(cflagsUtil) -I$(WSHR) -Fo$@  $(MSWSYS)\nhkeys.c
+       @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@  $(MSWSYS)\nttty.c
 $(O)winnt.o: $(HACK_H) $(INCL)\win32api.h $(MSWSYS)\winnt.c
-       @$(CC) $(cflagsUtil) -Fo$@  $(MSWSYS)\winnt.c
+       @$(cc) $(cflagsBuild) -Fo$@  $(MSWSYS)\winnt.c
 $(O)ntsound.o: $(HACK_H) $(MSWSYS)\ntsound.c
-       @$(CC) $(cflagsUtil)  -Fo$@ $(MSWSYS)\ntsound.c
+       @$(cc) $(cflagsBuild)  -Fo$@ $(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) $(cflagsBuild) -DGUISTUB -Fo$@ $(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)\ttystubs.c
+       @$(cc) $(cflagsBuild) -DTTYSTUB -Fo$@ $(MSWSYS)\stubs.c
 
 # 
 # util dependencies
 #
 
 $(O)panic.o:  $(U)panic.c $(CONFIG_H)
-       @$(CC) $(cflagsUtil) -Fo$@ $(U)panic.c
+       @$(cc) $(cflagsBuild) -Fo$@ $(U)panic.c
 
 # 
 # sys/share dependencies
 #
 
 (O)cppregex.o: $(O)cppregex.cpp $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\cppregex.cpp
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\cppregex.cpp
 
 #
 # The rest are stolen from sys/unix/Makefile.src, 
@@ -1369,7 +1312,7 @@ $(O)panic.o:  $(U)panic.c $(CONFIG_H)
 #   * ../include changed to $(INCL)
 #   * slashes changed to back-slashes 
 #   * -c (which is included in CFLAGS) substituted with -Fo$@
-#   * $(CFLAGS) replaced with $(cFlagsUtil)
+#   * $(CFLAGS) replaced with $(cflagsBuild)
 #   * $(CC) replaced with @$(CC)
 #   * targets prefixed with $(O)
 #   * the single win32api.h reference uncommented
@@ -1379,115 +1322,115 @@ $(O)panic.o:  $(U)panic.c $(CONFIG_H)
 #
 
 $(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\atari\tos.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c
 $(O)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h \
                $(INCL)\win32api.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\pcmain.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcmain.c
 $(O)pcsys.o: ..\sys\share\pcsys.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\pcsys.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcsys.c
 $(O)pctty.o: ..\sys\share\pctty.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\pctty.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c
 $(O)pcunix.o: ..\sys\share\pcunix.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\pcunix.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcunix.c
 $(O)random.o: ..\sys\share\random.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\random.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\random.c
 $(O)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\ioctl.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\ioctl.c
 $(O)unixtty.o: ..\sys\share\unixtty.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\share\unixtty.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\unixtty.c
 $(O)unixmain.o: ..\sys\unix\unixmain.c $(HACK_H) $(INCL)\dlb.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\unix\unixmain.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixmain.c
 $(O)unixunix.o: ..\sys\unix\unixunix.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\unix\unixunix.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixunix.c
 $(O)unixres.o: ..\sys\unix\unixres.c $(CONFIG_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\unix\unixres.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixres.c
 $(O)bemain.o: ..\sys\be\bemain.c $(HACK_H) $(INCL)\dlb.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\sys\be\bemain.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\sys\be\bemain.c
 $(O)getline.o: ..\win\tty\getline.c $(HACK_H) $(INCL)\func_tab.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\getline.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\getline.c
 $(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\termcap.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\termcap.c
 $(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\topl.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\topl.c
 $(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h $(INCL)\tcap.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\tty\wintty.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\wintty.c
 $(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \
                $(CONFIG_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\Window.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\Window.c
 $(O)dialogs.o: ..\win\X11\dialogs.c $(CONFIG_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\dialogs.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\dialogs.c
 $(O)winX.o: ..\win\X11\winX.c $(HACK_H) $(INCL)\winX.h $(INCL)\dlb.h \
                ..\win\X11\nh72icon ..\win\X11\nh56icon ..\win\X11\nh32icon
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winX.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winX.c
 $(O)winmap.o: ..\win\X11\winmap.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\dlb.h \
                $(INCL)\winX.h $(INCL)\tile2x11.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winmap.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmap.c
 $(O)winmenu.o: ..\win\X11\winmenu.c $(HACK_H) $(INCL)\winX.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winmenu.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmenu.c
 $(O)winmesg.o: ..\win\X11\winmesg.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\winX.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winmesg.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmesg.c
 $(O)winmisc.o: ..\win\X11\winmisc.c $(HACK_H) $(INCL)\func_tab.h \
                $(INCL)\winX.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winmisc.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmisc.c
 $(O)winstat.o: ..\win\X11\winstat.c $(HACK_H) $(INCL)\winX.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winstat.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winstat.c
 $(O)wintext.o: ..\win\X11\wintext.c $(HACK_H) $(INCL)\winX.h $(INCL)\xwindow.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\wintext.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\wintext.c
 $(O)winval.o: ..\win\X11\winval.c $(HACK_H) $(INCL)\winX.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\X11\winval.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winval.c
 $(O)tile.o: $(SRC)\tile.c $(HACK_H)
 $(O)gnaskstr.o: ..\win\gnome\gnaskstr.c ..\win\gnome\gnaskstr.h \
                ..\win\gnome\gnmain.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnaskstr.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnaskstr.c
 $(O)gnbind.o: ..\win\gnome\gnbind.c ..\win\gnome\gnbind.h ..\win\gnome\gnmain.h \
                ..\win\gnome\gnmenu.h ..\win\gnome\gnaskstr.h \
                ..\win\gnome\gnyesno.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnbind.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnbind.c
 $(O)gnglyph.o: ..\win\gnome\gnglyph.c ..\win\gnome\gnglyph.h $(INCL)\tile2x11.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnglyph.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnglyph.c
 $(O)gnmain.o: ..\win\gnome\gnmain.c ..\win\gnome\gnmain.h ..\win\gnome\gnsignal.h \
                ..\win\gnome\gnbind.h ..\win\gnome\gnopts.h $(HACK_H) \
                $(INCL)\date.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmain.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmain.c
 $(O)gnmap.o: ..\win\gnome\gnmap.c ..\win\gnome\gnmap.h ..\win\gnome\gnglyph.h \
                ..\win\gnome\gnsignal.h $(HACK_H)
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmap.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmap.c
 $(O)gnmenu.o: ..\win\gnome\gnmenu.c ..\win\gnome\gnmenu.h ..\win\gnome\gnmain.h \
                ..\win\gnome\gnbind.h $(INCL)\func_tab.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmenu.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmenu.c
 $(O)gnmesg.o: ..\win\gnome\gnmesg.c ..\win\gnome\gnmesg.h ..\win\gnome\gnsignal.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmesg.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmesg.c
 $(O)gnopts.o: ..\win\gnome\gnopts.c ..\win\gnome\gnopts.h ..\win\gnome\gnglyph.h \
                ..\win\gnome\gnmain.h ..\win\gnome\gnmap.h $(HACK_H)
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnopts.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnopts.c
 $(O)gnplayer.o: ..\win\gnome\gnplayer.c ..\win\gnome\gnplayer.h \
                ..\win\gnome\gnmain.h $(HACK_H)
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnplayer.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnplayer.c
 $(O)gnsignal.o: ..\win\gnome\gnsignal.c ..\win\gnome\gnsignal.h \
                ..\win\gnome\gnmain.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnsignal.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnsignal.c
 $(O)gnstatus.o: ..\win\gnome\gnstatus.c ..\win\gnome\gnstatus.h \
                ..\win\gnome\gnsignal.h ..\win\gnome\gn_xpms.h \
                ..\win\gnome\gnomeprv.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnstatus.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnstatus.c
 $(O)gntext.o: ..\win\gnome\gntext.c ..\win\gnome\gntext.h ..\win\gnome\gnmain.h \
                ..\win\gnome\gn_rip.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gntext.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gntext.c
 $(O)gnyesno.o: ..\win\gnome\gnyesno.c ..\win\gnome\gnbind.h ..\win\gnome\gnyesno.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnyesno.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnyesno.c
 $(O)gnworn.o: ..\win\gnome\gnworn.c ..\win\gnome\gnworn.h ..\win\gnome\gnglyph.h \
                ..\win\gnome\gnsignal.h ..\win\gnome\gnomeprv.h
-       @$(CC) $(cflagsUtil) $(GNOMEINC) -Fo$@ ..\win\gnome\gnworn.c
+       @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnworn.c
 $(O)wingem.o: ..\win\gem\wingem.c $(HACK_H) $(INCL)\func_tab.h $(INCL)\dlb.h \
                $(INCL)\patchlevel.h $(INCL)\wingem.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\gem\wingem.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem.c
 $(O)wingem1.o: ..\win\gem\wingem1.c $(INCL)\gem_rsc.h $(INCL)\load_img.h \
                $(INCL)\gr_rect.h $(INCL)\wintype.h $(INCL)\wingem.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\gem\wingem1.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem1.c
 $(O)load_img.o: ..\win\gem\load_img.c $(INCL)\load_img.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\gem\load_img.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\load_img.c
 $(O)gr_rect.o: ..\win\gem\gr_rect.c $(INCL)\gr_rect.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\gem\gr_rect.c
+       @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\gr_rect.c
 $(O)tile.o: $(SRC)\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 \
@@ -1499,11 +1442,11 @@ $(O)qt_clust.o: ..\win\Qt\qt_clust.cpp $(INCL)\qt_clust.h
 $(O)qttableview.o: ..\win\Qt\qttableview.cpp $(INCL)\qttableview.h
        $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qttableview.cpp
 $(O)wc_chainin.o: ..\win\chain\wc_chainin.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\chain\wc_chainin.c
+       @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainin.c
 $(O)wc_chainout.o: ..\win\chain\wc_chainout.c $(HACK_H)
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\chain\wc_chainout.c
+       @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainout.c
 $(O)wc_trace.o: ..\win\chain\wc_trace.c $(HACK_H) $(INCL)\func_tab.h
-       @$(CC) $(cflagsUtil) -Fo$@ ..\win\chain\wc_trace.c
+       @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_trace.c
 $(O)monstr.o: monstr.c $(CONFIG_H)
 $(O)vis_tab.o: vis_tab.c $(CONFIG_H) $(INCL)\vis_tab.h
 $(O)allmain.o: allmain.c $(HACK_H)
index 9b9b186bc1035d45bb7390ff593eeabeb3c67945..7fc2885e6128dc9c421daeec8ab00949a1d9d1cb 100644 (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;
-
-        /* Obtain handles for the standard Console I/O devices */
-       hConIn = GetStdHandle(STD_INPUT_HANDLE);
+        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);
+
+               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 */
diff --git a/sys/winnt/stubs.c b/sys/winnt/stubs.c
new file mode 100644 (file)
index 0000000..6b899a0
--- /dev/null
@@ -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 */
+
index c36175424cb6969bd45334d35f6f0434549a5709..9385b9febfbbf3c03c73acd6bbde12bebaee5345 100644 (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();
 }
index f0fce57abb266cc9b70da5645b70aefbf3867bf8..ee46aee3fad3fa4cb662fe08d6cbaf1428bf676e 100644 (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
index cdf5ba4b46db9d769bb2720588c888a50d190db1..4d1fc9160b2e90eb13dd10de889a260e77fcf156 100644 (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;
 }