Hi, does any one understand how is KEYBOARD (02BFh) routine working ? Why it uses two KSTATE sets ?
I generally understand how debouncing in software should work but ZX ROM seems overcomplicated to me.
Keyboard debouncing in ZX ROM ?
Keyboard debouncing in ZX ROM ?
Proud owner of Didaktik M
Re: Keyboard debouncing in ZX ROM ?
It's explained in very nice detail here https://skoolkit.ca/disassemblies/rom/hex/asm/02BF.html
A double system of 'KSTATE system variables' (KSTATE0-KSTATE3 and KSTATE4-KSTATE7) is used from now on.
The two sets allow for the detection of a new key being pressed (using one set) whilst still within the 'repeat period' of the previous key to have been pressed (details in the other set).
A set will only become free to handle a new key if the key is held down for about 1/10th. of a second, i.e. five calls to KEYBOARD.
Re: Keyboard debouncing in ZX ROM ?
Well, it's not actually doing debouncing, but key repeat management.
If you are reading a key once, every frame, you don't actually need to debounce it, since bouncing takes place in a lot less than 20ms.
If you are reading a key once, every frame, you don't actually need to debounce it, since bouncing takes place in a lot less than 20ms.