// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: do_plot_click(int)
void do_plot_click(int click)
{
static int mouse_sleeps = 0;
int right_button;
S32 i;

#define MOUSE_SLEEP  10    // msec delay between testing for next mouse state while right_click scrolling
#define SCROLL_SERVE 200   // serve_gps() every this many msecs while right_click scrolling

   // process a click in the plot area

   mouse_x -= PLOT_COL;
   if((mouse_x >= 0) && (mouse_x < plot_column) && (mouse_y >= PLOT_ROW) && (mouse_y < (PLOT_ROW+PLOT_HEIGHT))) { // mouse is in the plot area
//    show_last_mouse_x(WHITE);      // lmq
      last_plot_mouse_x = mouse_x;
      show_last_mouse_x(GREEN);      // lmq
      if(last_mouse_x != mouse_x) new_mouse_info |= 0x01;
      else if(last_mouse_y != mouse_y) new_mouse_info |= 0x01;

      i = plot_q_col0 + ((view_interval * mouse_x)/plot_mag);
      while(i >= plot_q_size) i -= plot_q_size;
      if(i != last_mouse_q) last_plot_glitch = i;  // mouse was moved
      last_mouse_q = last_plot_mouse_q = i;
      mouse_plot_valid = 1;  // mouse is in the plot area

      right_button = 2;
      if(touch_screen && button_lock) right_button = 1;  // change left button to right button

      if((this_button == right_button) && (last_button == 0)) {  // mark plot and center on it
         view_all_data = 0;
         need_view_auto = 0;
         right_time = 0;

         right_click:
         mark_q_entry[0] = last_mouse_q;  // mark the point

         no_mouse_review = 1; // inhibit recursive call to get_mouse_info
         goto_mark(0);        // center plot on the marked point
         no_mouse_review = 0;
      }
      else if((this_button == right_button) && (last_button == right_button)) {  // scroll plot with right mouse button
         Sleep(MOUSE_SLEEP);
         ++mouse_sleeps;

         // keep gps processing alive approx every 200 msecs while right mouse button scrolling
         if(enable_timer == 0) ;
         else if(timer_serve);
         else if((mouse_sleeps % (SCROLL_SERVE/MOUSE_SLEEP)) == 0) {
            #ifdef WINDOWS
               // windows timer proc does this for us
            #else
               ++timer_serve;
               serve_gps(55);
               --timer_serve;
            #endif  // __linux__  __MACH__   __FreeBSD__
         }

         if(++right_time >= RIGHT_DELAY) goto right_click;
      }
      else if(click) {  // zoom
         view_all_data = 0;
         need_view_auto = 0;
         right_time = 0;
         kbd_zoom();
      }
      else right_time = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl 0x1eac3a(%rip), %eax    # 0x205240
subl 0x1e8274(%rip), %eax    # 0x202880
movl %eax, 0x1eac2e(%rip)    # 0x205240
js 0x1a733
cmpl 0x1eadae(%rip), %eax    # 0x2053cc
jge 0x1a733
movl 0x1eac1a(%rip), %ecx    # 0x205244
movl 0x1e824c(%rip), %edx    # 0x20287c
cmpl %edx, %ecx
jl 0x1a733
addl 0x1e824a(%rip), %edx    # 0x202888
cmpl %edx, %ecx
jge 0x1a733
movl %edi, %ebx
movl %eax, 0x1eac02(%rip)    # 0x205250
pushq $0xa
popq %rdi
callq 0xe9f6
movslq 0x1eabe3(%rip), %rax    # 0x205240
cmpl %eax, 0x1eac2d(%rip)    # 0x205290
jne 0x1a673
movl 0x1eac29(%rip), %ecx    # 0x205294
cmpl 0x1eabd3(%rip), %ecx    # 0x205244
je 0x1a67a
orb $0x1, 0x1eabe0(%rip)    # 0x20525a
imulq 0x1ead1e(%rip), %rax    # 0x2053a0
movslq 0x1ead47(%rip), %rcx    # 0x2053d0
cqto
idivq %rcx
addq 0x1eabd3(%rip), %rax    # 0x205268
movq 0x1eac84(%rip), %rdx    # 0x205320
movslq %eax, %rcx
movq %rcx, %rax
subq %rdx, %rax
jge 0x1a69c
cmpq 0x1eabca(%rip), %rcx    # 0x205278
je 0x1a6b7
movq %rcx, 0x1eabc9(%rip)    # 0x205280
movq %rcx, 0x1eabca(%rip)    # 0x205288
movq %rcx, 0x1eabb3(%rip)    # 0x205278
movb $0x1, 0x1eab8c(%rip)    # 0x205258
cmpb $0x0, 0x1eab4b(%rip)    # 0x20521e
setne %al
cmpl $0x0, 0x30fa97(%rip)    # 0x32a174
setne %dl
andb %al, %dl
movzbl %dl, %edx
pushq $0x2
popq %rax
subl %edx, %eax
movl 0x1eab6c(%rip), %edx    # 0x20525c
xorl %eax, %edx
movl 0x1eab68(%rip), %esi    # 0x205260
movl %edx, %edi
orl %esi, %edi
jne 0x1a73a
andl $0x0, 0x1eacbb(%rip)    # 0x2053c0
movb $0x0, 0x1eacb9(%rip)    # 0x2053c5
andq $0x0, 0x20c63c(%rip)    # 0x226d50
movq %rcx, 0x1eab95(%rip)    # 0x2052b0
movl $0x1, 0x30f7d3(%rip)    # 0x329ef8
xorl %edi, %edi
callq 0x1a7d4
andl $0x0, 0x30f7c5(%rip)    # 0x329ef8
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %esi
orl %esi, %edx
jne 0x1a7a2
pushq $0xa
popq %rdi
callq 0xae83
movl 0x30feca(%rip), %eax    # 0x32a618
incl %eax
movl %eax, 0x30fec2(%rip)    # 0x32a618
cmpb $0x0, 0x2dd95f(%rip)    # 0x2f80bc
je 0x1a77e
pushq $0x14
popq %rcx
cltd
idivl %ecx
orl 0x1eaaad(%rip), %edx    # 0x205218
jne 0x1a77e
incl 0x1eaaa5(%rip)          # 0x205218
callq 0x1a858
decl 0x1eaa9a(%rip)          # 0x205218
movq 0x20c5cb(%rip), %rax    # 0x226d50
leaq 0x1(%rax), %rcx
movq %rcx, 0x20c5c0(%rip)    # 0x226d50
cmpq $0x9, %rax
jl 0x1a733
movq 0x1eaadb(%rip), %rcx    # 0x205278
jmp 0x1a714
testl %ebx, %ebx
je 0x1a7c7
andl $0x0, 0x1eac13(%rip)    # 0x2053c0
movb $0x0, 0x1eac11(%rip)    # 0x2053c5
andq $0x0, 0x20c594(%rip)    # 0x226d50
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1ab02
andq $0x0, 0x20c581(%rip)    # 0x226d50
jmp 0x1a733