# Pat80

![Pat80 Home Computer Logo](/assets/media/pat80-banner-colour-raster.png)

Pat80 Home Computer is an attempt to develop the simplest possible Zilog Z80 based computer in 2021.

## Hardware
Instead of being another single board computer, Pat80 focuses on modularity:
- The Core board contains Z80 CPU, 32k ram, 32k rom, memory and I/O decoding logic
- The Backplane is a stupid I/O bus board with no active components, 1 socket for the Core board and 8 sockets for I/O boards
- Each I/O board must implement tri-state and go to high impedance according to its EN pin to avoid bus contention
- The Power Supply module contains a 7805-based linear power supply capable of delivering 1A @5v for the core and I/O boards

Here is a picture of the early stages of development:

![Pat80 Breadboard prototype](/assets/media/photos/breadboard.jpg)

### I/O Boards

#### Parallel terminal interface
A parallel terminal based on Arduino is used for development purposes and will be replaced by an UART card.

#### Keyboard controller
Pat80 features a blue-switches mechanical matrix keyboard, seen by the system as a memory area in I/O space. The keyboard doesn't use interrupts and is polled by the OS.

#### Video controller
The monochrome 368x248 pixels video output is software-generated by an ATMega 1284 MCU. The timings are generated by the MCU's 16 bit internal timer and the vertical sync time is used to update the framebuffer.


## Software
The OS is a simple Memory Monitor. It can show memory content in hex and ascii with the typical hex editor tabular view.
Programs can be loaded from the keyboard, writing Z80 opcodes and data in hex. The program can be executed from any ram position and the Memory Monitor can be brought to screen in any moment issuing an INT signal (the Z80 INT pin should be connected to a button with pull-up resistor).
There is an experimental and unfinished quick load function using a python terminal to load a binary file directly to memory and execute it.

![Pat80 Memory Monitor](/assets/media/photos/memory_monitor.jpg)

## Emulator
The pat80 memory monitor (the os) can be run in a z80 emulator. This repository contains an emulator as submodule, already set up to run the os.
To try it, head to `pat80-computer/software/z80-assembly/os/` and run `make run` to build the rom from assembly and start the emulator. You will see some windows showing the emulated computer's memory and register status and the pat80 memory monitor prompt.

![Emulator running Memory Monitor](/assets/media/photos/emulator.png)

## Status
The project is heavily work in progress.

### Working
- Core board
- Sound board
- Arduino parallel terminal with its own Python companion script (or any UART terminal)

The only fully working configuration as now is the Core board with two devices hooked to its I/O bus: the Arduino Parallel Terminal (see `pat80-io-devices/parallel-terminal` and `pat80-computer/software/z80-assembly/os/drivers/arduino_terminal.asm`) and the SN76489 sound chip (see `pat80-computer/software/z80-assembly/os/drivers/hd44780.asm`)

### Partially working
The keyboard is only partially tested, as it's not completed.

![Pat80 keyboard pcb](/assets/media/photos/keyboard_before_etching.jpg)

![Pat80 keyboard layout](/assets/media/photos/keyboard_layout.jpg)

The composite video card is partially working, but has some nasty bugs on text cursor positioning and the graphics mode is not yet implemented (the only way to output graphics ATM is to place the bitmap in the MCU flash and load it to VRAM manually).

![Pat80 composite monitor text mode](/assets/media/photos/composite_text.jpg)

![Pat80 composite monitor graphics mode](/assets/media/photos/composite_graphics.jpg)

For the moment, better to stick with the Arduino Parallel Terminal.

### Not working
All the rest

## License
All the project is under GPL v3 license