Disclaimer: This is a minimal recipe, just to get someone else
started if they have a desire to get a full cross-compile of
NetHack-3.7 going for the Amiga. Some NetHack code bitrot was
corrected, and it does seem able to compile the game itself
to a point. See caveats below.
- If you want to obtain the cross-compiler and tools/libs for Amiga
https://github.com/bebbo/amiga-gcc
To our knowledge, a pre-built copy isn't available, so you have to
obtain the source via git and build it on your system.
The build prerequisite packages for Ubuntu are easily obtained:
sudo apt install make wget git gcc g++ lhasa libgmp-dev \
libmpfr-dev libmpc-dev flex bison gettext texinfo ncurses-dev \
autoconf rsync
The build prerequisite packages for macOS are apparently easily
obtained via homebrew, but that was not tested:
brew install bash wget make lhasa gmp mpfr libmpc flex gettext \
texinfo gcc make autoconf
After installing the prerequite packages and the cross-compiler
it was a straightforward build:
git clone https://github.com/bebbo/amiga-gcc.git
cd amiga-gcc
make update
[Note that you may have to take ownership of the files in the
bebbo repo via chown before succesfully carrying out the next
steps]
make clean
make clean-prefix
date; make all -j3 >&b.log; date
The compiler pieces are installed in /opt/amiga by default which
was satisfactory for our initial attempt, but if you want you can
alter the prefix before you build if you want. That is all
spelled out on the page at: https://github.com/bebbo/amiga-gcc
The Amiga cross-compile can then be carried out by specifying
CROSS_TO_AMIGA=1 on the make command line.
For example:
make CROSS_TO_AMIGA=1 all
make CROSS_TO_AMIGA=1 package
You can explicitly include tty and curses support if desired, otherwise
you'll end up with a tty-only cross-compile build. The SDL1 pdcurses
support has not been tested.
make WANT_WIN_TTY=1 WANT_WIN_CURSES=1 CROSS_TO_AMIGA=1 all
Also note that building the amiga targets using the make command
above, does not preclude you from building local linux or macOS
targets as well. Just drop the CROSS_TO_AMIGA=1 from the make
command line.
The cross-compiler hints additions are enclosed inside ifdef sections
and won't interfere with the non-cross-compile build in that case.
CAVEATS: The original NetHack Amiga build steps included the source for
some utilities that were built and executed on the amiga: txt2iff and
xpm2iff as part of the NetHack build procedure on amiga. Those did not
compile out-of-the-box on the linux host. They will either have to be:
- ported to build and run on the linux or macOS cross-compile host
or
- their functionality will have to be rolled into amiga NetHack
itself and executed on the target Amiga the first time the game
is run, perhaps.
Good luck amiga aficionados, perhaps you'll be able to take this
initial effort forward and get NetHack-3.7 available on the amiga or
amiga-emulator. Let us know if you do, and we can roll changes in
if you provide them.
286 lines
6.0 KiB
C
286 lines
6.0 KiB
C
/* NetHack 3.7 pcsys.c $NHDT-Date: 1596498283 2020/08/03 23:44:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.42 $ */
|
|
/* Copyright (c) 2012 by Michael Allison */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/*
|
|
* System related functions for MSDOS, OS/2, TOS
|
|
*/
|
|
|
|
#define NEED_VARARGS
|
|
#include "hack.h"
|
|
#include "wintty.h"
|
|
|
|
#include <ctype.h>
|
|
#include <fcntl.h>
|
|
#if !defined(MSDOS) && !defined(WIN_CE) && !defined(AMIGA_CROSS)
|
|
#include <process.h>
|
|
#endif
|
|
#if defined(__GO32__) || defined(AMIGA_CROSS)
|
|
#define P_WAIT 0
|
|
#define P_NOWAIT 1
|
|
#endif
|
|
#ifdef TOS
|
|
#include <osbind.h>
|
|
#endif
|
|
#if defined(MSDOS) && !defined(__GO32__)
|
|
#define findfirst findfirst_file
|
|
#define findnext findnext_file
|
|
#define filesize filesize_nh
|
|
#endif
|
|
|
|
#if defined(MICRO) || defined(OS2)
|
|
void FDECL(nethack_exit, (int)) NORETURN;
|
|
#else
|
|
#define nethack_exit exit
|
|
#endif
|
|
static void NDECL(msexit);
|
|
|
|
#ifdef MOVERLAY
|
|
extern void __far __cdecl _movepause(void);
|
|
extern void __far __cdecl _moveresume(void);
|
|
extern unsigned short __far __cdecl _movefpause;
|
|
extern unsigned short __far __cdecl _movefpaused;
|
|
#define __MOVE_PAUSE_DISK 2 /* Represents the executable file */
|
|
#define __MOVE_PAUSE_CACHE 4 /* Represents the cache memory */
|
|
#endif /* MOVERLAY */
|
|
|
|
#if defined(MICRO)
|
|
|
|
void
|
|
flushout()
|
|
{
|
|
(void) fflush(stdout);
|
|
return;
|
|
}
|
|
|
|
static const char *COMSPEC =
|
|
#ifdef TOS
|
|
"SHELL";
|
|
#else
|
|
"COMSPEC";
|
|
#endif
|
|
|
|
#define getcomspec() nh_getenv(COMSPEC)
|
|
|
|
#ifdef SHELL
|
|
int
|
|
dosh()
|
|
{
|
|
extern char orgdir[];
|
|
char *comspec;
|
|
#ifndef __GO32__
|
|
int spawnstat;
|
|
#endif
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
int grmode = iflags.grmode;
|
|
#endif
|
|
if ((comspec = getcomspec())) {
|
|
#ifndef TOS /* TOS has a variety of shells */
|
|
suspend_nhwindows(
|
|
"To return to NetHack, enter \"exit\" at the system prompt.\n");
|
|
#else
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
grmode = iflags.grmode;
|
|
#endif
|
|
suspend_nhwindows((char *) 0);
|
|
#endif /* TOS */
|
|
#ifndef NOCWD_ASSUMPTIONS
|
|
chdirx(orgdir, 0);
|
|
#endif
|
|
#ifdef __GO32__
|
|
if (system(comspec) < 0) { /* wsu@eecs.umich.edu */
|
|
#else
|
|
#ifdef MOVERLAY
|
|
/* Free the cache memory used by overlays, close .exe */
|
|
_movefpause |= __MOVE_PAUSE_DISK;
|
|
_movefpause |= __MOVE_PAUSE_CACHE;
|
|
_movepause();
|
|
#endif
|
|
spawnstat = spawnl(P_WAIT, comspec, comspec, (char *) 0);
|
|
#ifdef MOVERLAY
|
|
_moveresume();
|
|
#endif
|
|
|
|
if (spawnstat < 0) {
|
|
#endif
|
|
raw_printf("Can't spawn \"%s\"!", comspec);
|
|
getreturn("to continue");
|
|
}
|
|
#ifdef TOS
|
|
/* Some shells (e.g. Gulam) turn the cursor off when they exit */
|
|
if (iflags.BIOS)
|
|
(void) Cursconf(1, -1);
|
|
#endif
|
|
#ifndef NOCWD_ASSUMPTIONS
|
|
chdirx(hackdir, 0);
|
|
#endif
|
|
get_scr_size(); /* maybe the screen mode changed (TH) */
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
if (grmode)
|
|
gr_init();
|
|
#endif
|
|
resume_nhwindows();
|
|
} else
|
|
pline("Can't find %s.", COMSPEC);
|
|
return 0;
|
|
}
|
|
#endif /* SHELL */
|
|
#endif /* MICRO */
|
|
|
|
/*
|
|
* Add a backslash to any name not ending in /, \ or : There must
|
|
* be room for the \
|
|
*/
|
|
void
|
|
append_slash(name)
|
|
char *name;
|
|
{
|
|
char *ptr;
|
|
|
|
if (!*name)
|
|
return;
|
|
ptr = name + (strlen(name) - 1);
|
|
if (*ptr != '\\' && *ptr != '/' && *ptr != ':') {
|
|
*++ptr = '\\';
|
|
*++ptr = '\0';
|
|
}
|
|
return;
|
|
}
|
|
|
|
void
|
|
getreturn(str)
|
|
const char *str;
|
|
{
|
|
#ifdef TOS
|
|
msmsg("Hit <Return> %s.", str);
|
|
#else
|
|
#ifdef AMIGA_CROSS
|
|
(void) printf("Hit <Enter> %s.", str);
|
|
#else
|
|
msmsg("Hit <Enter> %s.", str);
|
|
#endif
|
|
#endif
|
|
while (pgetchar() != '\n')
|
|
;
|
|
return;
|
|
}
|
|
|
|
void msmsg
|
|
VA_DECL(const char *, fmt)
|
|
{
|
|
VA_START(fmt);
|
|
VA_INIT(fmt, const char *);
|
|
#if defined(MSDOS) && defined(NO_TERMS)
|
|
if (iflags.grmode)
|
|
gr_finish();
|
|
#endif
|
|
Vprintf(fmt, VA_ARGS);
|
|
flushout();
|
|
VA_END();
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* Follow the PATH, trying to fopen the file.
|
|
*/
|
|
#ifdef TOS
|
|
#ifdef __MINT__
|
|
#define PATHSEP ':'
|
|
#else
|
|
#define PATHSEP ','
|
|
#endif
|
|
#else
|
|
#define PATHSEP ';'
|
|
#endif
|
|
|
|
FILE *
|
|
fopenp(name, mode)
|
|
const char *name, *mode;
|
|
{
|
|
char buf[BUFSIZ], *bp, *pp, lastch = 0;
|
|
FILE *fp;
|
|
|
|
/* Try the default directory first. Then look along PATH.
|
|
*/
|
|
(void) strncpy(buf, name, BUFSIZ - 1);
|
|
buf[BUFSIZ - 1] = '\0';
|
|
if ((fp = fopen(buf, mode)))
|
|
return fp;
|
|
else {
|
|
int ccnt = 0;
|
|
pp = getenv("PATH");
|
|
while (pp && *pp) {
|
|
bp = buf;
|
|
while (*pp && *pp != PATHSEP) {
|
|
lastch = *bp++ = *pp++;
|
|
ccnt++;
|
|
}
|
|
if (lastch != '\\' && lastch != '/') {
|
|
*bp++ = '\\';
|
|
ccnt++;
|
|
}
|
|
(void) strncpy(bp, name, (BUFSIZ - ccnt) - 2);
|
|
bp[BUFSIZ - ccnt - 1] = '\0';
|
|
if ((fp = fopen(buf, mode)))
|
|
return fp;
|
|
if (*pp)
|
|
pp++;
|
|
}
|
|
}
|
|
#ifdef OS2_CODEVIEW /* one more try for hackdir */
|
|
(void) strncpy(buf, hackdir, BUFSZ);
|
|
buf[BUFSZ - 1] = '\0';
|
|
if ((strlen(name) + 1 + strlen(buf)) < BUFSZ - 1) {
|
|
append_slash(buf);
|
|
Strcat(buf, name);
|
|
} else
|
|
impossible("fopenp() buffer too small for complete filename!");
|
|
if (fp = fopen(buf, mode))
|
|
return fp;
|
|
#endif
|
|
return (FILE *) 0;
|
|
}
|
|
|
|
#if defined(MICRO) || defined(OS2)
|
|
void
|
|
nethack_exit(code)
|
|
int code;
|
|
{
|
|
msexit();
|
|
exit(code);
|
|
}
|
|
|
|
/* Chdir back to original directory
|
|
*/
|
|
#ifdef TOS
|
|
extern boolean run_from_desktop; /* set in pcmain.c */
|
|
#endif
|
|
|
|
static void
|
|
msexit()
|
|
{
|
|
#ifdef CHDIR
|
|
extern char orgdir[];
|
|
#endif
|
|
|
|
flushout();
|
|
#ifndef TOS
|
|
enable_ctrlP(); /* in case this wasn't done */
|
|
#endif
|
|
#if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS)
|
|
chdir(orgdir); /* chdir, not chdirx */
|
|
chdrive(orgdir);
|
|
#endif
|
|
#ifdef TOS
|
|
if (run_from_desktop)
|
|
getreturn("to continue"); /* so the user can read the score list */
|
|
#ifdef TEXTCOLOR
|
|
if (colors_changed)
|
|
restore_colors();
|
|
#endif
|
|
#endif
|
|
wait_synch();
|
|
return;
|
|
}
|
|
#endif /* MICRO || OS2 */
|