Boulder Dash 2

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

This is another major revamp of the "circle swipe" system. This video shows various scenarios where the swipe is used to uncover or cover the screen. I'm just ketting killed as early as possible and then switching to various view modes, moving away from the death position, etc.  I have worked on transitioning the swipe (mostly) to the position of the player -- even if that position is waaaaaaaay offscreen. It makes for interesting sideways and vertical swipes with massive circles (where we only see a part thereof).  Speed has been an issue for this system, but it appears to be mosty working now. Took a fair bit of head-scratching to get to this point.


Andrew Davie

#76

Here's a super-experimental rewrite of the main game loop to allow 2x vertical resolution in the boulders falling. Essentially... "less clunky".  It has limitations, but does look rather nice. Compared to the previous version, things are running at (essentially) the same speed, only we get more finesse in the boulder movement.  So, have a close look at the smoothness of when boulders fall, and enjoy.

I'm not sure if I will use this experimental version or not.

Bomberman94

Falling boulders are looking much better/natural now but maybe they are are now too slow and gameplay gets easier now? Not sure - must play to see if it ,,feels right".

Andrew Davie

Quote from: Bomberman94 on 08 May 2024, 05:58 AMFalling boulders are looking much better/natural now but maybe they are are now too slow and gameplay gets easier now? Not sure - must play to see if it ,,feels right".

Aaaaactualllyyyy.... I did get the boulders to fall more smoothly.... but only at the very top of their fall.  For the rest of the fall, they fall as they did before. I'll fix this bug soon, and the smoothness will be much more evident.  Also, they fall at exactly the same speed as they did before. It's just we have in-between "animations" now.

Andrew Davie

OK, well I had a bug in my last "smooth falling boulders" video, where the smoothness was only at the very top of the falling. This version corrects that bug, and now we can clearly see the smooth falling.

Interesting to me is that now the boulders appear to be falling much more slowly. But they're not. For example, the diamonds are still falling at the original speed - and it's the same as the new boulders. Also, the player moving down is the same speed as the boulders and diamonds. All checks out. It's just a perception thing. More chunky movement is clearly interpreted as "faster".

I'm still not sure if I will use this experimental version or not - I have some issues with player control/buffering to resolve.


Andrew Davie

When I do a build, a time-stamped binary is placed in a ROMs subdirectory.
That directory currently holds 21,007 individual builds. That's pretty impressive.

Andrew Davie

I've extended the "smooth falling" to diamonds, as well as the boulders. The changeover highlighted a few bugs in the boulder/diamond logic code, which is ironic really because just a few days ago I thought "hey I haven't touched that code for ages; it's really stable". But anyway, on revisiting the code it was appallingly messy, so rewrite it was.  After the rewrite things are working fairly well, and the code is neater.

I've also tidied up a few things, such as parallax background behind falling boulders/diamonds. It was costly, but the little things count.

In this video I play through the three magnifications on a boulder-intense cave. The magnifications ("normal", "mid", "overview") each have different size boulders - but what's really really pleasing is that the smooth falling has made a huge difference to overview - it appears MUCH less clunky.

I'm leaning towards using this as the definitive version now.  That is, sticking with "smooth falling".


Andrew Davie

Some notes on the circular swipe. I had some trouble wrapping my head around the calculations of the maximum radius (for going out when to stop, for going in when to start).  If I get it wrong, then the one-pixel-ring-at-a-time swipe leaves behind crumbs and it looks crap.  So I was trying to calculate this value given some constraints...

* focussed on an arbitrary x,y position where x in the range 0,159 and y in the range 0,153
* screen is x,y 40,66
* screen is scrolled an arbitrary x,y position
* x and y pixel aspect are asymmetrical (y ~= 7/8x) but circle must be round
* large circle pixel rings take forever to draw

The last one being critical. I wanted to start my circle swipe with the edge of the circle JUST offscreen for the furthermost visible pixel onscreen from the circle focus. But... where's that, and how big is the radius?  Too much for me to figure out, so here's what I did.

1) Start with a theoretical maximum size circle (focus at bottom left of coordinates, furthest point top right). This works, but of course most of the large circles are offscreen and we see a 5 second + delay before the circle reduces (or expands) to the visible screen.
2) rewrite the circle draw routine to return TRUE/FALSE based on if any visible pixels actually got drawn on the visible screen (this is a very quick check, so did not cost much time).  Now I can tell, for any cirlcle-pixel ring if it's intersecting with the visible screen
3) pretend to "draw" a circle (don't actually plot pixels) and see if it is visible.  If it is not, then significantly reduce the circle radius and repeat this step.
4) Now we have a circle that's somewhere on the visible screen, change the direction - we are now incrementing the circle radius
6) pretend to "draw" a circle, and see if it's still visible. If it is, then increase the circle radius by one pixel, and repeat (6)
7) Now the circle is JUST off the visible screen, we can proceed through the swipe...
8) draw a circle pixel-ring
9) if the ring (or more to the point any pixel in the ring) was visible, then reduce the radius by one pixel, and repeat (8)
10) nothing was visible so we are done

Pretty weird - but in short - start with a huge circle - rapidly reduce it until it's for-sure visible - then slowly increase it until it's not visible, and use that as our starting radius.  Draw circles and reduce radius until not visible anymore.

For going out, it's a bit easier because we only focus on the player's x,y which is guaranteed to be visible on the start of a cave when it's called.

1) start with x,y being the focus point of the player, and radius 1
2) draw a circle
3) if visible pixel(s) increase the radius and repeat (2)

These two algorithms (more specifically the first which handles circle reduction swipint to any offscreen point) handle ALL of the various end-of-life screen swiping you see in the videos.

It's pretty neat, but a real hack. It didn't cost many bytes and works super-quick. Perhaps 1/10s delay at worst when you're a ways-away from the focus point. Hardly noticeable.  There's a slight green background flash when the trigger starts the swipe, so you can tell the time cost/delay from there.

Of course the mathematician in me (a very small one) would like to see it actually calculated. But it was  taking heaps of code and head-scratching and he above hack just fell together in a few iterations.  Sometimes you gotta do what you gotta do.

Here's the full code!

void setCircle(int x, int y, int radius, int step, enum CIRCLEPHASE phase) {

    circleCenterX = x;
    circleCenterY = y;

    circleRadius = radius + step; // 24.8
    circleStep = step;            // 24.8

    circleX = circleRadius >> 8;
    circleY = 0;
    circleDelta = 1 - circleX;

    circleComplete = false;
    circleVisible = false;

    circlePhase = phase;
}

bool drawMaskBit(int x, int y) {

    if (x < 0 || x >= _1ROW || y < 0 || y >= _ICC_SCANLINES)
        return false;

    if (x >= 20) {
        x -= 20;
        y += 3 * _ICC_SCANLINES;
    }

    y += ((x + 4) >> 3) * _ICC_SCANLINES;

    switch (circlePhase) {
    case CIRCLE_GROW:
        ((unsigned char *)circleMask)[y] |= rebase[x];
        break;
    case CIRCLE_SHRINK:
        ((unsigned char *)circleMask)[y] &= ~rebase[x];
        break;
    default:
        break;
    }

    return true;
}

bool drawCirclePoints(int x, int y) {

    int x2 = (x * 7) >> 4;
    int y2 = (y * 7) >> 4;

    bool drawn = drawMaskBit(circleCenterX + x2 /* + 1*/, circleCenterY + y) |
                 drawMaskBit(circleCenterX + y2 /* + 1*/, circleCenterY + x) |
                 drawMaskBit(circleCenterX + y2 /* + 1*/, circleCenterY - x) |
                 drawMaskBit(circleCenterX + x2 /* + 1*/, circleCenterY - y) |
                 drawMaskBit(circleCenterX - x2, circleCenterY - y) |
                 drawMaskBit(circleCenterX - y2, circleCenterY - x) |
                 drawMaskBit(circleCenterX - y2, circleCenterY + x) |
                 drawMaskBit(circleCenterX - x2, circleCenterY + y);
    return drawn;
}

void circle() {

    while (T1TC < availableIdleTime - 16000 && !circleComplete) {

        circleVisible |= drawCirclePoints(circleX, circleY);

        circleY++;

        if (circleDelta < 0)
            circleDelta += 2 * circleY + 1;
        else
            circleDelta += 2 * (circleY - --circleX) + 1;

        if ((circleComplete = circleX < circleY)) {

            switch (circlePhase) {
            case CIRCLE_SEARCH:
                if (circleVisible) {
                    circleStep = 0;
                    circlePhase = CIRCLE_REGROW;
                }
                break;

            case CIRCLE_REGROW:
                circleStep = 128;
                if (!circleVisible)
                    circlePhase = CIRCLE_RESHRINK;
                break;

            case CIRCLE_RESHRINK:
                circleStep = -128;
                if (circleVisible)
                    circlePhase = CIRCLE_SHRINK;
                break;

            case CIRCLE_SHRINK: {

                if (!circleVisible || circleRadius <= 0)
                    return;

                int rad = circleRadius >> 8;
                circleStep = -(3 + rad);
                if (circleStep < -256)
                    circleStep = -256;
                break;
            }

            case CIRCLE_GROW:
                if (!circleVisible)
                    return;
                break;
            }

            setCircle(circleCenterX, circleCenterY, circleRadius, circleStep, circlePhase);
        }
    }
}


I just call setCircle(...) to trigger the appropriate circle start, and then call circle() once per frame and it all happens. Really really hard to see how this actually manages to draw beautiful circles, but it works, trust me!

Andrew Davie


Andrew Davie


I've reworked the display system to make the 'characters' (boulders, etc.) larger. Previously 21 scanlines deep, everything is now 24. I did this mainly as an experiment but it did "unsquash" the general feeling of things. I now have round boulders rather than flat boulders - and although initially I thought I would stick with the original, I went to the effort of conditionally compiling the whole lot of changes required so that now I can select which I want.

Because the interleaved chronocolour system works in scanline triplets, 21 was 7 "trixels" as I like to call them - groups of 3 scanlines forming a chronocolour pixel.  Working with 7 is a MAJOR PAIN. For example if you want to have "half movement" in characters, one has to be 4 trixels and the other 3 trixels. Uneven and deadly to my OCD.  So with 24 lines we have 8 trixels and this can of course be evenly divided.

There are other benefits to moving to 24 - for example with the original playere graphics his head kinda poked above the space that was available. Now with the extra space he fits nicely into the tunnels, etc.  So that's a plus.

A minus is that you have less stuff visible on the screen - but this is really balanced anyway by the multiple view magnifications (all playable).  So I'm currently leaning towards using this new 24-line mode.

I play the first half of the video in interleaved chronocolour (iCC) mode.  The latter half I have this turned off and it's in normal chronocolour.  You can select whichever you prefer on the tiele/menu screen.

I am now deeply in formal "beta testing".  Although I "finished" some time ago... perfectionists never finish stuff so this is in a kind of continual holding pattern with rewrites and refinements. Waiting for the day that it will see a formal release.  Which might be sooner than we think ;)

Bomberman94

Rounder boulders are much better now! Maybe (maaaaybe) we can now re-design the diamond with the larger size? 😬

Andrew Davie

Quote from: Bomberman94 on 14 May 2024, 01:49 AMRounder boulders are much better now! Maybe (maaaaybe) we can now re-design the diamond with the larger size? 😬

Yeah, nah. Several people over the years have asked for better diamonds and invariably I go through the process of installing their attempts and showing how it really doesn't get much better than it is now. Although we have 24 scanlines of depth - we do not have 24 scanlines of inividual colour choices. Because we have line triplets there are really only 8 definable pixels ("trixels") vertically, and 4 horizontally. So if you want to design a better diamond be my guest - but remember you must draw it in a 4 x 8 space. Good luck!

Bomberman94

Ah the triplets - I forgot the triplets 😵. We can not break the rule and may use a ,,higher resolution" and don't have the color changes for example?

No, with 4x8 it really doesn't make sense to form a diamond.

alex_79

I think, considered the limitations, that the diamonds look fine. The animated sparkling effect makes a big difference in conveying that they are actually diamonds, even with the simple shape allowed by the available resolution.

While the previous sligthly squashed look never bothered me, I agree that the new one looks better, especially the boulders.

Andrew Davie

Quote from: alex_79 on 14 May 2024, 07:59 PMI think, considered the limitations, that the diamonds look fine. The animated sparkling effect makes a big difference in conveying that they are actually diamonds, even with the simple shape allowed by the available resolution.

While the previous sligthly squashed look never bothered me, I agree that the new one looks better, especially the boulders.

Here is my internal visualisation of what I'm showing onscreen (same shape/orientation)

diamond.jpg