Multiplexing - well, I never....

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

Multiplexing is essentially trying to draw n+1 objects with just n sprites.
BIDT on the NES I did a lot of this, trying to fit more stuff onscreen, whilst making the flicker less obnoxious. I wrote many systems, mostly involving sharing the available sprites evently around the objects that wanted to be drawn.

In Lemmings, I thought this situation might come up a lot. If I can draw (say) 20 lemmings per frame, but there are actually 25 onscreen -- then some won't be drawn. The "simple" solution is to start the draw at a different place every frame.  Start with lemming 0 on frame 1, and draw the first 20.  Then on frame 2 you start with the next lemming (the first doesn't get drawn), etc. This works, and it works reasonably well (or so I thought).

It does lead to "visible patterns" in the sprite usage, though. Things flicker predictably. I got to thinking - well, what if they flickered *unpredictably*?   The easiest way to do this was just to start the draw at a *random* lemming, and draw the next n in order.  So, for example, if you have 30 lemmings on screen, and you can only draw 20... then draw 20 starting at a random place in the 30 lemming list.

Does it work?  Yes. Surprisingly well. And it's incredibly simple - just choose a random starting index every frame. I'm quite suprised that I've not done this this way before.

The two binaries attached show both a fully allocated (drawing 20 per frame out of 20 available -- the @20 binary), and a multiplexed (drawing 20 per frame out of 30 -- the @30 binary).  Of course the latter flickers. But, given that we just choose randomly which 20 to draw (effectively, anyway).... the result is actually quite impressive. To me, anyway.

You can use the SELECT button to change palette in these binaries.