sam-astro / Astro8-Computer

Custom 16-bit homebrew CPU, emulator, renderer, PCB, and language

Repository from Github https://github.comsam-astro/Astro8-ComputerRepository from Github https://github.comsam-astro/Astro8-Computer

Allow for multiple keys to be pressed at a time

surec-or opened this issue · comments

The pong game isn't very fun because the EX port can only register one key at a time.

I'm not sure how to fix this, but you mentioned in the video that the EX port is 16 bit and "available for any device to use", so something could be done more with that, and utilize more of the port.

There are many ways this could be done, but I'll list my own theoretical solution here.

Instead of using the entire 16 bit EX port, you can split it into two separate 8 bit sections when using multiplayer. This would allow for two player games without problem. The CPU would read both of the sections instead of reading just the one. Splitting the EX port into would also help with using audio and controls in the same program, or extra RAM and such. And this could be made optional, just in case.

Another thing that may be useful: the NES used is shift registers, where it queries all of the button presses and pushes it on this "stack" of some sorts. Then the CPU would pop one off and put it onto the input. I'm pretty sure this was done based on CPU interrupts. Interrupts would be a nice feature to have of this CPU.

Again, the solution isn't the greatest, and it basically turns it into a sort of game console, but I tried my best.. I recommend figuring out how other game consoles and computers handle input.

Please tell me if I'm wrong about anything. Thanks.

I have another idea. A separate space address for pheriferals like keyboard, mouse, audio. It could be read and write by adding two instruction (read and write) using register A

well we now have banks+switching (and also a "wider" expansion port size)
so this is possible

Right now there are 46 expansion port slots iirc, and keyboard, mouse, webcam, and audio are the premade ones among them.
In the dev branch, I started work on a system that would evenly send signals for all pressed keys, and it just requires a bit more tweaking probably, but it makes the pong game and others to have normal key inputs.

Much improved system is now implemented for keyboard, in v3.0.0-alpha and above