// File: /workspace/github_cpp_makefile_star2_O2/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: add_device(int, int, int, bool)
item* add_device(int type,int x,int y,bool in_inv)
{
	item* dev = new item();
	if(type == HOLOGRAM_PROJECTOR)
	{
		dev->projection = add_actor(zoo[0],false,-500,-500,true);
	}
	dev->device_type = type;
	dev->colour = COLOR_RED;
	dev->wavelength = -1;
	dev->time_remaining = -1;
	dev->species_stored = -1;
	dev->current_action = NULL_STIMULUS;
	dev->next_action = NULL_STIMULUS;
	dev->configuration = UNCONFIGURED;
	dev->power_remaining = 100;
	dev->player_has = false;
	switch (type)
	{
	case 0:
		dev->name = "low explosive";
		dev->ch = 'A';
		dev->description = "Inflicts damage on creatures and walls within a 3x3 area. Including you.";
		break;
	case 1:
		dev->name = "high explosive";
		dev->ch = 'B';
		dev->description = "Inflicts great damage on creatures and walls within a 5x5 area. Including you.";
		break;
	case 2:
		dev->name = "hologram projector";
		dev->description = "Projects holograms that confuse creatures that rely on sight. Such as you.";
		dev->ch = 'C';
		break;
	case 3:
		dev->name = "noise generator";
		dev->description = "Confuses or deafens creatures that rely on hearing. Like you.";
		dev->ch = 'D';
		break;
	case 4:
		dev->name = "scent generator";
		dev->ch = 'E';
		dev->description = "Confuses creatures with a sense of smell. For instance... your dog.";
		break;
	case 5:
		dev->name = "brain slice";
		dev->description = "Confuses creatures with a psychic sense. Like that guy from the infotainment datalinks.";
		dev->ch = 'F';
		break;
	default:
		delete dev;
		return NULL;
	}
	dev->base_description = dev->description;
	if (in_inv)
	{
		dev->x = p_ptr->x;
		dev->y = p_ptr->y;
		device_to_inventory(dev);
	}
	else
	{
		item_to_location(dev,x,y);
	}
	return dev;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %r15d
movl %edx, %ebp
movl %esi, %r14d
movl %edi, %r12d
movl $0xa0, %edi
callq 0x5230
movq %rax, %rbx
movl $0xa0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x5180
movq %rbx, %rdi
callq 0x110ea
cmpl $0x2, %r12d
jne 0xae92
movq 0x60579(%rip), %rax     # 0x6b3f0
movq (%rax), %rdi
pushq $0x1
popq %r8
xorl %esi, %esi
movl $0xfffffe0c, %edx       # imm = 0xFFFFFE0C
movl $0xfffffe0c, %ecx       # imm = 0xFFFFFE0C
callq 0x979c
movq %rax, (%rbx)
movl %r12d, 0x70(%rbx)
movl $0x1, 0x8(%rbx)
andq $0x0, 0x84(%rbx)
andl $0x0, 0x8c(%rbx)
movaps 0x92bd(%rip), %xmm0     # 0x14170
movups %xmm0, 0x74(%rbx)
movb $0x0, 0x98(%rbx)
cmpl $0x5, %r12d
ja 0xaff6
movl %r12d, %eax
leaq 0x92ae(%rip), %rcx      # 0x14180
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x10(%rbx), %rdi
leaq 0x9cc8(%rip), %rsi      # 0x14bae
callq 0x53f0
movb $0x41, 0xc(%rbx)
leaq 0x30(%rbx), %rdi
leaq 0x9cc2(%rip), %rsi      # 0x14bbc
jmp 0xaf8b
leaq 0x10(%rbx), %rdi
leaq 0x9e05(%rip), %rsi      # 0x14d0f
callq 0x53f0
movb $0x45, 0xc(%rbx)
leaq 0x30(%rbx), %rdi
leaq 0x9e01(%rip), %rsi      # 0x14d1f
jmp 0xaf8b
leaq 0x10(%rbx), %rdi
leaq 0x9d38(%rip), %rsi      # 0x14c63
callq 0x53f0
leaq 0x30(%rbx), %rdi
leaq 0x9d3b(%rip), %rsi      # 0x14c76
callq 0x53f0
movb $0x43, 0xc(%rbx)
jmp 0xafb6
leaq 0x10(%rbx), %rdi
leaq 0x9d70(%rip), %rsi      # 0x14cc1
callq 0x53f0
leaq 0x30(%rbx), %rdi
leaq 0x9d70(%rip), %rsi      # 0x14cd1
callq 0x53f0
movb $0x44, 0xc(%rbx)
jmp 0xafb6
leaq 0x10(%rbx), %rdi
leaq 0x9c8e(%rip), %rsi      # 0x14c05
callq 0x53f0
movb $0x42, 0xc(%rbx)
leaq 0x30(%rbx), %rdi
leaq 0x9c89(%rip), %rsi      # 0x14c14
callq 0x53f0
jmp 0xafb6
leaq 0x10(%rbx), %rdi
leaq 0x9dc6(%rip), %rsi      # 0x14d63
callq 0x53f0
leaq 0x30(%rbx), %rdi
leaq 0x9dc2(%rip), %rsi      # 0x14d6f
callq 0x53f0
movb $0x46, 0xc(%rbx)
leaq 0x30(%rbx), %rsi
movq %rbx, %rdi
addq $0x50, %rdi
callq 0x5170
testb %r15b, %r15b
je 0xafe7
movq 0x6050e(%rip), %rax     # 0x6b4e0
movq 0x20(%rax), %rax
movq %rax, 0x90(%rbx)
movq %rbx, %rdi
callq 0x967c
jmp 0xb008
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x958f
jmp 0xb008
movq %rbx, %rdi
callq 0x111d2
movq %rbx, %rdi
callq 0x5210
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq