From 15467bfb1ffe7a9fa286e40d689a7dd3889cb7f3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 1 Aug 2000 22:03:18 +0000 Subject: [PATCH] Moved MulDiv() and VGA routines out of GDI. --- files/dos_fs.c | 53 +++++++++++++++++++++++++++++++++++++++ graphics/Makefile.in | 3 +-- msdos/Makefile.in | 1 + {graphics => msdos}/vga.c | 0 objects/gdiobj.c | 51 ------------------------------------- 5 files changed, 55 insertions(+), 53 deletions(-) rename {graphics => msdos}/vga.c (100%) diff --git a/files/dos_fs.c b/files/dos_fs.c index dec37faff88..0c4782d1a68 100644 --- a/files/dos_fs.c +++ b/files/dos_fs.c @@ -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) */ diff --git a/graphics/Makefile.in b/graphics/Makefile.in index b9cd3d8d4e2..0c9a9dc91f2 100644 --- a/graphics/Makefile.in +++ b/graphics/Makefile.in @@ -15,8 +15,7 @@ C_SRCS = \ fontengine.c \ mapping.c \ painting.c \ - path.c \ - vga.c + path.c all: $(MODULE).o diff --git a/msdos/Makefile.in b/msdos/Makefile.in index e1a2a0f8894..96567bcdb31 100644 --- a/msdos/Makefile.in +++ b/msdos/Makefile.in @@ -36,6 +36,7 @@ C_SRCS = \ int5c.c \ interrupts.c \ ioports.c \ + vga.c \ vxd.c all: $(MODULE).o diff --git a/graphics/vga.c b/msdos/vga.c similarity index 100% rename from graphics/vga.c rename to msdos/vga.c diff --git a/objects/gdiobj.c b/objects/gdiobj.c index a711a93b08c..b08f395f263 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -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] *