// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: draw_azel_grid(int, int, int, int)
void draw_azel_grid(int signals, int grid_x,int grid_y, int grid_r)
{
int az, el;
int x0, y0;
float x1, y1;
float x2, y2;
float elx;
float len;
float r;
int max_el, el_grid;

   x0 = grid_x;
   y0 = grid_y;
   len = (float) grid_r;
   if(signals && (plot_signals == 3)) {
      x0 -= grid_r;
      y0 += grid_r;
      len *= 2.0F;
   }

   x1 = cos360(0) * len;
   y1 = sin360(0) * len;

   for(az=AZ_INCR; az<=360; az+=AZ_INCR) {
      x2 = cos360(az) * len;
      y2 = sin360(az) * len;

      if(signals && (plot_signals == 3) && ((az-AZ_INCR) > 90) && ((az-AZ_INCR) < 360)) {
         goto skip_it;
      }

      if(1 || (plot_signals == 0) || (signals && ((plot_signals >= 4)))) {
         r = 1.03F;  // extend radials out a smidge
         max_el = 90;
         el_grid = 30;
      }
      else {
         r = 1.0F;
         max_el = 100;
         el_grid = 25;
      }

      if(((az-AZ_INCR)%AZ_GRID) == 0) {  // draw azimuth vectors
         line(x0+0,y0-0, 
              x0+(int)(x1*r),y0-(int)(y1*r), azel_grid_color);
         if(signals && plot_signals) {
            if(plot_signals >= 4) tick_radial(grid_x,grid_y,grid_r, 90, (az-AZ_INCR)+270);
            else                  tick_radial(grid_x,grid_y,grid_r,100, (az-AZ_INCR)+270);
         }
      }

      // tick mark the 0 degree elevation circle
      line(x0+(int)(x1*0.99F),y0-(int)(y1*0.99F),  
           x0+(int)(x1*1.03F),y0-(int)(y1*1.03F), azel_grid_color); 

      // dot the satelite elevation mask angle circle
      if(plot_el_mask == 0) ;
      else if((signals == 0) && (map_and_watch || (map_and_sigs == 0) || (zoom_screen == 'B'))) { 
         elx = ((90.0F-el_mask) / 90.0F);
         dot(x0+(int)(x1*elx),y0-(int)(y1*elx), azel_grid_color); 
      }
      else if((plot_signals == 0) || (signals && ((plot_signals > 3)))) { 
         elx = ((90.0F-el_mask) / 90.0F);
         dot(x0+(int)(x1*elx),y0-(int)(y1*elx), azel_grid_color); 
      }

      // draw the elevation circles
//      for(el=0; el<max_el; el+=el_grid) {  
      for(el=0; el<=max_el; el+=el_grid) {  
         if(max_el == 0) break;
         elx = r = ((((float) max_el) - (float) el) / (float) max_el);

         if(plot_el_mask && (el == (int) el_mask) && (el_mask != 0.0F)) {
            continue;  
         }
         if((zoom_screen == 'B') && (el == 0)) continue;
         if(zoom_screen == 'M') ;
         else if(zoom_screen == 'S') ;
         else if(zoom_screen == 'Y') ;
         else if(zoom_screen == 'U') ;
         else if(zoom_screen == 'V') ;
         else if(zoom_screen == 'I') ;
         else if(map_and_watch && (el == 0)) continue;
         if(signals && (plot_signals == 3) && ((az-AZ_INCR) == 90)) continue;

         line(x0+(int)(x1*elx),y0-(int)(y1*elx), 
              x0+(int)(x2*elx),y0-(int)(y2*elx), azel_grid_color);
      }

      skip_it:
      x1 = x2;  y1 = y2;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x20(%rbp)
cvtsi2ssl -0x10(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x1502f5
leaq 0x12a32e(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x1502f5
movl -0x10(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x10(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movss 0x33081(%rip), %xmm0    # 0x18336c
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd 0x32830(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x1ee73(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x96f0
cvtsd2ss %xmm0, %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
xorps %xmm0, %xmm0
movsd 0x32801(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x1ee44(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x9080
cvtsd2ss %xmm0, %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movl $0x5, -0x14(%rbp)
cmpl $0x168, -0x14(%rbp)     # imm = 0x168
jg 0x15083f
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x327bc(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x1edff(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x96f0
cvtsd2ss %xmm0, %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
cvtsi2sdl -0x14(%rbp), %xmm0
movsd 0x3278b(%rip), %xmm1    # 0x182b30
callq 0x94d0
movsd 0x1edce(%rip), %xmm1    # 0x16f180
divsd %xmm1, %xmm0
callq 0x9080
cvtsd2ss %xmm0, %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x1503fb
leaq 0x12a21f(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x1503fb
movl -0x14(%rbp), %eax
subl $0x5, %eax
cmpl $0x5a, %eax
jle 0x1503fb
movl -0x14(%rbp), %eax
subl $0x5, %eax
cmpl $0x168, %eax            # imm = 0x168
jge 0x1503fb
jmp 0x15081d
movss 0x3edbd(%rip), %xmm0    # 0x18f1c0
movss %xmm0, -0x3c(%rbp)
movl $0x5a, -0x40(%rbp)
movl $0x1e, -0x44(%rbp)
movl -0x14(%rbp), %eax
subl $0x5, %eax
movl $0x1e, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1504dc
movl -0x1c(%rbp), %edi
addl $0x0, %edi
movl -0x20(%rbp), %esi
subl $0x0, %esi
movl -0x1c(%rbp), %edx
movss -0x24(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edx
movl -0x20(%rbp), %ecx
movss -0x28(%rbp), %xmm0
mulss -0x3c(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %ecx
leaq 0x24a122(%rip), %rax    # 0x39a588
movl (%rax), %eax
movzbl %al, %r8d
callq 0x109c0
cmpl $0x0, -0x4(%rbp)
je 0x1504da
leaq 0x12a177(%rip), %rax    # 0x27a5f5
cmpb $0x0, (%rax)
je 0x1504da
leaq 0x12a16b(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x4, %eax
jl 0x1504b6
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %r8d
subl $0x5, %r8d
addl $0x10e, %r8d            # imm = 0x10E
movl $0x5a, %ecx
callq 0x150080
jmp 0x1504d8
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %r8d
subl $0x5, %r8d
addl $0x10e, %r8d            # imm = 0x10E
movl $0x64, %ecx
callq 0x150080
jmp 0x1504da
jmp 0x1504dc
movl -0x1c(%rbp), %edi
movss 0x3ecdd(%rip), %xmm0    # 0x18f1c4
mulss -0x24(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edi
movl -0x20(%rbp), %esi
movss 0x3ecc7(%rip), %xmm0    # 0x18f1c4
mulss -0x28(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %esi
movl -0x1c(%rbp), %edx
movss 0x3ecad(%rip), %xmm0    # 0x18f1c0
mulss -0x24(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edx
movl -0x20(%rbp), %ecx
movss 0x3ec97(%rip), %xmm0    # 0x18f1c0
mulss -0x28(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %ecx
leaq 0x24a04d(%rip), %rax    # 0x39a588
movl (%rax), %eax
movzbl %al, %r8d
callq 0x109c0
leaq 0x12a0a9(%rip), %rax    # 0x27a5f6
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x15055a
jmp 0x150671
cmpl $0x0, -0x4(%rbp)
jne 0x1505ee
leaq 0x12a085(%rip), %rax    # 0x27a5f0
cmpb $0x0, (%rax)
jne 0x15058e
leaq 0x12a07a(%rip), %rax    # 0x27a5f1
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x15058e
leaq 0x21b402(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x42, %eax
jne 0x1505ee
movss 0x213ba(%rip), %xmm0    # 0x171950
leaq 0x21bcf7(%rip), %rax    # 0x36c294
subss (%rax), %xmm0
movss 0x213a7(%rip), %xmm1    # 0x171950
divss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x1c(%rbp), %edi
movss -0x24(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edi
movl -0x20(%rbp), %esi
movss -0x28(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %esi
leaq 0x249fa9(%rip), %rax    # 0x39a588
movl (%rax), %eax
movzbl %al, %edx
callq 0x10d70
jmp 0x15066f
leaq 0x12a000(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x150612
cmpl $0x0, -0x4(%rbp)
je 0x15066d
leaq 0x129feb(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x3, %eax
jle 0x15066d
movss 0x21336(%rip), %xmm0    # 0x171950
leaq 0x21bc73(%rip), %rax    # 0x36c294
subss (%rax), %xmm0
movss 0x21323(%rip), %xmm1    # 0x171950
divss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x1c(%rbp), %edi
movss -0x24(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edi
movl -0x20(%rbp), %esi
movss -0x28(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %esi
leaq 0x249f25(%rip), %rax    # 0x39a588
movl (%rax), %eax
movzbl %al, %edx
callq 0x10d70
jmp 0x15066f
jmp 0x150671
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x15081b
cmpl $0x0, -0x40(%rbp)
jne 0x15068f
jmp 0x15081b
cvtsi2ssl -0x40(%rbp), %xmm0
cvtsi2ssl -0x18(%rbp), %xmm1
subss %xmm1, %xmm0
cvtsi2ssl -0x40(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x3c(%rbp)
movss %xmm0, -0x34(%rbp)
leaq 0x129f3f(%rip), %rax    # 0x27a5f6
cmpb $0x0, (%rax)
je 0x1506ea
movl -0x18(%rbp), %eax
leaq 0x21bbce(%rip), %rcx    # 0x36c294
cvttss2si (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1506ea
leaq 0x21bbbf(%rip), %rax    # 0x36c294
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1506e5
jp 0x1506e5
jmp 0x1506ea
jmp 0x15080d
leaq 0x21b297(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x42, %eax
jne 0x150704
cmpl $0x0, -0x18(%rbp)
jne 0x150704
jmp 0x15080d
leaq 0x21b27d(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x4d, %eax
jne 0x150715
jmp 0x15078d
leaq 0x21b26c(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x53, %eax
jne 0x150726
jmp 0x15078b
leaq 0x21b25b(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x59, %eax
jne 0x150737
jmp 0x150789
leaq 0x21b24a(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x55, %eax
jne 0x150748
jmp 0x150787
leaq 0x21b239(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x56, %eax
jne 0x150759
jmp 0x150785
leaq 0x21b228(%rip), %rax    # 0x36b988
movzbl (%rax), %eax
cmpl $0x49, %eax
jne 0x15076a
jmp 0x150783
leaq 0x129e7f(%rip), %rax    # 0x27a5f0
cmpb $0x0, (%rax)
je 0x150781
cmpl $0x0, -0x18(%rbp)
jne 0x150781
jmp 0x15080d
jmp 0x150783
jmp 0x150785
jmp 0x150787
jmp 0x150789
jmp 0x15078b
jmp 0x15078d
cmpl $0x0, -0x4(%rbp)
je 0x1507af
leaq 0x129e5b(%rip), %rax    # 0x27a5f5
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x1507af
movl -0x14(%rbp), %eax
subl $0x5, %eax
cmpl $0x5a, %eax
jne 0x1507af
jmp 0x15080d
movl -0x1c(%rbp), %edi
movss -0x24(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edi
movl -0x20(%rbp), %esi
movss -0x28(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %esi
movl -0x1c(%rbp), %edx
movss -0x2c(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %eax, %edx
movl -0x20(%rbp), %ecx
movss -0x30(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
subl %eax, %ecx
leaq 0x249d86(%rip), %rax    # 0x39a588
movl (%rax), %eax
movzbl %al, %r8d
callq 0x109c0
movl -0x44(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x150678
jmp 0x15081d
movss -0x2c(%rbp), %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x30(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x14(%rbp)
jmp 0x15035a
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)