// File: khedoros[P]khednes/mem.cpp
// Function: mem::sendkeydown(SDL_Scancode)
void mem::sendkeydown(SDL_Scancode test) {
        //util::debug(ORIGIN,"Key down! (%04x)\n",test);
        switch(test) {
                case SDL_SCANCODE_A:
                        joy1_buttons[6]=true; //left
                        //printf("LEFT!\n");
                        break;
                case SDL_SCANCODE_D:
                        joy1_buttons[7]=true; //right
                        //printf("RIGHT! ");
                        break;
                case SDL_SCANCODE_G:
                        joy1_buttons[2]=true; //select
                        //printf("SELECT!\n");
                        break;
                case SDL_SCANCODE_H:
                        joy1_buttons[3]=true; //start
                        //printf("START!\n");
                        break;
                case SDL_SCANCODE_K:
                        joy1_buttons[1]=true; //b
                        //printf("B!\n");
                        break;
                case SDL_SCANCODE_L:
                        joy1_buttons[0]=true; //a
                        //printf("A!\n");
                        break;
                case SDL_SCANCODE_S:
                        joy1_buttons[5]=true; //down
                        //printf("DOWN!\n");
                        break;
                case SDL_SCANCODE_W:
                        joy1_buttons[4]=true; //up
                        //printf("UP!\n");
                        break;
                case SDL_SCANCODE_GRAVE:
                        pu.speedup(true);
                        break;
                case SDL_SCANCODE_X:
                        joy2_trigger=16;
                        break;
                case SDL_SCANCODE_Z:
                        joy2_light=0;
                        break;
                case SDL_SCANCODE_N:
                        pu.print_name_table();
                        break;
                default: cout<<"Saw button "<<int(test)<<endl;
        }        
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movl %esi, 0x9c(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x9c(%rsp), %eax
addl $-0x4, %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
subl $0x31, %eax
ja 0x14178
movq 0x10(%rsp), %rax
leaq 0x17937(%rip), %rcx     # 0x2b8b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x88(%rsp), %rdi
movl $0x6, %edx
callq 0x14f60
leaq 0x88(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x88(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x78(%rsp), %rdi
movl $0x7, %edx
callq 0x14f60
leaq 0x78(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x78(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x68(%rsp), %rdi
movl $0x2, %edx
callq 0x14f60
leaq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x68(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x58(%rsp), %rdi
movl $0x3, %edx
callq 0x14f60
leaq 0x58(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x58(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x48(%rsp), %rdi
movl $0x1, %edx
callq 0x14f60
leaq 0x48(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x48(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x38(%rsp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0x14f60
leaq 0x38(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x38(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x28(%rsp), %rdi
movl $0x5, %edx
callq 0x14f60
leaq 0x28(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x28(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
callq 0x14f60
leaq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x14fa0
leaq 0x18(%rsp), %rdi
callq 0x15010
jmp 0x141a9
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x1, %esi
callq 0x1fdd0
jmp 0x141a9
movq 0x8(%rsp), %rax
movl $0x10, 0x60(%rax)
jmp 0x141a9
movq 0x8(%rsp), %rax
movl $0x0, 0x64(%rax)
jmp 0x141a9
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x1fe30
jmp 0x141a9
movq 0x22e31(%rip), %rdi     # 0x36fb0
leaq 0x178ba(%rip), %rsi     # 0x2ba40
callq 0x43c0
movq %rax, %rdi
movl 0x9c(%rsp), %esi
callq 0x4660
movq %rax, %rdi
movq 0x22dec(%rip), %rsi     # 0x36f90
callq 0x4400
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)