Moved MulDiv() and VGA routines out of GDI.
This commit is contained in:
parent
ebecf50229
commit
15467bfb1f
|
@ -1867,6 +1867,59 @@ time_t DOSFS_FileTimeToUnixTime( const FILETIME *filetime, DWORD *remainder )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MulDiv (KERNEL32.391)
|
||||
* RETURNS
|
||||
* Result of multiplication and division
|
||||
* -1: Overflow occurred or Divisor was 0
|
||||
*/
|
||||
INT WINAPI MulDiv(
|
||||
INT nMultiplicand,
|
||||
INT nMultiplier,
|
||||
INT nDivisor)
|
||||
{
|
||||
#if SIZEOF_LONG_LONG >= 8
|
||||
long long ret;
|
||||
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
else
|
||||
ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
if ((ret > 2147483647) || (ret < -2147483647)) return -1;
|
||||
return ret;
|
||||
#else
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
|
||||
return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DosDateTimeToFileTime (KERNEL32.76)
|
||||
*/
|
||||
|
|
|
@ -15,8 +15,7 @@ C_SRCS = \
|
|||
fontengine.c \
|
||||
mapping.c \
|
||||
painting.c \
|
||||
path.c \
|
||||
vga.c
|
||||
path.c
|
||||
|
||||
all: $(MODULE).o
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ C_SRCS = \
|
|||
int5c.c \
|
||||
interrupts.c \
|
||||
ioports.c \
|
||||
vga.c \
|
||||
vxd.c
|
||||
|
||||
all: $(MODULE).o
|
||||
|
|
|
@ -1118,57 +1118,6 @@ INT16 WINAPI MulDiv16(
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* MulDiv (KERNEL32.391)
|
||||
* RETURNS
|
||||
* Result of multiplication and division
|
||||
* -1: Overflow occurred or Divisor was 0
|
||||
*/
|
||||
INT WINAPI MulDiv(
|
||||
INT nMultiplicand,
|
||||
INT nMultiplier,
|
||||
INT nDivisor)
|
||||
{
|
||||
#if SIZEOF_LONG_LONG >= 8
|
||||
long long ret;
|
||||
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
else
|
||||
ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
if ((ret > 2147483647) || (ret < -2147483647)) return -1;
|
||||
return ret;
|
||||
#else
|
||||
if (!nDivisor) return -1;
|
||||
|
||||
/* We want to deal with a positive divisor to simplify the logic. */
|
||||
if (nDivisor < 0)
|
||||
{
|
||||
nMultiplicand = - nMultiplicand;
|
||||
nDivisor = -nDivisor;
|
||||
}
|
||||
|
||||
/* If the result is positive, we "add" to round. else, we subtract to round. */
|
||||
if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
|
||||
( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
|
||||
return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
|
||||
|
||||
return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
|
||||
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************
|
||||
* GetColorAdjustment [GDI32.164]
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue