Sunday, 14 August 2016

PET LCD

This is something I've been working on for a while, and have finally put it all together.
The top half is a 6502 socket, with pass through, a GAL chip, some DIP switches, 32K RAM and a ROM chip with various ROM images on. The RAM and data bus buffer/switch are hidden under the chips. So far it is basically a squashed up version of my 6502 ROM/RAM boards.
The large chip is a 1K dual port RAM chip. That is 1K of RAM which can be independently read and written from two different address and data busses. One side is attached to the PET bus, where it sits at 0x8000-0x8400, the screen RAM. It is configured as write only, so whenever anything is written to the PET screen RAM, it is written to the board, and to this copy of the RAM.  This is the result of writing 0,1,2,3,4 etc. to the video RAM.
The PET video system is a fairly simple character based 40x25 display, you write characters to the 1K screen RAM buffer and they appear on the screen. No pixel based graphics or custom characters can be shown, it is limited to the 256 characters in the PETSCII character set. Well, sort of, there are two character sets, normal and graphics, which can be selected by an IO line which drives an address line on the ROM. It's actually 128 characters, plus those 128 again but inverted.
There is almost an isolation gap between to top and bottom halves of the board, with only power, and reset joining them, Yes, there are a couple of bodge wires, and an annoying bodge resistor. I had one pin pulled low on the schematic that should have been pulled high, so it was attached to the ground plane. I ended up drilling out the pad and wiring the bodge resistor directly to the pin.
The other side of the RAM chip is attached to an ATmega1284P microcontroller running at 20MHz. This is connected via a 3.3V level shift to a 2.2" 240x320 LCD module.
What does all this do then? Well, if you plug this into the CPU socket of a PET, whenever the PET writes to it's video RAM, it will also be written to the dual port RAM chip. The microcontroller is continually polling this RAM via the other port and converts that to a display on the LCD.
You effectively get a copy of what is on the PET screen on the LCD, updating in real time. To generate this, I have converted the PET character ROM into a data array and draw each character pixel by pixel on the display. The 240x320 layout fits well with the 40 character, 25 row display, each character is 8x8, so 40x8 = 320, 25x8=200, with 20 pixels space top and bottom. This gives a very clear, pixel perfect version of the screen.
 In business graphics mode, the PET introduced two pixels gap between the lines, so this can be fitted in to 225 pixels. I've fixed it in the graphics character set for the moment, as it needs to tap off a one of the pins on the VIA line to change font, I'll be adding that to a later revision, probably by duplicating the port with a single 8 bit register or even just a single flip flop.
This opens up a lot of interesting potential. This is really proof of concept stage. The initial idea was this would be a diagnostics tool. You can plug this into any PET and see if it is running, even if the video output on the PET itself isn't working, as long as it is writing to screen RAM, this will show the state of the system.
It can also be used in conjunction with my 6502 diagnostics board, and will show the results of ROM and RAM testing on it's LCD. So even if the ROM, RAM and video display are all faulty, it should be possible to diagnose this and fix it bit by bit.
Since this is a 40 column display, it's also a potential way to add a 40 column display (albeit a small one) onto an 80 column PET. The board has various ROM sets on there, so the 40 column editor ROM can be selected and the PET will run in 40 column mode. The actual monitor will show the wrong thing, but the LCD will show the correct output.
The update rate is reasonable, fast enough to play space invaders anyway. I tried a few demos, and they all ran OK. This is just the first testing, I imagine I can streamline the code to make updating a bit faster.
Another thing to consider is now that I have a way of collecting the screen data, it could be used to drive something larger than this LCD. It could instead be sent to an HDMI monitor or even generate a video signal for the PET monitor or a composite output, although I think I would need an external shift register to handle the pixel clock rate. Driving the PET monitor add the option of letting you switch between 40 and 80 columns on an 8032, which would be very useful to expand the range of available software. Lots of potential though.
One final thought, this is a 6502 CPU, ROM, RAM and a display. Stick in clock, reset and some IO, and you've got yourself an SBC. Add the appropriate ROMs and IO and you've got yourself a mini PET........

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.