Sprite System Refinements

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie


Critical to gameplay in Lemmings is the ability to display "hundreds" of Lemmings. Well, a lot of Lemmings, anyway.  So at the moment I'm working on a software sprite display system that can display "many" Lemmings.

In this installment, I've fixed up the sprite draw so that it now draws correctly regardless of the pixel position onscreen. The '2600 screen is tricky - although only 40 pixels wide, those 40 are distributed into registers in a bizarre combination of forward and backwards bits that were clearly designed to make programmers' lives difficult.

Anyway, that's all working very nicely indeed - as is the background masking for sprites.  So, the sprite draw is effectively completed.  It can handle sprites up to 8 pixels wide (i.e., 1/5 the screen width) - and 8 colours per 'trixel'.

I also have a multiplexed sprite draw happening here. Basically assume you are limited in the number of sprites you can draw per frame (I am, and it's currently very low - say about 12).  Then how do the sprites look when you have to abandon drawing them every frame?

That's what this installment is showing/testing. Midscreen is a number that pops up every time a Lemming is added. We can watch the visuals of the Lemming sprites to see how things look. Note the speed doesn't slowdown here; we just see differences in the draw. It's looking mostly OK - even up to 60 lemmings onscreen the flicker is really in your face, but actually not as bad as I'd feared. The trick will be to increase as much as possible the number of lemmings I can draw per frame - but with the knowledge that if I can't draw all the visible ones any frame, the dynamic draw management will make them visible, albeit flickering.


Andrew Davie

#1

It's now dynamic; it draws as many lemmings as possible in the available time, over a single frame, and then halts. If the number drawn is less than the total number of lemmings active, then the next frame the draw starting index is random.  The effect of this is that the lemmings remain solid until the system gets over-stressed, and then the distributed (=random) draw kicks in as discussed earlier in the forum.  Essentially, now the lemmings will be solid when possible, and flicker as little as possible.

In this video that system isn't active yet, but my tests indicate I can currently draw 22 lemmings without time overflow - after that, we get the non-annoying distributed draw system kicking in.

Andrew Davie

#2
I've added variable height and a center coordinate to the sprite draw. What this essentially means is that an object (i.e., a lemming) has a defined point at which it exists, and any frames drawn for that object are centered around that point.  And by centered, I mean each frame has a definable origin and the frame is shifted so that the origin of the frame aligns with the origin of the object (i.e. lemming).  What this means, in essence, is that animations look good... automatically.

Here I've added an umbrella/falling frame (from the original graphics).  It's way big on the '2600, but it is what it is. When the frame flips to umbrellas, the little lemming still looks like he's in the right place.

This also demonstrates the sprite system handling "big" sprites. It seems to be coping OK.  I'm not TOTALLY thrilled with the visuals, but we shall see how things progress.



Here's some code showing how the frames are defined...

typedef struct {
unsigned char height;
signed char centerX;
signed char centerY;
const unsigned char *data;
} frameDef;

#define LEM(a, b, c) ((a) | (b) | (c)), (a), (b), (c)

const unsigned char lemming1[] = {

    LEM(0b00110, 0b00000, 0b00000), //
    LEM(0b01110, 0b00010, 0b00010), //
    LEM(0b01111, 0b00111, 0b00111), //
    LEM(0b00000, 0b00110, 0b00000), //
    LEM(0b00010, 0b01110, 0b00010), //
    LEM(0b00010, 0b01110, 0b00010), //
    LEM(0b00010, 0b01110, 0b00010), //
    LEM(0b00001, 0b11111, 0b00001), //
    LEM(0b00000, 0b11110, 0b00000), //
    LEM(0b10011, 0b10011, 0b10011), //
};


const unsigned char lemmingFallingUmbrella[] = {

    LEM(0b00011000, 0b00000000, 0b00011000), //
    LEM(0b01111110, 0b00000000, 0b01111110), //
    LEM(0b01010101, 0b10101010, 0b01010101), //
    LEM(0b00000000, 0b00010000, 0b00000000), //
    LEM(0b00000000, 0b00010000, 0b00000000), //
    LEM(0b00011110, 0b00110000, 0b00010000), //
    LEM(0b00111110, 0b00101000, 0b00101000), //
    LEM(0b00111100, 0b00101100, 0b00101100), //
    LEM(0b00000000, 0b00000000, 0b00011100), //
    LEM(0b00000010, 0b00000010, 0b00011110), //
    LEM(0b00000000, 0b00000000, 0b00011100), //
    LEM(0b01000000, 0b01000000, 0b01111000), //
    LEM(0b01000000, 0b01000000, 0b01111000), //
    LEM(0b00000000, 0b00000000, 0b00011000), //
    LEM(0b00001100, 0b00001100, 0b00001100), //
};

const frameDef frameSet[] = {
    // height, centerX, centerY, data...
    {10, 5, 9, lemming1}, // frame 0
    {15, 4, 14, lemmingFallingUmbrella}, // frame 1
};


Andrew Davie

I've re-visited the software sprite draw and multiplexing. In this installment I'm demonstrating the (mostly) flicker-free sprites under extreme loads - up to 75 lemmings. There are parts where it does flicker, but nothing completely disappears, and it's really at an extreme instance of everything on screen at once.

Mostly it's pretty nice now, and working very effectively with the pCC background.



Andrew Davie

Aside from the fixes to the auto-detection of PAL/NTSC/SECAM, I have spent some time fixing the software sprite system "edge cases". I had some unexpected flicker - caused by the multiplexing code kicking in when it shouldn't've. :)

Now it appears to be working correctly, so the video is just demonstrating a couple of minutes of high sprite usage. It's quite nice.


I'm still considering how I'm going to do the level data. It's tricky because of the borked original way of doing it (IMHO), which doesn't lend itself to a ROM characterset format. IMHO. Also because procrastination.