// File: 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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movb 0x8(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5b86
jmp 0x5d90
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8cf0
testb $0x1, %al
jne 0x5cae
callq 0x5100
testb $0x1, %al
jne 0x5bb1
jmp 0x5cac
callq 0x51d0
movl %eax, -0xc(%rbp)
movb $0x0, -0xd(%rbp)
cmpl $0xe0, -0xc(%rbp)
jne 0x5bd2
callq 0x51d0
movl %eax, -0xc(%rbp)
movb $0x1, -0xd(%rbp)
testb $0x1, -0xd(%rbp)
je 0x5c2b
cmpl $0x4b, -0xc(%rbp)
jne 0x5bf3
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8d10
cmpl $0x4d, -0xc(%rbp)
jne 0x5c0e
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8e00
cmpl $0x50, -0xc(%rbp)
jne 0x5c29
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8ef0
jmp 0x5caa
cmpl $0x6a, -0xc(%rbp)
je 0x5c37
cmpl $0x68, -0xc(%rbp)
jne 0x5c4c
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8d10
cmpl $0x6c, -0xc(%rbp)
jne 0x5c67
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8e00
cmpl $0x6b, -0xc(%rbp)
jne 0x5c82
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8ef0
cmpl $0x2d, -0xc(%rbp)
jne 0x5c8d
jmp 0x5d90
cmpl $0x7a, -0xc(%rbp)
jne 0x5ca8
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8f70
jmp 0x5caa
jmp 0x5cac
jmp 0x5cc0
callq 0x5100
testb $0x1, %al
jne 0x5cb9
jmp 0x5cbe
callq 0x51d0
jmp 0x5cc0
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9180
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq -0x28(%rbp), %rsi
movq %rax, %rdi
addq $0x40, %rsi
callq 0x9200
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9260
testb $0x1, %al
jne 0x5d0d
jmp 0x5d5d
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq -0x28(%rbp), %rsi
movq %rax, %rdi
addq $0x30, %rsi
callq 0x8bb0
movq -0x28(%rbp), %rdi
addq $0x10, %rdi
callq 0x8c00
movq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x8c20
movq -0x28(%rbp), %rdi
addq $0x30, %rdi
leaq -0x20(%rbp), %rsi
callq 0x8cc0
leaq -0x20(%rbp), %rdi
callq 0x8ca0
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9280
movq -0x28(%rbp), %rdi
andb $0x1, %al
movb %al, 0x8(%rdi)
movq (%rdi), %rax
callq *0x18(%rax)
movl $0x10, %edi
callq 0x5230
jmp 0x5b74
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)