NXEngine (Cavestory) port to IRIX
#1
NXEngine (Cavestory) port to IRIX
Some months ago I was toying with getting NXengine, an open source Cave Story rewrite in SDL, to run on IRIX. I figured it would be a fun game to have and would run ok because it's a rather old game and isn't too demanding.

There were of course some hurdles to get it compiled and running, and so I'm using this post to document everything (or at least everything I can remember, as my memory is a little fuzzy now) that I did to fix it and get a version working. Because my memory isn't perfect on what I did or what files I had to patch, I'll be including a tarball of my entire source directory with the patches, as well as binaries in case they happen to run on your system, to this post. 

Firstly, I'll get dependencies and compiler setup out of the way - The game needs SDL (can be SDL1.2) and SDL_TT , other than that no real dependencies. For this I used nekoware SDL, as even though I'm not aware of an SDL2 that exists for IRIX, they have managed to get SDL_TTF working with SDL1.2 despite TTF being a 2.X exclusive (afaik). I also decided to choose SGUG-RSE/didbs GCC9 over MIPSPro or other GCC versions, this was mainly just personal preference and better compatibility with random C++ software but YMMV if you decide to use other compilers. Finally, I used the 1.0.0.6 bz2 source tarball from the NXEngine website I linked above. (Note that there is a refactor/rewrite of NXEngine called NXEngine-Evo, these are different projects and the latter uses SDL2 anyway, so I would suggest you stick with the original NXEngine if you are looking to try this.)

The first issue I encountered was with a file that needed endian.h. If I'm not wrong that header does not exist on IRIX by default - thankfully the SGUG-RSE team has a library to solve compatibility issue like this called libdicl. Just add libdicl to the list of include directories in the make, and that should be resolved.

Second issue was more with my system, rather than the program itself - but it makes use of cmath/math.h, which is broken by default on a lot of 6.5 installs, whether you're using GCC or MipsPro. I forget the details of the issue but you'll want to make sure you have working cmath; if that's not the case, the fix is to remove a couple bad patches put out by SGI from your system. Here is a guide on how to do so.

At this point, it should compile if you've applied the previous two fixes. But there are two endian-related problems that still need to be fixed that prevent the game from fully launching. In common/misc.cpp, there is an ifdef check for little endianness, but I don't think it quite works because the code still runs anyway and causes errors at launch. All you need to do to fix this is replace the line with an SDL-based endianness check, as detailed here. (This patch is for NXEngine-EVO, but works on the original NXEngine as well). Finally there is an issue with the sound initialization where it expects little endian sound format, you just need to go in sound/sslib.cpp and replace AUDIO_S16 with AUDIO_S16MSB on line 29.

And that's it! Here's a screenshot of it running on my O2:

[Image: UeZMk5h.png]

It doesn't run great, but it might be worth trying on a faster system like an Octane.

As promised, my source tarball is attached to this post.


Attached Files
.gz nx-IRIX.tar.gz Size: 9.17 MB  Downloads: 282

systems:
Indy x2  :Altix-350: O2  :where's-my-altix-330-emote:
(This post was last modified: 08-09-2020, 01:21 AM by Raion.)
partitionpenguin
panther_

Trade Count: (0)
Posts: 16
Threads: 5
Joined: Dec 2018
Find Reply
08-09-2020, 12:46 AM
#2
RE: NXEngine (Cavestory) port to IRIX
Fixed your linebreak issue. Also I just recommend using libxg, as it's lighter weight and it includes endian.h

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
08-09-2020, 01:22 AM
#3
RE: NXEngine (Cavestory) port to IRIX
(08-09-2020, 01:22 AM)Raion Wrote:  Fixed your linebreak issue. Also I just recommend using libxg, as it's lighter weight and it includes endian.h
Thanks, maybe it was just my browser or something. And yeah, I think that there a number of helper libraries for porting that are like libdicl. Anything that includes endian.h is fine.

systems:
Indy x2  :Altix-350: O2  :where's-my-altix-330-emote:
partitionpenguin
panther_

Trade Count: (0)
Posts: 16
Threads: 5
Joined: Dec 2018
Find Reply
08-09-2020, 01:51 AM
#4
RE: NXEngine (Cavestory) port to IRIX
Sweet! Aspect ratio looks a little off, though? I'll have to give this a shot, it's been ages since I played the original.

Edit: never mind, clued in after a moment that the IRIX UI was also squished and it was just the forum software being weird about scaling the image to fit.

Computers: Amiga 1200, DEC VAXStation 4000/60, DEC MicroPDP-11/73
Synthesizers: Roland JX-10/SH-09/MT-32/D-50, Yamaha DX7-II/V50/TX7/TG33/FB-01, Korg MS-20 Mini/ARP Odyssey/DW-8000/X5DR, Ensoniq SQ-80, E-mu Proteus/2, Nord Lead 2, Behringer Model D
(This post was last modified: 08-09-2020, 03:24 AM by commodorejohn.)
commodorejohn
PDP-X

Trade Count: (0)
Posts: 367
Threads: 7
Joined: May 2018
Find Reply
08-09-2020, 03:23 AM
#5
RE: NXEngine (Cavestory) port to IRIX
For future reference, IRIX does have endian.h.  You have to use:

Code:
#include <standards.h>
#include <sys/endian.h>

The comments in it say that its use is deprecated, but they don't say why.  (Perhaps it just predates the standards for endian.h and so it might be missing some functionality.  Perhaps just because of its non-standard location.  But I'm just speculating there.)

SGI:  Indigo, Indigo2, Octane, Origin 300
Sun:  SPARCstation 20 (x4), Ultra 2, Blade 2500, T5240
HP:  9000/380, 425e, C8000
Digital: DECstation 5000/125, PWS 600au
jpstewart
Developer

Trade Count: (1)
Posts: 444
Threads: 6
Joined: May 2018
Location: SW Ontario, CA
Find Reply
08-10-2020, 12:33 AM
#6
RE: NXEngine (Cavestory) port to IRIX
The macros/definitions that Linux/BSD programs expect - are they there?

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
08-10-2020, 12:48 AM
#7
RE: NXEngine (Cavestory) port to IRIX
(08-10-2020, 12:33 AM)jpstewart Wrote:  For future reference, IRIX does have endian.h.  You have to use:

Code:
#include <standards.h>
#include <sys/endian.h>

The comments in it say that its use is deprecated, but they don't say why.  (Perhaps it just predates the standards for endian.h and so it might be missing some functionality.  Perhaps just because of its non-standard location.  But I'm just speculating there.)
Ah, I wasn't aware of that, but I do believe that the sys/endian.h on IRIX which already exists was missing some functionality that CaveStory needed and thus was why a patch like libdicl is required.

systems:
Indy x2  :Altix-350: O2  :where's-my-altix-330-emote:
partitionpenguin
panther_

Trade Count: (0)
Posts: 16
Threads: 5
Joined: Dec 2018
Find Reply
08-10-2020, 04:03 PM
#8
RE: NXEngine (Cavestory) port to IRIX
(08-10-2020, 04:03 PM)partitionpenguin Wrote:  but I do believe that the sys/endian.h on IRIX which already exists was missing some functionality that CaveStory needed and thus was why a patch like libdicl is required.

I'm not surprised.  The native endian.h is a good starting point but not necessarily the full solution.

SGI:  Indigo, Indigo2, Octane, Origin 300
Sun:  SPARCstation 20 (x4), Ultra 2, Blade 2500, T5240
HP:  9000/380, 425e, C8000
Digital: DECstation 5000/125, PWS 600au
jpstewart
Developer

Trade Count: (1)
Posts: 444
Threads: 6
Joined: May 2018
Location: SW Ontario, CA
Find Reply
08-11-2020, 11:18 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)