// File: /workspace/github_cpp_makefile_star2_O1/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 0x47e6
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 %r14, -0x30(%rbp)
movq 0x20(%rbx), %rax
movl 0x68(%rax), %r12d
callq 0x3c94
testl %r12d, %r12d
je 0x4618
testb %al, %al
je 0x4716
callq 0x3d5f
jmp 0x4716
testb %al, %al
je 0x4716
movq %r15, %r14
movq %r13, %r15
callq 0x3d5f
movl %eax, %r13d
movl %eax, %r12d
cmpl $0xe0, %eax
jne 0x4640
callq 0x3d5f
movl %eax, %r12d
cmpl $0xe0, %r13d
jne 0x467b
cmpl $0x50, %r12d
movq %r15, %r13
je 0x46da
cmpl $0x4d, %r12d
movq %r14, %r15
je 0x46cb
cmpl $0x4b, %r12d
movq -0x30(%rbp), %r14
jne 0x4716
movq 0x20(%rbx), %rdi
callq 0x6f78
jmp 0x4716
movl %r12d, %eax
andl $-0x3, %eax
cmpl $0x68, %eax
movq %r15, %r13
jne 0x4692
movq 0x20(%rbx), %rdi
callq 0x6f78
cmpl $0x6b, %r12d
movq %r14, %r15
jle 0x46b6
cmpl $0x7a, %r12d
movq -0x30(%rbp), %r14
je 0x4701
cmpl $0x6c, %r12d
jne 0x4716
movq 0x20(%rbx), %rdi
callq 0x700a
jmp 0x4716
movq -0x30(%rbp), %r14
jne 0x470c
movq 0x20(%rbx), %rax
cmpl $0x0, 0x98(%rax)
jne 0x4716
jmp 0x46ee
movq 0x20(%rbx), %rdi
callq 0x700a
movq -0x30(%rbp), %r14
jmp 0x4716
movq 0x20(%rbx), %rax
cmpl $0x0, 0x98(%rax)
movq %r14, %r15
movq -0x30(%rbp), %r14
jne 0x4716
movl $0x1, 0x98(%rax)
addl $0x28, 0x80(%rax)
jmp 0x4716
movq 0x20(%rbx), %rdi
callq 0x7098
jmp 0x4716
cmpl $0x2d, %r12d
je 0x47d8
movq 0x20(%rbx), %rdi
callq 0x7228
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 0x4744
movl %eax, 0x48(%rbx)
movl 0x74(%r12), %eax
movl %eax, 0x4c(%rbx)
cmpl $0x4, 0x68(%r12)
jne 0x47af
movq 0x30(%rbx), %rax
movq %rax, 0x50(%r12)
leaq 0x58(%r12), %rdi
movq %r14, %rsi
callq 0x8026
movq %r13, 0x60(%r12)
movl $0x0, 0x68(%r12)
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x6ef2
movaps -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, -0x40(%rbp)
movq 0x38(%rbx), %rdi
movups %xmm0, 0x30(%rbx)
testq %rdi, %rdi
je 0x47a1
callq 0x7fac
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x47af
callq 0x7fac
movq 0x20(%rbx), %rax
cmpl $0x6, 0x68(%rax)
movq (%rbx), %rax
sete 0x8(%rbx)
movq %rbx, %rdi
callq *0x18(%rax)
movl $0x10, %edi
callq 0x3dd0
cmpb $0x1, 0x8(%rbx)
jne 0x45f4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop