Jump to content
  • 1
Miklós Pathy

How to handle the keyboard?

Question

And when I say keyboard handling, it means KEYBOARD HANDLING. Which means minimum everything and extras. (No, the joystick handling is not enough for this)

Currently i know only one method to poll the keyboard from assembly. Call GETIN, and use whatever you get back in the A register.
This is fantastic, except it is (moderated:) not ideal, you can only poll the last pressed key, you have no keyoff information at all.
Also, - by my experience - if you make any changes in the interrupt handling, the GETIN call simply terminate the program.

If you take a look at my YM2151 SYNTH UI project, the synth is monophonic, and do not know when the key is released. The only cause for this, because i can not handle all the simultaneouslythe pressed keys, and i do not know when these individual keys are released. Otherwise it could be a really cool polysynth. Also in this project i can not implement software based LFOs, because ovverriding the interrupt breaks this (edit:) keyboard handling.

I started a thread about key handling in the facebook group, and there was a long discussion about PS2 in the emulator, custom PS2 handling routines, etc.
It would be nice to continue the discussion here, examples would be appreciated, and hopefully at the end some good documentation in the topic. (obviously with howtos about full total PS2 handling not less)
 

Edited by Miklós Pathy
And
  • Like 3

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

if you haven't seen it yet, this thread may interest you: https://www.commanderx16.com/forum/index.php?/topic/312-ps2-usb-discussion-split-from-whats-the-state-of-play-with-serial-port-support/

It seems that the interrupts generated from the ps/2 ports go into the NMI line on the processor, not IRQ. As far as I'm aware, there's no way to override NMI handler like there is for IRQ. This seems like something that you should be able to do. At the very least for the time being, you could modify your kernal rom so that the NMI vector points into ram. There probably isn't any good documentation right now on how to manually interact with the ps/2 hardware, but you can refer to the kernal source on github.

Share this post


Link to post
Share on other sites
  • 0

What we really need is for the default PS/2 handler to place key UP events in the keyboard buffer, or for the handler to build a map of all of the scan codes with their current up/down state. 

I think the ideal choice would be a 128 byte chunk of memory that holds the state of each key. Then a program can poll the state of each key by simply reading the appropriate value. Of course, we only need 1 bit to know if a key is being held down, so this could be condensed to 16 bytes, but it takes extra code to do the math to make that work.... probably around 200 machine cycles. While that's not a huge amount, every cycle counts when writing games, so I'd probably use the larger table, given the choice. 

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use