asm_in_inkey() modifiers

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

asm_in_inkey() modifiers

Post by derekfountain »

I was looking at the in_inkey() library code, thinking about SYM and CAPS modifiers. The comments in the code don't say how it handles the modifiers, but the code seems to say it adds 40 to the ASCII value when CAPS is pressed, and 80 to the ASCII value when SYM is pressed. Maybe it's late, but that doesn't seem to make a whole lot of sense. :)

I wrote this:

Code: Select all

/*
 * zcc +zx -vn -startup=5 -clib=sdcc_iy key_press.c -o key_press -create-app
 */

#include <input.h>
#include <input/input_zx.h>
#include <stdio.h>
#include <sys/ioctl.h>

void main(void)
{

  ioctl(1, IOCTL_OTERM_PAUSE, 0);

  while(1)
  {
    uint8_t i = in_inkey();
    printf("0x%02X\n",i);
  }
}
which shows it does work for CAPS: 0x61 for 'a', 0x41 for CAPS-'a'. But I'm not quite sure what the pattern is for the SYM-SHIFT modifier. Could someone spell it out for me?
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: asm_in_inkey() modifiers

Post by dom »

Without digging too deeply, I believe the 0x40, 0x80 are modifiers to the scan code returned by in_key_scancode() and used by in_key_pressed() not to the ascii value that is returned by in_Inkey()

What's actually returned is in this table: https://github.com/z88dk/z88dk/blob/mas ... _table.asm which just maps the key legends with an extra simulated control key.
derekfountain
Member
Posts: 121
Joined: Mon Mar 26, 2018 1:49 pm

Re: asm_in_inkey() modifiers

Post by derekfountain »

The modifiers are 40 and 80 (not 0x40 and 0x80). The table looks right though, so I guess they're not so much modifiers as lookup table index adjustments - there are 40 keys on the Spectrum's keyboard. OK, that makes sense. Thanks!
Post Reply