Working with Colours

Minicube64 has a default set of 64 colours, and defining your own custom palette is easy.

Custom colour palettes can be defined in a familiar hex notation like this:

  hex 000000
  hex ff0000 ;red
  hex 00ff00
  hex 0000ff

It is recommended to define palette data before any other content such as graphics, but after the main program code.

It is also possible to define multiple palettes and switch to them at any time if needed.

Palettes can also be defined in byte notation if preferred.

  byte $00,$00,$00
  byte $ff,$00,$00
  byte $00,$ff,$00
  byte $00,$00,$ff

Before the palette data we should align the data to a location in memory with the align or org directive. This forces the following data to begin at that specific address in memory, making it easy to point the COLORS register to.

    align $500 ; or org $500

Setting the Colour Palette

Setting the COLORS register instructs to set the colour palette from a 256 byte region in memory.

The immediate value we load refers to the high-byte of the desired memory address. This can be any value from $0300. For example memory address 0x0500, we use #$5

  lda #$5
  sta COLORS

Changing palette values will only take effect at the end of the frame.


In this example we set a basic palette of 4 colours and show them at the top of the screen.

include ""
  org $200

  lda #$f
  sta VIDEO

  lda #$3
  sta COLORS

; draw once to screen
; optional styling to
; fill the top few lines
  and #$5f

  sta $f000,x
  bne Draw

  jmp Loop

; set palette values
  org $500
  hex 000000 ff0000 00ff00 0000ff

Last updated