I finally got around to successfully updating Orwell’s video to Grant Searle’s video board. So Orwell now supports 80 characters as well as 40 character, bold and double size outputs. It also now has simple pixel plotting graphics!
Once my 74HCT166s did finally arrive I was able to just plop one into the breadboard I had all set up, turn it on and it immediately worked! I tried each of the little sample programs on the Arduino and they all worked. Since I knew then the video output was working I set about making the changes needed to Orwell to drive the video board. I also built up the video circuit on a small piece of strip board. I was able to test that using the Arduino of course.
The video board needs 6 lines to control it, 4 data lines and 2 control lines. I had four unused lines on port B of the VIA. I am using 3 outputs on Port B for the keyboard scanning already and using pin 7 as a sound output pin as that can be independently driven off the VIA timer. It provides a very simple way of making sounds.
So I did have port B pins 6..3 free for use already. As well as CB1 and CB2 as the control lines. The hardware changes were just some simple wiring changes on Orwell. I removed the wires that went from the serial port to the header the Batsocks connected to and rewired that header to connect to port B on the VIA. I also added in a separate power header.
It was a bit fiddly but I managed to get there although I did have to order a new soldering iron tip and wait for that to arrive before I could start!
Delicate but doable work. I made all the loops of wire long enough to be easily moved aside when needed (luckily I only run at 1Mhz with all that wire all over the place).
I then had to write some software to control the board. This meant a new video output routine. Controlling the board is pretty simple as explained on Grant’s site. I am using CB2 as the AVAIL line and CB1 as the ACK line. AVAIL is controlled by Orwell, being set high or low directly in code. ACK is controlled by the video processor and I have it configured as an interrupt on CB1.
To send data to the video board I first get the top four bits of the byte to send then shift them right 1 bit (since bit 7 goes out on port B pin 6 and so on down). I then set up CB1 to interrupt on a positive transition and set CB2 high. That tells the video processor data is available. I then go into a busy loop waiting for CB1 to change.
Once it has processed it it sets the ACK signal which is the positive change on CB1 we are waiting for. The interrupt handler sets a flag which is what the busy loop is waiting for to break out.
I then get the next four bits and shift them 3 places to the left (again to line the data up on pins 6..3 on port B) and this time set up CB1 to interrupt on a negative change and then set CB2 low. Again we loop waiting and when the video board makes ACK low again we break from the loop and finish.
Fiddling with the bits here on PORT B doesn’t upset the keyboard routines since we are only doing it when sending characters. And similarly when we change Port B to scan the keyboard we’re not telling the video board any data is available so it ignores it.
The only issue I had was when I tried it out I was getting video output fine but I was getting odd carriage returns. My code still echos everything to the serial port (save mode) since before the video was driven by serial and that was also showing the odd carriage returns. It was enough to see the video processor was working though. If I commented out the code to the video processor and just left the serial code it all worked fine.
It took me ages to work it out (as some posts to 6502.0rg which helped enormously). One of the problems with only working on this now and again is I forget things (one of the reasons I gave up being a coder, my memory for code is terrible – “Ademo, what’s that?”).
The issue was my video routine was using the accumulator and so it was changing A as it did it’s thing. The serial outputting code, by chance, wasn’t modifying A.
My video routines are called from the MS Basic routine MONCOUT which is in turn called from OUTDO. That routine assumes that A is the same once you return from MONCOUT.
So, with that fixed it all now works great! Taking pictures is tricky since my camera can’t focus on the screen well. The output looks MUCH better on the real tellie than you see here.
That shows some of the different modes. Note the syntax error in the last (un-run) line! The CHR$() just means send the actual value not the ASCII of the value. So PRINT CHR$(24) means to the video board change mode with the next byte being the mode setting.
I have updated a few of the commands. CLS now works correctly. I may update the MOVE function (added for one of the Osborne book games) although you can do any commands using the PRINT CHR$(X) to send the commands. Graphics I need to work out the best way to do. I can plot pixels now using the commands as above but that’s clunky so I think I will add in some actual graphics functions. I will see how it is done in Dave Curran’s Arduino libraries I used for testing it perhaps.
So next I think I need to look at making a case for Orwell. I was looking at laying out an getting a circuit board made for him but that’s a lot of work (and MUCH swearing at Eagle PCB) for not a lot of reward. And if I had done that I wouldn’t have been so easily able to change the video board.
I now have my serial port freed up for just doing serial. I have more VIAs here and will add another to use as general IO ports. I would also like to add a couple of 8 bit analogue to digital converters. Probably using one port on a VIA as data pins and use the control lines to select which ADC to read. The other VIA port can be general purpose digital in/out. That way I could hook on an analogue joystick. And one of the Usborne books I need to review is all about interfacing to computers so it will be handy for that.
The final book I was missing did arrive finally so now I am pretty sure I have a full set!