If you're after a way of using arbitrary modes, it might be worth improving Brandy's support for the extensions to the MODE statement that were introduced in RISC OS 3.5:
If the unsigned value of N is less than 256, it's treated as a mode number. Otherwise, it's treated as a pointer to a
mode selector block - mode selector blocks are the main way of specifying screen modes in 3.5+.
Allows mode selection using a
mode string. Internally this just gets converted to an equivalent mode selector block, but it provides a more human-friendly way of selecting modes. (Note also that mode strings don't allow you to specify the full range of attributes that selector blocks do)
Causes BASIC to construct a mode selector block and use that. BPP must be 1, 2, 4, 8, 16 (selecting a 32K colour mode), or 32 (selecting a 16M colour mode). On RISC OS the true-colour modes will always be VIDC20-style, with the red channel in the low bits of the pixel. But if Brandy doesn't allow direct screen access then you can obviously ignore those concerns and just focus one the # colours.
Code: Select all
MODE <x>,<y>,<flags>,<ncol>,<l2bpp>[,<hz>]
RISC OS 5 introduced this extension to the "x,y,bpp" form, since the earlier version was a bit limited in terms of its features (e.g. no sensible way of supporting red/blue swapped modes, 4K/64K colour modes, or alpha channel modes). Flags, ncol, l2bpp directly correspond to the Mode Flags, NColour, and Log2BPP mode variables (allowing easy conversion to a mode selector block).
If a mode selector block or mode string has been used, then reading the value of MODE will return a pointer to a (kernel-managed) copy of the mode selector block (which will only be valid until the next mode change).