// File: /workspace/github_c_makefile_star2_O1/leiradel[P]zx48k-libretro/src/zx.h
// Function: zx_key_down
void zx_key_down(zx_t* sys, int key_code) {
    CHIPS_ASSERT(sys && sys->valid);
    switch (sys->joystick_type) {
        case ZX_JOYSTICKTYPE_NONE:
            kbd_key_down(&sys->kbd, key_code);
            break;
        case ZX_JOYSTICKTYPE_KEMPSTON:
            switch (key_code) {
                case 0x20:  sys->kbd_joymask |= ZX_JOYSTICK_BTN; break;
                case 0x08:  sys->kbd_joymask |= ZX_JOYSTICK_LEFT; break;
                case 0x09:  sys->kbd_joymask |= ZX_JOYSTICK_RIGHT; break;
                case 0x0A:  sys->kbd_joymask |= ZX_JOYSTICK_DOWN; break;
                case 0x0B:  sys->kbd_joymask |= ZX_JOYSTICK_UP; break;
                default:    kbd_key_down(&sys->kbd, key_code); break;
            }
            break;
        /* the Sinclair joystick ports work as normal keys */
        case ZX_JOYSTICKTYPE_SINCLAIR_1:
            switch (key_code) {
                case 0x20:  key_code = '5'; break;    /* fire */
                case 0x08:  key_code = '1'; break;    /* left */
                case 0x09:  key_code = '2'; break;    /* right */
                case 0x0A:  key_code = '3'; break;    /* down */
                case 0x0B:  key_code = '4'; break;    /* up */
                default: break;
            }
            kbd_key_down(&sys->kbd, key_code);
            break;
        case ZX_JOYSTICKTYPE_SINCLAIR_2:
            switch (key_code) {
                case 0x20:  key_code = '0'; break;    /* fire */
                case 0x08:  key_code = '6'; break;    /* left */
                case 0x09:  key_code = '7'; break;    /* right */
                case 0x0A:  key_code = '8'; break;    /* down */
                case 0x0B:  key_code = '9'; break;    /* up */
                default: break;
            }
            kbd_key_down(&sys->kbd, key_code);
            break;
    }
}

// Assembly:
testq %rdi, %rdi
je 0x114ad
cmpb $0x0, 0x1110(%rdi)
je 0x114ad
movl 0x1118(%rdi), %eax
cmpq $0x3, %rax
ja 0x1142c
leaq 0x22c6(%rip), %rcx      # 0x13680
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x1158, %rdi           # imm = 0x1158
jmp 0x3060
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x1142d
leaq 0x22c2(%rip), %rcx      # 0x136a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x31, %esi
jmp 0x113c3
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x11439
leaq 0x2293(%rip), %rcx      # 0x13690
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x36, %esi
jmp 0x113c3
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x11448
leaq 0x2294(%rip), %rcx      # 0x136b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x2, 0x111d(%rdi)
retq
cmpl $0x20, %esi
jne 0x113c3
movl $0x35, %esi
jmp 0x113c3
cmpl $0x20, %esi
jne 0x113c3
movl $0x30, %esi
jmp 0x113c3
cmpl $0x20, %esi
jne 0x113c3
orb $0x10, 0x111d(%rdi)
retq
movl $0x33, %esi
jmp 0x113c3
movl $0x34, %esi
jmp 0x113c3
movl $0x38, %esi
jmp 0x113c3
movl $0x32, %esi
jmp 0x113c3
orb $0x4, 0x111d(%rdi)
retq
movl $0x39, %esi
jmp 0x113c3
movl $0x37, %esi
jmp 0x113c3
orb $0x8, 0x111d(%rdi)
retq
orb $0x1, 0x111d(%rdi)
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x2de5(%rip), %rdi      # 0x1429d
leaq 0x2cab(%rip), %rsi      # 0x1416a
leaq 0x2e36(%rip), %rcx      # 0x142fc
movl $0x153, %edx            # imm = 0x153
callq 0x30b0