Original Post

What is the technique for calculating FPS? I’ve read most of the VB dev documentation and don’t remember seeing this topic before, so I thought I’d just ask outright, rather than trying to figure it out myself. I’d assume that it has something to do with checking the screen buffers, and counting how many CPU cycles had passed since the last change, but I’m absolutely clueless as to how to do that, and then convert that to seconds. I would also guess that limiting FPS would be a matter of waiting a certain number of cycles before the next buffer refresh, but I’m also clueless about this.

Also, how do you make an object or BGMap with an opaque black fill? Does it involve careful pallete manipulation? I can’t see how you could have an opaque black, and still use 4 colors, but the commercial games do it, so there has to be a way…

Any help is greatly appreciated!

11 Replies

To display a non-transparent black, set one of the palette entries in your palette to 00b.

But using that method, don’t you end up with 2 blacks? (1 transparent and 1 nontransparent?) I thought about doing that, but then you can only use 3 colors (counting the extra black as a color.)

But using that method, don’t you end up with 2 blacks? (1 transparent and 1 nontransparent?) I thought about doing that, but then you can only use 3 colors (counting the extra black as a color.)

That is correct. You can never have more than 3 colors in an obj, since the 4th one is always transparent no matter what you set it to. This is just how it works and there’s no way around it.

If you’ve seen a game that seems to make use of all 4 colors in a ‘single’ sprite, a technique it may use is to have a second obj right behind it at all times, that uses a different palette and a different char to make up a ‘mask’ behind the ‘real’ sprite. It’s a method that works, but you effectivly waste half of all available objs/chars 🙂

One way you could do it is to keep track of where you want to be opaque black, then after the frame is rendered by the VPU, go into the framebuffers and set those pixels to be black. Not exactly a nice way to do it, but wouldn’t take too much effort or processing time if you always knew that one small chunk needed to be solid black (like filling in the black of your main character).

DogP

Thanks! Makes sense… I’d just never thought of a palette as 3 colors, plus a transparency. I guess I’ll just stick with 3 colors, since 4 seems like a lot of work. 🙁

Also, forget the FPS question, since I realize now that it was a stupid question (it depends on the how often the game updates the frame buffer, not how often the VB draws the frame buffer, am I right?)

Actually, it’s not a stupid question at all. The frame-rate of a system like the VB is quite a complicated subject.

First, there’s the basic rate at which the scanner displays the contents of the frame buffers. On the VB, this is about 50Hz (give or take).

Then, there is the rate at which the VIP can fill the frame buffers with pixels based on the contents of the Worlds, et al. This, of course, depends on the complexity of the scene and how many special effects (e.g. Affine, H-Bias, etc.) are used. There’s actually a processor interrupt assigned to the situation wherein the VIP takes more than 20ms to draw a frame. I can’t provide any more detail about that, though, since I have never written an ISR in my life 😛

Then, there is the ability of the software to create and/or change the scene description itself. This will vary by the nature of the program and of the programmer, among other things.

These are each quite complicated topics to cover in a single forum post, and that’s without putting them together… Eventually, I hope the Wiki will cover them all thoroughly, though.

Wish I could help more…

Actually, the way I was thinking of calculating FPS (after reading some more technical docs) was to manually turn writing to the buffers on and off whenever you completed a frame, and use the hardware timer to find the time between buffer writes, and calculate the FPS from that. Of course, I have no idea if this can be done, because I don’t know if the VB timer has a high enough resolution, and I haven’t tried manually controlling buffer writes… (does toggling the XPEN bit effectively freeze the buffer state until you’re ready for another screen redraw?) I was thinking of trying manual buffer writes anyway, because I keep doing weird things to char memory when I try to write too much information to object memory, and end up doing it while the VB is writing to the frame buffers. 😛 Has anyone else tried manually controlling FB writes?

Fwirt wrote:

(does toggling the XPEN bit effectively freeze the buffer state until you’re ready for another screen redraw?)

Yes

I was thinking of trying manual buffer writes anyway, because I keep doing weird things to char memory when I try to write too much information to object memory, and end up doing it while the VB is writing to the frame buffers. 😛 Has anyone else tried manually controlling FB writes?

Well, XPSTTS bits 2 and 3 not only tell you when you shouldn’t write to VIP memory, but also tell you which framebuffer is being written to. Just check if (VIP_REGS[XPSTTS] & 0x0C) == 0 before writing. But only if the XP is turned on, obviously…

hth

  • This reply was modified 15 years, 8 months ago by RunnerPack.

One quick question: How exactly do you toggle XPEN? I tried masking XPCTRL with 0xFFFD to set XPEN to 0, but it didn’t seem to work (the display buffers didn’t freeze.)

Actually, I think you OR it with 1 to set the LSB (XPRST = “XP Reset”) but only when XPSTTS & 0x0C = 0 (ie when the XP is idle).

 

Write a reply

You must be logged in to reply to this topic.