Click to See Complete Forum and Search --> : C keyboard bios calls


acid45
07-23-2003, 02:54 PM
I've been looking at some solutions to a problem I'm having with a command system for the game me and another guy are working on. What I need is a good resource site or tutorial with some VALID sample code. I've searched google for the past 24+ hours and a few hours yesterday and came up with only one site but I don't understand it. Also I don't understand why sample code on this site doesn't work except the first one i tried. I need a good piece of sample code for keys and it's not findable for my via google.ca. I've searched using these:

for turbo c compiler:

advanced C
dos.h
bios calls
rom bios calls
c programming
programming with c
keyboard trapping
key trapping

for vc++
bios.h

I got one single site that actually has it on it but it's more of a "quick referance guide" than a tutorial or resource site. Mostly what it has is tables with the values and SOME VALID sample code and another piece of code that I hoped worked but didn't. Also It's alot slower using a dos based compiler. Anyone know of a good gui c compiler that supports dos.h? I need both. A good non-vc++ c compiler and a good resource/tutorial site for the topic. If I'm looking the wrong way please let me know. I'm having trouble with the home and arow keys using tolower(command) where command is a char type variable storing a single charater value entered by user. ANY help is appreciated.


Thanks.



I'm going to try contacting Aopen since they made my keyboard :P

Strogian
07-23-2003, 05:12 PM
Are you programming a DOS program?

acid45
07-23-2003, 07:32 PM
Yes, it's a DOS rpg.

bwkaz
07-23-2003, 08:40 PM
Umm... ask on a DOS forum perhaps?

I'm not entirely sure very many people would know the DOS function calls and whatnot else, here. Although somebody might surprise me.

I've got a "reference to int 21h" (or something simliar) book sitting somewhere in this house, but it's been forever since I opened it -- and it's not very useful when writing C programs anyway. It's hard to load registers and generate an interrupt in C (without blowing away the contents of the registers you just loaded -- the compiler tends, or tended, to put weird instructions in weird places). It would also be hard to upload, as it's hardcopy...

michaelk
07-24-2003, 08:58 PM
My borland C++ compiler has the function bioskey. I have no idea if its compatable with VC++. It uses bios.h

int bioskey(int cmd);

Where the value of cmd;
0 if lower 8 bits are nonzero then ASCII char. If lower bits are zero then upper 8 bits are extended keyboard codes defined by IBM PC ref manual.

1 Test if keystroke is available to be read. Returns zero of no keystroke.
-1 if ctrl-brk

2 Requests current shift status.
bit 7 0x80 insert on
bit 6 0x40 caps on
bit 5 0x20 num lock on
bit 4 0x10 scroll lock on
bit 3 0x08 alt pressed
bit 2 0x04 ctrl pressed
bit 1 0x02 left shift
bit 0 0x01 right shift

There is also _bios_keybrd function which handles enhanced keyboards.