C=64 Keyboard @ Gigatron

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

C=64 Keyboard @ Gigatron

Post by WattSekunde »

Maybe you have an old, unused, good or defect C=64 laying around in the dust because on your transparent shiny new gigatron TTL microcomputer Snake, Racer, Gigatris or Blocks are much more fun. :D

But you miss a real pro typewriter like keyboard. That one the C=64 has in the old days. The long wait is over and a dream becomes reality. :lol:

GigakeysC64-2.jpg
GigakeysC64-2.jpg (299.78 KiB) Viewed 4200 times
Ok, In this thread I'll give you all the Information, schematics and possible modifications about the C=64 keyboard and it's connection to the gigatron.

First of all there are no modifications necessary for a simple connection between the C=64 keyboard and my "gigaMatrixKey" adapter. The C-64 Keyboard has a connector you can easy unplug and use with a breadboard or a DIY "gigaMatrixKey" pcb and later put it back into your C-64!

In the next posts I'll describe the C64 keyboard connector as well as the matrix and the "gigaMatrixKey" schematics and maybe a custom PCB. And not to forget the GCL code & table for the C64 to ASCII conversion.

C=64 keyboard in action! https://youtu.be/jyx4R04JGU8
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: C=64 Keyboard @ Gigatron

Post by marcelk »

Absolutely brilliant!

This deserves the keymap to be included and supported in future ROMs that have embedded terminal applications.
So... we need a permutation of 64 values there for C64, and an identity mapping for ASCII?
Hmm... sounds like a noise wave form and a sawtooth? What an evil opportunity to combine two completely unrelated tables :twisted:
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: C=64 Keyboard @ Gigatron

Post by marcelk »

For those who are looking to clone WattSekunde's setup, the 8-Bit Guy just informed me he has more than plenty "new old-stock" C=16 matrix keyboards in his webshop...: http://www.the8bitguy.com/product/commo ... old-stock/

The wiring is not exactly the same, but can be made to match for the most part. Or use a different mapping in software of course...
Attachments
C16_keyboard_02.jpg
C16_keyboard_02.jpg (137.55 KiB) Viewed 4153 times
WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: C=64 Keyboard @ Gigatron

Post by WattSekunde »

marcelk wrote: 21 Jun 2018, 21:13 Absolutely brilliant!

This deserves the keymap to be included and supported in future ROMs that have embedded terminal applications.
So... we need a permutation of 64 values there for C64, and an identity mapping for ASCII?
Hmm... sounds like a noise wave form and a sawtooth? What an evil opportunity to combine two completely unrelated tables :twisted:
Haha.. nice one ;-). Like the old days where every byte counts...
marcelk wrote: 23 Jun 2018, 18:36 For those who are looking to clone WattSekunde's setup, the 8-Bit Guy just informed me he has more than plenty "new old-stock" C=16 matrix keyboards in his webshop...: http://www.the8bitguy.com/product/commo ... old-stock/

The wiring is not exactly the same, but can be made to match for the most part. Or use a different mapping in software of course...
I didn't know that the 8-bit guy has this online shop. Thats interesting!
WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: C=64 Keyboard @ Gigatron

Post by WattSekunde »

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
Post Reply