// File: /workspace/github_c_makefile_star2_O2/S01den[P]Lost_CavernRL/menu.c
// Function: objectMenu
void objectMenu(Weapons *weapon, Weapons listWeapons[], Armor *armor, Armor listArmors[], Inventory inventory[], Player *player, int *component, int caseInventory, int *colorPrint, char messagePrint[], int type)
{
	WINDOW* win;
	win = newwin(9,60,(LONGUEUR-5)/2+7,(LARGEUR-15)/2);
	box(win, 0 , 0);
	
	if(type == 1) // weapon
	{
		wattron(win,A_BOLD);
		mvwprintw(win,1,5,"%s",listWeapons[inventory[caseInventory].object].name);
		wattroff(win,A_BOLD);
		mvwprintw(win,2,1,"Degats: %d     State: %d",listWeapons[inventory[caseInventory].object].degat,listWeapons[inventory[caseInventory].object].state);
		mvwprintw(win,4,1,"%s",listWeapons[inventory[caseInventory].object].description);
		mvwprintw(win,6,1,"1) EQUIP");
		mvwprintw(win,7,1,"2) DESTROY TO COLLECT COMPONENTS");

		wrefresh(win);	

		int charMenu = wgetch(win);
		switch(charMenu)
		{
			case '1':
					if(listWeapons[inventory[caseInventory].object].strengthRequired <= player->strength)
					{
						int indiceWeapChange = weapon->indice;
						listWeapons[indiceWeapChange].state = weapon->state;
						*weapon = listWeapons[inventory[caseInventory].object];
						inventory[caseInventory].type = 0;
						inventory[caseInventory].object = indiceWeapChange;
					}
					else
					{
						*colorPrint = 197; 
						snprintf(messagePrint,100,"YOU MUST HAVE A MINIMUM STRENGTH OF %d !",listWeapons[inventory[caseInventory].object].strengthRequired);

					}
					break;
				
				case '2':
						*component += listWeapons[inventory[caseInventory].object].cost;
						snprintf(messagePrint,100,"BY DESTROYING THIS ITEM, YOU EARNED %d COMPONENTS !",listWeapons[inventory[caseInventory].object].cost);
						inventory[caseInventory].type = -1;
						inventory[caseInventory].object = 0;
						*colorPrint = 47; 
					break;
		}

	}
	else
	{
		wattron(win,A_BOLD);
		mvwprintw(win,1,5,"%s",listArmors[inventory[caseInventory].object].name);
		wattroff(win,A_BOLD);
		mvwprintw(win,2,1,"Resistance: %d    State: %d",listArmors[inventory[caseInventory].object].resistance,listArmors[inventory[caseInventory].object].state);
		mvwprintw(win,4,1,"%s",listArmors[inventory[caseInventory].object].description);
		mvwprintw(win,6,1,"1) EQUIP");
		mvwprintw(win,7,1,"2) DESTROY TO COLLECT COMPONENTS");

		int charMenu = wgetch(win);
		switch(charMenu)
		{
			case '1':

					if(listArmors[inventory[caseInventory].object].strengthRequired <= player->strength)
					{
						int indiceArmorChange = armor->indice;
						listArmors[indiceArmorChange].state = armor->state;
						*armor = listArmors[inventory[caseInventory].object];
						inventory[caseInventory].type = 1;
						inventory[caseInventory].object = indiceArmorChange;
					}
					else
					{
						*colorPrint = 197; 
						snprintf(messagePrint,100,"YOU MUST HAVE A MINIMUM STRENGTH OF %d !",listArmors[inventory[caseInventory].object].strengthRequired);
					}
					break;
				
				case '2':
						*component += listArmors[inventory[caseInventory].object].cost;
						snprintf(messagePrint,100,"BY DESTROYING THIS ITEM, YOU EARNED %d COMPONENTS !",listArmors[inventory[caseInventory].object].cost);
						inventory[caseInventory].type = -1;
						inventory[caseInventory].object = 0;
						*colorPrint = 47; 
					break;
		}
	}

	wrefresh(win);	

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x30(%rsp)
movq %r8, %r14
movq %rcx, %rbp
movq %rdx, 0x38(%rsp)
movq %rsi, %r13
movq %rdi, 0x40(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x28(%rsp)
movslq 0x88(%rsp), %r12
movl 0xa0(%rsp), %r15d
pushq $0x9
popq %rdi
pushq $0x3c
popq %rsi
pushq $0x18
popq %rdx
pushq $0x39
popq %rcx
callq 0x1130
movq %rax, %rbx
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 %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
movslq 0x4(%r14,%r12,8), %rax
cmpl $0x1, %r15d
jne 0x8e12
shlq $0x6, %rax
movq (%r13,%rax), %r8
leaq 0x55fc(%rip), %r15      # 0xe319
pushq $0x1
popq %rbp
pushq $0x5
popq %rdx
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rcx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x1060
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x10(%r13,%rax), %r8d
movl 0x1c(%r13,%rax), %r9d
leaq 0x6030(%rip), %rcx      # 0xed8b
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1070
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movq 0x8(%r13,%rax), %r8
pushq $0x4
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1070
leaq 0x6013(%rip), %rcx      # 0xeda4
pushq $0x6
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6006(%rip), %rcx      # 0xedad
pushq $0x7
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
callq 0x11e0
cmpl $0x32, %eax
je 0x8f25
cmpl $0x31, %eax
jne 0x901b
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x18(%r13,%rax), %ecx
movq 0x30(%rsp), %rdx
cmpl 0x20(%rdx), %ecx
jle 0x8f9a
movq 0x18(%rsp), %rax
movl $0xc5, (%rax)
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x18(%r13,%rax), %ecx
jmp 0x8f0a
imulq $0x30, %rax, %rax
movq (%rbp,%rax), %r8
leaq 0x54f7(%rip), %r13      # 0xe319
pushq $0x1
popq %r15
pushq $0x5
popq %rdx
movq %rbx, %rdi
movl %r15d, %esi
movq %r13, %rcx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x1060
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movl 0x14(%rbp,%rax), %r8d
movl 0x18(%rbp,%rax), %r9d
leaq 0x5fc9(%rip), %rcx      # 0xee2b
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movq 0x8(%rbp,%rax), %r8
pushq $0x4
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1070
leaq 0x5f0a(%rip), %rcx      # 0xeda4
pushq $0x6
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x5efc(%rip), %rcx      # 0xedad
pushq $0x7
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x11e0
cmpl $0x32, %eax
je 0x8f4a
cmpl $0x31, %eax
jne 0x901b
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movl 0x1c(%rbp,%rax), %ecx
movq 0x30(%rsp), %rdx
cmpl 0x20(%rdx), %ecx
jle 0x8fe0
movq 0x18(%rsp), %rax
movl $0xc5, (%rax)
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movl 0x1c(%rbp,%rax), %ecx
leaq 0x5ebd(%rip), %rdx      # 0xedce
pushq $0x64
popq %rsi
movq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x1050
jmp 0x901b
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x28(%r13,%rax), %eax
movq 0x28(%rsp), %rcx
addl %eax, (%rcx)
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x28(%r13,%rax), %ecx
jmp 0x8f6b
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movl 0x10(%rbp,%rax), %eax
movq 0x28(%rsp), %rcx
addl %eax, (%rcx)
movslq 0x4(%r14,%r12,8), %rax
imulq $0x30, %rax, %rax
movl 0x10(%rbp,%rax), %ecx
leaq 0x5e85(%rip), %rdx      # 0xedf7
pushq $0x64
popq %rsi
movq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0x1050
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, (%r14,%r12,8)
movq 0x18(%rsp), %rax
movl $0x2f, (%rax)
jmp 0x901b
movq 0x40(%rsp), %rdi
movslq 0x2c(%rdi), %rcx
movl 0x1c(%rdi), %edx
movq %rcx, %rsi
shlq $0x6, %rsi
movl %edx, 0x1c(%r13,%rsi)
movups (%r13,%rax), %xmm0
movups 0x10(%r13,%rax), %xmm1
movups 0x20(%r13,%rax), %xmm2
movups 0x30(%r13,%rax), %xmm3
movups %xmm3, 0x30(%rdi)
movups %xmm2, 0x20(%rdi)
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
andl $0x0, (%r14,%r12,8)
jmp 0x9016
movq 0x38(%rsp), %rdi
movslq 0x20(%rdi), %rcx
movl 0x18(%rdi), %edx
imulq $0x30, %rcx, %rsi
movl %edx, 0x18(%rbp,%rsi)
movups (%rbp,%rax), %xmm0
movups 0x10(%rbp,%rax), %xmm1
movups 0x20(%rbp,%rax), %xmm2
movups %xmm2, 0x20(%rdi)
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
movl $0x1, (%r14,%r12,8)
movl %ecx, 0x4(%r14,%r12,8)
movq %rbx, %rdi
callq 0x1100
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
pushq $0x20
popq %rbp
movq %rbx, %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 %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0x1120
movq %rbx, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1110