So, I want a Descent-like game using 40x25 character graphics. My goal is smooth frame rate rather than high fidelity graphics. Classic 6502 3D games had poor frame rates.
Well, how can this be done?
I’ve already figured out part of it. The end of the pipeline will be cropped to a 64x64x64 cube of camera coordinates in front of the player. These X-Y-Z coordinates get transformed into X/Z, Y/Z screen coordinates via 64x64 lookup table (X or Y coordinate is -32 … +31; Z coordinate is 0 … 63).
Basically, there’s a collection of “dots” in the corners and midpoints of the room and neighboring rooms to show terrain, and 2D character “sprites” for the ghosts and other objects. Each has object 3D coordinates in a 256x256x256 map … the basic pipeline is:
- Move objects in 256x256x256 block based space. It’s like a Roguelike in 3 dimensions. Typically, only one monster will move per frame, so this is very fast.
- Transform/cull 256x256x256 world coordinates to 64x64x64 camera coordinates … this doesn’t need to be super accurate, but it does need to be fast
- Erase characters drawn last frame
- Draw visible objects in semi-random order
The monsters are mostly ghosts, so I avoid bothering with hidden surface algorithms or even sorting back-to-front. I care about smooth frame rate, not high fidelity. Heck, it’s a 40x25 character display, who cares?
But it’s the transform step which I’m puzzling over. How can this be done quickly?
Here’s what I’m thinking … okay, so the camera has a position and rotation matrix. Position translation is easy and pretty fast … just byte-byte addition in all three coordinates. Rotation, though … well, the rotation matrix is three unit vectors, and I can sacrifice precision on each unit vector coordinate to 1/32, maybe? That way, the multiplication table is 64x128 = 8K in size (I’m assuming both positive and negative for both the unit vector component and the map component).
Does this strategy seem reasonable? I know there are clever ways to do fast 6502 multiplication other than a lookup table, but in this specialized application I don’t need precision results.