So I’ve been making my way through the Tonc tutorial I mentioned in the last post. While I’ve been doing that, I’ve been looking around for existing open source ray casting engines on the GBA. My thought process is if I can find a basic implementation of ray casting on the GBA, I can spend my time trying to improve it rather than reinventing the wheel.
Very briefly, ray casting is a technique for generating pseudo 3D visuals that was used in the 90s since hardware was not powerful enough to create “true” 3D graphics. It places limitations on what the environment can look like and what the user can do. For example, in Wolfenstein 3D programmed by John Carmack of id software, the environment must be made of walls of equal height at either 0 or 90 degrees to each other, with completely level floors, and the user can look left or right but not up or down. For a good explanation of ray casting, look here: http://www.permadi.com/tutorial/raycast/ .
I found three existing implementations of ray casting on the GBA.
1. http://www.loirak.com/gameboy/gbacaster.php : This implementation is based on F. Permadi’s description on ray casting posted above. However, it is very slow and has no optimizations whatsoever.
2. http://ima.udg.edu/~dagush/Projects/Jespa3D/ : This implementation is fairly complex and has a lot of features, including mipmapping and basic lighting, but it also runs fairly slow and I am looking for a more basic implementation that will run more smoothly. Also, it’s documentation is in Catalan, which makes it very difficult to understand what the code is doing.
3. http://linuxgamers.net/lsd/gba/raycaster/ : This implementation is also based on Permaid’s description of ray casting. It has a few optimizations to make it run faster, yet it is still very basic.
I really liked the simplicity of the third implementation, so my plan right now is to go through the code, document it, and improve it. I have a few ideas of what I want to add to it, but I’ll talk more about that later. But here’s a hint… sparse virtual texturing!
Since this implementation was created using a different toolset than mine, I’m working right now on getting it to compile with my toolset. I think this just means making some changes to the makefile, but we’ll see.