// File: /workspace/github_c_makefile_star2_O0/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::oscillatorInit()
void TED::oscillatorInit()
{
	unsigned int i;

	oscillatorReset();

	int im = 0xff;
    for (i = 0; i < 256; i++) {
		im = (im << 1) | (((im >> 7) ^ (im >> 5) ^ (im >> 4) ^ (im >> 1)) & 1);
		noise[i] = im & 1;
    }
	for (i = 0; i < 64; i++) {
		int chdbl = (i & 0x30) == 0x30;
		int vol = ((i & 0x0F) < 9 ? (i & 0x0F) : 8);
		int nonl = ((chdbl && vol > 1) ? vol * vol * 54 - 173 * vol + 162 : 0);
		volumeTable[i] = (vol && i & 0x30) ?
			(nonl + (586 + (vol - 1) * 1024) << (chdbl ? 1 : 0)) : 0;
	}
	oscStep = (1 << PRECISION) << 0;

	// set player specific parameters
	waveForm[0] = waveForm[1] = 1;
	masterVolume = AMP(8);
	setplaybackSpeed(3);
	enableChannel(0, true);
	enableChannel(1, true);
	enableChannel(2, true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
callq 0x19970
movl $0xff, -0x10(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x100, -0xc(%rbp)      # imm = 0x100
jae 0x19a7c
movl -0x10(%rbp), %eax
shll %eax
movl -0x10(%rbp), %ecx
sarl $0x7, %ecx
movl -0x10(%rbp), %edx
sarl $0x5, %edx
xorl %edx, %ecx
movl -0x10(%rbp), %edx
sarl $0x4, %edx
xorl %edx, %ecx
movl -0x10(%rbp), %edx
sarl %edx
xorl %edx, %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
andl $0x1, %eax
movb %al, %dl
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1bf52(%rip), %rax     # 0x359c0
movb %dl, (%rax,%rcx)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19a27
movl $0x0, -0xc(%rbp)
cmpl $0x40, -0xc(%rbp)
jae 0x19b60
movl -0xc(%rbp), %eax
andl $0x30, %eax
cmpl $0x30, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
andl $0xf, %eax
cmpl $0x9, %eax
jae 0x19ab7
movl -0xc(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19ac1
movl $0x8, %eax
movl %eax, -0x2c(%rbp)
jmp 0x19ac1
movl -0x2c(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x19af0
cmpl $0x1, -0x18(%rbp)
jle 0x19af0
movl -0x18(%rbp), %eax
imull -0x18(%rbp), %eax
imull $0x36, %eax, %eax
imull $0xad, -0x18(%rbp), %ecx
subl %ecx, %eax
addl $0xa2, %eax
movl %eax, -0x30(%rbp)
jmp 0x19af7
xorl %eax, %eax
movl %eax, -0x30(%rbp)
jmp 0x19af7
movl -0x30(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x19b39
movl -0xc(%rbp), %eax
andl $0x30, %eax
cmpl $0x0, %eax
je 0x19b39
movl -0x1c(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
shll $0xa, %ecx
addl $0x24a, %ecx            # imm = 0x24A
addl %ecx, %eax
movl -0x14(%rbp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x0, %esi
cmovnel %edx, %ecx
shll %cl, %eax
movl %eax, -0x34(%rbp)
jmp 0x19b40
xorl %eax, %eax
movl %eax, -0x34(%rbp)
jmp 0x19b40
movl -0x34(%rbp), %edx
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x1bf71(%rip), %rax     # 0x35ac0
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x19a83
movq -0x28(%rbp), %rax
movl $0x1, 0x1c052(%rip)     # 0x35bc0
movl $0x1, 0xb61b4(%rax)
movl $0x1, 0xb61b0(%rax)
movsd 0x57ce(%rip), %xmm0     # 0x1f358
movss 0x5d06(%rip), %xmm1     # 0x1f898
callq 0x1a460
movq -0x28(%rbp), %rdi
movsd 0x5cdd(%rip), %xmm1     # 0x1f880
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, 0x1bdce(%rip)     # 0x35980
movl $0x3, %esi
callq 0x19c00
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x19700
movq -0x28(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x19700
movq -0x28(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x19700
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)