// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/osd.c
// Function: OSD_HandleChar
int OSD_HandleChar(int ch)
{
	if (!osdinited) return ch;
	if (!osdvisible) return ch;

	if (ch < 32 || ch == 127) {
		switch (ch) {
			case 1:		// control a. jump to beginning of line
				OSD_Manipulate(OSDOP_START); break;
			case 2:		// control b, move one character left
				OSD_Manipulate(OSDOP_LEFT); break;
			case 3:		// control c, cancel
				OSD_Manipulate(OSDOP_CANCEL); break;
			case 5:		// control e, jump to end of line
				OSD_Manipulate(OSDOP_END); break;
			case 6:		// control f, move one character right
				OSD_Manipulate(OSDOP_RIGHT); break;
			case 8:
			case 127:	// control h, backspace
				OSD_Manipulate(OSDOP_BACKSPACE); break;
			case 9:		// tab
				OSD_Manipulate(OSDOP_COMPLETE); break;
			case 11:	// control k, delete all to end of line
				OSD_Manipulate(OSDOP_DELETE_END); break;
			case 12:	// control l, clear screen
				break;
			case 13:	// control m, enter
				OSD_Manipulate(OSDOP_SUBMIT); break;
			case 16:	// control p, previous (ie. up arrow)
				OSD_Manipulate(OSDOP_HISTORY_UP); break;
				break;
			case 20:	// control t, swap previous two chars
				break;
			case 21:	// control u, delete all to beginning
				OSD_Manipulate(OSDOP_DELETE_START); break;
			case 23:	// control w, delete one word back
				OSD_Manipulate(OSDOP_DELETE_WORD); break;
		}
	} else {	// text char
		OSD_InsertChar(ch);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
cmpb $0x1, 0x5aa001(%rip)    # 0x5ed2c8
jne 0x4330c
cmpb $0x0, 0x5ae00c(%rip)    # 0x5f12dc
je 0x4330c
cmpl $0x20, %r14d
setge %al
cmpl $0x7f, %r14d
setne %cl
testb %cl, %al
jne 0x43314
xorl %ebx, %ebx
leal -0x1(%r14), %eax
cmpl $0x16, %eax
ja 0x433a9
leaq 0x295d6(%rip), %rcx     # 0x6c8d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebx, %ebx
xorl %edi, %edi
jmp 0x433da
movl %r14d, %ebx
jmp 0x433df
movl 0x5adfde(%rip), %eax    # 0x5f12f8
movl 0x5adfec(%rip), %ebp    # 0x5f130c
movl %ebp, %ecx
xorl $0x1ff, %ecx            # imm = 0x1FF
xorl %ebx, %ebx
orl %eax, %ecx
je 0x433df
movl 0x5ae1d7(%rip), %r15d   # 0x5f1510
testl %eax, %eax
je 0x43346
movl %ebp, %eax
cmpl %r15d, %ebp
je 0x4336d
jmp 0x43378
movl %ebp, %eax
subl %r15d, %eax
jle 0x4336a
movslq %r15d, %rcx
leaq 0x5adfb9(%rip), %rdx    # 0x5f1310
leaq (%rdx,%rcx), %rsi
leaq (%rcx,%rdx), %rdi
incq %rdi
movslq %eax, %rdx
callq 0x61a0
movl %r15d, %eax
incl %ebp
movl %ebp, 0x5adf97(%rip)    # 0x5f130c
movl %eax, %r15d
movslq %r15d, %rcx
leaq 0x5adf8e(%rip), %rax    # 0x5f1310
movb %r14b, (%rcx,%rax)
leal 0x1(%rcx), %eax
movl %eax, 0x5ae181(%rip)    # 0x5f1510
movl 0x5a953(%rip), %eax     # 0x9dce8
cmpl %eax, %ecx
jl 0x433df
incl 0x5adf69(%rip)          # 0x5f1308
incl %eax
movl %eax, 0x5a941(%rip)     # 0x9dce8
jmp 0x433df
cmpl $0x7f, %r14d
jne 0x433df
pushq $0x6
jmp 0x433d9
pushq $0xa
jmp 0x433d9
pushq $0xd
jmp 0x433d9
pushq $0xc
jmp 0x433d9
pushq $0x1
jmp 0x433d9
pushq $0xb
jmp 0x433d9
pushq $0x2
jmp 0x433d9
pushq $0x8
jmp 0x433d9
pushq $0x4
jmp 0x433d9
pushq $0x9
jmp 0x433d9
pushq $0xe
popq %rdi
callq 0x433ec
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq