build both tty NetHack.exe and gui NetHackW.exe

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

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

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

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

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

View File

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