// File: /workspace/github_c_makefile_star2_O1/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 0x71ba
testl %r13d, %r13d
je 0x7fa2
movl %ebx, 0xc7da(%rip)      # 0x1476c
movl %ebx, 0xc7d0(%rip)      # 0x14768
movl $0x1, 0xc3de(%rip)      # 0x14380
cmpl $0x0, 0xc7bf(%rip)      # 0x14768
sete %al
testl %r12d, %r12d
sete %cl
cmpb %al, %cl
je 0x7fcb
movl %r12d, 0xc7ab(%rip)     # 0x14768
leaq 0xc37c(%rip), %rdi      # 0x14340
xorl %eax, %eax
callq 0x7058
cmpl $0x0, 0xc79a(%rip)      # 0x1476c
sete %al
testl %r15d, %r15d
sete %cl
cmpb %al, %cl
movl 0x8(%rsp), %ebx
je 0x7ff8
movl %r15d, 0xc782(%rip)     # 0x1476c
leaq 0xc35f(%rip), %rdi      # 0x14350
xorl %eax, %eax
callq 0x7058
movslq 0xc325(%rip), %rax      # 0x14324
cmpq %r14, %rax
je 0x8043
movl %r14d, 0xc319(%rip)     # 0x14324
leaq 0x69e4(%rip), %rsi      # 0xe9f6
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 0x6d47
movl 0xc727(%rip), %eax      # 0x14770
cmpl %ebp, %eax
setle %cl
testl %ebp, %ebp
sets %dl
orb %cl, %dl
jne 0x8087
leaq 0xc302(%rip), %r14      # 0x14360
leal -0x1(%rax), %ecx
movl %ecx, 0xc709(%rip)      # 0x14770
cltq
leaq (%r14,%rax,8), %rsi
addq $-0x8, %rsi
movl $0x4, %edi
xorl %eax, %eax
callq 0x79ae
movl 0xc6ed(%rip), %eax      # 0x14770
cmpl %ebp, %eax
jne 0x805e
cmpl %ebp, 0xc6e3(%rip)      # 0x14770
jge 0x80d5
movl 0xc6db(%rip), %eax      # 0x14770
cmpl %ebp, %eax
sete %cl
cmpl $0x4, %eax
setge %dl
orb %cl, %dl
jne 0x80d5
leaq 0xc2b5(%rip), %r14      # 0x14360
leal 0x1(%rax), %ecx
movl %ecx, 0xc6bc(%rip)      # 0x14770
cltq
leaq (%r14,%rax,8), %rsi
movl $0x4, %edi
xorl %eax, %eax
callq 0x7909
movl 0xc6a4(%rip), %eax      # 0x14770
cmpl %ebp, %eax
je 0x80d5
cmpl $0x4, %eax
jl 0x80ab
testl %ebx, %ebx
sete %cl
movl 0xc2a0(%rip), %eax      # 0x14380
testl %eax, %eax
setne %dl
orb %cl, %dl
je 0x811d
testl %eax, %eax
setne %al
testl %ebx, %ebx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8149
leaq 0xc227(%rip), %rsi      # 0x14328
xorl %ebx, %ebx
movl $0x2, %edi
xorl %eax, %eax
callq 0x79ae
leaq 0xc21a(%rip), %rsi      # 0x14330
movl $0x3, %edi
jmp 0x813c
leaq 0xc20c(%rip), %rsi      # 0x14330
movl $0x3, %edi
xorl %eax, %eax
callq 0x79ae
leaq 0xc1f1(%rip), %rsi      # 0x14328
movl $0x2, %edi
xorl %eax, %eax
callq 0x7909
movl %ebx, 0xc237(%rip)      # 0x14380
movl $0x1, %edi
xorl %eax, %eax
callq 0x71ba
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq