simplify and eliminate redundant swap macros. maschaffner@gmx.ch and btb
authorBradley Bell <btb@icculus.org>
Mon, 28 Oct 2002 20:57:11 +0000 (20:57 +0000)
committerBradley Bell <btb@icculus.org>
Mon, 28 Oct 2002 20:57:11 +0000 (20:57 +0000)
3d/interp.c
include/3d.h
include/byteswap.h
main/bm.c
main/netmisc.c
main/network.c

index f65b552..effa100 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: interp.c,v 1.7 2002-08-09 00:48:57 btb Exp $ */
+/* $Id: interp.c,v 1.8 2002-10-28 20:57:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -11,12 +11,12 @@ CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
+
 /*
  *
  * Polygon object interpreter
  *
  * Old Log:
- *
  * Revision 1.4  1995/10/10  22:20:09  allender
  * new morphing code from Matt
  *
@@ -40,7 +40,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #endif
 
 #ifdef RCS
-static char rcsid[] = "$Id: interp.c,v 1.7 2002-08-09 00:48:57 btb Exp $";
+static char rcsid[] = "$Id: interp.c,v 1.8 2002-10-28 20:57:11 btb Exp $";
 #endif
 
 #include <stdlib.h>
@@ -102,14 +102,14 @@ int glow_num = -1;
 #ifdef WORDS_BIGENDIAN
 void short_swap(short *s)
 {
-       *s = swapshort(*s);
+       *s = SWAPSHORT(*s);
 }
 
 void vms_vector_swap(vms_vector *v)
 {
-       v->x = (fix)swapint((int)v->x);
-       v->y = (fix)swapint((int)v->y);
-       v->z = (fix)swapint((int)v->z);
+       v->x = (fix)SWAPINT((int)v->x);
+       v->y = (fix)SWAPINT((int)v->y);
+       v->z = (fix)SWAPINT((int)v->z);
 }
 
 void swap_polygon_model_data(ubyte *data)
@@ -165,8 +165,8 @@ void swap_polygon_model_data(ubyte *data)
                                vms_vector_swap(vp(p + 16));
                                for (i=0;i<n;i++) {
                                        uvl_val = (g3s_uvl *)((p+30+((n&~1)+1)*2) + (i * sizeof(g3s_uvl)));
-                                       uvl_val->u = (fix)swapint((int)uvl_val->u);
-                                       uvl_val->v = (fix)swapint((int)uvl_val->v);
+                                       uvl_val->u = (fix)SWAPINT((int)uvl_val->u);
+                                       uvl_val->v = (fix)SWAPINT((int)uvl_val->v);
                                }
                                short_swap(wp(p+28));
                                for (i=0;i<n;i++)
@@ -188,8 +188,8 @@ void swap_polygon_model_data(ubyte *data)
                                vms_vector_swap(vp(p + 20));
                                vms_vector_swap(vp(p + 4));
                                short_swap(wp(p+2));
-                               *((int *)(p + 16)) = swapint(*((int *)(p + 16)));
-                               *((int *)(p + 32)) = swapint(*((int *)(p + 32)));
+                               *((int *)(p + 16)) = SWAPINT(*((int *)(p + 16)));
+                               *((int *)(p + 32)) = SWAPINT(*((int *)(p + 32)));
                                p+=36;
                                break;
 
index 02175f3..e9e5e0c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: 3d.h,v 1.6 2002-09-05 08:03:22 btb Exp $ */
+/* $Id: 3d.h,v 1.7 2002-10-28 20:57:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -353,7 +353,11 @@ bool g3_draw_morphing_model(void *model_ptr,grs_bitmap **model_bitmaps,vms_angve
 void g3_remap_interp_colors(void);
 
 // routine to convert little to big endian in polygon model data
+#ifdef WORDS_BIGENDIAN
 void swap_polygon_model_data(ubyte *data);
+#else
+#define swap_polygon_model_date(data)
+#endif
 
 #endif
 
index 2933aa9..18d98c7 100644 (file)
@@ -8,7 +8,7 @@ IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
-AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 */
 
@@ -17,11 +17,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 
 #include "pstypes.h"
 
-#if 0
-extern ushort swapshort(ushort s);
-extern uint swapint(uint i);
-#endif
-
 #define SWAPSHORT(x) (((ubyte)x << 8) | (((ushort)x) >> 8))
 #define SWAPINT(x)   ((x<<24) | (((uint)x) >> 24) | ((x &0x0000ff00) << 8) | ((x & 0x00ff0000) >> 8))
 
@@ -33,7 +28,4 @@ extern uint swapint(uint i);
 #define INTEL_SHORT(x) SWAPSHORT(x)
 #endif
 
-#define swapint(x)   INTEL_INT(x)
-#define swapshort(x) INTEL_SHORT(x)
-
 #endif
index 09d6787..006a4e6 100644 (file)
--- a/main/bm.c
+++ b/main/bm.c
@@ -1,4 +1,4 @@
-/* $Id: bm.c,v 1.18 2002-10-03 03:46:34 btb Exp $ */
+/* $Id: bm.c,v 1.19 2002-10-28 20:57:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -55,7 +55,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include "player.h"
 #include "endlevel.h"
 #include "cntrlcen.h"
-#include "byteswap.h"
 #include "makesig.h"
 
 ubyte Sounds[MAX_SOUNDS];
@@ -225,17 +224,13 @@ void load_exit_models()
                Polygon_models[exit_modelnum].model_data = d_malloc(Polygon_models[exit_modelnum].model_data_size);
                Assert( Polygon_models[exit_modelnum].model_data != NULL );
                cfread( Polygon_models[exit_modelnum].model_data, sizeof(ubyte), Polygon_models[exit_modelnum].model_data_size, exit_hamfile );
-#ifdef WORDS_BIGENDIAN
                swap_polygon_model_data(Polygon_models[exit_modelnum].model_data);
-#endif
                g3_init_polygon_model(Polygon_models[exit_modelnum].model_data);
 
                Polygon_models[destroyed_exit_modelnum].model_data = d_malloc(Polygon_models[destroyed_exit_modelnum].model_data_size);
                Assert( Polygon_models[destroyed_exit_modelnum].model_data != NULL );
                cfread( Polygon_models[destroyed_exit_modelnum].model_data, sizeof(ubyte), Polygon_models[destroyed_exit_modelnum].model_data_size, exit_hamfile );
-#ifdef WORDS_BIGENDIAN
                swap_polygon_model_data(Polygon_models[destroyed_exit_modelnum].model_data);
-#endif
                g3_init_polygon_model(Polygon_models[destroyed_exit_modelnum].model_data);
                cfclose(exit_hamfile);
 
@@ -311,9 +306,7 @@ void bm_read_all(CFILE * fp)
                Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size);
                Assert( Polygon_models[i].model_data != NULL );
                cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
-#ifdef WORDS_BIGENDIAN
                swap_polygon_model_data(Polygon_models[i].model_data);
-#endif
                g3_init_polygon_model(Polygon_models[i].model_data);
        }
 
@@ -422,9 +415,7 @@ void bm_read_extra_robots(char *fname,int type)
                Polygon_models[i].model_data = d_malloc(Polygon_models[i].model_data_size);
                Assert( Polygon_models[i].model_data != NULL );
                cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
-#ifdef WORDS_BIGENDIAN
                swap_polygon_model_data(Polygon_models[i].model_data);
-#endif
                g3_init_polygon_model(Polygon_models[i].model_data);
        }
 
@@ -501,9 +492,7 @@ void load_robot_replacements(char *level_name)
                Assert( Polygon_models[i].model_data != NULL );
 
                cfread( Polygon_models[i].model_data, sizeof(ubyte), Polygon_models[i].model_data_size, fp );
-#ifdef WORDS_BIGENDIAN
                swap_polygon_model_data(Polygon_models[i].model_data);
-#endif
                g3_init_polygon_model(Polygon_models[i].model_data);
 
                Dying_modelnums[i] = cfile_read_int(fp);
index 5ce6f11..b37b737 100644 (file)
@@ -16,7 +16,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #endif
 
 #ifdef RCS
-static char rcsid[] = "$Id: netmisc.c,v 1.5 2002-10-10 19:12:00 btb Exp $";
+static char rcsid[] = "$Id: netmisc.c,v 1.6 2002-10-28 20:57:11 btb Exp $";
 #endif
 
 #include <stdio.h>
@@ -128,7 +128,6 @@ ushort netmisc_calc_checksum_pc( void * vptr, int len )
 // this code must be kept in total sync
 
 #include "ipx.h"
-#include "byteswap.h"
 #include "multi.h"
 #ifdef NETWORK
 #include "network.h"
@@ -152,7 +151,7 @@ void receive_netplayer_info(ubyte *data, netplayer_info *info)
        info->connected = data[loc];                                                            loc++;
        memcpy(&(info->socket), &(data[loc]), 2);                                       loc += 2; 
    memcpy (&(info->rank),&(data[loc]),1);                                         loc++;
-//MWA  don't think we need to swap this because we need it in high order       info->socket = swapshort(info->socket);
+//MWA  don't think we need to swap this because we need it in high order       info->socket = INTEL_SHORT(info->socket);
 }
 
 void send_netplayers_packet(ubyte *server, ubyte *node)
@@ -215,7 +214,7 @@ void send_sequence_packet(sequence_packet seq, ubyte *server, ubyte *node, ubyte
        out_buffer[loc] = seq.player.version_minor;                                             loc++;
        out_buffer[loc] = seq.player.computer_type;                                             loc++;
        out_buffer[loc] = seq.player.connected;                                                 loc++;
-       tmps = swapshort(seq.player.socket);
+       tmps = INTEL_SHORT(seq.player.socket);
        memcpy(&(out_buffer[loc]), &tmps, 2);                                                   loc += 2;
    out_buffer[loc]=seq.player.rank;                                                                    loc++;          // for pad byte
        if (net_address != NULL)        
@@ -450,12 +449,12 @@ void receive_netgame_packet(ubyte *data, netgame_info *netgame, int lite_flag)
        memcpy(&(netgame->level_time), &(data[loc]), 4);                                        loc += 4;
        netgame->level_time = INTEL_INT(netgame->level_time);
        memcpy(&(netgame->control_invul_time), &(data[loc]), 4);                        loc += 4;
-       netgame->control_invul_time = swapint(netgame->control_invul_time);
+       netgame->control_invul_time = INTEL_INT(netgame->control_invul_time);
        memcpy(&(netgame->monitor_vector), &(data[loc]), 4);                            loc += 4;
-       netgame->monitor_vector = swapint(netgame->monitor_vector);
+       netgame->monitor_vector = INTEL_INT(netgame->monitor_vector);
        for (i = 0; i < MAX_PLAYERS; i++) {
                memcpy(&(netgame->player_score[i]), &(data[loc]), 4);                   loc += 4;
-               netgame->player_score[i] = swapint(netgame->player_score[i]);
+               netgame->player_score[i] = INTEL_INT(netgame->player_score[i]);
        }
        for (i = 0; i < MAX_PLAYERS; i++) {
                memcpy(&(netgame->player_flags[i]), &(data[loc]), 1); loc++;
index 1c68f22..ac01a2e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: network.c,v 1.15 2002-10-11 00:36:46 btb Exp $ */
+/* $Id: network.c,v 1.16 2002-10-28 20:57:11 btb Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -17,7 +17,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #endif
 
 #ifdef RCS
-static char rcsid[] = "$Id: network.c,v 1.15 2002-10-11 00:36:46 btb Exp $";
+static char rcsid[] = "$Id: network.c,v 1.16 2002-10-28 20:57:11 btb Exp $";
 #endif
 
 #define PATCH12
@@ -4942,7 +4942,7 @@ void squish_short_frame_info(short_frame_info old_info, ubyte *data)
        
        data[0] = old_info.type;                                            loc++;
        /* skip three for pad byte */                                       loc += 3;
-       tmpi = swapint(old_info.numpackets);
+       tmpi = INTEL_INT(old_info.numpackets);
        memcpy(&(data[loc]), &tmpi, 4);                                     loc += 4;
 
        memcpy(&(data[loc]), old_info.thepos.bytemat, 9);                   loc += 9;
@@ -4961,7 +4961,7 @@ void squish_short_frame_info(short_frame_info old_info, ubyte *data)
        tmps = INTEL_SHORT(old_info.thepos.velz);
        memcpy(&(data[loc]), &tmps, 2);                                     loc += 2;
 
-       tmps = swapshort(old_info.data_size);
+       tmps = INTEL_SHORT(old_info.data_size);
        memcpy(&(data[loc]), &tmps, 2);                                     loc += 2;
 
        data[loc] = old_info.playernum;                                     loc++;