8 colour mode 1 screens for games

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
dave j
Posts: 2
Joined: Tue Aug 18, 2020 3:48 pm
Contact:

8 colour mode 1 screens for games

Post by dave j » Wed Aug 19, 2020 8:12 pm

I read recently about how Oric 1 programmers use different palettes on alternate scan lines to work around the limitations of the colour attributes of that system and wondered how practical something similar would be to display 8 colours in mode 1 on the Beeb.

I'd read the Enhanced mode 1 pictures thread some time ago and that provided a starting off point. Obviously, palettes that adapt to the image aren't really suitable for animation - they'd severely restrict what you could place where without requiring more than four colours per line. Similarly, only being able to change two colours per scan line would also be an issue - I'd been thinking about alternating RGBW and CMYK palettes on successive lines to get all eight colours on screen. hexwab's mention of the flash bit in that thread provided the key to a solution because that would enable switching the whole palette with only one write the the ULA and it fits perfectly with my idea of swapping between RGBW and CMYK palettes.

The first step was to see if you could still get reasonable results from such an arrangement, so I wrote a alternating palette aware implementation of the Floyd-Steinberg dithering algorithm that converts an image to only use the colours available on the Beeb with alternating RGBW and CMYK palettes. You can customise the palette used by editing a variable near the top of the program.

The results where promising:-
DSCF5207-320x240x.png
DSCF5207-320x240x.png (27.62 KiB) Viewed 661 times
legzelda3-39x.png
legzelda3-39x.png (22.06 KiB) Viewed 661 times
mslug1x.png
mslug1x.png (21.75 KiB) Viewed 661 times
supghouls-16x.png
supghouls-16x.png (17.47 KiB) Viewed 661 times
superrtype-16x.png
superrtype-16x.png (17.83 KiB) Viewed 661 times
Not being able to produce true black or white can a problem but you can always define some fixed colours at the loss of others - a fixed black is an obvious example for space games. The last two images above do this (fixed black, no white for supghouls and fixed black and white with no green or magenta for superrtype). For reproducing photos, the approaches described in the Enhanced mode 1 pictures thread would produce superior results but the advantage of this scheme is it could be used for games.

Now obviously, the Beeb doesn't have the memory to store huge sprites or backgrounds used in those example images so to give an idea of what might be more achievable I added colours to a screenshot of the Spectrum version of SabreWulf and ran it through my dithering program.
SabreWulf2x.png
SabreWulf2x.png (10.08 KiB) Viewed 661 times
Obviously, there has to be enough time left over from palette switching to run a game so to test it out I've implemented a little demo that moves 6 24x24 spites over the mslug image. It uses use interrupts from user VIA timer 1 to control when the palette switches occur. Here it is running in b-em:
screen.png
The attached ZIP file contains:
  • dither.ssd - a disc image containing the demo.
  • dither.py - the palette switching aware dithering program.
  • tomode1.py - a program that takes the output of dither.py and converts it into Beeb 4 colour format.
  • dither.6502 - the source to the demo program.
  • bbc.6502 - some Beeb related defines and macros used by dither.6502.
  • square.dat - the sprite used in the demo.
  • slug1 - a version of the mslug 1 image above padded out to fill a mode 1 screen.
My 6502 is very rusty and the code is written to demonstrate the technique is feasible rather than a optimal implementation but I hope someone finds it useful.
Attachments
dither.zip
(31.48 KiB) Downloaded 31 times

User avatar
BigEd
Posts: 3420
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: 8 colour mode 1 screens for games

Post by BigEd » Wed Aug 19, 2020 8:33 pm

Colour me impressed! Excellent results. (And welcome!)

User avatar
tricky
Posts: 4665
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 8 colour mode 1 screens for games

Post by tricky » Wed Aug 19, 2020 8:47 pm

That's a nice idea.
If you have a boobip OS RAM expansion, you can half the cost of the interrupt, but with some creative coding, you might be able to interleave the update with a sprite routine and have less interrupts.
I would think that sprites with detail might need to stick to horizontal movement, or have two copies - may be free if they are already animated.
My Astro Blaster does all its drawing "off screen", so there is room to do quite a bit - but having a background that means the sprites need to be masked is not cheap.

User avatar
scarybeasts
Posts: 552
Joined: Tue Feb 06, 2018 7:44 am
Contact:

Re: 8 colour mode 1 screens for games

Post by scarybeasts » Wed Aug 19, 2020 9:39 pm

Great! Love these images.

VectorEyes
Posts: 376
Joined: Fri Apr 13, 2018 2:48 pm
Contact:

Re: 8 colour mode 1 screens for games

Post by VectorEyes » Wed Aug 19, 2020 10:53 pm

This is a really, really nice idea and those images look excellent.

Would you mind if I stole the idea and played around with it for future demo effects?

User avatar
FourthStone
Posts: 1028
Joined: Thu Nov 17, 2016 2:29 am
Location: Brisbane, Australia
Contact:

Re: 8 colour mode 1 screens for games

Post by FourthStone » Thu Aug 20, 2020 1:09 am

Super! Always amazed that there is still new stuff to try on the humble beeb.

=D>

User avatar
Rich Talbot-Watkins
Posts: 1661
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: 8 colour mode 1 screens for games

Post by Rich Talbot-Watkins » Thu Aug 20, 2020 11:53 am

I love this! The results are amazing, and it would definitely be interesting to see the technique used in a real game or demo.

It's great that people are still finding clever, innovative ways to push the humble Beeb after all this time!

User avatar
tricky
Posts: 4665
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 8 colour mode 1 screens for games

Post by tricky » Thu Aug 20, 2020 12:28 pm

dave j wrote:
Wed Aug 19, 2020 8:12 pm
BTW, Welcome to the forum (RichTW noticed and mentioned it) - great first post.
We have a Virtual (via Zoom) ABUG tonight that is dev focused if you are interested.
viewtopic.php?f=25&t=20237

User avatar
tricky
Posts: 4665
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 8 colour mode 1 screens for games

Post by tricky » Thu Aug 20, 2020 12:37 pm

Did you try with just black, red, green and blue, probably need black in one pair and blue in the other for darker scenes?
I guess it might be too limiting.
Or even in MODE 2, where you use the palette to have 4 background colours and 3 foreground colours.
- may be too blocky, I was thinking of something like Bomb Jack.

dave j
Posts: 2
Joined: Tue Aug 18, 2020 3:48 pm
Contact:

Re: 8 colour mode 1 screens for games

Post by dave j » Thu Aug 20, 2020 3:34 pm

Thanks for all the kind comments.

Replying to all the points raised no particular order.

I don't have a Beeb any more. After I got an Arc in 1987 my Beeb was used by my younger siblings for school work. At some point my parents decided it was no longer needed and it ended up at a church jumble sale or something. :(

If anybody wants to use the idea/code please feel free. I included the source in the zip file in the hope someone might find it useful. You'll want to review the code though. When I said my 6502 was very rusty I meant it - this is my first since 1987!

I don't have a web cam so joining the virtual ABUG meeting won't be possible.

Using just black, red, green and blue will be too dark - I had experience of this when emulating slot masks in crt shaders for Retroarch (I wrote the crt-pi shader).

I'm not sure how much I'll be able to contribute to the forum, I'm supposed to be finishing off GPU based rendering for the Vectrex emulator used by Retroarch and this Beeb stuff was a distraction from that. The GPU rendering itself is a distraction from me trying to learn more about electronics. Of course, getting a non working Beeb, fixing it up and designing some add-ons for it would be an ideal way to learn about electronics but I'm not sure I want to go down that particular rabbit hole yet.

User avatar
tricky
Posts: 4665
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 8 colour mode 1 screens for games

Post by tricky » Thu Aug 20, 2020 7:12 pm

You can join as a "lurker", you can watch and hear and don't have to show or tell :)

User avatar
Arcadian
Site Admin
Posts: 3599
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: 8 colour mode 1 screens for games

Post by Arcadian » Fri Aug 21, 2020 1:51 pm

dave j wrote:
Thu Aug 20, 2020 3:34 pm
I don't have a web cam so joining the virtual ABUG meeting won't be possible.
Thanks for posting, I've only tried the demo under emulation so far, but it's majorly impressive!

Really would be great if you could join in at one of the Virtual Dev Nights in the future, and maybe chat a little about the 'tech' (next one will be Thursday September 10th, from 7pm).

As tricky points out, there's no requirement to have a webcam - just a mic or headset with mic will do (or you could even just lurk if you wanted, but that might not be much fun!).
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

User avatar
tricky
Posts: 4665
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 8 colour mode 1 screens for games

Post by tricky » Fri Aug 21, 2020 3:33 pm

You can use a mobile phone on wifi too.

Post Reply

Return to “programming”