// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
movl %edi, %r14d
cmpb $0x1, 0x5a9c62(%rip)    # 0x5f32c8
jne 0x496a9
cmpb $0x0, 0x5adc6d(%rip)    # 0x5f72dc
je 0x496a9
cmpl $0x20, %r14d
setge %al
cmpl $0x7f, %r14d
setne %cl
testb %cl, %al
jne 0x496b3
xorl %ebx, %ebx
leal -0x1(%r14), %eax
cmpl $0x16, %eax
ja 0x49739
leaq 0x2d1d7(%rip), %rcx     # 0x76870
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebx, %ebx
jmp 0x497a8
movl %r14d, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl 0x5adc3f(%rip), %ecx    # 0x5f72f8
movl 0x5adc4d(%rip), %ebp    # 0x5f730c
movl %ebp, %eax
xorl $0x1ff, %eax            # imm = 0x1FF
xorl %ebx, %ebx
orl %ecx, %eax
je 0x496ac
movslq 0x5ade3d(%rip), %rax    # 0x5f7510
testl %ecx, %ecx
je 0x496dd
cmpl %ebp, %eax
je 0x496ff
jmp 0x49707
cmpl %eax, %ebp
jle 0x496ff
leaq 0x5adc28(%rip), %rcx    # 0x5f7310
leaq (%rcx,%rax), %rsi
leaq (%rax,%rcx), %rdi
incq %rdi
movl %ebp, %ecx
subl %eax, %ecx
movslq %ecx, %rdx
callq 0x61a0
incl %ebp
movl %ebp, 0x5adc05(%rip)    # 0x5f730c
movslq 0x5ade02(%rip), %rcx    # 0x5f7510
leaq 0x5adbfb(%rip), %rax    # 0x5f7310
movb %r14b, (%rcx,%rax)
leal 0x1(%rcx), %eax
movl %eax, 0x5addee(%rip)    # 0x5f7510
movl 0x5a5c0(%rip), %eax     # 0xa3ce8
cmpl %eax, %ecx
jl 0x496ac
incl 0x5adbd6(%rip)          # 0x5f7308
incl %eax
jmp 0x497bd
cmpl $0x7f, %r14d
jne 0x496ac
movl $0x6, %edi
jmp 0x4984e
movl $0xa, %edi
jmp 0x4984e
movl $0xd, %edi
jmp 0x4984e
movl $0xc, %edi
jmp 0x4984e
movl 0x5adb9b(%rip), %ecx    # 0x5f730c
movl %ecx, 0x5add99(%rip)    # 0x5f7510
movl %ecx, 0x5a56b(%rip)     # 0xa3ce8
movl 0x5a559(%rip), %eax     # 0xa3cdc
addl $-0x4, %eax
subl %eax, %ecx
movl %ecx, 0x5adb7a(%rip)    # 0x5f7308
jns 0x496ac
movl $0x0, 0x5adb6a(%rip)    # 0x5f7308
jmp 0x497bd
xorl %ebx, %ebx
movl %ebx, 0x5adb64(%rip)    # 0x5f730c
movl %ebx, 0x5add62(%rip)    # 0x5f7510
movl %ebx, 0x5adb54(%rip)    # 0x5f7308
movl 0x5a522(%rip), %eax     # 0xa3cdc
addl $-0x4, %eax
movl %eax, 0x5a525(%rip)     # 0xa3ce8
jmp 0x496ac
movl 0x5add42(%rip), %eax    # 0x5f7510
testl %eax, %eax
jle 0x497da
decl %eax
movl %eax, 0x5add36(%rip)    # 0x5f7510
movl 0x5add30(%rip), %eax    # 0x5f7510
movl %eax, %ecx
subl 0x5adb20(%rip), %ecx    # 0x5f7308
jge 0x496ac
addl %ecx, 0x5a4f4(%rip)     # 0xa3ce8
movl %eax, 0x5adb0e(%rip)    # 0x5f7308
jmp 0x496ac
movl $0x8, %edi
jmp 0x4984e
movl 0x5add04(%rip), %eax    # 0x5f7510
cmpl 0x5adafa(%rip), %eax    # 0x5f730c
jge 0x4981c
incl %eax
movl %eax, 0x5adcf4(%rip)    # 0x5f7510
movl 0x5adcee(%rip), %eax    # 0x5f7510
movl %eax, %ecx
subl 0x5a4be(%rip), %ecx     # 0xa3ce8
jl 0x496ac
addl %ecx, 0x5adad2(%rip)    # 0x5f7308
jmp 0x497bd
movl 0x5adcd2(%rip), %eax    # 0x5f7510
movl %eax, 0x5adac8(%rip)    # 0x5f730c
jmp 0x496ac
movl $0xe, %edi
callq 0x49858
jmp 0x496ac