// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl $0x107, %edi            # imm = 0x107
callq 0x2f2aa
testb %al, %al
je 0xd029
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
addss 0x8b539(%rip), %xmm0    # 0x98538
callq 0x8490
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
callq 0x88a0
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xbefc
cmpl $0x1, %eax
jne 0xd14b
movl $0x106, %edi            # imm = 0x106
callq 0x2f2aa
testb %al, %al
je 0xd07e
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
addss 0x8b0e0(%rip), %xmm0    # 0x98134
callq 0x82f0
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
callq 0x88a0
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xbefc
cmpl $0x1, %eax
jne 0xd16b
movl $0x109, %edi            # imm = 0x109
callq 0x2f2aa
testb %al, %al
je 0xd0d3
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
callq 0x88a0
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
addss 0x8b480(%rip), %xmm0    # 0x98538
callq 0x8490
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xbefc
cmpl $0x1, %eax
jne 0xd18e
movl $0x108, %edi            # imm = 0x108
callq 0x2f2aa
testb %al, %al
je 0xd1bb
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
callq 0x88a0
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
addss 0x8b023(%rip), %xmm0    # 0x98134
callq 0x82f0
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xbefc
cmpl $0x1, %eax
je 0xd1bb
andl $0x0, 0x3c(%rbx)
movss 0x2d4(%rbx), %xmm0
callq 0x88a0
movss %xmm0, 0x2d4(%rbx)
xorl %eax, %eax
pushq $0x1
jmp 0xd1ae
movl $0xc2b40000, 0x3c(%rbx) # imm = 0xC2B40000
movss 0x2d8(%rbx), %xmm0
callq 0x88a0
movss %xmm0, 0x2d8(%rbx)
pushq $-0x1
jmp 0xd189
movl $0x42b40000, 0x3c(%rbx) # imm = 0x42B40000
movss 0x2d8(%rbx), %xmm0
callq 0x88a0
movss %xmm0, 0x2d8(%rbx)
pushq $0x1
popq %rax
xorl %ecx, %ecx
jmp 0xd1af
movl $0x43340000, 0x3c(%rbx) # imm = 0x43340000
movss 0x2d4(%rbx), %xmm0
callq 0x88a0
movss %xmm0, 0x2d4(%rbx)
xorl %eax, %eax
pushq $-0x1
popq %rcx
movl %ecx, 0x2cc(%rbx)
movl %eax, 0x2d0(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq