// File: jkingan[P]ladyheather/heathui.cpp
// Function: build_string(int)
int build_string(int c)
{
u32 val;
int not_upper;
int i;

   // add a character to or edit the input string

   val = toupper(c & 0x7F);
if(getting_string == CALC_CMD) {
   i = rpn_mode;
   rpn_mode = 1;
   show_version_header();
   rpn_mode = i;
}

   // we are building a text string from the keystrokes / script input
   c = edit_string(c);     // attempt to add char to the string
   if(getting_string == SORT_CMD) {  // royal kuldge for GCC, GCG, GCZ, and GCT keyboard commands
      if(val == 'C') goto quick_cmd;  // GCC
      if(val == 'T') goto quick_cmd;  // GCT
      if(val == 'X') goto quick_cmd;  // GCX
      if(val == 'Z') goto quick_cmd;  // GCZ
      if(val == 'G') {
         getting_string = SAT_PLOT_CMD;
         goto quick_cmd;  // GCG
      }
   }
   else if(getting_string == TIDE_CMD) {  // royal kludge for GKx earth tide / gravity plot control
      goto quick_cmd;
   }

   if(getting_string < 0x0100) not_upper = !isupper(getting_string);
   else                        not_upper = 1;

   if(c == ESC_CHAR) {     // edit abandoned
      goto abandon_edit;
   }
   else if((c == 0x0D) && (edit_buffer[0] == 0) && ignore_blank_line(getting_string)) {  // blank input line
      // CR with no text in edit buffer
      abandon_edit:
      getting_string = 0;
      script_pause = 0;
      if(text_mode) redraw_screen();
      else if(rcvr_type == NO_RCVR) erase_plot(FULL_ERASE_OK);
      else if((PLOT_WIDTH/TEXT_WIDTH) <= 80) erase_plot(FULL_ERASE_OK);
   }
   else if(c == 0x0D) { // edit done, parameter available,  do the command
      quick_cmd:
      script_pause = 0;
      val = string_param();  // evaluate and act upon the text string
      getting_string = 0;

      if(val == NEED_NEW_QUEUES) new_queue(RESET_ALL_QUEUES, 10);
      else if(val == NEED_SCREEN_REDRAW) redraw_screen();
      else if(rcvr_type == NO_RCVR) erase_plot(FULL_ERASE_OK);
      else if((PLOT_WIDTH/TEXT_WIDTH) <= 80) erase_plot(FULL_ERASE_OK);
   }
   else if(getting_string == ADEV_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
// else if(getting_string == ADEV_BIN_CMD) {  // !!! kludge to make parsing command easier !!!
//    goto quick_cmd;
// }
   else if(getting_string == SIGNAL_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
   else if(getting_string == STAT_CMD) {  // !!! kludge to make parsing command easier !!!
      goto quick_cmd;
   }
   else return 0;  // character was added to the edit string

   return sure_exit();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %edi
andl $0x7f, %edi
callq 0x96e0
movl %eax, -0xc(%rbp)
leaq 0x361038(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x180, %eax            # imm = 0x180
jne 0x3d7e4
leaq 0x35d247(%rip), %rax    # 0x39aa08
movl (%rax), %eax
movl %eax, -0x14(%rbp)
leaq 0x35d23b(%rip), %rax    # 0x39aa08
movl $0x1, (%rax)
callq 0x9c6d0
movl -0x14(%rbp), %ecx
leaq 0x35d226(%rip), %rax    # 0x39aa08
movl %ecx, (%rax)
movl -0x8(%rbp), %edi
callq 0x3c8e0
movzbl %al, %eax
movl %eax, -0x8(%rbp)
leaq 0x360fef(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x250, %eax            # imm = 0x250
jne 0x3d848
cmpl $0x43, -0xc(%rbp)
jne 0x3d80e
jmp 0x3d950
cmpl $0x54, -0xc(%rbp)
jne 0x3d819
jmp 0x3d950
cmpl $0x58, -0xc(%rbp)
jne 0x3d824
jmp 0x3d950
cmpl $0x5a, -0xc(%rbp)
jne 0x3d82f
jmp 0x3d950
cmpl $0x47, -0xc(%rbp)
jne 0x3d846
leaq 0x360fac(%rip), %rax    # 0x39e7e8
movw $0x252, (%rax)          # imm = 0x252
jmp 0x3d950
jmp 0x3d860
leaq 0x360f99(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x251, %eax            # imm = 0x251
jne 0x3d85e
jmp 0x3d950
jmp 0x3d860
leaq 0x360f81(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x100, %eax            # imm = 0x100
jge 0x3d892
leaq 0x360f70(%rip), %rax    # 0x39e7e8
movzwl (%rax), %edi
callq 0x9250
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x10(%rbp)
jmp 0x3d899
movl $0x1, -0x10(%rbp)
cmpl $0x1b, -0x8(%rbp)
jne 0x3d8a1
jmp 0x3d8d4
cmpl $0xd, -0x8(%rbp)
jne 0x3d944
leaq 0x360c0e(%rip), %rax    # 0x39e4c0
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x3d944
leaq 0x360f23(%rip), %rax    # 0x39e7e8
movzwl (%rax), %edi
callq 0x3d280
cmpl $0x0, %eax
je 0x3d944
jmp 0x3d8d4
leaq 0x360f0d(%rip), %rax    # 0x39e7e8
movw $0x0, (%rax)
leaq 0x2607c9(%rip), %rax    # 0x29e0b0
movb $0x0, (%rax)
leaq 0x23a0c7(%rip), %rax    # 0x2779b8
cmpl $0x0, (%rax)
je 0x3d8fd
callq 0x12ae0
jmp 0x3d93f
leaq 0x23a1ac(%rip), %rax    # 0x277ab0
cmpq $0x400, (%rax)          # imm = 0x400
jne 0x3d919
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d10
jmp 0x3d93d
leaq 0x23a144(%rip), %rax    # 0x277a64
movl (%rax), %eax
leaq 0x23a0c7(%rip), %rcx    # 0x2779f0
cltd
idivl (%rcx)
cmpl $0x50, %eax
jg 0x3d93b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d10
jmp 0x3d93d
jmp 0x3d93f
jmp 0x3da22
cmpl $0xd, -0x8(%rbp)
jne 0x3d9db
jmp 0x3d950
leaq 0x260759(%rip), %rax    # 0x29e0b0
movb $0x0, (%rax)
callq 0x3da40
movzbl %al, %eax
movl %eax, -0xc(%rbp)
leaq 0x360e7c(%rip), %rax    # 0x39e7e8
movw $0x0, (%rax)
cmpl $0x2, -0xc(%rbp)
jne 0x3d988
movl $0x7, %edi
movl $0xa, %esi
callq 0x14df0
jmp 0x3d9d9
cmpl $0x1, -0xc(%rbp)
jne 0x3d995
callq 0x12ae0
jmp 0x3d9d7
leaq 0x23a114(%rip), %rax    # 0x277ab0
cmpq $0x400, (%rax)          # imm = 0x400
jne 0x3d9b1
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d10
jmp 0x3d9d5
leaq 0x23a0ac(%rip), %rax    # 0x277a64
movl (%rax), %eax
leaq 0x23a02f(%rip), %rcx    # 0x2779f0
cltd
idivl (%rcx)
cmpl $0x50, %eax
jg 0x3d9d3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11d10
jmp 0x3d9d5
jmp 0x3d9d7
jmp 0x3d9d9
jmp 0x3da20
leaq 0x360e06(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x61, %eax
jne 0x3d9ef
jmp 0x3d950
leaq 0x360df2(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x51, %eax
jne 0x3da03
jmp 0x3d950
leaq 0x360dde(%rip), %rax    # 0x39e7e8
movzwl (%rax), %eax
cmpl $0x7e, %eax
jne 0x3da17
jmp 0x3d950
movl $0x0, -0x4(%rbp)
jmp 0x3da2c
jmp 0x3da22
jmp 0x3da24
callq 0x37720
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)