// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movq %r9, 0x20(%rsp)
movq %r8, %r14
movq %rcx, %r13
movq %rdx, 0x30(%rsp)
movq %rsi, %rbp
movq %rdi, 0x28(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq 0x78(%rsp), %r12
movl 0x90(%rsp), %r15d
movl $0x9, %edi
movl $0x3c, %esi
movl $0x18, %edx
movl $0x39, %ecx
callq 0x1130
movq %rax, %rbx
subq $0x8, %rsp
xorl %eax, %eax
movq %rbx, %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 %rbx, %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x11c0
movslq 0x4(%r14,%r12,8), %rax
cmpl $0x1, %r15d
jne 0xa166
shlq $0x6, %rax
movq (%rbp,%rax), %r8
leaq 0x62a0(%rip), %r15      # 0x102fd
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5, %edx
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(%rbp,%rax), %r8d
movl 0x1c(%rbp,%rax), %r9d
leaq 0x6c4e(%rip), %rcx      # 0x10ceb
movq %rbx, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movq 0x8(%rbp,%rax), %r8
movq %rbx, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1070
leaq 0x6c27(%rip), %rcx      # 0x10d04
movq %rbx, %rdi
movl $0x6, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6c15(%rip), %rcx      # 0x10d0d
movq %rbx, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
callq 0x11e0
cmpl $0x32, %eax
je 0xa2a5
cmpl $0x31, %eax
jne 0xa3ab
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x18(%rbp,%rax), %ecx
movq 0x20(%rsp), %rdx
cmpl 0x20(%rdx), %ecx
jle 0xa324
movq 0x8(%rsp), %rax
movl $0xc5, (%rax)
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x18(%rbp,%rax), %ecx
jmp 0xa288
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq (%r13,%rax), %r8
leaq 0x6183(%rip), %rbp      # 0x102fd
movq %rbx, %rdi
movl $0x1, %esi
movl $0x5, %edx
movq %rbp, %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
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x14(%r13,%rax), %r8d
movl 0x18(%r13,%rax), %r9d
leaq 0x6bcd(%rip), %rcx      # 0x10d8b
movq %rbx, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movslq 0x4(%r14,%r12,8), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq 0x8(%r13,%rax), %r8
movq %rbx, %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x1070
leaq 0x6b02(%rip), %rcx      # 0x10d04
movq %rbx, %rdi
movl $0x6, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x6af0(%rip), %rcx      # 0x10d0d
movq %rbx, %rdi
movl $0x7, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x11e0
cmpl $0x32, %eax
je 0xa2c8
cmpl $0x31, %eax
jne 0xa3ab
movslq 0x4(%r14,%r12,8), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x1c(%r13,%rax), %ecx
movq 0x20(%rsp), %rdx
cmpl 0x20(%rdx), %ecx
jle 0xa368
movq 0x8(%rsp), %rax
movl $0xc5, (%rax)
movslq 0x4(%r14,%r12,8), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x1c(%r13,%rax), %ecx
leaq 0x6a9f(%rip), %rdx      # 0x10d2e
movl $0x64, %esi
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x1050
jmp 0xa3ab
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x28(%rbp,%rax), %eax
movq 0x18(%rsp), %rcx
addl %eax, (%rcx)
movslq 0x4(%r14,%r12,8), %rax
shlq $0x6, %rax
movl 0x28(%rbp,%rax), %ecx
jmp 0xa2f3
movslq 0x4(%r14,%r12,8), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x10(%r13,%rax), %eax
movq 0x18(%rsp), %rcx
addl %eax, (%rcx)
movslq 0x4(%r14,%r12,8), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movl 0x10(%r13,%rax), %ecx
leaq 0x6a5d(%rip), %rdx      # 0x10d57
movl $0x64, %esi
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x1050
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, (%r14,%r12,8)
movq 0x8(%rsp), %rax
movl $0x2f, (%rax)
jmp 0xa3ab
movq 0x28(%rsp), %rdi
movslq 0x2c(%rdi), %rcx
movl 0x1c(%rdi), %edx
movq %rcx, %rsi
shlq $0x6, %rsi
movl %edx, 0x1c(%rbp,%rsi)
movups (%rbp,%rax), %xmm0
movups 0x10(%rbp,%rax), %xmm1
movups 0x20(%rbp,%rax), %xmm2
movups 0x30(%rbp,%rax), %xmm3
movups %xmm3, 0x30(%rdi)
movups %xmm2, 0x20(%rdi)
movups %xmm1, 0x10(%rdi)
movups %xmm0, (%rdi)
movl $0x0, (%r14,%r12,8)
jmp 0xa3a6
movq 0x30(%rsp), %rdi
movslq 0x20(%rdi), %rcx
movl 0x18(%rdi), %edx
leaq (%rcx,%rcx,2), %rsi
shlq $0x4, %rsi
movl %edx, 0x18(%r13,%rsi)
movups (%r13,%rax), %xmm0
movups 0x10(%r13,%rax), %xmm1
movups 0x20(%r13,%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
subq $0x8, %rsp
xorl %eax, %eax
movl $0x20, %r14d
movq %rbx, %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 %rbx, %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 %rbx, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1110