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

            if (!my_board->IsBusy()) {
                if (special) { }
                else {
                    if (input == 'd') {
                        my_board->MoveLeft();
                    }
                    if (input == 'g') {
                        my_board->MoveRight();
                    }
                    if (input == 'f') {
                        my_board->MoveDown();
                    }
                    if (input == 'z') { // rotate
                        my_board->RotateCCW();
                    }
                }
            }
            if (!other_board->IsBusy()) {
                if (special) { }
                else {
                    if (input == 'l') {
                        other_board->MoveLeft();
                    }
                    if (input == '\'') {
                        other_board->MoveRight();
                    }
                    if (input == ';') {
                        other_board->MoveDown();
                    }
                    if (input == 'm') {
                        other_board->RotateCCW();
                    }
                }
            }
        }
        // input
        
        my_board->Update();
        my_board->UpdatePlayerInformation(my_info);
        if (my_board->IsNeedNext()) {
            my_board->SetNextBiPuyo(my_next_bipuyo);
            my_next_bipuyo = my_bipuyo_generator->GenerateBipuyo();
        }
        other_board->TakeObstacles(my_board->SendObstacles());
        // effect please
        other_board->Update();
        other_board->UpdatePlayerInformation(other_info);
        if (other_board->IsNeedNext()) {
            other_board->SetNextBiPuyo(other_next_bipuyo);
            other_next_bipuyo = other_bipuyo_generator->GenerateBipuyo();
        }
        my_board->TakeObstacles(other_board->SendObstacles());
        gameover = my_board->IsGameOver() || other_board->IsGameOver();
        // process
        
        Draw();
        Console::Sleep(16);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movb 0x8(%rax), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x6206
jmp 0x6552
callq 0x5100
testb $0x1, %al
jne 0x6214
jmp 0x6359
callq 0x51d0
movl %eax, -0xc(%rbp)
movb $0x0, -0xd(%rbp)
cmpl $0xe0, -0xc(%rbp)
jne 0x6235
callq 0x51d0
movl %eax, -0xc(%rbp)
movb $0x1, -0xd(%rbp)
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8cf0
testb $0x1, %al
jne 0x62c6
testb $0x1, -0xd(%rbp)
je 0x6256
jmp 0x62c4
cmpl $0x64, -0xc(%rbp)
jne 0x6271
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8d10
cmpl $0x67, -0xc(%rbp)
jne 0x628c
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8e00
cmpl $0x66, -0xc(%rbp)
jne 0x62a7
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8ef0
cmpl $0x7a, -0xc(%rbp)
jne 0x62c2
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8f70
jmp 0x62c4
jmp 0x62c6
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8cf0
testb $0x1, %al
jne 0x6357
testb $0x1, -0xd(%rbp)
je 0x62e7
jmp 0x6355
cmpl $0x6c, -0xc(%rbp)
jne 0x6302
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8d10
cmpl $0x27, -0xc(%rbp)
jne 0x631d
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8e00
cmpl $0x3b, -0xc(%rbp)
jne 0x6338
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8ef0
cmpl $0x6d, -0xc(%rbp)
jne 0x6353
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x8f70
jmp 0x6355
jmp 0x6357
jmp 0x6359
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9180
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq -0x38(%rbp), %rsi
movq %rax, %rdi
addq $0x40, %rsi
callq 0x9200
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9260
testb $0x1, %al
jne 0x63a6
jmp 0x63f6
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq -0x38(%rbp), %rsi
movq %rax, %rdi
addq $0x30, %rsi
callq 0x8bb0
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x8c00
movq %rax, %rsi
leaq -0x20(%rbp), %rdi
callq 0x8c20
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
leaq -0x20(%rbp), %rsi
callq 0x8cc0
leaq -0x20(%rbp), %rdi
callq 0x8ca0
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq -0x38(%rbp), %rdi
movq %rax, -0x40(%rbp)
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9330
movq -0x40(%rbp), %rdi
movl %eax, %esi
callq 0x9310
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9180
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq -0x38(%rbp), %rsi
movq %rax, %rdi
addq $0x80, %rsi
callq 0x9200
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9260
testb $0x1, %al
jne 0x6477
jmp 0x64c7
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq -0x38(%rbp), %rsi
movq %rax, %rdi
addq $0x70, %rsi
callq 0x8bb0
movq -0x38(%rbp), %rdi
addq $0x50, %rdi
callq 0x8c00
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x8c20
movq -0x38(%rbp), %rdi
addq $0x70, %rdi
leaq -0x30(%rbp), %rsi
callq 0x8cc0
leaq -0x30(%rbp), %rdi
callq 0x8ca0
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq -0x38(%rbp), %rdi
movq %rax, -0x50(%rbp)
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9330
movq -0x50(%rbp), %rdi
movl %eax, %esi
callq 0x9310
movq -0x38(%rbp), %rdi
addq $0x20, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9280
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x41(%rbp)
jne 0x6531
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
callq 0x87b0
movq %rax, %rdi
callq 0x9280
movb %al, -0x41(%rbp)
movq -0x38(%rbp), %rdi
movb -0x41(%rbp), %al
andb $0x1, %al
movb %al, 0x8(%rdi)
movq (%rdi), %rax
callq *0x18(%rax)
movl $0x10, %edi
callq 0x5230
jmp 0x61f4
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)