A error in my Keyboard driver

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
VoidLogic

A error in my Keyboard driver

Post by VoidLogic »

Please help!

1. the following code if for real mode
2. it compiles
3. it is has correct syntax
4. it crashes

The main loop in constently looking for a new char, the int. function is called at a key press and fills the vector. The first time a key is pressed everything works, the second time everything works and after about 25-75 runs through the main loop the program freezes. :(

here she is:

#include <BIOS.h>
#include <Ctype.h>
#include <StdIO.h>
#include <DOS.h>
#include <Apqueue.h>

#define INTR 0011 // The Keyboard INT

#ifdef __cplusplus
    #define __CPPARGS ...
#else
    #define __CPPARGS
#endif

apqueue <int> KeyQue;

void interrupt ( *oldhandler)(__CPPARGS);

void interrupt handler(__CPPARGS)
{
disable();
oldhandler();
KeyQue.enqueue(bioskey(0));
enable();
}

void main(void)
{
bool Loop_Flag = true;
int key = 0;
oldhandler = getvect(INTR);
setvect(INTR, handler);
while(Loop_Flag)
{
  cout<<".";
  if (KeyQue.length() > 0)
  {
   KeyQue.dequeue(key);
   if (isalnum(key & 0xFF))
    printf("%c", key);
   else
    printf("%#02x", key);
   if(char(key) == 'e') Loop_Flag = false;
  }
}
setvect(INTR, oldhandler);
}
Post Reply