Close

Interaction

A project log for Gigatron TTL microcomputer

Just because! A home computer without microprocessor

Marcel van KervinckMarcel van Kervinck 10/16/2017 at 20:500 Comments

With the instruction set, video, sound and blinkenlights already checked, the last remaining unknown is the input. I will be using a simple NES-type of controller for the games. Unlike the simpler Atari joysticks these controllers have a serial interface. In this video you see the computer read the input once during every scanline in vertical blank, and render the received value in binary somewhere in the middle of the screen.

The controller needs sync pulses from the computer. For simplicity I feed it with the VGA vSync and hSync signals. The software loop already generates these anyway. Then on the receiving end I decode the controller's single data line with a 74HC595 shift register, which in turn connects to the computer's data bus. The 74HC595 is also designed to work with two sync signals, but I didn't bother and hooked up both pins to hSync. With that, 60 times per second the controller state flows through the shift register at a rate of one bit per scanline. Using the in bus mode the software can read its contents. It just needs to catch it at exactly the right time otherwise the buttons get confused. But the timing is measured in scanlines, and this computer races pixels, so no sweat there. 

The code running in the video above is this:

address
|    encoding
|    |     instruction
|    |     |    operands
|    |     |    |
V    V     V    V
016f 0043  ld   $43          # Calculate which Y position we want to draw
0170 b508  suba [$08],y
0171 1014  ld   $14,x        # Start at fixed X position (20)
0172 dc00  st   $00,[y,x++]  # Draw black pixel and advance X
0173 c313  st   in,[$13]     # Read controller input
0174 0001  ld   $01          # Set mask to bit 1
0175 c214  st   [$14]
0176 2113  anda [$13]        # Is this bit On or Off?
0177 f07a  beq  $7a          # (See previous blog post on this idiom)
0178 fc7b  bra  $7b
0179 000f  ld   $0f          # On: yellow
017a 0004  ld   $04          # Off: dark green
017b de00  st   [y,x++]      # Draw pixel and advance X
017c 0114  ld   [$14]
017d f475  bge  $75          # Shift mask and loop over all bits
017e 8200  adda ac
017f dc00  st   $00,[y,x++]  # Draw a final black pixel

With this last hurdle taken, the TTL microcomputer is complete: we have video in 64 colors, 4 channels of sound and we have input to make it interactive.

Everything is now ready to start writing games.

Discussions