Porting issues (most likely byte order issues) - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: Porting issues (most likely byte order issues) (/thread-4754.html)
Porting issues (most likely byte order issues) - akb825 - Nov 27, 2005 01:12 PM
I've been working on a port for the PC version of Wolfenstein 3D to Mac OS X. I have all the windowing, event, and sound (though sound will likely need tweeking to work correctly): no problem. However, I then started to try and tackle the byte order issue. I though it would be rather trivial: just swap the bytes whenever they are read. Unfortunately, there's compression schemes everywhere and though I know where generally to swap the bytes, the problem is where specifically and when. With the shareware version, I'm fairly certain the problem is loading the map file, which is done mainly in CA_CacheMap in id_ca.c. There are 2 decompression algorithms in there, and I could swear that I put the byte swapping in the right place and swapping the right bytes, but apparently not, since it doesn't like what the map tells it to load. That is for the shareware version, but for the full version, I have no idea. It just loads random pictures in the menus and crashes when loading the map with a stack trace that makes no sense. (a higher level function as the only function call: not even main or anything like that shows up) I would appreciate any help anybody has to offer.
You can download the source code here. All of my byte swapping functions are in endian.c and .h. (don't mind the prefix: they came from a library I started and will finish after I complete the other game I'm making ) The datafiles are in the Debug build directory, so if you're building under 10.4, you can just do a build and run and it will run. You might want to change your resolution in config.cfg, though.
If you're building in 10.3.9, you need to do the following. First, in id_heads.h and system.h, you need to typedef int bool. You may also need to #define true and false. Also, you'll need to officially set up the prefix header for the carbon framework, since according to unknown it messes up when attempting to do that because of my prefix header already being there. (or something like that) I included OpenAL, so if you don't have it installed before, since you'd need to use a couple of command line utilities to have the app link to it if you embed it, it would just be easier if you drop it into your Frameworks directory in a Library folder.
If you want to try out the full version, a download is in our thread in Porting Games. (I reposted here since that forum hardly gets any traffic... ) Just change the #define _WOLF_SHAREWARE_ in version.h to #define _WOLF_FULL_.
Porting issues (most likely byte order issues) - zenoen - Mar 24, 2006 08:45 AM
i would think it would be nice to play the pc version ()
can i run the PC mods for wolfenstine too
or will i have to live without
Porting issues (most likely byte order issues) - DoG - Mar 24, 2006 11:47 AM
As a general rule of thumb, you should be doing byte swapping wherever you read a word longer than a byte from a buffer with differing endianness.