
Originally Posted by
Black Phoenix
Keyboard
Hi-Speed outputs: Memory/Key
Keyboard! You push keys, and it reacts! By default it outputs last pressed key to its only output, BUT the only output also serves as hi-speed link..!
Virtual memory area thing of wired keyboard is divided into 2 areas: 1 is the key buffer, and other one is array of pressed keys.
Key buffer is situated at first 32 bytes of keyboard, and it has following structure:
Zeroth byte shows how much keys there are in the buffer. New keys are appended on start.
Writing value to ANY of these 32 bytes except first will clear value you wrote from key buffer. I.e. if our buffer looks like:
4,2,3,4,5
it means that there are 4 variables. If we write "3" to it, it will become:
3,2,4,5
Writing removes most recent entry of key.
Ideally you'd read a key, trigger your event, and write back this code to same position you read it from.
Writing value to first value clears ENTIRE buffer.
There is also other area, which is situated from 32 bytes and up. It is ASCII-mapped array, where for each byte it's value shows if key is pressed or no.
I.e. if we wanna know if key #48 is pressed (thats "0") we look what is at address 32+48. If theres 1, we're off! Else meh, bad luck, key isn't pressed yet.
Bookmarks