|
|
1.1 root 1: 1.1.1.3 ! root 2: /**************************************************************************** ! 3: Microsoft RPC Version 1.0 ! 4: Copyright Microsoft Corp. 1992 ! 5: mandel Example ! 6: ! 7: FILE: calc.c ! 8: ! 9: PURPOSE: Server side of the RPC distributed application Mandel ! 10: ! 11: FUNCTIONS: MandelCalc() - Do the calculations for the Windows ! 12: Mandelbrot Set distributed drawing program. 1.1 root 13: 14: ****************************************************************************/ 15: 1.1.1.3 ! root 16: #include <stdlib.h> ! 17: #include <stdio.h> 1.1 root 18: #include <windows.h> 19: 20: #ifdef RPC 21: #include "mdlrpc.h" 22: #endif 1.1.1.3 ! root 23: #include "mandel.h" ! 24: 1.1 root 25: 1.1.1.3 ! root 26: short calcmand(double, double, short); 1.1 root 27: 1.1.1.3 ! root 28: ! 29: void MandelCalc(PCPOINT pcptLL, ! 30: PLONGRECT prcDraw, ! 31: double precision, ! 32: DWORD ulThreshold, ! 33: LINEBUF * pbBuf) 1.1 root 34: { 1.1.1.3 ! root 35: DWORD h, height, width; 1.1 root 36: double dreal, dimag, dimag2; 1.1.1.3 ! root 37: short maxit = 0; ! 38: short * pbPtr; 1.1 root 39: 1.1.1.3 ! root 40: pbPtr = *pbBuf; // LINEBUF is an array of shorts 1.1 root 41: 42: dreal = pcptLL->real + ((double)prcDraw->xLeft * precision); 43: dimag = pcptLL->imag + ((double)prcDraw->yBottom * precision); 44: 45: maxit = (short) ulThreshold; 46: 47: height = (prcDraw->yTop - prcDraw->yBottom) + 1; 48: width = (prcDraw->xRight - prcDraw->xLeft) + 1; 49: 50: for ( ; width > 0; --width, dreal += precision) { 1.1.1.3 ! root 51: for (dimag2 = dimag, h = height; h > 0; --h, dimag2 += precision) { ! 52: if ((dreal > 4.0) || (dreal < -4.0) || ! 53: (dimag2 > 4.0) || (dimag2 < -4.0)) ! 54: *(pbPtr++) = 0; ! 55: else ! 56: *(pbPtr++) = calcmand(dreal, dimag2, maxit); ! 57: } 1.1 root 58: } 59: } 60: 61: 62: /* C version of the assembly language program */ 1.1.1.3 ! root 63: short calcmand(double dreal, ! 64: double dimag, ! 65: short maxit) 1.1 root 66: { 1.1.1.3 ! root 67: double x, y, xsq, ysq; ! 68: short k; 1.1 root 69: 1.1.1.3 ! root 70: k = maxit; 1.1 root 71: x = dreal; 72: y = dimag; 73: 74: while (1) { 75: xsq = x * x; 76: ysq = y * y; 77: y = 2.0 * x * y + dimag; 78: x = (xsq - ysq) + dreal; 79: if (--k == 0) 80: return((short) (maxit - k)); 81: if ((xsq + ysq) > 4.0) 82: return((short) (maxit - k)); 83: } 84: } 1.1.1.3 ! root 85:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.