CAPS-SHIFT key for ZX81

Requests for features
Post Reply
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

CAPS-SHIFT key for ZX81

Post by siggi »

Currently a keypress on the keyboard of a ZX81 is converted to a lower case ASCII-charcter, when read e. g. by getk(). The SHIFT-key of the ZX81 keyboard is necessary to get some symbols (like $ or "), thus cannot be used to enter uppercase characters.

It would be fine, if another key (e. g. SHIFT 9/GRAPHICS) could be used to switch once (for the next entered character) or until pressed again to UPPERCASE characters (only a..z -> A..Z).

Currently I need to have workarounds implemented in my SENDMAIL and GETMAIL programs to enter SMPT/POP3-passwords and text in lower or UPPERCASE characters.

Siggi
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

siggi wrote:It would be fine, if another key (e. g. SHIFT 9/GRAPHICS) could be used to switch once (for the next entered character) or until pressed again to UPPERCASE characters (only a..z -> A..Z).
Codes 166 to 192 seem to be mapped to capital letters. Are you able to generate those codes from the keyboard?

If not, do you have the code for SHIFT+9 handy?
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Codes 166 to 191 are inverted characters, which are used on output to screen to indicate capital ASCII characters. Currently they cannot be entered by keyboard, that is the current problem ;-)

GRAPHICS is ZX81 code 116:

Code: Select all

112 cursor up
113 cursor down
114 cursor left
115 cursor right
116 GRAPHICS
117 EDIT
118 NEWLINE
119 RUBOUT
GRAPHICS in BASIC environment is used to enter inverted characters and graphical characters (ZX81 block graphics) by keyboard. Some of them are already used on output by Z88DK to print some special ASCII characters to screen, which are not present in the ZX81 character set (like %, !, _, #). Maybe they could also be entered as ZX81 graphics character from keyboard? That would also be useful ....
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I've added CAPS LOCK, which can be toggled with GRAPHICS on the zx81. I decided to keep the CAPS LOCK state across calls to fgets so let us know if that seems strange too.

If you can think of anything else that should change just let us know. I can't make those decisions for the zx81 as I am not familiar enough to know what is normal.
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Alvin,
that sounds great. In BASIC, the GRAPHICS are also "locked" until GRAPHICS is pressed again. So that is the "normal" behaviour :-)

Thanks
Siggi

... now waiting for a SUCCESSFUL NIGHTLY BUILD ....
Last edited by siggi on Sun Apr 13, 2014 10:39 am, edited 1 time in total.
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Tested today: works great :-)
Thanks a lot
Siggi

PS. getchar() seems not to be affected by setting of GRAPHICS/SHIFT-LOCK, right? Is in_Inkey() affected?
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

siggi wrote:Tested today: works great :-)
Great!
PS. getchar() seems not to be affected by setting of GRAPHICS/SHIFT-LOCK, right? Is in_Inkey() affected?
No, it only affects fgets on stdin. I wasn't quite sure what to do with it as the zx81 version is calling into ROM to get characters so there is a possibility that I should be setting a system variable to change to GRAPHICS mode (but I don't think you're getting a cursor?) and then that might affect getk, getchar. Instead I made a local state variable for a 'terminal' inside fgets_cons and this change affects all z80 targets so that everyone gets a CAPS LOCK.

in_Inkey is completely separate with its own key scanning code. Are you thinking CAPS LOCK should apply everywhere? I'm revisiting the input.h API and how it interacts with terminals right now for the new clib so if you have any ideas, just say so. One thing I will do is get rid of the camel case -- I have learned to hate it :P
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Alvin
I think, the fuctions returning a single keypress from keyboard (e. g. in_Inkey) should not be affected by CAPS LOCK (because the user cannot see, whether it is enabled and also cannot disable it), only those functions, which reads complete strings from keyboard (where editing using BACKSPACE or RUBOUT is possible) should be affected by CAPS LOCK (the user sees the echo on screen and can enable/disable CAPS LOCK, if necessary).

So the current implementations seems to fulfill that, right?

Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

While writing a new version of the ZeddyNet Network Filemanager I noticed, that CAPS-SHIPS does not work using "gets", while it works using "fgets" when reading from keyboard. Is that in intended behaviour? Both functions read complete strings from keyboard ...
It would be nice, if that would also work for gets().

Siggi
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

This should be added in the Dec 13 build.
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Hi Alvin
using the new build I get error message when compiling NFM. e. g.:

Code: Select all

D:\PRIVAT\ZX81\DEV\LAN\ZeddyNet\nfm>zcc +zx81 -zorg=32768 -startup=2 -vn -llibzeddynet -llibsocket -o NFM-32KE.bin cli.c -O3
        1 Datei(en) kopiert.
        1 Datei(en) kopiert.
Error at file 'stdio/gets.asm' line 76: symbol '__cons_state' not defined
Error at file 'stdio/gets.asm' line 82: symbol '__cons_state' not defined
Error at file 'stdio/gets.asm' line 86: symbol '__cons_state' not defined
3 errors occurred during assembly
Key to filenames:
C:\Users\siggi\AppData\Local\Temp\s4ts_.o = cli.c
Error at file 'stdio/gets.asm' line 76: symbol '__cons_state' not defined
Error at file 'stdio/gets.asm' line 82: symbol '__cons_state' not defined
Error at file 'stdio/gets.asm' line 86: symbol '__cons_state' not defined
:-(

Siggi
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

siggi wrote::-(
Bah, I forgot to commit the updated list file. This should work in the next build Dec 14
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

I still can't enter uppercase letters using gets(). :-(
But fgets() still works ;-)

Siggi
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Maybe SHIFT-9 (GRAPHICS) is not interpreted within gets() to switch CAPS-SHIFT mode on/off???
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

siggi wrote:Maybe SHIFT-9 (GRAPHICS) is not interpreted within gets() to switch CAPS-SHIFT mode on/off???
Hmm. Ok I will check whether gets() is using a different key input path. Both gets() and fgets() share the same capslock indicator so if fgets() sets capslock, it should be set inside gets() as well.
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

I think it's resolved. Try again with the Dec 15 build later on.
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

Crazy: Using the test program

Code: Select all

//zcc +zx81 -startup=2 -create-app -vn -O3 -o test-fgets.bin test-fgets.c
#include <stdio.h>
int main(void)
{
    int i;
    static char buf[60];
    for (i=0; i < 4; i++)
    {
       printf("fgets()\n");
       fgets(buf, sizeof(buf), stdin);
       printf("gets()\n");
       gets(buf);
    }
}
I found:
during FGETS() I can enable and disable uppercase (SHIFT-9)
during GETS() I can only DISABLE (!) uppercase, if it has been enabled during FGETS before!

Siggi
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

siggi wrote:I found:
during FGETS() I can enable and disable uppercase (SHIFT-9)
during GETS() I can only DISABLE (!) uppercase, if it has been enabled during FGETS before!
Yes that's what I thought might happen; the fix applied should address this.
siggi
Well known member
Posts: 344
Joined: Thu Jul 26, 2007 9:06 am

Post by siggi »

The test program above now works perfectly :-)

Thanks a lot
Siggi
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

Alvin, you're my hero :)

Sorry for my rare presence in the the forum, recently.
Post Reply