// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
andl $0x7f, %edi
callq 0x9700
movl %eax, %r15d
leaq 0x2ffc16(%rip), %r12    # 0x329608
cmpw $0x180, (%r12)          # imm = 0x180
jne 0x29a14
leaq 0x2fbe26(%rip), %r14    # 0x325828
movl (%r14), %r13d
movl $0x1, (%r14)
callq 0x68b5b
movl %r13d, (%r14)
movl %ebx, %edi
callq 0x290b2
movzwl (%r12), %ebx
cmpl $0x251, %ebx            # imm = 0x251
je 0x29a48
movl %eax, %r14d
cmpl $0x250, %ebx            # imm = 0x250
jne 0x29a88
addl $-0x43, %r15d
cmpl $0x17, %r15d
ja 0x29a88
movl $0xa20001, %eax         # imm = 0xA20001
btl %r15d, %eax
jae 0x29a79
leaq 0x1ff481(%rip), %rax    # 0x228ed0
movb $0x0, (%rax)
callq 0x29b41
andw $0x0, (%r12)
cmpb $0x1, %al
je 0x29acb
movzbl %al, %eax
cmpl $0x2, %eax
jne 0x29ad2
pushq $0x7
popq %rdi
pushq $0xa
popq %rsi
callq 0x10a99
jmp 0x29b02
cmpl $0x4, %r15d
jne 0x29a88
movw $0x252, (%r12)          # imm = 0x252
jmp 0x29a48
cmpb $0x1b, %r14b
je 0x29aaf
cmpb $0xd, %r14b
jne 0x29b18
leaq 0x2ff841(%rip), %rax    # 0x3292e0
cmpb $0x0, (%rax)
jne 0x29b18
movl %ebx, %edi
callq 0x29732
testl %eax, %eax
je 0x29b18
andw $0x0, (%r12)
leaq 0x1ff414(%rip), %rax    # 0x228ed0
movb $0x0, (%rax)
leaq 0x1d8d12(%rip), %rax    # 0x2027d8
cmpl $0x0, (%rax)
je 0x29ad2
callq 0xf426
jmp 0x29b02
leaq 0x1d8df7(%rip), %rax    # 0x2028d0
cmpq $0x400, (%rax)          # imm = 0x400
je 0x29afa
leaq 0x1d8d9b(%rip), %rax    # 0x202884
movl (%rax), %eax
leaq 0x1d8d1e(%rip), %rcx    # 0x202810
cltd
idivl (%rcx)
cmpl $0x50, %eax
jg 0x29b02
pushq $-0x1
popq %rdi
callq 0xeaef
callq 0x258cd
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0xd, %r14b
je 0x29a48
cmpw $0x7e, %bx
je 0x29a48
cmpw $0x61, %bx
je 0x29a48
cmpw $0x51, %bx
jne 0x29b07
jmp 0x29a48