// File: /workspace/github_c_makefile_star2_O1/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, 0xbfba4(%rip)     # 0xce97c
je 0xf0c8
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xd2800(%rip), %rbx     # 0xe15f0
leaq 0x4(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b437
testl %eax, %eax
jle 0xf0ba
leaq 0x4(%rsp), %r12
leaq 0x7d033(%rip), %rbp     # 0x8be44
leaq 0x793d08(%rip), %r14    # 0x7a2b20
leaq 0xd3821(%rip), %r15     # 0xe2640
leaq 0xd372a(%rip), %r13     # 0xe2550
movzbl 0xd27c3(%rip), %ecx     # 0xe15f0
cmpq $0x8, %rcx
ja 0xeef6
movslq (%rbp,%rcx,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
leaq 0x793cc8(%rip), %rax    # 0x7a2b10
movl (%rax), %edi
testl %edi, %edi
leaq 0xd374d(%rip), %r9      # 0xe25a0
js 0xeeec
leaq 0x793cac(%rip), %rax    # 0x7a2b0c
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 0xee9b
movslq %edx, %rdi
incl %edx
movb (%rdi,%rbx), %dil
movb %dil, (%rcx,%r13)
testb $0x2, %sil
je 0xeeb0
movslq %edx, %rdi
leal 0x2(%rdi), %edx
movzwl (%rdi,%rbx), %edi
movw %di, (%r9,%rcx,2)
testb $0x4, %sil
je 0xeecc
movslq %edx, %rdi
leal 0x2(%rdi), %edx
movzwl (%rdi,%rbx), %edi
leaq 0xd3739(%rip), %r8      # 0xe2600
movw %di, (%r8,%rcx,2)
testb $0x8, %sil
je 0xeee1
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 0xee6d
callq 0xd1ba
jmp 0xf0a7
cmpl $0xff, %ecx
jne 0xf0a7
movslq 0x4(%rsp), %rax
leaq 0xd3842(%rip), %rcx     # 0xe2750
movswl (%rcx,%rax,2), %edi
callq 0x46eef
movslq 0x4(%rsp), %rdx
leaq (%rdx,%rdx,4), %rax
leaq (%rdx,%rax,2), %rcx
leaq 0xd3745(%rip), %rax     # 0xe2670
addq %rax, %rcx
leaq 0x11ef2b(%rip), %r12    # 0x12de60
movq %r12, %rdi
leaq 0x7d3de(%rip), %rsi     # 0x8c31d
xorl %eax, %eax
callq 0x8f20
movq %r12, %rdi
leaq 0x4(%rsp), %r12
xorl %eax, %eax
callq 0x14b61
jmp 0xf0a7
movzbl 0xd2690(%rip), %eax     # 0xe15f1
leaq (%rax,%rax,4), %rcx
leaq (%rax,%rcx,2), %rax
movzwl 0xd268a(%rip), %ecx     # 0xe15fa
leaq 0xd36f9(%rip), %rdx     # 0xe2670
movw %cx, 0x8(%rdx,%rax)
movq 0xd266f(%rip), %rcx     # 0xe15f2
movq %rcx, (%rdx,%rax)
movb $0x0, 0xa(%rdx,%rax)
jmp 0xf0a7
decb %al
movb %al, 0xd3c0d(%rip)      # 0xe2ba6
movsbl %al, %r12d
testb %r12b, %r12b
jle 0xefbf
movl %r12d, %edx
leal -0x1(%r12), %eax
movq %rdx, %rsi
subq %rax, %rsi
addq %rbx, %rsi
leaq 0xd3bf6(%rip), %rdi     # 0xe2bb0
callq 0x80e0
leaq 0x54b382(%rip), %rax    # 0x55a348
movl (%rax), %eax
shll $0x4, %r12d
addl %r12d, %eax
addl $0x168, %eax            # imm = 0x168
movl %eax, 0xd3c7a(%rip)     # 0xe2c54
leaq 0x4(%rsp), %r12
jmp 0xf0a7
movzbl 0xd2606(%rip), %eax     # 0xe15f1
movl $0x2, %ecx
testb $0x1, %al
je 0xf008
movb 0xd25f8(%rip), %cl      # 0xe15f2
movslq 0x4(%rsp), %rdx
movb %cl, (%rdx,%r13)
movl $0x3, %ecx
testb $0x2, %al
leaq 0xd358f(%rip), %rdi     # 0xe25a0
je 0xf025
movl %ecx, %edx
movslq 0x4(%rsp), %rsi
addl $0x2, %ecx
movzwl (%rdx,%rbx), %edx
movw %dx, (%rdi,%rsi,2)
testb $0x4, %al
je 0xf042
movl %ecx, %edx
movslq 0x4(%rsp), %rsi
addl $0x2, %ecx
movzwl (%rdx,%rbx), %edx
leaq 0xd35c2(%rip), %rdi     # 0xe2600
movw %dx, (%rdi,%rsi,2)
testb $0x8, %al
je 0xf057
movslq 0x4(%rsp), %rdx
movl %ecx, %esi
incl %ecx
movb (%rsi,%rbx), %sil
movb %sil, (%r15,%rdx,2)
testb $0x10, %al
je 0xf0a7
movslq 0x4(%rsp), %rax
movl %ecx, %ecx
movb (%rcx,%rbx), %cl
movb %cl, 0x1(%r15,%rax,2)
jmp 0xf0a7
movb 0xd257f(%rip), %al      # 0xe15f1
movslq 0x4(%rsp), %rcx
leaq 0x11b422(%rip), %rdx    # 0x12a4a0
movb %al, (%rcx,%rdx)
leaq 0x793a88(%rip), %rdx    # 0x7a2b10
movl (%rdx), %edi
cmpl %edi, %ecx
sete %cl
cmpb $0x2, %al
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0xf0a7
movq %rbx, %rsi
movl $0x2, %edx
callq 0x5bcf2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5b437
testl %eax, %eax
jg 0xee26
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq