Merge branch 'win-minor' into NetHack-3.6.2-beta01
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
/* main.c - MSDOS, OS/2, ST, Amiga, and Windows NetHack */
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32api.h" /* for GetModuleFileName */
|
||||
#endif
|
||||
|
||||
#include "hack.h"
|
||||
#include "dlb.h"
|
||||
|
||||
@@ -22,10 +26,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32api.h" /* for GetModuleFileName */
|
||||
#endif
|
||||
|
||||
#ifdef __DJGPP__
|
||||
#include <unistd.h> /* for getcwd() prototype */
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@ You can build a TTY version of NetHack and a Windows Graphical
|
||||
version. You can use one of the following build environments:
|
||||
|
||||
o A copy of Microsoft Visual Studio 2017 Community Edition
|
||||
OR Microsoft Visual Studio 2015 Express
|
||||
|
||||
OR
|
||||
|
||||
@@ -35,20 +34,15 @@ version. You can use one of the following build environments:
|
||||
Graphical version.
|
||||
|
||||
/--------------------------------------------------------\
|
||||
| Building And Running Using Visual Studio 2015 or |
|
||||
| Visual Studio 2017 |
|
||||
| Building And Running Using Visual Studio 2017 |
|
||||
\--------------------------------------------------------/
|
||||
|
||||
If you are NOT using Visual Studio 2015 or Visual Studio 2017 IDE, or
|
||||
you prefer to build using a Make utility and a Makefile proceed
|
||||
to "Building Using Make".
|
||||
If you are NOT using Visual Studio 2017 IDE, or you prefer to build
|
||||
using a Make utility and a Makefile proceed to "Building Using Make".
|
||||
|
||||
When using either Visual Studio 2015 or Visual Studio 2017, you simply
|
||||
need to load the solution file within the IDE, build the solution and
|
||||
run the version of NetHack you wish to run.
|
||||
|
||||
The Visual Studio 2015 NetHack solution file can be found here:
|
||||
win\win32\vs2015\NetHack.sln
|
||||
When using either Visual Studio 2017, you simply need to load the
|
||||
solution file within the IDE, build the solution and run the version
|
||||
of NetHack you wish to run.
|
||||
|
||||
The Visual Studio 2017 NetHack solution file can be found here:
|
||||
win\win32\vs2017\NetHack.sln
|
||||
@@ -64,8 +58,7 @@ You can also build all the projects for all platforms and configurations
|
||||
using a "build.bat" batch file found in the same directory as the solution.
|
||||
|
||||
Open a developer command prompt for the version of Visual Studio you are
|
||||
using. Change to the appropriate directory (i.e. win\win32\vs2015 for
|
||||
VS2015 builds, win\win32\vs2017 for VS2017 builds) and run "build.bat".
|
||||
using. Change to the directory win\win32\vs2017 and run "build.bat".
|
||||
|
||||
/-----------------------------------\
|
||||
| Building Using Make |
|
||||
|
||||
@@ -300,7 +300,7 @@ conlibs = $(baselibs)
|
||||
guilibs = $(winlibs)
|
||||
#
|
||||
|
||||
INCLDIR= /I..\include
|
||||
INCLDIR= /I..\include /I..\sys\winnt
|
||||
|
||||
#==========================================
|
||||
# Util builds
|
||||
@@ -997,14 +997,6 @@ $(O)envchk.tag: $(O)obj.tag
|
||||
#=========== SECONDARY TARGETS ============
|
||||
#==========================================
|
||||
|
||||
#===========================================
|
||||
# Header files NOT distributed in $(INCL)
|
||||
#===========================================
|
||||
|
||||
$(INCL)\win32api.h: $(MSWSYS)\win32api.h
|
||||
copy $(MSWSYS)\win32api.h $@
|
||||
|
||||
|
||||
#==========================================
|
||||
# DLB utility and nhdat file creation
|
||||
#==========================================
|
||||
@@ -1065,7 +1057,7 @@ $(U)recover.exe: $(RECOVOBJS)
|
||||
@echo Linking $(@:\=/)
|
||||
$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(RECOVOBJS)
|
||||
|
||||
$(O)recover.o: $(CONFIG_H) $(U)recover.c $(INCL)\win32api.h
|
||||
$(O)recover.o: $(CONFIG_H) $(U)recover.c $(MSWSYS)\win32api.h
|
||||
@$(cc) $(cflagsBuild) -Fo$@ $(U)recover.c
|
||||
|
||||
#==========================================
|
||||
@@ -1159,10 +1151,10 @@ $(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32)
|
||||
)
|
||||
<<
|
||||
|
||||
$(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
|
||||
$(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h
|
||||
@$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c
|
||||
|
||||
$(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(INCL)\win32api.h
|
||||
$(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h
|
||||
@$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c
|
||||
|
||||
#==========================================
|
||||
@@ -1235,7 +1227,6 @@ spotless: clean
|
||||
if exist $(O)gamedir.tag del $(O)gamedir.tag
|
||||
if exist $(O)nh*key.lib del $(O)nh*key.lib
|
||||
if exist $(O)nh*key.exp del $(O)nh*key.exp
|
||||
if exist $(INCL)\win32api.h del $(INCL)\win32api.h
|
||||
if exist $(MSWIN)\mnsel.bmp del $(MSWIN)\mnsel.bmp
|
||||
if exist $(MSWIN)\mnselcnt.bmp del $(MSWIN)\mnselcnt.bmp
|
||||
if exist $(MSWIN)\mnunsel.bmp del $(MSWIN)\mnunsel.bmp
|
||||
@@ -1340,11 +1331,10 @@ $(DAT)\dungeon: $(O)utility.tag $(DAT)\dungeon.def
|
||||
# NT dependencies
|
||||
#
|
||||
|
||||
$(O)nttty.o: $(HACK_H) $(TILE_H) $(INCL)\win32api.h $(MSWSYS)\nttty.c
|
||||
$(O)nttty.o: $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h $(MSWSYS)\nttty.c
|
||||
@$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(MSWSYS)\nttty.c
|
||||
$(O)win10.o: $(HACK_H) $(MSWSYS)\win10.c
|
||||
$(O)winnt.o: $(HACK_H) $(MSWSYS)\win32api.h $(MSWSYS)\winnt.c
|
||||
@$(cc) $(cflagsBuild) -I$(MSWSYS) -I$(MSWIN) -Fo$@ $(MSWSYS)\win10.c
|
||||
$(O)winnt.o: $(HACK_H) $(INCL)\win32api.h $(MSWSYS)\winnt.c
|
||||
@$(cc) $(cflagsBuild) -Fo$@ $(MSWSYS)\winnt.c
|
||||
$(O)ntsound.o: $(HACK_H) $(MSWSYS)\ntsound.c
|
||||
@$(cc) $(cflagsBuild) -Fo$@ $(MSWSYS)\ntsound.c
|
||||
@@ -1400,7 +1390,7 @@ $(O)panic.o: $(U)panic.c $(CONFIG_H)
|
||||
$(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h
|
||||
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c
|
||||
$(O)pcmain.o: ..\sys\share\pcmain.c $(HACK_H) $(INCL)\dlb.h \
|
||||
$(INCL)\win32api.h
|
||||
$(MSWSYS)\win32api.h
|
||||
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcmain.c
|
||||
$(O)pcsys.o: ..\sys\share\pcsys.c $(HACK_H)
|
||||
@$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pcsys.c
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
static char where_to_get_source[] = "http://www.nethack.org/";
|
||||
static char author[] = "The NetHack Development Team";
|
||||
|
||||
#include "win32api.h"
|
||||
#include "hack.h"
|
||||
#include "wintty.h"
|
||||
#include "win32api.h"
|
||||
|
||||
extern HANDLE hConIn;
|
||||
extern INPUT_RECORD ir;
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
static char where_to_get_source[] = "http://www.nethack.org/";
|
||||
static char author[] = "The NetHack Development Team";
|
||||
|
||||
#include "win32api.h"
|
||||
#include "hack.h"
|
||||
#include "wintty.h"
|
||||
#include "win32api.h"
|
||||
|
||||
extern HANDLE hConIn;
|
||||
extern INPUT_RECORD ir;
|
||||
|
||||
@@ -160,9 +160,9 @@
|
||||
static char where_to_get_source[] = "http://www.nethack.org/";
|
||||
static char author[] = "Ray Chason";
|
||||
|
||||
#include "win32api.h"
|
||||
#include "hack.h"
|
||||
#include "wintty.h"
|
||||
#include "win32api.h"
|
||||
|
||||
extern HANDLE hConIn;
|
||||
extern INPUT_RECORD ir;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hack.h"
|
||||
#include "win32api.h"
|
||||
#include "hack.h"
|
||||
#include <mmsystem.h>
|
||||
|
||||
#ifdef USER_SOUNDS
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
#ifdef WIN32
|
||||
#define NEED_VARARGS /* Uses ... */
|
||||
#include "win32api.h"
|
||||
#include "winos.h"
|
||||
#include "hack.h"
|
||||
#include "wintty.h"
|
||||
#include <sys\types.h>
|
||||
#include <sys\stat.h>
|
||||
#include "win32api.h"
|
||||
|
||||
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
||||
extern int redirect_stdout;
|
||||
@@ -241,8 +242,8 @@ static void back_buffer_flip()
|
||||
|
||||
void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
x == 0)));
|
||||
|
||||
cell_t * dst = buffer + console.width * y + x;
|
||||
@@ -256,8 +257,8 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y)
|
||||
|
||||
static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && ((y < console.height) || (y == console.height &&
|
||||
x == 0)));
|
||||
cell_t * dst = buffer + console.width * y + x;
|
||||
cell_t *sentinel = buffer + console.width * (y + 1);
|
||||
@@ -271,8 +272,8 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y)
|
||||
|
||||
void buffer_write(cell_t * buffer, cell_t * cell, COORD pos)
|
||||
{
|
||||
ntassert(pos.X >= 0 && pos.X < console.width);
|
||||
ntassert(pos.Y >= 0 && pos.Y < console.height);
|
||||
nhassert(pos.X >= 0 && pos.X < console.width);
|
||||
nhassert(pos.Y >= 0 && pos.Y < console.height);
|
||||
|
||||
cell_t * dst = buffer + (console.width * pos.Y) + pos.X;
|
||||
*dst = *cell;
|
||||
@@ -464,8 +465,8 @@ int *x, *y, *mod;
|
||||
|
||||
static void set_console_cursor(int x, int y)
|
||||
{
|
||||
ntassert(x >= 0 && x < console.width);
|
||||
ntassert(y >= 0 && y < console.height);
|
||||
nhassert(x >= 0 && x < console.width);
|
||||
nhassert(y >= 0 && y < console.height);
|
||||
|
||||
console.cursor.X = max(0, min(console.width - 1, x));
|
||||
console.cursor.Y = max(0, min(console.height - 1, y));
|
||||
@@ -546,8 +547,8 @@ void
|
||||
xputc_core(ch)
|
||||
char ch;
|
||||
{
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
boolean inverse = FALSE;
|
||||
cell_t cell;
|
||||
@@ -569,6 +570,9 @@ char ch;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
// Temporary fix. Tty putstatusfield()
|
||||
|
||||
inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
|
||||
console.attr = (inverse) ?
|
||||
ttycolors_inv[console.current_nhcolor] :
|
||||
@@ -592,8 +596,8 @@ char ch;
|
||||
}
|
||||
}
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -601,42 +605,6 @@ char ch;
|
||||
* for win32. It is used for glyphs only, not text.
|
||||
*/
|
||||
|
||||
/* CP437 to Unicode mapping according to the Unicode Consortium */
|
||||
static const WCHAR cp437[] = {
|
||||
0x0020, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
|
||||
0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
|
||||
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
|
||||
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x2302,
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
|
||||
0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
|
||||
0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
|
||||
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
|
||||
0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
|
||||
0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
|
||||
0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
|
||||
0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
|
||||
0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
void
|
||||
g_putch(in_ch)
|
||||
int in_ch;
|
||||
@@ -1014,7 +982,7 @@ register char *op;
|
||||
|
||||
void unload_keyboard_handler()
|
||||
{
|
||||
ntassert(keyboard_handler.hLibrary != NULL);
|
||||
nhassert(keyboard_handler.hLibrary != NULL);
|
||||
|
||||
FreeLibrary(keyboard_handler.hLibrary);
|
||||
memset(&keyboard_handler, 0, sizeof(keyboard_handler_t));
|
||||
@@ -1651,10 +1619,10 @@ set_known_good_console_font()
|
||||
L"Consolas");
|
||||
|
||||
success = SetConsoleOutputCP(437);
|
||||
ntassert(success);
|
||||
nhassert(success);
|
||||
|
||||
success = SetCurrentConsoleFontEx(console.hConOut, FALSE, &console_font_info);
|
||||
ntassert(success);
|
||||
nhassert(success);
|
||||
}
|
||||
|
||||
/* restore_original_console_font will restore the console font and code page
|
||||
@@ -1690,12 +1658,17 @@ void set_cp_map()
|
||||
if (console.has_unicode) {
|
||||
UINT codePage = GetConsoleOutputCP();
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
char c = (char)i;
|
||||
int count = MultiByteToWideChar(codePage, 0, &c, 1,
|
||||
&console.cpMap[i], 1);
|
||||
ntassert(count == 1);
|
||||
if (codePage == 437) {
|
||||
memcpy(console.cpMap, cp437, sizeof(console.cpMap));
|
||||
} else {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
char c = (char)i;
|
||||
int count = MultiByteToWideChar(codePage, 0, &c, 1,
|
||||
&console.cpMap[i], 1);
|
||||
nhassert(count == 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1712,8 +1685,8 @@ void early_raw_print(const char *s)
|
||||
if (console.hConOut == NULL)
|
||||
return;
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
WORD attribute = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE;
|
||||
DWORD unused;
|
||||
@@ -1752,8 +1725,8 @@ void early_raw_print(const char *s)
|
||||
s++;
|
||||
}
|
||||
|
||||
ntassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
ntassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
|
||||
nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
|
||||
|
||||
SetConsoleCursorPosition(console.hConOut, console.cursor);
|
||||
|
||||
@@ -1789,7 +1762,7 @@ void nethack_enter_nttty()
|
||||
windowprocs.win_raw_print = early_raw_print;
|
||||
|
||||
console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
ntassert(console.hConOut != NULL); // NOTE: this assert will not print
|
||||
nhassert(console.hConOut != NULL); // NOTE: this assert will not print
|
||||
|
||||
GetConsoleScreenBufferInfo(console.hConOut, &console.origcsbi);
|
||||
|
||||
@@ -1830,7 +1803,7 @@ void nethack_enter_nttty()
|
||||
/* At this point early_raw_print will work */
|
||||
|
||||
console.hConIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
ntassert(console.hConIn != NULL);
|
||||
nhassert(console.hConIn != NULL);
|
||||
|
||||
/* grow the size of the console buffer if it is not wide enough */
|
||||
if (console.origcsbi.dwSize.X < console.width) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/* Copyright (c) 2015 by Michael Allison */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "win32api.h"
|
||||
#include "hack.h"
|
||||
|
||||
#ifdef GUISTUB
|
||||
@@ -52,9 +53,6 @@ char *argv[];
|
||||
|
||||
#ifdef TTYSTUB
|
||||
|
||||
#include "hack.h"
|
||||
#include "win32api.h"
|
||||
|
||||
HANDLE hConIn;
|
||||
HANDLE hConOut;
|
||||
int GUILaunched;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
/* Copyright (C) 2018 by Bart House */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include <process.h>
|
||||
#include "winMS.h"
|
||||
#include "hack.h"
|
||||
#include "win10.h"
|
||||
#include <process.h>
|
||||
#include <VersionHelpers.h>
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
Win10 gWin10 = { 0 };
|
||||
|
||||
void win10_init()
|
||||
@@ -27,6 +27,10 @@ void win10_init()
|
||||
if (gWin10.AreDpiAwarenessContextsEqual == NULL)
|
||||
panic("Unable to get address of AreDpiAwarenessContextsEqual");
|
||||
|
||||
gWin10.GetDpiForWindow = (GetDpiForWindowProc) GetProcAddress(hUser32, "GetDpiForWindow");
|
||||
if (gWin10.GetDpiForWindow == NULL)
|
||||
panic("Unable to get address of GetDpiForWindow");
|
||||
|
||||
FreeLibrary(hUser32);
|
||||
|
||||
gWin10.Valid = TRUE;
|
||||
@@ -35,7 +39,7 @@ void win10_init()
|
||||
if (gWin10.Valid) {
|
||||
if (!gWin10.AreDpiAwarenessContextsEqual(
|
||||
gWin10.GetThreadDpiAwarenessContext(),
|
||||
DPI_AWARENESS_CONTEXT_UNAWARE))
|
||||
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2))
|
||||
panic("Unexpected DpiAwareness state");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,25 @@
|
||||
/* Copyright (C) 2018 by Bart House */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
typedef DPI_AWARENESS_CONTEXT(WINAPI * GetThreadDpiAwarenessContextProc)(VOID);
|
||||
typedef BOOL (WINAPI *AreDpiAwarenessContextsEqualProc)(DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
|
||||
#ifndef WIN10_H
|
||||
#define WIN10_H
|
||||
|
||||
#include "win32api.h"
|
||||
|
||||
typedef DPI_AWARENESS_CONTEXT(WINAPI *GetThreadDpiAwarenessContextProc)(VOID);
|
||||
typedef BOOL(WINAPI *AreDpiAwarenessContextsEqualProc)(
|
||||
DPI_AWARENESS_CONTEXT dpiContextA, DPI_AWARENESS_CONTEXT dpiContextB);
|
||||
typedef UINT(WINAPI *GetDpiForWindowProc)(HWND hwnd);
|
||||
|
||||
typedef struct {
|
||||
BOOL Valid;
|
||||
GetThreadDpiAwarenessContextProc GetThreadDpiAwarenessContext;
|
||||
AreDpiAwarenessContextsEqualProc AreDpiAwarenessContextsEqual;
|
||||
GetDpiForWindowProc GetDpiForWindow;
|
||||
} Win10;
|
||||
|
||||
extern Win10 gWin10;
|
||||
|
||||
void win10_init();
|
||||
|
||||
#endif // WIN10_H
|
||||
@@ -7,22 +7,36 @@
|
||||
* header files & NetHack before including windows.h, so all NetHack
|
||||
* files should include "win32api.h" rather than <windows.h>.
|
||||
*/
|
||||
#ifndef WIN32API
|
||||
#define WIN32API
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#undef strcmpi
|
||||
#undef min
|
||||
#undef max
|
||||
#pragma warning(disable : 4142) /* Warning, Benign redefinition of type */
|
||||
#pragma pack(8)
|
||||
|
||||
#if defined(HACK_H)
|
||||
#error win32api.h must be included before hack.h
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#if defined(strcmpi)
|
||||
#error win32api.h should be included first
|
||||
#endif
|
||||
|
||||
#undef Protection /* We have a global name space collision. No source file
|
||||
using win32api.h should be using the Protection macro
|
||||
from youprop.h.
|
||||
A better fix would be to ensure we include all window
|
||||
header files before we start clobbering the global name
|
||||
space with NetHack specific macros. */
|
||||
#if defined(min)
|
||||
#error win32api.h should be included first
|
||||
#endif
|
||||
|
||||
#if defined(max)
|
||||
#error win32api.h should be included first
|
||||
#endif
|
||||
|
||||
#if defined(Protection)
|
||||
#error win32api.h should be included first
|
||||
#endif
|
||||
|
||||
#pragma warning(disable : 4142) /* Warning, Benign redefinition of type */
|
||||
#pragma pack(8)
|
||||
#endif // _MSC_VER
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
@@ -31,4 +45,6 @@
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif // WIN32API
|
||||
|
||||
/*win32api.h*/
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "winos.h"
|
||||
|
||||
#define NEED_VARARGS
|
||||
#include "hack.h"
|
||||
#include <dos.h>
|
||||
@@ -18,7 +20,6 @@
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include "win32api.h"
|
||||
#ifdef TTY_GRAPHICS
|
||||
#include "wintty.h"
|
||||
#endif
|
||||
@@ -467,8 +468,8 @@ char *buf;
|
||||
}
|
||||
#endif /* RUNTIME_PORT_ID */
|
||||
|
||||
/* ntassert_failed is called when an ntassert's condition is false */
|
||||
void ntassert_failed(const char * exp, const char * file, int line)
|
||||
/* nhassert_failed is called when an nhassert's condition is false */
|
||||
void nhassert_failed(const char * exp, const char * file, int line)
|
||||
{
|
||||
char message[128];
|
||||
_snprintf(message, sizeof(message),
|
||||
@@ -491,6 +492,95 @@ void nethack_enter_winnt()
|
||||
nethack_enter_nttty();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* CP437 to Unicode mapping according to the Unicode Consortium */
|
||||
const WCHAR cp437[256] = {
|
||||
0x0020, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
|
||||
0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
|
||||
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
|
||||
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x2302,
|
||||
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||
0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
|
||||
0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
|
||||
0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
|
||||
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
|
||||
0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
|
||||
0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
|
||||
0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
|
||||
0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
|
||||
0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
|
||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||
};
|
||||
|
||||
WCHAR *
|
||||
winos_ascii_to_wide_str(const unsigned char * src, WCHAR * dst, size_t dstLength)
|
||||
{
|
||||
size_t i = 0;
|
||||
while(i < dstLength - 1 && src[i] != 0)
|
||||
dst[i++] = cp437[src[i]];
|
||||
dst[i] = 0;
|
||||
return dst;
|
||||
}
|
||||
|
||||
WCHAR
|
||||
winos_ascii_to_wide(const unsigned char c)
|
||||
{
|
||||
return cp437[c];
|
||||
}
|
||||
|
||||
BOOL winos_font_support_cp437(HFONT hFont)
|
||||
{
|
||||
BOOL allFound = FALSE;
|
||||
HDC hdc = GetDC(NULL);
|
||||
HFONT oldFont = SelectObject(hdc, hFont);
|
||||
|
||||
DWORD size = GetFontUnicodeRanges(hdc, NULL);
|
||||
GLYPHSET *glyphSet = (GLYPHSET *) malloc(size);
|
||||
|
||||
if (glyphSet != NULL) {
|
||||
GetFontUnicodeRanges(hdc, glyphSet);
|
||||
|
||||
allFound = TRUE;
|
||||
for (int i = 0; i < 256 && allFound; i++) {
|
||||
WCHAR wc = cp437[i];
|
||||
BOOL found = FALSE;
|
||||
for (DWORD j = 0; j < glyphSet->cRanges && !found; j++) {
|
||||
WCHAR first = glyphSet->ranges[j].wcLow;
|
||||
WCHAR last = first + glyphSet->ranges[j].cGlyphs - 1;
|
||||
|
||||
if (wc >= first && wc <= last)
|
||||
found = TRUE;
|
||||
}
|
||||
if (!found)
|
||||
allFound = FALSE;
|
||||
}
|
||||
|
||||
free(glyphSet);
|
||||
}
|
||||
|
||||
SelectObject(hdc, oldFont);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
return allFound;
|
||||
}
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*winnt.c*/
|
||||
/*winnt.c*/
|
||||
20
sys/winnt/winos.h
Normal file
20
sys/winnt/winos.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* NetHack 3.6 winos.h $NHDT-Date: 1524321419 2018/04/21 14:36:59 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.30 $ */
|
||||
/* Copyright (c) NetHack PC Development Team 2018 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#ifndef WINOS_H
|
||||
#define WINOS_H
|
||||
|
||||
#include "win32api.h"
|
||||
|
||||
extern const WCHAR cp437[256];
|
||||
|
||||
WCHAR *
|
||||
winos_ascii_to_wide_str(const unsigned char * src, WCHAR * dst, size_t dstLength);
|
||||
|
||||
WCHAR
|
||||
winos_ascii_to_wide(const unsigned char c);
|
||||
|
||||
BOOL winos_font_support_cp437(HFONT hFont);
|
||||
|
||||
#endif // WINOS_H
|
||||
Reference in New Issue
Block a user