// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heather.cpp
// Function: dump_screen(int, int, char*)
int dump_screen(int invert, int top_line, char *fn)
{
int x, y;
int redraw;
int do_gif;

   strcpy(out, fn);
   if(strstr(out, ".") == 0) {
      #ifdef GIF_FILES
         strcat(out, ".gif");
      #else
         strcat(out, ".bmp");
      #endif
   }

   bmp_file = topen(out, "wb");
   if(bmp_file == 0) return 0;

   strlwr(out);
   if(strstr(out, ".gif") || strstr(out, ".GIF")) do_gif = 1;
   else do_gif = 0;

   redraw = 0;
   if(mouse_plot_valid && (last_mouse_x >= 0)) {
      if(0) {
         x = PLOT_COL+last_mouse_x;
         y = PLOT_ROW+8;
         line(x-1,PLOT_ROW, x-1,y, WHITE);
         line(x+0,PLOT_ROW, x+0,y, WHITE);
         line(x+1,PLOT_ROW, x+1,y, WHITE);
         line(x-3,y+1,  x+3,y+1, WHITE);
         line(x-2,y+2,  x+2,y+2, WHITE);
         line(x-1,y+3,  x+1,y+3, WHITE);
         line(x-0,y+4,  x+0,y+4, WHITE);
      }
      else {
         x = PLOT_COL+last_mouse_x;
         y = last_mouse_y;
         thick_line(x-5,y-5, x+5,y+5, WHITE, 2);
         thick_line(x+5,y-5, x-5,y+5, WHITE, 2);

//       line(x-5,y-5, x+5,y-5, WHITE);
//       line(x-5,y+5, x+5,y+5, WHITE);
//       line(x-5,y-5, x-5,y+5, WHITE);
//       line(x+5,y-5, x+5,y+5, WHITE);
      }
      redraw = 1;
   }

   if(do_screen_dump == 0) {  // keyboard commanded dump
      BEEP(5);                // beep because this can take a while to do
   }

#ifdef USE_X11   // capture the screen image into a buffer
   if(display == 0) return 0;
   if(capture_image) XDestroyImage(capture_image);
   SWAP(SCREEN_WIDTH, SCREEN_HEIGHT);
   capture_image = XGetImage(display,win, 0,0, SCREEN_WIDTH,SCREEN_HEIGHT, AllPlanes,XYPixmap);
   SWAP(SCREEN_WIDTH, SCREEN_HEIGHT);
#endif

   #ifdef GIF_FILES
      if(do_gif) {
         dump_gif_file(invert, top_line, bmp_file);
      }
      else
   #endif
   {
      dump_bmp_file(invert, top_line);
   }

   fclose(bmp_file);
   bmp_file = 0;

#ifdef USE_X11  // free uo the image capture buffer
   if(capture_image) XDestroyImage(capture_image);
   capture_image = 0;
#endif

   if(do_screen_dump == 0) {
      BEEP(6);
   }

   if(redraw) redraw_screen();
   return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl %edi, %r14d
leaq 0x32c9d9(%rip), %r15    # 0x33c220
movq %r15, %rdi
movq %rdx, %rsi
callq 0x9340
movq %r15, %rdi
movl $0x2e, %esi
callq 0x9100
testq %rax, %rax
jne 0xf87a
movq %r15, %rdi
callq 0x9120
movl $0x6669672e, (%rax,%r15) # imm = 0x6669672E
movb $0x0, 0x4(%rax,%r15)
leaq 0x32c99f(%rip), %rdi    # 0x33c220
leaq 0xfa6d6(%rip), %rsi     # 0x109f5e
callq 0x9a4d
movq %rax, 0x3308cc(%rip)    # 0x340160
testq %rax, %rax
je 0xfaa0
movl %ebx, -0x3c(%rbp)
movb 0x32c97a(%rip), %al     # 0x33c220
testb %al, %al
je 0xf8c5
leaq 0x32c970(%rip), %rbx    # 0x33c221
movsbl %al, %edi
callq 0x9580
movb %al, -0x1(%rbx)
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0xf8b1
leaq 0x32c954(%rip), %rdi    # 0x33c220
leaq 0xfb30d(%rip), %rsi     # 0x10abe0
callq 0x9090
testq %rax, %rax
movl %r14d, -0x38(%rbp)
je 0xf8ea
movl $0x0, -0x30(%rbp)
jmp 0xf906
leaq 0x32c92f(%rip), %rdi    # 0x33c220
leaq 0xfa669(%rip), %rsi     # 0x109f61
callq 0x9090
testq %rax, %rax
sete %al
movl %eax, -0x30(%rbp)
cmpb $0x0, 0x20b94b(%rip)    # 0x21b258
sete %cl
movl 0x20b97a(%rip), %eax    # 0x21b290
testl %eax, %eax
sets %dl
orb %cl, %dl
movb %dl, -0x29(%rbp)
jne 0xf9d5
movl 0x208f54(%rip), %ecx    # 0x218880
movl 0x20b962(%rip), %edx    # 0x21b294
leal (%rcx,%rax), %esi
addl $-0x5, %esi
movq %rsi, -0x50(%rbp)
addl %ecx, %eax
addl $0x5, %eax
movq %rax, -0x48(%rbp)
addl $0x5, %edx
movl %edx, -0x34(%rbp)
xorl %ebx, %ebx
movq -0x50(%rbp), %rax
leal (%rbx,%rax), %r15d
movq -0x48(%rbp), %rax
leal (%rbx,%rax), %r12d
movl $0x2, %r14d
movl -0x34(%rbp), %eax
movl %eax, %r13d
leal -0xa(%r13), %esi
movl %r15d, %edi
movl %r12d, %edx
movl %r13d, %ecx
movl $0xf, %r8d
callq 0xe3c3
incl %r13d
decl %r14d
jne 0xf969
incl %ebx
cmpl $0x2, %ebx
jne 0xf94d
xorl %ebx, %ebx
movq -0x48(%rbp), %rax
leal (%rbx,%rax), %r15d
movq -0x50(%rbp), %rax
leal (%rbx,%rax), %r12d
movl $0x2, %r14d
movl -0x34(%rbp), %eax
movl %eax, %r13d
leal -0xa(%r13), %esi
movl %r15d, %edi
movl %r12d, %edx
movl %r13d, %ecx
movl $0xf, %r8d
callq 0xe3c3
incl %r13d
decl %r14d
jne 0xf9ae
incl %ebx
cmpl $0x2, %ebx
jne 0xf992
cmpb $0x0, 0x2fe5be(%rip)    # 0x30df9a
jne 0xf9e8
movl $0x5, %edi
callq 0x9d80
cmpq $0x0, 0x1614d0(%rip)    # 0x170ec0
movl -0x3c(%rbp), %ebx
movl -0x38(%rbp), %r14d
je 0xfaa0
movq 0x33054c(%rip), %rdi    # 0x33ff50
testq %rdi, %rdi
je 0xfa0c
callq *0x60(%rdi)
cmpl $0x0, 0x208e15(%rip)    # 0x218828
je 0xfa33
movl 0x208de9(%rip), %eax    # 0x218804
movl %eax, 0x208e0b(%rip)    # 0x21882c
movl 0x208dd9(%rip), %ecx    # 0x218800
movl %ecx, 0x208dd7(%rip)    # 0x218804
movl %eax, 0x208dcd(%rip)    # 0x218800
movq 0x161486(%rip), %rdi    # 0x170ec0
movq 0x16148f(%rip), %rsi    # 0x170ed0
movl 0x208db8(%rip), %r8d    # 0x218800
movl 0x208db5(%rip), %r9d    # 0x218804
xorl %edx, %edx
xorl %ecx, %ecx
pushq $0x1
pushq $-0x1
callq 0x9040
addq $0x10, %rsp
movq %rax, 0x3304e9(%rip)    # 0x33ff50
cmpl $0x0, 0x208dba(%rip)    # 0x218828
je 0xfa8e
movl 0x208d8e(%rip), %eax    # 0x218804
movl %eax, 0x208db0(%rip)    # 0x21882c
movl 0x208d7e(%rip), %ecx    # 0x218800
movl %ecx, 0x208d7c(%rip)    # 0x218804
movl %eax, 0x208d72(%rip)    # 0x218800
cmpb $0x0, -0x30(%rbp)
je 0xfaa4
movl %r14d, %edi
movl %ebx, %esi
callq 0xf60e
jmp 0xfab5
xorl %ebx, %ebx
jmp 0xfb09
movq 0x3306b5(%rip), %rdx    # 0x340160
movl %r14d, %edi
movl %ebx, %esi
callq 0x1043b0
movq 0x3306a4(%rip), %rdi    # 0x340160
callq 0x9370
movq $0x0, 0x330694(%rip) # 0x340160
movq 0x33047d(%rip), %rdi    # 0x33ff50
testq %rdi, %rdi
je 0xfadb
callq *0x60(%rdi)
movq $0x0, 0x33046a(%rip) # 0x33ff50
cmpb $0x0, 0x2fe4ad(%rip)    # 0x30df9a
jne 0xfaf9
movl $0x6, %edi
callq 0x9d80
movl $0x1, %ebx
cmpb $0x0, -0x29(%rbp)
jne 0xfb09
callq 0xfb1a
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq