// File: nesro[P]NCursesGomoku/src/game.cpp
// Function: CGame::showMenu()
void CGame::showMenu(void) {
	int key;
	int row = 0;
	int col = 0;

	clearScreen();

	mvprintw(row++, col, "/=====================================\\");
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "| Program: \"NCursesGomoku\"            |");
	mvprintw(row++, col, "| Author:  \"nesrotom@fit.cvut.cz\"     |");
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "| You can specify host and port with  |");
	mvprintw(row++, col, "| this usage:                         |");
	mvprintw(row++, col, "| nesrotom port host                  |");
	mvprintw(row++, col, "| if not, default is:                 |");
	mvprintw(row++, col, "| nesrotom %d localhost             |",
			CNetwork::DEFAULT_PORT);
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "| \"1\" or \"a\" - New AI game            |");

	/* if we are clinet, we cannot convert to server */
	if ((m_IsServerUp == false && m_IsConnectionUp == false)
			|| (m_IsServerUp == true && m_IsConnectionUp == true)) {
		mvprintw(row++, col, "| \"2\" or \"s\" - New NET game (server)  |");
	}

	/* if we are server, we cannot convert to client */
	if ((m_IsServerUp == false && m_IsConnectionUp == false)
			|| (m_IsServerUp == false && m_IsConnectionUp == true)) {
		mvprintw(row++, col, "| \"3\" or \"c\" - New NET game (client)  |");
	}

	mvprintw(row++, col, "| \"4\" or \"w\" - Watch AI vs AI         |");
	mvprintw(row++, col, "| \"5\" or \"h\" - 2 players hotseat      |");
	mvprintw(row++, col, "| \"6\" or \"q\" - Quit                   |");
	mvprintw(row++, col, "|                                     |");
	mvprintw(row++, col, "\\=====================================/");

	move(0, 0);
	key = getch();

	/* just for safety */
	playerCleanup();

	switch (key) {
	case '1':
	case 'a':
	case 'A':
		m_Players[0] = new CLocal(m_Board, PLAYER_0_CHAR);
		m_Players[1] = new CAI(m_Board, PLAYER_1_CHAR);

		/* let random decide, who starts! */
		startGame(rand() % 2);
		break;
	case '2':
	case 's':
	case 'S':

		/* no for client */
		if (m_IsServerUp == false && m_IsConnectionUp == true) {
			showMenu();
			break;
		}

		m_Players[0] = new CLocal(m_Board, PLAYER_0_CHAR);
		m_Players[1] = new CServer(m_Board, PLAYER_1_CHAR, this);

		/* I (server) starts */
		startGame(0);
		break;
	case '3':
	case 'c':
	case 'C':

		/* no for server */
		if (m_IsServerUp) {
			showMenu();
			break;
		}

		m_Players[0] = new CLocal(m_Board, PLAYER_0_CHAR);
		m_Players[1] = new CClient(m_Board, PLAYER_1_CHAR, this);

		/* He (server) starts */
		startGame(1);
		break;
	case '4':
	case 'w':
	case 'W':
		m_Players[0] = new CAI(m_Board, PLAYER_0_CHAR);
		m_Players[1] = new CAI(m_Board, PLAYER_1_CHAR);

		/* random AI starts*/
		startGame(rand() % 2);

		break;
	case '5':
	case 'h':
	case 'H':
		m_Players[0] = new CLocal(m_Board, PLAYER_0_CHAR);
		m_Players[1] = new CLocal(m_Board, PLAYER_1_CHAR);

		startGame(0);
		break;
	case '6':
	case 'q':
	case 'Q':
		m_Status = CGame::STATUS_EXIT;
		break;
	default:
		showMenu();
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
callq 0x5690
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x2c11(%rip), %rdx      # 0x8430
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32ef(%rip), %rdx      # 0x8b2a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32fb(%rip), %rdx      # 0x8b52
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3307(%rip), %rdx      # 0x8b7a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x329b(%rip), %rdx      # 0x8b2a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x327f(%rip), %rdx      # 0x8b2a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32db(%rip), %rdx      # 0x8ba2
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32e7(%rip), %rdx      # 0x8bca
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32f3(%rip), %rdx      # 0x8bf2
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32ff(%rip), %rdx      # 0x8c1a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x330b(%rip), %rdx      # 0x8c42
movl $0x44d, %ecx            # imm = 0x44D
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x31d2(%rip), %rdx      # 0x8b2a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x31b6(%rip), %rdx      # 0x8b2a
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32d8(%rip), %rdx      # 0x8c68
movb $0x0, %al
callq 0x3360
movq -0x30(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x59b9
movq -0x30(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x59db
movq -0x30(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x59f7
movq -0x30(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x59f7
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x32a0(%rip), %rdx      # 0x8c90
movb $0x0, %al
callq 0x3360
movq -0x30(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5a19
movq -0x30(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x5a3b
movq -0x30(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5a57
movq -0x30(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5a57
movl -0x10(%rbp), %edi
movl %edi, %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3268(%rip), %rdx      # 0x8cb8
movb $0x0, %al
callq 0x3360
movl -0x10(%rbp), %edi
movl %edi, %eax
incl %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3275(%rip), %rdx      # 0x8ce0
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
movb %al, -0x3d(%rbp)
callq 0x3360
movb -0x3d(%rbp), %al
movl -0x10(%rbp), %edi
movl %edi, %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3279(%rip), %rdx      # 0x8d08
callq 0x3360
movb -0x3d(%rbp), %al
movl -0x10(%rbp), %edi
movl %edi, %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3285(%rip), %rdx      # 0x8d30
callq 0x3360
movb -0x3d(%rbp), %al
movl -0x10(%rbp), %edi
movl %edi, %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x3063(%rip), %rdx      # 0x8b2a
callq 0x3360
movb -0x3d(%rbp), %al
movl -0x10(%rbp), %edi
movl %edi, %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
movl -0x14(%rbp), %esi
leaq 0x2d18(%rip), %rdx      # 0x87fb
callq 0x3360
movl -0x3c(%rbp), %esi
movl %esi, %edi
callq 0x31b0
movq 0x64cf(%rip), %rax      # 0xbfc8
movq (%rax), %rdi
callq 0x3100
movq -0x30(%rbp), %rdi
movl %eax, -0xc(%rbp)
callq 0x55a0
movl -0xc(%rbp), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x46, %eax
ja 0x5f32
movq -0x38(%rbp), %rax
leaq 0x2ecb(%rip), %rcx      # 0x89f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x18, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x48(%rbp)
movq 0x50(%rax), %rsi
movl $0x78, %edx
callq 0x6220
jmp 0x5b5e
movq -0x30(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x28, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x50(%rbp)
movq 0x50(%rax), %rsi
movl $0x6f, %edx
callq 0x39b0
jmp 0x5b92
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x48(%rax)
callq 0x30b0
movq -0x30(%rbp), %rdi
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, %esi
callq 0x5790
jmp 0x5f3b
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x3290
jmp 0x5f44
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x3290
jmp 0x5f44
movq -0x30(%rbp), %rax
movb 0x4(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5c29
movq -0x30(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5c29
movq -0x30(%rbp), %rdi
callq 0x57e0
jmp 0x5f3b
movl $0x18, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x58(%rbp)
movq 0x50(%rax), %rsi
movl $0x78, %edx
callq 0x6220
jmp 0x5c51
movq -0x30(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x30, %edi
callq 0x3280
movq -0x30(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq 0x50(%rcx), %rsi
movl $0x6f, %edx
callq 0x6a20
jmp 0x5c85
movq -0x30(%rbp), %rdi
movq -0x60(%rbp), %rax
movq %rax, 0x48(%rdi)
xorl %esi, %esi
callq 0x5790
jmp 0x5f3b
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x3290
jmp 0x5f44
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x30, %esi
callq 0x3290
jmp 0x5f44
movq -0x30(%rbp), %rax
testb $0x1, 0x4(%rax)
je 0x5cf3
movq -0x30(%rbp), %rdi
callq 0x57e0
jmp 0x5f3b
movl $0x18, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x68(%rbp)
movq 0x50(%rax), %rsi
movl $0x78, %edx
callq 0x6220
jmp 0x5d1b
movq -0x30(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x28, %edi
callq 0x3280
movq -0x30(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
movq 0x50(%rcx), %rsi
movl $0x6f, %edx
callq 0x4d80
jmp 0x5d4f
movq -0x30(%rbp), %rdi
movq -0x70(%rbp), %rax
movq %rax, 0x48(%rdi)
movl $0x1, %esi
callq 0x5790
jmp 0x5f3b
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x3290
jmp 0x5f44
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x3290
jmp 0x5f44
movl $0x28, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x78(%rbp)
movq 0x50(%rax), %rsi
movl $0x78, %edx
callq 0x39b0
jmp 0x5dd0
movq -0x30(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x28, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x80(%rbp)
movq 0x50(%rax), %rsi
movl $0x6f, %edx
callq 0x39b0
jmp 0x5e04
movq -0x30(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, 0x48(%rax)
callq 0x30b0
movq -0x30(%rbp), %rdi
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, %esi
callq 0x5790
jmp 0x5f3b
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x3290
jmp 0x5f44
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x28, %esi
callq 0x3290
jmp 0x5f44
movl $0x18, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x88(%rbp)
movq 0x50(%rax), %rsi
movl $0x78, %edx
callq 0x6220
jmp 0x5e96
movq -0x30(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0x40(%rax)
movl $0x18, %edi
callq 0x3280
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x90(%rbp)
movq 0x50(%rax), %rsi
movl $0x6f, %edx
callq 0x6220
jmp 0x5ed0
movq -0x30(%rbp), %rdi
movq -0x90(%rbp), %rax
movq %rax, 0x48(%rdi)
xorl %esi, %esi
callq 0x5790
jmp 0x5f3b
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x3290
jmp 0x5f44
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x3290
jmp 0x5f44
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
jmp 0x5f3b
movq -0x30(%rbp), %rdi
callq 0x57e0
addq $0x90, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x3410
nopl (%rax)