Please check if this is a z88dk bug, or if there is a possible workaround for this.
Here is a test program I have written to reproduce this problem, the compile commands for various ANSI-capable targets are in the comment at the top. Try any of the working systems first to see the desired behaviour.
Code: Select all
/*
z88dk kbhit() and getch() test for targets that support VT100 Console I/O ANSI
by RobertK, 2018-04-04
Compile commands:
=== Jupiter Ace === (ok)
zcc +ace -clib=ansi -lgfxace -vn -create-app kbhit_getch_test.c -o kgt.bin
load the program in the Jupiter Ace by typing:
0 0 bload kgt.bin
=== Mattel Aquarius === (ok)
zcc +aquarius -clib=ansi -lgfxaq48 -lm -create-app kbhit_getch_test.c -o kgt_aquarius
=== Sharp MZ-700 === (ok)
zcc +mz -clib=ansi -lm -create-app kbhit_getch_test.c -o kgt_sharpmz
Note: on this system the input keys are always upper-case.
=== Philips VG5000 === (ok)
zcc +vg5k -create-app -lm kbhit_getch_test.c -o kgt_vg5000
(Note: "ansi VT emulation is implicit")
Use the DCVG5K emulator (dcvg5k.free.fr) for testing.
Attach the .k7 cassette file and type CLOAD to load the program.
Note that the VG5000 has a French AZERTY keyboard so on most
other keyboard layouts you have to type CLOQD.
This also affects the input within the test program.
=== VZ200 / Laser 210 / Laser 110 === (ok)
Note: ansi VT emulation seems to be implicit.
zcc +vz -lm -o kgt_vz200.vz kbhit_getch_test.c
or (for graphics mode)
zcc +vz -lm -pragma-redirect=fputc_cons=putc4x6 -o kgt_vz200.vz kbhit_getch_test.c
=== Robotron Z1013 ===
zcc +z1013 -clib=ansi -lm -create-app kbhit_getch_test.c -o kgt_z1013
Note: on this system the input keys are always upper-case.
Issue: Pressed key does not get "released" again.
*/
#include <stdio.h>
#include <conio.h>
void main()
{
char c;
int exit = 0;
printf("%c",12); // clear the screen
printf("kbhit / getch test\npress any key\n");
getch(); // wait for keypress
printf("%c",12); // clear the screen
printf("press a or b, or x to exit...\n");
while(exit<1)
{
if(kbhit()) // key has been pressed?
{
c = getch(); // determine the key that has been
// printf("\nkey %d pressed\n",c);
if (c=='a')
{
printf("a pressed (%d)\n",c);
}
else if (c=='A')
{
printf("A pressed (%d)\n",c);
}
else if (c=='b')
{
printf("b pressed (%d)\n",c);
}
else if (c=='B')
{
printf("B pressed (%d)\n",c);
}
else if (c=='x')
{
printf("x pressed (%d)\n",c);
exit=1;
break;
}
else if (c=='X')
{
printf("X pressed (%d)\n",c);
exit=1;
break;
}
else
{
printf("other key pressed (%d)\n",c);
}
}
}
printf("done");
getch(); // wait for keypress
printf("%c",12); // clear the screen
}