The Sentinel (1986)

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Andrew Davie

#45
OK, as could be expected things are tight in the timings. I've done a bit of optimisation of things and learned a lot more about limitations and what I need to do. Memory is over-used so we may halve the vertical resoultion, or switch to a more capable CPU. I don't know how to do the latter - but would really like to use the same CPU as the PlusCart which I understand is a beast.

One nice bit of improvement is the idea of dithering images (as per these examples), but manually preprocessing and block-filling solid colours which we want solid after dithering with the appropriate reference palette colour. All being well, these areas will NOT be affected by dithering. I did this in the sample for the sky (which in previous versions was really dithered and odd looking) and the light green of the tree. A lot better.



One of the interesting challenges is drawing lines in hi-res (the sprite window) that continue into the low-res area but still look "good". It's a real balance between thickness and speed. In any case, I for the most part won't be continuing with the 3D cube/lines. But it's a learning experience and I wanted to get some basic idea of how much processing time I had.



Andrew Davie

One interesting idea I had was that on the initial draw of any view (i.e., when you move or turn and the 3D renderer does its stuff for a few seconds while you have a cuppa)... well when it comes back the hires window should be positioned on the "most significant object" on the screen. In the above examples it would be the near sentinel-type guy as shown in the first image.  You'd still have manual control to shift the window left/right, but with initial positioning the graphics and info available on first glance would be improved.

Andrew Davie

#47

At the moment I'm working on a 3D engine. Previously I have demonstrated wireframe via a rotating cube. Now I've added "solid" faces. This will eventually morph into the engine that draw the terrain. It doesn't need to be too sophisticated, but I'm raw at 3D engines from 1st principles, so I'm quite happy with this.

There are a few things missing - backface culling, and sorting of the faces. So things overlap when they shouldn't - these are not complex things to fix, but imagine my excitement when THIS started working for the first time. Basically, the flat-fill of the face(s) of the cube as it rotates. It may not seem like much, in the scheme of things, but I'm chuffed that it's working and one more obstacle out of the way.

I only have 3 faces rendering here (the rest is wireframe). A few things to note;

a) with the current architecture all of this has to happen in the overscan/vblank period (Zack calls this "overblank" which is neat.  So that's roughly 1/5 of the processing time of the screen.
b) I add any more and everything goes overtime - crash
c) The faces and edges are unsorted, so they draw over each other inappropriately. A sort is coming soon.
d) Video shows hires window moving over/off the rotating cube, so we see it in both hires and lowres (and parts thereof). It's mostly OK, but perhaps I can improve the downsample so that those joins between faces are more intuitive. Rather than red+blue = white, perhaps I might choose one over the other. That's for a later day though.
d) Gopher gets way slow with 3 -- down to about 45fps on my machine!  I shudder to think what's going to happen when I'm rendering 500 faces :P. -- I'll have to disable/implement in parts and have functional hardware handy.



Andrew Davie

3D graphics needs trig. I'm quite proud of my little sin() function which uses the Taylor series. I've optimised it as much as I could, and it's sufficient precision and reasonably zippy. Works with radians, in the range -PI to +PI


int factorialTable[TRIG_PRECISION*2+1] = {
    1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800
};


#define TRIG_PRECISION 5

float sin(float x) {

    float sum = 0.0;
    float p = x;
    float x2 = -x * x;

    for (int i = 1; i < TRIG_PRECISION * 2; i += 2, p *= x2)
        sum += (p / factorialTable[i]);

    return sum;
}

Andrew Davie

Backface removal is now working, and the cube... looks like a cube!  Regular black-screen flickering is overtime issues, and a solution for that is being discussed. There are a few options, but it's not an issue in the global scheme of things. Will not happen with new architecture.


Andrew Davie

We can do alternate colour schemes...


Andrew Davie

OK, found a glitch in the iCC display that caused flickering. Here's a regular chronocolour (CC) display, with some improvement in the rendering thrown in too. The edges are only drawn when the cube is close. In this video I shift the hires window left/right at the start, too. Looking quite nice!


Andrew Davie

There's a high-resolution "buffer" into which the 3D system does its rendering. This is at resolution 160 x 96, basically. But the PF background only has 40 pixel resolution, so the high-res buffer is subsampled (in real time) down to 40 x 96. The display system uses the high-resolution buffer for the sprite display (48-pixel x 192), and the low-resolution buffer for the playfield display, blanking out the playfield where the sprite strip is. The sprite strip can occupy any of 5 positions on screen - basically left, left/center, center, right/center, right. So by moving the sprite strip, we get a highres strip 48-pixels wide in one of those positions, with the rest of the screen in lowres.  Because the sprite strip and the playfield are sourced from the same data, they tend to blend very nicely.

The 3D engine (which I've written from scratch - still WIP) renders into the high-resolution buffer just before the subsapling -> low resolution is done. What's really interesting is looking at how well the subsampling is doing. It's actually quite a complex interaction between the chronocolour display and the different resolution pixels. One wants to avoid cross-pixel contamination, so the subsampling has been a bit of a black art. But this version is working very nicely.

So here it is, all coming together in a quite "clean" implementation.  Next up, more 3D engine work... and down the track we will have a version that can handle many more objects.


Andrew Davie

What is shown in this video works on real Atari 2600 hardware. That is, if you put this on a cartridge, plug it in, then any genuine Atari 2600 will run it.

I'm still piecing together my 3D engine. I've realised I'm doing things a bit primitively - from first principles, basically - rather than using matrix math. My math isn't strong, but the transformation matrices for 3D are extremely well documented, so I will move to those.

The scaling is hacked in this - just continually expanding. The x and y positions are working correctly, calculated according to camera position/distance. But there are a few things not quite working properly. I'm not too far away, though.

A limiting factor at the moment is that this all has to run in the overblank, so that the scren can be drawn in the remaining time. I'm itching to get an interrupt system running which will give the 3D stuff about 5x the speed. I can't, at the moment, show more than 3 cubes of about the size you see here.  Or, one giant one that fills the whole screen when close.


Bomberman94

The last binary you shared (1.7. last one) starts but crashes then (light 6er Pal with PlusCart). Maybe you share this one with us? Thanks for your amazing work 👍

Andrew Davie

Quote from: Bomberman94 on 07 Jul 2024, 03:00 AMThe last binary you shared (1.7. last one) starts but crashes then (light 6er Pal with PlusCart). Maybe you share this one with us? Thanks for your amazing work 👍

The binaries will crash occasionally as there is no time-checking, and everything has to happen in the "overblank". It's a balance at the moment trying to get things working at all, and keeping within the overblank limit. Changes are afoot (a few weeks from now hopefully) where there will no longer be any time limit on the 3D engine, and it can do way more complex things.

I might hold off on binaries for a little, as I don't want to be dealing with lots of bug reports on systems that are really not ready for testing. More to the point, what it is NOW is nothing really to do with the *game* Sentinel. I'm just building/demonstrating 3D systems.

Andrew Davie

#56
I've reconsidered, and just gonna plonk down this binary for now. It may very well crash when there are two large objects on the screen (=overtimer). I've been thinking a lot about the 3D engine and the issues I can forsee -- basically it's going to be easier in the long run to port an existing engine, so I'll once again be looking at that option.

NOTE: Press DOWN 3 times or so to get to the non-interleaved small-format chronocolour screen as per the picture...


Andrew Davie

What is shown in this video works on real Atari 2600 hardware. That is, if you put this on a cartridge, plug it in, then any genuine Atari 2600 will run it.

This is a screen capture of the Gopher emulator running the binary. This is really pushing the limits of what's possible -- "ambitious" would be a good description. As such, the emulation is running at about 50% speed.  What I'm doing here is allowing larger cubes - but only rendering one cube per overblank period. There are 5 cubes, so the frame rate is about 6/60 (i.e., 10Hz in the real world.  Going about 5 Hz here because of the emulation slowdown).

This was never meant to be a "realtime" engine -- that is, there are only occasional updates to the screen expected/required in "The Sentinel". Although this rudimentary 3D engine looks capable, there's a LOT left to do and I'm exploring other avenues for the 3D part.



Andrew Davie

#58
A bit disillusioned. My math isn't really the greatest to be doing a 3D engine, but will keep going I guess. There's lots of online examples, and so far it looks OK. I guess I know there's a LOT left to do. At least we've shown that "The Sentinel" is not only feasible, but that it won't be all that bad looking, actually.

At the moment I'm just faffing about, really. There are a few things that need doing, and a lot of things that needed experimenting. Although the downsampling of hires buffer -> lores is quite effective, there are some "glitches" there that are the result of treating each colour plane in isolation. I can't see a better way to do it at the moment.

Also, the outlines of the 3D shapes -- this black line doesn't follow the edge of the coloured infill. This is due to different algorithm/math. I think it will be a lot better when I get around to fixing that.

Also also, the faces need to be sorted. I just don't have the motivation right now.  Also the clipping at the edges of the screen seems to be a little haphazard - whole faces flip on/off, and that shouldn't happen.

Just a lot of little things.

Attached are a bunch of random colour schemes. ChronoColour has just 3 available colours, nominally red, green, and blue. But those colours combined with adjacent on/off pixels give the impression of 8 colours. If we use different colours than "red" "green" "blue" we get different "schemes". So I pumped random values into "red" etc., to see what came out.



Andrew Davie

Here's a run with 32 cubes. I'm a bit down about the various little bugs that have crept in. I might spend some time tightening up things - particularly the chronocolour display which I have somehow broken and to be honest have no idea how it's actually working at the moment.

I really need to get the source code back into shape. I've hacked it a fair bit doing "what if??" experiments and it's a bit unruly/disorganised. Bah.