// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/src/tekmsc.c
// Function: domenu
void
domenu(void)
{
     char pal;
     int  i;
     int dax,dax2,day,day2;
     struct menu *mptr;
     static int firstpass;
    #ifdef DYNAMICSAVESETUP
     static int odiff,osoundv,omusicv,omousesens,oheadb;
    #endif

     if (activemenu == HELPSCREEN) {
          showhelpscreen();
          return;
     }
     if (firstpass == 0) {
          firstpass=1;
          getloadsavenames();
         #ifdef DYNAMICSAVESETUP
          odiff=difficulty;
          osoundv=soundv;
          omusicv=musicv;
          omousesens=mousesensitivity;
          oheadb=headbobon;
         #endif
          if (headbobon) {
               strcpy(headbobstr,"HEAD BOB ON");
          }
          else {
               strcpy(headbobstr,"HEAD BOB OFF");
          }
     }
     if (activemenu == 255) {
         #ifdef DYNAMICSAVESETUP
          if (odiff != difficulty || osoundv != soundv
             || omusicv != musicv || omousesens != mousesensitivity
             || oheadb != headbobon) {
               teksavesetup();
          }
         #endif
          playsound( S_MENUSOUND2 ,0,0,0,ST_IMMEDIATE);
          setup3dscreen();
          activemenu=0;
          firstpass=0;
          return;
     }
     vel=svel=angvel=0;
     mptr=&menu[activemenu][0];
     if (redrawborders) {
          dax=windowx1;
          dax2=windowx2;
          day=windowy1;
          day2=windowy2;
          if (dax2-dax < xdim-1 || day2-day < ydim-1) {
               setup3dscreen();
          }
          redrawborders=0;
     }
     if (selopt == 0) {
          switch (activemenu) {
          case MENULOADGAME:
          case MENUSAVEGAME:
               selopt=1;
               break;
          }
     }
     showmenu();
     for (i=0 ; i < MAXSUBOPTIONS ; i++) {
          if (mptr->label != NULL) {
               if (selopt == i) {
                    pal=4;
               }
               else {
                    pal=mptr->pal;
               }
               mprintf(mptr->x,mptr->y,mptr->proportional,mptr->shade,pal,
                    mptr->label);
               if (mptr->nextopt != NULL) {
                    mptr=mptr->nextopt;
               }
               else {
                    break;
               }
          }
     }
     if (activemenu == 5 && loadnewgame) {   // select a mission
          switch (loadnewgame) {
          case 1:   // day mission
               newgame("city.map");
               break;
          case 2:   // night mission
               newgame("hospital.map");
               break;
          case 3:
               newgame("police.map");
               break;
          case 4:
               newgame("warehse.map");
               break;
          }
          loadnewgame=0;
          activemenu=255;
     }
     if (activemenu == 6 || activemenu == 7) {    // load/save a game
          dax=(xdim>>1)-((MAXLOADSAVESIZE*tilesizx[MFONT_A])>>1);
          dax-=tilesizx[MFONT_A];
          for (i=1 ; i <= MAXLOADSAVEOPTS ; i++) {
               if (selopt == i) {
                    pal=4;
                    if (loctypemode == 0) {
                         mprintf(dax,2+i,0,0,pal,"%d %s",i,loadsavenames[i-1]);
                    }
                    else {
                         mprintf(dax,2+i,0,0,pal,"%d %s",i,lockeybuf);
                         if (totalclock > curblinkclock) {
                              curblinkclock=totalclock+(CLKIPS>>2);
                              curblink^=1;
                         }
                         if (curblink) {
                              day=((2+i)*MFONTYSTEP)+3;
                              if (ydim >= 400) {
                                   day<<=1;
                              }
                              rotatesprite((dax+(((int)strlen(lockeybuf)+1)*16)+5)<<16, day<<16, 65536l, 0, YELLOWLIGHTPIC,
                                   0, 0, 8+16, 0, 0, xdim-1, ydim-1);
                         }
                    }
               }
               else {
                    pal=1;
                    mprintf(dax,2+i,0,0,pal,"%d %s",i,loadsavenames[i-1]);
               }
          }
     }
     else if (activemenu == 8) {   // sound/music volume
          dax=(xdim>>1)-(tilesizx[SLIDERBARPIC]>>1);
          day=50;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          rotatesprite((dax+10+(soundv*7))<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          day=86;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          rotatesprite((dax+10+(musicv*7))<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
     }
     else if (activemenu == 9) {   // mouse sensitivity
          dax=(xdim>>1)-(tilesizx[SLIDERBARPIC]>>1);
          day=26;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          dax+=(10+(mousesensitivity*7));
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x63, 0x115bec(%rip)   # 0x12c4f4
jne 0x1691d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x177dd
cmpb $0x0, 0x1176b8(%rip)    # 0x12dfdc
jne 0x16973
movb $0x1, 0x1176af(%rip)    # 0x12dfdc
callq 0x17343
leaq 0xb8fa7(%rip), %rax     # 0xcf8e0
cmpl $0x0, (%rax)
movabsq $0x424f422044414548, %rax # imm = 0x424F422044414548
je 0x1695b
movq %rax, 0xb8411(%rip)     # 0xced60
movl $0x4e4f20, 0xb840f(%rip) # imm = 0x4E4F20
jmp 0x16973
movabsq $0x46464f20424f42, %rcx # imm = 0x46464F20424F42
movq %rcx, 0xb83f9(%rip)     # 0xced65
movq %rax, 0xb83ed(%rip)     # 0xced60
movslq 0x115b7a(%rip), %rax    # 0x12c4f4
cmpq $0xff, %rax
jne 0x169b3
movl $0x35, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1c1f1
callq 0x14903
movl $0x0, 0x115b4d(%rip)    # 0x12c4f4
movb $0x0, 0x11762e(%rip)    # 0x12dfdc
jmp 0x16e10
leaq 0xcbe2e(%rip), %rcx     # 0xe27e8
xorl %edx, %edx
movl %edx, (%rcx)
leaq 0xcbe1f(%rip), %rcx     # 0xe27e4
movl %edx, (%rcx)
leaq 0xcbe12(%rip), %rcx     # 0xe27e0
movl %edx, (%rcx)
leaq (%rax,%rax,2), %r14
cmpb $0x0, 0x117602(%rip)    # 0x12dfdd
je 0x16a2b
leaq 0x5691ec(%rip), %rax    # 0x57fbd0
leaq 0x59f455(%rip), %rcx    # 0x5b5e40
movl (%rcx), %ecx
subl (%rax), %ecx
leaq 0x59f456(%rip), %rax    # 0x5b5e4c
movl (%rax), %eax
decl %eax
cmpl %eax, %ecx
jl 0x16a1f
leaq 0x59f43f(%rip), %rax    # 0x5b5e44
movl (%rax), %eax
leaq 0x56afd2(%rip), %rcx    # 0x5819e0
subl (%rcx), %eax
leaq 0x59f439(%rip), %rcx    # 0x5b5e50
movl (%rcx), %ecx
decl %ecx
cmpl %ecx, %eax
jge 0x16a24
callq 0x14903
movb $0x0, 0x1175b2(%rip)    # 0x12dfdd
shlq $0x6, %r14
leaq 0xb833a(%rip), %rbx     # 0xced70
cmpl $0x0, 0xb8bb7(%rip)     # 0xcf5f4
jne 0x16a57
movl 0x115aaf(%rip), %eax    # 0x12c4f4
andl $-0x2, %eax
cmpl $0x6, %eax
jne 0x16a57
movl $0x1, 0xb8b9d(%rip)     # 0xcf5f4
addq %r14, %rbx
callq 0x17699
xorl %ebp, %ebp
movq 0x8(%rbx), %r9
testq %r9, %r9
je 0x16a9a
movb $0x4, %al
cmpl 0xb8b82(%rip), %ebp     # 0xcf5f4
je 0x16a77
movb 0x6(%rbx), %al
movswl (%rbx), %edi
movswl 0x2(%rbx), %esi
movsbl 0x4(%rbx), %edx
movsbl 0x5(%rbx), %ecx
movsbl %al, %r8d
xorl %eax, %eax
callq 0x173e1
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
je 0x16aa1
incl %ebp
cmpl $0x6, %ebp
jne 0x16a61
cmpl $0x5, 0x115a4c(%rip)    # 0x12c4f4
sete %cl
movl 0x11752f(%rip), %eax    # 0x12dfe0
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x16aec
cmpl $0x4, %eax
ja 0x16ad8
cltq
leaq 0x75aa1(%rip), %rcx     # 0x8c56c
movslq -0x4(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x16f82
movl $0x0, 0x1174fe(%rip)    # 0x12dfe0
movl $0xff, 0x115a08(%rip)   # 0x12c4f4
movl 0x115a02(%rip), %eax    # 0x12c4f4
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x16c9d
leaq 0x59f345(%rip), %rax    # 0x5b5e4c
movl (%rax), %eax
sarl %eax
leaq 0x5a736e(%rip), %rcx    # 0x5bde80
movswl 0xbaa(%rcx), %ecx
leal (,%rcx,4), %edx
leal (%rdx,%rdx,2), %edx
sarl %edx
addl %ecx, %edx
subl %edx, %eax
movswl %ax, %ebx
shll $0x10, %eax
addl $0x100000, %eax         # imm = 0x100000
movq %rax, 0x10(%rsp)
movl $0x1, %r12d
movl $0x27, %ebp
leaq 0x117455(%rip), %r13    # 0x12dfa0
leaq 0x75f9b(%rip), %r14     # 0x8caed
movl %ebx, 0xc(%rsp)
movl 0xb8a98(%rip), %eax     # 0xcf5f4
cmpq %rax, %r12
jne 0x16c48
cmpl $0x0, 0x117478(%rip)    # 0x12dfe4
je 0x16c5e
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x4, %r8d
movq %r14, %r9
xorl %eax, %eax
leaq 0x117456(%rip), %r10    # 0x12dfe8
pushq %r10
pushq %r12
callq 0x173e1
addq $0x10, %rsp
leaq 0x5437a2(%rip), %rax    # 0x55a348
movl (%rax), %eax
cmpl 0x117446(%rip), %eax    # 0x12dff4
jle 0x16bc0
addl $0x1e, %eax
movl %eax, 0x11743b(%rip)    # 0x12dff4
xorb $0x1, 0x117438(%rip)    # 0x12dff8
cmpl $0x0, 0x117431(%rip)    # 0x12dff8
je 0x16c84
movq %r14, %rbx
leaq 0x59f279(%rip), %rax    # 0x5b5e50
movl (%rax), %r14d
cmpl $0x190, %r14d           # imm = 0x190
setge %cl
movl %ebp, %r15d
shll %cl, %r15d
leaq 0x1173f7(%rip), %rdi    # 0x12dfe8
callq 0x85a0
shll $0x14, %eax
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %edi
addl $0x50000, %edi          # imm = 0x50000
shll $0x10, %r15d
leaq 0x59f23a(%rip), %rax    # 0x5b5e4c
movl (%rax), %eax
decl %eax
decl %r14d
movl %r15d, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x624, %r8d            # imm = 0x624
xorl %r9d, %r9d
pushq %r14
movq %rbx, %r14
movl 0x14(%rsp), %ebx
pushq %rax
xorl %eax, %eax
pushq %rax
pushq %rax
pushq $0x18
pushq %rax
callq 0x4bca3
addq $0x30, %rsp
jmp 0x16c84
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
jmp 0x16c72
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x4, %r8d
movq %r14, %r9
xorl %eax, %eax
pushq %r13
pushq %r12
callq 0x173e1
addq $0x10, %rsp
incq %r12
addl $0xc, %ebp
addq $0xc, %r13
cmpq $0x6, %r12
jne 0x16b56
jmp 0x16e10
cmpl $0x9, %eax
je 0x16e1f
cmpl $0x8, %eax
jne 0x16e10
leaq 0x59f196(%rip), %r12    # 0x5b5e4c
movl (%r12), %eax
movl %eax, %r13d
sarl %r13d
leaq 0x5a71b9(%rip), %rcx    # 0x5bde80
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %r13d
leaq 0x59f173(%rip), %r15    # 0x5b5e50
movl (%r15), %r10d
movl $0x190, %ecx            # imm = 0x190
cmpl %ecx, %r10d
movl $0x640000, %ecx         # imm = 0x640000
movl $0x320000, %ebp         # imm = 0x320000
cmovgel %ecx, %ebp
movl %r13d, %ebx
shll $0x10, %ebx
decl %eax
decl %r10d
xorl %r14d, %r14d
movl $0x18, %r11d
movl %ebx, %edi
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r11
pushq %r14
callq 0x4bca3
addq $0x30, %rsp
movl 0xb88c5(%rip), %eax     # 0xcf5fc
leal (,%rax,8), %ecx
subl %eax, %ecx
leal (%rcx,%r13), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r12), %eax
decl %eax
movl (%r15), %r10d
decl %r10d
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
movl $0x18, %eax
pushq %rax
pushq %r14
callq 0x4bca3
addq $0x30, %rsp
movl (%r15), %eax
movl $0x190, %ecx            # imm = 0x190
cmpl %ecx, %eax
movl $0xac0000, %ecx         # imm = 0xAC0000
movl $0x560000, %ebp         # imm = 0x560000
cmovgel %ecx, %ebp
movl (%r12), %r10d
decl %r10d
decl %eax
movl %ebx, %edi
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %rax
pushq %r10
pushq %r14
pushq %r14
movl $0x18, %ebx
pushq %rbx
pushq %r14
callq 0x4bca3
addq $0x30, %rsp
movl 0xb8826(%rip), %eax     # 0xcf5f8
leal (,%rax,8), %ecx
subl %eax, %ecx
leal (%rcx,%r13), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r12), %eax
decl %eax
movl (%r15), %r10d
decl %r10d
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %rbx
jmp 0x16edb
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x59f026(%rip), %r15    # 0x5b5e4c
movl (%r15), %eax
movl %eax, %ebp
sarl %ebp
leaq 0x5a704c(%rip), %rcx    # 0x5bde80
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %ebp
leaq 0x59f007(%rip), %r13    # 0x5b5e50
movl (%r13), %r10d
cmpl $0x190, %r10d           # imm = 0x190
movl $0x340000, %ecx         # imm = 0x340000
movl $0x1a0000, %ebx         # imm = 0x1A0000
cmovgel %ecx, %ebx
movl %ebp, %edi
shll $0x10, %edi
decl %eax
decl %r10d
xorl %r14d, %r14d
movl $0x18, %r12d
movl %ebx, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r12
pushq %r14
callq 0x4bca3
addq $0x30, %rsp
movl 0x11715c(%rip), %eax    # 0x12dffc
leal (,%rax,8), %edi
subl %eax, %edi
addl %ebp, %edi
shll $0x10, %edi
addl $0xa0000, %edi          # imm = 0xA0000
movl (%r15), %eax
decl %eax
movl (%r13), %r10d
decl %r10d
movl %ebx, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r12
pushq %r14
callq 0x4bca3
addq $0x48, %rsp
jmp 0x16e14