From: nhmall Date: Mon, 28 Sep 2020 21:30:22 +0000 (-0400) Subject: add cross-compile recipe for amiga X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb223271cb910976e0e1be3e36768e468638200a;p=nethack 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. --- diff --git a/include/dlb.h b/include/dlb.h index 4f5934b55..4c1e5e583 100644 --- a/include/dlb.h +++ b/include/dlb.h @@ -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 */ diff --git a/include/extern.h b/include/extern.h index 60c44d2fd..374598ae4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 ### */ diff --git a/include/global.h b/include/global.h index af46502d0..fbffef7a1 100644 --- a/include/global.h +++ b/include/global.h @@ -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 diff --git a/include/pcconf.h b/include/pcconf.h index c0c4786a0..86ce2efe7 100644 --- a/include/pcconf.h +++ b/include/pcconf.h @@ -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 */ @@ -101,6 +105,10 @@ #include /* Provides prototypes of exit(), spawn() */ #endif +#ifdef AMIGA_CROSS +#include +#endif + #if defined(_MSC_VER) && (_MSC_VER >= 7) #include #include @@ -155,7 +163,9 @@ #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 */ diff --git a/outdated/include/amiconf.h b/outdated/include/amiconf.h index 122854b4a..5215515d8 100644 --- a/outdated/include/amiconf.h +++ b/outdated/include/amiconf.h @@ -14,6 +14,11 @@ #include /* get time_t defined before use! */ +#ifdef AMIGA_CROSS +#include +#include +#endif + #ifdef __SASC_60 /* since SAS can prevent re-inclusion */ #include /* general things, including builtins */ #include @@ -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 */ diff --git a/outdated/sys/amiga/Makefile.agc b/outdated/sys/amiga/Makefile.agc index da5b38567..22b1473f6 100644 --- a/outdated/sys/amiga/Makefile.agc +++ b/outdated/sys/amiga/Makefile.agc @@ -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 diff --git a/outdated/sys/amiga/Makefile.ami b/outdated/sys/amiga/Makefile.ami index 7d7f676e4..b3b29e775 100644 --- a/outdated/sys/amiga/Makefile.ami +++ b/outdated/sys/amiga/Makefile.ami @@ -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 diff --git a/outdated/sys/amiga/amidos.c b/outdated/sys/amiga/amidos.c index 926948946..4f2413008 100644 --- a/outdated/sys/amiga/amidos.c +++ b/outdated/sys/amiga/amidos.c @@ -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 diff --git a/outdated/sys/amiga/amigst.c b/outdated/sys/amiga/amigst.c index 91f0d3430..64cdc2f0e 100644 --- a/outdated/sys/amiga/amigst.c +++ b/outdated/sys/amiga/amigst.c @@ -36,8 +36,14 @@ #include #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 */ diff --git a/outdated/sys/amiga/amirip.c b/outdated/sys/amiga/amirip.c index eea00e2a0..ba17cbdf0 100644 --- a/outdated/sys/amiga/amirip.c +++ b/outdated/sys/amiga/amirip.c @@ -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); diff --git a/outdated/sys/amiga/amiwind.c b/outdated/sys/amiga/amiwind.c index a5c4f7d67..9654fb5d9 100644 --- a/outdated/sys/amiga/amiwind.c +++ b/outdated/sys/amiga/amiwind.c @@ -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 */ diff --git a/outdated/sys/amiga/winmenu.c b/outdated/sys/amiga/winamenu.c similarity index 99% rename from outdated/sys/amiga/winmenu.c rename to outdated/sys/amiga/winamenu.c index 085294008..cf1d75376 100644 --- a/outdated/sys/amiga/winmenu.c +++ b/outdated/sys/amiga/winamenu.c @@ -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 diff --git a/outdated/sys/amiga/winami.c b/outdated/sys/amiga/winami.c index 5045d1592..0a9bd2951 100644 --- a/outdated/sys/amiga/winami.c +++ b/outdated/sys/amiga/winami.c @@ -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()"); diff --git a/outdated/sys/amiga/winchar.c b/outdated/sys/amiga/winchar.c index b7960c01a..020b721ed 100644 --- a/outdated/sys/amiga/winchar.c +++ b/outdated/sys/amiga/winchar.c @@ -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 */ diff --git a/outdated/sys/amiga/winfuncs.c b/outdated/sys/amiga/winfuncs.c index 380954681..130d66cc9 100644 --- a/outdated/sys/amiga/winfuncs.c +++ b/outdated/sys/amiga/winfuncs.c @@ -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 diff --git a/outdated/sys/amiga/winkey.c b/outdated/sys/amiga/winkey.c index c90e06fc8..0964f0574 100644 --- a/outdated/sys/amiga/winkey.c +++ b/outdated/sys/amiga/winkey.c @@ -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; { diff --git a/outdated/sys/amiga/winproto.h b/outdated/sys/amiga/winproto.h index dffa90f67..5fb1441c7 100644 --- a/outdated/sys/amiga/winproto.h +++ b/outdated/sys/amiga/winproto.h @@ -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); diff --git a/outdated/sys/amiga/winreq.c b/outdated/sys/amiga/winreq.c index 3d59f5960..fecf2b4ce 100644 --- a/outdated/sys/amiga/winreq.c +++ b/outdated/sys/amiga/winreq.c @@ -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); diff --git a/outdated/sys/amiga/winstr.c b/outdated/sys/amiga/winstr.c index 75d1d2509..d74e566a0 100644 --- a/outdated/sys/amiga/winstr.c +++ b/outdated/sys/amiga/winstr.c @@ -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; diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 704da8d2c..633c1f13a 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -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*/ diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index 0282c7a49..c027827c4 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -12,10 +12,10 @@ #include #include -#if !defined(MSDOS) && !defined(WIN_CE) /* already done */ +#if !defined(MSDOS) && !defined(WIN_CE) && !defined(AMIGA_CROSS) #include #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 %s.", str); +#else +#ifdef AMIGA_CROSS + (void) printf("Hit %s.", str); #else msmsg("Hit %s.", str); +#endif #endif while (pgetchar() != '\n') ; diff --git a/sys/unix/hints/include/cross-post.2020 b/sys/unix/hints/include/cross-post.2020 index 844fa3e2b..a89d6ca08 100644 --- a/sys/unix/hints/include/cross-post.2020 +++ b/sys/unix/hints/include/cross-post.2020 @@ -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 # diff --git a/sys/unix/hints/include/cross-pre.2020 b/sys/unix/hints/include/cross-pre.2020 index b3da7e30b..846fed9c9 100644 --- a/sys/unix/hints/include/cross-pre.2020 +++ b/sys/unix/hints/include/cross-pre.2020 @@ -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