summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2004-12-22 21:12:36 +0000
committerbjarni <bjarni@openttd.org>2004-12-22 21:12:36 +0000
commita92dc63ec90343fbe1b403719882a7f8876f67ba (patch)
tree152ac6fd50333783aaad3a27f3e03b5dda93fd45
parente04e8f53c36fc089b233ebe58252b8e675d58f2f (diff)
downloadopenttd-a92dc63ec90343fbe1b403719882a7f8876f67ba.tar.xz
(svn r1236) MorphOS: added make release like in OSX (tokai)
MorphOS: cleaned up the code telling the difference between AmigaOS and MorphOS (tokai)
-rw-r--r--Makefile32
-rw-r--r--dedicated.c9
-rw-r--r--intro_gui.c2
-rw-r--r--misc.c14
-rw-r--r--network.c68
-rw-r--r--network_core.h16
-rwxr-xr-xos/morphos/icons/OpenTTD.infobin0 -> 8110 bytes
-rwxr-xr-xos/morphos/icons/docs.infobin0 -> 5390 bytes
-rw-r--r--os/morphos/icons/document.infobin0 -> 4451 bytes
-rwxr-xr-xos/morphos/icons/drawer.infobin0 -> 5390 bytes
-rw-r--r--stdafx.h23
-rw-r--r--ttd.c11
-rw-r--r--unix.c5
13 files changed, 137 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index e974e4920..e63ee0526 100644
--- a/Makefile
+++ b/Makefile
@@ -748,6 +748,38 @@ lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt
winres.o: ttd.rc
windres -o $@ $<
+ifdef MORPHOS
+release: all
+ @rm -fr "/t/openttd-$(RELEASE)-morphos.lha"
+ @mkdir -p "/t/"
+ @mkdir -p "/t/openttd-$(RELEASE)-morphos"
+ @mkdir -p "/t/openttd-$(RELEASE)-morphos/docs"
+ @mkdir -p "/t/openttd-$(RELEASE)-morphos/data"
+ @mkdir -p "/t/openttd-$(RELEASE)-morphos/lang"
+ @cp -R $(TTD) "/t/openttd-$(RELEASE)-morphos/"
+ @cp data/* "/t/openttd-$(RELEASE)-morphos/data/"
+ @cp lang/*.lng "/t/openttd-$(RELEASE)-morphos/lang/"
+ @cp readme.txt "/t/openttd-$(RELEASE)-morphos/docs/ReadMe"
+ @cp docs/console.txt "/t/openttd-$(RELEASE)-morphos/docs/Console"
+ @cp COPYING "/t/openttd-$(RELEASE)-morphos/docs/"
+ @cp changelog.txt "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog"
+ @cp os/morphos/icons/openttd.info "/t/openttd-$(RELEASE)-morphos/$(TTD).info"
+ @cp os/morphos/icons/docs.info "/t/openttd-$(RELEASE)-morphos/docs.info"
+ @cp os/morphos/icons/drawer.info "/t/openttd-$(RELEASE)-morphos.info"
+ @cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ReadMe.info"
+ @cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/Console.info"
+ @cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/COPYING.info"
+ @cp os/morphos/icons/document.info "/t/openttd-$(RELEASE)-morphos/docs/ChangeLog.info"
+ @strip --strip-all --strip-unneeded --remove-section .comment "/t/openttd-$(RELEASE)-morphos/$(TTD)"
+ @lha a -r "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos"
+ @lha a "t:openttd-$(RELEASE)-morphos.lha" "t:openttd-$(RELEASE)-morphos.info"
+ @rm -fr "/t/openttd-$(RELEASE)-morphos"
+ @rm -fr "/t/openttd-$(RELEASE)-morphos.info"
+ @echo "Release archive can be found in RAM:t/ now."
+
+.PHONY: release
+endif
+
ifdef OSX
release: all
@mkdir -p "OpenTTD $(RELEASE)"
diff --git a/dedicated.c b/dedicated.c
index 5197dd924..051573bee 100644
--- a/dedicated.c
+++ b/dedicated.c
@@ -20,6 +20,13 @@
# include <signal.h>
# define STDIN 0 /* file descriptor for standard input */
#endif
+#ifdef __MORPHOS__
+/* voids the fork, option will be disabled for morphos build anyway, because MorphOS
+ * doesn't support forking (could only implemented with lots of code changes here).
+ */
+int morphos_dummy_fork() { return -1; }
+#define fork morphos_dummy_fork
+#endif
// This file handles all dedicated-server in- and outputs
@@ -167,7 +174,7 @@ static int DedicatedVideoMainLoop()
next_tick = (tim.tv_usec / 1000) + 30 + (tim.tv_sec * 1000);
#endif
- /* Siganl handlers */
+ /* Signal handlers */
#ifdef UNIX
signal(SIGTERM, DedicatedSignalHandler);
signal(SIGINT, DedicatedSignalHandler);
diff --git a/intro_gui.c b/intro_gui.c
index 74716f0ca..a4f77fcb0 100644
--- a/intro_gui.c
+++ b/intro_gui.c
@@ -198,7 +198,7 @@ static void AskAbandonGameWndProc(Window *w, WindowEvent *e) {
SetDParam(0, STR_OSNAME_BEOS);
#elif defined(__MORPHOS__)
SetDParam(0, STR_OSNAME_MORPHOS);
-#elif defined(__AMIGA__) /* note: __AMIGA__ is defined under MorphOS too, so it must be after __MORPHOS__. */
+#elif defined(__AMIGA__)
SetDParam(0, STR_OSNAME_AMIGAOS);
#else
SetDParam(0, STR_0134_UNIX);
diff --git a/misc.c b/misc.c
index 8ce6e8ce0..dcb18656d 100644
--- a/misc.c
+++ b/misc.c
@@ -107,14 +107,14 @@ void SetDate(uint date)
// multi os compatible sleep function
-#if defined(__AMIGA__)
+#ifdef __AMIGA__
// usleep() implementation
# include <devices/timer.h>
# include <dos/dos.h>
- static struct Device *TimerBase = NULL;
- static struct MsgPort *TimerPort = NULL;
- static struct timerequest *TimerRequest = NULL;
+ extern struct Device *TimerBase = NULL;
+ extern struct MsgPort *TimerPort = NULL;
+ extern struct timerequest *TimerRequest = NULL;
#endif // __AMIGA__
void CSleep(int milliseconds)
@@ -123,13 +123,13 @@ void CSleep(int milliseconds)
Sleep(milliseconds);
#endif
#if defined(UNIX)
- #if !defined(__BEOS__) && !defined(__AMIGAOS__)
+ #if !defined(__BEOS__) && !defined(__AMIGA__)
usleep(milliseconds * 1000);
#endif
#ifdef __BEOS__
snooze(milliseconds * 1000);
#endif
- #if defined(__AMIGAOS__) && !defined(__MORPHOS__)
+ #if defined(__AMIGA__)
{
ULONG signals;
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
@@ -145,7 +145,7 @@ void CSleep(int milliseconds)
}
WaitIO((struct IORequest *)TimerRequest);
}
- #endif // __AMIGAOS__ && !__MORPHOS__
+ #endif // __AMIGA__
#endif
}
diff --git a/network.c b/network.c
index 46f8dddb3..3f2d1e9d4 100644
--- a/network.c
+++ b/network.c
@@ -23,6 +23,11 @@
#include <stdarg.h> /* va_list */
#include "md5.h"
+#ifdef __MORPHOS__
+// the library base is required here
+struct Library *SocketBase = NULL;
+#endif
+
// The listen socket for the server
static SOCKET _listensocket;
@@ -1255,7 +1260,39 @@ static void NetworkGenerateUniqueId(void)
void NetworkStartUp(void)
{
DEBUG(net, 3) ("[NET][Core] Starting network...");
- // Network is available
+
+ #if defined(__MORPHOS__) || defined(__AMIGA__)
+ /*
+ * IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
+ * network related function, else: crash.
+ */
+ {
+ DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
+ if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
+ DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
+ _network_available = false;
+ return;
+ }
+
+ #if defined(__AMIGA__)
+ // for usleep() implementation (only required for legacy AmigaOS builds)
+ if ( (TimerPort = CreateMsgPort()) ) {
+ if ( (TimerRequest = (struct timerequest *) CreateIORequest(TimerPort, sizeof(struct timerequest))) ) {
+ if ( OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) TimerRequest, 0) == 0 ) {
+ if ( !(TimerBase = TimerRequest->tr_node.io_Device) ) {
+ // free ressources...
+ DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
+ _network_available = false;
+ return;
+ }
+ }
+ }
+ }
+ #endif // __AMIGA__
+ }
+ #endif // __MORPHOS__ / __AMIGA__
+
+ // Network is available
_network_available = true;
_network_dedicated = false;
_network_last_advertise_date = 0;
@@ -1287,33 +1324,6 @@ void NetworkStartUp(void)
return;
}
}
- #else
- #if defined(__MORPHOS__) || defined(__AMIGA__)
- {
- DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
- if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
- DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
- _network_available = false;
- return;
- }
-
- #if defined(__AMIGA__)
- // for usleep() implementation (only required for legacy AmigaOS builds)
- if ( (TimerPort = CreateMsgPort()) ) {
- if ( (TimerRequest = (struct timerequest *) CreateIORequest(TimerPort, sizeof(struct timerequest))) ) {
- if ( OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) TimerRequest, 0) == 0 ) {
- if ( !(TimerBase = TimerRequest->tr_node.io_Device) ) {
- // free ressources...
- DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
- _network_available = false;
- return;
- }
- }
- }
- }
- #endif // __AMIGA__
- }
- #endif // __MORPHOS__ / __AMIGA__
#endif // WIN32
NetworkInitialize();
@@ -1331,7 +1341,7 @@ void NetworkShutDown(void)
#if defined(__MORPHOS__) || defined(__AMIGA__)
{
// free allocated ressources
- #if !defined(__MORPHOS__)
+ #if defined(__AMIGA__)
if (TimerBase) { CloseDevice((struct IORequest *) TimerRequest); }
if (TimerRequest) { DeleteIORequest(TimerRequest); }
if (TimerPort) { DeleteMsgPort(TimerPort); }
diff --git a/network_core.h b/network_core.h
index 37c51cd5d..4eaea2d81 100644
--- a/network_core.h
+++ b/network_core.h
@@ -52,7 +52,7 @@ typedef struct ifreq IFREQ;
# include <netinet/tcp.h>
# include <arpa/inet.h>
# include <net/if.h>
-# if !defined(SUNOS)
+# if !defined(SUNOS) && !defined(__MORPHOS__)
# include <ifaddrs.h>
// If for any reason ifaddrs.h does not exist on a system, remove define below
// and an other system will be used to fetch ips from the system
@@ -71,7 +71,8 @@ typedef struct ifreq IFREQ;
# include <exec/types.h>
# include <proto/exec.h> // required for Open/CloseLibrary()
# if defined(__MORPHOS__)
-# include <sys/filio.h> // FION#? defines
+# include <sys/filio.h> // FIO* defines
+# include <sys/sockio.h> // SIO* defines
# else // __AMIGA__
# include <proto/socket.h>
# endif
@@ -80,8 +81,17 @@ typedef struct ifreq IFREQ;
# define closesocket(s) CloseSocket(s)
# define GET_LAST_ERROR() Errno()
# define ioctlsocket(s,request,status) IoctlSocket((LONG)s,(ULONG)request,(char*)status)
+# define ioctl ioctlsocket
- struct Library *SocketBase = NULL;
+ typedef unsigned int in_addr_t;
+ extern struct Library *SocketBase;
+
+# ifdef __AMIGA__
+ // for usleep() implementation
+ extern struct Device *TimerBase;
+ extern struct MsgPort *TimerPort;
+ extern struct timerequest *TimerRequest;
+# endif
#endif // __MORPHOS__ || __AMIGA__
#endif // NETWORK_CORE_H
diff --git a/os/morphos/icons/OpenTTD.info b/os/morphos/icons/OpenTTD.info
new file mode 100755
index 000000000..fd6cafa49
--- /dev/null
+++ b/os/morphos/icons/OpenTTD.info
Binary files differ
diff --git a/os/morphos/icons/docs.info b/os/morphos/icons/docs.info
new file mode 100755
index 000000000..6f8ac00f2
--- /dev/null
+++ b/os/morphos/icons/docs.info
Binary files differ
diff --git a/os/morphos/icons/document.info b/os/morphos/icons/document.info
new file mode 100644
index 000000000..877ea3575
--- /dev/null
+++ b/os/morphos/icons/document.info
Binary files differ
diff --git a/os/morphos/icons/drawer.info b/os/morphos/icons/drawer.info
new file mode 100755
index 000000000..149ef7e10
--- /dev/null
+++ b/os/morphos/icons/drawer.info
Binary files differ
diff --git a/stdafx.h b/stdafx.h
index 15a59c7a0..30313085b 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -32,6 +32,27 @@
#include <alloca.h>
#endif
+#ifdef __MORPHOS__
+// morphos defines certain amiga defines per default, we undefine them
+// here to make the rest of source less messy and more clear what is
+// required for morphos and what for amigaos
+# ifdef amigaos
+# undef amigaos
+# endif
+# ifdef __amigaos__
+# undef __amigaos__
+# endif
+# ifdef __AMIGA__
+# undef __AMIGA__
+# endif
+# ifdef AMIGA
+# undef AMIGA
+# endif
+# ifdef amiga
+# undef amiga
+# endif
+#endif /* __MORPHOS__ */
+
#define BSWAP32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) << 8) & 0xFF0000) | (((x) << 24) & 0xFF000000))
#define BSWAP16(x) ((x) >> 8 | (x) << 8)
@@ -182,7 +203,7 @@ assert_compile(sizeof(uint8) == 1);
#define CloseConnection OTTD_CloseConnection
#endif
-#if !(defined(__AMIGA__) && !defined(__MORPHOS__))
+#ifdef __AMIGA__
// it seems AmigaOS already have a Point declared
#define Point OTTD_AMIGA_POINT
#endif
diff --git a/ttd.c b/ttd.c
index b7fbbffc9..c3647c253 100644
--- a/ttd.c
+++ b/ttd.c
@@ -314,7 +314,9 @@ static void showhelp()
" -G seed = Set random seed\n"
" -n [ip#player:port] = Start networkgame\n"
" -D = Start dedicated server\n"
+ #if !defined(__MORPHOS__) && !defined(__AMIGA__)
" -f = Fork into the background (dedicated only)\n"
+ #endif
" -i = Force to use the DOS palette (use this if you see a lot of pink)\n"
" -p #player = Player as #player (deprecated) (network only)\n"
);
@@ -526,6 +528,7 @@ int ttd_main(int argc, char* argv[])
bool network = false;
char *network_conn = NULL;
char *language = NULL;
+ char *optformat;
char musicdriver[16], sounddriver[16], videodriver[16];
int resolution[2] = {0,0};
uint startdate = -1;
@@ -541,7 +544,13 @@ int ttd_main(int argc, char* argv[])
// a letter means: it accepts that param (e.g.: -h)
// a ':' behind it means: it need a param (e.g.: -m<driver>)
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
- MyGetOptInit(&mgo, argc-1, argv+1, "m:s:v:hDfn::l:eit:d::r:g::G:p:");
+ #if !defined(__MORPHOS__) && !defined(__AMIGA__)
+ optformat = "m:s:v:hDfn::l:eit:d::r:g::G:p:";
+ #else
+ optformat = "m:s:v:hDn::l:eit:d::r:g::G:p:"; // no fork option
+ #endif
+
+ MyGetOptInit(&mgo, argc-1, argv+1, optformat);
while ((i = MyGetOpt(&mgo)) != -1) {
switch(i) {
case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
diff --git a/unix.c b/unix.c
index 6e43d2878..ca4d19c8b 100644
--- a/unix.c
+++ b/unix.c
@@ -23,6 +23,11 @@
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
#endif /* __MORPHOS__ */
+#ifdef __AMIGA__
+#warning add stack symbol to avoid that user needs to set stack manually (tokai)
+// ULONG __stack =
+#endif
+
static char *_fios_path;
static char *_fios_save_path;
static char *_fios_scn_path;