--- mstools/samples/rpc/mandel/calc.c 2018/08/09 18:20:01 1.1 +++ mstools/samples/rpc/mandel/calc.c 2018/08/09 18:24:15 1.1.1.3 @@ -1,43 +1,43 @@ -/**************************************************************************** - - CALC.C -- - - Code to do the calculations for the Windows Mandelbrot Set distributed - drawing program. - Copyright (C) 1990 Microsoft Corporation. - - This code sample is provided for demonstration purposes only. - Microsoft makes no warranty, either express or implied, - as to its usability in any given situation. +/**************************************************************************** + Microsoft RPC Version 1.0 + Copyright Microsoft Corp. 1992 + mandel Example + + FILE: calc.c + + PURPOSE: Server side of the RPC distributed application Mandel + + FUNCTIONS: MandelCalc() - Do the calculations for the Windows + Mandelbrot Set distributed drawing program. ****************************************************************************/ +#include +#include #include -#include // malloc, free -#include #ifdef RPC -#include #include "mdlrpc.h" #endif +#include "mandel.h" -#include "mandel.h" -void MandelCalc(PCPOINT pcptLL, - PLONGRECT prcDraw, - double precision, - DWORD ulThreshold, - PLINEBUF pbBuf) +short calcmand(double, double, short); + + +void MandelCalc(PCPOINT pcptLL, + PLONGRECT prcDraw, + double precision, + DWORD ulThreshold, + LINEBUF * pbBuf) { - DWORD h, height; - DWORD width; - PWORD pbPtr; + DWORD h, height, width; double dreal, dimag, dimag2; - short maxit = 0; + short maxit = 0; + short * pbPtr; - pbPtr = (PWORD) pbBuf; // PLINEBUF points to the struct LINEBUF; - // LINEBUF is an array of WORDS + pbPtr = *pbBuf; // LINEBUF is an array of shorts dreal = pcptLL->real + ((double)prcDraw->xLeft * precision); dimag = pcptLL->imag + ((double)prcDraw->yBottom * precision); @@ -48,43 +48,26 @@ void MandelCalc(PCPOINT pcptLL, width = (prcDraw->xRight - prcDraw->xLeft) + 1; for ( ; width > 0; --width, dreal += precision) { - for (dimag2 = dimag, h = height; h > 0; --h, dimag2 += precision) - { - if ((dreal > 4.0) || (dreal < -4.0) || - (dimag2 > 4.0) || (dimag2 < -4.0)) - *(pbPtr++) = 0L; - else - *(pbPtr++) = (WORD) (calcmand(dreal, dimag2, maxit)); - } + for (dimag2 = dimag, h = height; h > 0; --h, dimag2 += precision) { + if ((dreal > 4.0) || (dreal < -4.0) || + (dimag2 > 4.0) || (dimag2 < -4.0)) + *(pbPtr++) = 0; + else + *(pbPtr++) = calcmand(dreal, dimag2, maxit); + } } - return; } -// midl requires these functions -// ==================================================================== -// MIDL allocate and free -// ==================================================================== - - -void * MIDL_user_allocate(unsigned long len) -{ - return(PDWORD) (LocalLock(LocalAlloc(LMEM_MOVEABLE, len))); -} - -void MIDL_user_free(void * ptr) -{ - LocalFree(ptr); -} - /* C version of the assembly language program */ - -short calcmand(double dreal, double dimag, short maxit) +short calcmand(double dreal, + double dimag, + short maxit) { -double x, y, xsq, ysq; -short k; + double x, y, xsq, ysq; + short k; - k = (short) maxit; + k = maxit; x = dreal; y = dimag; @@ -99,3 +82,4 @@ short k; return((short) (maxit - k)); } } +