
Steve
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
And in mode 7, with "some nasty effects", or just palette swapping, I think that is 800 * 4 bits!RobC wrote:Yes - good point. With overscan, it's possible to have a display that's close to 800 pixels wide in mode 0.tricky wrote:What is fixed at 640 bits?
Had a bit of a rummage, and this it it, modifiled with a bit of code that I think sets colours with palettemate:jgharston wrote:I wrote most of a VDU extension to implement VDU 19,l,x,red,green,blue to program the palette. I'll probably find the code when looking for something else.
Code: Select all
10 REM VDU19/src
20 REM Extended VDU 19 driver
30 :
40 load%=&FFFF0A00:DIM mcode% &200
50 wrchv=&20E:vduQ=&26A
60 :
70 FOR P=0 TO 1
80 P%=load%:O%=mcode%
90 [OPT P*3+4
100 .go%
110 LDA wrchv+0:STA oldwrch+1
120 LDA wrchv+1:STA oldwrch+2
130 LDA #newvdu AND 255:STA wrchv+0
140 LDA #newvdu DIV 256:STA wrchv+1
150 LDA #0:STA flag:RTS
160 :
170 .newvdu
180 BIT vduQ:BMI check:STA flag
190 .oldwrch
200 JMP &FFFF
210 .oldvdu
220 PLA:JMP oldwrch
230 .check
240 PHA
250 LDA vduQ:CMP #255:BNE oldvdu
260 LDA flag:CMP #19:BNE oldvdu
270 PLA:PHA:STA &323:\ last entry of VDU queue
280 \ VDU queue
300 \ &31F l
310 \ &320 p
320 \ &321 r
330 \ &322 g
340 \ &323 b
350 LDA &31F:CMP #255:BEQ border1 :\ VDU 19,-1,p,r,g,b
360 LDA &320:CMP #24:BEQ border2 :\ VDU 19,l,24,r,g,b
370 JSR RGBtest:BEQ oldvdu :\ VDU 19,l,p,0,0,0
380 :
390 \ VDU 19,l,ignored,red,green,blue
400 \ VDUPlus
410 LDA &321:LSR A:LSR A:LSR A:LSR A:STA &FE23 :\ red
420 LDA &322:LSR A:LSR A:LSR A:LSR A:STA flag :\ green
430 LDA &323:AND #&F0:ORA flag:STA &FE23 :\ blue+green
440 .done
450 INC vduQ:PLA:RTS :\ Clear vduQ and return
460
470 \ Chameleon
480 LDA &321:LSR A:LSR A:LSR A:LSR A:STA &FE60 :\ red
490 LDA &321:LSR A:LSR A:LSR A:LSR A:ORA #&40:STA &FE60 :\ green
500 LDA &321:LSR A:LSR A:LSR A:LSR A:ORA #&80:STA &FE60 :\ blue
510
520 :
530 \ VDU 19,-1,p,red,green,blue
540 .border1
550 JSR RGBtest:BNE border2 :\ VDU 19,-1,ignored,red,green,blue
560 LDA &320:AND #&0F:STA &FE22 :\ VDU 19,-1,physical,ign,ign,ign
570 JMP done
580 .border2
590 JSR RGBtoP:STA &FE22:JMP done:\ VDU 19,ign,24,red,green,blue
600 :
610 .RGBtoP
620 LDA &323:ASL A:LDA #0:ROL A:PHA
630 LDA &322:ASL A:PLA:ROL A:PHA
640 LDA &321:ASL A:PLA:ROL A:RTS
650 .RGBtest
660 LDA &321:ORA &322:ORA &323:RTS
670 .flag:BRK
680 ]NEXT
690 IF P%>&B00:PRINT"WARN: Code overrun":END
700 PRINT "*SAVE VDU19 ";~mcode%;" ";~O%;" ";~go%OR&FFFF0000;" ";~load%
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Yes - the idea is that by modifying the physical colours, any original software isn't aware that this is going on. You just define the palette and away you go. I'll try to post some pictures of games using modified palettes over the weekend.tricky wrote:Not sure about mousetrap, but having choice is definitely great. I would suspect that the way you have set it up, nearly every game would be compatible.
Roughly what do you think this will cost?
Many thanks - I'll have a play with this tomorrow.jgharston wrote: Had a bit of a rummage, and this it it, modifiled with a bit of code that I think sets colours with palettemate:Code: Select all
snipped...
I noticed I missed off the logical colour number. It probably should be:RobC wrote:Many thanks - I'll have a play with this tomorrow.jgharston wrote: Had a bit of a rummage, and this it it, modifiled with a bit of code that I think sets colours with palettemate:Code: Select all
snipped...
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Yes - I can test for xxxx being non-zero and proceed accordingly.jgharston wrote:Also, if you implement 12-bit border colour will it know the differce between selecting an 3-bit physical colour and the start of a 12-bit colour? Eg ?&FE22=%00000bgr for 3-bit colour, ?&FE22=%xxxxrrrr:?&FE22=%bbbbgggg for RGB colour with xxxx not zero.
Makes perfect sense. The CPLD has a simple state machine so that it knows which type of write is to be expected next. The state machine currently gets reset at power-up. Not sure about resetting on writes to FE20/1 as that could clash with the MOS flipping flashing colours etc.jgharston wrote:And a thought occurs on how to ensure that the double writes to &FE22/23 don't get out of sequence and so when a program makes a first write the ula is expecting the first byte. My thought is that a writre to &FE20/1 (the normal ULA registers) should reset the state to 'expecting first of double write'
Dos that make sense? I've only had one cup of tea today.
That happens on interupts with a write to &FE20, so could just document that the program writer needs to do SEI/CLI around code that writes to FE22/23.RobC wrote:Make perfect sense. The CPLD has a simple state machine so that it knows which type of write is to be expected next. The state machine currently gets reset at power-up. Not sure about resetting on writes to FE20/1 as that could clash with the MOS flipping flashing colours etc.
But then how do you tell the difference between setting the 12-bit palette for logical colour 0 and setting the 12-bit palette for the border by using logical colour 0 to select the border? I think FE22=border palette, FE23=pixel palette makes more sense.RobC wrote:Another option would be to use FE22 for the first write and FE23 for the second. The border could be set via colour 0 as I think that some monitors have issues if you redefine it to be anything other than true black.
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Thinking about it, I'd like to be clearer about how the issue might occur before I think about modifying the existing behaviour. How do you think this problem might arise?jgharston wrote:That happens on interupts with a write to &FE20, so could just document that the program writer needs to do SEI/CLI around code that writes to FE22/23.
The 12-bit palette is for physical colours rather than logical colours and I'm led to believe that changing physical colour 0 can cause problems on some monitors. So, by specifying that writing 0000xxxx modifies the border rather than physical colour 0, we could save a register address.jgharston wrote:But then how do you tell the difference between setting the 12-bit palette for logical colour 0 and setting the 12-bit palette for the border by using logical colour 0 to select the border? I think FE22=border palette, FE23=pixel palette makes more sense.
I've never had any problem on any monitor doing VDU 19,0,any_nonzero_value,0,0,0 to change the background colour to non-black. Tho' I think we've got crossed wires mixing up the terms "physical colour" and "logical colour".RobC wrote:The 12-bit palette is for physical colours rather than logical colours and I'm led to believe that changing physical colour 0 can cause problems on some monitors.jgharston wrote:But then how do you tell the difference between setting the 12-bit palette for logical colour 0 and setting the 12-bit palette for the border by using logical colour 0 to select the border? I think FE22=border palette, FE23=pixel palette makes more sense.
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Code: Select all
10 REM VDU19/src
20 REM Extended VDU 19 driver
30 :
40 load%=&FFFF0A00:DIM mcode% &200
50 wrchv=&20E:vduQ=&26A
60 :
70 FOR P=0 TO 1
80 P%=load%:O%=mcode%
90 [OPT P*3+4
100 .go%
110 LDA wrchv+0:STA oldwrch+1
120 LDA wrchv+1:STA oldwrch+2
130 LDA #newvdu AND 255:STA wrchv+0
140 LDA #newvdu DIV 256:STA wrchv+1
150 LDA #0:STA flag:RTS
160 :
170 .newvdu
180 BIT vduQ:BMI check:STA flag
190 .oldwrch
200 JMP &FFFF
210 .oldvdu
220 PLA:JMP oldwrch
230 .check
240 PHA
250 LDA vduQ:CMP #255:BNE oldvdu
260 LDA flag:CMP #19:BNE oldvdu
270 PLA:PHA:STA &323:\ last entry of VDU queue
280 \ VDU queue
290 \ &31F logical colour
300 \ &320 physical 4-bit colour (extension options if >15)
310 \ &321 red component of physical colour
320 \ &322 green component of physical colour
330 \ &323 blue component of physical colour
340 LDA &31F:CMP #255:BEQ border :\ VDU 19,-1,p,r,g,b
350 LDA &320:CMP #24:BEQ borderRGB :\ VDU 19,l,24,r,g,b
360 JSR RGBtest:BEQ oldvdu :\ VDU 19,l,p,0,0,0
370 :
380 \ VDU 19,l,ignored,red,green,blue
390 \ Select Palettemate 12-bit physical colour
400 LDA &31F:ASL A:ASL A:ASL A:ASL A:STA flag :\ logical colour
410 LDA &321:LSR A:LSR A:LSR A:LSR A :\ physical colour red component
420 ORA flag:STA &FE23 :\ write %llllrrrr
430 LDA &322:LSR A:LSR A:LSR A:LSR A:STA flag :\ physical colour green component
440 LDA &323:AND #&F0 :\ physical colour blue component
450 ORA flag:STA &FE23 :\ write %bbbbgggg
460 .done
470 INC vduQ:PLA:RTS :\ Clear vduQ and return
480 :
490 \ Select Chameleon 12-bit physical colour
500 \LDA &321:\LSR A:\LSR A:\LSR A:\LSR A:\STA &FE60 :\ red component
510 \LDA &322:\LSR A:\LSR A:\LSR A:\LSR A:\ORA #&40:\STA &FE60 :\ green component
520 \LDA &323:\LSR A:\LSR A:\LSR A:\LSR A:\ORA #&80:\STA &FE60 :\ blue component
530 :
540 \ VDU 19,-1,p,red,green,blue
550 .border
560 JSR RGBtest:BEQ border3bit :\ VDU 19,-1,p,0,0,0
570 :
580 \ VDU 19,-1,ignored,red,green,blue
590 \ VDU 19,ignored,24,red,green,blue
600 .borderRGB
610 LDA #&80:STA flag :\ top nybble<>0 to indicate 12-bit colour
620 LDA &321:LSR A:LSR A:LSR A:LSR A :\ physical colour red component
630 ORA flag:STA &FE22 :\ write %xxxxrrrr
640 LDA &322:LSR A:LSR A:LSR A:LSR A:STA flag :\ physical colour green component
650 LDA &323:AND #&F0 :\ physical colour blue component
660 ORA flag:STA &FE22 :\ write %bbbbgggg
670 JMP done
680 :
690 \ VDU 19,-1,physical,ignored,ignored,ignored
700 .border3bit
710 LDA &320:AND #&0F:STA &FE22 :\ write %0000xbgr, top nybble=0 to indicate 3-bit colour
720 JMP done
730 :
740 .RGBtest
750 LDA &321:ORA &322:ORA &323:RTS :\ EQ=all RGB values are zero
760 .flag:BRK
770 ]NEXT
780 IF P%>&B00:PRINT"WARN: Code overrun":END
790 PRINT "*SAVE VDU19 ";~mcode%;" ";~O%;" ";~go%OR&FFFF0000;" ";~load%
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Code: Select all
380 \ VDU 19,l,ignored,red,green,blue
390 \ Select Palettemate 12-bit physical colour
392 PHP:SEI :\ Disable IRQs
395 .palette
400 LDA &31F:ASL A:ASL A:ASL A:ASL A:STA flag :\ logical colour
410 LDA &321:LSR A:LSR A:LSR A:LSR A :\ physical colour red component
420 ORA flag:STA &FE23 :\ write %llllrrrr
430 LDA &322:LSR A:LSR A:LSR A:LSR A:STA flag :\ physical colour green component
440 LDA &323:AND #&F0 :\ physical colour blue component
450 ORA flag:STA &FE23 :\ write %bbbbgggg
452 LDA &31F:SEC:ADC &360:STA &31F :\ Add number of colours to step to next palette index
454 CMP #16:BCC palette :\ Loop to do all
456 PLP :\ Restore IRQs
460 .done
470 INC vduQ:PLA:RTS :\ Clear vduQ and return
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
1024MAK wrote:@ Rob, I like the idea of upgrading the Beeb's video circuitry to improve the colour selection. But all the colour palette talk is a bit confusing at a quick glance. I will have to re-read this thread when my brain is a bit less tired...
So keep working at it. Something that hopefully can be made available to *. members in due course. Then we will let Tricky, Rich and the other games programmers* loose on it, hopefully with very colourful results![]()
Thanks for the encouragement and I wouldn't worry about all the details yet. I'm still evolving the VHDL code and so things are still likely to change!trixster wrote:Amazing work and what a brilliant idea. Id definitely like to get one if they become available.
YES! Even 8 half brite RGB levels would have been all kinds of awesome!Rich Talbot-Watkins wrote:Amazing stuff Rob! 16 proper colours in Mode 2 was always the biggest thing on my wishlist!
Mine too.Rich Talbot-Watkins wrote:Amazing stuff Rob! 16 proper colours in Mode 2 was always the biggest thing on my wishlist!
I tend to agree with 4096 colours being overkill but, given that the larger palette fits in the CPLD, it doesn't really make the hardware much more complicated (4-bit DACs vs 2-bit DACs). Plus, it's still only 2 writes to set a colour - anything larger would need an extra write so I ruled that out.Rich Talbot-Watkins wrote:Personally I think even 4096 colours is overkill though, given the crummy resolution you get to display them on. I'd be happy even with a 64 colour palette, that's more than enough to make some colourful screens (might also make the hardware simpler; two writes to change the palette - one to set the palette index, another to set the colour).
If there are enough resources, more than one palette plus an extra control register (and maybe a counter, depending on how much "memory" is available for palettes) could mean one palette per line up to the total number of palettes...tricky wrote:What would the chance of multiple palettes be?
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_
Mike Cook's Chamelon had two palettes each holding eight 12-bit colours (so only 8 colours + flashing on screen in mode 2). I once used this to display many colours (can't quite remember exactly how many) on screen using an interrupt routine to modify the alternate palettes over several scan lines.tricky wrote:What would the chance of multiple palettes be?
For things like the enhanced mode 1 pictures, one of the limiting factors on the beeb is the time it takes to change palette entries. There is only time to change 2 colours during the off screen period. With yours you could change all four colours, but if you could swap palette with one write, then you could change palette mid line and be updating another palette ready to swap again.
From memory, I think each scanline takes 64uS which is 128 cycles. With two loads and stores, I think it currently takes a minimum of 12 cycles to set a colour. So, it's not possible to modify more than 10 colours per scanline as things stand. Please do correct me if I've got this wrong as I've not tried it and am a bit hazy on the details.1024MAK wrote:If there are enough resources, more than one palette plus an extra control register (and maybe a counter, depending on how much "memory" is available for palettes) could mean one palette per line up to the total number of palettes...
So if there are say four available palettes, the programmer could program (in the new register) which palette is wanted before each line starts to be generated.
Further, if a counter was included (and I don't know how useful this would be), it could automatically count through the available palettes at intervals defined by the new register, so every line, every second line, every 4th, 8th line etc...
Anyway, how practical this is, I'm not sure, but it's an idea to think about. As it would make multicoloured displays using more of the available 4096 colours easier to generate![]()
I haven't implemented any border control features yet so it's slightly misleading to say that this is what it doesjgharston wrote:&FE22 selects the border colour, with the high nybble=%0000 selecting a 3-bit physical colour and the high nybble non-zero selecting a 12-bit physical colour
Code: Select all
$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_