shithub: choc

Download patch

ref: 3fcdb6dc1835c87655ae45a1d362dc8b09f6849c
parent: a78ddf0ecadb3580f5f09b09a931abc5734b7f33
author: Simon Howard <[email protected]>
date: Wed Jan 4 21:48:03 EST 2006

Fixes for big endian machines (thanks locust)

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 255

--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 
+    Fixes for big endian machines (thanks locust)
+
 0.1.2 (2005-10-29):
 
     Silence sounds at odd sample rates (rather than bombing out); this
--- a/configure.in
+++ b/configure.in
@@ -45,6 +45,8 @@
 
 AC_SUBST(ac_aux_dir)
 
+AC_C_BIGENDIAN
+
 AC_OUTPUT([
 Makefile
 textscreen/Makefile
--- a/src/m_swap.c
+++ b/src/m_swap.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: m_swap.c 18 2005-07-23 18:56:07Z fraggle $
+// $Id: m_swap.c 255 2006-01-05 02:48:03Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -22,6 +22,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.4  2006/01/05 02:48:03  fraggle
+// Fixes for big endian machines (thanks locust)
+//
 // Revision 1.3  2005/07/23 18:56:07  fraggle
 // Remove unneccessary pragmas
 //
@@ -38,7 +41,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: m_swap.c 18 2005-07-23 18:56:07Z fraggle $";
+rcsid[] = "$Id: m_swap.c 255 2006-01-05 02:48:03Z fraggle $";
 
 
 #include "m_swap.h"
@@ -45,7 +48,7 @@
 
 
 // Not needed with big endian.
-#ifndef __BIG_ENDIAN__
+#ifndef WORDS_BIGENDIAN
 
 // Swap 16bit, that is, MSB and LSB byte.
 unsigned short SwapSHORT(unsigned short x)
--- a/src/m_swap.h
+++ b/src/m_swap.h
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: m_swap.h 75 2005-09-05 22:50:56Z fraggle $
+// $Id: m_swap.h 255 2006-01-05 02:48:03Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -35,7 +35,7 @@
 
 // Endianess handling.
 // WAD files are stored little endian.
-#ifdef __BIG_ENDIAN__
+#ifdef WORDS_BIGENDIAN
 short	SwapSHORT(short);
 long	SwapLONG(long);
 #define SHORT(x)	((short)SwapSHORT((unsigned short) (x)))
@@ -43,10 +43,6 @@
 #else
 #define SHORT(x)	(x)
 #define LONG(x)         (x)
-#define doom_wtohs(x)   ((short int) (x))
-#define doom_htows(x)   ((short int) (x))
-#define doom_wtohl(x)   ((long int) (x))
-#define doom_htowl(x)   ((long int) (x))
 #endif
 
 
@@ -56,6 +52,9 @@
 //-----------------------------------------------------------------------------
 //
 // $Log$
+// Revision 1.5  2006/01/05 02:48:03  fraggle
+// Fixes for big endian machines (thanks locust)
+//
 // Revision 1.4  2005/09/05 22:50:56  fraggle
 // Add mmus2mid code from prboom.  Use 'void *' for music handles.  Pass
 // length of data when registering music.
--- a/src/mmus2mid.c
+++ b/src/mmus2mid.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: mmus2mid.c 76 2005-09-06 21:06:45Z fraggle $
+// $Id: mmus2mid.c 255 2006-01-05 02:48:03Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 //  Copyright (C) 1999 by
@@ -27,6 +27,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.3  2006/01/05 02:48:03  fraggle
+// Fixes for big endian machines (thanks locust)
+//
 // Revision 1.2  2005/09/06 21:06:45  fraggle
 // Newer versions of mmus2mid.c,h from prboom
 //
@@ -340,11 +343,11 @@
   // copy the MUS header from the MUS buffer to the MUSh header structure
 
   memcpy(&MUSh,mus,sizeof(MUSheader));
-  MUSh.ScoreLength = doom_wtohs(MUSh.ScoreLength);
-  MUSh.ScoreStart  = doom_wtohs(MUSh.ScoreStart);
-  MUSh.channels    = doom_wtohs(MUSh.channels);
-  MUSh.SecChannels = doom_wtohs(MUSh.SecChannels);
-  MUSh.InstrCnt    = doom_wtohs(MUSh.InstrCnt);
+  MUSh.ScoreLength = SHORT(MUSh.ScoreLength);
+  MUSh.ScoreStart  = SHORT(MUSh.ScoreStart);
+  MUSh.channels    = SHORT(MUSh.channels);
+  MUSh.SecChannels = SHORT(MUSh.SecChannels);
+  MUSh.InstrCnt    = SHORT(MUSh.InstrCnt);
 
   // check some things and set length of MUS buffer from internal data