// File: /workspace/github_c_makefile_star2_O3/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::getWaveSample(unsigned int, unsigned int)
inline unsigned int TED::getWaveSample(unsigned int channel, unsigned int wave)
{
	unsigned int sm;

	switch (wave) {
		default:
		case 1: // square
			return waveSquare(channel);
		case 2: // sawtooth
			return waveSawTooth(channel);
		case 4: // triangle
			return waveTriangle(channel);

		// combined waveforms � la SID
		case 3: // square + sawtooth
			sm = waveSawTooth(channel) + waveSquare(channel);
			return sm /= 2;
		case 5: // square + triangle
			sm = waveTriangle(channel) + waveSquare(channel);
			return sm /= 2;
		case 6: // sawtooth + triangle
			sm = waveTriangle(channel) + waveSawTooth(channel);
			return sm /= 2;
		case 7: // square + sawtooth + triangle
			sm = waveTriangle(channel) + waveSawTooth(channel) + waveSquare(channel);
			return sm /= 3;
	}
}

// Assembly:
addl $-0x2, %edx
cmpl $0x5, %edx
ja 0xca6d
leaq 0x40e1(%rip), %rax      # 0x10970
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl %esi, %eax
leaq 0x19c57(%rip), %rcx     # 0x264f8
movl (%rcx,%rax,4), %ecx
leaq 0x19e7d(%rip), %rdx     # 0x26728
movl (%rdx,%rax,4), %edx
subl %edx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
imull 0x19e72(%rip), %eax     # 0x26730
movl $0x401, %ecx            # imm = 0x401
subl %edx, %ecx
cltd
idivl %ecx
retq
movl %esi, %eax
leaq 0x19e56(%rip), %rcx     # 0x26728
movl (%rcx,%rax,4), %edi
leal 0x400(%rdi), %ecx
shrl $0x1f, %ecx
leal (%rdi,%rcx), %esi
addl $0x400, %esi            # imm = 0x400
sarl %esi
leaq 0x19c08(%rip), %rcx     # 0x264f8
movl (%rcx,%rax,4), %ecx
xorl %r8d, %r8d
cmpl %esi, %ecx
movl %esi, %edx
cmovll %r8d, %edx
movl %ecx, %eax
subl %edx, %eax
movl 0x19e27(%rip), %r9d     # 0x26730
imull %r9d, %eax
xorl %edx, %edx
divl %esi
movl %eax, %esi
subl %edi, %ecx
testl %ecx, %ecx
cmovlel %r8d, %ecx
imull %r9d, %ecx
movl $0x401, %r8d            # imm = 0x401
subl %edi, %r8d
movl %ecx, %eax
cltd
idivl %r8d
jmp 0xc9b8
movl %esi, %eax
leaq 0x19dec(%rip), %rcx     # 0x26728
movl (%rcx,%rax,4), %ecx
movl %ecx, %edx
addl $0x400, %edx            # imm = 0x400
shrl $0x1f, %edx
addl %edx, %ecx
addl $0x400, %ecx            # imm = 0x400
sarl %ecx
leaq 0x19b9d(%rip), %rdx     # 0x264f8
movl (%rdx,%rax,4), %eax
xorl %edx, %edx
cmpl %ecx, %eax
movl %ecx, %esi
cmovll %edx, %esi
subl %esi, %eax
imull 0x19dc0(%rip), %eax     # 0x26730
xorl %edx, %edx
divl %ecx
retq
movl %esi, %eax
leaq 0x19daa(%rip), %rcx     # 0x26728
movl (%rcx,%rax,4), %ecx
movl %ecx, %edx
addl $0x400, %edx            # imm = 0x400
shrl $0x1f, %edx
addl %edx, %ecx
addl $0x400, %ecx            # imm = 0x400
sarl %ecx
leaq 0x19b5b(%rip), %rdx     # 0x264f8
movl (%rdx,%rax,4), %eax
xorl %edx, %edx
cmpl %ecx, %eax
movl %ecx, %esi
cmovll %edx, %esi
subl %esi, %eax
movl 0x19d7f(%rip), %esi     # 0x26730
imull %esi, %eax
xorl %edx, %edx
divl %ecx
addl %esi, %eax
jmp 0xc9f0
movl %esi, %eax
leaq 0x19b33(%rip), %rcx     # 0x264f8
movl (%rcx,%rax,4), %ecx
leaq 0x19d59(%rip), %rdx     # 0x26728
movl (%rdx,%rax,4), %edx
subl %edx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
movl 0x19d4f(%rip), %ecx     # 0x26730
imull %ecx, %eax
movl $0x401, %esi            # imm = 0x401
subl %edx, %esi
cltd
idivl %esi
addl %ecx, %eax
shrl %eax
retq
movl %esi, %eax
leaq 0x19d2c(%rip), %rcx     # 0x26728
movl (%rcx,%rax,4), %edi
leal 0x400(%rdi), %ecx
shrl $0x1f, %ecx
leal (%rdi,%rcx), %esi
addl $0x400, %esi            # imm = 0x400
sarl %esi
leaq 0x19ade(%rip), %rcx     # 0x264f8
movl (%rcx,%rax,4), %ecx
xorl %r8d, %r8d
cmpl %esi, %ecx
movl %esi, %edx
cmovll %r8d, %edx
movl %ecx, %eax
subl %edx, %eax
movl 0x19cfd(%rip), %r9d     # 0x26730
imull %r9d, %eax
xorl %edx, %edx
divl %esi
movl %eax, %esi
subl %edi, %ecx
testl %ecx, %ecx
cmovlel %r8d, %ecx
imull %r9d, %ecx
movl $0x401, %r8d            # imm = 0x401
subl %edi, %r8d
movl %ecx, %eax
cltd
idivl %r8d
movl %eax, %ecx
addl %r9d, %ecx
addl %esi, %ecx
movl $0xaaaaaaab, %eax       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
retq
movl 0x19cbd(%rip), %eax     # 0x26730
retq