www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/17/14:05:10

Message-ID: <018f01bd9a07$2d6feb80$9a4d08c3@arthur>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>
Subject: Re: Keyboard
Date: Wed, 17 Jun 1998 16:46:59 +0100
MIME-Version: 1.0

>: Can anyone tell me how to patch the keyboard a la Allegro? I would like
an
>: array or bitfield of, say, 128 elements which would show which keys were
>: pressed at which time.
>
>"at which time" or "at the time you test them"?  The latter is
>simpler.


Yes, sorry. My grammar is inexcusible. I also apologise for the "a la" which
should have accents, and in my original posting I used the word "librarys"
which should, of course, read "libraries."

>At the basic level, you need to hook the keyboard interrupt and do
>something sensible.  "Something sensible" generally involves reading a
>byte from I/O port 0x60 and then setting or unsetting the flag for the
>corresponding key.  Most keys have almost unique scancodes in the
>range from 1 to about 88.  The value you read is generally the
>scancode of the key, in the bottom 7 bits, and a press/release flag in
>the top bit.  The flag is set if this is a key-release event, unset if
>the key is being pressed.  So all you need to do is set or unset your
>array element corresponding to the scancode in the bottom 7 bits.
>Finally you send 0x20 to port 0x20 to clear the interrupt.
>
>That's a simplistic view; some keys on the keyboard are special, and
>these are communicated to you in different ways.  If you want to know
>in more detail what to do, you should either refer to some
>documentation or to some existing source code.  There are several in
>the v2tk directory of the djgpp distribution -- see readme.1st for
>details.
>
>: Why can't I just use Allegro? 'Cos I don't like using librarys (see my
other
>: posting Re: C vs C++).
>
>I don't fully understand your feelings here so perhaps you don't want
>to do this, but you might consider looking at its keyboard handler
>anyway.  It's in the file allegro/src/djgpp/keyboard.c.  You shouldn't
>feel ashamed to use or study other people's code; Allegro's handler
>will probably tell you much more than I did above.


The fact is that I feel that if I don't understand *exactly* what I'm doing,
I'm not really programming - it's someone else's work. For instance,
Allegro, while a perfectly good library, does not really let the user know
what it is doing; so the user cannot fully appreciate and anticipate certain
behaviour. This leads to a marginal drop in speed (and increased compile
size) in the final code, and I started writing on a platform where a saving
of one clock cycle was a benefit. Trouble is, coders don't know what they're
born with these days...

And I believe that in a perfect world, everything should be written in
assembler, fully optimised by the user, not the computer (but my C is better
than my ASM, so I'm a little hyppocritical here).

I have absolutely no qualms about looking over other people's code, so long
as I understand it. But Allegro's routines hardly give a step-by-step
walkthrough, do they?

Still, I may be able to understand it now.

Thanks

James Arthur
jaa AT arfa DOT clara DOT net

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019