Robotron Z1013 Issue with VT100 Console I/O ANSI: kbhit() and getch()

Discussion about other targets
Post Reply
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Robotron Z1013 Issue with VT100 Console I/O ANSI: kbhit() and getch()

Post by RobertK »

I have noticed a problem with the Robotron Z1013 target (which supports VT100 Console I/O ANSI) when reading user key input using kbhit() and getch(). When the user presses a key, the key gets "stuck", i.e. the pressed key does not get "released" again, and after that no other key can be hit.

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  
}
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

https://github.com/z88dk/z88dk/issues/599

... the problem on the z1013 should be solved already, please check the latest nightly build.
The fix will work only with the later version of the z1013 bios, the older variant would eventually still have this limit.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

I'm reopening the issue :(
your code seemed to run fine to me but the Fabrizio's example proposed one in issue 599 does not.
Moreover I discovered my guess on the correct OS was totally wrong, there are at least 10 different BIOS variants out there and 5 different keyboard types.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Just fixed, I hope more efficiently :)
Please check out the next nightly build tomorrow morning and let us know
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Thanks, with the current nightly it works on the "Z1013 (matrix 8x4)", which according to M.A.M.E. was the original system.

Not all variants of this system work correctly, but we can live with that. Here is an overview (tested with M.A.M.E. 0.196):

Z1013 (matrix 8x4): ok
Z1013 (K7652/S6009): no key input possible
Z1013 (K7659): no key input possible
Z1013 (K7669): no key input possible
Z1013 (matrix 8x8): ok
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

interesting, I checked it with jkc_emu and I succeded with all the available keyboard options.
I also found my same workaround as an added feature in the bios by J. Mueller 1990-1992 (8x4), and I was convinced it was almost a standard... well I suppose we couldn't count on a real standard for a computer with so many keyboard variants! all of them won't be probably ever emulated!
We're in an even worse condition than for the nascom, where many monitor versions existed on roughly the same hw, while the z1013 keyboard and its support circuits and interfaces were designed an built by the users, including the needed firmware mods.
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

by the way, have you tested the k7659 or k7652 keyboards with the A2 monitor?
http://hc-ddr.hucki.net/wiki/doku.php/z ... n:tastatur
User avatar
RobertK
Well known member
Posts: 347
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Sorry, forget about what I wrote about the Z1013 variants. In Mame 0.196 these are marked as not working yet, only Z1013 (matrix 8x4) and Z1013 (matrix 8x8) are marked as working.

I have now tested it with JKCEMU and all Monitor/Keyboard versions work: 2.02/Membrane, A.2/Alpha, 2.028/K7659, 2.028/S6009, 2.2/K7669 and M?ller 1992/Membrane.

Problem solved, thanks!
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

:)
Post Reply