// File: 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
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x43e0
movq -0xa0(%rbp), %rax
movslq 0x8(%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, -0x20(%rbp)
movl $0x0, -0x10(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x4553
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0xb240
movq -0xb0(%rbp), %rsi
movq 0xdb0b(%rip), %rdi      # 0x11fc8
callq 0x3230
movq %rax, -0xa8(%rbp)
jmp 0x44cb
movq -0xa8(%rbp), %rdi
leaq 0x7b73(%rip), %rsi      # 0xc04c
callq 0x3280
jmp 0x44e0
leaq -0x40(%rbp), %rdi
callq 0x3180
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
leaq -0x70(%rbp), %rdi
callq 0xb240
leaq -0x70(%rbp), %rdi
callq 0x33c0
shrq $0x3, %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
leaq -0x70(%rbp), %rdi
callq 0x3180
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4476
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3180
jmp 0x48da
movq 0xda6e(%rip), %rdi      # 0x11fc8
leaq 0x7c31(%rip), %rsi      # 0xc192
callq 0x3280
movl $0x0, -0xc(%rbp)
movq -0xa0(%rbp), %rcx
movl -0xc(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x4760
movl $0x0, -0x10(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x10(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x473f
leaq -0x91(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x34b0
movq -0xb8(%rbp), %rdx
leaq 0x7a91(%rip), %rsi      # 0xc04c
leaq -0x90(%rbp), %rdi
callq 0x5570
jmp 0x45c9
leaq -0x91(%rbp), %rdi
callq 0x32d0
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
movslq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x4648
leaq 0x7a59(%rip), %rsi      # 0xc04c
leaq -0x90(%rbp), %rdi
callq 0x3510
jmp 0x4601
jmp 0x4603
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x45dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x32d0
jmp 0x48da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3180
jmp 0x48da
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb1f0
movb %al, -0xb9(%rbp)
jmp 0x4670
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x467c
jmp 0x46af
movq 0xd945(%rip), %rdi      # 0x11fc8
leaq 0x79c4(%rip), %rsi      # 0xc04e
callq 0x3280
movq %rax, -0xc8(%rbp)
jmp 0x4698
movq -0xc8(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3230
jmp 0x46ad
jmp 0x4725
movq 0xd912(%rip), %rdi      # 0x11fc8
leaq 0x7996(%rip), %rsi      # 0xc053
callq 0x3280
movq %rax, -0xd0(%rbp)
jmp 0x46cb
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x10(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0xb270
movl %eax, -0xd4(%rbp)
jmp 0x46f3
movl -0xd4(%rbp), %esi
movq -0xd0(%rbp), %rdi
callq 0x3480
movq %rax, -0xe0(%rbp)
jmp 0x470e
movq -0xe0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3230
jmp 0x4723
jmp 0x4725
leaq -0x90(%rbp), %rdi
callq 0x3180
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4587
movq 0xd882(%rip), %rdi      # 0x11fc8
leaq 0x7a44(%rip), %rsi      # 0xc191
callq 0x3280
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x456d
movq 0xd861(%rip), %rdi      # 0x11fc8
leaq 0x78e7(%rip), %rsi      # 0xc055
callq 0x3280
movq %rax, %rdi
movq -0xa0(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x3480
movq %rax, %rdi
leaq 0x7a03(%rip), %rsi      # 0xc192
callq 0x3280
movb $0x0, -0x92(%rbp)
movq 0xd826(%rip), %rdi      # 0x11fc8
leaq 0x78b6(%rip), %rsi      # 0xc05f
callq 0x3280
movq 0xd823(%rip), %rdi      # 0x11fd8
leaq -0x18(%rbp), %rsi
callq 0x3170
movq %rax, %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x3320
testb $0x1, %al
jne 0x47d3
jmp 0x47dc
movb $0x0, -0x92(%rbp)
jmp 0x482b
movq 0xd7e5(%rip), %rdi      # 0x11fc8
leaq 0x7886(%rip), %rsi      # 0xc070
callq 0x3280
movq 0xd7e2(%rip), %rax      # 0x11fd8
movq (%rax), %rax
movq 0xd7d8(%rip), %rdi      # 0x11fd8
addq -0x18(%rax), %rdi
xorl %esi, %esi
callq 0x3460
callq 0x5620
movq %rax, %rsi
movq 0xd7be(%rip), %rdi      # 0x11fd8
movl $0xa, %edx
callq 0x3190
movb $0x1, -0x92(%rbp)
cmpl $0x2328, -0x18(%rbp)    # imm = 0x2328
jne 0x4850
movq 0xd78d(%rip), %rdi      # 0x11fc8
leaq 0x7850(%rip), %rsi      # 0xc092
callq 0x3280
movb $0x1, -0x92(%rbp)
jmp 0x48a5
movq -0xa0(%rbp), %rcx
movl -0x18(%rbp), %eax
imull $0xb, 0x8(%rcx), %ecx
cmpl %ecx, %eax
jle 0x487e
movq 0xd75f(%rip), %rdi      # 0x11fc8
leaq 0x7850(%rip), %rsi      # 0xc0c0
callq 0x3280
movb $0x1, -0x92(%rbp)
jmp 0x48a3
cmpl $0x2328, -0x18(%rbp)    # imm = 0x2328
jle 0x48a1
movq 0xd73a(%rip), %rdi      # 0x11fc8
leaq 0x785f(%rip), %rsi      # 0xc0f4
callq 0x3280
movb $0x1, -0x92(%rbp)
jmp 0x48a3
jmp 0x48a5
jmp 0x48a7
testb $0x1, -0x92(%rbp)
jne 0x479b
movq -0xa0(%rbp), %rdi
callq 0x43e0
movq -0xa0(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x48f0
xorl %eax, %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)