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

     if (totalclock < ototalclock+TICSPERFRAME) return;
     if (ready2send == 0) return;
     ototalclock = totalclock;

     // I am the MASTER (or 1 player game)
     if ((myconnectindex == connecthead) || (option[4] == 0))
     {
          if (option[4] != 0)
               getpackets();

          if (getoutputcirclesize() < 16)
          {
               getinput();
               fsyncvel[myconnectindex] = locvel;
               fsyncsvel[myconnectindex] = locsvel;
               fsyncangvel[myconnectindex] = locangvel;
               fsyncbits[myconnectindex] = locbits;

               if (option[4] != 0)
               {
                    tempbuf[0] = 0;
                    j = ((numplayers+1)>>1)+1;
                    for(k=1;k<j;k++) tempbuf[k] = 0;
                    k = (1<<3);
                    for(i=connecthead;i>=0;i=connectpoint2[i])
                    {
                         l = 0;
                         if (fsyncvel[i] != osyncvel[i]) tempbuf[j++] = fsyncvel[i], l |= 1;
//** Les START - 09/27/95
                         if (fsyncsvel[i] != osyncsvel[i]) {
                              tempbuf[j++]=(fsyncsvel[i]&0xFF);
                              tempbuf[j++]=(fsyncsvel[i]>>8);
                              l|=2;
                         }
                         if (fsyncangvel[i] != osyncangvel[i]) {
                              tempbuf[j++]=(fsyncangvel[i]&0xFF);
                              tempbuf[j++]=(fsyncangvel[i]>>8);
                              l|=4;
                         }
//** Les END   - 09/27/95
                         if (fsyncbits[i] != osyncbits[i])
                         {
                              tempbuf[j++] = (fsyncbits[i]&255);
                              tempbuf[j++] = ((fsyncbits[i]>>8)&255);
                              l |= 8;
                         }
                         tempbuf[k>>3] |= (l<<(k&7));
                         k += 4;

                         osyncvel[i] = fsyncvel[i];
                         osyncsvel[i] = fsyncsvel[i];
                         osyncangvel[i] = fsyncangvel[i];
                         osyncbits[i] = fsyncbits[i];
                    }
#if 0
                    while (syncvalplc != syncvalend)
                    {
                         tempbuf[j] = (unsigned char)(syncval[syncvalplc]&255);
                         tempbuf[j+1] = (unsigned char)((syncval[syncvalplc]>>8)&255);
                         j += 2;
                         syncvalplc = ((syncvalplc+1)&(MOVEFIFOSIZ-1));
                    }
#endif
                    for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
                         sendpacket(i,tempbuf,j);
               }
               else if (numplayers == 2)
               {
                    if (keystatus[0xb5] > 0)
                    {
                         keystatus[0xb5] = 0;
                         locselectedgun2++;
                         if (locselectedgun2 >= 3) locselectedgun2 = 0;
                    }

                    // second player on 1 computer mode
                    locvel2 = min(max(vel2,-128+8),127-8);
                    locsvel2 = min(max(svel2,-128+8),127-8);
                    locangvel2 = min(max(angvel2,-128+16),127-16);
                    locbits2 = (locselectedgun2<<13);
                    locbits2 |= keystatus[0x45];                  //Stand high
                    locbits2 |= (keystatus[0x47]<<1);             //Stand low
                    locbits2 |= (1<<8);                           //Run
                    locbits2 |= (keystatus[0x49]<<2);             //Look up
                    locbits2 |= (keystatus[0x37]<<3);             //Look down
                    locbits2 |= (keystatus[0x50]<<10);            //Space
                    locbits2 |= (keystatus[0x52]<<11);            //Shoot

                    other = connectpoint2[myconnectindex];
                    if (other < 0) other = connecthead;

                    fsyncvel[other] = locvel2;
                    fsyncsvel[other] = locsvel2;
                    fsyncangvel[other] = locangvel2;
                    fsyncbits[other] = locbits2;
               }
               movethings();  //Move EVERYTHING (you too!)
          }
     }
     else                        //I am a SLAVE
     {
          getpackets();

          if (getoutputcirclesize() < 16)
          {
               getinput();

               tempbuf[0] = 1; k = 0;
               j = 2;

               if (locvel != olocvel) tempbuf[j++] = locvel, k |= 1;
//** Les START - 09/27/95
               if (locsvel != olocsvel) {
                    tempbuf[j++]=locsvel&0xFF;
                    tempbuf[j++]=(locsvel>>8);
                    k|=2;
               }
               if (locangvel != olocangvel) {
                    tempbuf[j++]=locangvel&0xFF;
                    tempbuf[j++]=(locangvel>>8);
                    k|=4;
               }
//** Les END   - 09/27/95
               if ((locbits^olocbits)&0x00ff) tempbuf[j++] = (locbits&255), k |= 8;
               if ((locbits^olocbits)&0xff00) tempbuf[j++] = ((locbits>>8)&255), k |= 16;

               tempbuf[1] = k;

               olocvel = locvel;
               olocsvel = locsvel;
               olocangvel = locangvel;
               olocbits = locbits;

               sendpacket(connecthead,tempbuf,j);
          }
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x54ba0b(%rip), %rax    # 0x55a348
movl (%rax), %eax
movl 0xd2b0f(%rip), %ecx     # 0xe1454
addl $0x3, %ecx
cmpl %ecx, %eax
jl 0xeb95
cmpb $0x0, 0xd2afc(%rip)     # 0xe1453
je 0xeb95
movl %eax, 0xd2af1(%rip)     # 0xe1454
leaq 0x79419a(%rip), %rbx    # 0x7a2b04
movl (%rbx), %eax
leaq 0x79419d(%rip), %r14    # 0x7a2b10
cmpl (%r14), %eax
sete %cl
movb 0xbfffd(%rip), %al      # 0xce97c
testb %al, %al
sete %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0xeb63
testb %al, %al
je 0xe998
callq 0xedd1
callq 0x5a85a
cmpl $0xf, %eax
jg 0xeb95
callq 0xd6c3
movb 0x1192d4(%rip), %cl     # 0x127c85
movslq (%rbx), %rax
leaq 0xd3b95(%rip), %rdx     # 0xe2550
movb %cl, (%rax,%rdx)
movzwl 0x1192c1(%rip), %ecx    # 0x127c86
leaq 0xd3bd4(%rip), %rdx     # 0xe25a0
movw %cx, (%rdx,%rax,2)
movzwl 0x1192b1(%rip), %ecx    # 0x127c88
leaq 0xd3c22(%rip), %rdx     # 0xe2600
movw %cx, (%rdx,%rax,2)
movzwl 0xd41bb(%rip), %ecx     # 0xe2ba4
leaq 0xd3c50(%rip), %rdx     # 0xe2640
movw %cx, (%rdx,%rax,2)
cmpb $0x0, 0xbff81(%rip)     # 0xce97c
je 0xec82
movb $0x0, 0xd2be8(%rip)     # 0xe15f0
leaq 0x7940fd(%rip), %rax    # 0x7a2b0c
movl (%rax), %ebx
incl %ebx
sarl %ebx
testl %ebx, %ebx
jle 0xea29
movl %ebx, %edx
leaq 0xd2bcf(%rip), %rdi     # 0xe15f1
xorl %esi, %esi
callq 0x8440
incl %ebx
movl (%r14), %ecx
testl %ecx, %ecx
js 0xeb24
movl $0x8, %eax
leaq 0xd3aee(%rip), %rdx     # 0xe2530
leaq 0xd3b17(%rip), %rsi     # 0xe2560
leaq 0xd3b70(%rip), %rdi     # 0xe25c0
leaq 0xd3bc9(%rip), %r8      # 0xe2620
leaq 0xd2b92(%rip), %r9      # 0xe15f0
leaq 0x7940bb(%rip), %r10    # 0x7a2b20
movl %ecx, %r11d
leaq 0xd3ae1(%rip), %rcx     # 0xe2550
movb (%r11,%rcx), %r14b
xorl %r15d, %r15d
cmpb (%r11,%rdx), %r14b
je 0xea8b
movslq %ebx, %rcx
incl %ebx
movb %r14b, (%rcx,%r9)
movl $0x1, %r15d
leaq 0xd3b0e(%rip), %rcx     # 0xe25a0
movzwl (%rcx,%r11,2), %r12d
cmpw (%rsi,%r11,2), %r12w
je 0xeaad
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %r12w, (%rcx,%r9)
orl $0x2, %r15d
leaq 0xd3b4c(%rip), %rcx     # 0xe2600
movzwl (%rcx,%r11,2), %r13d
cmpw (%rdi,%r11,2), %r13w
je 0xeacf
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %r13w, (%rcx,%r9)
orl $0x4, %r15d
leaq 0xd3b6a(%rip), %rcx     # 0xe2640
movzwl (%rcx,%r11,2), %ebp
cmpw (%r8,%r11,2), %bp
je 0xeaf1
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %bp, (%rcx,%r9)
orl $0x8, %r15d
movl %eax, %ecx
andb $0x4, %cl
shll %cl, %r15d
movl %eax, %ecx
shrl $0x3, %ecx
orb %r15b, (%rcx,%r9)
addl $0x4, %eax
movb %r14b, (%r11,%rdx)
movw %r12w, (%rsi,%r11,2)
movw %r13w, (%rdi,%r11,2)
movw %bp, (%r8,%r11,2)
movl (%r10,%r11,4), %ecx
testl %ecx, %ecx
jns 0xea65
leaq 0x793fe5(%rip), %rax    # 0x7a2b10
movslq (%rax), %rax
leaq 0x793feb(%rip), %r15    # 0x7a2b20
movl (%r15,%rax,4), %ebp
testl %ebp, %ebp
js 0xedbe
leaq 0xd2aa8(%rip), %r14     # 0xe15f0
movl %ebp, %edi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5bcf2
movl %ebp, %eax
movl (%r15,%rax,4), %ebp
testl %ebp, %ebp
jns 0xeb48
jmp 0xedbe
callq 0xedd1
callq 0x5a85a
cmpl $0xf, %eax
jg 0xeb95
callq 0xd6c3
movb $0x1, 0xd2a72(%rip)     # 0xe15f0
movb 0x119101(%rip), %al     # 0x127c85
cmpb 0xd3986(%rip), %al      # 0xe2510
jne 0xeba4
xorl %ecx, %ecx
movl $0x2, %edx
jmp 0xebb4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %al, 0xd2a48(%rip)      # 0xe15f2
movl $0x1, %ecx
movl $0x3, %edx
movzwl 0x1190cb(%rip), %edi    # 0x127c86
cmpw 0xd3950(%rip), %di      # 0xe2512
je 0xebd8
movl %edx, %esi
leaq 0xd2a23(%rip), %r8      # 0xe15f0
addl $0x2, %edx
movw %di, (%rsi,%r8)
orl $0x2, %ecx
movzwl 0x1190a8(%rip), %r8d    # 0x127c88
cmpw 0xd392e(%rip), %r8w     # 0xe2516
je 0xebfe
movl %edx, %esi
leaq 0xd29fd(%rip), %r9      # 0xe15f0
addl $0x2, %edx
movw %r8w, (%rsi,%r9)
orl $0x4, %ecx
movzwl 0xd3f9f(%rip), %ebx     # 0xe2ba4
movzwl 0xd390e(%rip), %esi     # 0xe251a
xorw %bx, %si
testb %sil, %sil
je 0xec27
movl %edx, %r9d
incl %edx
leaq 0xd29d0(%rip), %r10     # 0xe15f0
movb %bl, (%r9,%r10)
orl $0x8, %ecx
movzwl %si, %esi
cmpl $0x100, %esi            # imm = 0x100
jb 0xec43
movl %edx, %esi
incl %edx
leaq 0xd29b3(%rip), %rbp     # 0xe15f0
movb %bh, (%rsi,%rbp)
orl $0x10, %ecx
movb %cl, 0xd29a8(%rip)      # 0xe15f1
leaq 0xd29a0(%rip), %rsi     # 0xe15f0
movb %al, 0xd38ba(%rip)      # 0xe2510
movw %di, 0xd38b5(%rip)      # 0xe2512
movw %r8w, 0xd38b1(%rip)     # 0xe2516
movw %bx, 0xd38ae(%rip)      # 0xe251a
movl (%r14), %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5bcf2
leaq 0x793e83(%rip), %rcx    # 0x7a2b0c
cmpl $0x2, (%rcx)
jne 0xedbe
leaq 0x31d467(%rip), %rsi    # 0x32c100
cmpb $0x0, 0xb5(%rsi)
jle 0xecc0
movb $0x0, 0xb5(%rsi)
movl 0x11b7e9(%rip), %ecx    # 0x12a498
leal 0x1(%rcx), %edx
xorl %edi, %edi
cmpl $0x2, %ecx
cmovll %edx, %edi
movl %edi, 0x11b7d8(%rip)    # 0x12a498
movl 0x118fba(%rip), %ecx    # 0x127c80
cmpl $-0x77, %ecx
movl $0xffffff88, %edx       # imm = 0xFFFFFF88
cmovll %edx, %ecx
movl $0x77, %edi
cmpl %edi, %ecx
cmovgel %edi, %ecx
movl 0x118f9a(%rip), %r8d    # 0x127c7c
cmpl $-0x77, %r8d
cmovgel %r8d, %edx
cmpl %edi, %edx
cmovgel %edi, %edx
movb %cl, 0x11b79b(%rip)     # 0x12a490
movw %dx, 0x11b796(%rip)     # 0x12a492
movl 0x118f76(%rip), %edi    # 0x127c78
cmpl $-0x6f, %edi
movl $0xffffff90, %r8d       # imm = 0xFFFFFF90
cmovgel %edi, %r8d
cmpl $0x6f, %r8d
movl $0x6f, %edi
cmovll %r8d, %edi
movw %di, 0x11b771(%rip)     # 0x12a494
movl 0x11b76e(%rip), %r8d    # 0x12a498
shll $0xd, %r8d
movsbl 0x45(%rsi), %r9d
orl %r8d, %r9d
movsbl 0x47(%rsi), %r8d
addl %r8d, %r8d
orl %r9d, %r8d
movsbl 0x49(%rsi), %r9d
shll $0x2, %r9d
movsbl 0x37(%rsi), %r10d
shll $0x3, %r10d
orl %r9d, %r10d
orl %r8d, %r10d
movl 0x50(%rsi), %r8d
shll $0xa, %r8d
movzbl 0x52(%rsi), %esi
shll $0xb, %esi
orl %r8d, %esi
orl %r10d, %esi
orl $0x100, %esi            # imm = 0x100
movw %si, 0x11b71b(%rip)     # 0x12a496
leaq 0x793d9e(%rip), %r8     # 0x7a2b20
movl (%r8,%rax,4), %eax
testw %ax, %ax
jns 0xed8e
movl (%r14), %eax
movswq %ax, %rax
leaq 0xd37b7(%rip), %r8      # 0xe2550
movb %cl, (%rax,%r8)
leaq 0xd37fc(%rip), %rcx     # 0xe25a0
movw %dx, (%rcx,%rax,2)
leaq 0xd3851(%rip), %rcx     # 0xe2600
movw %di, (%rcx,%rax,2)
leaq 0xd3886(%rip), %rcx     # 0xe2640
movw %si, (%rcx,%rax,2)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd1ba