// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekgame.c
// Function: getpackets
void
getpackets()
{
     int i, j, k, l;
     int other, tempbufleng;

     if (option[4] == 0) return;

     while ((tempbufleng = getpacket(&other,tempbuf)) > 0)
     {
          switch(tempbuf[0])
          {
               case 0:  //[0] (receive master sync buffer)
                    j = ((numplayers+1)>>1)+1; k = (1<<3);
                    for(i=connecthead;i>=0;i=connectpoint2[i])
                    {
                         l = (tempbuf[k>>3]>>(k&7));
                         if (l&1) fsyncvel[i] = tempbuf[j++];
//** Les START - 09/27/95
                         if (l&2) {
                              fsyncsvel[i]=tempbuf[j++];
                              fsyncsvel[i]|=(tempbuf[j++]<<8);
                         }
                         if (l&4) {
                              fsyncangvel[i]=tempbuf[j++];
                              fsyncangvel[i]|=(tempbuf[j++]<<8);
                         }
//** Les END   - 09/27/95
                         if (l&8)
                         {
                              fsyncbits[i] = ((short)tempbuf[j])+(((short)tempbuf[j+1])<<8);
                              j += 2;
                         }
                         k += 4;
                    }
#if 0
                    while (j != tempbufleng)
                    {
                         othersyncval[othersyncvalend] = ((int)tempbuf[j]);
                         othersyncval[othersyncvalend] += (((int)tempbuf[j+1])<<8);
                         j += 2;
                         othersyncvalend = ((othersyncvalend+1)&(MOVEFIFOSIZ-1));
                    }

                    i = 0;
                    while (syncvalplc != syncvalend)
                    {
                         if (othersyncvalcnt > syncvalcnt)
                         {
                              if (i == 0) syncstat = 0, i = 1;
                              syncstat |= (syncval[syncvalplc]^othersyncval[syncvalplc]);
                         }
                         syncvalplc = ((syncvalplc+1)&(MOVEFIFOSIZ-1));
                         syncvalcnt++;
                    }
                    while (othersyncvalplc != othersyncvalend)
                    {
                         if (syncvalcnt > othersyncvalcnt)
                         {
                              if (i == 0) syncstat = 0, i = 1;
                              syncstat |= (syncval[othersyncvalplc]^othersyncval[othersyncvalplc]);
                         }
                         othersyncvalplc = ((othersyncvalplc+1)&(MOVEFIFOSIZ-1));
                         othersyncvalcnt++;
                    }
#endif

                movethings();        //Move all players and sprites
                    break;
               case 1:  //[1] (receive slave sync buffer)
                    j = 2; k = tempbuf[1];
                    if (k&1) fsyncvel[other] = tempbuf[j++];
//** Les START - 09/27/95
                     if (k&2) {
                         fsyncsvel[other]=tempbuf[j++];
                         fsyncsvel[other]|=(tempbuf[j++]<<8);
                     }
                     if (k&4) {
                         fsyncangvel[other]=tempbuf[j++];
                         fsyncangvel[other]|=(tempbuf[j++]<<8);
                     }
//** Les END   - 09/27/95
                    if (k&8) fsyncbits[other] = ((fsyncbits[other]&0xff00)|((short)tempbuf[j++]));
                    if (k&16) fsyncbits[other] = ((fsyncbits[other]&0x00ff)|(((short)tempbuf[j++])<<8));
                    break;
               case 2:
                    getmessageleng = tempbufleng-1;
                    for(j=getmessageleng-1;j>=0;j--) getmessage[j] = tempbuf[j+1];
                    getmessagetimeoff = totalclock+360+(getmessageleng<<4);
                    break;
               case 3:
                    break;
              #ifdef NETNAMES
               case 8:
                    memcpy(netnames[tempbuf[1]],&tempbuf[2],10);
                    netnames[tempbuf[1]][10]=0;
                    break;
              #endif
               case 5:
                    playerreadyflag[other] = tempbuf[1];
                    if ((other == connecthead) && (tempbuf[1] == 2))
                         sendpacket(connecthead,tempbuf,2);
                    break;
               case 255:  //[255] (logout)
                    deletesprite(playersprite[other]);
                    sprintf(tektempbuf,"%2d %8s HAS QUIT", other,netnames[other]);
                    showmessage(tektempbuf);
                    break;
          }
     }
}

// Assembly:
cmpb $0x0, 0xc2b9f(%rip)     # 0xd197c
je 0xf0cb
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xd57fb(%rip), %rbx     # 0xe45f0
leaq 0x4(%rsp), %rdi
movq %rbx, %rsi
callq 0x5e6cb
testl %eax, %eax
jle 0xf0bd
leaq 0x4(%rsp), %r12
leaq 0x80032(%rip), %rbp     # 0x8ee48
leaq 0x796d23(%rip), %r14    # 0x7a5b40
leaq 0xd681c(%rip), %r15     # 0xe5640
leaq 0xd6725(%rip), %r13     # 0xe5550
movzbl 0xd57be(%rip), %ecx     # 0xe45f0
cmpq $0x8, %rcx
ja 0xeefb
movslq (%rbp,%rcx,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
leaq 0x796ce3(%rip), %rax    # 0x7a5b30
movl (%rax), %edi
testl %edi, %edi
leaq 0xd6748(%rip), %r9      # 0xe55a0
js 0xeef1
leaq 0x796cc7(%rip), %rax    # 0x7a5b2c
movl (%rax), %edx
incl %edx
sarl %edx
incl %edx
movl $0x8, %eax
movl %eax, %ecx
shrl $0x3, %ecx
movzbl (%rcx,%rbx), %r8d
movl %eax, %ecx
andb $0x4, %cl
movl %r8d, %esi
shrl %cl, %esi
movl %eax, %ecx
andl $0x4, %ecx
btl %ecx, %r8d
movl %edi, %ecx
jae 0xeea0
movslq %edx, %rdi
incl %edx
movb (%rdi,%rbx), %dil
movb %dil, (%rcx,%r13)
testb $0x2, %sil
je 0xeeb5
movslq %edx, %rdi
leal 0x2(%rdi), %edx
movzwl (%rdi,%rbx), %edi
movw %di, (%r9,%rcx,2)
testb $0x4, %sil
je 0xeed1
movslq %edx, %rdi
leal 0x2(%rdi), %edx
movzwl (%rdi,%rbx), %edi
leaq 0xd6734(%rip), %r8      # 0xe5600
movw %di, (%r8,%rcx,2)
testb $0x8, %sil
je 0xeee6
movslq %edx, %rdx
movzwl (%rdx,%rbx), %esi
movw %si, (%r15,%rcx,2)
addl $0x2, %edx
addl $0x4, %eax
movl (%r14,%rcx,4), %edi
testl %edi, %edi
jns 0xee72
callq 0xd199
jmp 0xf0aa
cmpl $0xff, %ecx
jne 0xf0aa
movslq 0x4(%rsp), %rax
leaq 0xd683d(%rip), %rcx     # 0xe5750
movswl (%rcx,%rax,2), %edi
callq 0x48e5b
movslq 0x4(%rsp), %rdx
leaq (%rdx,%rdx,4), %rax
leaq (%rdx,%rax,2), %rcx
leaq 0xd6740(%rip), %rax     # 0xe5670
addq %rax, %rcx
leaq 0x121f36(%rip), %r12    # 0x130e70
movq %r12, %rdi
leaq 0x803ed(%rip), %rsi     # 0x8f331
xorl %eax, %eax
callq 0x8f20
movq %r12, %rdi
leaq 0x4(%rsp), %r12
xorl %eax, %eax
callq 0x14be7
jmp 0xf0aa
movzbl 0xd568b(%rip), %eax     # 0xe45f1
leaq (%rax,%rax,4), %rcx
leaq (%rax,%rcx,2), %rax
movzwl 0xd5685(%rip), %ecx     # 0xe45fa
leaq 0xd66f4(%rip), %rdx     # 0xe5670
movw %cx, 0x8(%rdx,%rax)
movq 0xd566a(%rip), %rcx     # 0xe45f2
movq %rcx, (%rdx,%rax)
movb $0x0, 0xa(%rdx,%rax)
jmp 0xf0aa
decb %al
movb %al, 0xd6c08(%rip)      # 0xe5ba6
movsbl %al, %r12d
testb %r12b, %r12b
jle 0xefc4
movl %r12d, %edx
leal -0x1(%r12), %eax
movq %rdx, %rsi
subq %rax, %rsi
addq %rbx, %rsi
leaq 0xd6bf1(%rip), %rdi     # 0xe5bb0
callq 0x80e0
leaq 0x54e39d(%rip), %rax    # 0x55d368
movl (%rax), %eax
shll $0x4, %r12d
addl %r12d, %eax
addl $0x168, %eax            # imm = 0x168
movl %eax, 0xd6c75(%rip)     # 0xe5c54
leaq 0x4(%rsp), %r12
jmp 0xf0aa
movzbl 0xd5601(%rip), %eax     # 0xe45f1
movl $0x2, %ecx
testb $0x1, %al
je 0xf00d
movb 0xd55f3(%rip), %cl      # 0xe45f2
movslq 0x4(%rsp), %rdx
movb %cl, (%rdx,%r13)
movl $0x3, %ecx
testb $0x2, %al
leaq 0xd658a(%rip), %rdi     # 0xe55a0
je 0xf02a
movl %ecx, %edx
movslq 0x4(%rsp), %rsi
addl $0x2, %ecx
movzwl (%rdx,%rbx), %edx
movw %dx, (%rdi,%rsi,2)
testb $0x4, %al
je 0xf047
movl %ecx, %edx
movslq 0x4(%rsp), %rsi
addl $0x2, %ecx
movzwl (%rdx,%rbx), %edx
leaq 0xd65bd(%rip), %rdi     # 0xe5600
movw %dx, (%rdi,%rsi,2)
testb $0x8, %al
je 0xf05c
movslq 0x4(%rsp), %rdx
movl %ecx, %esi
incl %ecx
movb (%rsi,%rbx), %sil
movb %sil, (%r15,%rdx,2)
testb $0x10, %al
je 0xf0aa
movslq 0x4(%rsp), %rax
movl %ecx, %ecx
movb (%rcx,%rbx), %cl
movb %cl, 0x1(%r15,%rax,2)
jmp 0xf0aa
movb 0xd557a(%rip), %al      # 0xe45f1
movslq 0x4(%rsp), %rdi
leaq 0x11e41d(%rip), %rcx    # 0x12d4a0
movb %al, (%rdi,%rcx)
leaq 0x796aa3(%rip), %rcx    # 0x7a5b30
cmpl (%rcx), %edi
sete %cl
cmpb $0x2, %al
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0xf0aa
movq %rbx, %rsi
movl $0x2, %edx
callq 0x5f092
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5e6cb
testl %eax, %eax
jg 0xee2b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq