Multi-Colour Mode

By Mark Bellis

Originally published in EUG #29

For Master series and machines with Shadow RAM and CRTC. (Sorry, Elk users! Perhaps you can use the 'extra' grey colour - See later.)

Use these instructions with the following files:

  U.16C1GEN ....... Generates machine code for 16 colour mode 1
U.16C1SRC ....... The resultant source code (already on disk)
U.36C2GEN ....... Generates machine code for 36 colour mode 2
U.36C2SRC ....... The resultant source code (already on disk)

All files have been stripped of Master-specific instructions, so they should compile/run on all machines - if you have the relevant chips!

Following an idea in the MASTER ADVANCED REFERENCE MANUAL, and also the will to stretch the BBC Master 128 to its limit (and try to keep up with other machines with zillions of colours!), I have experimented with creating modes which give more colours. (Higher resolution in Mode 0 has not been possible - yet!)

The technique is to intercept the frame-sync event with *FX14,4 and redirect the EVENTV vector at &0220-21.

Create a routine for the vector to point to which switches between main and Shadow RAM for display (by EORing bits of &FE34) - equivalent to *FX113,1 or 113,2. Change RAM banks every frame sync. Change the palette as well, by poking to the palette at &FE21. There are rules for doing this which are in the MASTER ADVANCED REFERENCE MANUAL on page 46.

Oh dear. Perhaps this means BBC B+ users cannot benefit; the MASTER ADVANCED REFERENCE MANUAL shows the RAM latch at &FE34 as a difference between Models B/B+ and the Master 128. Those hackers with their own addons might be able to tweak it though. I hope.

The "new modes" created rely on palette matrices of 4x4 and 8x8 respectively for Modes 1 and 2. 16 colours in Mode 1 is 4x4, but in Mode 2, the number of colours is 8x8, with nearly half being removed because they are duplicates.

      Mode 1                         Mode 2

                main colour                 main colour
                \  1  2  3  4            \  1  2  3  4  5  6  7  8
              --+-------------         --+-------------------------
      shadow  1 \  0  1  2  3          1 \  0  d  d  d  d  d  d  d
      colour  2 \  4  5  6  7          2 \  1  2  d  d  d  d  d  d
              3 \  8  9 10 11  shadow  3 \  3  4  5  d  d  d  d  d
              4 \ 12 13 14 15  colour  4 \  6  7  8  9  d  d  d  d
                                       5 \ 10 11 12 13 14  d  d  d
          d = duplicate colour         6 \ 15 16 17 18 19 20  d  d
                                       7 \ 21 22 23 24 25 26 27  d
      numbers 1-4 or 1-8               8 \ 28 29 30 31 32 33 34 35
      can be changed to give
      the best combinations

For Mode 2, palette-switching is not necessary; all combinations can be seen as all possible colours are available on screen at once. This is the reason why 36C2SRC is shorter than 16C1SRC.

For Mode 1, however, only four colours are available on each screen, so a possible palette combination would be black, red, green, yellow for the main screen, and black, blue, cyan, magenta for the Shadow screen. If white was required, it would have to be one of the colours on each screen, thus reducing the available combinations.

One slight disadvantage of multi-colour Modes is that all points plotted, or text printed, or sprites copied to screen, need to be written to main RAM then, after switching a bit of &FE34, written to Shadow RAM thus taking longer to plot. I have, however, written a multi-colour Mode sprite plotting routine which is not slow enough to hinder writing games that use it. There will be a memory overhead of twice the number of sprites though - each screen needs its own set.

Unfortunately the necessity to slow the refresh rate down to 25Hz rather than the usual 50Hz, in order to fit two screens into the time, means that the effect of light/dark colour combinations (such as yellow/red) is rather flickery (Beware if you are allergic to strobes!)!

Try to stick to combinations that are not so bad, such as:

  red/black .... appears .... brown(ish)
blue/red .... appears .... purple
red/magenta .... appears .... shocking pink!

etc...

The list of pure colours in order of brightness is as follows:

  White, cyan, yellow, green, magenta, blue, red, black.

Generally, the nearer two colours are to each other in the above list, the less flickery the combination will be. The best grey will be green/magenta for this reason. (By the way, a game called 'ORCREST' uses colour 11 with *FX9,1 and *FX10,1 to give grey - perhaps all machines can have an extra colour - although *FX9 and 10 rely on the LSB of the VIDPROC register - do Elks have a VIDPROC (as they don't have a CRTC)?

Mark Bellis, EUG #29