GetAsyncKeyState() для MS DOS

Я сделал небольшую игру для Windows, в которой используется GetAsyncKeyState(). Теперь я хочу скомпилировать игру для MS DOS, но не могу найти альтернативу этой функции. getch() и kbhit() слишком медленны для обработки нажатий клавиш. Основная цель — обрабатывать нажатия клавиш со скоростью света или, по крайней мере, со скоростью GetAsyncKeyState(). Заранее спасибо.


person user3496846    schedule 28.04.2014    source источник


Ответы (1)


Пример кода для обработки клавиатуры в Borland C++ MSDOS, который использует conio.h , kbhit() и getch(). Это должно отлично компилироваться в MSDOS Borland C++.

#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <dos.h>

#define TRUE 1
#define FALSE (!TRUE)
#define TEXTSCREEN 0xB800


#define esc    27
#define tab    9
#define up     72
#define down   80
#define left   75
#define right  77
#define home   71
#define cend   79
#define pgup   73
#define pgdn   81
#define ins    82
#define del    83
#define plus   43
#define subt   45
#define mult   42
#define devi   47
#define spc    32
#define f1     59
#define f2     60
#define f3     61
#define f4     62
#define f5     63
#define f6     64
#define f7     65
#define f8     66
#define f9     67
#define f10    68
#define ap     53
#define bksp   8
#define enter  13
#define crum   245


void key2(void);

int main(void)
{

    ch=0;
    while(ch!=esc)
    {

       key2(); 

     }

  return 0;
}


void key2(void)
{
  if (kbhit())
  {
    ch=getch();

    if (ch==f1)
    {

    }
    if (ch==f2)
    {

    }
    if (ch==f3)
    {

    }
    if (ch==f4)
    {


    }
    if (ch==f5)
    {


    }
    if (ch==f6)
    {


    }
    if (ch==f7)
    {


    }
    if (ch==f8)
    {


    }
    if (ch==f9)
    {

    }
    if (ch==f10)
    {


    }


    if (ch==tab)
    {

    }

    if (ch==ins)
    {

    }

    if (ch==del)
    {
    }

    if (ch==bksp)
    {



    }

    if (ch==enter)
    {


    }

    if (ch==spc)
    {

    }
    if (ch==49)
    {



    }
    if (ch==50)
    {



    }

    if (ch==up)
    {


    }

    if (ch==down)
    {


    }
    if (ch==home)
    {



    }
    if (ch==cend)
    {



    }
    if (ch==pgup)
    {



    }
    if (ch==pgdn)
    {



    }
  }
}
person Software_Designer    schedule 17.05.2015