From e459f5ee02fc248577b62b1831d4994cf4f25fe6 Mon Sep 17 00:00:00 2001 From: tigital Date: Fri, 11 Jun 2004 00:29:22 +0000 Subject: [PATCH] byte-swapping changes for bigendian systems --- src/anim/animplay.cpp | 11 +++++++++-- src/cfile/cfile.cpp | 10 ++++++++-- src/cfile/cfilesystem.cpp | 11 +++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/anim/animplay.cpp b/src/anim/animplay.cpp index 9a77880..6e2afda 100644 --- a/src/anim/animplay.cpp +++ b/src/anim/animplay.cpp @@ -15,6 +15,9 @@ * C module for playing back anim files * * $Log$ + * Revision 1.4 2004/06/11 00:27:06 tigital + * byte-swapping changes for bigendian systems + * * Revision 1.3 2002/06/09 04:41:15 relnev * added copyright header * @@ -791,13 +794,13 @@ void anim_release_all_instances(int screen_id) // 2 | version number // 2 | fps // 1 | transparent red value -// 1 | transparent green value +// 1 | transparent green value // 1 | transparent blue value // 2 | width // 2 | height // 2 | number of frames // 2 | packer code -// 763 | palette +// 763 | palette // 2 | number of key frames // 2 | key frame number } repeats // 4 | key frame offset } repeats @@ -859,6 +862,7 @@ void anim_read_header(anim *ptr, CFILE *fp) ptr->total_frames = cfread_short(fp); cfread(&ptr->packer_code, 1, 1, fp); + ptr->packer_code = INTEL_SHORT(ptr->packer_code); cfread(&ptr->palette, 256, 3, fp); ptr->num_keys = cfread_short(fp); @@ -946,6 +950,8 @@ anim *anim_load(char *real_filename, int file_mapped) ptr->keys[idx].frame_num = 0; cfread(&ptr->keys[idx].frame_num, 2, 1, fp); cfread(&ptr->keys[idx].offset, 4, 1, fp); + ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num ); + ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset ); } /*prev_keyp = &ptr->keys; @@ -961,6 +967,7 @@ anim *anim_load(char *real_filename, int file_mapped) cfread(&keyp->offset, 4, 1, fp); }*/ cfread(&count, 4, 1, fp); // size of compressed data + count = INTEL_INT( count ); ptr->cfile_ptr = NULL; diff --git a/src/cfile/cfile.cpp b/src/cfile/cfile.cpp index 1374271..1e438ea 100644 --- a/src/cfile/cfile.cpp +++ b/src/cfile/cfile.cpp @@ -15,6 +15,9 @@ * Utilities for operating on files * * $Log$ + * Revision 1.10 2004/06/11 00:28:39 tigital + * byte-swapping changes for bigendian systems + * * Revision 1.9 2003/05/25 02:30:42 taylor * Freespace 1 support * @@ -1138,6 +1141,9 @@ void cf_set_version( CFILE * cfile, int version ) // routines to read basic data types from CFILE's. Put here to // simplify mac/pc reading from cfiles. +#ifdef __APPLE__ +#include +#endif float cfread_float(CFILE *file, int ver, float deflt) { @@ -1149,7 +1155,7 @@ float cfread_float(CFILE *file, int ver, float deflt) if (cfread( &f, sizeof(f), 1, file) != 1) return deflt; -// i = INTEL_INT(i); // hmm, not sure what to do here + f = INTEL_FLOAT(&f); return f; } @@ -1295,7 +1301,7 @@ void cfread_string_len(char *buf,int n, CFILE *file) int cfwrite_float(float f, CFILE *file) { -// i = INTEL_INT(i); // hmm, not sure what to do here + f = INTEL_FLOAT(&f); return cfwrite(&f, sizeof(f), 1, file); } diff --git a/src/cfile/cfilesystem.cpp b/src/cfile/cfilesystem.cpp index acc8de0..82e51ff 100644 --- a/src/cfile/cfilesystem.cpp +++ b/src/cfile/cfilesystem.cpp @@ -19,6 +19,9 @@ * all those locations, inherently enforcing precedence orders. * * $Log$ + * Revision 1.10 2004/06/11 00:29:22 tigital + * byte-swapping changes for bigendian systems + * * Revision 1.9 2003/05/27 03:03:11 taylor * fix second root (gamedir) searching * @@ -694,6 +697,10 @@ void cf_search_root_pack(int root_index) Assert( sizeof(VP_header) == 16 ); fread(&VP_header, 1, sizeof(VP_header), fp); + VP_header.version = INTEL_INT( VP_header.version); + VP_header.index_offset = INTEL_INT( VP_header.index_offset); + VP_header.num_files = INTEL_INT( VP_header.num_files); + // Read index info fseek(fp, VP_header.index_offset, SEEK_SET); @@ -707,6 +714,10 @@ void cf_search_root_pack(int root_index) fread( &find, sizeof(VP_FILE), 1, fp ); + find.offset = INTEL_INT( find.offset ); + find.size = INTEL_INT( find.size ); + find.write_time = INTEL_INT(find.write_time); + if ( find.size == 0 ) { if ( !stricmp( find.filename, ".." )) { int l = strlen(search_path); -- 2.39.2