// File: 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:
subq $0x38, %rsp
movb %cl, %al
movl %edi, 0x2c(%rsp)
movl %esi, 0x28(%rsp)
movl %edx, 0x24(%rsp)
andb $0x1, %al
movb %al, 0x23(%rsp)
movl $0xa0, %edi
callq 0x52c0
movq %rax, %rdi
movq %rdi, 0x10(%rsp)
xorl %esi, %esi
movl $0xa0, %edx
callq 0x51c0
movq 0x10(%rsp), %rdi
callq 0x20ca0
movq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpl $0x2, 0x2c(%rsp)
jne 0x13a33
leaq 0x74a58(%rip), %rdi     # 0x88460
xorl %eax, %eax
movl %eax, %esi
callq 0x20650
movq (%rax), %rdi
xorl %esi, %esi
movl $0xfffffe0c, %ecx       # imm = 0xFFFFFE0C
movl $0x1, %r8d
movl %ecx, %edx
callq 0xfdf0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movl 0x2c(%rsp), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x70(%rax)
movq 0x18(%rsp), %rax
movl $0x1, 0x8(%rax)
movq 0x18(%rsp), %rax
movl $0xffffffff, 0x74(%rax) # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
movl $0xffffffff, 0x7c(%rax) # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
movl $0xffffffff, 0x80(%rax) # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rax
movl $0x0, 0x84(%rax)
movq 0x18(%rsp), %rax
movl $0x0, 0x88(%rax)
movq 0x18(%rsp), %rax
movl $0x0, 0x8c(%rax)
movq 0x18(%rsp), %rax
movl $0x64, 0x78(%rax)
movq 0x18(%rsp), %rax
movb $0x0, 0x98(%rax)
movl 0x2c(%rsp), %eax
movq %rax, 0x8(%rsp)
subq $0x5, %rax
ja 0x13c29
movq 0x8(%rsp), %rax
leaq 0x1962a(%rip), %rcx     # 0x2d100
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a333(%rip), %rsi     # 0x2de22
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x41, 0xc(%rax)
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a323(%rip), %rsi     # 0x2de30
callq 0x53c0
jmp 0x13c55
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a352(%rip), %rsi     # 0x2de79
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x42, 0xc(%rax)
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a343(%rip), %rsi     # 0x2de88
callq 0x53c0
jmp 0x13c55
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a378(%rip), %rsi     # 0x2ded7
callq 0x53c0
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a376(%rip), %rsi     # 0x2deea
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x43, 0xc(%rax)
jmp 0x13c55
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a39e(%rip), %rsi     # 0x2df35
callq 0x53c0
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a399(%rip), %rsi     # 0x2df45
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x44, 0xc(%rax)
jmp 0x13c55
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a3b4(%rip), %rsi     # 0x2df83
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x45, 0xc(%rax)
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a3a6(%rip), %rsi     # 0x2df93
callq 0x53c0
jmp 0x13c55
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
leaq 0x1a3d3(%rip), %rsi     # 0x2dfd7
callq 0x53c0
movq 0x18(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1a3ca(%rip), %rsi     # 0x2dfe3
callq 0x53c0
movq 0x18(%rsp), %rax
movb $0x46, 0xc(%rax)
jmp 0x13c55
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x13c4a
movq (%rsp), %rdi
callq 0x210e0
movq (%rsp), %rdi
callq 0x5290
movq $0x0, 0x30(%rsp)
jmp 0x13cc5
movq 0x18(%rsp), %rsi
addq $0x30, %rsi
movq 0x18(%rsp), %rdi
addq $0x50, %rdi
callq 0x5040
testb $0x1, 0x23(%rsp)
je 0x13ca9
movq 0x748d6(%rip), %rax     # 0x88550
movl 0x20(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x90(%rax)
movq 0x748c1(%rip), %rax     # 0x88550
movl 0x24(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x94(%rax)
movq 0x18(%rsp), %rdi
callq 0xfc70
jmp 0x13cbb
movq 0x18(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x24(%rsp), %edx
callq 0xfad0
movq 0x18(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
addq $0x38, %rsp
retq
nop