// File: /workspace/github_cpp_makefile_star2_O2/Matlock42[P]Jeopardy/jgameClass.cpp
// Function: Game::showBoard()
int Game::showBoard(void)
{
	clearScreen();
	int i,j,k;
	int lPrompt;
	int * t; // Number of additional tabs to add to make things line up
	t = new int [mSize];

	for(j = 0; j < mSize; j++)	// print category names
	{
		cout << mQuestionSet[j][0]->category() << "\t";
		t[j] = ((mQuestionSet[j][0]->category().length()) / 8); // each tab takes 8 char spaces in the terminal
	}
	cout << "\n";

	for(i = 0; i < mSize; i++)	// different rows (prices)
	{
		for(j=0; j < mSize; j++) // go through each category
		{
			std::string tabs = "\t"; // tabs between each
			for(k=0; k < t[j]; k++)
			{
				tabs.append("\t");  // Add any additional tabs
			}

			// display empty slot if the question has already been played
			if(mQuestionSet[j][i]->hasBeenPlayed())
			{
				cout << "----" << tabs;
			}
			else	// display the amount the question is worth
			{
				cout << "$" << mQuestionSet[j][i]->price() << tabs;
			}
		}
		cout << "\n\n";
	}
	// Display the current score and prompt for the next question
	cout << "\t\tScore: " << mScore << "\n";
	
	// validate the input
	bool lInputError = false;
	do
	{
		cout << "Next question: \n";
	    if (cin >> lPrompt) // Sanitize input to an integer
	    {
	    	lInputError = false;
	    } 
	    else
	    {
	        cout << "Entered value is not an Integer.\n";
	        cin.clear();
	        cin.ignore(numeric_limits<streamsize>::max(), '\n');
	        lInputError = true;
	    }
		if( lPrompt == 9000 )
		{
			cout << "I'm sorry, Dave. I'm afraid I can't do that.\n"; // 2001
			lInputError = true;
		}
		else if( lPrompt > (mSize * 11)) // only allow up to the max question number
		{
			cout << "We need to go to the crappy town where I'm a hero!\n"; // Firefly
			lInputError = true;
		}
		else if( lPrompt > 9000 )
		{
			cout << "It's over 9000!\n"; 
			lInputError = true;
		}

	} while (lInputError);
	clearScreen();
	showQuestion(lPrompt);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
callq 0x2cec
movq %rbx, -0x30(%rbp)
movslq 0x8(%rbx), %r14
leaq (,%r14,4), %rax
testq %r14, %r14
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0x2030
movq %rax, -0x40(%rbp)
xorl %ebx, %ebx
leaq -0x60(%rbp), %r15
movq 0x724f(%rip), %r12      # 0x9fc0
leaq 0x32f8(%rip), %r13      # 0x6070
movslq %r14d, %rax
cmpq %rax, %rbx
jge 0x2dec
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0x58f8
movq %r12, %rdi
movq %r15, %rsi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq %r15, %rdi
callq 0x20d0
movq -0x30(%rbp), %r14
movq 0x10(%r14), %rax
movq (%rax,%rbx,8), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0x58f8
movq -0x58(%rbp), %rax
shrq $0x3, %rax
movq -0x40(%rbp), %rcx
movl %eax, (%rcx,%rbx,4)
movq %r15, %rdi
callq 0x20d0
incq %rbx
movl 0x8(%r14), %r14d
jmp 0x2d78
movq 0x71cd(%rip), %rdi      # 0x9fc0
leaq 0x33bc(%rip), %rsi      # 0x61b6
callq 0x2210
leaq 0x326a(%rip), %r12      # 0x6070
leaq -0x60(%rbp), %r13
xorl %r14d, %r14d
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rax
cmpq %rax, %r14
jge 0x2f01
xorl %ebx, %ebx
cltq
cmpq %rax, %rbx
jge 0x2ee6
movq %r13, %rdi
movq %r12, %rsi
leaq -0x31(%rbp), %rdx
callq 0x376e
movq -0x40(%rbp), %rax
movl (%rax,%rbx,4), %r15d
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
subl $0x1, %r15d
jb 0x2e61
movq %r13, %rdi
movq %r12, %rsi
callq 0x23e0
jmp 0x2e4e
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movq (%rax,%r14,8), %rdi
callq 0x58d4
testb %al, %al
je 0x2e8f
movq 0x713f(%rip), %rdi      # 0x9fc0
leaq 0x31ea(%rip), %rsi      # 0x6072
callq 0x2210
jmp 0x2ec4
movq 0x712a(%rip), %rdi      # 0x9fc0
leaq 0x31da(%rip), %rsi      # 0x6077
callq 0x2210
movq %rax, %r15
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movq (%rax,%r14,8), %rdi
callq 0x5910
movq %r15, %rdi
movl %eax, %esi
callq 0x2370
movq %rax, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x20d0
incq %rbx
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
jmp 0x2e20
movq 0x70d3(%rip), %rdi      # 0x9fc0
leaq 0x32c1(%rip), %rsi      # 0x61b5
callq 0x2210
incq %r14
jmp 0x2e0d
movq 0x70b8(%rip), %r14      # 0x9fc0
leaq 0x316a(%rip), %rsi      # 0x6079
movq %r14, %rdi
callq 0x2210
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x2370
leaq 0x3289(%rip), %rsi      # 0x61b6
movq %rax, %rdi
callq 0x2210
movq 0x7094(%rip), %r12      # 0x9fd0
leaq -0x38(%rbp), %r13
leaq 0x316f(%rip), %rbx      # 0x60b6
movq %r14, %rdi
leaq 0x3132(%rip), %rsi      # 0x6083
callq 0x2210
movq %r12, %rdi
movq %r13, %rsi
callq 0x2120
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x20(%rax,%rcx), %r15d
testb $0x5, %r15b
je 0x2fa9
movq %r14, %rdi
leaq 0x3117(%rip), %rsi      # 0x6094
callq 0x2210
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
xorl %esi, %esi
callq 0x2350
movq %r12, %rdi
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
pushq $0xa
popq %rdx
callq 0x2130
movl -0x38(%rbp), %eax
movq %rbx, %rsi
cmpl $0x2328, %eax           # imm = 0x2328
je 0x2fd7
movq -0x30(%rbp), %rcx
imull $0xb, 0x8(%rcx), %ecx
leaq 0x311f(%rip), %rsi      # 0x60e4
cmpl %ecx, %eax
jg 0x2fd7
leaq 0x3148(%rip), %rsi      # 0x6118
cmpl $0x2328, %eax           # imm = 0x2328
jle 0x2fe4
movq %r14, %rdi
callq 0x2210
jmp 0x2f47
testb $0x5, %r15b
jne 0x2f47
callq 0x2cec
movl -0x38(%rbp), %esi
movq -0x30(%rbp), %rdi
callq 0x302e
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3019
movq %rax, %rbx
jmp 0x3025
jmp 0x3019
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2390
nop