Using the ULAplus 64 colour mode from Sinclair BASIC
Using the ULAplus 64 colour mode from Sinclair BASIC
Can anybody help me get my head around accessing ULAplus from BASIC? I've read the guide, but I'm struggling to understand it.
Say for example I just want to fill the screen with single characters changing to a random paper and ink from the 64 as I go.
Thanks
Say for example I just want to fill the screen with single characters changing to a random paper and ink from the 64 as I go.
Thanks
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
Is it not just a matter of enabling 64 colour mode, setting up the palette entries you want and then PRINTing characters in a variety of INK/PAPER/FLASH/BRIGHT combinations?
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
It is. The example linked to has the explanation and sample code to actually do it.
Maybe it would be better for Peter to ask specific questions about the parts of the explanation you don’t understand, and say what it is you doesn’t understand.
Maybe it would be better for Peter to ask specific questions about the parts of the explanation you don’t understand, and say what it is you doesn’t understand.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
OK,
So I'm enabling ULAplus, electing to change palette number 0 which is flash off, bright off, ink 0. Then writing the RGB, printing in ink 0, changing the RGB, then printing in Ink 0 again.
I would expect the ink colour to change.
So I'm enabling ULAplus, electing to change palette number 0 which is flash off, bright off, ink 0. Then writing the RGB, printing in ink 0, changing the RGB, then printing in Ink 0 again.
I would expect the ink colour to change.
Code: Select all
;enable ULAplus
20 OUT 48955,64
30 OUT 65339,1
;choose palette entry 0 (ink 0)
50 OUT 48955,0
;set RGB colours
70 LET r=3
80 LET g=6
90 LET b=1
;set the colours
110 OUT 65339,((g*32)+(r*4)+b)
;print in ink 0
120 PRINT FLASH 0; BRIGHT 0; INK 0;"Hello ";
;change red intensity
130 LET r=r-1
;set new colour
135 OUT 65339,((g*32)+(r*4)+b)
;print again
140 PRINT FLASH 0; BRIGHT 0; INK 0;"World ";
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
I would expect Hello and World to be printed in the same colour. Which would be set by line 135.PeterJ wrote: ↑Thu Oct 26, 2023 2:14 pm OK,
So I'm enabling ULAplus, electing to change palette number 0 which is flash off, bright off, ink 0. Then writing the RGB, printing in ink 0, changing the RGB, then printing in Ink 0 again.
I would expect the ink colour to change.
Code: Select all
20 OUT 48955,64 30 OUT 65339,1 50 OUT 48955,0 70 LET r=3 80 LET g=6 90 LET b=1 110 OUT 65339,((g*32)+(r*4)+b) 120 PRINT FLASH 0; BRIGHT 0; INK 0;"Hello "; 130 LET r=r-1 135 OUT 65339,((g*32)+(r*4)+b) 140 PRINT FLASH 0; BRIGHT 0; INK 0;"World ";
Every time you change a palette entry, you are redefining what colour that particular combination of INK/PAPER/BRIGHT/FLASH means for the entire screen. Things that were already printed in the particular combination will change to reflect the palette colour change automatically.
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
OK @AndyC,
so if I do an OUT 48955,1 before line 135 and change link 140 to INK 1 would that do it?
so if I do an OUT 48955,1 before line 135 and change link 140 to INK 1 would that do it?
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
Yeah, I think so. Things that need to be a different colour need to be printed with different attributes still.
Your initial code was setting colour 0, printing in it, then immediately changing what colour 0 was. And was quick enough the you can't see the colours change. Putting a long PAUSE before line 135 would probably also make this obvious.
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
And the other obvious thing that bears spelling out is that attribute cells can still only contain one ink and one paper colour like a standard Speccy. And since both ink and paper in a cell shared the same flash and bright settings in a standard Speccy, in ULAplus that translates to both redefined colours used in a cell needing to come from the same "quadrant" of the 64 colour redefined palette - what I labelled here as A, B, C and D.
ULaplus can be used in conjunction with Timex hicolour mode which has 8x1 attribute cells, too. The SpecEmu TC2048 machine demonstrates that nicely.
ULaplus can be used in conjunction with Timex hicolour mode which has 8x1 attribute cells, too. The SpecEmu TC2048 machine demonstrates that nicely.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
I've made the change, but it still doesn't seem to be working as expected.
Code: Select all
;enable ULAplus
20 OUT 48955,64
30 OUT 65339,1
;choose palette entry 0 (ink 0)
50 OUT 48955,0
;set RGB colours
70 LET r=3
80 LET g=6
90 LET b=1
;set the colours
110 OUT 65339,((g*32)+(r*4)+b)
;print in ink 0
120 PRINT FLASH 0; BRIGHT 0; INK 0;"Hello ";
;change red intensity
130 LET r=r-1
;set new colour
131 OUT 48955,1
135 OUT 65339,((g*32)+(r*4)+b)
;print again
140 PRINT FLASH 0; BRIGHT 0; INK 1;"World ";
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
Without redefining palettes it looks like this on a standard speccy. You printed in INK 0 and 1, paper 7, non-flashing and non-bright:
After running on a ULAplus capable machine it looks like this. INK 0 and 1 are both redefined to green, paper remains as it was:
Note that Spin has a somewhat screwed up default ULAplus palette entry for dim white - it looks mauve. But on in it's default ULAplus palette, not its standard palette. That's just a Spin thing though.
After running on a ULAplus capable machine it looks like this. INK 0 and 1 are both redefined to green, paper remains as it was:
Note that Spin has a somewhat screwed up default ULAplus palette entry for dim white - it looks mauve. But on in it's default ULAplus palette, not its standard palette. That's just a Spin thing though.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
You're setting two colours that are nearly identical, set them to values a bit further apart and the change will be more obviousPeterJ wrote: ↑Thu Oct 26, 2023 3:28 pm I've made the change, but it still doesn't seem to be working as expected.
Code: Select all
;enable ULAplus 20 OUT 48955,64 30 OUT 65339,1 ;choose palette entry 0 (ink 0) 50 OUT 48955,0 ;set RGB colours 70 LET r=3 80 LET g=6 90 LET b=1 ;set the colours 110 OUT 65339,((g*32)+(r*4)+b) ;print in ink 0 120 PRINT FLASH 0; BRIGHT 0; INK 0;"Hello "; ;change red intensity 130 LET r=r-1 ;set new colour 131 OUT 48955,1 135 OUT 65339,((g*32)+(r*4)+b) ;print again 140 PRINT FLASH 0; BRIGHT 0; INK 1;"World ";
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
BTW if you're not already using it, Remy's tool to tokenize basic and then export as a .tap is a helpful online way to try out these kind of code snippets in your favourite emulator without installing software or retyping.
https://zx.remysharp.com/bas/
https://zx.remysharp.com/bas/
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
Thanks @Guesser,
I think you solved it!
Changed line 130 to let r=r+3: let g=g-3
I think you solved it!
Changed line 130 to let r=r+3: let g=g-3
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
You didn't say that the two greens were the part you thought was wrong. You just said it was not as expected. If you are specific with your questions then they almost answer themselves, or at least give people the chance to give you a fix wihout having to dig in and try to get inside your head.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
Good point @Seven.FFF. I should have been clearer. I would certainly recommend not trying to get inside my head.
Thanks again for your help.
Thanks again for your help.
Re: Using the ULAplus 64 colour mode from Sinclair BASIC
It was not meant as criticism. It was fun to help!
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins
SevenFFF / Threetwosevensixseven / colonel32
NXtel • NXTP • ESP Update • ESP Reset • CSpect Plugins