]> granicus.if.org Git - nethack/commitdiff
add cross-compile recipe for amiga
authornhmall <nhmall@nethack.org>
Mon, 28 Sep 2020 21:30:22 +0000 (17:30 -0400)
committernhmall <nhmall@nethack.org>
Mon, 28 Sep 2020 21:30:22 +0000 (17:30 -0400)
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.

23 files changed:
include/dlb.h
include/extern.h
include/global.h
include/pcconf.h
outdated/include/amiconf.h
outdated/sys/amiga/Makefile.agc
outdated/sys/amiga/Makefile.ami
outdated/sys/amiga/amidos.c
outdated/sys/amiga/amigst.c
outdated/sys/amiga/amirip.c
outdated/sys/amiga/amiwind.c
outdated/sys/amiga/winamenu.c [moved from outdated/sys/amiga/winmenu.c with 99% similarity]
outdated/sys/amiga/winami.c
outdated/sys/amiga/winchar.c
outdated/sys/amiga/winfuncs.c
outdated/sys/amiga/winkey.c
outdated/sys/amiga/winproto.h
outdated/sys/amiga/winreq.c
outdated/sys/amiga/winstr.c
sys/share/pcmain.c
sys/share/pcsys.c
sys/unix/hints/include/cross-post.2020
sys/unix/hints/include/cross-pre.2020

index 4f5934b557ffd357a61572c9106e3733493c02a6..4c1e5e583cfe41cdf5b9c73eae85006366caad7f 100644 (file)
@@ -9,7 +9,7 @@
 #ifdef DLB
 
 /* implementations */
-#ifdef MAC
+#if defined(MAC) && !defined(MAC_CROSS)
 #define DLBRSRC /* use Mac resources */
 #else
 #define DLBLIB /* use a set of external files */
index 60c44d2fdbb4d67225c5919f461a81457289d30b..374598ae481b1f608ef8f821088658ee03e401be 100644 (file)
@@ -2149,10 +2149,12 @@ E void NDECL(deliver_splev_message);
 /* ### random.c ### */
 
 #if defined(RANDOM) && !defined(__GO32__) /* djgpp has its own random */
+#ifndef AMIGA_CROSS
 E void FDECL(srandom, (unsigned));
 E char *FDECL(initstate, (unsigned, char *, int));
 E char *FDECL(setstate, (char *));
 E long NDECL(random);
+#endif
 #endif /* RANDOM */
 
 /* ### read.c ### */
index af46502d0c4ae97cbe917f762b1aac1b821ee030..fbffef7a1ff36c50377f791cd8718888ec771cfd 100644 (file)
@@ -166,6 +166,10 @@ extern struct cross_target_s cross_target;
 #include "ntconf.h"
 #endif
 
+#ifdef AMIGA
+#include "amiconf.h"
+#endif
+
 /* Displayable name of this port; don't redefine if defined in *conf.h */
 #ifndef PORT_ID
 #ifdef AMIGA
index c0c4786a090e74ce5cb6ca9ba3312ac38d5fe9d0..86ce2efe7d79308ed08b1648b2e84af474a386d3 100644 (file)
@@ -35,7 +35,9 @@
 
 /*#define OVERLAY */ /* Manual overlay definition (MSC 6.0ax only) */
 
+#ifndef AMIGA_CROSS
 #define SHELL /* via exec of COMMAND.COM */
+#endif
 
 /*
  * Screen control options
@@ -88,7 +90,9 @@
 #define ANSI_DEFAULT
 #endif
 
+#ifndef AMIGA_CROSS
 #define RANDOM /* have Berkeley random(3) */
+#endif
 
 #define MAIL /* Allows for fake mail daemon to deliver mail */
              /* in the MSDOS version.  (For AMIGA MAIL see  */
 #include <process.h> /* Provides prototypes of exit(), spawn()      */
 #endif
 
+#ifdef AMIGA_CROSS
+#include <spawn.h>
+#endif
+
 #if defined(_MSC_VER) && (_MSC_VER >= 7)
 #include <sys/types.h>
 #include <stdlib.h>
 
 #endif /* MSDOS configuration stuff */
 
+#ifndef PATHLEN
 #define PATHLEN 64  /* maximum pathlength */
+#endif
 #define FILENAME 80 /* maximum filename length (conservative) */
 #ifndef MICRO_H
 #include "micro.h" /* contains necessary externs for [os_name].c */
index 122854b4a64107e98dbb1dd966e1ab1fbecb51ee..5215515d88647ab06eb8c7f7c595b206d15c2cd5 100644 (file)
 
 #include <time.h> /* get time_t defined before use! */
 
+#ifdef AMIGA_CROSS
+#include <stdlib.h>
+#include <string.h>
+#endif
+
 #ifdef __SASC_60    /* since SAS can prevent re-inclusion */
 #include <stdlib.h> /* general things, including builtins */
 #include <string.h>
@@ -40,6 +45,8 @@ typedef long off_t;
                              LEVELDIR, SAVEDIR, BONESDIR, DATADIR,    \
                              SCOREDIR, LOCKDIR, CONFIGDIR, and TROUBLEDIR */
 
+#define PATHLEN 130
+
 /* data librarian defs */
 #ifndef NOCWD_ASSUMPTIONS
 #define DLBFILE "NetHack:nhdat"   /* main library */
@@ -49,7 +56,11 @@ typedef long off_t;
 #define DLBFILE2 "nhsdat" /* sound library */
 #endif
 
+#ifndef AMIGA_CROSS
 #define FILENAME_CMP stricmp /* case insensitive */
+#else
+#define FILENAME_CMP strcmpi /* case insensitive */
+#endif
 
 #ifndef __SASC_60
 #define O_BINARY 0
@@ -65,7 +76,9 @@ typedef long off_t;
 #define MFLOPPY /* You'll probably want this; provides assistance \
                  * for typical personal computer configurations   \
                  */
+#ifndef AMIGA_CROSS
 #define RANDOM
+#endif
 
 /* ### amidos.c ### */
 
@@ -123,8 +136,6 @@ extern FILE *FDECL(freopen, (const char *, const char *, FILE *));
 extern char *FDECL(gets, (char *));
 #endif
 
-#define msmsg printf
-
 /*
  * If AZTEC_C  we can't use the long cpath in vision.c....
  */
@@ -138,7 +149,9 @@ extern char *FDECL(gets, (char *));
 
 #define TEXTCOLOR /* Use colored monsters and objects */
 #define HACKFONT  /* Use special hack.font */
-#define SHELL     /* Have a shell escape command (!) */
+#ifndef AMIGA_CROSS   /* issues with prototype and spawnl */
+#define SHELL  /* Have a shell escape command (!) */
+#endif
 #define MAIL      /* Get mail at unexpected occasions */
 #define DEFAULT_ICON "NetHack:default.icon" /* private icon */
 #define AMIFLUSH /* toss typeahead (select flush in .cnf) */
@@ -186,5 +199,24 @@ void FDECL(amii_setpens, (int));
 #undef M
 #define M(c) ((c) -128)
 #endif
+struct ami_sysflags {
+       char sysflagsid[10];
+#ifdef AMIFLUSH
+       boolean altmeta;  /* use ALT keys as META */
+       boolean amiflush; /* kill typeahead */
+#endif
+#ifdef AMII_GRAPHICS           
+       int numcols;
+       unsigned short amii_dripens[20]; /* DrawInfo Pens currently there are 13 in v39 */
+       AMII_COLOR_TYPE amii_curmap[AMII_MAXCOLORS]; /* colormap */
+#endif
+#ifdef OPT_DISPMAP
+       boolean fast_map; /* use optimized, less flexible map display */
+#endif
+#ifdef MFLOPPY
+       boolean asksavedisk;
+#endif
+};
+extern struct ami_sysflags sysflags;
 
 #endif /* AMICONF_H */
index da5b3856726988175d924fe6a8200f43f6d3e216..22b1473f6e5f1cb7083d62599982736b2968ab37 100644 (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
 
index 7d7f676e44611cba4f645d6ecbe10a49ba87b77d..b3b29e7754157e66af940d726e0302463a7aad3f 100644 (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
 
index 9269489469e4eb5bc7cea16dece35472dfb5d22e..4f24130083eaec65bdf8dd7d28a30160bf741687 100644 (file)
 #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
index 91f0d3430fcaad26fe6695ff479e9b84cc86b97e..64cdc2f0eaf525c3638a006f29a1721b0257a19a 100644 (file)
 #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 */
index eea00e2a0e0b36cb541b7afce2609124ebb50cb6..ba17cbdf076a7c5d35245f551560b5c2847a2077 100644 (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);
 
index a5c4f7d670fe80aabb7a7bad380f4dee2c6fe931..9654fb5d99273fbaaa4c9e7c0ece2ea539f83f0a 100644 (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 */
 
similarity index 99%
rename from outdated/sys/amiga/winmenu.c
rename to outdated/sys/amiga/winamenu.c
index 085294008089a900e387440e337c813d2b4851ea..cf1d7537678f4595343ed3c2e5b342504db79faf 100644 (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
index 5045d1592c0b6f9ab84ec8d44f0df0a43f0fc96f..0a9bd29513ae9bd53dcb458498bd3a259e9af9ce 100644 (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()");
index b7960c01a268070e1fe933005765a2072e97e41c..020b721edd8a245bb4e2d0536f0ea174b8ca9f8a 100644 (file)
 #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 */
index 380954681045896e6242e22fa00bf32e49f91f6b..130d66cc9c3fbb6315f92ab39132771862a353f5 100644 (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
index c90e06fc80a6def6a457b2864f4fd8cfde442619..0964f05741afa0f1c505244db25c85aba7bd61df 100644 (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;
 {
index dffa90f674f37694c67ed42b14533261aca601f4..5fb1441c72ff3a2bb244e9aa8c16ec4b54a1e5a3 100644 (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);
index 3d59f596047981578c5490357722b78638136e25..fecf2b4cec77e6ab629d4072264699a5e485ef26 100644 (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);
 
index 75d1d2509894e9ea71a51a06d8c7b02e4e8cf678..d74e566a0674b51573779c5422374217e2400e0c 100644 (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;
index 704da8d2cdd3ee5ab14994601802b98f3eff2e3b..633c1f13ab1b297f19a4875aac20d5503664e7fa 100644 (file)
@@ -268,7 +268,7 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
     if (argc == 0)
         chdirx(HACKDIR, 1);
 #endif
-    ami_wininit_data();
+    ami_wininit_data(WININIT);
 #endif
     initoptions();
 
@@ -754,4 +754,40 @@ char *str;
 }
 #endif /* EXEPATH */
 
+#ifdef AMIGA_CROSS
+void msmsg
+VA_DECL(const char *, fmt)
+{
+    VA_START(fmt);
+    VA_INIT(fmt, const char *);
+    Vprintf(fmt, VA_ARGS);
+    flushout();
+    VA_END();
+    return;
+}
+
+unsigned long
+sys_random_seed()
+{
+    unsigned long seed = 0L;
+    unsigned long pid = (unsigned long) getpid();
+    boolean no_seed = TRUE;
+
+#ifdef AMIGA_STRONG_RANDOM_SEED_HERE
+    /* hypothetical - strong seed code is required */
+    /* then has_strong_seed could be set */
+#endif
+    if (no_seed) {
+        seed = (unsigned long) getnow(); /* time((TIME_type) 0) */
+        /* Quick dirty band-aid to prevent PRNG prediction */
+        if (pid) {
+            if (!(pid & 3L))
+                pid -= 1L;
+            seed *= pid;
+        }
+    }
+    return seed;
+}
+#endif
+
 /*pcmain.c*/
index 0282c7a49ee4c91a5907ba817f845fff793ab184..c027827c46fc2759c2ca1dab2e5b797b65bb5f1c 100644 (file)
 
 #include <ctype.h>
 #include <fcntl.h>
-#if !defined(MSDOS) && !defined(WIN_CE) /* already done */
+#if !defined(MSDOS) && !defined(WIN_CE) && !defined(AMIGA_CROSS)
 #include <process.h>
 #endif
-#ifdef __GO32__
+#if defined(__GO32__) || defined(AMIGA_CROSS)
 #define P_WAIT 0
 #define P_NOWAIT 1
 #endif
@@ -153,8 +153,12 @@ 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')
         ;
index 844fa3e2b9e420392d2d4cf404a39e5bd5dcd193..a89d6ca08ffa6f0496778becb3c280d9e796d285 100644 (file)
@@ -37,6 +37,81 @@ dospkg: $(GAMEBIN) $(TARGETDIR)/recover.exe ../dat/nhtiles.bmp
        @echo msdos package zip file $(TARGETDIR)/NH370DOS.ZIP
 endif  # CROSS_TO_MSDOS
 
+ifdef CROSS_TO_AMIGA
+$(TARGETDIR)/amidos.o : ../outdated/sys/amiga/amidos.c $(HACK_H)
+$(TARGETDIR)/amigst.o : ../outdated/sys/amiga/amigst.c $(HACK_H)
+$(TARGETDIR)/amirip.o : ../outdated/sys/amiga/amirip.c $(HACK_H)
+$(TARGETDIR)/amistack.o : ../outdated/sys/amiga/amistack.c $(HACK_H)
+$(TARGETDIR)/amitty.o : ../outdated/sys/amiga/amitty.c $(HACK_H)
+$(TARGETDIR)/amiwind.o : ../outdated/sys/amiga/amiwind.c \
+               ../outdated/sys/amiga/amimenu.c $(HACK_H)
+$(TARGETDIR)/winami.o : ../outdated/sys/amiga/winami.c $(HACK_H)
+$(TARGETDIR)/winchar.o : ../outdated/sys/amiga/winchar.c tile.c $(HACK_H)
+$(TARGETDIR)/winfuncs.o : ../outdated/sys/amiga/winfuncs.c $(HACK_H)
+$(TARGETDIR)/winkey.o : ../outdated/sys/amiga/winkey.c $(HACK_H)
+$(TARGETDIR)/winamenu.o : ../outdated/sys/amiga/winamenu.c $(HACK_H) 
+$(TARGETDIR)/winreq.o : ../outdated/sys/amiga/winreq.c \
+               ../outdated/sys/amiga/colorwin.c \
+               ../outdated/sys/amiga/clipwin.c $(HACK_H)
+$(TARGETDIR)/winstr.o : ../outdated/sys/amiga/winstr.c $(HACK_H)
+$(TARGETDIR)/tomb.iff : ../util/xpm2iff ../outdated/sys/amiga/gave16.xpm
+../util/tiletext.o : ../win/share/tiletext.c
+       $(CC) $(CFLAGS) -c \
+               -o $@ ../win/share/tiletext.c
+../util/txt2iff : ../util/txt2iff.o ../util/tiletext.o \
+               ../util/tiletxt.o
+       $(LINK) $(LFLAGS) -L../lib -o $@ ../util/txt2iff.o ../util/tiletext.o \
+               ../util/tiletxt.o -lriffl
+../util/txt2iff.o : ../outdated/sys/amiga/txt2iff.c $(HACK_H)
+       $(CC) $(CFLAGS) -c \
+               -I../lib/riffl-0.2/include \
+               -I/opt/amiga/m68k-amigaos/ndk13-include \
+               -o $@ ../outdated/sys/amiga/txt2iff.c
+../util/xpm2iff : ../util/xpm2iff.o
+       $(LINK) $(LFLAGS) -L../lib -o $@ ../util/txt2iff.o -lriffl
+../util/xpm2iff.o : ../outdated/sys/amiga/xpm2iff.c $(HACK_H)
+       $(CC) $(CFLAGS) -o $@ ../outdated/sys/amiga/xpm2iff.c
+$(TARGETDIR)/objects.iff: ../win/share/objects.txt ../util/txt2iff
+       ../util/txt2iff ../win/share/objects.txt $@
+$(TARGETDIR)/monsters.iff: ../win/share/monsters.txt ../util/txt2iff
+       ../util/txt2iff ../win/share/monsters.txt $@
+$(TARGETDIR)/other.iff: ../win/share/other.txt ../util/txt2iff
+       ../util/txt2iff ../win/share/other.txt $@
+#
+#.PHONY: amigapkg
+amigapkg: $(GAMEBIN) $(TARGETDIR)/recover.exe ../dat/nhtiles.bmp
+       mkdir -p $(TARGETDIR)/pkg
+       cp $(GAMEBIN) $(TARGETDIR)/pkg/nethack
+       cp ../dat/nhdat $(TARGETDIR)/pkg/nhdat
+       cp ../dat/license $(TARGETDIR)/pkg/license
+       cp ../dat/nhtiles.bmp $(TARGETDIR)/pkg/nhtiles.bmp
+       cp $(TARGETDIR)/tomb.iff $(TARGETDIR)/pkg/tomb.iff
+       cp $(TARGETDIR)/monsters.iff $(TARGETDIR)/pkg/monsters.iff
+       cp $(TARGETDIR)/objects.iff $(TARGETDIR)/pkg/objects.iff
+       cp $(TARGETDIR)/other.iff $(TARGETDIR)/pkg/other.iff
+       cp ../dat/symbols $(TARGETDIR)/pkg/symbols
+       cp ../sys/share/NetHack.cnf $(TARGETDIR)/pkg/nethack.cnf
+       cp ../sys/msdos/sysconf $(TARGETDIR)/pkg/sysconf
+       cp ../outdated/sys/amiga/amii.hlp $(TARGETDIR)/pkg/amii.hlp
+       cp ../sys/msdos/sysconf $(TARGETDIR)/pkg/sysconf
+       cp ../doc/nethack.txt $(TARGETDIR)/pkg/nethack.txt
+       ../util/uudecode ../outdated/sys/amiga/amifont8.uu
+       cp 8 $(TARGETDIR)/pkg/8
+       ../util/uudecode ../outdated/sys/amiga/amifont.uu
+       cp hack.font $(TARGETDIR)/pkg/hack.font
+       ../util/uudecode ../outdated/sys/amiga/dflticon.uu
+       cp default.icon $(TARGETDIR)/pkg/default.icon
+       ../util/uudecode ../outdated/sys/amiga/NHinfo.uu
+       cp NetHack.info $(TARGETDIR)/pkg/NetHack.info
+       ../util/uudecode ../outdated/sys/amiga/NewGame.uu
+       cp NewGame.info $(TARGETDIR)/pkg/NewGame.info
+       ../util/uudecode ../outdated/sys/amiga/HackWB.uu
+       cp HackWB.info $(TARGETDIR)/pkg/HackWB.info
+       -touch $(TARGETDIR)/pkg/record
+       zip -9 $(TARGETDIR)/NH370AMI.ZIP $(TARGETDIR)/pkg/*
+       @echo amiga package zip file $(TARGETDIR)/NH370AMI.ZIP
+endif  # CROSS_TO_AMIGA
+
 #
 # shared file dependencies
 #
index b3da7e30b8c4a98aa631ce9e181efd748fbbe9d4..846fed9c9a889c23017f01c114622bd9a482edd2 100644 (file)
@@ -12,6 +12,14 @@ override TARGETDIR = ../targets/$(TARGET)
 override TARGET_LIBS=
 endif
 
+ifdef CROSS_TO_AMIGA
+BUILD_LUA=1
+BUILD_PDCURSES=1
+override TARGET = amiga
+override TARGETDIR = ../targets/$(TARGET)
+override TARGET_LIBS=
+endif
+
 ifdef BUILD_LUA
 #===============-=================================================
 # LUA library
@@ -86,6 +94,10 @@ override TARGET_LIBS += $(PDCLIB)
 ifdef CROSS_TO_MSDOS
 PDCINCL += -I$(PDCTOP)/dos
 endif
+ifdef CROSS_TO_AMIGA
+PDCINCL += -I$(PDCTOP)/sdl1 -I/opt/amiga/m68k-amigaos/include/SDL
+override TARGET_LIBS += -lSDL
+endif
 BUILDMORE += $(PDCLIB)
 # Rules for PDCurses files
 $(TARGETDIR)/%.o : $(PDCTOP)/pdcurses/%.c
@@ -167,6 +179,95 @@ $(TARGETDIR)/%.o : ../sys/msdos/%.c
 endif  # CROSS_TO_MSDOS
 #=================================================================
 
+ifdef CROSS_TO_AMIGA
+#===============-=================================================
+# AmigaOS m68k cross-compile recipe
+#===============-=================================================
+# Uses an Amiga M68K cross-compiler on linux or macOS.
+#
+# 1. You can obtain the cross-compiler for your system via:
+#     sys/amiga/fetch-cross.sh
+# 2. Then
+#     make CROSS_TO_AMIGAOS=1 WANT_WIN_TTY=1 WANT_WIN_CURSES=1 all
+#
+# Amiga m68k from https://github.com/bebbo/amiga-gcc
+#=================================================================
+
+CFLAGS += -DCROSSCOMPILE -DCROSSCOMPILE_HOST
+
+#
+# Override the build tools and some obj files to
+# reflect the amiga-gccs cross-compiler.
+#
+TOOLTOP = /opt/amiga/bin
+#TOOLARCH = -m68020 -mcrt=clib2
+#TOOLARCH = -m68020   #newlib
+TOOLARCH = -m68020 -noixemul
+override REGEXOBJ = $(TARGETDIR)/cppregex.o
+override TARGET_CC = $(TOOLTOP)/m68k-amigaos-gcc
+override TARGET_CXX = $(TOOLTOP)/m68k-amigaos-c++
+override TARGET_AR = $(TOOLTOP)/m68k-amigaos-ar 
+override TARGET_STUBEDIT=
+#override TARGET_CFLAGS = -c -O $(TOOLARCH) -I../include -I../outdated/include
+override TARGET_CFLAGS = -c -O $(TOOLARCH) \
+       -I../include -I../outdated/include \
+       -I../outdated/sys/amiga -I../win/share \
+       $(LUAINCL) -DAMIGA -DAMIGA_CROSS $(PDCURSESDEF) \
+       -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET \
+       -DAMIGA_VERSION_STRING=\""VER: NetHack 3.7.0 \(12.13.2020)\""
+override TARGET_CXXFLAGS = $(TARGET_CFLAGS)
+ifeq "$(REGEXOBJ)" "$(TARGETDIR)/cppregex.o"
+override TARGET_LINK = $(TARGET_CXX)
+else
+override TARGET_LINK = $(TARGET_CC)
+endif
+override TARGET_LFLAGS= $(TOOLARCH)
+#override TARGET_LIBS += 
+VARDATND += nhtiles.bmp
+override SYSSRC = ../outdated/sys/amiga/amidos.c ../outdated/sys/amiga/amigst.c \
+               ../outdated/sys/amiga/amimenu.c ../outdated/sys/amiga/amirip.c \
+               ../outdated/sys/amiga/amistack.c ../outdated/sys/amiga/amitty.c \
+               ../outdated/sys/amiga/amiwind.c ../outdated/sys/amiga/clipwin.c \
+               ../outdated/sys/amiga/colorwin.c \
+               ../outdated/sys/amiga/winami.c ../outdated/sys/amiga/winchar.c \
+               ../outdated/sys/amiga/winfuncs.c ../outdated/sys/amiga/winkey.c \
+               ../outdated/sys/amiga/winamenu.c ../outdated/sys/amiga/winreq.c \
+               ../outdated/sys/amiga/winstr.c ../sys/share/pcmain.c \
+               ../win/share/bmptiles.c ../win/share/giftiles.c \
+               ../win/share/tileset.c
+#              ../outdated/sys/amiga/xpm2iff.c
+#              ../outdated/sys/amiga/txt2iff.c
+override SYSOBJ = $(TARGETDIR)/amidos.o $(TARGETDIR)/amigst.o \
+               $(TARGETDIR)/amirip.o $(TARGETDIR)/amistack.o \
+               $(TARGETDIR)/amitty.o $(TARGETDIR)/amiwind.o \
+               $(TARGETDIR)/winami.o $(TARGETDIR)/winchar.o \
+               $(TARGETDIR)/winfuncs.o $(TARGETDIR)/winkey.o \
+               $(TARGETDIR)/winamenu.o $(TARGETDIR)/winreq.o \
+               $(TARGETDIR)/winstr.o $(TARGETDIR)/pcmain.o \
+               $(TARGETDIR)/bmptiles.o $(TARGETDIR)/giftiles.o \
+               $(TARGETDIR)/tileset.o
+#              $(TARGETDIR)/xpm2iff.o
+#              ../util/txt2iff.o
+override WINLIB=
+override LUALIB=
+override GAMEBIN = $(TARGETDIR)/nethack.exe
+override PACKAGE= amigapkg
+PREGAME = mkdir -p ../targets/amiga
+CLEANMORE += rm -r ../targets/amiga
+BUILDMORE += $(TARGETDIR)/recover.exe
+#              ../util/txt2iff
+#
+ifdef WANT_WIN_CURSES
+# rules for pdcurses sdl1-specific files
+$(TARGETDIR)/%.o : $(PDCTOP)/sdl1/%.c
+       $(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@  $<
+endif  # WANT_WIN_CURSES
+# Rule for files in sys/amiga
+$(TARGETDIR)/%.o : ../outdated/sys/amiga/%.c
+       $(TARGET_CC) $(TARGET_CFLAGS) -o$@ $<
+endif  # CROSS_TO_AMIGA
+#=================================================================
+
 ifdef WANT_WIN_CURSES
 # rules for pdcurses dos-specific files
 $(TARGETDIR)/%.o : $(PDCTOP)/sdl1/%.c