Originally posted by Syphor:
I have made a program which will tell me the version number of the MD2 file called "tris.md2", I have compiled this on linux and freebsd though the very same program doesn't work on darwin/macos x....
it comes up with diff outputs:
FreeBSD: Version is 8
Linux: Version is 8
Mac OS X: Version is 134217728
http://syphor.homeip.net/MD2
download md2.c, md2.h, tris.md2 and then type "cc -o run md2.c" then "./run"
Any help would be very very very appriciated
To actually connect to the site, use
http://syphor.homeip.net/MD2/ folks.
And on to the problem...
The problem is that the file stores data on disk in little endian byte format, whereas Macs use a big endian byte format. Here's what happens:
The version is stored as a 32 bit number as this is the size of ints on most computers today. On a little endian machine, 8 when extended out to be 32 bits is stored as:
0x08 0x00 0x00 0x00
On a PowerPC machine (big endian), 8 is represented as:
0x00 0x00 0x00 0x08
Hence when you read that top number in, it is, in big endian format actually 134217728.
You'll need to come up with a way convert from little endian to big endian to read it on any big endian machine, such as SPARC, PowerPC, Motorola 680x0, or basically anything but i386/VAX/IA-64.
- proton