3 ms·
> There are no release events, and hold events cannot be distinguished from repeated press events. Running into this now in MS-DOS! I’m in the middle of learn
by drivers99 3y ago
> There are no release events, and hold events cannot be distinguished from repeated press events.
Running into this now in MS-DOS!
I’m in the middle of learning some low-level assembly language 16-bit x86/BIOS/MS-DOS & bare metal if necessary (I/O ports) programming (for fun, on my original IBM PC). I’m trying to program a game and there is no BIOS or DOS interrupt routine to get the key-up scan codes, just key down and/or the translated codes, even though the keyboard and interrupt controller send both to a BIOS interrupt handler. There is a BIOS function for getting the left and right shift, alt, Ctrl, and well as the states of scroll lock, caps lock, num lock, and insert states, which are derived from those keyboard events since it obviously tracks when those keys go up and down. [0] So I can use the shift keys for a game for now as a workaround, but only for moving left or right like in Breakout or Space Invaders.
I ran across examples of how to capture all the scancodes by taking over interrupt 9. [1] Usually those examples also emulate what the BIOS would do, but for a game I wouldn’t care about that. That would give me the ability to track any key’s state that I care about.
So it’s interesting to see how it works (in the normal BIOS interrupt handler) that “Ctrl” and “A” are equal keys at one level, just having up/down scan codes. 1D and 9D for Ctrl up/down for instance. And the next level up will give you translated ASCII (or other codes for non-ascii keys like function, arrow, or Alt- keys), Ctrl-A is 01 (SOH), A by itself is ‘a’ (61h), shift A is ‘A’ (41h), or the opposite if Caps Lock is on. I don’t think it even supports combos like Shift-Ctrl-A etc. [2] (Other OSes take over and do things different and I don’t really know much about that. Don’t modern OSes give you access to whether keys are being pressed? Pygame has key up and down events and I think DirectX lets you check if a key is down.)
[0] http://www.ctyme.com/intr/rb-1756.htm http://www.ctyme.com/intr/rb-1756.htm
[1] https://stackoverflow.com/questions/12882342/override-default-int-9h https://stackoverflow.com/questions/12882342/override-defaul...
[2] https://www.plantation-productions.com/Webster/www.artofasm.com/DOS/ch20/CH20-1.html https://www.plantation-productions.com/Webster/www.artofasm....