// File: /workspace/github_cpp_makefile_star2_O2/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 0x317050(%rip), %r15    # 0x326220
movq %r15, %rdi
movq %rdx, %rsi
callq 0x9330
pushq $0x2e
popq %rsi
movq %r15, %rdi
callq 0x9100
testq %rax, %rax
jne 0xf201
movq %r15, %rdi
callq 0x9120
movl $0x6669672e, (%rax,%r15) # imm = 0x6669672E
movb $0x0, 0x4(%rax,%r15)
leaq 0x317018(%rip), %rdi    # 0x326220
leaq 0xe4daf(%rip), %rsi     # 0xf3fbe
callq 0x9a22
movq %rax, 0x31af45(%rip)    # 0x32a160
testq %rax, %rax
je 0xf34b
leaq 0x316ff5(%rip), %r15    # 0x326220
movq %r15, %rdi
callq 0x986c
leaq 0xe5a31(%rip), %rsi     # 0xf4c6b
movq %r15, %rdi
callq 0x9090
testq %rax, %rax
je 0xf24c
xorl %r12d, %r12d
jmp 0xf266
leaq 0x316fcd(%rip), %rdi    # 0x326220
leaq 0xe4d67(%rip), %rsi     # 0xf3fc1
callq 0x9090
testq %rax, %rax
sete %r12b
cmpb $0x0, 0x1f5feb(%rip)    # 0x205258
sete %cl
movl 0x1f601a(%rip), %eax    # 0x205290
testl %eax, %eax
sets %r15b
orb %cl, %r15b
jne 0xf2f2
movl 0x1f35f9(%rip), %ecx    # 0x202880
movb %r15b, -0x29(%rbp)
movl 0x1f6002(%rip), %r15d   # 0x205294
movl %r12d, -0x30(%rbp)
leal (%rcx,%rax), %r12d
addl $-0x5, %r12d
leal -0x5(%r15), %r13d
movl %r14d, -0x34(%rbp)
movl %ebx, %r14d
leal (%rcx,%rax), %ebx
addl $0x5, %ebx
addl $0x5, %r15d
pushq $0xf
popq %r8
pushq $0x2
popq %r9
movl %r12d, %edi
movl %r13d, %esi
movl %ebx, %edx
movl %r15d, %ecx
callq 0xe5ca
movl %ebx, %edi
movl %r14d, %ebx
movl -0x34(%rbp), %r14d
movl %r13d, %esi
movl %r12d, %edx
movl -0x30(%rbp), %r12d
movl %r15d, %ecx
movb -0x29(%rbp), %r15b
pushq $0xf
popq %r8
pushq $0x2
popq %r9
callq 0xe5ca
cmpb $0x0, 0x2e8ca1(%rip)    # 0x2f7f9a
jne 0xf303
pushq $0x5
popq %rdi
callq 0x9d23
cmpq $0x0, 0x14bbb5(%rip)    # 0x15aec0
je 0xf34b
movq 0x31ac3c(%rip), %rdi    # 0x329f50
testq %rdi, %rdi
je 0xf31c
callq *0x60(%rdi)
cmpl $0x0, 0x1f3505(%rip)    # 0x202828
movl 0x1f34d7(%rip), %eax    # 0x202800
movl 0x1f34d4(%rip), %r8d    # 0x202804
je 0xf352
movl %r8d, 0x1f34f3(%rip)    # 0x20282c
movl %eax, 0x1f34c5(%rip)    # 0x202804
movl %r8d, 0x1f34ba(%rip)    # 0x202800
movl %eax, %r9d
jmp 0xf358
xorl %ebx, %ebx
jmp 0xf415
movl %r8d, %r9d
movl %eax, %r8d
movq 0x14bb61(%rip), %rdi    # 0x15aec0
movq 0x14bb6a(%rip), %rsi    # 0x15aed0
orq $-0x1, (%rsp)
movl $0x1, 0x8(%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x9040
movq %rax, 0x31abcd(%rip)    # 0x329f50
cmpl $0x0, 0x1f349e(%rip)    # 0x202828
je 0xf3aa
movl 0x1f3472(%rip), %eax    # 0x202804
movl %eax, 0x1f3494(%rip)    # 0x20282c
movl 0x1f3462(%rip), %ecx    # 0x202800
movl %ecx, 0x1f3460(%rip)    # 0x202804
movl %eax, 0x1f3456(%rip)    # 0x202800
testb %r12b, %r12b
je 0xf3bb
movl %r14d, %edi
movl %ebx, %esi
callq 0xf014
jmp 0xf3cc
movq 0x31ad9e(%rip), %rdx    # 0x32a160
movl %r14d, %edi
movl %ebx, %esi
callq 0xee24b
movq 0x31ad8d(%rip), %rdi    # 0x32a160
callq 0x9360
andq $0x0, 0x31ad80(%rip)    # 0x32a160
movq 0x31ab69(%rip), %rdi    # 0x329f50
testq %rdi, %rdi
je 0xf3ef
callq *0x60(%rdi)
andq $0x0, 0x31ab59(%rip)    # 0x329f50
cmpb $0x0, 0x2e8b9c(%rip)    # 0x2f7f9a
jne 0xf408
pushq $0x6
popq %rdi
callq 0x9d23
pushq $0x1
popq %rbx
testb %r15b, %r15b
jne 0xf415
callq 0xf426
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq