Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Keyboard Handler

GeoSF18GeoSF18 Posts: 2Member
hello there.. i'm trying to create a keyboard handler for a game and i can't get it to work. i'm using borland pascal 7.0 for windows.i'm using what i've found on some posts but when the game starts it loops all the time and without using the procedure Newkeyb whose address i've set the interrupt 9 to. i'm using units wincrt and windos. if anyone can help me create one or knows what the problem is please reply.

(using Windows XP Pro) oh another problem i've experienced is that i can't use the debugger because it is a 16bit process which tries to get access to keyboard or mouse something that is not supported by winXp (at least it says so). Thanks.

Comments

  • bpajkbpajk Posts: 156Member
    : hello there.. i'm trying to create a keyboard handler for a game and i can't get it to work. i'm using borland pascal 7.0 for windows.i'm using what i've found on some posts but when the game starts it loops all the time and without using the procedure Newkeyb whose address i've set the interrupt 9 to. i'm using units wincrt and windos. if anyone can help me create one or knows what the problem is please reply.
    :
    : (using Windows XP Pro) oh another problem i've experienced is that i can't use the debugger because it is a 16bit process which tries to get access to keyboard or mouse something that is not supported by winXp (at least it says so). Thanks.
    :
    BIOS interrupts are not allowed in windows systems. The interrupt 9 you are using, is a hardwere (BIOS) interrupt, so therefore is probably not allowed. There is a unit Keyboard in Borland Turbo Pascal, it probably has evreything you nead. Borland Pascal for Windows should have a unit like that. With a combination of WinCrt and a Keyboard unit, you probably wouldn't have to use interrupts.
  • GeoSF18GeoSF18 Posts: 2Member
    first of all thanks for the reply.. ok then is there a way to use the up,left,right,down key and a combination of them in bp7?it seams they are used to scroll the window. it's more easy to create a new keyboard handler than search in the bp's help file.. :p thanks again.
  • zibadianzibadian Posts: 6,349Member
    : first of all thanks for the reply.. ok then is there a way to use the up,left,right,down key and a combination of them in bp7?it seams they are used to scroll the window. it's more easy to create a new keyboard handler than search in the bp's help file.. :p thanks again.
    :
    You can use ReadKey() for that, although I don't know if it is included in the WinCrt. If it is, then each of those keys consist of 2 key codes: #0 and the actual key code. A very simple tool can show you that code. Here is the code for such a tool:
    [code]
    var
    ch: char;
    begin
    repeat until Keypressed;
    ch := ReadKey;
    if ch = #0 then
    writeln(ord(Readkey)) { display extended key code }
    else
    writeln(ord(ch)); { display normal key code }
    end.
    [/code]
    This code assumes that KeyPressed() and ReadKey() are available in the windows version of BP7.
  • bpajkbpajk Posts: 156Member
    : : first of all thanks for the reply.. ok then is there a way to use the up,left,right,down key and a combination of them in bp7?it seams they are used to scroll the window. it's more easy to create a new keyboard handler than search in the bp's help file.. :p thanks again.
    : :
    : You can use ReadKey() for that, although I don't know if it is included in the WinCrt. If it is, then each of those keys consist of 2 key codes: #0 and the actual key code. A very simple tool can show you that code. Here is the code for such a tool:
    : [code]
    : var
    : ch: char;
    : begin
    : repeat until Keypressed;
    : ch := ReadKey;
    : if ch = #0 then
    : writeln(ord(Readkey)) { display extended key code }
    : else
    : writeln(ord(ch)); { display normal key code }
    : end.
    : [/code]
    : This code assumes that KeyPressed() and ReadKey() are available in the windows version of BP7.
    :
    I actually didn't find an interface for 16bit compilers that could process several keypresses at the same time (for example up and down key at the same time). This is because windows blockes BIOS interrupts. Because 16bit programs run in emulated DOS, they have wery poor access to windows recurses, they can't access the windows function that could solve this problem. But the program would work perfectly under DOS. Therefore I can only recomend a 32bit compiler like free pascal that can handle several keypressed at the same time with the integrated windows functions in its units. I looked it up their forum. This question is allready solved.
Sign In or Register to comment.