Lesson P17 - Palette definitions on the BBC

Posts relating to BBC A / BBC B and Master
Post Reply
User avatar
Posts: 411
Joined: Mon Apr 22, 2019 3:19 am

Lesson P17 - Palette definitions on the BBC

Post by akuyou » Mon Sep 02, 2019 9:16 pm


In these tutorials we use a common RGB palette definition which uses 1 nibble per color in -GRB format...
The BBC only has a fixed 8 color palette, so we'll need to convert those colors via a lookup table, and set them in the hardware,
Lets learn how!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Posts: 6
Joined: Sun Aug 18, 2019 7:14 am

Re: Lesson P17 - Palette definitions on the BBC

Post by tricky » Sat Sep 07, 2019 8:29 am

The beeb has had many palette extenders over the years (1st in 1982), but the most recent is the Video NuLA (New ULA), allows a palette of r4g4b4 and two modes of mapping the beebs 16 colours (actually 8 + 8 fixed flashing combinations - why!!!) to what you see.

The first mode allows you to remap the original output colour to a different colour, so as long as swapping one colour for another is OK, then you can set the palette and run the game and hey-presto, the game has new colours.

The second mode replaces the original operation of the Video ULA and maps bytes to different combinations of colours/pixels. In this mode you can have 16 colours on screen without reprogramming the palette and all 4096 if you like! I think this is the mode that the CPC emulator for the beeb uses as it only needs access to all 16 palette entries.

An extension of the second mode allows colour schemes more like other micros, including a 3 pixel per byte mode, where the first 2 bits select the palette and the 2 bits per pixel select from that palette. Another mode has one byte specify foreground and background colours, which the next byte then indexes to give a kind of attribute mode that is used in the spectrum emulator that runs on the beeb with copro. There is also an 80 column mode with a choice of 8 colours per character.

One final trick that the NuLA has is that it can do hardware sub-pixel horizontal scrolling, which is hard on the beeb.
b-em windows, not sure about other OSs, jsbeeb java script in browser and maybe b2 and beebem emulators support the NuLA.

This is the setup code from my Frogger game (actually, it isn't the final mapping), it sets up the remapping and then after this sets the palette up as normal, so if there is no NuLA, the game uses blue and magenta etc and if there is a NuLA, purple and brown etc

Code: Select all

VideoULA         = &FE20
VideoULAControl  = VideoULA + 0
VideoULAPalette  = VideoULA + 1
VideoNuLACtrl    = VideoULA + 2
VideoNuLAPal     = VideoULA + 3
  lda #&40 : sta VideoNuLACtrl ; RESET NuLA (logical palette mode)
  ldy #nula_colour_defs_end - nula_colour_defs - 1
  lda nula_colour_defs, y : sta VideoNuLAPal : dey : bpl set_nula_cols
; ULA  black  red    green  yellow magenta cyan  white  white_ cyan_  mage_  yell_  green_
; NuLA black  red    green  yellow magenta cyan  white  white  orange purple bk_blue brown
  EQUW &0000, &1E00, &21C0, &3EE0, &5E3D, &60CD, &7CCD, &8CCD, &9E30, &A80D, &C004, &DA54 ; &cRGB
NuLANoNuLA.png (10.22 KiB) Viewed 5786 times
If I remember correctly, I set the first of the flashing pair colours visible for the top and the second for the bottom.
The logs are Magenta/Green (mapped to brown) at the top so they are Brown with a NuLA and Magenta if not.
The safe middle and bottom are Magenta (mapped to purple) so they are purple with a NuLA and Magenta without.
The paint on the middle row of cars is Green/Magenta (mapped to pink) so that it is pink on a NuLA and Magenta otherwise.
I do it this way as there is no way to detect a NuLA, other than checking if its support ROM is installed and this way, I don't need to ask the user who may not know what a NuLA is anyway.

Going of topic a bit, but still NuLA related - honest!

The beeb was designed to have a "second processor" hanging off its "TUBE" port and this was used to develop the first ARM CPUs, so it is nice to see it come full circle and have a modern Raspberry Pi connected to the TUBE as a second processor. You might call this cheating, but it is what it was designed for from the beginning and BITD had 6502, Z80, 6809 (I think), 65C816 (16 bit), 68000, ARM, 80186 and maybe more that I don't remember. More recently, it has the Raspberry Pi, which can emulate a whole host of CPUs or use its own directly.
beeb + Pi + NuLA = DOOM!
Skip to 3min to avoid loading!
And if you don't have a NuLA, you can still have ugly DOOM!

Doom isn't finished and I don't think that RobC has added sound yet.

Post Reply

Return to “BBC Micro Assembly Programming”