This patch adds bigendian detection, so the tool can communicate 
successfully on bigendian platforms with the dreamcast.

Tested on sparc64

written by Raphael Assenat <raph@raphnet.net>

--- dcload-1.0.3/host-src/tool/dc-tool.c	2001-09-27 11:23:02.000000000 -0400
+++ dcload-1.0.3-edited/host-src/tool/dc-tool.c	2004-03-13 20:19:04.854802993 -0500
@@ -40,6 +40,33 @@
 
 int _nl_msg_cat_cntr;
 
+/* The dreamcast is little endian, so swap the bytes
+ * only if the current platform is big endian. */
+static void DC_Host_Swap(unsigned int *value)
+{
+	static int detected=0;
+	static int big_endian=0;
+
+	if (!detected) {
+		/* Runtime detection. Should be very portable,
+		 * but adds more overhead than ifdefs. */
+		int i = 0;
+		((char *)(&i))[0] = 1;
+		if (i != 1) {
+			/* platform is big endian */
+			big_endian = 1;
+		}
+		detected = 1;
+	}
+
+	if (!big_endian) { return; }
+
+	*value = (((*value)&0xFF) << 24) |
+			(((*value)&0xFF00) << 8) |
+			(((*value)&0xFF0000) >> 8) |
+			(((*value)&0xFF000000) >> 24);
+}
+
 #define DCLOADBUFFER 8192
 #ifdef _WIN32
 #define DATA_BITS	8
@@ -239,14 +266,18 @@
     }
 }
 
+
 /* send 4 bytes */
 int send_uint(unsigned int value)
 {
     unsigned int tmp;
-    
-    serial_write(&value, 4);
-    blread(&tmp, 4);
 
+	DC_Host_Swap(&value);
+	serial_write(&value, 4);
+
+	blread(&tmp, 4);
+	DC_Host_Swap(&tmp);
+	
     if (tmp != value)
 	return 0;
 
@@ -260,6 +291,8 @@
 
     blread(&tmp, 4);
 
+	DC_Host_Swap(&tmp);
+	
     return (tmp);
 }
 
