Scrolling Tiled Backgrounds

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

The current engine is derived from Boulder Dash (BD). In BD, there's a board of a set-size (40 x 22). The engine implements this as a fixed buffer of 40x22 characters (thus, 880 bytes of RAM). Each one of those 'grid positions' is processed every game frame - that's where a lot of the processing time goes.

In the original BD, sophisticated algorithms were employed to avoid scanning everyting; in particular, stacks of objects and changed squares were maintained so that only things that needed to be processed were processed. It was quite the amazing bit of convoluted code - but it worked.

However, 40x22 is quite a limitation - for several reasons. The first is that although it's a "large" playing area, it is still very constrained. Side scrolling games probably need a larger virtual world. Secondly, it's expensive in terms of taking up much of the avoiable RAM.

So what I/we really need is a scroll system that will feed rows or columns onto the screen *as required* and thus give an effective "infinite world".  This is pretty much how NES and C64 games I wrote did it - that is, we have the visible screen buffer, and a single character 'padding' on the edges onto which we feed scrolling playfield as required.  I need a system like this for Lemmings.

I have no idea how big the Lemmings worlds are right now, but I don't see a real need to limit things. I'll write a generic system that feeds *matrices* as required. This thread is for updates on how that process is going.

Probably first thing I need to work with is the visible screen buffer.  Characters in the character set are configurable in the engine. Although a particular instance (e.g., Boulder Dash, or GridLock, or Lemmings) needs to hardwire to a particular character size... the engine itself can handle any size.  So, in Lemmings we have a character size of 5 pixels wide x 11 trixels (33 scanlines) deep. 

That equates to 40/5 == 8 characters across, and 198/11/3 = 6 characters deep.  And we'll add an extra row and column for the "feed in" scrolling bits, which gives 9 x 7 (i.e., 63 bytes) for the screen memory. Right off the bat, that saves 817 bytes of memory - and we go from a 40x22 playfield to an (any x any) playfield.  Of course I have to write the thing first, but that's the plan!

Andrew Davie

#1
I've made a start on this. What we have here is a 9 x 7 character buffer (i.e., the visible window + border strips) being populated with "scenery". That scenery at the moment being just a randomly selected character. But it's the genesis of a full-blown scroll. What I need to do now is figure the tileset data structures and read the scenery from those instead. And I'll need to adjust the sub-character scroll so that we see the buffer strips (or pixels thereof) when appropriate.

After that, we'll have an "unlimited" scrolling background that isn't restricted to the 40x22 of previous engines, and more to the point is using WAAAAAY less memory.


Andrew Davie

same system - iCC instead of pCC this time.


I think I prefer iCC.

Bomberman94

You do magic things with the 2600 but I still can't imagine playing Lemmings in these dimensions/proportions.

Andrew Davie

Quote from: Bomberman94 on 09 Oct 2025, 07:03 AM... I still can't imagine playing Lemmings in these dimensions/proportions.

You may be right, but it's fun seeing what happens. Besides, it's requiring the development of systems that should be useful in other games.

Andrew Davie

The background scrolling system is taking shape. It's a matrix-based system, where the background is defined by a grid of matrices - each of those being 4x4 characters in size.  In this demo I think I had some 60 matrices across - some 240 characters, Each character is 5 PF pixels horizontally by 33 vertically.

In the video I play around with scrolling via joystick moves. It takes a hefty while to find the right and bottom edges of the world.  You can clearly see, in this random data, the 4x4 matrices - I defined just 3 variants of them for this first effort.  The reason for using matrices is the overall saving in ROM space - you can get big worlds at 1/16th (roughly) the data size. It seemed the right thing to do, so now it's done.

Now the scrolling I've limited to running just every 8th frame - and so it's quite clunky and jerky. The finesse will come later, but for now it appears to be working just fine. Now I need to write a converter and grab some actual genuine background data from Lemmings. That may take a little longer to do.

In the game itself, the lemmings will mostly be drawn over black, so they will be easier to see. I will also choose colours where the scenery in the background uses colours NOT used in the lemmings, so they will be more distinct. I have 8 colours (including black) to play with total.


Andrew Davie

#6
I'm thinking about the conversion/porting process from the original graphics. Although those graphics are all drawn with tilesets and characters, as per this system, there are fundamental differences in the graphics in terms of aspect ratios, pixel format, character sizes, etc.  So I'm thinking of this process:

1) get a screenshot of any level
2) scale it such that its dimensions are multiples of my character sizes (i.e., 5 across and 33 deep)
3) downsample colours to the 8-colour palette (this will need much more work)
4) write a tool to produce a unique character set (dropping duplicates)
5) produce a matrix set for the image

Additional data such as lemming placement, etc., can come from original source data or added manually.
This should take a day or two - essentially I want to see a rudimentary 1st level background displaying on the '2600. It's going to be VERY rudimentary, but that's the goal.


Edit: That's not gonna work; there are not enough quality screenshots of appropriate resolution.
Going to have to work from tileset/characterset data, if I can find it.


Andrew Davie

#7
The smooth scrolling is now implemented. Looks really good.
I also have some lemmings doing very rudimentary collisions and animations based on what they're doing.


Next step, I think are some data conversion tools to get a proper background in.

I've hardwired the palette in this version.