Clone of ZX-81 computer, unfinished semi-finished product for inspiration
The original intent of the ATX-81 was to create a replica of the ZX-81 computer with the ATmega8 processor, which has similar features to the original ZX-81 - 1 KB of RAM and 8 KB of ROM. I didn't count on emulating the processor (the ATmega couldn't do that because of the video signal generator), but the computer was supposed to be roughly BASIC-compatible. And although the project remained in a work in progress and will probably never be finished, it may serve as an interesting inspiration for other projects. For inspiration, we can recommend both the VGA video display method and the internal macro interpeter of the floating point calculator.
What is functional in the project - VGA, PAL and NTSC image generator, the larger part of the calculator with macro interpreter, the command processing and program storage part (I planned to store the program in EEPROM, this would free up RAM for data), PS/2 keyboard input, display management and memory management. Most importantly - it's a nice little box that paints nice retro letters on the display, so I'm quite sorry for the incompletion. :-) In time it turned out that there would be nothing to run on such a computer, because pure BASIC programs for the original ZX-81 (with 1 KB RAM) are quite few, mostly requiring extended RAM and machine code.
The most interesting part of the project is the image generator. The SPI interface is used to generate the video signal. By sending a byte to the SPI port, the serial bits of the image start to be transmitted, which is an alternation of black and white. With ATmega processors, however, you must take into account that 1 byte is sent to the SPI as 9 bits - 8 data bits and 1 stop bit. In an image, this is reflected in the fact that there is 1 pixel between the 8 pixels of the letter as a separator space. In plain text (black font on a white background) this is not visible. 1 bit on SPI takes either 2 or 4 CPU clock cycles depending on VGA or TV mode. 1 character is sent in 18 CPU clock cycles in VGA mode. One line can have 30 characters, that's 540 clock cycles. At a crystal frequency of 24 MHz, this is a display time of 22.5 us.
It is also worth mentioning the implementation of image synchronization. It is often apparently not known that VGA monitors can also use a synchronization mix, instead of separate VSYNC and HSYNC signals. This simplifies wiring and operation. Horizontal synchronization is routed from the PWM output of the OC1A counter of Timer1. Thus, there is no need to operate the sync output in software, this is handled by the hardware. Vertical synchronization is also handled in a simple way - during video lines generating VSYNC pulse, the polarity of the OC1A output is simply changed, which is interpreted by the monitor as a vertical sync pulse.
The ZX-81 used an unusual method of memory organization (which I also tried to adopt). Because it has only 1 KB of RAM, this memory is shared between the program, data variables, and video memory. This is so that each line in the image can have a variable number of characters per line (max 32). As characters are displayed, the line lengths are extended and the next memory area is shifted or added at the same time. Pretty diabolical way. :-).
As you can see in the schematic, the contents are mainly the processor, the crystal and a bunch of connectors. That's the advantage of modern microchips, they include everything you need. And also a disadvantage, because the bus cannot be expanded. Connected to the processor are signals for video output (video + data, VGA connector and CINCH), input from the PS/2 keyboard, audio output, LED output, programming connector, I2C connector and input from the video mode selector switch (VGA/PAL/NTSC).
The PCB was implemented as a one-sided joint.
I printed the print of the joint on the printer, glued it to the board and taped it with adhesive.
And covering. :-)
Download complete documentation (schematic in Eagle, source code for WinAvr): ATX81.zip