// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekmsc.c
// Function: newmap
void
newmap(int mapno)
{
     int       sn,p;
     int       savhealth;
     int       savestun;
     int       savereds;
     int       saveblues;
     int       saveaccutrk;
     int       newmap;

     if( option[4] != 0 ) {
          return;
     }
     if( mapno >= TOTALMAPS ) {
          return;
     }

     switch( mapno ) {
     case 0:
     case 1:
     case 2:
     case 3:
          newmap=mapreturn(currentmapno);
          if( newmap != mapno ) {
               crashgame("bad return map");
          }
          break;
     }

     drawscreen(screenpeek,0);
     printext((xdim>>1)-44,(ydim>>1)-32,"LOADING MAP",ALPHABET2,255);
     nextpage();

     initpaletteshifts();
     p=screenpeek;

    #if 0
     switch( currentmapno ) {
     case 0:
     case 1:
     case 2:
     case 3:
          warpretx=posx[p];
          warprety=posy[p];
          warpretz=posz[p];
          warpretang=ang[p];
          warpretsect=cursectnum[p];
          break;
     default:
          break;
     }
    #endif

     savhealth=health[p];
     savestun=stun[p];
     savereds=invredcards[p];
     saveblues=invbluecards[p];
     saveaccutrk=invaccutrak[p];

     newgame(mapnames[mapno]);

     health[p]=savhealth;
     stun[p]=savestun;
     invredcards[p]=savereds;
     invbluecards[p]=saveblues;
     invaccutrak[p]=saveaccutrk;

    #if 0
     switch( mapno ) {
     case 0:
     case 1:
     case 2:
     case 3:
          sn=playersprite[p];
          sprite[sn].x=warpretx;
          sprite[sn].y=warprety;
          sprite[sn].z=warpretz;
          changespritesect(sn,warpretsect);
          posx[p]=sprite[sn].x;
          posy[p]=sprite[sn].y;
          posz[p]=sprite[sn].z;
          ang[p]=((warpretang+1024)&2047);
          cursectnum[p]=sprite[sn].sectnum;
          updatesector(posx[p],posy[p],cursectnum[p]);
          break;
     default:
          break;
     }
    #endif

     switch( mapno ) {
     case 0:
     case 1:
     case 2:
     case 3:
          sn=playersprite[p];

          sprite[sn].x=warpretx;
          sprite[sn].y=warprety;
          sprite[sn].ang=warpretang;
          copybuf(&sprite[sn].x,&osprite[sn].x,3);
          changespritesect(sn,warpretsect);

          posx[p]=sprite[sn].x;
          posy[p]=sprite[sn].y;
          ang[p]=sprite[sn].ang;
          cursectnum[p]=sprite[sn].sectnum;

          //updatesector(posx[p],posy[p],cursectnum[p]);
          //pushmove(&posx[p],&posy[p],&posz[p],&cursectnum[p],128L,4<<8,4<<8,CLIPMASK0);
          break;
     default:
          break;
     }

     vel=0;
     svel=0;
     angvel=0;

     currentmapno=mapno;
     strcpy(tektempbuf, mapnames[mapno]);
     showmessage(Bstrupr(tektempbuf));

     musicfade();
     if( mapno <= 3 ) {
          menusong(1);
     }
     else {
          startmusic(mission);
     }

}

// Assembly:
cmpl $0x1f, %edi
jg 0x17410
leaq 0xba7b6(%rip), %rax     # 0xd1978
cmpb $0x0, 0x4(%rax)
jne 0x17410
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
cmpl $0x3, %edi
ja 0x171fe
movl 0x118325(%rip), %edi    # 0x12f50c
callq 0x1714d
cmpl %ebx, %eax
je 0x171fe
leaq 0x78911(%rip), %rdi     # 0x8fb08
xorl %eax, %eax
callq 0x2eb88
leaq 0xcd259(%rip), %r14     # 0xe445e
movswl (%r14), %edi
xorl %esi, %esi
callq 0xb541
leaq 0x5a1c55(%rip), %rax    # 0x5b8e6c
movl (%rax), %edi
sarl %edi
addl $-0x2c, %edi
leaq 0x5a1c4b(%rip), %rax    # 0x5b8e70
movl (%rax), %esi
sarl %esi
addl $-0x20, %esi
leaq 0x788e4(%rip), %rdx     # 0x8fb17
movl $0x15d, %ecx            # imm = 0x15D
movl $0xff, %r8d
callq 0xa15f
callq 0x46cdb
callq 0x1464a
movswq (%r14), %r15
leaq 0xcd338(%rip), %rax     # 0xe4590
movl (%rax,%r15,4), %ecx
movl %ecx, 0xc(%rsp)
leaq 0xcd129(%rip), %rax     # 0xe4390
movl (%rax,%r15,4), %r12d
leaq 0x119b1e(%rip), %rax    # 0x130d90
movl (%rax,%r15,4), %r13d
leaq 0x119b53(%rip), %rax    # 0x130dd0
movl (%rax,%r15,4), %r14d
leaq 0x119b88(%rip), %rax    # 0x130e10
movl (%rax,%r15,4), %ebp
movslq %ebx, %rax
leaq 0xbb37a(%rip), %rcx     # 0xd2610
movq %rax, 0x10(%rsp)
movq (%rcx,%rax,8), %rdi
callq 0x1705b
movl 0xc(%rsp), %eax
leaq 0xcd2e1(%rip), %rcx     # 0xe4590
movl %eax, (%rcx,%r15,4)
leaq 0xcd0d6(%rip), %rax     # 0xe4390
movl %r12d, (%rax,%r15,4)
leaq 0x119acb(%rip), %rax    # 0x130d90
movl %r13d, (%rax,%r15,4)
leaq 0x119b00(%rip), %rax    # 0x130dd0
movl %r14d, (%rax,%r15,4)
leaq 0x119b35(%rip), %rax    # 0x130e10
movl %ebp, (%rax,%r15,4)
cmpl $0x3, %ebx
ja 0x17397
leaq 0xce461(%rip), %rax     # 0xe5750
movswl (%rax,%r15,2), %eax
movl 0x119caa(%rip), %ecx    # 0x130fa4
movslq %eax, %r14
imulq $0x2c, %r14, %rbp
leaq 0x416828(%rip), %r13    # 0x42db30
movq %r13, %rdi
addq %rbp, %rdi
movl %ecx, (%r13,%rbp)
movl 0x119c8f(%rip), %eax    # 0x130fa8
movl %eax, 0x4(%r13,%rbp)
movzwl 0x119c87(%rip), %eax    # 0x130fac
movw %ax, 0x1c(%r13,%rbp)
leaq (%r14,%r14,2), %rsi
shlq $0x2, %rsi
addq 0xb9c76(%rip), %rsi     # 0xd0fb0
movl $0x3, %edx
callq 0x6110e
movswl 0x119c65(%rip), %esi    # 0x130fb0
movl %r14d, %edi
callq 0x48b21
movl (%r13,%rbp), %eax
leaq 0xcd171(%rip), %rcx     # 0xe44d0
movl %eax, (%rcx,%r15,4)
movl 0x4(%r13,%rbp), %eax
leaq 0xcd1a1(%rip), %rcx     # 0xe4510
movl %eax, (%rcx,%r15,4)
movzwl 0x1c(%r13,%rbp), %eax
leaq 0xcd130(%rip), %rcx     # 0xe44b0
movw %ax, (%rcx,%r15,2)
movzwl 0x18(%r13,%rbp), %eax
leaq 0xce38e(%rip), %rcx     # 0xe5720
movw %ax, (%rcx,%r15,2)
leaq 0xce442(%rip), %rax     # 0xe57e0
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0xce43b(%rip), %rax     # 0xe57e4
movl %ecx, (%rax)
leaq 0xce436(%rip), %rax     # 0xe57e8
movl %ecx, (%rax)
movl %ebx, 0x118152(%rip)    # 0x12f50c
movq 0x10(%rsp), %rax
leaq 0xbb24a(%rip), %rcx     # 0xd2610
movq (%rcx,%rax,8), %rsi
leaq 0x119a9f(%rip), %r14    # 0x130e70
movq %r14, %rdi
callq 0x85b0
movq %r14, %rdi
callq 0x35b9e
movq %rax, %rdi
xorl %eax, %eax
callq 0x14be7
xorl %eax, %eax
callq 0x1cd8a
cmpl $0x3, %ebx
leaq 0x18(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jg 0x17411
movl $0x1, %edi
jmp 0x1cd9c
retq
movl 0x1180f9(%rip), %edi    # 0x12f510
jmp 0x1ce25