Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Multidevice ASIO output plugin for WinAMP

, 13 Feb 2009 CDDL
A tiny WinAMP output DLL that uses a C++ replacement of the official ASIO SDK that supports multiple ASIO devices.
// math.cpp

// math functions

// 08/20/05 (mv)

#include "libct.h"

#include <cassert>
#include <windows.h>

BEGIN_EXTERN_C

static int lastrand;
int _fltused = 0;

#pragma function(abs)
int abs(int n)
{
	return (n>0)?n:-n;
}

ldiv_t ldiv ( long const numer, long const denom )
{
    assert( ( denom != 0 ) && "Divide by zero!" );

    ldiv_t result;

    result.quot = numer / denom;
    result.rem  = numer % denom;

    return result;
}


void srand(unsigned int seed)
{
	lastrand = seed;
}

int rand()
{
	return (((lastrand = lastrand * 214013L + 2531011L) >> 16) & 0x7FFF);
}

#pragma warning(push)
#pragma warning(disable: 4725)  // Instruction may be inaccurate on some Pentiums.
__declspec(naked) void _CIacos()
{
	__asm
	{
		fld		st(0)
		fld		st(0)
		fmul
		fld1
		fsubr
		fsqrt
		fxch
		fpatan
		ret
	}
}
#pragma warning(pop)

__declspec(naked) void _ftol2()
{
	__asm
	{
		push        ebp
		mov         ebp,esp
		sub         esp,20h
		and         esp,0FFFFFFF0h
		fld         st(0)
		fst         dword ptr [esp+18h]
		fistp       qword ptr [esp+10h]
		fild        qword ptr [esp+10h]
		mov         edx,dword ptr [esp+18h]
		mov         eax,dword ptr [esp+10h]
		test        eax,eax
		je          integer_QnaN_or_zero
	arg_is_not_integer_QnaN:
		fsubp       st(1),st
		test        edx,edx
		jns         positive
		fstp        dword ptr [esp]
		mov         ecx,dword ptr [esp]
		xor         ecx,80000000h
		add         ecx,7FFFFFFFh
		adc         eax,0
		mov         edx,dword ptr [esp+14h]
		adc         edx,0
		jmp         localexit
	positive:
		fstp        dword ptr [esp]
		mov         ecx,dword ptr [esp]
		add         ecx,7FFFFFFFh
		sbb         eax,0
		mov         edx,dword ptr [esp+14h]
		sbb         edx,0
		jmp         localexit
	integer_QnaN_or_zero:
		mov         edx,dword ptr [esp+14h]
		test        edx,7FFFFFFFh
		jne         arg_is_not_integer_QnaN
		fstp        dword ptr [esp+18h]
		fstp        dword ptr [esp+18h]
	localexit:
  		leave
  		ret
	}
}

END_EXTERN_C

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

Domagoj Šarić
Software Developer Little Endian Ltd.
Croatia Croatia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 13 Feb 2009
Article Copyright 2009 by Domagoj Šarić
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid