Let’s extract a plane.
Planes can be found in folders 0066–0102 (Japanese version) and 0047–0068 (EU/US version). These all have the following layout:
- folder with 12 small binary files (from 0 B to 16 KiB)
- folder with a small binary file (~100 B)
- folder with two textures:
- a binary file of several KiB
Pretty obvious this is plane data. But where’s the vertices? We should take a look at the binary files from the first folder. You’d probably start with the first file, but I’ll pick #9 here because it contains some data that’s not present in the first file (and it’s not as complex as the other ones). Let’s repeat the process of finding patterns in binary data
, and so we’ll find this structure throughout the files:
This looks a lot like the vertex data we found earlier
. In fact, it’s pretty easy to recognize vertices in the same XY XY XY Z Z Z
format. Triangle indices are pretty easy to spot as well (the consecutive integers from 00 to 0B):
Visualize what we just found:
Makes sense! I’ll take a shortcut here: In some other files, the last block is not empty, but contains quads instead of triangles (4th index not always zero). However, many files come with no triangles/quads at all, just a set of vertices. Let’s have a look at all files from the folder:
Using this identification chart
, we can clearly identify it as a F-18 Hornet
Now, what about the other data (X, Y, Z, Q)?
X does not make sense as triangle indices, but it does make sense as indices into block #3. (See how it counts to 0B == 12 decimal, and there’s 13 entries in block #3?)
So what’s in block #3? It’s not too difficult to figure out once you know what you’re looking for. It’s the vertex normals, scaled to 4096 and stored as 16-bit fixed point numbers (because the PSX has no floating-point support). These normals are indeed very pretty (I decided to apply a random color to individual meshes in order to tell them apart):
We have seen Z before: It’s the GPU instruction for drawing a triangle.
There is not much room left for Y & Q: It must
be texture coordinates, because where else would they go? But there’s eight numbers for three vertices, so we need to pick the right ones. We can easily get this done by using the individual texture coordinates as red and green colors: (I chose a different plane here because I was too lazy to take another screenshot for the article, sorry!) Nice smooth shading and the seams are exactly where a designer would place them!
We’ll apply the texture next time. It’s more difficult than one would think, and it requires the last pair of bytes to get it right …