⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winfract.c

📁 frasr200的win 版本源码(18.21),使用make文件,使用的vc版本较低,在我的环境下编译有问题! 很不错的分形程序代码!
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************


    PROGRAM: winfract.c

    PURPOSE: Windows-specific main-driver code for Fractint for Windows
             (look in MAINFRAC.C for the non-windows-specific code)

    Copyright (C) 1990-1993 The Stone Soup Group.  Fractint for Windows 
    may be freely copied and distributed, but may not be sold.
    
    We are, of course, copyrighting the code we wrote to implement
    Fractint-for-Windows, and not the routines we lifted directly
    or indirectly from Microsoft's Windows 3.0 Software Development Kit.

****************************************************************************/

#include "windows.h"
#include "winfract.h"
#include "mathtool.h"
#include "fractype.h"
#include "fractint.h"
#include "select.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <search.h>
#include <string.h>
#include <time.h>
#include "profile.h"

unsigned int windows_version;		/* 0x0300 = Win 3.0, 0x030A = 3.1 */

extern LPSTR win_lpCmdLine;

HANDLE hInst;

HANDLE hAccTable;                        /* handle to accelerator table */
extern BOOL ZoomBarOpen;
int ZoomMode;

HWND hMainWnd, hwnd;                     /* handle to main window */
HWND hWndCopy;				 /* Copy of hWnd */

char far winfract_title_text[41];	/* Winfract title-bar text */

#define PALETTESIZE 256               /* dull-normal VGA                    */
HANDLE hpal;                          /* palette handle                     */
PAINTSTRUCT ps;                       /* paint structure                    */
HDC hDC;                              /* handle to device context           */
HDC hMemoryDC;                        /* handle to memory device context    */
BITMAP Bitmap;                        /* bitmap structure                   */
extern time_t last_time;
unsigned IconWidth, IconHeight, IconSize;
HANDLE hIconBitmap;

HANDLE  hPal;          /* Handle to the application's logical palette  */
HANDLE  hLogPal;       /* Temporary Handle */
LPLOGPALETTE pLogPal;  /* pointer to tha application's logical palette */
int     iNumColors;    /* Number of colors supported by device	       */
int     iRasterCaps;   /* Raster capabilities			               */
int     iPalSize;      /* Size of Physical palette		               */

BOOL	win_systempaletteused = FALSE;	/* flag system palette set */
extern int win_syscolorindex[21];
extern DWORD win_syscolorold[21];
extern DWORD win_syscolornew[21];

/* MCP 6-16-91 */
extern int pixelshift_per_byte;
extern long pixels_per_bytem1;        /* pixels / byte - 1 (for ANDing) */
extern unsigned char win_andmask[8];
extern unsigned char win_notmask[8];
extern unsigned char win_bitshift[8];

extern int CoordBoxOpen;
extern HWND hCoordBox;
extern int TrackingZoom, Zooming, ReSizing;

#define EXE_NAME_MAX_SIZE  128

BOOL       bHelp = FALSE;      /* Help mode flag; TRUE = "ON"*/
HCURSOR    hHelpCursor;        /* Cursor displayed when in help mode*/
char       szHelpFileName[EXE_NAME_MAX_SIZE+1];    /* Help file name*/

extern int stopmsg(int ,CHAR far *);

void MakeHelpPathName(char*);  /* Function deriving help file path */

unsigned char far win_dacbox[256][3];
extern unsigned char dacbox[256][3], olddacbox[256][3];
extern int colorpreloaded;
extern int  colorstate;

int win_fastupdate;                   /* 0 for "normal" fast screen updates */
extern int show_orbit;

int max_colors;

BOOL bTrack = FALSE;                  /* TRUE if user is selecting a region */
BOOL bMove  = FALSE;
BOOL bMoving = FALSE;
BOOL zoomflag = FALSE;                /* TRUE if a zoom-box selected */
extern POINT DragPoint;
RECT Rect;

int Shape = SL_ZOOM;            /* shape to use for the selection rectangle */

/* pointers to various dialog-box routines */
FARPROC lpProcAbout;
FARPROC lpSelectFractal;
FARPROC lpSelectFracParams;
FARPROC lpSelectImage;
FARPROC lpSelectDoodads;
FARPROC lpSelectExtended;
FARPROC lpSelectSavePar;
FARPROC lpSelectCycle;
FARPROC lpProcStatus;
FARPROC lpSelect3D;
FARPROC lpSelect3DPlanar;
FARPROC lpSelect3DSpherical;
FARPROC lpSelectIFS3D;
FARPROC lpSelectFunnyGlasses;
FARPROC lpSelectLightSource;
FARPROC lpSelectStarfield;

extern int FileFormat;
extern unsigned char readname[];
extern unsigned char FormFileName[];
extern unsigned char DefPath[];
extern unsigned char LFileName[];
extern unsigned char LName[];
extern char far StatusTitle[];
unsigned char far DialogTitle[128];
unsigned char FileName[128];
unsigned char FullPathName[128];
unsigned char DefSpec[13];
unsigned char DefExt[10];

HBITMAP hBitmap, oldBitmap, oldoldbitmap;              /* working bitmaps */

HANDLE hDibInfo;		/* handle to the Device-independent bitmap */
LPBITMAPINFO pDibInfo;		/* pointer to the DIB info */
HANDLE hpixels;			/* handle to the DIB pixels */
unsigned char huge *pixels;	/* the device-independent bitmap  pixels */
extern int bytes_per_pixelline;	/* pixels/line / pixels/byte */
extern long win_bitmapsize;     /* size of the DIB in bytes */
extern	int	resave_flag;	/* resaving after a timed save */
extern	char overwrite; 	/* overwrite on/off */

HANDLE hClipboard1, hClipboard2, hClipboard3; /* handles to clipboard info */
LPSTR lpClipboard1, lpClipboard2;            /* pointers to clipboard info */

int last_written_y = -2;        /* last line written */
int screen_to_be_cleared = 1;	/* flag that the screen is to be cleared */
int time_to_act = 0;		/* time to take some sort of action? */
int time_to_restart = 0;        /* time to restart?  */
int time_to_reinit = 0;         /* time to reinitialize?  */
int time_to_resume = 0;		/* time to resume? */
int time_to_quit = 0;           /* time to quit? */
int time_to_save = 0;		/* time to save the file? */
int time_to_print = 0;		/* time to print the file? */
int time_to_load = 0;		/* time to load a new file? */
int time_to_cycle = 0;          /* time to begin color-cycling? */
int time_to_starfield = 0;      /* time to make a starfield? */
int time_to_orbit = 0;          /* time to activate orbits? */

int win_3dspherical = 0;          /* spherical 3D? */
int win_display3d, win_overlay3d; /* 3D flags */
extern	int	init3d[20];	/* '3d=nn/nn/nn/...' values */
extern	int RAY;

extern int win_cycledir, win_cyclerand, win_cycledelay;

extern int calc_status;
extern int julibrot;

int xdots, ydots, colors, maxiter;
int ytop, ybottom, xleft, xright;
int xposition, yposition, win_xoffset, win_yoffset, xpagesize, ypagesize;
int win_xdots, win_ydots;
extern int fractype;
extern double param[4];
extern double xxmin, xxmax, yymin, yymax, xx3rd, yy3rd;
double jxxmin, jxxmax, jyymin, jyymax, jxx3rd, jyy3rd;
extern int frommandel, bitshift, biomorph;
extern int maxit;

int cpu, fpu;			/* cpu, fpu flags */

extern int win_release;

char *win_choices[100];
int win_numchoices, win_choicemade;

extern int onthelist[];
extern int CountFractalList;
extern int CurrentFractal;
int MaxFormNameChoices = 80;
char FormNameChoices[80][25];
extern char FormName[30];
extern char	IFSFileName[];    /* IFS code file */
extern char	IFSName[];        /* IFS code item */
double far *temp_array;
HANDLE htemp_array;

HANDLE hSaveCursor;             /* the original cursor value */
HANDLE hHourGlass;              /* the hourglass cursor value */

BOOL winfract_menustyle = FALSE;/* Menu style:
				   FALSE = Winfract-style,
				   TRUE  = Fractint-style */

/* far strings (near space is precious) */
char far winfract_msg01[] = "Fractint For Windows";
char far winfract_msg02[] = "WinFracMenu";
char far winfract_msg03[] = "FractintForWindowsV0010";
char far winfract_msg04[] = "WinfractAcc";
char far winfract_msg96[] = "I'm sorry, but color-cycling \nrequires a palette-based\nvideo driver";
char far winfract_msg97[] = "There isn't enough available\nmemory to run Winfract";
char far winfract_msg98[] =  "This program requires Standard\nor 386-Enhanced Mode";
char far winfract_msg99[] = "Not Enough Free Memory to Copy to the Clipboard";


int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
HANDLE hInstance;
HANDLE hPrevInstance;
LPSTR lpCmdLine;
int nCmdShow;
{
    win_lpCmdLine = lpCmdLine;

    if (!hPrevInstance)
        if (!InitApplication(hInstance))
            return (FALSE);

    if (!InitInstance(hInstance, nCmdShow))
        return (FALSE);

    fractint_main();            /* fire up the main Fractint code */
    if(htemp_array) {
        GlobalUnlock(htemp_array);
        GlobalFree(htemp_array);
    }
    
    wintext_destroy();		/* destroy the text window */

    DestroyWindow(hWndCopy);    /* stop everything when it returns */

    return(0);                  /* we done when 'fractint_main' returns */
}


BOOL InitApplication(hInstance)
HANDLE hInstance;
{
    WNDCLASS  wc;

    wc.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
    wc.lpfnWndProc = MainWndProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = NULL;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = GetStockObject(BLACK_BRUSH);
    wc.lpszMenuName =  winfract_msg02;
    wc.lpszClassName = winfract_msg03;

    return(RegisterClass(&wc) && RegisterMathWindows(hInstance));
}


BOOL InitInstance(hInstance, nCmdShow)
    HANDLE          hInstance;
    int             nCmdShow;
{
    DWORD WinFlags;
    unsigned int version, i;
    int iLoop, jLoop;
    DWORD ThisColor;

    float temp;

    /* so, what kind of a computer are we on, anyway? */
    WinFlags = GetWinFlags();
    cpu = 88;                             /* determine the CPU type */
    if (WinFlags & WF_CPU186) cpu = 186;
    if (WinFlags & WF_CPU286) cpu = 286;
    if (WinFlags & WF_CPU386) cpu = 386;
    if (WinFlags & WF_CPU486) cpu = 386;
    fpu = 0;                              /* determine the FPU type */
    if (WinFlags & WF_80x87)  fpu = 87;
    if (fpu && (cpu == 386))  fpu = 387;

    version = LOWORD(GetVersion());	/* which version of Windows is it? */
    windows_version = ((LOBYTE(version) << 8) | HIBYTE(version));

    hInst = hInstance;

    hAccTable = LoadAccelerators(hInst, winfract_msg04);

    win_set_title_text();

    hMainWnd = hwnd = CreateWindow(
        winfract_msg03,
        winfract_title_text,
        WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
        140, 100,  /* initial locn instead of CW_USEDEFAULT, CW_USEDEFAULT, */
        360, 280,  /* initial size instead of CW_USEDEFAULT, CW_USEDEFAULT, */
        NULL,
        NULL,
        hInstance,
        NULL
    );

    if (!hwnd) {  /* ?? can't create the initial window! */
        return (FALSE);
        }

    wintext_initialize(
        (HANDLE) hInstance,
        (HWND) hwnd,
        (LPSTR) winfract_title_text);

    /* This program doesn't run in "real" mode, so shut down right
       now to keep from mucking up Windows */
    if (!((WinFlags & WF_STANDARD) || (WinFlags & WF_ENHANCED))) {
        MessageBox (
            GetFocus(),
            winfract_msg98,
            winfract_msg01,
            MB_ICONSTOP | MB_OK);
        return(FALSE);
        }
    
    win_xdots = xdots;
    win_ydots = ydots;
    maxiter = 150;                   /* and a few iterations */
    xposition = yposition = 0;       /* dummy up a few pointers */
    xpagesize = ypagesize = 2000;
    set_win_offset();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -