New category: Coding tips and tricks

Just added a new category, for tricks and such for PCE design. I’ll post entries from time to time. Some complex and some fairly simple.

Ok, here’s the first entry: Extending vblank bandwidth.

If you code for the PCE, you know that the two fastest ways to get graphics to the VDC – is to use either Txx block move instructions or embedded your graphics as opcodes (ST1 #xx/ST2 #xx). The latter is faster and doesn’t stall interrupts, but has the downside of doubling the size of your graphics. Txx instructions are easy to use and fast, but it stalls interrupts. This is a problem if you use this during active display (in which it’s normal to update vram during active display on the PCE). Especially if you need to do stuff like H-interrupts.

If your game has a ‘status’ bar, move it to the bottom of the screen instead of the top. You can either build it with all sprites, making it highest priority so that nothing shows above it (easiest method). Or use a part of the tilemap repositioned at that part of the screen, and turn off sprites. The latter has the additional complexity in that you’ll need to ‘sew’ the tilemap height to avoid showing this bar, if the screen scrolls vertically at all. The earlier method eats up a little bit of the SAT entries, but makes it easier in the long run (no calculated special H-int to sew/fix the tilemap).

But here’s the reason to put the bar at the bottom; extending vlbank time. Not really, but since you don’t need H-ints at that part of the screen – you can include the height of the status bar into vblank time. That means it’s safe to use Txx block move instructions. I guess you could put the bar at the top as well, and think of it as extending vblank time as well – but either way, make it out of sprites. You now have that much more time to update vram

Of course, if you’re using the Timer interrupt, or ‘all scanlines’ interrupt, to drive sample playback – then this won’t help you (since they’ll be called during vblank anyway). This would be more for CD projects that use ADPCM for sample playback.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: