|I forget there are 104 keys sometimes|
Yea, this guy.
In testing my totally awesome new keyboard input system, I discovered that it was outputting totally awesome garbage. Turns out that the scan codes emitted from Allegro are not the same as the scan codes emitted by the BIOS. How it's supposed to work is simple. ROE retrieves a BIOS scan code from the keyboard queue and processes it into ASCII. If the key doesn't have a ASCII equivalent, like a function key, it's assigned a special number. This is done with a lookup table. The problem was that I didn't understand what the BIOS was supposed to be emitting so I could get Allegro to emulate it. You see a BIOS keyboard scan code has a surprising amount of data stuffed inside it. None of it being the actual letter (glyph) you typed. It's more like what was the location of the key you interacted with and if it was being pressed (a "make" in mechanical keyboard terms) or coming up (a "break"). It makes no distinction between a lower-case "a" or an upper case "A" It's up to the programmer to put together the keyboard state (as it came from a mechanical device) to generate the character you want.
|I had to manually map this keymap too.|
BIOS scan code for the "A" key : 30
Allegro scan code for the "A" key: 01
ASCII code for capital "A" : 65
ASCII code for lowercase "a" : 97
Luckily, ROE does not use lower case letters. But keep in mind it was written before F11 and F12 was a standard thing! But what the BIOS was actually generating on each key press was kind of an enigma. Different libraries process scan codes different ways. Is it one bye? Three byes? Two? Does it need to be bit shifted? What being shifted out? Is that important?
So the only way to figure it out was to ask the BIOS directly. But, remember, interrupt vectors are not allowed in Windows. So what do I do? Well, fire up DOS!
|Hello 80x53 text, how have you been?|
After input is complete, I should be getting into the realm of dropping in functions. I'm about 80% complete with Nermal, which means I have about 90% left to go.