According to Bendersky:
What's wrong with the CRT in `BPcompat'?
There's nothing wrong with it. Just that I want to learn how to use GPC, and not how to write my programs in Borland Pascal and make them run in GPC.
:-) Welcome to the club!
It's just that, so what I did, was to take a look to the BPcompat sources to learn how to "import" functions from the C library. I finally used the following as borland's readkey:
Function getche:char; C;
Okay, that's *one* method to get this functionality.
Which system are you running? DOS/DJGPP?
Yes, I'm running that system.
Then it's probably the best method to get a `ReadKey' function to call the BIOS interrupt directly from your program.
Function KeyPressed = result: Boolean;
begin (* KeyPressed *) result:= false; asm ( 'movb $0x01, %%ah' 'int $0x16' 'setneb %0' : '=rm' ( result ) : (* no input *) : '%eax' ); end (* KeyPressed *);
Function ReadKey = result: Char;
begin (* ReadKey *) asm ( 'movb $0x00, %%ah' 'int $0x16' : '=a' ( result ) : (* no input *) : '%eax' ); end (* ReadKey *);
Remarks:
* The "= result" above is an ISO-10206 Pascal extension. It declares a variable that holds the return value of the function.
* The above only works under DOS (or DOS emulation). For UNIX (incl. Linux), use some C functions instead; I recommand to use the portable `ncurses' library. (That's the reason why I don't mind to use assembler under DOS: There is no intrinsically portable solution anyway.)
* For a GPC assembler tutorial, see ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpcasm.zip.
In addition, have a look at the fairly portable GRX graphics library.
Have fun,
Peter