// File: KellerMartins[P]PDS2-Pacman/source/game/pacman.cpp
// Function: Pacman::CalculaDirecao()
void Pacman::CalculaDirecao(){
	//RenderManager::DrawDebugCube((Vector3){ceilf(x-1), 0.5, roundf(y)}, (Vector3){1,1,1}, WHITE);
	//RenderManager::DrawDebugCube((Vector3){floorf(x+1), 0.5, roundf(y)}, (Vector3){1,1,1}, WHITE);
	//RenderManager::DrawDebugCube((Vector3){roundf(x), 0.5, ceilf(y-1)}, (Vector3){1,1,1}, WHITE);
	//RenderManager::DrawDebugCube((Vector3){roundf(x), 0.5, floorf(y+1)}, (Vector3){1,1,1}, WHITE);

	if (IsKeyPressed(KEY_LEFT) && Mapa::GetElementoMapa(ceilf(_x-1),roundf(_y)) != ElementoMapa::Parede)
	{
		_modelo.rotationAngle = -90;
		_y = roundf(_y);
		_direcaoY = 0;
		_direcaoX = -1;
	}
	else if (IsKeyPressed(KEY_RIGHT) && Mapa::GetElementoMapa(floorf(_x+1),roundf(_y)) != ElementoMapa::Parede)
	{
		_modelo.rotationAngle = 90;
		_y = roundf(_y);
		_direcaoY = 0;
		_direcaoX = 1;
	}
	else if (IsKeyPressed(KEY_UP) && Mapa::GetElementoMapa(roundf(_x),ceilf(_y-1)) != ElementoMapa::Parede)
	{
		_modelo.rotationAngle = 180;
		_x = roundf(_x);
		_direcaoY = -1;
		_direcaoX = 0;
	}
	else if(IsKeyPressed(KEY_DOWN) && Mapa::GetElementoMapa(roundf(_x),floorf(_y+1)) != ElementoMapa::Parede)
	{
		_modelo.rotationAngle = 0;
		_x = roundf(_x);
		_direcaoY = 1;
		_direcaoX = 0;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movl $0x107, %edi            # imm = 0x107
callq 0x3bf22
testb $0x1, %al
jne 0x13f37
jmp 0x13fcd
movq -0x10(%rbp), %rax
movss 0x2d4(%rax), %xmm0
movss 0x2d8(%rax), %xmm1
movss %xmm1, -0x18(%rbp)
movss 0x914a4(%rip), %xmm1    # 0xa53fc
addss %xmm1, %xmm0
callq 0x94b0
movaps %xmm0, %xmm1
movss -0x18(%rbp), %xmm0
cvttss2si %xmm1, %rax
movl %eax, -0x14(%rbp)
callq 0x98f0
movl -0x14(%rbp), %edi
cvttss2si %xmm0, %rax
movl %eax, %esi
callq 0x104d0
cmpl $0x1, %eax
je 0x13fcd
movq -0x10(%rbp), %rax
movss 0x911c6(%rip), %xmm0    # 0xa515c
movss %xmm0, 0x3c(%rax)
movss 0x2d8(%rax), %xmm0
callq 0x98f0
movq -0x10(%rbp), %rax
movss %xmm0, 0x2d8(%rax)
movl $0x0, 0x2cc(%rax)
movl $0xffffffff, 0x2d0(%rax) # imm = 0xFFFFFFFF
jmp 0x141c4
movl $0x106, %edi            # imm = 0x106
callq 0x3bf22
testb $0x1, %al
jne 0x13fe0
jmp 0x14076
movq -0x10(%rbp), %rax
movss 0x2d4(%rax), %xmm0
movss 0x2d8(%rax), %xmm1
movss %xmm1, -0x20(%rbp)
movss 0x9100f(%rip), %xmm1    # 0xa5010
addss %xmm1, %xmm0
callq 0x9310
movaps %xmm0, %xmm1
movss -0x20(%rbp), %xmm0
cvttss2si %xmm1, %rax
movl %eax, -0x1c(%rbp)
callq 0x98f0
movl -0x1c(%rbp), %edi
cvttss2si %xmm0, %rax
movl %eax, %esi
callq 0x104d0
cmpl $0x1, %eax
je 0x14076
movq -0x10(%rbp), %rax
movss 0x91119(%rip), %xmm0    # 0xa5158
movss %xmm0, 0x3c(%rax)
movss 0x2d8(%rax), %xmm0
callq 0x98f0
movq -0x10(%rbp), %rax
movss %xmm0, 0x2d8(%rax)
movl $0x0, 0x2cc(%rax)
movl $0x1, 0x2d0(%rax)
jmp 0x141c2
movl $0x109, %edi            # imm = 0x109
callq 0x3bf22
testb $0x1, %al
jne 0x14089
jmp 0x1411f
movq -0x10(%rbp), %rax
movss 0x2d4(%rax), %xmm0
movss 0x2d8(%rax), %xmm1
movss %xmm1, -0x28(%rbp)
callq 0x98f0
movaps %xmm0, %xmm1
movss -0x28(%rbp), %xmm0
cvttss2si %xmm1, %rax
movl %eax, -0x24(%rbp)
movss 0x9133d(%rip), %xmm1    # 0xa53fc
addss %xmm1, %xmm0
callq 0x94b0
movl -0x24(%rbp), %edi
cvttss2si %xmm0, %rax
movl %eax, %esi
callq 0x104d0
cmpl $0x1, %eax
je 0x1411f
movq -0x10(%rbp), %rax
movss 0x9106c(%rip), %xmm0    # 0xa5154
movss %xmm0, 0x3c(%rax)
movss 0x2d4(%rax), %xmm0
callq 0x98f0
movq -0x10(%rbp), %rax
movss %xmm0, 0x2d4(%rax)
movl $0xffffffff, 0x2cc(%rax) # imm = 0xFFFFFFFF
movl $0x0, 0x2d0(%rax)
jmp 0x141c0
movl $0x108, %edi            # imm = 0x108
callq 0x3bf22
testb $0x1, %al
jne 0x14132
jmp 0x141be
movq -0x10(%rbp), %rax
movss 0x2d4(%rax), %xmm0
movss 0x2d8(%rax), %xmm1
movss %xmm1, -0x30(%rbp)
callq 0x98f0
movaps %xmm0, %xmm1
movss -0x30(%rbp), %xmm0
cvttss2si %xmm1, %rax
movl %eax, -0x2c(%rbp)
movss 0x90ea8(%rip), %xmm1    # 0xa5010
addss %xmm1, %xmm0
callq 0x9310
movl -0x2c(%rbp), %edi
cvttss2si %xmm0, %rax
movl %eax, %esi
callq 0x104d0
cmpl $0x1, %eax
je 0x141be
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x3c(%rax)
movss 0x2d4(%rax), %xmm0
callq 0x98f0
movq -0x10(%rbp), %rax
movss %xmm0, 0x2d4(%rax)
movl $0x1, 0x2cc(%rax)
movl $0x0, 0x2d0(%rax)
jmp 0x141c0
jmp 0x141c2
jmp 0x141c4
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)