// File: /workspace/github_c_makefile_star2_O2/jrrk[P]cbzone/c_graphics.c
// Function: updatedisplay
void updatedisplay (missile, lander, score, numleft, sens, reset)
     Bool missile, lander, sens, reset;
     LONG score;  // Eric Fogelin made this LONG from int
     int numleft;
{
  char text[11];
  static Bool flasher[] = {False, False};
  static int currentnumleft = 0;
  static int currentscore = -1;
  static int bswitch[] = {918, 612};
  static int blswitch[] = {918, 638};	// Eric Fogelin: added - orig did not work
  static int wind1[][2] = {591, 571, 54, 29};
  static int wind2[][2] = {656, 571, 54, 29};
  static int origin[][2] = {733, 493, 733, 533, 733, 573, 733, 613};
  static Bool currentsens = True;

  gprsetclippingactive(False);
  if (reset) {
    flasher[0] = flasher[1] = False;
    currentsens = True;
  }

  if ((flasher[0] && !missile) ||       /* change the missile warning */
      (!flasher[0] && missile)) {
    flasher[0] = missile;
    bitblt(wind1);
  }
  if ((flasher[1] && !lander) ||        /* change the lander warning */
      (!flasher[1] && lander)) {
    flasher[1] = lander;
    bitblt(wind2);
  }
  if (score != currentscore) {          /*     change the score      */
    currentscore = score;
    sprintf(text,"%10ld",score);  // Eric Fogelin changed this to ld from d
    printstring(608, 542, text, strlen(text));
  }
  if (numleft < currentnumleft && numleft >= 0)    /* remove tank(s) */
    while (numleft != currentnumleft)
      removepixmap(4, origin[--currentnumleft]);
  if (numleft > currentnumleft)                    /*  add tank(s)   */
    while (numleft != currentnumleft && currentnumleft < 4)
      putpixmap(4, origin[currentnumleft++]);
  if (sens && !currentsens) {           /* change to high gear       */
    removepixmap(3, blswitch); // Eric Fogelin: added - orig did not work
    putpixmap(2, bswitch);
    currentsens = sens;
  }
  else if (!sens && currentsens) {      /* change to low gear        */
    removepixmap(2, bswitch);  // Eric Fogelin: added - orig did not work
    putpixmap(3, blswitch);
    currentsens = sens;
  }
  gprsetclippingactive(True);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r13d
movl %r8d, %ebx
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r15d
movl %edi, %r12d
xorl %edi, %edi
xorl %eax, %eax
callq 0x6cb6
testl %r13d, %r13d
je 0x7a78
andl $0x0, 0xbe98(%rip)      # 0x1376c
andl $0x0, 0xbe8d(%rip)      # 0x13768
movl $0x1, 0xba9b(%rip)      # 0x13380
testl %r12d, %r12d
je 0x78ff
movl %r12d, 0xbe77(%rip)     # 0x13768
leaq 0xba48(%rip), %rdi      # 0x13340
xorl %eax, %eax
callq 0x6bd5
cmpl $0x0, 0xbe66(%rip)      # 0x1376c
sete %al
testl %r15d, %r15d
sete %cl
cmpb %al, %cl
je 0x7928
movl %r15d, 0xbe52(%rip)     # 0x1376c
leaq 0xba2f(%rip), %rdi      # 0x13350
xorl %eax, %eax
callq 0x6bd5
movslq 0xb9f5(%rip), %rax      # 0x13324
cmpq %r14, %rax
je 0x7973
movl %r14d, 0xb9e9(%rip)     # 0x13324
leaq 0x6164(%rip), %rsi      # 0xdaa6
leaq 0xd(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x42e0
movq %r15, %rdi
callq 0x4280
movl $0x260, %edi            # imm = 0x260
movl $0x21e, %esi            # imm = 0x21E
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x69e2
movl 0xbdf7(%rip), %eax      # 0x13770
cmpl %ebp, %eax
setle %cl
testl %ebp, %ebp
sets %dl
orb %cl, %dl
jne 0x79bb
leaq 0xb9d2(%rip), %r15      # 0x13360
pushq $0x4
popq %r14
cmpl %ebp, %eax
je 0x79f4
leal -0x1(%rax), %ecx
movl %ecx, 0xbdd1(%rip)      # 0x13770
cltq
leaq (%r15,%rax,8), %rsi
addq $-0x8, %rsi
movl %r14d, %edi
xorl %eax, %eax
callq 0x7335
movl 0xbdb7(%rip), %eax      # 0x13770
jmp 0x7992
cmpl %ebp, %eax
jge 0x79f4
leaq 0xb99a(%rip), %r15      # 0x13360
pushq $0x4
popq %r14
cmpl %ebp, %eax
je 0x79f4
cmpl $0x3, %eax
jg 0x79f4
leal 0x1(%rax), %ecx
movl %ecx, 0xbd94(%rip)      # 0x13770
cltq
leaq (%r15,%rax,8), %rsi
movl %r14d, %edi
xorl %eax, %eax
callq 0x72c1
movl 0xbd7e(%rip), %eax      # 0x13770
jmp 0x79ca
testl %ebx, %ebx
sete %cl
movl 0xb981(%rip), %eax      # 0x13380
testl %eax, %eax
setne %dl
orb %cl, %dl
je 0x7a37
testl %eax, %eax
setne %al
testl %ebx, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7a5f
leaq 0xb908(%rip), %rsi      # 0x13328
xorl %ebx, %ebx
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x7335
leaq 0xb8fd(%rip), %rsi      # 0x13330
pushq $0x3
jmp 0x7a51
leaq 0xb8f2(%rip), %rsi      # 0x13330
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x7335
leaq 0xb8d9(%rip), %rsi      # 0x13328
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x72c1
movl %ebx, 0xb921(%rip)      # 0x13380
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x6cb6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0xbce9(%rip)      # 0x13768
sete %al
testl %r12d, %r12d
sete %cl
cmpb %al, %cl
jne 0x78ea
jmp 0x78ff