Changing paper/border colours in LAYER 1,2.

The Speccy's spritely young offspring. Discuss everything from FPGA to ZX
Post Reply
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Changing paper/border colours in LAYER 1,2.

Post by MonkZy »

I have been using the next screen mode LAYER 1,2. This mode emulates the Timex hi res mode found on the T/S 2068 and is 512x192 with two colours. I love this mode and think they should have included it on the 128k machines, it allows 64 columns of 8x8 text or 85 columns if a 6 pixel wide font is used.

On the Next this mode has two palette options. PALETTE FORMAT 0 replicates a standard ULA machine. In this format BRIGHT is ignored and all colours are displayed at the highest brightness. The PAPER colour is the INK colour with flipped bits, this means only certain INK/PAPER combinations are allowed Red/Cyan , Blue/Yellow, Black/White, Green/Magenta. Using black ink on white paper also means that the paper colour is very bright for text, and BRIGHT 0 does nothing. BORDER is ignored and will be given the same colour as the PAPER.

PALETTE FORMAT 1 turns on enhanced ULA. This allows each palette entry to be adjusted individually and given any of the 512 colours available. I could not find any useful information in the manual on how to set the colours for PAPER or BORDER in LAYER 1,2. After some experimentation I have found how to do this :

Code: Select all

10 LAYER PALETTE 1,0,0
20 LAYER PALETTE 1,135,0
30 LAYER PALETTE 1,188,BIN 101101101
40 LAYER 1,2
50 PALETTE FORMAT 1
60 LAYER PALETTE 1
70 BANK 5 ERASE 0,6912,0 
80 BANK 5 ERASE 8192,6912,0
This replicates BRIGHT 0: INK 0: PAPER 7: BORDER 0: CLS

Line 10-30 set up three colours in palette 1. Colour register 0 is used for INK and is set to 0 (BIN 000000000) - Black. After some experimentation I found the registers for BORDER and PAPER which can be set as different colours. Register 135 is the border colour, I have set it to black. Register 188 is the paper colour, I have set this to the same shade as BRIGHT 0: PAPER 7. The colours are set as a 9-bit GRB.

Line 40 sets the screen mode. Line 50 sets the palette format, or rather the number of palette registers used for INK colours. For layer 1,2 set this to 1. Using a different format changes the register used by PAPER, stick to 1 it will work fine as Hi Res only uses one ink colour. Line 60 sets palette 1 to be the used palette.

Line 70-80 perform a CLS. I have found that CLS sometimes creates a 'N Statement lost' error, maybe a bug in NextBASIC? I use the BANK x ERASE function to set both screen buffers to all 0's instead. In hires mode both buffers are used for odd and even character columns. The attribute areas are not used.

After this you have a 512x192 screen which works fine with all the usual PRINT commands!
User avatar
TMD2003
Rick Dangerous
Posts: 2043
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: Changing paper/border colours in LAYER 1,2.

Post by TMD2003 »

Further to this, I'm in a jam needing to change colours on LAYER 1,2 while using a custom palette. Knowing that PAPER = !(INK) is one thing I didn't know before.

What I need to do is have LAYER 1,2 with black ink on a transparent background - which should, as I understood it, have meant redefining the palette entry for the PAPER colour to the current transparency (I use 200, because it's easy to remember and has no blue component so it's the same in 8-bit or 9-bit palettes). So far I've got black text on the rusty-brown background that is entry 200, but (with LAYER OVER 2 to put layer 1 on top of layer 2, which shows all the background detail) even with the transparency set correctly, it isn't transparent.

But I haven't put in PALETTE FORMAT 1, so that might be my problem. I will test it.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
MonkZy
Manic Miner
Posts: 279
Joined: Thu Feb 08, 2018 1:01 pm

Re: Changing paper/border colours in LAYER 1,2.

Post by MonkZy »

Changing the palette format certainly has an effect on things when using layer 1,2. The only thing I observed was the palette register for the paper changes depending on the format value, the border register is always 135 or at least it is on formats 1,3 and 7. Because layer 1,2 only ever displays one ink colour I don't think it makes much difference which format is used other than 0.
User avatar
TMD2003
Rick Dangerous
Posts: 2043
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: Changing paper/border colours in LAYER 1,2.

Post by TMD2003 »

Well, that's interesting. PALETTE 0,135,200 is what sets the paper and border to rusty-orange (which I intend to be transparent). That's the only palette entry I've found to be effective so far. So is that me actually changing the border colour?

In the main program I intend to use this with (and maybe more beyond), I have defined PALETTE FORMAT 15, because I've defined a custom palette as Spectrum colours (0-7 for BRIGHT 0 and 8-15 for BRIGHT 1), and EGA (15-31, with the colours rearranged to the blue-red-green Spectrum order, rather than blue-green-red of the actual EGA palette). Technically it's the CGA palette, but only at low resolution - Spectrum resolution with 16 colours available would be EGA, so that's how I'll refer to it.

Colours that are this customisable are fun. With judicious use of sprites to make a 40-column display, I could make a Next look like a Commodore 64 without installing a new not-at-all-legitimate core. The possibilities for trolling are endless!
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Changing paper/border colours in LAYER 1,2.

Post by Seven.FFF »

The Next palette system has a pair of 256 entry palettes for every layer. Each entry in a palette can be defined as a RGB333 9bit colour or RGB332 8bit colour (which are actually expanded out to 9bit colours internally after you set them, with the 9th bit coming from oRing two other blue bits together - just like ULAplus does for 8bit).

LAYER 1,2, being built on top of Timex hires mode, is part of the ULA layer, so it uses either the primary or secondary ULA palette. The classic Spectrum INK/PAPER/BORDER BRIGHT/non-BRIGHT colours are all mapped into specific entries in this palette. And borders on Speccies are always non-bright, so on the Next the border colours come from the same place the non-bright ink colours do.

Timex hires is a little different. On the original hardware you could only specify one of eight contrasting pairs of bright colours in the hires configuration, with the border always being the same colour as the paper colour. So on the Next you can redefine the palette entries for that particular bright paper and bright ik colour.

So yes, it's definitely possible to redefine every single colour in classic Speccy, timex hicolour and timex hires layers. You just have to keep it clear in your head that the original hardware was using fixed colours, but on the Next every fixed colour becomes a palette index that points to a redefinable colour.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
TMD2003
Rick Dangerous
Posts: 2043
Joined: Fri Apr 10, 2020 9:23 am
Location: Airstrip One
Contact:

Re: Changing paper/border colours in LAYER 1,2.

Post by TMD2003 »

Right - I've got something that works, provided by Matt Langley on the Faceache page. I have found no way of changing LAYER 1,2 palette entries with the LAYER PALETTE n,p,b command or BANK b POKE x,y then LAYER PALETTE * BANK b.

But there is a way to do it with three REG commands. So:

tr=200
LAYER 2,1
(put whatever you like here - PRINT, PLOT, LOAD "bob.sl2" LAYER, etc)
LAYER 1,2
LAYER PALETTE 0
LAYER OVER 2: ; changes the order to sprites on top, then LAYER 0/1, then LAYER 2 on the bottom
PALETTE OVER tr
REG 67,128: ; select palette 0 to change; REG 67,64 if using palette 1
REG 64,31: ; change "ULAplus" palette entry 31, i.e. BRIGHT 1: PAPER 7, the default for LAYER 1,2
REG 65,tr: ; change this palette entry to the pre-defined transparency setting
PRINT "This can fit more text than a Commodore 64 can handle"

And there we are.
Spectribution: Dr. Jim's Sinclair computing pages.
Features my own programs, modified type-ins, RZXs, character sets & UDGs, and QL type-ins... so far!
Post Reply