The Cave Story port uses SDL

18 07 2007

Last time I mentioned writing a common abstraction layer for Cave Story as an intermediate step to getting it up and running on the GameCube.

I decided on SDL for handling as much of that layer as possible. This has a few advantages:

  • I can test the port on Windows.
  • I don’t have to write so much code.
  • The process of porting to other platforms is simplified.

There are quite a lot of references to RECTs throughout the code, which I don’t yet want to convert to SDL_Rects. That may sound silly, but SDL rectangles are stored as “left, top, width and height”, whereas Windows rectangles are stored as “left, top, right and bottom”.

It’s not a large difference, but while converting a few snippets over to the SDL way isn’t at all difficult, the number of RECT references is large enough to cause a few evenings worth of tedious and error-prone work, which I would rather skip! I just want to get the game up and running with as few far-reaching changes as possible.

So instead, I convert RECTs to SDL_Rects at the last second, just before blitting.

But anyway, there is one glaring hole in my longer term plan. As far as I am aware, there is no stand alone GameCube port of SDL. If believe there’s a version for GameCube Linux, but not a stand alone library. Fortunately, porting the parts of SDL I use to the GameCube probably won’t be much more work than I would have had to do anyway.





Cave Story source

13 07 2007

After the initial hiccup from a few days ago, Pixel sent me the source code again and it arrived safely.

I took some time last night and this morning to skim over it and get it compiling using Visual C++ Express. It wasn’t too much trouble, only requiring some brief fixing up of resource scripts, different DirectX SDK locations and the odd thing which has changed with the newer version of the compiler.

I was really surprised to find that most of the code is in very readable English! The comments are in Japanese, but all the variables and functions are in English. I expected them to be in Romaji (because C++ identifiers are limited to a subset of ASCII). Japanese programmers deserve some credit for translating and programming at the same time!

While the code is generally clean, it is very Windows-centric. Some data files (notably the music and end sequence images) are linked into the executable as resources and there are also many uses of Windows types like RECT and BOOL throughout the code.

Handling endianness and debugging it on the GameCube is going to be difficult. I think I will need to go over all of the file loading code with a fine toothed comb and do what I can.

While ufo_z’s PSP port is based on Cave Story 1.0.0.7, I noticed that the version I have is 1.0.0.4. I’ll need to check with Pixel to see if he’s accidentally sent me the older code.

This morning I set about separating the source code files into generic and Win32-specific directories. This will make it easier to strip out any unnecessary Windows dependencies and help define a common abstraction layer which can be used between platforms.

It may be that on non-Windows platforms I will supply a dummy windows.h header file just to define the Windows types that Cave Story needs. The advantage of this is that my modified sources won’t diverge too much from Pixel’s, making patching easier in the future. The downside is of course that doing that would be a kludge, fixing the problem at the symptom instead of at the cause.

But anyway, that’s enough Cave Story for today. I have proper work to do.





Source code: almost gotten!

11 07 2007

Pixel sent me the source code for Cave Story… but I didn’t get it.

Unfortunately, Gmail decided that the viral threat of the archive was clearly too great to accept and promptly bounced the message back to him. As if this is not difficult enough already!

Trying to talk with someone who doesn’t necessarily speak your language well is a bit of a minefield. Many English words have several meanings which are only disambiguated by their context. If the reader doesn’t pick up the context just right, the meaning could be lost.

When trying to phrase things simply and unambiguously, I find it difficult to keep the tone which I would like. In English, sentences are considered polite if they are phrased in a complicated or indirect way. For example, “would you mind if I borrowed your magazine?” as opposed to “give me your magazine”.

Maybe the key to conveying tone of voice would be through cunning use of smileys. I could probably look into that but I really don’t want to get to the stage where I delimit each sentence with a string of faces in order to set the tone!

It struck me that I may be trying way too hard to simplify my English. I learned a bit of Spanish a few years ago and I found that reading it was much easier than writing or speaking it.

I wonder how difficult people who are learning English find it to pick the meaning out of the fluff.