// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x40(%rdi), %r14
leaq 0x30(%rdi), %r15
pushq $0x10
popq %r12
cmpb $0x0, 0x8(%rbx)
jne 0x43bb
movq 0x20(%rbx), %rax
movl 0x68(%rax), %r13d
callq 0x3a7c
testl %r13d, %r13d
je 0x42b2
testb %al, %al
je 0x434a
callq 0x3b49
jmp 0x434a
testb %al, %al
je 0x434a
callq 0x3b49
cmpl $0xe0, %eax
jne 0x42e5
callq 0x3b49
cmpl $0x50, %eax
je 0x4321
cmpl $0x4d, %eax
je 0x4316
cmpl $0x4b, %eax
jne 0x434a
movq 0x20(%rbx), %rdi
callq 0x5d4e
jmp 0x434a
movl %eax, %r13d
andl $-0x3, %eax
cmpl $0x68, %eax
jne 0x42f9
movq 0x20(%rbx), %rdi
callq 0x5d4e
cmpl $0x6b, %r13d
je 0x4321
cmpl $0x6c, %r13d
je 0x4316
cmpl $0x7a, %r13d
je 0x4341
cmpl $0x2d, %r13d
jne 0x434a
jmp 0x43bb
movq 0x20(%rbx), %rdi
callq 0x5de0
jmp 0x434a
movq 0x20(%rbx), %rax
cmpl $0x0, 0x98(%rax)
jne 0x434a
movl $0x1, 0x98(%rax)
addl $0x28, 0x80(%rax)
jmp 0x434a
movq 0x20(%rbx), %rdi
callq 0x5e6e
movq 0x20(%rbx), %rdi
callq 0x5f58
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x5f96
movq 0x20(%rbx), %rdi
movl 0x68(%rdi), %eax
cmpl $0x4, %eax
jne 0x439e
movq %r15, %rsi
callq 0x5cd4
movq 0x10(%rbx), %rsi
leaq -0x38(%rbp), %r13
movq %r13, %rdi
callq 0x5d00
movq %r15, %rdi
movq %r13, %rsi
callq 0x81ec
leaq -0x30(%rbp), %rdi
callq 0x6896
movq 0x20(%rbx), %rax
movl 0x68(%rax), %eax
cmpl $0x6, %eax
sete 0x8(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl %r12d, %edi
callq 0x3bba
jmp 0x4284
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq