// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rsi, (%rsp)
leal 0x41(%rdi), %ecx
movl $0xe, %edi
movl $0x14, %esi
movl $0x13, %edx
callq 0x1130
movq %rax, %r14
subq $0x8, %rsp
xorl %eax, %eax
movq %r14, %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 %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x5de4(%rip), %rcx      # 0xf6d2
movq %r14, %rdi
movl $0x4, %esi
movl $0x8, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x1060
movq %r14, %rdi
movl $0x1, %esi
callq 0x1080
movl $0x2, %r12d
leaq 0xa455(%rip), %r13      # 0x13d80
movl %r12d, %r15d
shlq $0x3, %r15
movl $0x7, %ebp
xorl %ebx, %ebx
cmpq %rbx, %r15
jne 0x9973
movq %r14, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x11c0
movq (%rbx,%r13), %rcx
movq %r14, %rdi
movl %ebp, %esi
movl $0x4, %edx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movl $0xfe00, %esi           # imm = 0xFE00
xorl %edx, %edx
callq 0x1060
jmp 0x9988
movq (%rbx,%r13), %rcx
movq %r14, %rdi
movl %ebp, %esi
movl $0x4, %edx
xorl %eax, %eax
callq 0x1070
incl %ebp
addq $0x8, %rbx
cmpq $0x28, %rbx
jne 0x9939
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x11e0
cmpl $0xa, %eax
je 0x99d8
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x103, %eax            # imm = 0x103
je 0x99cb
cmpl $0x102, %eax            # imm = 0x102
jne 0x99db
xorl %eax, %eax
cmpl $0x4, %r12d
setl %al
addl %eax, %r12d
jmp 0x99db
xorl %eax, %eax
testl %r12d, %r12d
setg %al
subl %eax, %r12d
jmp 0x99db
movl %r12d, %r15d
cmpl $-0x1, %r15d
je 0x992b
cmpl $0x4, %r15d
jne 0x99f2
movl $0x1, %ebp
jmp 0x99f4
xorl %ebp, %ebp
subq $0x8, %rsp
xorl %eax, %eax
movl $0x20, %ebx
movq %r14, %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 %r14, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
movl $0x20, %r9d
pushq %rbx
pushq %rbx
pushq %rbx
callq 0x1120
addq $0x20, %rsp
movq %r14, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x1110
cmpl $0x3, %r15d
je 0x9f83
cmpl $0x1, %r15d
je 0x9be5
testl %r15d, %r15d
jne 0x9f8a
movl $0xf, %edi
movl $0x41, %esi
movl $0x11, %edx
movl $0x46, %ecx
callq 0x1130
movq %rax, %r14
subq $0x8, %rsp
xorl %eax, %eax
movq %r14, %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 %r14, %rdi
movl $0x1, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x701d(%rip), %rcx      # 0x10b02
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 0x5bbb(%rip), %rcx      # 0xf6ca
movq %r14, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fe9(%rip), %rcx      # 0x10b13
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fdd(%rip), %rcx      # 0x10b22
movq %r14, %rdi
movl $0x3, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fd8(%rip), %rcx      # 0x10b38
movq %r14, %rdi
movl $0x9, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fcf(%rip), %rcx      # 0x10b4a
movq %r14, %rdi
movl $0x6, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fc4(%rip), %rcx      # 0x10b5a
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fdd(%rip), %rcx      # 0x10b8e
movq %r14, %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6fed(%rip), %rcx      # 0x10bb9
movq %r14, %rdi
movl $0x5, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
jmp 0x9ef9
movl $0x18, %edi
movl $0x41, %esi
movl $0x11, %edx
movl $0x46, %ecx
callq 0x1130
movq %rax, %r14
subq $0x8, %rsp
xorl %eax, %eax
movq %r14, %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 %r14, %rdi
movl $0x1, %esi
callq 0x1080
movq %r14, %rdi
movl $0x20000, %esi          # imm = 0x20000
xorl %edx, %edx
callq 0x11c0
leaq 0x6f95(%rip), %rcx      # 0x10bda
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 0x6f7e(%rip), %rcx      # 0x10bed
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 0x6f5d(%rip), %rcx      # 0x10bf6
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 0x6f3b(%rip), %rcx      # 0x10bfe
movq %r14, %rdi
movl $0x4, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6f2b(%rip), %rcx      # 0x10c09
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 0x6f0a(%rip), %rcx      # 0x10c12
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 0x6ee9(%rip), %rcx      # 0x10c1b
movq %r14, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6ed7(%rip), %rcx      # 0x10c24
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6ec7(%rip), %rcx      # 0x10c2f
movq %r14, %rdi
movl $0x9, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6eb5(%rip), %rcx      # 0x10c38
movq %r14, %rdi
movl $0xa, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6ea5(%rip), %rcx      # 0x10c43
movq %r14, %rdi
movl $0xb, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e9e(%rip), %rcx      # 0x10c57
movq %r14, %rdi
movl $0xc, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e96(%rip), %rcx      # 0x10c6a
movq %r14, %rdi
movl $0xd, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e85(%rip), %rcx      # 0x10c74
movq %r14, %rdi
movl $0xe, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e74(%rip), %rcx      # 0x10c7e
movq %r14, %rdi
movl $0xf, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e64(%rip), %rcx      # 0x10c89
movq %r14, %rdi
movl $0x10, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e5f(%rip), %rcx      # 0x10c9f
movq %r14, %rdi
movl $0x11, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e51(%rip), %rcx      # 0x10cac
movq %r14, %rdi
movl $0x12, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e41(%rip), %rcx      # 0x10cb7
movq %r14, %rdi
movl $0x13, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e34(%rip), %rcx      # 0x10cc5
movq %r14, %rdi
movl $0x14, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6e23(%rip), %rcx      # 0x10ccf
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 0x6e04(%rip), %rcx      # 0x10cda
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
xorl %eax, %eax
movl $0x20, %ebx
movq %r14, %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 %r14, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
movl $0x20, %r9d
pushq %rbx
pushq %rbx
pushq %rbx
callq 0x1120
addq $0x20, %rsp
movq %r14, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1100
movq %r14, %rdi
callq 0x1110
cmpl $0x3, %r15d
jne 0x9f8a
movq (%rsp), %rax
xorb $0x1, (%rax)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq