// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq %rsi, 0x30(%rsp)
leal 0x41(%rdi), %ecx
pushq $0xe
popq %rdi
pushq $0x14
popq %rsi
pushq $0x13
popq %rdx
callq 0x1130
movq %rax, %r15
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1120
movq %r15, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x508d(%rip), %rcx      # 0xd6d2
pushq $0x4
popq %rsi
pushq $0x8
popq %rdx
movq %r15, %rdi
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
pushq $0x1
popq %rsi
movq %r15, %rdi
movl %esi, 0x24(%rsp)
callq 0x1080
pushq $0x2
popq %rcx
movl %ecx, %r14d
movq %rcx, 0x28(%rsp)
leal 0x7(%rcx), %r12d
leaq (,%r14,8), %rbp
xorl %ebx, %ebx
pushq $0x7
popq %r13
cmpq $0x28, %rbx
je 0x86fa
cmpq %rbx, %rbp
jne 0x86d6
movq %r15, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
leaq 0xa6cf(%rip), %rax      # 0x12d80
movq (%rax,%r14,8), %rcx
movq %r15, %rdi
movl %r12d, %esi
pushq $0x4
popq %rdx
xorl %eax, %eax
callq 0x1070
movq %r15, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
jmp 0x86f1
leaq 0xa6a3(%rip), %rax      # 0x12d80
movq (%rbx,%rax), %rcx
movq %r15, %rdi
movl %r13d, %esi
pushq $0x4
popq %rdx
xorl %eax, %eax
callq 0x1070
incl %r13d
addq $0x8, %rbx
jmp 0x8690
movq %r15, %rdi
callq 0x1100
movq %r15, %rdi
callq 0x11e0
cmpl $0xa, %eax
je 0x8743
cmpl $0x103, %eax            # imm = 0x103
movq 0x28(%rsp), %rcx
je 0x8734
cmpl $0x102, %eax            # imm = 0x102
jne 0x873d
xorl %eax, %eax
cmpl $0x4, %ecx
setl %al
addl %ecx, %eax
pushq $-0x1
popq %r12
movl %eax, %ecx
jmp 0x874b
xorl %eax, %eax
testl %ecx, %ecx
setg %al
subl %eax, %ecx
pushq $-0x1
popq %r12
jmp 0x874b
movq 0x28(%rsp), %rcx
movl %ecx, %r12d
cmpl $-0x1, %r12d
je 0x8676
cmpl $0x4, %r12d
je 0x8763
movl $0x0, 0x24(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
pushq $0x20
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x1120
movl %ebp, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl %ebp, (%rsp)
movq %r15, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x1120
movq %r15, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1100
movq %r15, %rdi
callq 0x1110
cmpl $0x3, %r12d
je 0x8c41
cmpl $0x1, %r12d
je 0x8917
testl %r12d, %r12d
jne 0x8c49
pushq $0xf
popq %r12
pushq $0x41
popq %rsi
pushq $0x11
popq %rdx
pushq $0x46
popq %rcx
movl %r12d, %edi
callq 0x1130
movq %rax, %r14
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1120
pushq $0x1
popq %r15
movq %r14, %rdi
movl %r15d, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x6367(%rip), %rcx      # 0xeba2
movq %r14, %rdi
movl %r15d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
leaq 0x4e69(%rip), %rcx      # 0xd6ca
pushq $0x2
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x633b(%rip), %rcx      # 0xebb3
pushq $0x8
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6333(%rip), %rcx      # 0xebc2
pushq $0x3
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6332(%rip), %rcx      # 0xebd8
pushq $0x9
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x632d(%rip), %rcx      # 0xebea
pushq $0x6
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6326(%rip), %rcx      # 0xebfa
pushq $0x7
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6343(%rip), %rcx      # 0xec2e
pushq $0x4
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6357(%rip), %rcx      # 0xec59
pushq $0x5
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
jmp 0x8bd6
pushq $0x18
popq %rdi
pushq $0x41
popq %rsi
pushq $0x11
popq %r12
pushq $0x46
popq %rcx
movl %r12d, %edx
callq 0x1130
movq %rax, %r14
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1120
pushq $0x1
popq %r15
movq %r14, %rdi
movl %r15d, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x6304(%rip), %rcx      # 0xec7a
pushq $0xf
popq %r13
movq %r14, %rdi
movl %r15d, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
leaq 0x62ed(%rip), %rcx      # 0xec8d
pushq $0x2
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x11c0
leaq 0x62d0(%rip), %rcx      # 0xec96
pushq $0x3
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x7c00, %esi           # imm = 0x7C00
xorl %edx, %edx
callq 0x1060
leaq 0x62b2(%rip), %rcx      # 0xec9e
pushq $0x4
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x62a6(%rip), %rcx      # 0xeca9
pushq $0x5
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x11c0
leaq 0x6289(%rip), %rcx      # 0xecb2
pushq $0x6
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xf500, %esi           # imm = 0xF500
xorl %edx, %edx
callq 0x1060
leaq 0x626c(%rip), %rcx      # 0xecbb
pushq $0x7
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x625e(%rip), %rcx      # 0xecc4
pushq $0x8
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6252(%rip), %rcx      # 0xeccf
pushq $0x9
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6244(%rip), %rcx      # 0xecd8
pushq $0xa
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6238(%rip), %rcx      # 0xece3
pushq $0xb
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6235(%rip), %rcx      # 0xecf7
pushq $0xc
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6231(%rip), %rcx      # 0xed0a
pushq $0xd
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6224(%rip), %rcx      # 0xed14
pushq $0xe
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6217(%rip), %rcx      # 0xed1e
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x620b(%rip), %rcx      # 0xed29
pushq $0x10
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x620a(%rip), %rcx      # 0xed3f
movq %r14, %rdi
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6200(%rip), %rcx      # 0xed4c
pushq $0x12
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x61f4(%rip), %rcx      # 0xed57
pushq $0x13
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x61eb(%rip), %rcx      # 0xed65
pushq $0x14
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x61de(%rip), %rcx      # 0xed6f
pushq $0x15
popq %rsi
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x11c0
leaq 0x61c3(%rip), %rcx      # 0xed7a
pushq $0x16
popq %rsi
movq %r14, %rdi
movl %r15d, %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
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x1120
movl %ebp, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl %ebp, (%rsp)
movq %r14, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x1120
movq %r14, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x1110
jmp 0x8c49
movq 0x30(%rsp), %rax
xorb $0x1, (%rax)
movl 0x24(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq