// File: matallui[P]nibble-curses/src/CNibbles.cpp
// Function: CNibbles::CNibbles()
CNibbles::CNibbles ( void )
	: m_exception ( "" )
{
  m_maxLines = 36;
  m_maxCols = 100;
  m_level = 0;
  m_num_obstacles = 0;
  m_nplayers = 0;
  m_mode = 0;				// 1-Single Player , 2-Multi-player on PC, 3-Multi-player over Network
  m_speed = 0;				// game speed
  m_nfood = 0;				// food number
  m_score = 0;				// global score ( sum of all player scores )
  m_snakes = new CSnake* [2];		// pointer array to control game players
  m_snakes[0] = m_snakes[1] = NULL;
  m_socket = NULL;			// pointer to socket
  m_master = true;			// determines who is the server / player 1 ( = true )
  
  srand(time(NULL));	// initialize seed
  
  // initialize ncurses
  initscr ();
  nodelay ( stdscr, true );
  if ( getenv("ESCDELAY") == NULL ) ESCDELAY = 25;
  keypad ( stdscr, true );
  noecho ();
  curs_set (0);
  start_color();
  init_pair ( 1, COLOR_BLACK, COLOR_BLACK );	// for erasing
  init_pair ( 2, COLOR_YELLOW, COLOR_YELLOW );	// for obstacles
  init_pair ( 3, COLOR_WHITE, COLOR_BLACK );	// for scores
  init_pair ( 4, COLOR_GREEN, COLOR_BLACK );	// for player 1
  init_pair ( 5, COLOR_BLUE, COLOR_BLACK );	// for player 2
  init_pair ( 6, COLOR_RED, COLOR_WHITE );	// for pop-up windows
  
  // allocate memory for obstacles and set their colors
  m_obstacles = new CObstacle [20];
  for ( int i = 0; i < 20; i++ )
    m_obstacles[i].SetColors( 2, 1 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x78(%rbp)
addq $0x38, %rdi
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
leaq -0xc(%rbp), %rsi
leaq -0x10(%rbp), %rdx
callq 0x3bd0
movq -0x78(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x70(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x34f0
movq -0x68(%rbp), %rdx
leaq 0x6331(%rip), %rsi      # 0xc4eb
leaq -0x30(%rbp), %rdi
callq 0x3880
jmp 0x61c5
movq -0x70(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3770
jmp 0x61d4
leaq -0x30(%rbp), %rdi
callq 0x31d0
leaq -0x31(%rbp), %rdi
callq 0x3340
movq -0x78(%rbp), %rax
movl $0x24, (%rax)
movl $0x64, 0x4(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, 0xc(%rax)
movl $0x0, 0x10(%rax)
movl $0x0, 0x14(%rax)
movl $0x0, 0x1c(%rax)
movl $0x0, 0x40(%rax)
movl $0x0, 0x20(%rax)
movl $0x10, %edi
callq 0x3030
movq %rax, -0x80(%rbp)
jmp 0x6238
movq -0x78(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq 0x30(%rax), %rcx
movq $0x0, 0x8(%rcx)
movq 0x30(%rax), %rcx
movq $0x0, (%rcx)
movq $0x0, 0x48(%rax)
movb $0x1, 0x18(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x32a0
movl %eax, %edi
callq 0x32b0
callq 0x3470
jmp 0x627e
movq 0x9d4b(%rip), %rax      # 0xffd0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x31c0
jmp 0x6294
leaq 0x60bb(%rip), %rdi      # 0xc356
callq 0x33c0
cmpq $0x0, %rax
jne 0x62f7
movq 0x9d13(%rip), %rax      # 0xffc0
movl $0x19, (%rax)
jmp 0x62f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x62d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x31d0
leaq -0x31(%rbp), %rdi
callq 0x3340
jmp 0x64af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x64a6
movq 0x9cd2(%rip), %rax      # 0xffd0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x3140
jmp 0x630d
callq 0x33a0
jmp 0x6314
xorl %edi, %edi
callq 0x3240
jmp 0x631d
callq 0x30a0
jmp 0x6324
movl $0x1, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x3070
jmp 0x6334
movl $0x2, %edi
movl $0x3, %edx
movl %edx, %esi
callq 0x3070
jmp 0x6347
movl $0x3, %edi
movl $0x7, %esi
xorl %edx, %edx
callq 0x3070
jmp 0x635a
movl $0x4, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3070
jmp 0x636d
movl $0x5, %edi
movl $0x4, %esi
xorl %edx, %edx
callq 0x3070
jmp 0x6380
movl $0x6, %edi
movl $0x1, %esi
movl $0x7, %edx
callq 0x3070
jmp 0x6396
movl $0x1e0, %edi            # imm = 0x1E0
callq 0x3030
movq %rax, -0x88(%rbp)
jmp 0x63a9
movq -0x88(%rbp), %rax
movq %rax, %rcx
addq $0x1e0, %rcx            # imm = 0x1E0
movq %rcx, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movb $0x48, -0x51(%rbp)
leaq -0x48(%rbp), %rsi
leaq -0x4c(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x51(%rbp), %r8
callq 0x3e60
jmp 0x6406
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %rax
addq $0x18, %rax
cmpq %rcx, %rax
movq %rax, -0x90(%rbp)
jne 0x63c8
movq -0x78(%rbp), %rax
movq -0x88(%rbp), %rcx
movq %rcx, 0x28(%rax)
movl $0x0, -0x58(%rbp)
cmpl $0x14, -0x58(%rbp)
jge 0x649d
movq -0x78(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x58(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rdi
movl $0x2, -0x5c(%rbp)
movl $0x1, -0x60(%rbp)
leaq -0x5c(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x3f20
jmp 0x6471
jmp 0x6473
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x643a
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl $0x1e0, %esi            # imm = 0x1E0
callq 0x3510
jmp 0x64a6
addq $0xa0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0xbc30
movq -0x40(%rbp), %rdi
callq 0x34e0
nopl (%rax,%rax)