Boulder Dash 2

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

#15
SECAM does a surprisingly decent render, given the 8-colour fixed intensity palette!

crt_composite_CDFJBoulderDash_20240118_000038.jpg

New teeth version...
crt_composite_CDFJBoulderDash_20240118_185644.jpg

Andrew Davie


Andrew Davie

#17
We've been to the dentist to fix our teeth.

crt_composite_CDFJBoulderDash_20240118_190830.jpg

Creating an image like this is reasonably challenging.  With iCC (interleaved ChronoColour) we actually have only three colours - repeating down the screen.  Each group of 3 lines "rotates" through those three available colours. By varying when pixels are on/off within those 3 lines, we get a blend of colours (over time), forming the iCC system.

This means we don't really have a graduated palette like this image seems to suggest (with the fine shading).  We actually still ONLY have those three colours (and for the record, in this image they are NTSC 0x10, 0x16, 0xF4).  If we blend pixels, we get a "mixed" colour based on combinations of those (8 possibilities including black).  The trick is finding a good set of the three original colours which, when blended in the 8 ways, produce acceptable (perceptual) colouring.

To produce the data for this display, I have a small tool that takes an input GIF and simply outputs a table of byte values for writing to PF registers.  It's 4 bytes wide (=32 pixels) and 66 pixels deep - each pixel being a "trixel" 3 scanlines high.  So effectively 66*3 = 198 scanlines deep.  That's what you see here.  The display code does the "rolling" of the colour usage within each triplet of scanlines to produce that expanded version.

So, a full screen image (well, 32 pixel wide) takes 264 bytes of data.

To produce this particular image, I created a GIF image with a graduated palette from dark to light, and then transformed the original image into the correct size using this graduated palette.  This means that the darkest non-black pixel is colour #1, black being colour #0, and the lightest colour #7.  I can effectvely only define 3 colours, those being #1, #2, #4 - and the other colours we see are combinations of those three.  So I need to find colours such that #1+#2 looks kinda halfway between #2 and #4 (ie: #3) -- and similarly for all the other non-elemental colours. It's tricky to do, as (for example) colour #1 is only shown on one of every 3 frames (for any scanline) due to the iCC triplet drawing.  And colour #3 is shown on two of every 3 scanlines. Another way of thinking of this is that an iCC trixel (3 scanlines) is formed by an on or off pixel on each scaline. For colour #1, #2, #4 we have an on pixel on one scanline only.  For colour #3, #5, #6 we have an on pixel on two scanlines, and for colour #7 we have all-on pixels on the 3 lines. But this means that the perceived intensity is different not just on the graduated palette concept, but also on the duration/area on screen of each colour.  Those with 1 scanline are shown 1/3 of the time. Those with 3 scanlines (i.e., colour #7) are shown 3/3 of the time. This significantly affects the brightness. So we have this complex problem - what colours should we choose to get a nice brightness graduation, AND what palette entry should they be at (given the temporal duration of each colour as explained earlier).  What I do is not an optimal solution (creating a graduated palette), and might give better results if I took into account the colour durations as explaned, but for now I'm using exisiting tools and the result is... OK.

I've attached the GIF source image!

BoulderDash.gif


Andrew Davie

Here's the standard (non-interleaved) ChronoColour version.  Rock solid, no "shimmer" that iCC has.
Not too bad.  I'm busy integrating this with the rest of the game; I don't have much space left so it's tricky.


crt_composite_CDFJBoulderDash_20240119_170835.jpg

Bomberman94

Wow looks great on TV - the perfect ,,Game Over" screen. Maybe a bit too much shimmer in iCC mode but not for my taste personally (I think because of its huge size on the screen...).

Andrew Davie

I ran out of space and thought finding more was next to impossible. But, coming back to it after a while I found several optimisations which, surprisingly, gained me about 600 bytes (!) which is actually quite remarkable on "already-optimised" code.  So in this version I've now managed to integrate the entire "rage quit" screen (seen in action about 50s in the video) and still have about the same space I had before that.  I've been working on "tidying up" some of the transitions between various "modes" - copyright, menu, status, game.  I have a few poor 263- scanline frames in there which are proving a bit tricky to remove. It's getting there, though.


Andrew Davie

One thing I forgot to mention - for the longest time there was a bit of sluggishness in the controls. You'd tap the joystick but the move would not happen for just a tiny fraction, which I thought was inherent in the design of the systems. But I revisited the code and managed to tweak things such that joystick presses are picked up just a fraction quicker, and it does seem to make a difference to usability. 

Andrew Davie

#22
A bit of an experiment; in WenHop I implemented "rounded corners" on dug-out dirt squares. I've transplanted the draw routine from WenHop into BD to see what it looks like. The following two images are the original (no-rounded-corners) both with and without the parallax...

Click on the image(s) for big versions!

crt_composite_CDFJBoulderDash_20240127_171442.jpg. crt_composite_CDFJBoulderDash_20240127_171438.jpg

The two below are the new "rounded corner" implementation.  It's costly; about 600 bytes all-up, and I really can't afford that without ditching other capability. In my view it does NOT work when the parallax is visible. It DOES work otherwise. For reference, look at the blank "hole" at bottom right of board. Early version has square corners... later version has rounded. But I'm not sure I'll keep it.

crt_composite_CDFJBoulderDash_20240127_171249.jpg. crt_composite_CDFJBoulderDash_20240127_171244.jpg



Bomberman94

I think most people will turn on the parallax scrolling therefore the rounded corner effect won't be much recognized. At the end personally i'm not sure if it adds much to the game.

Andrew Davie

#24
Here I attempt to discuss the difficulty in having a responsive joystick in a game that is running a game loop at approximately 15 Hz, with variability on when the player is processed within the 7 frame game loop. It's complex.

----> TIME AXIS

  1 TV frame
+------------+

 -->                                   1 game frame (7 TV frames)                       <--
+------------+------------+------------+------------+------------+------------+------------+

 --> board processing (including player)             <--|
+-------------------------------------------------------+
                                                         -->  idle time                 <--
                                                        +----------------------------------+

============================================================================================
SCENARIO 1
----------
--------------------------------------->*
                                         player processed here (e.g)
--->*
    joystick pressed here
------------------------------>*
                               joystick released here
============================================================================================

SCENARIO 2
----------
-------------------------->*
                           player processed here (e.g)
--->*
    joystick pressed here
------------------------------>*
                               joystick released here
============================================================================================

SCENARIO 3
----------
->*
  player processed here (e.g)
------->*
        joystick pressed here
------------------------------>*
                               joystick released here
============================================================================================

SCENARIO 4
----------
->*
  player processed here (e.g)
------------------------------------------------------------------->*
                                                                    joystick pressed here
--------------------------------------------------------------------->*
                                                                      joystick released here
============================================================================================

1. when the player is processed, the joystick is not pressed. But it was pressed at the
  start of the game frame, so we should really be reacting to that press. This means
  we need to BUFFER the joystick, and player should use buffered joystick for moves

2. when player is processed, the joystick is still pressed, and we make the move based
  on the buffered value. But the joystick is STILL pressed. This "release" may not
  happen until deep into the time for the next game frame. Should we be responding to
  that press for the 2nd game frame, or not?

3. joystick is NOT pressed when player is processed. But it's pressed and released within
  the current game frame. We should buffer the joystick and react, but there will be
  a SIGNIFICANT delay before the player moves. In this case, it could be 6 TV frames
  (1/10 second) which is noticeable. How do we prevent this lag (where the joystick
  is pressed early in the game loop, after the player has already been processed)? This is
  an argument for having a short game loop (instead of 7 TV frames, say 4 or 5). But there
  is a limit to how fast the system can run (say, 4 TV frames per scan), and in any case
  if we run a 4-frame game loop then everything moves super-fast, which is not playable.
  So there is a balance between joystick responsiveness and game speed.

4. Joystick is pressed and released within a single TV frame. Should we buffer it?  If
  the joystick is only read once per frame, then we may or may not miss the press. How
  many times per TV frame should we be reading it? Currently it is read once per
  frame, in the overscan period.

We MUST process the player in correct sequential order based on the board. What is
above the player has to process before the player, and below after. This is critical. But
because the game loop takes many frames (say, 4) and the player can be at top or bottom
of the board, we cannot guarantee where in the game loop the player is processed. And
likewise the joystick can be pressed/released at any point in time. Either before or
after the player is processed. It can easily be pressed/released between the time
player is processed and the next time it is processed.  It can be pressed just after the
player has processed, and almost an entire game frame will pass before it can possibly
be acted upon. Given a game frame is ~6/60 seconds that's 1/10 th of a second. VERY
noticeable.

JetSetIlly

Quote from: Andrew Davie on 28 Jan 2024, 03:17 PMWe MUST process the player in correct sequential order based on the board. What is
above the player has to process before the player, and below after. This is critical. But
because the game loop takes many frames (say, 4) and the player can be at top or bottom
of the board, we cannot guarantee where in the game loop the player is processed. And
likewise the joystick can be pressed/released at any point in time. Either before or
after the player is processed. It can easily be pressed/released between the time
player is processed and the next time it is processed.  It can be pressed just after the
player has processed, and almost an entire game frame will pass before it can possibly
be acted upon. Given a game frame is ~6/60 seconds that's 1/10 th of a second. VERY
noticeable.

Also, don't forget that there'll be lag introduced by emulation, which will affect perception of how responsive the game is. In Gopher2600 there's a 5 frame lag by default, but you can reduce it.
https://github.com/JetSetIlly/Gopher2600
@JetSetIlly@mastodon.gamedev.place
@jetsetilly.bsky.social

Yurkie

This is pure genius Andrew, I would buy the rom.

Andrew Davie

Quote from: Yurkie on 29 Jan 2024, 01:44 AMThis is pure genius Andrew, I would buy the rom.

TY. I often wonder how, if ever, I am going to get this into players' hands. I hope to release a playable demo but who knows. As to making ROMs available for purchase, that has crossed my mind. But at this stage there are no discussions/plans along these lines.

Andrew Davie

Quote from: JetSetIlly on 29 Jan 2024, 01:22 AMAlso, don't forget that there'll be lag introduced by emulation, which will affect perception of how responsive the game is. In Gopher2600 there's a 5 frame lag by default, but you can reduce it.

Could you expand on this?  Why is there a lag, what are the consequences when compared to playing on hardware. Why is it 5?

JetSetIlly

Quote from: Andrew Davie on 30 Jan 2024, 01:49 AMCould you expand on this?  Why is there a lag, what are the consequences when compared to playing on hardware. Why is it 5?

Because we're not running on a realtime OS there's no guarantee on when we receive the next frame for rendering. With flicker kernels this is a particular problem because it spoils the interlacing effect. We can increase the intensity of the phosphor effect but I don't feel this is a great solution in all cases.

Another way is to let the emulator run ahead and to buffer the frames in a queue and to show the queue in sync with the monitor. This is a good solution if the monitor is running at a similar rate to the refresh rate of the emulated TV.

I set the queue to five because I felt it was a good balance between responsiveness and smoothness of the display. A queue of one is janky on my machine for example. You can change it in Gopher2600 from the Playmode tab of the Prefs window *

(* The "Automatic Frame Queue" options works okay but if there's a sudden surge of CPU load from elsewhere in the system then the queue can get too high - I can definitely improve on this and introduce conditions under which the queue can reduce in length.)


I think there's room for improvement but ultimately, there's always going to be certain amount of display lag introduced by the emulation process. Of course, at some point, the difference is imperceptible to the human eye. I think 5 frames is probably okay in most cases, but in the case of BoulderDash if you're checking input less frequently than every frame then it might be more noticeable.

https://github.com/JetSetIlly/Gopher2600
@JetSetIlly@mastodon.gamedev.place
@jetsetilly.bsky.social