libnethack pr385

roll parts of pr385 into source tree

This does not take the PR as is.

Unlike the PR, this streamlines and minimizes the integration somewhat:

- use hints/include mechanism instead of creating alternative
  Makefile.dat, Makefile.src, Makefile.top, Makefile.utl in sys/lib;
  those would have been a maintenance nightmare.

- don't have alternative mkmkfile.sh and setup.sh in sys/lib.

- sys/lib/libnethackmain.c differed from sys/unix/unixmain.c by
  very little, so just place a small bit of conditional code at the
  top of sys/unix/unixmain.c instead.

- changed the conditional code bits from __EMSCRIPTEN__ to
  CROSS_TO_WASM.

- You should be able to build the wasm result by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make WANT_LIBNH all

- You should be able to build LIBNBH by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make CROSS_TO_WASM=1 all

As it is currently coded, winshim.c requires C99.
This commit is contained in:
Adam Powers
2020-08-26 19:22:00 -07:00
committed by nhmall
parent 741e6fd5b7
commit dc2d757399
28 changed files with 1555 additions and 120 deletions

View File

@@ -131,7 +131,7 @@ static struct win_info window_opts[] = {
{ "mswin", "Windows GUI", TRUE },
#endif
#ifdef SHIM_GRAPHICS
{ "shim", "Nethack Library Windowing Shim", TRUE },
{ "shim", "NetHack Library Windowing Shim", TRUE },
#endif
#if 0 /* remainder have been retired */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 rip.c $NHDT-Date: 1596498204 2020/08/03 23:43:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */
/* NetHack 3.7 rip.c $NHDT-Date: 1597967808 2020/08/20 23:56:48 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.33 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2017. */
/* NetHack may be freely redistributed. See license for details. */
@@ -6,7 +6,8 @@
#include "hack.h"
#if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) \
|| defined(MSWIN_GRAPHICS) || defined(DUMPLOG) || defined(CURSES_GRAPHICS) || defined(SHIM_GRAPHICS)
|| defined(MSWIN_GRAPHICS) || defined(DUMPLOG) \
|| defined(CURSES_GRAPHICS) || defined(SHIM_GRAPHICS)
#define TEXT_TOMBSTONE
#endif
#if defined(mac) || defined(__BEOS__) || defined(WIN32_GRAPHICS)
@@ -60,12 +61,10 @@ static const char *rip_txt[] = {
};
#define STONE_LINE_CENT 19 /* char[] element of center of stone face */
#endif /* NH320_DEDICATION */
#define STONE_LINE_LEN \
16 /* # chars that fit on one line \
* (note 1 ' ' border) \
*/
#define NAME_LINE 6 /* *char[] line # for player name */
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
#define STONE_LINE_LEN 16 /* # chars that fit on one line
* (note 1 ' ' border) */
#define NAME_LINE 6 /* *char[] line # for player name */
#define GOLD_LINE 7 /* *char[] line # for amount of gold */
#define DEATH_LINE 8 /* *char[] line # for death description */
#define YEAR_LINE 12 /* *char[] line # for year */
@@ -90,9 +89,9 @@ time_t when;
register char **dp;
register char *dpx;
char buf[BUFSZ];
long year;
register int x;
int line;
int line, year;
long cash;
g.rip = dp = (char **) alloc(sizeof(rip_txt));
for (x = 0; rip_txt[x]; ++x)
@@ -100,13 +99,15 @@ time_t when;
dp[x] = (char *) 0;
/* Put name on stone */
Sprintf(buf, "%s", g.plname);
buf[STONE_LINE_LEN] = 0;
Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, g.plname);
center(NAME_LINE, buf);
/* Put $ on stone */
Sprintf(buf, "%ld Au", g.done_money);
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
cash = max(g.done_money, 0L);
/* arbitrary upper limit; practical upper limit is quite a bit less */
if (cash > 999999999L)
cash = 999999999L;
Sprintf(buf, "%ld Au", cash);
center(GOLD_LINE, buf);
/* Put together death description */
@@ -114,11 +115,11 @@ time_t when;
/* Put death type on stone */
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
register int i, i0;
char tmpchar;
int i, i0 = (int) strlen(dpx);
if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
if (i0 > STONE_LINE_LEN) {
for (i = STONE_LINE_LEN; (i > 0) && (i0 > STONE_LINE_LEN); --i)
if (dpx[i] == ' ')
i0 = i;
if (!i)
@@ -135,8 +136,8 @@ time_t when;
}
/* Put year on stone */
year = yyyymmdd(when) / 10000L;
Sprintf(buf, "%4ld", year);
year = (int) ((yyyymmdd(when) / 10000L) % 10000L);
Sprintf(buf, "%4d", year);
center(YEAR_LINE, buf);
#ifdef DUMPLOG

View File

@@ -265,7 +265,7 @@ boolean pastebuf;
raw_printf("%s", buf2);
if (pastebuf) {
#ifdef RUNTIME_PASTEBUF_SUPPORT
#if defined(RUNTIME_PASTEBUF_SUPPORT) && !defined(LIBNH)
/*
* Call a platform/port-specific routine to insert the
* version information into a paste buffer. Useful for