// File: /workspace/github_cpp_makefile_star2_O2/tlaloc1313[P]chess-project/draw.cpp
// Function: draw(Board*, bool)
int draw(Board* gameBoard, bool isWhiteTurn) {

  int currentSquare;

  //Clears the screen
  for (int n=0; n<100; n++) {
    cout<<std::endl;
  }

  //Game board is displayed from White's POV
  if (isWhiteTurn == 1) {

    //Iterating through rows
    for (int row=7; row>=0; row--) {

      //Row numbering is displayed alongside the board
      cout<<row+1<<SPACINGH;

      //Iterating through columns
      for (int column=0; column<8; column++) {
        currentSquare = (column*8) + row;

        //Where the square is occupied, print that piece
        if (gameBoard->spaceOccupied(currentSquare) == 1) {
          cout<<gameBoard->getPiece(currentSquare)<<SPACINGH;
        } else { //Where the square is unoccupied, print either a black or white square
          if ((column+row)%2 == 0) {
            cout<<u8"\u25A0"<<SPACINGH;
          } else {
            cout<<u8"\u25A1"<<SPACINGH;
          }
        }
      }
      //Spacing between rows:
      cout<<SPACINGV;
    }
    // Column numbers are displayed below the board
    cout<<" "<<SPACINGH<<"a"<<SPACINGH<<"b"<<SPACINGH<<"c"<<SPACINGH<<"d"<<SPACINGH<<"e"<<SPACINGH<<"f"<<SPACINGH<<"g"<<SPACINGH<<"h \n\n";

  } else { //Game board is displayed from Black's POV

    //Iterating through rows
    for (int row=0; row<8; row++){

      //Row numbering is displayed alongside the board
      cout<<row+1<<SPACINGH;

      //Iterating through columns
      for (int column=7; column>=0; column--){
        currentSquare = (column*8) + row;

        //Where the square is occupied, print that piece
        if (gameBoard->spaceOccupied(currentSquare) == 1){
          cout<<gameBoard->getPiece(currentSquare)<<SPACINGH;
        } else { //Where the square is unoccupied, print either a black or white square
          if ((column+row)%2 == 0){
            cout<<u8"\u25A0"<<SPACINGH;
          } else {
            cout<<u8"\u25A1"<<SPACINGH;
          }
        }
      }
      //Spacing between rows:
      cout<<SPACINGV;
    }
    // Column numbers are displayed below the board
    cout<<" "<<SPACINGH<<"h"<<SPACINGH<<"g"<<SPACINGH<<"f"<<SPACINGH<<"e"<<SPACINGH<<"d"<<SPACINGH<<"c"<<SPACINGH<<"b"<<SPACINGH<<"a \n\n";
  }

  drawMoves(gameBoard);

return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %r14d
movq %rdi, %rbx
pushq $0x64
popq %r12
movq 0x6477(%rip), %r15      # 0x8fd0
subl $0x1, %r12d
jb 0x2b69
movq %r15, %rdi
callq 0x2090
jmp 0x2b59
testb %r14b, %r14b
je 0x2c77
pushq $0x7
popq %r12
leaq 0x36b7(%rip), %rax      # 0x6234
movq %rax, -0x70(%rbp)
leaq 0x36aa(%rip), %rax      # 0x6232
movq %rax, -0x68(%rbp)
leaq 0x369d(%rip), %rax      # 0x6230
movq %rax, -0x60(%rbp)
leaq 0x3690(%rip), %rax      # 0x622e
movq %rax, -0x58(%rbp)
leaq 0x374d(%rip), %rax      # 0x62f6
movq %rax, -0x50(%rbp)
leaq 0x3678(%rip), %rax      # 0x622c
movq %rax, -0x48(%rbp)
leaq 0x366b(%rip), %rax      # 0x622a
movq %rax, -0x40(%rbp)
leaq 0x365e(%rip), %rax      # 0x6228
movq %rax, -0x38(%rbp)
movq 0x63fb(%rip), %r14      # 0x8fd0
testl %r12d, %r12d
js 0x2d8f
leal 0x1(%r12), %esi
movq %r14, %rdi
callq 0x21a0
movq %rax, %rdi
leaq 0x3629(%rip), %rsi      # 0x621e
callq 0x20f0
xorl %r15d, %r15d
movl %r12d, %r13d
cmpl $0x8, %r15d
je 0x2c60
movq %rbx, %rdi
movl %r13d, %esi
callq 0x384c
testb %al, %al
je 0x2c28
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3b08
movq %r14, %rdi
movq %rax, %rsi
jmp 0x2c43
leal (%r12,%r15), %eax
movq %r14, %rdi
testb $0x1, %al
jne 0x2c3c
leaq 0x35e6(%rip), %rsi      # 0x6220
jmp 0x2c43
leaq 0x35e1(%rip), %rsi      # 0x6224
callq 0x20f0
movq %rax, %rdi
leaq 0x35cc(%rip), %rsi      # 0x621e
callq 0x20f0
incl %r15d
addl $0x8, %r13d
jmp 0x2c00
movq %r14, %rdi
leaq 0x33a3(%rip), %rsi      # 0x600d
callq 0x20f0
decl %r12d
jmp 0x2bd5
xorl %r13d, %r13d
pushq $0x38
popq %r12
leaq 0x35b6(%rip), %rax      # 0x623b
movq %rax, -0x70(%rbp)
leaq 0x359a(%rip), %rax      # 0x622a
movq %rax, -0x68(%rbp)
leaq 0x3591(%rip), %rax      # 0x622c
movq %rax, -0x60(%rbp)
leaq 0x3650(%rip), %rax      # 0x62f6
movq %rax, -0x58(%rbp)
leaq 0x357d(%rip), %rax      # 0x622e
movq %rax, -0x50(%rbp)
leaq 0x3574(%rip), %rax      # 0x6230
movq %rax, -0x48(%rbp)
leaq 0x356b(%rip), %rax      # 0x6232
movq %rax, -0x40(%rbp)
leaq 0x3567(%rip), %rax      # 0x6239
movq %rax, -0x38(%rbp)
movq 0x62f3(%rip), %r14      # 0x8fd0
cmpl $0x8, %r13d
je 0x2d8f
leal 0x1(%r13), %esi
movq %r14, %rdi
movl %esi, -0x2c(%rbp)
callq 0x21a0
movq %rax, %rdi
leaq 0x351e(%rip), %rsi      # 0x621e
callq 0x20f0
movl %r12d, -0x30(%rbp)
pushq $0x7
popq %rax
movl %eax, %r15d
testl %r15d, %r15d
js 0x2d6e
movq %rbx, %rdi
movl %r12d, %esi
callq 0x384c
testb %al, %al
je 0x2d36
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3b08
movq %r14, %rdi
movq %rax, %rsi
jmp 0x2d51
leal (%r15,%r13), %eax
movq %r14, %rdi
testb $0x1, %al
jne 0x2d4a
leaq 0x34d8(%rip), %rsi      # 0x6220
jmp 0x2d51
leaq 0x34d3(%rip), %rsi      # 0x6224
callq 0x20f0
movq %rax, %rdi
leaq 0x34be(%rip), %rsi      # 0x621e
callq 0x20f0
decl %r15d
addl $-0x8, %r12d
jmp 0x2d0f
movq %r14, %rdi
leaq 0x3295(%rip), %rsi      # 0x600d
callq 0x20f0
movl -0x30(%rbp), %r12d
incl %r12d
movl -0x2c(%rbp), %eax
movl %eax, %r13d
jmp 0x2cdd
movq 0x623a(%rip), %rdi      # 0x8fd0
leaq 0x3481(%rip), %r14      # 0x621e
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x68(%rbp), %rsi
callq 0x20f0
movq %rax, %rdi
movq %r14, %rsi
callq 0x20f0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x20f0
movq %rbx, %rdi
callq 0x2a50
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop