I'm designing a computer using a Z80 processor (I know, not the same as the one the C64 used, it doesn't matter)
I found the following schematic showing part of the C64 circuit, and I'm particularly interested in the keyboard section on the right, attached to the MOS6525 chip. I understand in theory how keyboard like this work (i.e. scan the columns, and read each row to determine which keys are pressed.)
As I said, I understand this, but I'm confused onto how this is implemented in the software. Does the C64 constantly poll the keyboard? Because, I would've assumed there'd be some sort of secondary controller to do this scanning. How would the C64 have enough time to do other things such as running programs, if it's spending so much time polling the keyboard? (and also drawing the screen, and polling joysticks, for that matter?)
Is it all down to the kernel? Does the kernel say something like "poll the keyboard, then poll the joysticks, then run a couple instructions of a program, then repeat"?