// File: /workspace/github_cpp_makefile_star2_O1/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 0x2fe62
testb %al, %al
je 0xd6fb
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
addss 0x8be3f(%rip), %xmm0    # 0x99510
callq 0x8490
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
callq 0x8890
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xc4f2
cmpl $0x1, %eax
jne 0xd823
movl $0x106, %edi            # imm = 0x106
callq 0x2fe62
testb %al, %al
je 0xd750
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
addss 0x8ba0e(%rip), %xmm0    # 0x99134
callq 0x8300
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
callq 0x8890
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xc4f2
cmpl $0x1, %eax
jne 0xd846
movl $0x109, %edi            # imm = 0x109
callq 0x2fe62
testb %al, %al
je 0xd7a5
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
callq 0x8890
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
addss 0x8bd86(%rip), %xmm0    # 0x99510
callq 0x8490
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xc4f2
cmpl $0x1, %eax
jne 0xd86b
movl $0x108, %edi            # imm = 0x108
callq 0x2fe62
testb %al, %al
je 0xd89a
movss 0x2d4(%rbx), %xmm0
movss 0x2d8(%rbx), %xmm1
movss %xmm1, -0x14(%rbp)
callq 0x8890
cvttss2si %xmm0, %r14
movss -0x14(%rbp), %xmm0
addss 0x8b951(%rip), %xmm0    # 0x99134
callq 0x8300
cvttss2si %xmm0, %rsi
movl %r14d, %edi
callq 0xc4f2
cmpl $0x1, %eax
je 0xd89a
movl $0x0, 0x3c(%rbx)
movss 0x2d4(%rbx), %xmm0
callq 0x8890
movss %xmm0, 0x2d4(%rbx)
xorl %eax, %eax
movl $0x1, %ecx
jmp 0xd88e
movl $0xc2b40000, 0x3c(%rbx) # imm = 0xC2B40000
movss 0x2d8(%rbx), %xmm0
callq 0x8890
movss %xmm0, 0x2d8(%rbx)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xd867
movl $0x42b40000, 0x3c(%rbx) # imm = 0x42B40000
movss 0x2d8(%rbx), %xmm0
callq 0x8890
movss %xmm0, 0x2d8(%rbx)
movl $0x1, %eax
xorl %ecx, %ecx
jmp 0xd88e
movl $0x43340000, 0x3c(%rbx) # imm = 0x43340000
movss 0x2d4(%rbx), %xmm0
callq 0x8890
movss %xmm0, 0x2d4(%rbx)
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl %ecx, 0x2cc(%rbx)
movl %eax, 0x2d0(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop