Porting issues (most likely byte order issues)

Moderator
Posts: 1,140
Joined: 2005.07
Post: #1
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 Rasp) 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... Sneaky) Just change the #define _WOLF_SHAREWARE_ in version.h to #define _WOLF_FULL_.
Quote this message in a reply
zenoen
Unregistered
 
Post: #2
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
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  PackageManager issues StevenPeeler 2 4,206 Feb 10, 2011 10:07 AM
Last Post: StevenPeeler
  cross development issues JeroMiya 2 3,172 Mar 25, 2007 11:33 AM
Last Post: OneSadCookie
  Unity issues stevejohnson 2 2,685 Nov 20, 2006 08:53 PM
Last Post: stevejohnson
  Xcode 1.5 + SDL 1.2.11 issues erkokite 3 2,746 Sep 2, 2006 03:48 PM
Last Post: OneSadCookie
  More Issues kodex 5 4,504 Jun 11, 2005 07:35 AM
Last Post: wadesworld