// File: Dalgona[P]mine/game.cpp
// Function: game::updateDisplay()
void game::updateDisplay()
{
  scr->mvprintw(0, 0, "[ MINESWEEPER ] ");
  if (newGame)
  {
    scr->with_color(4, [&]() {
      scr->printw("Step anywhere to start the game!");
    });
  }
  else
    scr->printw("%03d mines out of %03d (%02d, %02d)", nFlags, nMines, cX, cY);

  int num, color, c = 0;
  std::div_t d;
  char ch;
  for (const auto &i : field)
  {
    d = std::div(c++, cols);
    if (d.rem == 0) move(2 + d.quot, 8);

    if      (i & MF_DISP_UNKNOWN)  color = 200, ch = '.';
    else if (i & MF_DISP_FLAG)     color = 201, ch = 'F';
    else if (i & MF_DISP_QUESTION) color = 202, ch = '?';
    else if (i & MF_DISP_EMPTY)    color = 203, ch = ' ';
    else if (i & MF_DISP_NUMBER)
    {
      num = (i & 0x0FFFFFFF) >> 24;
      color = 100 + num, ch = '0' + num;
    }
    else if (i & MF_DISP_MINE)     color = 204, ch = '@';
    else if (i & MF_DISP_MINE_CLR) color = 205, ch = '@';

    scr->with_color(color, [&]() { addch(ch); });
  }

  scr->with_color(1, [&]() {
    scr->mvprintw(-1, 0, "ARROW/hjkl: MOVE    f: FLAG    q: NOTSURE    s: STEP");
  });
  move(2 + cY, 8 + cX);
  refresh();
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x40(%rsp)
movq (%rax), %rdi
xorl %edx, %edx
leaq 0x6224(%rip), %rcx      # 0x125dc
movl %edx, %esi
movb $0x0, %al
callq 0x11230
movq 0x40(%rsp), %rax
testb $0x1, 0x3c(%rax)
je 0xc446
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x30(%rsp)
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0xe8(%rsp), %rsi
callq 0xcff0
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rdx
movl $0x4, %esi
callq 0x11360
jmp 0xc411
leaq 0xf0(%rsp), %rdi
callq 0x8c90
jmp 0xc46a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x8c90
jmp 0xc7ad
movq 0x40(%rsp), %rax
movq (%rax), %rdi
movl 0x34(%rax), %edx
movl 0x30(%rax), %ecx
movl 0x2c(%rax), %r8d
movl 0x28(%rax), %r9d
leaq 0x618a(%rip), %rsi      # 0x125ed
movb $0x0, %al
callq 0x11170
movq 0x40(%rsp), %rax
movl $0x0, 0xd0(%rsp)
addq $0x8, %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0xe290
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0xe2c0
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xe2f0
testb $0x1, %al
jne 0xc4ce
jmp 0xc726
leaq 0xb0(%rsp), %rdi
callq 0xe330
movq %rax, %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0xa0(%rsp)
movl 0xd0(%rsp), %edi
movl %edi, %ecx
addl $0x1, %ecx
movl %ecx, 0xd0(%rsp)
movl 0x24(%rax), %esi
callq 0x2220
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0xc8(%rsp)
cmpl $0x0, 0xcc(%rsp)
jne 0xc53c
movl 0xc8(%rsp), %edi
addl $0x2, %edi
movl $0x8, %esi
callq 0x2190
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
je 0xc568
movl $0xc8, 0xd4(%rsp)
movb $0x2e, 0xc7(%rsp)
jmp 0xc699
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
je 0xc594
movl $0xc9, 0xd4(%rsp)
movb $0x46, 0xc7(%rsp)
jmp 0xc697
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x80000, %eax          # imm = 0x80000
cmpl $0x0, %eax
je 0xc5c0
movl $0xca, 0xd4(%rsp)
movb $0x3f, 0xc7(%rsp)
jmp 0xc695
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x20000, %eax          # imm = 0x20000
cmpl $0x0, %eax
je 0xc5ec
movl $0xcb, 0xd4(%rsp)
movb $0x20, 0xc7(%rsp)
jmp 0xc693
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x40000000, %eax       # imm = 0x40000000
cmpl $0x0, %eax
je 0xc63d
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0xfffffff, %eax        # imm = 0xFFFFFFF
sarl $0x18, %eax
movl %eax, 0xd8(%rsp)
movl 0xd8(%rsp), %eax
addl $0x64, %eax
movl %eax, 0xd4(%rsp)
movl 0xd8(%rsp), %eax
addl $0x30, %eax
movb %al, 0xc7(%rsp)
jmp 0xc691
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0x100000, %eax         # imm = 0x100000
cmpl $0x0, %eax
je 0xc666
movl $0xcc, 0xd4(%rsp)
movb $0x40, 0xc7(%rsp)
jmp 0xc68f
movq 0xa0(%rsp), %rax
movl (%rax), %eax
andl $0xe00000, %eax         # imm = 0xE00000
cmpl $0x0, %eax
je 0xc68d
movl $0xcd, 0xd4(%rsp)
movb $0x40, 0xc7(%rsp)
jmp 0xc68f
jmp 0xc691
jmp 0xc693
jmp 0xc695
jmp 0xc697
jmp 0xc699
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movl 0xd4(%rsp), %eax
movl %eax, 0x24(%rsp)
leaq 0xc7(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0x70(%rsp), %rsi
callq 0xd080
movq 0x18(%rsp), %rdi
movl 0x24(%rsp), %esi
movq 0x28(%rsp), %rdx
callq 0x11360
jmp 0xc6e7
leaq 0x78(%rsp), %rdi
callq 0x8c90
leaq 0xb0(%rsp), %rdi
callq 0xe340
jmp 0xc4b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x8c90
jmp 0xc7ad
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x8(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
movq %rdi, 0x10(%rsp)
leaq 0x48(%rsp), %rsi
callq 0xd110
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rdx
movl $0x1, %esi
callq 0x11360
jmp 0xc762
leaq 0x50(%rsp), %rdi
callq 0x8c90
movq 0x40(%rsp), %rax
movl 0x28(%rax), %edi
addl $0x2, %edi
movl 0x2c(%rax), %esi
addl $0x8, %esi
callq 0x2190
callq 0x23e0
addq $0x118, %rsp            # imm = 0x118
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x8c90
movq 0xe0(%rsp), %rdi
callq 0x2400
nopw (%rax,%rax)