6845 Shenanigans

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
julie_m
Posts: 141
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

6845 Shenanigans

Post by julie_m » Thu Mar 12, 2020 9:00 pm

Back in the day, I never fully appreciated just how a screen display is put together, so I never bothered experimenting with the BBC's video system. So this must be old hat to you, but please bear with me as I'm only just discovering the joys .....

If I run

Code: Select all

10MODE5
20VDU23,0,1,32,0;0;0;
then I end up with a screen whose frame buffer runs from &5800 to &77FF, and with each scanline exactly 256 bytes long -- an obvious benefit if you want to write to and read from the frame buffer directly. (The poor Beeb still thinks the screen has 20 columns, though, so text and graphics are a bit messed up ..... not a problem if you're playing fast and loose writing directly to screen memory! And arguably safer than relying on a 320-times table in somebody else's ROM, yet still quicker than evaluating the product each time and saving space versus keeping your own copy of the table. Ironically you've just freed up 2K bytes by obviating the original need for the table .....)

So the next obvious questions are, is there a way to centralise the 128-pixel screen or is it fixed, and if a method exists, does it work properly under emulation?

User avatar
tricky
Posts: 4223
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 6845 Shenanigans

Post by tricky » Thu Mar 12, 2020 9:32 pm

You need to reduce the horizontal sync position register.

User avatar
kieranhj
Posts: 861
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: 6845 Shenanigans

Post by kieranhj » Fri Mar 13, 2020 3:33 pm

Welcome to the wonderful world of CRTC register abuse! It is a lot of fun. :D jsBeeb is by far and away the most accurate emulator when it comes to display timing but you should find both b2 and b-em are very good and sufficient for your experiments, unless you’re getting down to needing to update registers on specific cycles. BeebEm is generally to be avoided for this kind of development.

I wrote quite a lot of waffle on CRTC register twiddling in my write up for Twisted Brain: viewtopic.php?f=53&t=15300. Less on horizontal register changes but as Tricky says, you just need to change the horizontal sync position to move the screen left & right. Best discovered through experiment to understand how it works.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
tricky
Posts: 4223
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 6845 Shenanigans

Post by tricky » Fri Mar 13, 2020 6:13 pm

Try to keep your total screen height to 39 lines with some non-displayed bits around v-sync and watch out for -1 registers.
Have fun.
Ditto for not beebem if timing is required as even the v-sync interrupt is off.

julie_m
Posts: 141
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: 6845 Shenanigans

Post by julie_m » Fri Mar 13, 2020 9:39 pm

kieranhj wrote:
Fri Mar 13, 2020 3:33 pm
Welcome to the wonderful world of CRTC register abuse! It is a lot of fun. :D
Aye :) It's also interesting how manufacturers in the UK and USA adopted different approaches. We went for ULAs and fully-bitmapped screens with every pixel individually-addressable, and the processor and video ULA taking it in turns to access the RAM, implicitly refreshing it (and putting up with the attendant problems like "out-of-order" addresses); they went for fancier hardware creating small bit-mapped sprites overlaid on a character-mapped screen, with mult-coloured backgrounds created by changing the background colour on each scanline. There must be a book waiting to be written there .....
kieranhj wrote:
Fri Mar 13, 2020 3:33 pm
jsBeeb is by far and away the most accurate emulator when it comes to display timing but you should find both b2 and b-em are very good and sufficient for your experiments, unless you’re getting down to needing to update registers on specific cycles. BeebEm is generally to be avoided for this kind of development.

I wrote quite a lot of waffle on CRTC register twiddling in my write up for Twisted Brain: viewtopic.php?f=53&t=15300. Less on horizontal register changes but as Tricky says, you just need to change the horizontal sync position to move the screen left & right.
I found the "Twisted Brain" thread, and it was interesting stuff.

What I was most interested in was getting the screen to be exactly 256 bytes across. Or maybe seeing if or not it was possible to create a 10-column, 4-colour mode ..... it doesn't matter so much if the MOS can't do anything sensible on screen, if I am going to be poking the framebuffer directly. I've been deliberately avoiding that with BCP (except using the framebuffer as workspace for visual debugging .....) so it will be fun to have a go at it again.

I was using BeebEm but it seems the behaviour is a bit off. With positive values in register 2, I get the screen offset to the left, but it doesn't offset to the right with negative values. Had a quick try on JSBeeb and that worked a little better, till I managed to send it unstable with a rogue value (which I am still regarding as a good sign, because something happened even although it wasn't what I wanted). Will also have to try downloading and building B-Em again (pretty sure that was actually the first BBC emulator I tried, a couple of HDDs ago .....) and maybe see if my old Model B is still in my parents' attic -- I don't mind soldering in some new capacitors with fresh smoke ;) and I also happen to know my floppy drive was direct-driven, so no gooey belt residue to worry about. Be a nice little project, that.
kieranhj wrote:
Fri Mar 13, 2020 3:33 pm
That's something I like the sound of!

User avatar
tricky
Posts: 4223
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 6845 Shenanigans

Post by tricky » Sat Mar 14, 2020 8:41 am

In b-em you have a setting for borders, when set to small, the just hug the displayed area, so for 6845, you need medium or large.
For games, they could have swapped a few address lines around and set the addresses in columns of 256 bytes (32 character rows) which would have made most things much easier, by modes 3 and 6 would have to have been software :( I don't think that you can do a MODE 8 style 4 colours, but you might find linear addressing (mixing gfx in the MODE 7 screen area) fun.
You might also find these interresting: 160 x 128 mode 80 column text and if you wanted gfx + text, just do part in teletext mode - interrupts required ;)

Post Reply

Return to “programming”