// File: /workspace/github_c_makefile_star2_O2/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 0x54593e(%rip), %rax    # 0x553368
movl (%rax), %eax
movl 0xcca22(%rip), %ecx     # 0xda454
addl $0x3, %ecx
cmpl %ecx, %eax
jl 0xdb55
cmpb $0x0, 0xcca0f(%rip)     # 0xda453
je 0xdb55
movl %eax, 0xcca04(%rip)     # 0xda454
leaq 0x78e0cd(%rip), %rbx    # 0x79bb24
movl (%rbx), %eax
leaq 0x78e0d0(%rip), %r14    # 0x79bb30
cmpl (%r14), %eax
sete %cl
movb 0xb9f10(%rip), %al      # 0xc797c
testb %al, %al
sete %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0xdb1e
testb %al, %al
je 0xda85
callq 0xde98
callq 0x53dab
cmpl $0xf, %eax
jg 0xdb55
callq 0xc8a2
movb 0x1131e7(%rip), %al     # 0x120c85
movslq (%rbx), %rcx
leaq 0xcdaa8(%rip), %rdx     # 0xdb550
movb %al, (%rcx,%rdx)
movzwl 0x1131d4(%rip), %eax    # 0x120c86
leaq 0xcdae7(%rip), %rdx     # 0xdb5a0
movw %ax, (%rdx,%rcx,2)
movzwl 0x1131c4(%rip), %eax    # 0x120c88
leaq 0xcdb35(%rip), %rdx     # 0xdb600
movw %ax, (%rdx,%rcx,2)
movzwl 0xce0ce(%rip), %eax     # 0xdbba4
leaq 0xcdb63(%rip), %rdx     # 0xdb640
movw %ax, (%rdx,%rcx,2)
cmpb $0x0, 0xb9e94(%rip)     # 0xc797c
je 0xdd54
movb $0x0, 0xccafb(%rip)     # 0xda5f0
leaq 0x78e030(%rip), %rax    # 0x79bb2c
movl (%rax), %ebx
incl %ebx
sarl %ebx
movslq %ebx, %rax
pushq $0x1
popq %rcx
leaq 0xccae1(%rip), %r8      # 0xda5f0
cmpq %rax, %rcx
jg 0xdb64
movb $0x0, (%rcx,%r8)
incq %rcx
jmp 0xdb0f
callq 0xde98
callq 0x53dab
cmpl $0xf, %eax
jg 0xdb55
callq 0xc8a2
movb $0x1, 0xccab7(%rip)     # 0xda5f0
movb 0x113146(%rip), %al     # 0x120c85
cmpb 0xcd9cb(%rip), %al      # 0xdb510
jne 0xdc7f
pushq $0x2
popq %rdx
xorl %ecx, %ecx
jmp 0xdc8a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %ebx
pushq $0x8
popq %r9
leaq 0xcd9bf(%rip), %r10     # 0xdb530
leaq 0xcd9e8(%rip), %r11     # 0xdb560
leaq 0xcda41(%rip), %r15     # 0xdb5c0
leaq 0xcda9a(%rip), %r13     # 0xdb620
leaq 0x78dfb3(%rip), %r12    # 0x79bb40
movslq (%r14), %r14
testq %r14, %r14
js 0xdc52
leaq 0xcd9b0(%rip), %rax     # 0xdb550
movb (%r14,%rax), %bpl
xorl %eax, %eax
cmpb (%r14,%r10), %bpl
je 0xdbb8
movslq %ebx, %rax
incl %ebx
movb %bpl, (%rax,%r8)
pushq $0x1
popq %rax
leaq 0xcd9e1(%rip), %rcx     # 0xdb5a0
movzwl (%rcx,%r14,2), %edx
cmpw (%r11,%r14,2), %dx
je 0xdbd9
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %dx, (%rcx,%r8)
orl $0x2, %eax
leaq 0xcda20(%rip), %rcx     # 0xdb600
movzwl (%rcx,%r14,2), %esi
cmpw (%r15,%r14,2), %si
je 0xdbfa
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %si, (%rcx,%r8)
orl $0x4, %eax
leaq 0xcda3f(%rip), %rcx     # 0xdb640
movzwl (%rcx,%r14,2), %edi
cmpw (%r13,%r14,2), %di
je 0xdc1c
movslq %ebx, %rcx
leal 0x2(%rcx), %ebx
movw %di, (%rcx,%r8)
orl $0x8, %eax
movl %r9d, %ecx
andb $0x4, %cl
shll %cl, %eax
movl %r9d, %ecx
shrl $0x3, %ecx
orb %al, (%rcx,%r8)
addl $0x4, %r9d
movb %bpl, (%r14,%r10)
movw %dx, (%r11,%r14,2)
movw %si, (%r15,%r14,2)
movw %di, (%r13,%r14,2)
shlq $0x2, %r14
addq %r12, %r14
jmp 0xdb8d
leaq 0x78ded7(%rip), %rax    # 0x79bb30
movslq (%rax), %r14
leaq 0xcc98d(%rip), %r15     # 0xda5f0
movslq (%r12,%r14,4), %r14
testq %r14, %r14
js 0xde85
movl %r14d, %edi
movq %r15, %rsi
movl %ebx, %edx
callq 0x54ffd
jmp 0xdc63
movb %al, 0xcc96d(%rip)      # 0xda5f2
movb $0x1, %cl
pushq $0x3
popq %rdx
movzwl 0x112ff5(%rip), %edi    # 0x120c86
cmpw 0xcd87a(%rip), %di      # 0xdb512
je 0xdcae
movl %edx, %esi
leaq 0xcc94d(%rip), %r8      # 0xda5f0
addl $0x2, %edx
movw %di, (%rsi,%r8)
orb $0x2, %cl
movzwl 0x112fd2(%rip), %r8d    # 0x120c88
cmpw 0xcd858(%rip), %r8w     # 0xdb516
je 0xdcd4
movl %edx, %esi
leaq 0xcc927(%rip), %r9      # 0xda5f0
addl $0x2, %edx
movw %r8w, (%rsi,%r9)
orb $0x4, %cl
movzwl 0xcdec9(%rip), %ebx     # 0xdbba4
movzwl 0xcd838(%rip), %esi     # 0xdb51a
xorw %bx, %si
testb %sil, %sil
je 0xdcfd
movl %edx, %r9d
incl %edx
leaq 0xcc8fa(%rip), %r10     # 0xda5f0
movb %bl, (%r9,%r10)
orb $0x8, %cl
cmpw $0x100, %si             # imm = 0x100
jb 0xdd15
movl %edx, %esi
incl %edx
leaq 0xcc8e1(%rip), %rbp     # 0xda5f0
movb %bh, (%rsi,%rbp)
orb $0x10, %cl
movb %cl, 0xcc8d6(%rip)      # 0xda5f1
leaq 0xcc8ce(%rip), %rsi     # 0xda5f0
movb %al, 0xcd7e8(%rip)      # 0xdb510
movw %di, 0xcd7e3(%rip)      # 0xdb512
movw %r8w, 0xcd7df(%rip)     # 0xdb516
movw %bx, 0xcd7dc(%rip)      # 0xdb51a
movl (%r14), %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x54ffd
leaq 0x78ddd1(%rip), %rax    # 0x79bb2c
cmpl $0x2, (%rax)
jne 0xde85
leaq 0x3173b5(%rip), %rdx    # 0x325120
cmpb $0x0, 0xb5(%rdx)
movl 0x115720(%rip), %esi    # 0x123498
jle 0xdd94
movb $0x0, 0xb5(%rdx)
leal 0x1(%rsi), %eax
xorl %edi, %edi
cmpl $0x2, %esi
cmovll %eax, %edi
movl %edi, 0x115706(%rip)    # 0x123498
movl %edi, %esi
movl 0x112ee6(%rip), %eax    # 0x120c80
cmpl $-0x77, %eax
pushq $-0x78
popq %r8
cmovll %r8d, %eax
pushq $0x77
popq %rdi
cmpl %edi, %eax
cmovgel %edi, %eax
movb %al, 0x1156dd(%rip)     # 0x123490
movl 0x112ec2(%rip), %r9d    # 0x120c7c
cmpl $-0x77, %r9d
cmovgel %r9d, %r8d
cmpl %edi, %r8d
cmovgel %edi, %r8d
movw %r8w, 0x1156c1(%rip)    # 0x123492
movl 0x112ea1(%rip), %edi    # 0x120c78
cmpl $-0x6f, %edi
pushq $-0x70
popq %r10
cmovgel %edi, %r10d
cmpl $0x6f, %r10d
pushq $0x6f
popq %r9
cmovll %r10d, %r9d
movw %r9w, 0x11569e(%rip)    # 0x123494
shll $0xd, %esi
movsbl 0x45(%rdx), %edi
orl %esi, %edi
movsbl 0x47(%rdx), %esi
addl %esi, %esi
orl %edi, %esi
movsbl 0x49(%rdx), %edi
shll $0x2, %edi
movsbl 0x37(%rdx), %r10d
shll $0x3, %r10d
orl %edi, %r10d
orl %esi, %r10d
movl 0x50(%rdx), %esi
shll $0xa, %esi
movzbl 0x52(%rdx), %edx
shll $0xb, %edx
orl %esi, %edx
orl %r10d, %edx
orl $0x100, %edx            # imm = 0x100
movw %dx, 0x11565a(%rip)     # 0x123496
leaq 0x78dcfd(%rip), %rsi    # 0x79bb40
movl (%rsi,%rcx,4), %ecx
testw %cx, %cx
jns 0xde54
leaq 0x78dcde(%rip), %rcx    # 0x79bb30
movl (%rcx), %ecx
movswq %cx, %rcx
leaq 0xcd6f1(%rip), %rsi     # 0xdb550
movb %al, (%rcx,%rsi)
leaq 0xcd737(%rip), %rax     # 0xdb5a0
movw %r8w, (%rax,%rcx,2)
leaq 0xcd78b(%rip), %rax     # 0xdb600
movw %r9w, (%rax,%rcx,2)
leaq 0xcd7bf(%rip), %rax     # 0xdb640
movw %dx, (%rax,%rcx,2)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc3d8