// File: /workspace/github_c_makefile_star2_O3/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, 0x8(%rsp)
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r15d
movl %edi, %r12d
xorl %ebx, %ebx
xorl %edi, %edi
xorl %eax, %eax
callq 0x7212
testl %r13d, %r13d
je 0x81b4
movl %ebx, 0xc75f(%rip)      # 0x1475c
movl %ebx, 0xc755(%rip)      # 0x14758
movl $0x1, 0xc363(%rip)      # 0x14370
testl %r12d, %r12d
je 0x8027
movl %r12d, 0xc73f(%rip)     # 0x14758
leaq 0xc310(%rip), %rdi      # 0x14330
xorl %eax, %eax
callq 0x70b0
cmpl $0x0, 0xc72e(%rip)      # 0x1475c
sete %al
testl %r15d, %r15d
sete %cl
cmpb %al, %cl
movl 0x8(%rsp), %ebx
je 0x8054
movl %r15d, 0xc716(%rip)     # 0x1475c
leaq 0xc2f3(%rip), %rdi      # 0x14340
xorl %eax, %eax
callq 0x70b0
movslq 0xc2b9(%rip), %rax      # 0x14314
cmpq %r14, %rax
je 0x809f
movl %r14d, 0xc2ad(%rip)     # 0x14314
leaq 0x6a68(%rip), %rsi      # 0xead6
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 0x6d9f
movl 0xc6bb(%rip), %eax      # 0x14760
cmpl %ebp, %eax
setle %cl
testl %ebp, %ebp
sets %dl
orb %cl, %dl
je 0x80f5
cmpl %ebp, %eax
setge %cl
cmpl $0x4, %eax
setge %dl
orb %cl, %dl
jne 0x8125
leaq 0xc287(%rip), %r14      # 0x14350
leal 0x1(%rax), %ecx
movl %ecx, 0xc68e(%rip)      # 0x14760
cltq
leaq (%r14,%rax,8), %rsi
movl $0x4, %edi
xorl %eax, %eax
callq 0x7961
movl 0xc676(%rip), %eax      # 0x14760
cmpl %ebp, %eax
je 0x8125
cmpl $0x4, %eax
jl 0x80c9
jmp 0x8125
leaq 0xc254(%rip), %r14      # 0x14350
leal -0x1(%rax), %ecx
movl %ecx, 0xc65b(%rip)      # 0x14760
cltq
leaq (%r14,%rax,8), %rsi
addq $-0x8, %rsi
movl $0x4, %edi
xorl %eax, %eax
callq 0x7a06
movl 0xc63f(%rip), %eax      # 0x14760
cmpl %ebp, %eax
jne 0x80fc
testl %ebx, %ebx
sete %cl
movl 0xc240(%rip), %eax      # 0x14370
testl %eax, %eax
setne %dl
orb %cl, %dl
je 0x816d
testl %eax, %eax
setne %al
testl %ebx, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8199
leaq 0xc1c7(%rip), %rsi      # 0x14318
xorl %ebx, %ebx
movl $0x2, %edi
xorl %eax, %eax
callq 0x7a06
leaq 0xc1ba(%rip), %rsi      # 0x14320
movl $0x3, %edi
jmp 0x818c
leaq 0xc1ac(%rip), %rsi      # 0x14320
movl $0x3, %edi
xorl %eax, %eax
callq 0x7a06
leaq 0xc191(%rip), %rsi      # 0x14318
movl $0x2, %edi
xorl %eax, %eax
callq 0x7961
movl %ebx, 0xc1d7(%rip)      # 0x14370
movl $0x1, %edi
xorl %eax, %eax
callq 0x7212
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0xc59d(%rip)      # 0x14758
sete %al
testl %r12d, %r12d
sete %cl
cmpb %al, %cl
jne 0x8012
jmp 0x8027