VGA Interface for RC2014

IMG_0488S
IMG_0487S
IMG_0492S

The Z80 RC2014 computer, designed by Spencer Owen, uses exclusively a serial interface to communicate with a host PC to be programmed. This card allows you to use, for the same task, a VGA monitor and a USB or PS/2 keyboard, leaving the serial interfaces free to be used with other devices such as modems, printers, etc.

Circuit Schematic

The board uses the Parallax Propeller microcontroller interfaced to the Z80 microprocessor as a normal I/O device (Input / Output). Starting from the connector marked RC2014_BUS we can observe how address decoding is carried out using only a few silicon diodes of type 1N4148, instead of the more bulky integrated circuits that are normally used, configured as logical OR and AND gates, to determine whether the corresponding bus lines must be at level 0 or 1.

Lines A7, A5, A4, A2, A1 and IOREQ are connected to the anode of diodes configured as logical OR. The output of the diodes, consisting of the common cathode and the pull-down resistor R36, will be at logic level 0 only and only if all the lines are at logic level 0. Lines A6, A3 and M1 are instead connected to the cathode of the diodes configured as logical AND, therefore the output, represented by the common anode and the pull-up resistor R28, will be at logic level 1 only and only if all the lines are at logic level 1. With this information we can determine that the I/O addresses corresponding to the required conditions are 48H and 49H. Through the resistors R31 and R32 the status of these “logic gates” will be brought to pins P27 and P6 of the microcontroller which, with a suitable firmware, checks their status to determine if the Z80 microprocessor is accessing the interface. Any other address will not satisfy the conditions of the “logic gates” therefore it will be ignored and can be used for other peripherals.

The A0 line, as well as the WR and RD lines, are connected directly to the microcontroller through the resistors R27, R29 and R30 and are used by the firmware to establish exactly which of the two available ports the Z80 microprocessor wants to communicate with and whether it must write or read the data.

The data bus, consisting of the D0-D7 lines, is also connected directly to the P8-P15 pins of the microcontroller, by means of as many limiting resistors.

The interface also uses the RESET line to reset the microcontroller via the TR2 transistor when the Z80 microprocessor is reset, and the WAIT line to temporarily stop the Z80 microprocessor via the TR1 transistor when the requested data is not yet ready.

The P16-P23 pins of the microcontroller are used to generate the VGA signal formed by two signals for vertical and horizontal synchronisms, and two pins for each of the three RGB colors connected to a simple digital to analog conversion circuit (DAC) consisting of the precision resistors R4/R5, R6/R7 and R8/R9. With two pins for each channel it is possible to generate four voltage levels, therefore 4x4x4 = 64 corresponding combinations of as many colors displayed on the screen. The resistors R12-R14 help to adapt the output impedance required by the VGA monitor to 75 ohms.

Finally, pins P0 and P1 are used for the USB or PS/2 port to which the keyboard is connected.

Board assembly

The printed circuit board designed for this board is double-sided and completely through-hole. I recommend starting with low-profile components, such as diodes and resistors, to finish with larger ones, such as the VGA connector, in order to facilitate positioning and soldering. Let’s start by mounting the silicon diodes 1N4148 being careful to orient the reference band that indicates the cathode terminal as shown on the silkscreen, in particular D2, D5 and D9 must face the bus connector while the others towards the microcontroller socket.

Continue by mounting the bus connector, all resistors, the 5 MHz crystal, the decoupling ceramic capacitors and the sockets for the microcontroller and the EEPROM memory. Finally, mount the two transistors, taking care not to swap the models as one is a PNP type and the other a NPN type and if exchanged they will never function correctly, the voltage regulator, the two electrolytic capacitors, the small piezo speaker and the USB (or PS/2 depending on the type of keyboard used) and VGA connectors.

Once assembly is complete, the firmware must be programmed in the IC2 EEPROM memory. If you have a PROP-PLUG adapter, you can use the connector located near the crystal to program it without removing it from the circuit. If you do not have a PROP-PLUG adapter, any programmer capable of writing the Microchip serial EEPROM memories, such as the TL866 available at various online stores, is required.

In both cases, make sure to program the EEPROM with the specific firmware for the type of keyboard connector inserted in the printed circuit. USB firmware will never work with PS/2 keyboards and vice versa.

Software

To use the interface on your Z80 computer, you need to modify the software appropriately. The firmware partially emulates an ACIA 68B50 serial interface with the control port at address 48H and the data port at address 49H.

The following sample code illustrates how to read characters typed on the keyboard, send characters to the interface to be displayed and check the status.

CRT_C           .EQU  48H
CRT_D           .EQU  49H

RXCHAR
WAITCRT         IN    A, (CRT_C)        ; Status byte D0=RX char ready
                AND   01H
                JR    Z, WAITCRT
                IN    A, (CRT_D)
                RET                     ; Char ready in A

TXCHAR
                PUSH  AF
CRTOUT1         IN    A, (CRT_C)
                AND   02H
                JR    Z, CRTOUT1
                POP   AF                ; RETrieve character
                OUT   (CRT_D), A        ; OUTput the character
                RET

CKINCHAR
                IN    A, (CRT_C)
                AND   01H
                RET

To simplify things for the less experienced, the pre-compiled versions of the “standard” ROM supplied with the RC2014 computer containing the BASIC and the MONITOR program are available, as well as the CP/M 2.2 system ready to be used with this card.

Inside the zip file downloadable from the link at the bottom of the page, you will find the 24886000.BIN file to be programmed in a 64K ROM containing the 32k and 56k BASIC, the 16K SCMonitor program, the “standard” monitor program and a special bootloader to directly load CP/M from the compact flash card without the need for manual intervention.

You will also find the Intel-HEX files containing the CP/M system, modified to use the interface, to be loaded on the compact flash card following the procedure illustrated on the README.txt file.

For systems with Z180 microprocessor a version of RomWBW, modified to use the card as a CRT console, is also included.

Terminal Settings

Pressing the CTRL-F10 keys on the keyboard accesses the terminal configuration screen. Pressing the numeric button next to the parameter will change the setting. Press the CTRL-F10 keys again to save the new settings and return to the terminal screen.

1. Keyboard Mapping

Toggles between the supported national keyboard mappings.

2. Cursor Keys

Selects the codes sent by pressing the cursor movement keys when the terminal is in “cursor” keys mode.

3. Application Cursor Keys

Selects the codes sent by pressing the cursor movement keys when the terminal is in “application” keys mode.

Tasto VT-100 VT-100 Appl. WordStar
Up ESC[A ESCOA CTRL-E
Down ESC[B ESCOB CTRL-X
Right ESC[C ESCOC CTRL-D
Left ESC[D ESCOD CTRL-S
Home ESC[H ESCOH CTRL-Q S
End ESC[K ESCOK CTRL-Q D
PageUp CTRL-R
PageDown CTRL-C
Insert CTRL-V
Delete CTRL-G
Shift+Right CTRL-F
Shift+Left CTRL-A

4. Cursor Style

Changes the default cursor style between block or underline, blinking or steady. Note that ESCape sequences can be sent by applications to change the cursor appearance, in that case the style is not saved and will be reset to the default at power-on.

5. Num. Lock

Sets the default state of the Num. Lock toggle.

6. Caps Lock

Sets the default state of the Caps Lock toggle.

Terminal control codes

The firmware partially emulates an ANSI / VT-100 terminal. Programs can use standard ESCape sequences and control characters to control the terminal behaviour.

Control Characters

Dec. Hex Oct.  
7 07 007 Bell.
8 08 010 Backspace, moves the cursor backward by 1 column.
9 09 011 Tab, moves the cursor to the beginning of the next 8-characters column.
10 0A 012 Line feed, moves the cursor to the next row at the same column.
12 0C 014 Clear the entire screen an moves the cursor to the home position.
13 0D 015 Carriage return, moves the cursor to the beginning of the line.
27 1B 033 ESCaped character or ANSI / VT-100 codes prefix.

All other characters are displayed. If you want to display one of the above characters, prefix it with ESC.

ANSI / VT-100 Codes

ESC[{count}A Moves the cursor up by {count} rows; the default count is 1.
ESC[{count}B Moves the cursor down by {count} rows; the default count is 1.
ESC[{count}C Moves the cursor forward by {count} columns; the default count is 1.
ESC[{count}D Moves the cursor backward by {count} columns; the default count is 1.
ESC[{row};{col}H Sets the cursor position where subsequent text will begin. If no row/col parameters are provided (ie. ESC[H), the cursor will move to the home position, at the upper left of the screen.
ESC[K Clear line from cursor right.
ESC[1K Clear line from cursor left.
ESC[2K Clear entire line
ESC[J Clear screen from cursor down.
ESC[1J Clear screen from cursor up.
ESC[2J Clear entire screen.
ESC[{row};{col}f Same as ESC[{row};{col}H
ESC[{num1};…;{numN}m Sets multiple display attribute settings, where {numX} can be the following:

0 Reset all attributes
1 Bright
2 Dim
5 Blink
7 Reverse
25 Blink off
30..37 Foreground color (black, red, green, yellow, blue, magenta, cyan, white)
38;5;{num} Foreground color to {num} (0-15)
39 Default foreground color (white)
40..47 Background color (black, red, green, yellow, blue, magenta, cyan, white)
48;5;{num} Background color to {num} (0-7)
49 Default background color (black)
ESC[6n Reports the cursor position to the application as (as though typed at the keyboard) ESC[{row];{col}R
ESC[s Save current cursor position.
ESC[u Restore the saved cursor position.
ESC[L Insert line.
ESC[M Delete line.
ESC[{num}q Set cursor style. {num} can be 0/1=blinking block, 2=steady block, 3=blinking underline, 4=steady underline.
ESC[?1h Set cursor keys to application.
ESC[?1l Set cursor keys to cursor.
ESC[?12h Enable cursor blinking.
ESC[?12l Disable cursor blinking.
ESC[?25h Show cursor.
ESC[?25l Hide cursor.
ESC[?42h Enable National Replacement Characters Set.
ESC[?42l Disable National Replacement Characters Set.

VT-52 Compatible Codes

ESCA Moves the cursor up by 1 row.
ESCB Moves the cursor down by 1 row.
ESCC Moves the cursor forward by 1 column.
ESCD Moves the cursor backward by 1 column.
ESCH Moves the cursor to the home position.

Where ESC is character code 27 (1B hex, 033 oct.), {count}, {row}, {col} and {num} are numeric parameters.

The National Replacement Characters Set is an option that allows to replace some seldom user characters from the 7 bit ASCII set with national characters such as umlauts. It is used with word processors on systems that are capable of handling 8 bit characters such as CP/M. This option can also be enabled or disabled by pressing CTRL-F9. The displayed characters depends on the set keyboard map.

Files