Code: Select all
======================================
C=64 keyboard to gigatron - part 1
======================================
Code: Select all
{
Btw it's original written in and "painted" with an old style monospaced or non-proportional ASCII font of your choice.
That's a bit like writing on IT stone that last forever. ;-)
}
Let's start on gigatrons game controller input connector with it's three signal wires.
Code: Select all
o Pin_4 = SER_PULSE = output signal = VGA /HSYNC
o Pin_3 = SER_LATCH = output signal = VGA /VSYNC
o Pin_2 = SER_DATA = 8-bit serial input pin 14 at 74HC595 with a 2k2 ohm pullup resistor.
To understand the input in detail we look on two things first. The old Nintendo NES controller "protocol" and the VGA sync signals.
And maybe why they are so well connected to each other.
Code: Select all
+--------------------------------------------------------+
| |
| +---+ |
| | U | game controller |
| +---+ +---+ |
| | L R | Select Start ___ ___ |
| +---+ +---+ / \ / \ |
| | D | [###] [###] | A | | B | |
| +---+ \___/ \___/ |
| |
+--------------------------------------------------------+
The old Nintendo NES controller has a total of 8 functions / buttons. Yes, that sounds like 8-bit or a byte right.
~ But wait the nice gigatron unbranded game controller has 10 buttons?
~ Yes, of course it's a bit cheating with more than a single shift register under the black blob on the PCB inside
. Later more on that...
Now we have to transfer the information which button is pressed via three wires. The thing of choice back then, when CPUs are much more expensive than nowadays, are two shift registers. One converts the parallel data into a serial bitstream and the other gets the serial bitstream and converts it back to parallel.
The first shift register is in the game controller and looks basically like this:
Code: Select all
+------------------------------------------+
|4021 |
| [shifts the bits to the output] <--+--o clock input
| |
serial | [1=parallel input, 0=serial output] <--+--o P/S
input | |
+-o--+->[1]->[2]->[3]->[4]->[5]->[6]->[7]->[8]--+--o serial output
| | ^ ^ ^ ^ ^ ^ ^ ^ |
| | | | | | | | | | |
--- +---|----|----|----|----|----|----|----|---+
| | | | | | | |
o o o o o o o o
R L D U St. Se. B A
The block is the parallel in / serial out shift register 4021 (CMOS 4000 Series). This one was used by nintendo back in the day.
The parallel input pins are at the bottom. Each pin is connected to a dedicated button wich corresponds to a dedicated bit within the transfered byte. Each button is high = 5V if not pressed and low = 0V if pressed.
Code: Select all
R = right = bit 1 = BUS0 (signal within gigatron)
L = left = bit 2 = BUS1
D = down = bit 3 = BUS2
U = up = bit 4 = BUS3
St. = Start = bit 5 = BUS4
Se. = Select = bit 6 = BUS5
B = B = bit 7 = BUS6
A = A = bit 8 = BUS7
Each of the parallel input pins is connected to a register inside the 4021 that is able to store the input signal and send it one after another to the serial output.
This shift register has basically two operating modes. Parallel P and serial /S.
> In parallel mode the signals from the input pins are setting the internal registers 1..8. And, also very important, the clock input is disabled.
> In serial mode the registers are cut off from the parallel input pins but remember the last value.
> To get these values out of the serial output pin we have to clock the shift register.
> A clock pulse is a rising edge (0->1) on the clock input. With each pulse all the bits are copied to the next neighbour. From 8 to serial out, from 7 to 8, from 6 to 7 ... from serial input to 1. Serial input is tied to ground.
~ A signal name with a / in front (mostly) marks a low active signal. P/S means: P = parallel mode if logic 1 (5 Volt), /S = serial mode if logic 0 (0 Volt).
But we need a source for clock and P/S. There has to be a source or master of this signals. And this could only be the gigatron.
Let's take a closer look to DB9 pin 3 and 4 SER_LATCH and SER_PULSE.
Both signals correspond to the simple VGA Sync signals.
On page 44 of the gigatron handbook / schematics you find that the VGA sync signals are direct connected to the SER_x signals.
Code: Select all
> SER_PULSE = VGA /HSYNC
> SER_LATCH = VGA /VSYNC
If we look to these signals on our gigatron through an oscilloscope it looks like this:
Code: Select all
____ ___________________ .... _____
/VSYNC |_______________________________| |___
____ _ _ _ _ _ _ _ _ _ _ _ _ _ .... _ _ _
/HSYNC |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_| |_|
rising edges ^ ^ ^ ^ ^ ^ ^ ^
1 2 3 4 5 6 7 8
The vertical sync signal (falling edge) marks the begin of each frame at 60 times per second (60Hz).
The horizontal sync signal (falling edge) marks the begin of each line within the frame.
The most interesting part for the game controller are the 8 rising edges within the low periode of the /VSYNC signal.
That's exactly what we need to clock our 4021 shift register in the game controller to get the byte out of it.
> The /VSYNC signal is the SER_LATCH output signal on gigatron becomes the P/S input on 4021.
> The /HSYNC signal is the SER_PULSE output signal on gigatron becomes the clock input on 4021.
That's a very clever way to reuse a complex signal generation. Well done!
Now we have a serialized byte that the gigatron can read on the DB9 connector pin 2 = SER_DATA.
And finally the system software can grab this byte from the input port via the instruction bit IR0=1 & IR1=1 over Bus access decoder /IE signal (gigatron schematics p.40).
Yes, it's that simple
In my next post I describe where the serial byte disappears inside the gigatron and how we use the 4021 for a simple keyboard adapter.
bye for now,
Michael