add cross-compile recipe for amiga

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.
This commit is contained in:
nhmall
2020-09-28 17:30:22 -04:00
parent 14b532bf10
commit cb223271cb
23 changed files with 405 additions and 31 deletions

View File

@@ -184,7 +184,7 @@ MAKEDEFOBJ = \
AMIGAOBJ = \
$(O)amidos.o $(O)amirip.o $(O)amistack.o \
$(O)amiwind.o $(O)winami.o $(O)winchar.o $(O)winfuncs.o \
$(O)winkey.o $(O)winmenu.o $(O)winreq.o $(O)winstr.o
$(O)winkey.o $(O)winamenu.o $(O)winreq.o $(O)winstr.o
# Objects from assembly sources (because DMake can't handle default rules)
AMIGAOBJ2 = \
@@ -572,7 +572,7 @@ $(O)winfuncs.o: $(AMI)winfuncs.c $(HDEP) $(AMDEP) $(I)patchlevel.h
$(O)winkey.o: $(AMI)winkey.c $(HDEP) $(AMDEP)
$(O)winmenu.o: $(AMI)winmenu.c $(HDEP) $(AMDEP)
$(O)winamenu.o: $(AMI)winamenu.c $(HDEP) $(AMDEP)
$(O)winami.o: $(AMI)winami.c $(HDEP) $(AMDEP) #$(AMI)char.c $(AMI)randwin.c

View File

@@ -391,7 +391,7 @@ MAKEDEFOBJ = \
AMIGAOBJ = \
$(O)amidos.o $(O)amirip.o $(O)amistack.o \
$(O)amiwind.o $(O)winami.o $(O)winchar.o $(O)winfuncs.o \
$(O)winkey.o $(O)winmenu.o $(O)winreq.o $(O)winstr.o
$(O)winkey.o $(O)winamenu.o $(O)winreq.o $(O)winstr.o
# Objects from assembly sources (because DMake can't handle default rules)
AMIGAOBJ2 = \
@@ -844,7 +844,7 @@ $(O)winfuncs.o: $(AMI)winfuncs.c $(HDEP) $(AMDEP) $(I)patchlevel.h
$(O)winkey.o: $(AMI)winkey.c $(HDEP) $(AMDEP)
$(O)winmenu.o: $(AMI)winmenu.c $(HDEP) $(AMDEP)
$(O)winamenu.o: $(AMI)winamenu.c $(HDEP) $(AMDEP)
$(O)winami.o: $(AMI)winami.c $(HDEP) $(AMDEP) #$(AMI)char.c $(AMI)randwin.c

View File

@@ -29,12 +29,19 @@
#endif
/* Prototypes */
#include "NH:sys/amiga/winami.p"
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/amiwind.p"
#include "NH:sys/amiga/winami.p"
#include "NH:sys/amiga/amidos.p"
#else
#include "winami.p"
#include "winami.p"
#include "amidos.p"
#endif
extern char Initialized;
extern struct window_procs amii_procs;
struct ami_sysflags sysflags = {0};
#ifndef __SASC_60
int Enable_Abort = 0; /* for stdio package */
@@ -272,6 +279,7 @@ const char *from, *to;
}
#endif
#ifdef MFLOPPY
/* this should be replaced */
saveDiskPrompt(start)
{
@@ -325,6 +333,7 @@ saveDiskPrompt(start)
}
return 1;
}
#endif /* MFLOPPY */
/* Return 1 if the record file was found */
static boolean

View File

@@ -36,8 +36,14 @@
#include <functions.h>
#endif
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/winami.p"
#include "NH:sys/amiga/amiwind.p"
#include "NH:sys/amiga/amidos.p"
#else
#include "winami.p"
#include "amiwind.p"
#include "amidos.p"
#endif
/* end amigst.c */

View File

@@ -191,7 +191,7 @@ time_t when;
tomb_text(buf);
/* Put $ on stone */
Sprintf(buf, "%ld Au", done_money);
Sprintf(buf, "%ld Au", g.done_money);
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
tomb_text(buf);

View File

@@ -3,9 +3,15 @@
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1993,1996 */
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
/* Have to undef CLOSE as display.h and intuition.h both use it */
#undef CLOSE
@@ -20,10 +26,21 @@ static int BufferGetchar(void);
static void ProcessMessage(register struct IntuiMessage *message);
#define BufferQueueChar(ch) (KbdBuffer[KbdBuffered++] = (ch))
#ifndef AMIGA_CROSS
struct Library *ConsoleDevice;
#else
struct Device *
# ifdef __CONSTLIBBASEDECL__
__CONSTLIBBASEDECL__
# endif /* __CONSTLIBBASEDECL__ */
ConsoleDevice;
#endif
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/amimenu.c"
#else
#include "amimenu.c"
#endif
/* Now our own variables */

View File

@@ -1,11 +1,17 @@
/* NetHack 3.6 winmenu.c $NHDT-Date: 1432512796 2015/05/25 00:13:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
/* NetHack 3.6 winamenu.c $NHDT-Date: 1432512796 2015/05/25 00:13:16 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993,1996.
*/
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
/* Start building the text for a menu */
void

View File

@@ -3,11 +3,22 @@
*/
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
#include "dlb.h"
#ifdef AMIGA_CROSS
#define strnicmp strncmpi
#endif
#ifdef AMIGA_INTUITION
static int FDECL(put_ext_cmd, (char *, int, struct amii_WinDesc *, int));
@@ -29,8 +40,9 @@ long amii_scrnmode;
*/
struct window_procs amii_procs = {
"amii", WC_COLOR | WC_HILITE_PET | WC_INVERSE,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
0L, amii_init_nhwindows,
amii_init_nhwindows,
amii_player_selection, amii_askname, amii_get_nh_event,
amii_exit_nhwindows, amii_suspend_nhwindows, amii_resume_nhwindows,
amii_create_nhwindow, amii_clear_nhwindow, amii_display_nhwindow,
@@ -63,8 +75,9 @@ struct window_procs amii_procs = {
*/
struct window_procs amiv_procs = {
"amitile", WC_COLOR | WC_HILITE_PET | WC_INVERSE,
0L,
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
0L, amii_init_nhwindows,
amii_init_nhwindows,
amii_player_selection, amii_askname, amii_get_nh_event,
amii_exit_nhwindows, amii_suspend_nhwindows, amii_resume_nhwindows,
amii_create_nhwindow, amii_clear_nhwindow, amii_display_nhwindow,
@@ -1134,7 +1147,7 @@ boolean complain;
register int win;
register dlb *fp;
register char *t;
register char buf[200];
char buf[200];
if (fn == NULL)
panic("NULL file name in display_file()");

View File

@@ -14,14 +14,24 @@
#ifdef TESTING
#include "hack.h"
#else
#ifndef AMIGA_CROSS
#include "NH:src/tile.c"
#else
#include "../src/tile.c"
#endif
#endif
#ifndef AMIGA_CROSS
#include "NH:win/share/tile.h"
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "tile.h"
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
#ifdef OPT_DISPMAP
#define DISPMAP /* use display_map() from dispmap.s */

View File

@@ -3,14 +3,29 @@
*/
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
#include "patchlevel.h"
#include "date.h"
extern struct TagItem scrntags[];
#ifndef AMIGA_CROSS
extern struct Library *ConsoleDevice;
#else
extern struct Device *
# ifdef __CONSTLIBBASEDECL__
__CONSTLIBBASEDECL__
# endif /* __CONSTLIBBASEDECL__ */
ConsoleDevice;
#endif
static BitMapHeader amii_bmhd;
static void cursor_common(struct RastPort *, int, int);
@@ -776,8 +791,17 @@ amii_create_nhwindow(type) register int type;
Abort(AG_OpenDev | AO_ConsoleDev);
}
ConsoleDevice = (struct Library *) ConsoleIO.io_Device;
ConsoleDevice =
#ifndef AMIGA_CROSS
(struct Library *)
#else
(struct Device *
# ifdef __CONSTLIBBASEDECL__
__CONSTLIBBASEDECL__
# endif /* __CONSTLIBBASEDECL__ */
)
#endif
ConsoleIO.io_Device;
KbdBuffered = 0;
#ifdef HACKFONT

View File

@@ -2,9 +2,15 @@
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
amii_nh_poskey(x, y, mod) int *x, *y, *mod;
{

View File

@@ -65,7 +65,7 @@ void Abort(long rc);
#endif
void CleanUp(void);
void flush_glyph_buffer(struct Window *w);
void amiga_print_glyph(winid window, int color_index, int glyph, int bkglyph);
void amiga_print_glyph(winid window, int color_index, int glyph);
void start_glyphout(winid window);
void amii_end_glyphout(winid window);
struct NewWindow *DupNewWindow(struct NewWindow *win);

View File

@@ -2,9 +2,15 @@
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
#define GADBLUEPEN 2
#define GADREDPEN 3
@@ -39,7 +45,11 @@ struct NewWindow StrWindow = {
&String, NULL, NULL, NULL, NULL, 5, 5, 0xffff, 0xffff, CUSTOMSCREEN
};
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/colorwin.c"
#else
#include "colorwin.c"
#endif
#define XSIZE 2
#define YSIZE 3
@@ -48,7 +58,11 @@ struct NewWindow StrWindow = {
#define GADOKAY 6
#define GADCANCEL 7
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/clipwin.c"
#else
#include "clipwin.c"
#endif
void ClearCol(struct Window *w);

View File

@@ -2,10 +2,15 @@
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef AMIGA_CROSS
#include "NH:sys/amiga/windefs.h"
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
#else
#include "windefs.h"
#include "winext.h"
#include "winproto.h"
#endif
/* Put a string into the indicated window using the indicated attribute */
void
@@ -76,8 +81,8 @@ const char *str;
while (isspace(*str))
str++;
strncpy(toplines, str, TBUFSZ);
toplines[TBUFSZ - 1] = 0;
strncpy(g.toplines, str, TBUFSZ);
g.toplines[TBUFSZ - 1] = 0;
/* For initial message to be visible, we need to explicitly position
* the
@@ -96,15 +101,15 @@ const char *str;
memcpy(cw->data, &cw->data[1],
(iflags.msg_history - 1) * sizeof(char *));
cw->data[iflags.msg_history - 1] =
(char *) alloc(strlen(toplines) + 5);
(char *) alloc(strlen(g.toplines) + 5);
strcpy(cw->data[i = iflags.msg_history - 1] + SOFF
+ (scrollmsg != 0),
toplines);
g.toplines);
} else {
/* Otherwise, allocate a new one and copy the line in */
cw->data[cw->maxrow] = (char *) alloc(strlen(toplines) + 5);
cw->data[cw->maxrow] = (char *) alloc(strlen(g.toplines) + 5);
strcpy(cw->data[i = cw->maxrow++] + SOFF + (scrollmsg != 0),
toplines);
g.toplines);
}
cw->data[i][SEL_ITEM] = 1;
cw->data[i][VATTR] = attr + 1;
@@ -177,7 +182,7 @@ const char *str;
/ w->RPort->TxHeight,
totalvis, totalvis);
}
i = strlen(toplines + SOFF);
i = strlen(g.toplines + SOFF);
cw->maxcol = max(cw->maxcol, i);
cw->vwy = cw->maxrow;
break;