SRB2 Mac OS X Port

Status
Not open for further replies.

Sappharad

Member
srb2_mac1.png

Here's a port of 2.0.0, the current version on the website, to Mac OS X.

http://projects.sappharad.com/srb2_mac/

Everything you need to run the program is bundled inside the app. I've tested this on a fresh install of Leopard, you don't need to install SDL or the libpng frameworks.

It's based on the Mac OS X code already included with the source, just updated to compile on newer hardware. I've included the Xcode 3.0 project for this with the download, you can replace the project builder project in the existing source and it will compile with no changes needed if you have the frameworks required.

The application is for Mac OS X 10.4 or newer, and is compiled as a universal binary for both PPC and Intel Macs.
 
Now, I don't have a Mac, and I've never seen you before...and you come on in here and the first thing you do is post a finished build for a different OS? o_o()

Damn.

I wish there were others as ambitious as you are. Regardless of the build quality, you get a thumbs up from me.
 
Spazzo said:
Now, I don't have a Mac, and I've never seen you before...and you come on in here and the first thing you do is post a finished build for a different OS? o_o()

Damn.

I wish there were others as ambitious as you are. Regardless of the build quality, you get a thumbs up from me.
SSN would know me as 'sonicblur' but the forum wouldn't let me register that name. So I didn't.

I've popped in once a year or so...
 
Can you do a Linux port please? *prays*

I'm going to install Linux soon, and I don't want to run SRB2 through VMWare.

EDIT: Never mind.
 
SSNTails said:
Hi Sonicblur!

Can software mode run on the Intel Mac port?
The game becomes really stupid when you try to compile it in software mode:
Code:
W_Init: Init WADfiles.
I_StartupTimer...
File srb not found.
File son not found.
File tai not found.
File knu not found.
File aut not found.
File bom not found.
File hom not found.
File rai not found.
File inf not found.
File dri not found.
File soa not found.
File mus not found.
If I heed its wishes and rename the files, it does this:
Code:
W_Init: Init WADfiles.
I_StartupTimer...
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
File My D not found.
I assume there's some kind of memory corruption going on in Software mode, or I built it wrong somehow.
 
Problem with srb2waddir? Have a look at that code. My D looks like the beginning of My Documents.
 
Conicpp said:
Problem with srb2waddir? Have a look at that code. My D looks like the beginning of My Documents.
Mac OS X doesn't even have My Documents.
The wads are stored inside the executable and it had no problem finding them before I removed the HWRENDER define.
 
LoganA said:
you could make it do software mode by passing the -software parm to the binary

or you can change the default rander mode by editing this line:
http://trac.srb2.org/browser/SRB21094/trunk/src/sdl/i_video.c#L122
you shouldn't remove the HWRENDER define
Alright. Launching software via command line causes a segfault when you try to start a new game.
Code:
InitColormaps...
S_Init: Setting up sound.
I_StartupSound:
 Staring up with audio driver : coreaudio
 configured audio device with 1024 samples/slice at 22khz(46ms buffer)
I_InitSound: sound module ready
Compiled for SDL_mixer version: 1.2.8
Linked with SDL_mixer version: 1.2.8
Temp Shutdown of SDL Audio System Done
I_InitMusic: Staring up with audio driver : coreaudio with SDL_Mixer
 Reconfigured SDL Audio System with 2048 samples/slice at 44khz(46ms buffer)
I_InitMusic: music initialized
ST_Init: Init status bar.
D_CheckNetGame: Checking network game status.
Entering main game loop...
I_StartupKeyboard...
 CSegmentation fault

Here's the relevant information from the crashdump of where it died:
Code:
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000002bcac058
Crashed Thread:  0

Thread 0 Crashed:
0   Srb2                          	0x00032fcb HWR_DrawPatchInCache + 565
1   Srb2                          	0x00033457 HWR_MakePatch + 406
2   Srb2                          	0x000a8a5c W_CachePatchNum + 144
3   Srb2                          	0x0004d0c4 M_DrawTextBox + 60
4   Srb2                          	0x0004f076 M_DrawMessageMenu + 83
5   Srb2                          	0x00006da4 D_Display + 1385
6   Srb2                          	0x0000715a D_SRB2Loop + 282
7   Srb2                          	0x0003fe07 I_InitNetwork + 0
8   Srb2                          	0x000a73cf -[SDLMain applicationDidFinishLaunching:] + 141

Changing the default render mode by modifying the line you mentioned causes the same mess-up that removing the HWRENDER define does. It suddenly can't find the WAD's anymore, even though it knows where to look.
 
Alright. I got software mode working. Horray for XCode's debugger.

Change
#define MAX_WADPATH 128
to
#define MAX_WADPATH 256

Why the hell was it so small? The paths were getting truncated, although I didn't bother to see how it was messing up the names that it wrote as errors to the log. The path to the files inside of my copy was:
/Users/sappharad/Documents/Coding/srb2/FinalDemo1094/SRB2Src1094/src/sdl/macosx/build/Development/Srb2Debug.app/Contents/Resources/srb2.srb

So it was getting cut off at Resources when trying to find the WAD. I'll post a new build if I can ever figure out why it won't link as a Universal binary.

Also, you might want to take a look at this function:
Code:
static void add_spechit(line_t *ld)
{
	static int spechit_max = 0;

	if (numspechit >= spechit_max)
	{
		spechit_max = spechit_max ? spechit_max*2 : 16;
		spechit = (size_t *)realloc(spechit, sizeof (size_t) * spechit_max);
	}

	spechit[numspechit] = ld - lines;
	numspechit++;
}
I had it crash on me in the middle of GFZ2 with EXEC_BAD_ACCESS at the spechit[numspechit] assignment line, because apparently spechit wasn't allocated. (It had an value of 0)
 
Heh, actually, that function has been removed in 1.1, since its data isn't used anymore. :) Cool.

But at the same time, I don't see how that function could be 'fixed'... I don't see anything wrong, do you? (Other than maybe bombing out on a failed realloc).
 
SSNTails said:
But at the same time, I don't see how that function could be 'fixed'... I don't see anything wrong, do you? (Other than maybe bombing out on a failed realloc).
It seemed to me like it was failing because spechit wasn't allocated somehow, and numspechit was > 0.

spechit_max did have a value of 16 when it died, which implies to me that it did try to perform the alloc. A shitty fix might be to do size check on spechit:
if(numspechit < sizeof(spechit))
(Assuming that's an array of bytes, which it probably isn't.)

Anyway, I guess I'll look forward to porting 1.1 then. This wasn't too hard since someone already did the hard part a few years ago. (Although some of Mac OS X API calls they're using are deprecated now, I should probably replace them.)
 
srb2_macUniversal.png

New build should be ready in a few days. Changes:
- Universal Binary for PPC and Intel Macs
- Updated Xcode project that now automatically copies SDL and libpng frameworks into the binary. (I did this by hand in the last released build)
- Software rendering used instead of OpenGL.
- Some changes to the mac specific code to replace deprecated API calls.

If anyone has some suggestions for changes I should slip in, feel free.
 
Updated the first post with a link to the updated universal binary build.

Contrary to my previous post, I left OpenGL as the default because it's more stable than Software mode. (Which makes the warnings inside the game a lie.) Also, the lighting effects in the OpenGL multiplayer levels are cool. To switch to software rendering (why would you want that?) you'll need to recompile with the source change mentioned by Logan in this thread. Switching via the command line argument causes the game to crash when loading a level and I didn't bother to figure out why. Besides, I doubt most users know how to pass arguments to a Mac OS X program anyway.

In conclusion, download the app, unzip and double click on the icon. That's all you need to do. Perhaps I'll stop by again when 1.1 is out to release a port of that.

Enjoy.
 
I feel really simple here, but I have like no experience in this field, so I may be doing something completely wrong, but when I try to launch this it "unexpected quits"

Looking at the log the last thing it says is "Error while loading md2.dat"


I'm running on a 1GHz G4 Mac OS X 10.4.11

What am I doing wrong?
 
MD2.dat is for MD2's (you know, models?) only. That usually appears in OpenGL straight away 'cause... wait, doesn't that only appear when you type in GR_MD2 1? Never mind, if that's the only error, it's nothing.
 
Violo said:
MD2.dat is for MD2's (you know, models?) only. That usually appears in OpenGL straight away 'cause... wait, doesn't that only appear when you type in GR_MD2 1? Never mind, if that's the only error, it's nothing.

That's the thing, it keeps unexpectedly quiting... Right on launch, the log ends on that.
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top