how do i get 128 colours on screen in sam basic?
how do i get 128 colours on screen in sam basic?
it it possible in basic? the manual says it is but its not very clear. ive tried using palette to do this but it just seems to reset the colours per line. am i missing something here?
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
Re: how do i get 128 colours on screen in sam basic?
The palette consists of 16 colours.
You can change (part of) the palette using line interrupts.
If you change the loop to 127 you will get error 25 Too many palette changes.
You can change (part of) the palette using line interrupts.
Code: Select all
10 for f=0 to 126
20 palette 0,f line f
30 next f
Re: how do i get 128 colours on screen in sam basic?
ok, thank you. is it possible to have a different set of 16 colours every line then? so you could display 128 colours in just 8 lines? i.e draw each pixel one of 16 colours across the screen and then have a different set of colours on the next line?Stefan wrote: ↑Tue May 30, 2023 2:34 pm The palette consists of 16 colours.
You can change (part of) the palette using line interrupts.
If you change the loop to 127 you will get error 25 Too many palette changes.Code: Select all
10 for f=0 to 126 20 palette 0,f line f 30 next f
also, what do you mean 'part' of the palette?
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
Re: how do i get 128 colours on screen in sam basic?
You can change multiple palette entries on a line, IIRC. Note however that doing so takes time and while a single palette entry can be changed purely in the border time, subsequent palette changes might happen part way through a line leaving a visible result. Trying to change every palette entry on every line, for example, is probably not going to give the results you'd want (unless the screen has been very carefully crafted around the change timings).
Re: how do i get 128 colours on screen in sam basic?
No. The SAM's Z80 runs at 6MHz. So that's 6 million ticks a second. A screen is updated approx 50 times a second, so that leaves 120 thousand ticks per frame. A frame has approximately 312 lines, so that's approx 384 ticks per line.
To change a complete palette you can:
Code: Select all
ld hl,palette.table + 15 ; 10 t-states
ld bc,256*16 + port.clut ; 10 t-states - port.clut = 248
otdr ; 331 t-states (15 * 21 + 16)
; total 351 t-states
Code: Select all
ld hl,palette.table + 15 ; 10 t-states
ld bc,256*16 + port.clut ; 10 t-states - port.clut = 248
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
outd ; 16 t-states
; total 276 t-states
You also need to change the palette before it is used, to prevent palette shearing.
Re: how do i get 128 colours on screen in sam basic?
thank you both.AndyC wrote: ↑Tue May 30, 2023 5:08 pm You can change multiple palette entries on a line, IIRC. Note however that doing so takes time and while a single palette entry can be changed purely in the border time, subsequent palette changes might happen part way through a line leaving a visible result. Trying to change every palette entry on every line, for example, is probably not going to give the results you'd want (unless the screen has been very carefully crafted around the change timings).
is this not 128 colors on screen all at once across the lines, in basic?
no sure why it has a kind of slanted pixel effect... plus you get the odd flickery pixel, which is weird... and some of the pixels are double or 4x across
here is the code...
line 190 is missing, it should say- 190 next t
run it then type goto 70
here is a disk image of it:
https://filebin.net/rxzn3ypkqmkl5hu0
maybe someone could modify the code so it works better?
i started programming the spectrum when i was 8 :-
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
1 plot rnd*255,rnd*175
2 goto 1
http://zxspeccy.great-site.net/
Re: how do i get 128 colours on screen in sam basic?
See what we both already wrote.
You can get it to work better using assembler, but as I already wrote, that will only get you so far.