// File: /workspace/github_cpp_makefile_star2_O3/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 0x200079(%rip), %eax    # 0x21b240
subl 0x1fd6b3(%rip), %eax    # 0x218880
movl %eax, 0x20006d(%rip)    # 0x21b240
js 0x1b301
cmpl 0x2001ed(%rip), %eax    # 0x21b3cc
jge 0x1b301
movl 0x200059(%rip), %ecx    # 0x21b244
movl 0x1fd68b(%rip), %edx    # 0x21887c
cmpl %edx, %ecx
jl 0x1b301
addl 0x1fd689(%rip), %edx    # 0x218888
cmpl %edx, %ecx
jge 0x1b301
movl %edi, %ebx
movl %eax, 0x200041(%rip)    # 0x21b250
movl $0xa, %edi
callq 0xef35
movslq 0x200020(%rip), %rax    # 0x21b240
cmpl %eax, 0x20006a(%rip)    # 0x21b290
jne 0x1b236
movl 0x200066(%rip), %ecx    # 0x21b294
cmpl 0x200010(%rip), %ecx    # 0x21b244
je 0x1b23d
orb $0x1, 0x20001d(%rip)    # 0x21b25a
imulq 0x20015b(%rip), %rax    # 0x21b3a0
movslq 0x200184(%rip), %rcx    # 0x21b3d0
cqto
idivq %rcx
addq 0x200010(%rip), %rax    # 0x21b268
movq 0x2000c1(%rip), %rdx    # 0x21b320
movslq %eax, %rcx
movq %rcx, %rax
subq %rdx, %rax
jge 0x1b25f
cmpq 0x200007(%rip), %rcx    # 0x21b278
je 0x1b27a
movq %rcx, 0x200006(%rip)    # 0x21b280
movq %rcx, 0x200007(%rip)    # 0x21b288
movq %rcx, 0x1ffff0(%rip)    # 0x21b278
movb $0x1, 0x1fffc9(%rip)    # 0x21b258
cmpb $0x0, 0x1fff88(%rip)    # 0x21b21e
setne %al
cmpl $0x0, 0x324ed4(%rip)    # 0x340174
setne %dl
andb %al, %dl
movzbl %dl, %edx
movl $0x2, %eax
subl %edx, %eax
movl 0x1fffa7(%rip), %edx    # 0x21b25c
xorl %eax, %edx
movl 0x1fffa3(%rip), %esi    # 0x21b260
movl %edx, %edi
orl %esi, %edi
jne 0x1b308
movb $0x0, 0x2000fb(%rip)    # 0x21b3c5
movl $0x0, 0x2000ec(%rip)    # 0x21b3c0
movq $0x0, 0x221a71(%rip) # 0x23cd50
movq %rcx, 0x1fffca(%rip)    # 0x21b2b0
movl $0x1, 0x324c08(%rip)    # 0x33fef8
xorl %edi, %edi
callq 0x1b3c6
movl $0x0, 0x324bf7(%rip)    # 0x33fef8
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %esi
orl %esi, %edx
jne 0x1b38b
movl $0x2710, %edi           # imm = 0x2710
callq 0x9540
movl 0x3252fa(%rip), %eax    # 0x340618
incl %eax
movl %eax, 0x3252f2(%rip)    # 0x340618
cmpb $0x0, 0x2f2d8f(%rip)    # 0x30e0bc
je 0x1b367
movslq %eax, %rcx
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x23, %rcx
addl %edx, %ecx
shll $0x2, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
orl 0x1ffec4(%rip), %eax    # 0x21b218
jne 0x1b367
incl 0x1ffebc(%rip)          # 0x21b218
callq 0x1b44c
decl 0x1ffeb1(%rip)          # 0x21b218
movq 0x2219e2(%rip), %rax    # 0x23cd50
leaq 0x1(%rax), %rcx
movq %rcx, 0x2219d7(%rip)    # 0x23cd50
cmpq $0x9, %rax
jl 0x1b301
movq 0x1ffef2(%rip), %rcx    # 0x21b278
jmp 0x1b2df
testl %ebx, %ebx
je 0x1b3b6
movb $0x0, 0x20002f(%rip)    # 0x21b3c5
movl $0x0, 0x200020(%rip)    # 0x21b3c0
movq $0x0, 0x2219a5(%rip) # 0x23cd50
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1b720
movq $0x0, 0x22198f(%rip) # 0x23cd50
jmp 0x1b301