// File: /workspace/github_c_makefile_star2_O1/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 0xc58d
leaq 0x4371(%rip), %rax      # 0x10720
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl %esi, %eax
leaq 0x19133(%rip), %rcx     # 0x254f4
movl (%rcx,%rax,4), %ecx
leaq 0x19359(%rip), %rdx     # 0x25724
movl (%rdx,%rax,4), %edx
subl %edx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
imull 0x1934e(%rip), %eax     # 0x2572c
movl $0x401, %ecx            # imm = 0x401
subl %edx, %ecx
cltd
idivl %ecx
retq
movl %esi, %eax
leaq 0x19332(%rip), %rcx     # 0x25724
movl (%rcx,%rax,4), %edi
leal 0x400(%rdi), %ecx
shrl $0x1f, %ecx
leal (%rdi,%rcx), %esi
addl $0x400, %esi            # imm = 0x400
sarl %esi
leaq 0x190e4(%rip), %rcx     # 0x254f4
movl (%rcx,%rax,4), %ecx
xorl %r8d, %r8d
cmpl %esi, %ecx
movl %esi, %edx
cmovll %r8d, %edx
movl %ecx, %eax
subl %edx, %eax
movl 0x19303(%rip), %r9d     # 0x2572c
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 0xc4d8
movl %esi, %eax
leaq 0x192c8(%rip), %rcx     # 0x25724
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 0x19079(%rip), %rdx     # 0x254f4
movl (%rdx,%rax,4), %eax
xorl %edx, %edx
cmpl %ecx, %eax
movl %ecx, %esi
cmovll %edx, %esi
subl %esi, %eax
imull 0x1929c(%rip), %eax     # 0x2572c
xorl %edx, %edx
divl %ecx
retq
movl %esi, %eax
leaq 0x19286(%rip), %rcx     # 0x25724
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 0x19037(%rip), %rdx     # 0x254f4
movl (%rdx,%rax,4), %eax
xorl %edx, %edx
cmpl %ecx, %eax
movl %ecx, %esi
cmovll %edx, %esi
subl %esi, %eax
movl 0x1925b(%rip), %esi     # 0x2572c
imull %esi, %eax
xorl %edx, %edx
divl %ecx
addl %esi, %eax
jmp 0xc510
movl %esi, %eax
leaq 0x1900f(%rip), %rcx     # 0x254f4
movl (%rcx,%rax,4), %ecx
leaq 0x19235(%rip), %rdx     # 0x25724
movl (%rdx,%rax,4), %edx
subl %edx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
movl 0x1922b(%rip), %ecx     # 0x2572c
imull %ecx, %eax
movl $0x401, %esi            # imm = 0x401
subl %edx, %esi
cltd
idivl %esi
addl %ecx, %eax
shrl %eax
retq
movl %esi, %eax
leaq 0x19208(%rip), %rcx     # 0x25724
movl (%rcx,%rax,4), %edi
leal 0x400(%rdi), %ecx
shrl $0x1f, %ecx
leal (%rdi,%rcx), %esi
addl $0x400, %esi            # imm = 0x400
sarl %esi
leaq 0x18fba(%rip), %rcx     # 0x254f4
movl (%rcx,%rax,4), %ecx
xorl %r8d, %r8d
cmpl %esi, %ecx
movl %esi, %edx
cmovll %r8d, %edx
movl %ecx, %eax
subl %edx, %eax
movl 0x191d9(%rip), %r9d     # 0x2572c
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 0x19199(%rip), %eax     # 0x2572c
retq