// File: /workspace/github_cpp_makefile_star2_O1/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 0x20009c(%rip), %eax    # 0x21b240
subl 0x1fd6d6(%rip), %eax    # 0x218880
movl %eax, 0x200090(%rip)    # 0x21b240
js 0x1b2e5
cmpl 0x200210(%rip), %eax    # 0x21b3cc
jge 0x1b2e5
movl 0x20007c(%rip), %ecx    # 0x21b244
movl 0x1fd6ae(%rip), %edx    # 0x21887c
cmpl %edx, %ecx
jl 0x1b2e5
addl 0x1fd6ac(%rip), %edx    # 0x218888
cmpl %edx, %ecx
jge 0x1b2e5
movl %edi, %ebx
movl %eax, 0x200064(%rip)    # 0x21b250
movl $0xa, %edi
callq 0xefb4
movslq 0x200043(%rip), %rax    # 0x21b240
cmpl %eax, 0x20008d(%rip)    # 0x21b290
jne 0x1b213
movl 0x200089(%rip), %ecx    # 0x21b294
cmpl 0x200033(%rip), %ecx    # 0x21b244
je 0x1b21a
orb $0x1, 0x200040(%rip)    # 0x21b25a
imulq 0x20017e(%rip), %rax    # 0x21b3a0
movslq 0x2001a7(%rip), %rcx    # 0x21b3d0
cqto
idivq %rcx
addq 0x200033(%rip), %rax    # 0x21b268
movq 0x2000e4(%rip), %rdx    # 0x21b320
movslq %eax, %rcx
movq %rcx, %rax
subq %rdx, %rax
jge 0x1b23c
cmpq 0x20002a(%rip), %rcx    # 0x21b278
je 0x1b257
movq %rcx, 0x200029(%rip)    # 0x21b280
movq %rcx, 0x20002a(%rip)    # 0x21b288
movq %rcx, 0x200013(%rip)    # 0x21b278
movb $0x1, 0x1fffec(%rip)    # 0x21b258
cmpb $0x0, 0x1fffab(%rip)    # 0x21b21e
setne %al
cmpl $0x0, 0x324ef7(%rip)    # 0x340174
setne %cl
andb %al, %cl
movzbl %cl, %ecx
movl $0x2, %eax
subl %ecx, %eax
movl 0x1fffca(%rip), %ecx    # 0x21b25c
xorl %eax, %ecx
movl 0x1fffc6(%rip), %edx    # 0x21b260
movl %ecx, %esi
orl %edx, %esi
jne 0x1b2ec
movb $0x0, 0x20011e(%rip)    # 0x21b3c5
movl $0x0, 0x20010f(%rip)    # 0x21b3c0
movq $0x0, 0x221a94(%rip) # 0x23cd50
movq 0x1fffb5(%rip), %rax    # 0x21b278
movq %rax, 0x1fffe6(%rip)    # 0x21b2b0
movl $0x1, 0x324c24(%rip)    # 0x33fef8
xorl %edi, %edi
callq 0x1b3a7
movl $0x0, 0x324c13(%rip)    # 0x33fef8
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
xorl %eax, %edx
orl %edx, %ecx
jne 0x1b36c
movl $0x2710, %edi           # imm = 0x2710
callq 0x9540
movl 0x325316(%rip), %eax    # 0x340618
incl %eax
movl %eax, 0x32530e(%rip)    # 0x340618
cmpb $0x0, 0x2f2dab(%rip)    # 0x30e0bc
je 0x1b34b
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 0x1ffee0(%rip), %eax    # 0x21b218
jne 0x1b34b
incl 0x1ffed8(%rip)          # 0x21b218
callq 0x1b42d
decl 0x1ffecd(%rip)          # 0x21b218
movq 0x2219fe(%rip), %rax    # 0x23cd50
leaq 0x1(%rax), %rcx
movq %rcx, 0x2219f3(%rip)    # 0x23cd50
cmpq $0x8, %rax
jg 0x1b2bc
jmp 0x1b2e5
testl %ebx, %ebx
je 0x1b397
movb $0x0, 0x20004e(%rip)    # 0x21b3c5
movl $0x0, 0x20003f(%rip)    # 0x21b3c0
movq $0x0, 0x2219c4(%rip) # 0x23cd50
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1b6f7
movq $0x0, 0x2219ae(%rip) # 0x23cd50
jmp 0x1b2e5