// File: /workspace/github_c_makefile_star2_O3/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, 0x5a879f(%rip)    # 0x5f42c8
jne 0x4bb6c
cmpb $0x0, 0x5ac7aa(%rip)    # 0x5f82dc
je 0x4bb6c
cmpl $0x20, %r14d
setge %al
cmpl $0x7f, %r14d
setne %cl
testb %cl, %al
jne 0x4bb7c
xorl %ebx, %ebx
leal -0x1(%r14), %eax
cmpl $0x16, %eax
ja 0x4bc0e
leaq 0x2c004(%rip), %rcx     # 0x77b60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebx, %ebx
jmp 0x4bc7d
movl %r14d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl 0x5ac776(%rip), %eax    # 0x5f82f8
movl 0x5ac784(%rip), %ebp    # 0x5f830c
movl %ebp, %ecx
xorl $0x1ff, %ecx            # imm = 0x1FF
xorl %ebx, %ebx
orl %eax, %ecx
je 0x4bb6f
movl 0x5ac973(%rip), %r15d   # 0x5f8510
testl %eax, %eax
je 0x4bbaa
movl %ebp, %eax
cmpl %r15d, %ebp
je 0x4bbd1
jmp 0x4bbdc
movl %ebp, %eax
subl %r15d, %eax
jle 0x4bbce
movslq %r15d, %rcx
leaq 0x5ac755(%rip), %rdx    # 0x5f8310
leaq (%rdx,%rcx), %rsi
leaq (%rcx,%rdx), %rdi
incq %rdi
movslq %eax, %rdx
callq 0x61a0
movl %r15d, %eax
incl %ebp
movl %ebp, 0x5ac733(%rip)    # 0x5f830c
movl %eax, %r15d
movslq %r15d, %rcx
leaq 0x5ac72a(%rip), %rax    # 0x5f8310
movb %r14b, (%rcx,%rax)
leal 0x1(%rcx), %eax
movl %eax, 0x5ac91d(%rip)    # 0x5f8510
movl 0x590ef(%rip), %eax     # 0xa4ce8
cmpl %eax, %ecx
jl 0x4bb6f
incl 0x5ac701(%rip)          # 0x5f8308
incl %eax
jmp 0x4bc92
cmpl $0x7f, %r14d
jne 0x4bb6f
movl $0x6, %edi
jmp 0x4bd17
movl $0xa, %edi
jmp 0x4bd17
movl $0xd, %edi
jmp 0x4bd17
movl $0xc, %edi
jmp 0x4bd17
movl 0x5ac6c6(%rip), %ecx    # 0x5f830c
movl %ecx, 0x5ac8c4(%rip)    # 0x5f8510
movl %ecx, 0x59096(%rip)     # 0xa4ce8
movl 0x59084(%rip), %eax     # 0xa4cdc
addl $-0x4, %eax
subl %eax, %ecx
movl %ecx, 0x5ac6a5(%rip)    # 0x5f8308
jns 0x4bb6f
movl $0x0, 0x5ac695(%rip)    # 0x5f8308
jmp 0x4bc92
xorl %ebx, %ebx
movl %ebx, 0x5ac68f(%rip)    # 0x5f830c
movl %ebx, 0x5ac88d(%rip)    # 0x5f8510
movl %ebx, 0x5ac67f(%rip)    # 0x5f8308
movl 0x5904d(%rip), %eax     # 0xa4cdc
addl $-0x4, %eax
movl %eax, 0x59050(%rip)     # 0xa4ce8
jmp 0x4bb6f
movl 0x5ac86d(%rip), %eax    # 0x5f8510
testl %eax, %eax
jle 0x4bcaf
decl %eax
movl %eax, 0x5ac861(%rip)    # 0x5f8510
movl %eax, %ecx
subl 0x5ac651(%rip), %ecx    # 0x5f8308
jge 0x4bb6f
addl %ecx, 0x59025(%rip)     # 0xa4ce8
movl %eax, 0x5ac63f(%rip)    # 0x5f8308
jmp 0x4bb6f
movl $0x8, %edi
jmp 0x4bd17
movl 0x5ac835(%rip), %eax    # 0x5f8510
cmpl 0x5ac62b(%rip), %eax    # 0x5f830c
jge 0x4bceb
incl %eax
movl %eax, 0x5ac825(%rip)    # 0x5f8510
movl %eax, %ecx
subl 0x58ff5(%rip), %ecx     # 0xa4ce8
jl 0x4bb6f
addl %ecx, 0x5ac609(%rip)    # 0x5f8308
jmp 0x4bc92
movl 0x5ac809(%rip), %eax    # 0x5f8510
movl %eax, 0x5ac5ff(%rip)    # 0x5f830c
jmp 0x4bb6f
movl $0xe, %edi
callq 0x4bd21
jmp 0x4bb6f