[HN Gopher] How the C64 Keyboard Works ___________________________________________________________________ How the C64 Keyboard Works Author : ibobev Score : 96 points Date : 2023-03-04 13:30 UTC (9 hours ago) (HTM) web link (c64os.com) (TXT) w3m dump (c64os.com) | logbiscuitswave wrote: | This was a really great and well-explained article. For an | article that went deep into hardware internals, it somehow made | it all make perfect sense. Kudos to the writer. | | It's pretty fascinating just how "dumb" the keyboard is and how | keyboard input is actually being polled. It seems like this could | easily lead to missed key presses or slow response, but I don't | recall the C64 keyboard suffering from either of these things. | (It's been some years since I last used a real C64 though.) | | Yet, somehow on an exponentially more powerful and capable modern | computer it seems that things like instant input response and no | missed key presses is somehow asking for a lot. | tyingq wrote: | > somehow on an exponentially more powerful and capable modern | computer it seems that things like instant input response and | no missed key presses is somehow asking for a lot | | I would guess there's still an 8bit CPU polling the keyboard | matrix, only inside the now separate keyboard. That being the | first layer, it can only get slower as it traverses all the | other, new layers. | Aldipower wrote: | The 6526 (CIA) was the first chip I could fix by replacing the | broken one to another functioning one. Those CIAs are at high | risks, because they are directly connected to the 2 joystick | ports of the C64. You just need to touch some pins at the port | and you probably grill your CIA with static electricity. | Unfortunatly the CIAs getting rarer and rarer, because the cannot | reproduced by FMPGs until today, so you need to get a space CIA | from another machine. Maybe in the future this will work with | replications. | Findecanor wrote: | One thing that people do to break the first CIA chip is to | connect a gamepad from a Sega Master System or for the Mega | Drive/Genesis. They work fine on other systems that accept | "Atari-compatible" joysticks, such as the Atari VCS, Atari | 8-bit, Amiga, etc. so you'd think they'd work fine here too, | but no. | | Sega had put the pull-up resistors in the controller instead of | on the motherboard, thus providing positive current on each | input pins when a button/direction is not pressed. But for the | C64, the inputs are supposed to be disconnected when not | active, and when CIA #1 is reading the keyboard, the extra | current could overload the chip. You could make an adaptor | though with a diode on each input line. (The adaptor should | also route Vcc to pin 5 which is Sega's Vcc pin) | rollcat wrote: | Recently an entire C64 was built from scratch using modern | parts, I think there were some FPGAs involved. It's unfortunate | that the design is so brittle (maybe good idea to mod a | protective shutter), but I wouldn't worry about future | repairability. | | Also TIL that C64OS is a thing. Maybe C64 is the design we | should be looking into when considering permacomputing. | Aldipower wrote: | https://news.ycombinator.com/item?id=34389496 Hey, if you | referring to this video, I made a comment there that the CIAs | are straight out of the eighties. It was a little bit | clickbait. The C64 was build from scratch, but not all parts | were freshly made. | | Absolutely the C64 is a thing for permacomputing, haha. | psadri wrote: | I had a C64 in Iran when I was 12. After a few years, a column of | keys on the keyboard stopped working. So, every time I turned it | back on, my first task was to remap some critical keys to the | function row keys. | Aldipower wrote: | This is a typical phenom if you grilled one of your CIAs by | touching the joystick ports. | peter_d_sherman wrote: | >"The C64's keyboard, by comparison, is _absolutely dumb_. It has | no electronics at all. Just switches in an 8x8 matrix. The actual | matrix switches themselves are fed down the keyboard cable and | into the computer. And the C64 's own CPU needs to spend precious | time scanning the matrix." | | While "unfortunate" from the perspective that a C64 requires some | of its CPU time to actively scan/poll the keyboard -- it also is | quite possibly one of the _simplest_ (simple = positive, | beneficial, educational, etc.) keyboard designs that could exist | for a microcomputer (and for that reason, educationally | valuable!) perhaps only short of a "dumb" keyboard connected to | an RS-232 interface... | | Anyway, great article! | masswerk wrote: | This is also what enables nearly latency-free keyboard response | at 60Hz polling, something most modern implementations can only | dream of. (The latency of modern keyboard communications is | also an issue with emulation.) | | BTW, this architecture really goes back to the PET 2001 (1977), | which even comes with a detailed keyboard matrix diagram in the | manual. | | [0] | https://www.masswerk.at/pet/manuals/PET_User_Manual_(2001-8)... | (p 12) | | Commodore does a good job there (just before and after the | diagram) of selling the advantages and disadvantages: | | _> Until that key is released, no other keyboard scans are | acknowledged unless a later scanned key is struck. The later | scanned key is then considered to be the next key closure. The | algorithm does not give classical N key roll over but does | allow for legitimate rejection of noise and trapping of the | keys in the order that they are struck._ | | _> The keyboard is left scanning the last row, which contains | the stop key. This allows the routine in BASIC, that checks for | the stop key to sample the input I /O device, without having to | perform any of the normal functions of scanning. The user can | take advantage of this by reading the input character for that | row._ | bullen wrote: | How does shift-lock work? | | NM: https://twitter.com/gregnacu/status/1632080241316225027 | | What about restore? | rzzzt wrote: | Restore is wired to the NMI input of the CPU. It is also | pressure-sensitive ;) | | https://www.c64-wiki.com/wiki/RESTORE_(Key) | ryandrake wrote: | Cool article that goes into a little depth on the humble, handy | 6526. The 6510 and 6581(SID) always win the popularity contests, | and there's a lot of ink spilled over them, but it's nice to deep | dive on the other very interesting parts of the C64! | | I'm always amazed how fewer and fewer "computer science" | graduates every year have ever wire-wrapped a simple 68000 | computer from scratch, hooked it up to RAM, ports, a bunch of | LEDs for output and so on. Or even an already-wired | microcontroller. Fewer and fewer computer professionals really | know how these things work and have made them work by their own | hands. Maybe the Raspberry Pi has re-kindled some of this | interest, but I wonder how many people use it as just a cool- | looking tiny PC and how many actually play with the GPIOs. | anon946 wrote: | I'm a professor at a R1 university in the CS dept. I wire- | wrapped a PDP-8 in school as part of a CS degree, and thought | it was super-interesting and fun, and part of me agrees with | you. | | But the reality is that you can only cram so much into a 4-year | degree and wire-wrapping a 68000 seems like it would take many | hours. I already feel like there is so much that we are leaving | out. For example, our undergrads don't implement a compiler as | part of their degree. | | *EDIT: Also, it's arguably more computer engineering than | computer science, but the my main point is that the undergrad | CS curriculum is already super-crowded. | zabzonk wrote: | > I'm always amazed how fewer and fewer "computer science" | graduates every year have ever wire-wrapped a simple 68000 | computer from scratch | | perhaps this might explain why it is no longer popular: | | https://en.wikipedia.org/wiki/Wire_wrap#/media/File:Computer... | | and that's for an 8-bit cpu. i can't imagine wire-wrapping a | 68000. | | also, this would be computer engineering, not computer science. | galangalalgol wrote: | There are plenty of computer science, not engineering, | programs that still have required classes that involve wire | wrapping a uc and building something. It is less common as | the voracious appetite of the web and web related industry | for cs grads caused curriculum to become increasingly geared | towards meeting that need. I still find it astounding how | much software is required to keep all rhe websites I use | running. It doesn't make sense to me, but I know very little | about how that sort of software works, so I will simply trust | that some of the largest companies in the world wouldn't be | paying for it if there was an easier way. | hungryforcodes wrote: | Relevant link: | | https://www.yikes.com/~bear/wirewrapping.htm | derriz wrote: | In college, we had to wire wrap an 8-bit (6809) CPU with an | EPROM and UART to connect a terminal. It looked nothing like | your image. A 16 bit address bus, 8 bit data and only | RAM/ROM/UART sharing the "bus" meant that the wiring was | actually quite neat and it was transparent what wires were | doing what. Inevitably, part of the work involved diagnosing | poor wraps which would clearly be impossible with that pile | of spaghetti in your image. It was one of the most fun | projects we had in the 4 years. I thought it very valuable as | it brought software (writing a simple monitor using a cross- | compiler) and hardware together. ___________________________________________________________________ (page generated 2023-03-04 23:00 UTC)