home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inside Multimedia 1995 July
/
IMM0795.ISO
/
share
/
os2
/
pmfract
/
src
/
pmfrsrc.doc
< prev
next >
Wrap
Text File
|
1994-01-24
|
8KB
|
155 lines
FRACTINT for OS/2 Presentation Manager
Description of the source code for version 2.0.
The source code for Fractint for Presentation Manager is freely available.
Enhancements to it are appreciated. If you want to add something to
Fractint for PM and join the Stone Soup Group, please do! To submit changes,
see "Contacting the Authors" in Fractint's online help.
Some parts of the source are from the public domain and are not
copyrighted.
Some parts of the source bear explicit copyright notices from the
author and are subject to the conditions listed there by the author.
The remainder of the source (not already public domain, no explicit
author's copyright notice) is copyrighted by the Stone Soup Group
(a loosely associated and ever-growing group of fanatic programmers).
The source code may be copied freely and may be used in other programs
under the following conditions:
It may not be used in a commercial program which produces fractal images.
Please credit the author (in general, credit Fractint and the Stone Soup
Group) as the source of the code.
I assume you have previously gotten the FRACTINT-for-DOS source code
(FRASRC.ZIP) from whereever you get it (usually CompuServe COMART forum)
and have read the documentation of how the fractal calculation engine works
and how it is structured. Here I will describe the code I added to form the
Presentation Manager user interface and drivers to connect the fractal
calculation engine to Presentation Manager.
I assume you are somewhat familiar with the structure of a Presentation
Manager program, and have a feel for window events, the PM API for window
events, and threads and semaphores and such in OS/2. If not, I am afraid
that this program will not make that good an introductory tutorial. The
books "Programming the OS/2 Presentation Manager" by Charles Petzold, and
"Advanced OS/2 Programming" by Ray Duncan provide excellent background
material.
To ensure responsiveness to mouse and keyboard actions, and to allow
PMFRACT to be calculating a fractal in the background while I am working
on something else, the fractal calculation engine runs as a background
thread while the foreground thread interfaces with Presentation Manager,
handling window events and doing the actual drawing on the window.
The two threads interlock through several semaphores, flag bytes, and other
common variables. All of the shared fields are in a structure called the
CALCPARM (defined in PMFRACT.H) which is defined only once as the global
variable "cp". Besides doing the fractal calculations, the background
thread performs .GIF and .BMP file loading and saving, and all printing.
The background thread can also signal to the foreground thread that it
wants attention by posting a PM user message to the foreground window.
The code has been structured so that the functions to handle a given event
or group of like events are together, along with subfunctions used by
those functions. The idea was that like code would then be loaded as a
single segment, and could then be discarded after the event in question
passed. This lessens somewhat the amount of real menory needed to run this
program. It should be noted that the graphic data (bitmaps for both PM and
me) takes up a lot of room!
All code new for PMFRACT begins with PMFR-. Modules not mentioned here are
straight from FRACTINT for DOS. Details of the inner workings of modules
and functions is spread out through the code as comments. Here is a
high-level index to the Presentation Manager-specific modules:
PMFRACT.C The main module. Main message loop and main window proc.
Also the routines that handle non-user generated window
events and routines to communicate with the background
thread.
PMFRINIT.C Initialization code. Runs at startup and then discarded.
PMFRTHRD.C Main module for the background thread. Waits on a semaphore
until the main thread gives it something to do, then calls
the appropriate Calc, Load, Save, or Print routine.
PMFRUSER.C Main user interface module. The main function in this
module is called from the main window proc to handle events
generated by mouse movements or keyboard events, or poking
at the main menu. Subroutines here or in PMFRDLG1 or
PMFRDLG2 then act on the event.
PMFRDLG1.C Functions supporting PM dialog boxes that process
parameters for the calculation engine.
PMFRDLG2.C Functions supporting PM dialog boxes that process other
activities, such as Load, Save, or Print.
PMFRCALC.C The main module that drives the FRACTINT calculation engine.
This is basically a hacked-up FRACTINT.C from FRACTINT for
DOS. Also contains the code that sends pixels back to
Presentation Manager (putcolor and getcolor). The pixels
are eventually displayed by the main thread from the function
PMfrPaint in PMFRACT.C. This module also contains
many dummy functions to tie off loose FRACTINT function
references.
PMFRLOAD.C Module called to do reading of .GIF or .BMP files, or
to pull a bitmap off the PM Clipboard.
PMFRSAVE.C Module called to do saving of .GIF or .BMP files, or
to put a bitmap on the PM Clipboard.
PMFRPRNT.C Module called to do printing of the currently displayed
fractal. Either prints using the Presentation Manager
printer driver, or prints directly to a HP PaintJet.
There is currently no HP PaintJet driver, so I stole the
code from FRACTINT for DOS.
PMFRDATA.ASM Assembler module containing the built-in display palettes.
PMGENERL.ASM Other assembler subroutines (hacked out of GENERAL.ASM
from FRACTINT for DOS).
SMPL*.* The files pertaining to the Simple Help subroutines.
FILE.C, TOOL.C, etc. Files from the Microsoft OS/2 Presentation Manager
Toolkit sample File Open/Save dialog (OPENDLG), modified
slightly by me to center the dialog boxes on the screen.
Other than that, this is straight out of the toolkit.
How to build PMFRACT
I use Microsoft C (currently version 6.00A) as the primary tool.
I also use Microsoft Macro Assembler (MASM) for assembler files.
Most of the work was done with MASM 5.1, but the final build
was done with MASM 6.0, which had just arrived.
There are three MAKE files that have to be built in turn.
OPENDLG.MAK is the make file for the OPENDLG subroutines.
SMPLHELP is the make file for the Simple Help subroutines.
PMFRACT.MAK is the make file for the main Fractint for PM executable.
OPENDLG and SMPLHELP must be constructed first as they create import .LIB
files needed for the final link of PMFRACT.
Also, the different Make files have symbols that can be used to
create either debuging versions (full Codeview symbols) or optimized
running versions (no Codeview symbols).
The make files assume that environment variables PATH, INCLUDE, LIB, TMP,
and etc. have been set as needed for the version of C and MASM you have
and the way you have chosen to install them. I assume that all the
rest of the source is in one subdirectory, which is the current subdirectory
(that is how I work, more or less).
Now, for example, to make debugging versions of everything, just say:
NMAKE /f OPENDLG.MAK
NMAKE /f SMPLHELP
NMAKE /f PMFRACT.MAK
To make the final optimized version, you could say:
NMAKE nd= CC=$(CO) /f OPENDLG.MAK
NMAKE nd= cl=$(co) /f SMPLHELP
NMAKE nd= cl=$(co) cf=$(so) /f PMFRACT.MAK
**** Warning **** Warning **** Warning ****
No Warranties are either Expressed or Implied!
**** Warning **** Warning **** Warning ****
The best way to contact me is to leave me a message in the
COMART forum of CompuServe.
Donald P. Egen
409 Cameron Circle, Apt. 1204
Chattanooga, TN 37402
CIS 73507,3143