// File: jkingan[P]ladyheather/heathui.cpp
// Function: edit_error(char*)
int edit_error(char *s)
{
int x;
char out[256+1];
int row,col,width;

   rpn_break = 1;
   edit_err_flag = 1;

   if(reading_lla && (zoom_screen == 'L')) {
      row = TEXT_ROWS-4;
      col = TEXT_COLS/2;
      width = TEXT_COLS/2;
   }
   else {
      row = EDIT_ROW+3;
      col = EDIT_COL;
      width = 80;
   }

   // show an error message and wait for a key press
   vidstr(row+0, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);
   vidstr(row+1, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);
   vidstr(row+2, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);
   vidstr(row+3, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);
   vidstr(row+4, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);
   vidstr(row+5, col, PROMPT_COLOR, &blanks[TEXT_COLS-width]);

   if(script_file) {
      sprintf(out, "Error in script file %s: line %d, col %d: %s",
         script_name, script_line, script_col, s);
      vidstr(row+1, col, PROMPT_COLOR, out);
      vidstr(row+2, col, PROMPT_COLOR, "Press any key to stop script....");
   }
   else {
      vidstr(row+1, col, PROMPT_COLOR, s);
      vidstr(row+2, col, PROMPT_COLOR, "Press any key to continue....");
   }

   if(rpn_mode) {
      BEEP(6566);
   }

   refresh_page();

   //!!! just waiting for a key here would be bad news because
   //    gps data would not be processed and the queue can overflow
   wait_for_key(1);

   vidstr(row+1, col, PROMPT_COLOR, "                                ");
   refresh_page();

   if(KBHIT()) x = GETCH();
   else        x = 0;
   script_fault = 1;

   if(rpn_mode) {
      edit_buffer[0] = 0;
      edit_buffer[1] = 0;
      msg_field[0] = 0;
      nmea_msg[0] = 0;
      msg_col = 0;
      start_calc(123);
      rpn_mode = (-1);
      rpn_err_flag = 1;
   }
   return x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl $0x1, 0x3711b7(%rip)    # 0x3a1f30
movl $0x1, 0x370c95(%rip)    # 0x3a1a18
leaq 0x36972d(%rip), %rax    # 0x39a4b7
cmpb $0x0, (%rax)
je 0x30de0
leaq 0x33abf2(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x4c, %eax
jne 0x30de0
leaq 0x246c47(%rip), %rax    # 0x2779ec
movl (%rax), %eax
subl $0x4, %eax
movl %eax, -0x114(%rbp)
leaq 0x246c31(%rip), %rax    # 0x2779e8
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x118(%rbp)
leaq 0x246c1a(%rip), %rax    # 0x2779e8
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x11c(%rbp)
jmp 0x30e0b
leaq 0x36da05(%rip), %rax    # 0x39e7ec
movl (%rax), %eax
addl $0x3, %eax
movl %eax, -0x114(%rbp)
leaq 0x36d9f7(%rip), %rax    # 0x39e7f0
movl (%rax), %eax
movl %eax, -0x118(%rbp)
movl $0x50, -0x11c(%rbp)
movl -0x114(%rbp), %edi
addl $0x0, %edi
movl -0x118(%rbp), %esi
leaq 0x246bc7(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a3be(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x1, %edi
movl -0x118(%rbp), %esi
leaq 0x246b93(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a38a(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x2, %edi
movl -0x118(%rbp), %esi
leaq 0x246b5f(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a356(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x3, %edi
movl -0x118(%rbp), %esi
leaq 0x246b2b(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a322(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x4, %edi
movl -0x118(%rbp), %esi
leaq 0x246af7(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a2ee(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x5, %edi
movl -0x118(%rbp), %esi
leaq 0x246ac3(%rip), %rax    # 0x2779e8
movl (%rax), %eax
subl -0x11c(%rbp), %eax
cltq
leaq 0x36a2ba(%rip), %rcx    # 0x39b1f0
addq %rax, %rcx
movl $0xb, %edx
callq 0x10ee0
leaq 0x26d14e(%rip), %rax    # 0x29e098
cmpq $0x0, (%rax)
je 0x30fc5
leaq -0x110(%rbp), %rdi
leaq 0x26d142(%rip), %rax    # 0x29e0a0
movl (%rax), %ecx
leaq 0x26d13d(%rip), %rax    # 0x29e0a4
movl (%rax), %r8d
movq -0x8(%rbp), %r9
leaq 0x14843a(%rip), %rsi    # 0x1793af
leaq 0x26d094(%rip), %rdx    # 0x29e010
movb $0x0, %al
callq 0x9060
movl -0x114(%rbp), %edi
addl $0x1, %edi
movl -0x118(%rbp), %esi
leaq -0x110(%rbp), %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x2, %edi
movl -0x118(%rbp), %esi
movl $0xb, %edx
leaq 0x14841e(%rip), %rcx    # 0x1793dc
callq 0x10ee0
jmp 0x31002
movl -0x114(%rbp), %edi
addl $0x1, %edi
movl -0x118(%rbp), %esi
movq -0x8(%rbp), %rcx
movl $0xb, %edx
callq 0x10ee0
movl -0x114(%rbp), %edi
addl $0x2, %edi
movl -0x118(%rbp), %esi
movl $0xb, %edx
leaq 0x148400(%rip), %rcx    # 0x1793fd
callq 0x10ee0
leaq 0x3699ff(%rip), %rax    # 0x39aa08
cmpl $0x0, (%rax)
je 0x31018
movl $0x19a6, %edi           # imm = 0x19A6
callq 0x9ec0
callq 0xb0d0
movl $0x1, %edi
callq 0x29180
movl -0x114(%rbp), %edi
addl $0x1, %edi
movl -0x118(%rbp), %esi
movl $0xb, %edx
leaq 0x16566b(%rip), %rcx    # 0x1966ad
callq 0x10ee0
callq 0xb0d0
callq 0xf3d0
cmpl $0x0, %eax
je 0x31060
callq 0xf3f0
movl %eax, -0xc(%rbp)
jmp 0x31067
movl $0x0, -0xc(%rbp)
leaq 0x26d03e(%rip), %rax    # 0x29e0ac
movl $0x1, (%rax)
leaq 0x36998d(%rip), %rax    # 0x39aa08
cmpl $0x0, (%rax)
je 0x310d7
leaq 0x36d439(%rip), %rax    # 0x39e4c0
movb $0x0, (%rax)
leaq 0x36d42f(%rip), %rax    # 0x39e4c0
movb $0x0, 0x1(%rax)
leaq 0x369b84(%rip), %rax    # 0x39ac20
movb $0x0, (%rax)
leaq 0x36996a(%rip), %rax    # 0x39aa10
movb $0x0, (%rax)
leaq 0x369d74(%rip), %rax    # 0x39ae24
movl $0x0, (%rax)
movl $0x7b, %edi
callq 0x2e6c0
leaq 0x369941(%rip), %rax    # 0x39aa08
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0x1, 0x372821(%rip)    # 0x3a38f8
movl -0xc(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)