// File: /workspace/github_cpp_makefile_star2_O3/Leeingnyo[P]newPuyoC/game.cpp
// Function: SingleGame::GameLoop()
void SingleGame::GameLoop() {
    while (!gameover) {
        if (!my_board->IsBusy()) {
            if (kbhit()) {
                int input = getch();
                bool special = false;
                if (input == 224) {
                    input = getch();
                    special = true;
                }

                if (special) {
                    if (input == 75) {
                        my_board->MoveLeft();
                    }
                    if (input == 77) {
                        my_board->MoveRight();
                    }
                    if (input == 80) {
                        my_board->MoveDown();
                    }
                } else {
                    if (input == 'j' || input == 'h') {
                        my_board->MoveLeft();
                    }
                    if (input == 'l') {
                        my_board->MoveRight();
                    }
                    if (input == 'k') {
                        my_board->MoveDown();
                    }
                    if (input == '-') {
                        break;
                    }
                    if (input == 'z') { // rotate
                        my_board->RotateCCW();
                    }
                }
            }
        }
        else {
            if (kbhit()) getch();
        }
        // input
        
        my_board->Update();
        my_board->UpdatePlayerInformation(my_info);
        if (my_board->IsNeedNext()) {
            // need next bipuyo
            my_board->SetNextBiPuyo(my_next_bipuyo);
            // set next bipuyo
            my_next_bipuyo = my_bipuyo_generator->GenerateBipuyo();
        }
        gameover = my_board->IsGameOver();
        // process
        
        Draw();
        // draw
        
        Console::Sleep(16); // ?
    }
}

// Assembly:
cmpb $0x0, 0x8(%rdi)
jne 0x477b
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
movabsq $0x100000002, %r13      # imm = 0x100000002
leaq -0x40(%rbp), %r15
movq 0x20(%rbx), %rax
movl 0x68(%rax), %r12d
callq 0x3c8c
testl %r12d, %r12d
je 0x460c
testb %al, %al
je 0x46a7
callq 0x3d57
jmp 0x46a7
testb %al, %al
je 0x46a7
callq 0x3d57
cmpl $0xe0, %eax
jne 0x463f
callq 0x3d57
cmpl $0x50, %eax
je 0x4672
cmpl $0x4d, %eax
je 0x4665
cmpl $0x4b, %eax
jne 0x46a7
movq 0x20(%rbx), %rdi
callq 0x6f66
jmp 0x46a7
movl %eax, %r12d
andl $-0x3, %eax
cmpl $0x68, %eax
jne 0x4653
movq 0x20(%rbx), %rdi
callq 0x6f66
cmpl $0x6b, %r12d
jle 0x4670
cmpl $0x7a, %r12d
je 0x4692
cmpl $0x6c, %r12d
jne 0x46a7
movq 0x20(%rbx), %rdi
callq 0x6ff8
jmp 0x46a7
jne 0x469d
movq 0x20(%rbx), %rax
cmpl $0x0, 0x98(%rax)
jne 0x46a7
movl $0x1, 0x98(%rax)
addl $0x28, 0x80(%rax)
jmp 0x46a7
movq 0x20(%rbx), %rdi
callq 0x7086
jmp 0x46a7
cmpl $0x2d, %r12d
je 0x476d
movq 0x20(%rbx), %rdi
callq 0x71c0
movq 0x20(%rbx), %r12
movl 0x6c(%r12), %eax
addl %eax, 0x40(%rbx)
movl $0x0, 0x6c(%r12)
movl 0x70(%r12), %eax
movl %eax, 0x44(%rbx)
cmpl %eax, 0x48(%rbx)
jge 0x46d5
movl %eax, 0x48(%rbx)
movl 0x74(%r12), %eax
movl %eax, 0x4c(%rbx)
movl 0x68(%r12), %eax
cmpl $0x4, %eax
jne 0x4749
movq 0x30(%rbx), %rax
movq %rax, 0x50(%r12)
leaq 0x58(%r12), %rdi
movq %r14, %rsi
callq 0x7fc8
movq %r13, 0x60(%r12)
movl $0x0, 0x68(%r12)
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x6ee8
movaps -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x38(%rbx), %rdi
movups %xmm0, 0x30(%rbx)
testq %rdi, %rdi
je 0x4742
callq 0x7f4e
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x4742
callq 0x7f4e
movq 0x20(%rbx), %rax
movl 0x68(%rax), %eax
cmpl $0x6, %eax
sete 0x8(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl $0x10, %edi
callq 0x3dc8
cmpb $0x1, 0x8(%rbx)
jne 0x45e8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq