// File: /workspace/github_c_makefile_star2_O3/S01den[P]Lost_CavernRL/menu.c
// Function: pauseMenu
int pauseMenu(int y, int *keyboard)
{
	int ret = 0;
	int select = 2;
	int choice = -1;
	int i = 0;
	int key = 0;

	WINDOW *win;
	win = newwin(14,20,LONGUEUR/2,LARGEUR/2+y);
	box(win,0,0);
	wattron(win, A_UNDERLINE);
	mvwprintw(win,4,8,"MENU");
	wattroff(win, A_UNDERLINE);
	keypad(win, TRUE);

	char *menus[] = {"KEYS LIST","TILES LIST","RETURN TO GAME","CHANGE KEYBOARD","EXIT THE GAME"};

	while(1)
	{
		for(i = 0; i < 5; i++)
		{
			if(i == select)
			{
				wattron(win, COLOR_PAIR(STAIRS_COLOR));
				mvwprintw(win, i+7, 4, menus[i]);
				wattroff(win,COLOR_PAIR(STAIRS_COLOR));
			}
			else
			{
				mvwprintw(win, i+7, 4, menus[i]);
			}
		}

		wrefresh(win);

		key = wgetch(win);
		switch(key)
		{	
			case KEY_DOWN:
				if(select+1<=4)
					select++;
				break;

			case KEY_UP:
				if(select-1 >= 0)
					select--;
				break;

			case'\n':
				choice = select;
				break;
		}

		if(choice != -1)
			break;
	}

	if(choice == 4)
		ret = 1;

	box(win, ' ', ' ');
	wborder(win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
	wclear(win);
	wrefresh(win);
	delwin(win);

	if(choice == 0)
	{
		WINDOW *winKey;
		winKey = newwin(15,65,LONGUEUR/2-2,LARGEUR/2+5);
		box(winKey,0,0);
		keypad(winKey, TRUE);	

		wattron(winKey,A_UNDERLINE);
		mvwprintw(winKey,1,15,"*** KEY LIST ***");
		wattroff(winKey,A_UNDERLINE);
		mvwprintw(winKey,2,1,"[ESC] : MENU");
		mvwprintw(winKey,8,1,"c : CRAFT MENU");
		mvwprintw(winKey,3,1,"[SPACE] : MISS A TURN");
		mvwprintw(winKey,9,1,", : QUEST JOURNAL");
		mvwprintw(winKey,6,1,"[ARROWS] : MOVE");
		mvwprintw(winKey,7,1,"zsqdaewx : ATTACK ON A DIRECTION (OR TALK TO A PNJ)");
		mvwprintw(winKey,4,1,"A_NUMBER : USE AN OBJECT IN YOUR INVENTORY");
		mvwprintw(winKey,5,1,"[ENTER] : USE YOUR SPECIAL POWER");

		wrefresh(winKey);
		wgetch(winKey);

		box(winKey, ' ', ' ');
		wborder(winKey, ' ', ' ', ' ',' ',' ',' ',' ',' ');
		wclear(winKey);
		wrefresh(winKey);
		delwin(winKey);
	}
	else if(choice == 1)
	{
		WINDOW *winKey;
		winKey = newwin(24,65,LONGUEUR/2-2,LARGEUR/2+5);
		box(winKey,0,0);
		keypad(winKey, TRUE);	

		wattron(winKey,A_UNDERLINE);
		mvwprintw(winKey,1,15,"*** TILES LIST ***");
		wattroff(winKey,A_UNDERLINE);
		mvwprintw(winKey,2,1,"# : WALL");
		wattron(winKey,COLOR_PAIR(124));
		mvwprintw(winKey,3,1,"# : GEM");
		wattroff(winKey,COLOR_PAIR(124));
		mvwprintw(winKey,4,1,"@ : PLAYER");
		mvwprintw(winKey,5,1,"= : TRAP");
		wattron(winKey,COLOR_PAIR(COLOR_LAVA));
		mvwprintw(winKey,6,1,"* : LAVA");
		wattroff(winKey,COLOR_PAIR(COLOR_LAVA));
		mvwprintw(winKey,7,1,"* : BOMB");
		mvwprintw(winKey,8,1,"> : STAIRS");
		mvwprintw(winKey,9,1,"! : DRUG");
		mvwprintw(winKey,10,1,"+ : SHIELD");
		mvwprintw(winKey,11,1,"; : DISTANCE WEAPON");
		mvwprintw(winKey,12,1,"/ : CONTACT WEAPON");
		mvwprintw(winKey,13,1,"[ : ARMOR");
		mvwprintw(winKey,14,1,"d : DROID");
		mvwprintw(winKey,15,1,"t : TURRET");
		mvwprintw(winKey,16,1,"n : INFECTED GUARDIAN");
		mvwprintw(winKey,17,1,"g : GUARDIAN");
		mvwprintw(winKey,18,1,"c : CLERIC");
		mvwprintw(winKey,19,1,"s : SCIENTIST");
		mvwprintw(winKey,20,1,"e : ERMIT");
		mvwprintw(winKey,21,1,"w : WORKER");
		wattron(winKey,COLOR_PAIR(47));
		mvwprintw(winKey,22,1,".: RADIOACTIVITY");
		wattroff(winKey,COLOR_PAIR(47));

		wrefresh(winKey);
		wgetch(winKey);

		box(winKey, ' ', ' ');
		wborder(winKey, ' ', ' ', ' ',' ',' ',' ',' ',' ');
		wclear(winKey);
		wrefresh(winKey);
		delwin(winKey);	
	}
	if(choice == 3)
	{
		(*keyboard) ^= 1;
	}

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
leal 0x41(%rdi), %ecx
movl $0xe, %edi
movl $0x14, %esi
movl $0x13, %edx
callq 0x1130
movq %rax, %r15
subq $0x8, %rsp
xorl %eax, %eax
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq %rax
callq 0x1120
addq $0x20, %rsp
movq %r15, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x5d51(%rip), %rcx      # 0xf712
movq %r15, %rdi
movl $0x4, %esi
movl $0x8, %edx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
movq %r15, %rdi
movl $0x1, %esi
callq 0x1080
movl $0x2, %ecx
movl %ecx, %r14d
movq %rcx, 0x8(%rsp)
leal 0x7(%rcx), %ebx
leaq (,%r14,8), %r13
movl $0x7, %ebp
xorl %r12d, %r12d
cmpq %r12, %r13
jne 0x9a52
movq %r15, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
leaq 0xa354(%rip), %rax      # 0x13d80
movq (%rax,%r14,8), %rcx
movq %r15, %rdi
movl %ebx, %esi
movl $0x4, %edx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
jmp 0x9a6e
leaq 0xa327(%rip), %rax      # 0x13d80
movq (%r12,%rax), %rcx
movq %r15, %rdi
movl %ebp, %esi
movl $0x4, %edx
xorl %eax, %eax
callq 0x1070
incl %ebp
addq $0x8, %r12
cmpq $0x28, %r12
jne 0x9a11
movq %r15, %rdi
callq 0x1100
movq %r15, %rdi
callq 0x11e0
cmpl $0xa, %eax
je 0x9ac0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x103, %eax            # imm = 0x103
movq 0x8(%rsp), %rcx
je 0x9ab5
cmpl $0x102, %eax            # imm = 0x102
jne 0x9ac7
xorl %eax, %eax
cmpl $0x4, %ecx
setl %al
addl %ecx, %eax
movl %eax, %ecx
jmp 0x9ac7
xorl %eax, %eax
testl %ecx, %ecx
setg %al
subl %eax, %ecx
jmp 0x9ac7
movq 0x8(%rsp), %rcx
movl %ecx, %ebp
cmpl $-0x1, %ebp
je 0x99f6
cmpl $0x4, %ebp
jne 0x9adc
movl $0x1, %ebx
jmp 0x9ade
xorl %ebx, %ebx
subq $0x8, %rsp
xorl %eax, %eax
movl $0x20, %r14d
movq %r15, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq %rax
callq 0x1120
addq $0x18, %rsp
movq %r15, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
movl $0x20, %r9d
pushq %r14
pushq %r14
pushq %r14
callq 0x1120
addq $0x20, %rsp
movq %r15, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1100
movq %r15, %rdi
callq 0x1110
cmpl $0x3, %ebp
je 0xa077
cmpl $0x1, %ebp
je 0x9cd4
testl %ebp, %ebp
jne 0xa07f
movl $0xf, %edi
movl $0x41, %esi
movl $0x11, %edx
movl $0x46, %ecx
callq 0x1130
movq %rax, %r14
subq $0x8, %rsp
xorl %r15d, %r15d
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r15
pushq %r15
pushq %r15
callq 0x1120
addq $0x20, %rsp
movq %r14, %rdi
movl $0x1, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x700e(%rip), %rcx      # 0x10be2
movq %r14, %rdi
movl $0x1, %esi
movl $0xf, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
leaq 0x5b0c(%rip), %rcx      # 0xf70a
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fda(%rip), %rcx      # 0x10bf3
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fce(%rip), %rcx      # 0x10c02
movq %r14, %rdi
movl $0x3, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fc9(%rip), %rcx      # 0x10c18
movq %r14, %rdi
movl $0x9, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fc0(%rip), %rcx      # 0x10c2a
movq %r14, %rdi
movl $0x6, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fb5(%rip), %rcx      # 0x10c3a
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fce(%rip), %rcx      # 0x10c6e
movq %r14, %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fde(%rip), %rcx      # 0x10c99
movq %r14, %rdi
movl $0x5, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
jmp 0x9fec
movl $0x18, %edi
movl $0x41, %esi
movl $0x11, %edx
movl $0x46, %ecx
callq 0x1130
movq %rax, %r14
subq $0x8, %rsp
xorl %r15d, %r15d
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r15
pushq %r15
pushq %r15
callq 0x1120
addq $0x20, %rsp
movq %r14, %rdi
movl $0x1, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x6f82(%rip), %rcx      # 0x10cba
movq %r14, %rdi
movl $0x1, %esi
movl $0xf, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
leaq 0x6f6b(%rip), %rcx      # 0x10ccd
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x11c0
leaq 0x6f4a(%rip), %rcx      # 0x10cd6
movq %r14, %rdi
movl $0x3, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x1060
leaq 0x6f28(%rip), %rcx      # 0x10cde
movq %r14, %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6f18(%rip), %rcx      # 0x10ce9
movq %r14, %rdi
movl $0x5, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x11c0
leaq 0x6ef7(%rip), %rcx      # 0x10cf2
movq %r14, %rdi
movl $0x6, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x1060
leaq 0x6ed6(%rip), %rcx      # 0x10cfb
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6ec4(%rip), %rcx      # 0x10d04
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6eb4(%rip), %rcx      # 0x10d0f
movq %r14, %rdi
movl $0x9, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6ea2(%rip), %rcx      # 0x10d18
movq %r14, %rdi
movl $0xa, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e92(%rip), %rcx      # 0x10d23
movq %r14, %rdi
movl $0xb, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e8b(%rip), %rcx      # 0x10d37
movq %r14, %rdi
movl $0xc, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e83(%rip), %rcx      # 0x10d4a
movq %r14, %rdi
movl $0xd, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e72(%rip), %rcx      # 0x10d54
movq %r14, %rdi
movl $0xe, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e61(%rip), %rcx      # 0x10d5e
movq %r14, %rdi
movl $0xf, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e51(%rip), %rcx      # 0x10d69
movq %r14, %rdi
movl $0x10, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e4c(%rip), %rcx      # 0x10d7f
movq %r14, %rdi
movl $0x11, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e3e(%rip), %rcx      # 0x10d8c
movq %r14, %rdi
movl $0x12, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e2e(%rip), %rcx      # 0x10d97
movq %r14, %rdi
movl $0x13, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e21(%rip), %rcx      # 0x10da5
movq %r14, %rdi
movl $0x14, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e10(%rip), %rcx      # 0x10daf
movq %r14, %rdi
movl $0x15, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x11c0
leaq 0x6df1(%rip), %rcx      # 0x10dba
movq %r14, %rdi
movl $0x16, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x1060
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x11e0
subq $0x8, %rsp
movl $0x20, %r12d
movq %r14, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq %r15
pushq %r15
pushq %r15
callq 0x1120
addq $0x18, %rsp
movq %r14, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
movl $0x20, %r9d
pushq %r12
pushq %r12
pushq %r12
callq 0x1120
addq $0x20, %rsp
movq %r14, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x1110
jmp 0xa07f
movq 0x10(%rsp), %rax
xorb $0x1, (%rax)
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq