Page 1 of 1

Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Fri Oct 28, 2022 7:08 pm
by jordi

I reused a code from stackoverflow and all I get is a hang trying to return from the interrupt, printing the following:

198712617-16c50d4c-e940-4c3d-a7d6-5ec6e44dc546.jpeg
198712617-16c50d4c-e940-4c3d-a7d6-5ec6e44dc546.jpeg (191.53 KiB) Viewed 1765 times

This is the code and the compiled .exe I reused: https://github.com/MiSTer-devel/PCXT_Mi ... 6/KEY2.zip

It's like not returning properly from interrupt in the:
out 20h, 20h

which in C is: outp(0x20, 0x20);

Expected behaviour (Dosbox execution):
https://user-images.githubusercontent.c ... 520728.mov

Does the code is ok? it looks like


Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Fri Oct 28, 2022 7:12 pm
by jordi
Microcorelabs, might this be an issue?

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 3:29 am
by kitune-san
The PCXT should output a pulse from port B of 8255 after reading the key code.
Otherwise, the next key code reading will not be started.
In KEY2.c, apparently it is not done.

A possible countermeasure would be to trigger the reading of port A to start reading the next key code.
However, this would not be the correct behavior of PCXT.

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 3:47 am
by spark2k06
This application also hangs on 86Box/PCem with the IBM PC machine (1982), for example..., it is not useful for testing.

And forget DOSBOX for testing, either use real machines or the best alternative is PCem/86Box, on a machine like Tandy 1000 or IBM PC from 1982.

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 3:51 am
by spark2k06
What happens with KEYB SP is simply that it doesn't seem to detect the modifier key release, but it only happens with modifier keys (CTRL, SHIFT, ALT...), normal keys are detected fine. However, with SignalTap I have been able to observe that the core is sending the release of all keys, including the modifier keys... I'm still investigating the cause, meanwhile, if you think of anything, @kitune-san...

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 4:27 am
by kitune-san
I am just wondering about the following points:
- What is the instruction that identifies the break bit?
- What instruction resets the Shift, Alt key flag?

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 4:57 am
by spark2k06
kitune-san wrote: Sat Oct 29, 2022 4:27 am I am just wondering about the following points:
- What is the instruction that identifies the break bit?
- What instruction resets the Shift, Alt key flag?
I am sending you a private message to provide you with the keyb source code. Let's discuss it...

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 7:24 am
by spark2k06
Investigating further together with kitune-san, we have located the bug, which is in the MCL86 core:

MCL86:
20221029_091616-screen.png
20221029_091616-screen.png (180.38 KiB) Viewed 2438 times
PCem/86Box:
Monitor_1_20221029-091708-943943.png
Monitor_1_20221029-091708-943943.png (6.18 KiB) Viewed 2438 times
MicroCoreLabs wrote:
@MicroCoreLabs, could you check MCL86? It seems to fail to do an NOT AH when the previous CMP has previously set the carry flag.

Thank you kitune-san for noticing this detail.

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 8:56 am
by kitune-san
Maybe they are clearing the flag here.
2022-10-29 175450.png
2022-10-29 175450.png (39.43 KiB) Viewed 2397 times

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 9:18 am
by kitune-san
kitune-san wrote: Sat Oct 29, 2022 8:56 am Maybe they are clearing the flag here.

2022-10-29 175450.png
This line has been changed to NOP.
https://github.com/kitune-san/PCXT_MiST ... 420001e0cd

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 9:46 am
by Mills
kitune-san wrote: Sat Oct 29, 2022 9:18 am
kitune-san wrote: Sat Oct 29, 2022 8:56 am Maybe they are clearing the flag here.

2022-10-29 175450.png
This line has been changed to NOP.
https://github.com/kitune-san/PCXT_MiST ... 420001e0cd
It seems to work well. I tested Spanish keyboard:
20221029_094433-screen.png
20221029_094433-screen.png (57.98 KiB) Viewed 2361 times

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 5:22 pm
by MicroCoreLabs
Yes, the NOT opcode should not affect any flags, but I am clearing them in the common 0xF6 code. Your NOP fix may be the best fix, but let me investigate to make sure this solution will not affect other 0xF6 opcodes. Thanks!

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 6:10 pm
by MicroCoreLabs
Yes, it looks like changing that line of microcode to a NOP is the best fix.

I verified that each 0xF6 opcode sets the Carry and Overflow flags independently so there is no need to pre-zero them when the 0xF6 opcode is recognized. The mistake was when a microcode operation is shared between opcodes I tried to perform it just once to save the microcode memory space, which in this case was incorrect. :)

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sat Oct 29, 2022 6:15 pm
by spark2k06
MicroCoreLabs wrote: Sat Oct 29, 2022 6:10 pm Yes, it looks like changing that line of microcode to a NOP is the best fix.

I verified that each 0xF6 opcode sets the Carry and Overflow flags independently so there is no need to pre-zero them when the 0xF6 opcode is recognized. The mistake was when a microcode operation is shared between opcodes I tried to perform it just once to save the microcode memory space, which in this case was incorrect. :)
Thank you! This solution will be available in the next release.

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sun Oct 30, 2022 10:40 am
by kitune-san
MicroCoreLabs wrote: Sat Oct 29, 2022 6:10 pm Yes, it looks like changing that line of microcode to a NOP is the best fix.

I verified that each 0xF6 opcode sets the Carry and Overflow flags independently so there is no need to pre-zero them when the 0xF6 opcode is recognized. The mistake was when a microcode operation is shared between opcodes I tried to perform it just once to save the microcode memory space, which in this case was incorrect. :)
The TEST instruction in group 6 (0xF6) does not seem to clear OF and CF.
I think the microcode may need to be modified.

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Sun Oct 30, 2022 11:29 am
by kitune-san
Sorry. That was my misunderstanding. :oops:

Re: Some Research Over the Keyboard Issues on Hang Shift for Keyb sp

Posted: Mon Oct 31, 2022 1:36 pm
by jordi
kitune-san wrote: Sun Oct 30, 2022 11:29 am Sorry. That was my misunderstanding. :oops:
No sorries, we would not have this core without you!