*WARNING the pictures in this document are around 400K in size. They take a while to download*
Ok, everyone gather around. Remember to bring your pens and paper. You may have to take notes on this.
Ok, I've been taking apart the PSX version of FF7. Now this helps to figure out how the PC version works because it's a direct port. Now I'm going to show you how the field files and the texture management work in the PSX version and you should find the PC version working exactly the same way. Now before I begin with the nitty gritty, I have to get you guys up to speed about how a PSX does its graphics so we all know what's going on.
The PSX only has 1 Meg of video memory. Actually it's a "surface" that's 1024x512. Now we can allocate that whole thing to be viewable, but then there would be nothing left for textures or page flipping. Usually a "window" is created and the rest is left to textures. This leads us to the second problem with the PSX. Video memory is 100% off limits to the CPU. You have to manipulate everything through the GPU (Graphics prossessing unit). If you want to load textures into video memory, it has to be in TIM file format. Which is nothing but a PSX bitmap.
Now this following http://www.execpc.com/~halkun/field/vidmem.png" TARGET=_blank>picture is what the video memory looks like after the movie stops running on the first field file. I've marked off key locations so you can see what they are. The framebuffer and backbuffer are where the animation is flipped back and forth. The 24 bit overflow area is when the movies play in 24 bit color, they need a little more memory. (The PC version didn't have 24 bit movies). Under that is the Color Look Up Table or CLUT. When you load a field file, the pallette goes here. The next thing is the GPU texture cache. This can be disregarded. Now the thing I have labeled as "field layers" is actually in a place I call the "transient texture cache" it's very easily overwritable. It happens to have the field layer textures in it right now. When other modules load, such as "battle" this area is the first to be overwritten. Below that is the "semi-permanant" area. What is written in there tends to stick between module loads. "Eyes" are the characters eyes (they randomly blink, even if you don't see the character on screen) and the section is for the PHS, and finally the text and status menu textures which never go away.
The next http://www.execpc.com/~halkun/field/trainvid.png" TARGET=_blank>picture is the engine in motion. Now you can see the display buffer and back buffer working. You can see some squares on the display buffer being drawn on the field picture, I'm going to go into that now.
This http://www.execpc.com/~halkun/field/prio.png" TARGET=_blank>picture shows the field file's priority layers. I had the computer put a box around all the textures. The color of the box shows it's priority. The lowest priority is white. You can see our friend Cloud is standing in an area of white priority boxes so no textures are "infront" of him. The next priority is purple. This can either be infront of or behind a character depending on location. The light blue and then dark blue are next. Light blue is higher than purple and dark blue will always be on top, no matter how close the character is. It's hard to see the difference between light and dark blue in this picture. but if you look at the train conductor farthest away, you can see it's in the light blue priority.
Now do you see the pipe on the train, the one sticking way out on top, and has a green outline around it? You can also see the building behind it. Ok, the pipe is in a light blue priority, but the green outline allows everything *around* the pipe to be shown through. (Jessie jumped behind this pipe at the beginning) That's why Mr. Far conductor is not being obscured by the train. The obscuring starts at the pipe in the corner of that square. You got it so far?
What happens when you get into a fight? Well, I'll show you. Take a look at this http://www.execpc.com/~halkun/field/battlevid.png" TARGET=_blank>picture here. You can see that the battle textures overwrote the field data, but not entirely. The rest of the field data is cached. Now, look at the frame buffer. You can see that one of the battle textures overwrote the 24-bit overflow area, that's fine. The battles are never in 24 bit anyway so clipping isn't a problem. Now the semi-permanent area at the bottom was filled with all kinds of textures. Those are common battle textures, such as limit auras, magic auras, potion auras, thinks like that. They won't go away after the battle is finished so the load times are kept down. The eyes are gone though. Actually. Clouds eye is next to the top framebuffer. That's the only texture there, when you get more characters those fill in, such as Barret's tatoo and Tifa's eye. Also when any special attack does off, such as magic, it will fill up after the battle textures eating away at the field texture cache. Wanna see the battle close up? Take a look http://www.execpc.com/~halkun/field/battlewire.png" TARGET=_blank>here Notice the little dust texture at the feet of Mr. bad guy? Thats in the semi-permanent area in video memory. It's a very popular texture.
So what about the video memory after battle? well if you look http://www.execpc.com/~halkun/field/afterbat.png" TARGET=_blank>here you will find the semi-permanent textures stuck, but the field textures overwrote the battle ones, except which was in the 24 bit overflow area.
This right http://www.execpc.com/~halkun/field/prio2.png" TARGET=_blank>here is another picture showing how priorities work a little better. Notice that Cloud's foot is in a dark blue priority box? It is being overwritten, but it's the pipe that isn't transparent. The lamp over on the left is priority color purple. Cloud can walk both in front or behind it depending on his location. The sign? That's priority dark blue. It's animated too. When animation is done, it's only the boxes that change get changes, not the whole priority layer.
Animation? Did I say animation? If you want to see the video memory of a "full" field file with animation look http://www.execpc.com/~halkun/field/anivid.png" TARGET=_blank>here. The smoke that blows about is there and it's filled all the way to the semi-permanent textures. Just remember, if cloud leaves this scene and comes back, what isn't overwritten is cached.
I think that covers everything I've found so far. Do with this information as you wish. It may be in your best interests to save these pictures as I think I'm over quota at my ISP. I'll keep them up for about a week.
Anyway I'm going to bed. Feel free to talk amongst yourselves.
-Halkun
[This message has been edited by halkun (edited August 24, 2001).]
[This message has been edited by halkun (edited August 24, 2001).]
Third EDIT by The SaiNt in an effort to correct halkun's horrible spelling.
[This message has been edited by The SaiNt (edited August 24, 2001).]