// File: /workspace/github_c_makefile_star2_O3/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 0x54ea21(%rip), %rax    # 0x55d368
movl (%rax), %eax
movl 0xd5b05(%rip), %ecx     # 0xe4454
addl $0x3, %ecx
cmpl %ecx, %eax
jl 0xeb9e
cmpb $0x0, 0xd5af2(%rip)     # 0xe4453
je 0xeb9e
movl %eax, 0xd5ae7(%rip)     # 0xe4454
leaq 0x7971b0(%rip), %rbx    # 0x7a5b24
movl (%rbx), %eax
leaq 0x7971b3(%rip), %r14    # 0x7a5b30
cmpl (%r14), %eax
sete %cl
movb 0xc2ff3(%rip), %al      # 0xd197c
testb %al, %al
sete %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0xeb6c
testb %al, %al
je 0xe9a2
callq 0xedd6
callq 0x5da3d
cmpl $0xf, %eax
jg 0xeb9e
callq 0xd6ec
movb 0x11c2ca(%rip), %cl     # 0x12ac85
movslq (%rbx), %rax
leaq 0xd6b8b(%rip), %rdx     # 0xe5550
movb %cl, (%rax,%rdx)
movzwl 0x11c2b7(%rip), %ecx    # 0x12ac86
leaq 0xd6bca(%rip), %rdx     # 0xe55a0
movw %cx, (%rdx,%rax,2)
movzwl 0x11c2a7(%rip), %ecx    # 0x12ac88
leaq 0xd6c18(%rip), %rdx     # 0xe5600
movw %cx, (%rdx,%rax,2)
movzwl 0xd71b1(%rip), %ecx     # 0xe5ba4
leaq 0xd6c46(%rip), %rdx     # 0xe5640
movw %cx, (%rdx,%rax,2)
cmpb $0x0, 0xc2f77(%rip)     # 0xd197c
je 0xec88
movb $0x0, 0xd5bde(%rip)     # 0xe45f0
leaq 0x797113(%rip), %rax    # 0x7a5b2c
movl (%rax), %ebx
incl %ebx
sarl %ebx
testl %ebx, %ebx
jle 0xea33
movl %ebx, %edx
leaq 0xd5bc5(%rip), %rdi     # 0xe45f1
xorl %esi, %esi
callq 0x8440
incl %ebx
movslq (%r14), %rax
testq %rax, %rax
movq %rax, (%rsp)
js 0xeb33
movl $0x8, %edx
leaq 0xd6adf(%rip), %rsi     # 0xe5530
leaq 0xd6b08(%rip), %rdi     # 0xe5560
leaq 0xd6b61(%rip), %r8      # 0xe55c0
leaq 0xd6bba(%rip), %r9      # 0xe5620
leaq 0xd5b83(%rip), %r10     # 0xe45f0
leaq 0x7970cc(%rip), %r11    # 0x7a5b40
movl %eax, %r14d
leaq 0xd6ad2(%rip), %rax     # 0xe5550
movb (%r14,%rax), %al
xorl %r15d, %r15d
cmpb (%r14,%rsi), %al
je 0xea9a
movslq %ebx, %rcx
incl %ebx
movb %al, (%rcx,%r10)
movl $0x1, %r15d
leaq 0xd6aff(%rip), %rcx     # 0xe55a0
movzwl (%rcx,%r14,2), %r12d
cmpw (%rdi,%r14,2), %r12w
je 0xeabc
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %r12w, (%rcx,%r10)
orl $0x2, %r15d
leaq 0xd6b3d(%rip), %rcx     # 0xe5600
movzwl (%rcx,%r14,2), %r13d
cmpw (%r8,%r14,2), %r13w
je 0xeade
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %r13w, (%rcx,%r10)
orl $0x4, %r15d
leaq 0xd6b5b(%rip), %rcx     # 0xe5640
movzwl (%rcx,%r14,2), %ebp
cmpw (%r9,%r14,2), %bp
je 0xeb00
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %bp, (%rcx,%r10)
orl $0x8, %r15d
movl %edx, %ecx
andb $0x4, %cl
shll %cl, %r15d
movl %edx, %ecx
shrl $0x3, %ecx
orb %r15b, (%rcx,%r10)
addl $0x4, %edx
movb %al, (%r14,%rsi)
movw %r12w, (%rdi,%r14,2)
movw %r13w, (%r8,%r14,2)
movw %bp, (%r9,%r14,2)
movl (%r11,%r14,4), %eax
testl %eax, %eax
jns 0xea74
leaq 0x797006(%rip), %r15    # 0x7a5b40
movq (%rsp), %rax
movl (%r15,%rax,4), %ebp
testl %ebp, %ebp
js 0xedc3
leaq 0xd5a9f(%rip), %r14     # 0xe45f0
movl %ebp, %edi
movq %r14, %rsi
movl %ebx, %edx
callq 0x5f092
movl %ebp, %eax
movl (%r15,%rax,4), %ebp
testl %ebp, %ebp
jns 0xeb51
jmp 0xedc3
callq 0xedd6
callq 0x5da3d
cmpl $0xf, %eax
jg 0xeb9e
callq 0xd6ec
movb $0x1, 0xd5a69(%rip)     # 0xe45f0
movb 0x11c0f8(%rip), %al     # 0x12ac85
cmpb 0xd697d(%rip), %al      # 0xe5510
jne 0xebad
movl $0x2, %edx
xorl %ecx, %ecx
jmp 0xebba
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %al, 0xd5a3f(%rip)      # 0xe45f2
movb $0x1, %cl
movl $0x3, %edx
movzwl 0x11c0c5(%rip), %edi    # 0x12ac86
cmpw 0xd694a(%rip), %di      # 0xe5512
je 0xebde
movl %edx, %esi
leaq 0xd5a1d(%rip), %r8      # 0xe45f0
addl $0x2, %edx
movw %di, (%rsi,%r8)
orb $0x2, %cl
movzwl 0x11c0a2(%rip), %r8d    # 0x12ac88
cmpw 0xd6928(%rip), %r8w     # 0xe5516
je 0xec04
movl %edx, %esi
leaq 0xd59f7(%rip), %r9      # 0xe45f0
addl $0x2, %edx
movw %r8w, (%rsi,%r9)
orb $0x4, %cl
movzwl 0xd6f99(%rip), %ebx     # 0xe5ba4
movzwl 0xd6908(%rip), %esi     # 0xe551a
xorw %bx, %si
testb %sil, %sil
je 0xec2d
movl %edx, %r9d
incl %edx
leaq 0xd59ca(%rip), %r10     # 0xe45f0
movb %bl, (%r9,%r10)
orb $0x8, %cl
movzwl %si, %esi
cmpl $0x100, %esi            # imm = 0x100
jb 0xec49
movl %edx, %esi
incl %edx
leaq 0xd59ad(%rip), %rbp     # 0xe45f0
movb %bh, (%rsi,%rbp)
orb $0x10, %cl
movb %cl, 0xd59a2(%rip)      # 0xe45f1
leaq 0xd599a(%rip), %rsi     # 0xe45f0
movb %al, 0xd68b4(%rip)      # 0xe5510
movw %di, 0xd68af(%rip)      # 0xe5512
movw %r8w, 0xd68ab(%rip)     # 0xe5516
movw %bx, 0xd68a8(%rip)      # 0xe551a
movl (%r14), %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f092
leaq 0x796e9d(%rip), %rcx    # 0x7a5b2c
cmpl $0x2, (%rcx)
jne 0xedc3
leaq 0x320481(%rip), %rsi    # 0x32f120
cmpb $0x0, 0xb5(%rsi)
movl 0x11e7eb(%rip), %r8d    # 0x12d498
jle 0xeccc
movb $0x0, 0xb5(%rsi)
leal 0x1(%r8), %ecx
xorl %edx, %edx
cmpl $0x2, %r8d
cmovll %ecx, %edx
movl %edx, 0x11e7cf(%rip)    # 0x12d498
movl %edx, %r8d
movl 0x11bfae(%rip), %ecx    # 0x12ac80
cmpl $-0x77, %ecx
movl $0xffffff88, %edx       # imm = 0xFFFFFF88
cmovll %edx, %ecx
movl $0x77, %edi
cmpl %edi, %ecx
cmovgel %edi, %ecx
movb %cl, 0x11e7a3(%rip)     # 0x12d490
movl 0x11bf88(%rip), %r9d    # 0x12ac7c
cmpl $-0x77, %r9d
cmovgel %r9d, %edx
cmpl %edi, %edx
cmovgel %edi, %edx
movw %dx, 0x11e78a(%rip)     # 0x12d492
movl 0x11bf6a(%rip), %edi    # 0x12ac78
cmpl $-0x6f, %edi
movl $0xffffff90, %r9d       # imm = 0xFFFFFF90
cmovgel %edi, %r9d
cmpl $0x6f, %r9d
movl $0x6f, %edi
cmovll %r9d, %edi
movw %di, 0x11e765(%rip)     # 0x12d494
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, 0x11e716(%rip)     # 0x12d496
leaq 0x796db9(%rip), %r8     # 0x7a5b40
movl (%r8,%rax,4), %eax
testw %ax, %ax
jns 0xed93
movl (%r14), %eax
movswq %ax, %rax
leaq 0xd67b2(%rip), %r8      # 0xe5550
movb %cl, (%rax,%r8)
leaq 0xd67f7(%rip), %rcx     # 0xe55a0
movw %dx, (%rcx,%rax,2)
leaq 0xd684c(%rip), %rcx     # 0xe5600
movw %di, (%rcx,%rax,2)
leaq 0xd6881(%rip), %rcx     # 0xe5640
movw %si, (%rcx,%rax,2)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd199