home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
PROGRAMM
/
FGL112B.ZIP
/
USER01.DOC
< prev
next >
Wrap
Text File
|
1992-10-05
|
53KB
|
1,156 lines
Fastgraph (tm)
User's Guide
Ted Gruber Software
PO Box 13408
Las Vegas, NV 89112
(702) 735-1980
Copyright (c) 1991,1992 by Ted Gruber Software.
All rights reserved. No part of this publication may be reproduced, stored
in a retrieval system, or transmitted by any means, electronic, mechanical,
photocopying, recording, or otherwise, without express written permission
from Ted Gruber Software. The software described in this publication is
furnished under a license agreement and may be used or copied only in
accordance with the terms of that agreement.
This publication and its associated software are sold without warranties,
either expressed or implied, regarding their merchantability or fitness for
any particular application or purpose. The information in this publication
is subject to change without notice and does not represent a commitment on
the part of Ted Gruber Software. In no event shall Ted Gruber Software be
liable for any loss of profit or any other commercial damage, including but
not limited to special, incidental, consequential, or other damages resulting
from the use of or the inability to use this product, even if Ted Gruber
Software has been notified of the possibility of such damages.
Second Printing, January 1992
Fastgraph version 2.10
Fastgraph/Light version 1.10
DFI is a registered trademark of Diamond Flower Electric Instrument Co., Inc.
Fastgraph and Fastgraph/Light are trademarks of Ted Gruber Software.
Hercules is a trademark of Hercules Computer Technology.
IBM, IBM PC, IBM PC/XT, IBM PC/AT, PS/2, PCjr, and PC-DOS are registered
trademarks of International Business Machines, Inc.
Intel is a registered trademark of Intel Corporation.
Logitech is a trademark of LOGITECH, Inc.
Microsoft, Microsoft Mouse, and MS-DOS are registered trademarks of Microsoft
Corporation.
PC Paintbrush is a registered trademark of ZSoft, Inc.
QuickBASIC and QuickC are trademarks of Microsoft Corporation.
Tandy is a registered trademark of Tandy Corporation.
Turbo C and Turbo Pascal are registered trademarks of Borland International,
Inc.
All other brand and product names mentioned in this publication are
trademarks or registered trademarks of their respective holders.
T a b l e o f C o n t e n t s
Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 1
What is Fastgraph? . . . . . . . . . . . . . . . . . . . . . . . . . 2
Fastgraph/Light . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Prerequisite Knowledge . . . . . . . . . . . . . . . . . . . . . . . 2
Supported Compilers . . . . . . . . . . . . . . . . . . . . . . . . 3
Memory Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Installing Fastgraph . . . . . . . . . . . . . . . . . . . . . . . . 4
Fastgraph Naming Conventions . . . . . . . . . . . . . . . . . . . . 4
Compilation and Linking . . . . . . . . . . . . . . . . . . . . . . 5
Borland C++ . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Microsoft C . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Microsoft FORTRAN . . . . . . . . . . . . . . . . . . . . . . . 9
Microsoft QuickBASIC . . . . . . . . . . . . . . . . . . . . . 10
Microsoft QuickC . . . . . . . . . . . . . . . . . . . . . . . 11
Power C . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Turbo C and Turbo C++ . . . . . . . . . . . . . . . . . . . . . 14
Turbo Pascal . . . . . . . . . . . . . . . . . . . . . . . . . 15
Fastgraph/Light Video Driver . . . . . . . . . . . . . . . . . . . . 16
Chapter 2 PC and PS/2 Video Modes . . . . . . . . . . . . . . . . . . . 17
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Text Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Graphics Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
CGA Graphics Modes . . . . . . . . . . . . . . . . . . . . . . 21
Tandy 1000 and PCjr Graphics Modes . . . . . . . . . . . . . . 22
Hercules Graphics Modes . . . . . . . . . . . . . . . . . . . . 22
EGA Graphics Modes . . . . . . . . . . . . . . . . . . . . . . 23
VGA and MCGA Graphics Modes . . . . . . . . . . . . . . . . . . 24
Chapter 3 Initializing the Video Environment . . . . . . . . . . . . . . 27
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Establishing a Text Mode . . . . . . . . . . . . . . . . . . . . . . 28
43-line and 50-line Text Modes . . . . . . . . . . . . . . . . . . . 31
Establishing a Graphics Mode . . . . . . . . . . . . . . . . . . . . 32
Summary of Video Initialization Routines . . . . . . . . . . . . . . 36
Chapter 4 Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . 39
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Character Space . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Screen Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
World Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Conversion Routines . . . . . . . . . . . . . . . . . . . . . . . . 44
Summary of Coordinate Routines . . . . . . . . . . . . . . . . . . . 44
Chapter 5 The Use of Color . . . . . . . . . . . . . . . . . . . . . . . 47
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Text Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Color Modes . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Monochrome Mode . . . . . . . . . . . . . . . . . . . . . . . . 49
Graphics Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
CGA Color Modes . . . . . . . . . . . . . . . . . . . . . . . . 51
CGA Two-Color Mode . . . . . . . . . . . . . . . . . . . . . . 52
Tandy and PCjr Modes . . . . . . . . . . . . . . . . . . . . . 53
Hercules Mode . . . . . . . . . . . . . . . . . . . . . . . . . 54
iii
Hercules Low-Resolution Mode . . . . . . . . . . . . . . . . . 55
EGA 200-Line Modes . . . . . . . . . . . . . . . . . . . . . . 56
EGA Monochrome Mode . . . . . . . . . . . . . . . . . . . . . . 58
EGA Enhanced Mode . . . . . . . . . . . . . . . . . . . . . . . 59
VGA and MCGA Two-Color Mode . . . . . . . . . . . . . . . . . . 61
VGA 16-Color Mode . . . . . . . . . . . . . . . . . . . . . . . 63
VGA and MCGA 256-Color Modes . . . . . . . . . . . . . . . . . 64
RGB Color Mapping . . . . . . . . . . . . . . . . . . . . . . . . . 68
Defining All Palette Registers . . . . . . . . . . . . . . . . . . . 69
Virtual Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
A Multiple-Mode Example . . . . . . . . . . . . . . . . . . . . . . 71
Summary of Color-Related Routines . . . . . . . . . . . . . . . . . 73
Chapter 6 Graphics Fundamentals . . . . . . . . . . . . . . . . . . . . 75
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Clearing the Screen . . . . . . . . . . . . . . . . . . . . . . . . 76
Clipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
The Graphics Cursor . . . . . . . . . . . . . . . . . . . . . . . . 79
Solid Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Dashed Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Polygons, Circles, and Ellipses . . . . . . . . . . . . . . . . . . 83
Solid Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Unfilled Rectangles . . . . . . . . . . . . . . . . . . . . . . . . 87
Dithered Rectangles . . . . . . . . . . . . . . . . . . . . . . . . 88
Region Fill . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Summary of Fundamental Graphics Routines . . . . . . . . . . . . . . 96
Chapter 7 Character Display Routines . . . . . . . . . . . . . . . . . . 99
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Character Space . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Hardware Characters . . . . . . . . . . . . . . . . . . . . . . . . 101
Conversion Routines . . . . . . . . . . . . . . . . . . . . . . . . 107
Software Characters . . . . . . . . . . . . . . . . . . . . . . . . 108
Bit-Mapped Characters . . . . . . . . . . . . . . . . . . . . . . . 114
Summary of Character Display Routines . . . . . . . . . . . . . . . 114
Chapter 8 Video Page Management . . . . . . . . . . . . . . . . . . . . 117
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Physical Pages and Virtual Pages . . . . . . . . . . . . . . . . . . 118
Pages With Special Meanings . . . . . . . . . . . . . . . . . . . . 119
Some Simple Examples . . . . . . . . . . . . . . . . . . . . . . . . 119
Text Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Obtaining Video Page Information . . . . . . . . . . . . . . . . . . 127
Considerations for Virtual Pages . . . . . . . . . . . . . . . . . . 128
Logical Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Video Page Resizing . . . . . . . . . . . . . . . . . . . . . . . . 131
Summary of Video Page Management Routines . . . . . . . . . . . . . 132
Chapter 9 Images and Image Management . . . . . . . . . . . . . . . . . . 135
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Mode-Independent Bit-Mapped Images . . . . . . . . . . . . . . . . . 136
Mode-Specific Bit-Mapped Images . . . . . . . . . . . . . . . . . . 140
Regular Images . . . . . . . . . . . . . . . . . . . . . . . . 141
Clipped Images . . . . . . . . . . . . . . . . . . . . . . . . 148
Reversed Images . . . . . . . . . . . . . . . . . . . . . . . . 149
iv
Reversed Clipped Images . . . . . . . . . . . . . . . . . . . . 149
Some Examples . . . . . . . . . . . . . . . . . . . . . . . . . 149
Pixel Run Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Display Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . 158
PCX Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Masking Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Retrieving Images . . . . . . . . . . . . . . . . . . . . . . . . . 169
Byte Boundaries . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Image Transfer Routines . . . . . . . . . . . . . . . . . . . . . . 175
Summary of Image Display Routines . . . . . . . . . . . . . . . . . 184
Chapter 10 Animation Techniques . . . . . . . . . . . . . . . . . . . . 187
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Simple Animation . . . . . . . . . . . . . . . . . . . . . . . . . . 188
XOR Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Static Frame Animation . . . . . . . . . . . . . . . . . . . . . . . 192
Dynamic Frame Animation . . . . . . . . . . . . . . . . . . . . . . 194
Page Flipping . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Summary of Animation Techniques . . . . . . . . . . . . . . . . . . 198
Chapter 11 Special Effects . . . . . . . . . . . . . . . . . . . . . . . 199
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Screen Dissolving . . . . . . . . . . . . . . . . . . . . . . . . . 200
Scrolling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Changing the Screen Origin . . . . . . . . . . . . . . . . . . . . . 205
Summary of Special Effects Routines . . . . . . . . . . . . . . . . 208
Chapter 12 Input Device Support . . . . . . . . . . . . . . . . . . . . 209
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Keyboard Support . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Reading Keystrokes . . . . . . . . . . . . . . . . . . . . . . 212
Testing and Setting Key States . . . . . . . . . . . . . . . . 213
Mouse Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Initializing the Mouse . . . . . . . . . . . . . . . . . . . . 215
Controlling the Mouse Cursor . . . . . . . . . . . . . . . . . 216
Reporting the Mouse Status . . . . . . . . . . . . . . . . . . 218
Defining the Mouse Cursor . . . . . . . . . . . . . . . . . . . 220
Joystick Support . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Initializing Joysticks . . . . . . . . . . . . . . . . . . . . 227
Reporting Joystick Status . . . . . . . . . . . . . . . . . . . 227
Keyboard Emulation . . . . . . . . . . . . . . . . . . . . . . 229
Special Joystick Considerations . . . . . . . . . . . . . . . . 230
Summary of Input Routines . . . . . . . . . . . . . . . . . . . . . 231
Chapter 13 Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . 233
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Sound Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Synchronous Sound . . . . . . . . . . . . . . . . . . . . . . . . . 234
Asynchronous Sound . . . . . . . . . . . . . . . . . . . . . . . . . 239
Summary of Sound Routines . . . . . . . . . . . . . . . . . . . . . 244
Chapter 14 Program Timing . . . . . . . . . . . . . . . . . . . . . . . 247
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Real-Time Routines . . . . . . . . . . . . . . . . . . . . . . . . . 248
Routines Dependent on the System Speed . . . . . . . . . . . . . . . 249
Summary of Timing Routines . . . . . . . . . . . . . . . . . . . . . 251
v
Chapter 15 Miscellaneous Routines . . . . . . . . . . . . . . . . . . . 253
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Determining Available Memory . . . . . . . . . . . . . . . . . . . . 254
Choosing the Video Memory Update Function . . . . . . . . . . . . . 255
Summary of Miscellaneous Routines . . . . . . . . . . . . . . . . . 256
Appendix A Fastgraph Utilities . . . . . . . . . . . . . . . . . . . . . 257
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
SNAPSHOT Utility . . . . . . . . . . . . . . . . . . . . . . . . . . 258
CLIP Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
CONVERT Utility . . . . . . . . . . . . . . . . . . . . . . . . . . 261
EDITSPR Utility . . . . . . . . . . . . . . . . . . . . . . . . . . 261
GrabRGB Utility . . . . . . . . . . . . . . . . . . . . . . . . . . 262
HERCFIX Utility . . . . . . . . . . . . . . . . . . . . . . . . . . 263
Appendix B Using Fastgraph from Assembly Language . . . . . . . . . . . 265
Appendix C Interrupts and Fastgraph . . . . . . . . . . . . . . . . . . 269
Interrupts Used by Fastgraph . . . . . . . . . . . . . . . . . . . . 270
Extending the Time-of-Day Interrupt . . . . . . . . . . . . . . . . 270
Appendix D Contents of the Compiler-Specific Libraries . . . . . . . . . 277
vi
Chapter 1
Introduction
2 Fastgraph User's Guide
What is Fastgraph?
Fastgraph is a library of more than 170 highly-optimized routines that
are callable from high-level and assembly language programs running under the
MS-DOS or PC-DOS operating systems. This collection of routines provides a
programmer with proven, powerful tools to take command of the PC and PS/2
video environment. In addition to its video support, Fastgraph also contains
routines to perform keyboard, mouse, and joystick control, as well as music
and sound capabilities. Fastgraph is an ideal development tool for
entertainment and educational software, presentation graphics products,
scientific and engineering applications, CAD/CAM, animation, or any
application that demands robust graphics.
As its name implies, the most notable feature of Fastgraph is its speed.
Virtually all of Fastgraph is written in 8086 assembly language, and each
routine has been optimized by hand to provide maximum performance.
Fastgraph supports all the standard text and graphics video modes used
by the IBM PC (PC, PC/XT, and PC/AT) and PS/2 families and compatible
systems. In addition, Fastgraph provides support for four extended VGA
graphics modes and a 16-color graphics mode unique to Tandy 1000 series
computers and the PCjr. Even though the graphics mode of the Hercules
Graphics Card is not an IBM standard, its popularity has made it a de facto
standard, and for this reason Fastgraph also supports it. A complete
discussion of all of Fastgraph's supported video modes appears in the next
chapter.
Fastgraph/Light
Fastgraph/Light is a subset of Fastgraph. It includes all of
Fastgraph's features except the redefinable world space coordinate system and
the routines pertaining to software characters. Programs created using
Fastgraph/Light are 100% source code compatible with Fastgraph.
The most important difference between Fastgraph/Light and Fastgraph is
the method of running a program created with the two products. With
Fastgraph, any of its routines used in your program are linked directly into
the resulting .EXE file. With Fastgraph/Light, however, this is not the
case. Instead, the Fastgraph/Light routines provide an interface to an
external driver, called the Fastgraph/Light Video Driver, which must be
loaded separately before running programs that call any Fastgraph/Light
routines. A further discussion of this driver begins on page 16.
In this document, and in the accompanying Fastgraph Reference Manual,
references to Fastgraph also apply to Fastgraph/Light unless stated
otherwise.
Prerequisite Knowledge
Fastgraph is a programming tool, which means programmers are its
intended audience. For this reason, the Fastgraph User's Guide and the
accompanying Fastgraph Reference Manual assume you have a knowledge of
programming. Additionally, a knowledge of converting numbers between binary,
decimal, and hexadecimal is assumed.
Chapter 1: Introduction 3
Virtually all the examples in this manual are written in the C
programming language, so a knowledge of C would be especially helpful. The
examples intentionally avoid using any of C's features and idioms that might
not be readily apparent to a programmer unfamiliar with C. Finally, we'd
like to point out that the examples are intended to be read not by
themselves, but as part of the surrounding text.
Supported Compilers
You can use Fastgraph with any compilers or assemblers that use the same
calling and naming conventions as the small, medium, or large memory models
of the supported compilers. Mixed language programming is allowed where
supported by the language translators and linker being used. Fastgraph
supports the following compilers:
Borland C++ (version 2.0 or later)
Microsoft C (version 5.0 or later)
Microsoft FORTRAN (version 4.0 or later)
Microsoft QuickBASIC (version 4.0 or later)
Microsoft QuickC (version 2.0 or later)
Power C (version 2.0 or later)
Turbo C or Turbo C++ (version 2.0 or later)
Turbo Pascal (version 6.0 or later)
The listed version numbers are the compiler versions under which Fastgraph
was developed and tested. Fastgraph may or may not work with earlier
versions of these compilers. The use of Fastgraph from assembly language
programs is addressed in Appendix B.
Memory Models
All of Fastgraph's supported compilers except QuickBASIC and Turbo
Pascal offer several memory models. A memory model defines how memory is set
up for a program's code and data segments. Fastgraph includes libraries for
the small, medium, and large memory models.
The small memory model allows for one code segment and one data segment.
Programs that use the small model can thus have a maximum of 64K bytes of
code and 64K bytes of data. Because the small model implements call
instructions and data references through near pointers, it produces the most
efficient code of the three supported memory models.
The medium memory model allows for multiple code segments and one data
segment. Programs that use the medium model thus have no compiler-imposed
limit to the code size (although no one segment can exceed 64K bytes) and a
maximum of 64K bytes of data. Like the small model, the medium model
implements data references through near pointers, but it implements call
instructions through far pointers. The use of far pointers adds two bytes of
code and 13 clock cycles for each subprogram call. The medium model is a
popular choice among programmers.
The large memory model supports multiple code and data segments.
Programs that use the large model do not have any compiler-imposed limits for
code and data sizes. However, no single code or data segment can exceed 64K
bytes. Because the large model implements call instructions and data
4 Fastgraph User's Guide
references through far pointers, it produces the least efficient code of the
three supported memory models.
For more information about memory models, please refer to the user's
guide or reference manual for the compilers you'll be using with Fastgraph.
Installing Fastgraph
This section explains how to use the INSTALL program to load Fastgraph
(or Fastgraph/Light) and its related files on a hard disk. The installation
program lets you select the compilers and memory models you wish to use with
Fastgraph. It also gives you the opportunity to load many example Fastgraph
programs specific to the compilers you choose.
Before you start the installation, you should use the DOS commands COPY
or DISKCOPY to make working copies of the Fastgraph distribution disks (refer
to your DOS reference manual if you are unfamiliar with these commands).
Once you have created the working copies, store the original disks in a safe
place. Install Fastgraph from the working copies you just created.
For simplicity, we'll assume you are installing Fastgraph from the
diskette drive A: to the hard drive C:, but you can of course use any
available drives. The Fastgraph distribution disk labeled Installation and
Utilities contains Fastgraph's INSTALL program. Place this disk in the A:
drive, make A: your current drive, and enter the command INSTALL, as shown
below.
C> A:
A> INSTALL
From this point, just follow the directions on each screen. At any time, you
can press the Esc key to abort the installation.
The INSTALL program will ask you for the compilers and memory models
you'll use with Fastgraph, as well as the directory names for the Fastgraph
utilities, libraries, and include files. For the utilities, the default
directory is C:\FG. For the include files and libraries, we recommend using
directories where the compiler you've chosen normally searches for such
files. INSTALL will automatically try to determine these directories and
propose them as defaults.
You can install support for additional compilers or memory models at any
time. If you choose to do this, you should use the command INSTALL /L to
avoid copying the files common to all compilers and memory models.
Fastgraph Naming Conventions
The names of all Fastgraph routines begin with the three characters
"fg_". This prefix helps identify Fastgraph routines within a program, and
it also reduces the chance of name conflicts that might otherwise occur
between Fastgraph and other third party libraries.
Because QuickBASIC does not permit underscores in identifiers, the
QuickBASIC versions of Fastgraph routines begin with the two characters "FG".
Chapter 1: Introduction 5
For example, the fg_version routine is named FGversion in the QuickBASIC
libraries. All subsequent references to Fastgraph routines in this manual
and the accompanying Fastgraph Reference Manual will use the fg_ naming
convention instead of the QuickBASIC names.
Compilation and Linking
To build an executable (.EXE) file for a program that uses Fastgraph
routines, first compile or assemble the program using the small, medium, or
large memory model. This step produces an object file, which is then linked
with Fastgraph and any other object libraries to produce an executable file.
Examples 1-1 through 1-4 use the Fastgraph routine fg_version to display
the version number for your copy of Fastgraph. These examples are
respectively written in the four high-level languages Fastgraph supports:
C/C++, BASIC, FORTRAN, and Pascal. If you loaded the example programs when
you installed Fastgraph, the files \FG\EXAMPLES\01-01.C, 01-02.BAS,
01-03.FOR, and 01-04.PAS contain the source code for these examples. You can
use them to test the compilation and linking process for the memory models
and compilers you'll be using with Fastgraph.
Example 1-1.
#include <fastgraf.h>
#include <stdio.h>
void main(void);
void main()
{
int major;
int minor;
fg_version(&major,&minor);
printf("This is version %d.%2.2d of Fastgraph.\n",major,minor);
}
The file FASTGRAF.H contains the C function prototypes for each
Fastgraph routine. It should reside in a directory where the compiler
normally searches for other .H files. For Microsoft C and QuickC, FASTGRAF.H
can reside in any of the directories specified by the INCLUDE environment
variable. For Power C, it can reside in any of the directories specified by
the /i switch in the PCOPTION environment variable.
Example 1-2.
REM $INCLUDE: 'fastgraf.bi'
DEFINT A-Z
FGversion Major, Minor
Version! = Major + Minor*0.01
PRINT USING "This is version #.## of Fastgraph."; Version!
END
6 Fastgraph User's Guide
You must include the DECLARE commands in the file FASTGRAF.BI at the
beginning of each QuickBASIC module. This file should reside in the
directory where the compiler normally searches for other .BI files, or in any
of the directories specified by the INCLUDE environment variable. The
DECLARE commands in this file automatically provide the calling convention
and naming convention for each Fastgraph routine. In addition, they relieve
the QuickBASIC programmer of distinguishing arguments passed by value from
those passed by reference.
Example 1-3.
$INCLUDE: '\FG\INTRFACE.FOR'
PROGRAM MAIN
INTEGER*2 MAJOR
INTEGER*2 MINOR
CALL FG_VERSION (MAJOR, MINOR)
WRITE (6,10) MAJOR, MINOR
10 FORMAT (' This is version ', I1, '.', I2.2, ' of Fastgraph.')
STOP ' '
END
You must include the INTERFACE statements in the file INTRFACE.FOR at
the beginning of your program (this file should reside in the \FG directory).
The INTERFACE statements in this file automatically provide the calling
convention and naming convention for each Fastgraph routine. In addition,
they relieve the FORTRAN programmer of distinguishing arguments passed by
value from those passed by reference.
Example 1-4.
program main;
uses fgtp;
var
Major : integer;
Minor : integer;
begin
fg_version(Major,Minor);
writeln('This is version ',Major,'.',Minor:2,' of Fastgraph.');
end.
Turbo Pascal programs that use Fastgraph or Fastgraph/Light must include
a uses statement specifying the name of the Fastgraph unit, FGTP. In
addition, if the program calls any of the compiler-specific Fastgraph
routines listed in Appendix D, the uses statement also must include the name
of the extended Fastgraph unit, FGTPX. The unit files must reside in a
directory where Turbo Pascal normally searches for units.
Chapter 1: Introduction 7
The following sections show the simplest compilation and linking
procedures for the supported compilers. In what follows, items enclosed in
angle brackets, such as <filename>, are placeholders for parameters you must
supply (the name of a file in this case). Items enclosed in square brackets,
such as [/E], are optional.
Borland C++
Borland C++ allows you to compile and link a program directly from the
DOS command line, or from within its integrated development environment
(IDE). To use Fastgraph from the IDE, you must make sure the compiler
options match one of Fastgraph's available memory models (small, medium, or
large) and then create a project file that links with the corresponding
Fastgraph libraries (as listed below).
You also can compile and link a Borland C++ program from the DOS command
line using the BCC command. The format of the BCC command for compiling a
program and linking it with Fastgraph is
BCC <model> <filename> <fg_library> [<fg_extended>]
where:
<model> specifies the compiler memory model you'll be using.
It must be either -ms (for the small model), -mm
(for the medium model), or -ml (for the large
model).
<filename> is the name of the file containing your
program. It may include a path specification.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLS.LIB (for the small model), FGLM.LIB
(for the medium model), or FGLL.LIB (for the large
model). For Fastgraph, the library name is FGS.LIB
(for the small model), FGM.LIB (for the medium
model), or FGL.LIB (for the large model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGTCS.LIB (for the small
model), FGTCM.LIB (for the medium model), or
FGTCL.LIB (for the large model). Fastgraph/Light
does not use extended libraries.
For example, to compile the program 01-01.C under the medium memory
model and then link it with Fastgraph, you could use the following BCC
command:
BCC -mm 01-01.C FGM.LIB FGTCM.LIB
8 Fastgraph User's Guide
Although we specified the extended library name FGTCM.LIB on the command
line, we didn't need to in this example because the program doesn't call any
of the compiler-specific Fastgraph routines listed in Appendix D. If you
were using Fastgraph/Light instead of Fastgraph, the BCC command would be:
BCC -mm 01-01.C FGLM.LIB
For more information about memory models or other compilation and linking
options, please refer to the Borland C++ User's Guide, published by Borland
International.
Microsoft C
Microsoft C programs are compiled and linked by entering a CL command at
the DOS command prompt. The format of the CL command for compiling a program
and linking it with Fastgraph is
CL <model> <filename> /link <fg_library> [<fg_extended>] [/E]
where:
<model> specifies the compiler memory model you'll be using.
It must be either /AS (for the small model), /AM
(for the medium model), or /AL (for the large
model).
<filename> is the name of the file containing your
program. It must include the file extension
(typically .C) and may include a path
specification.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLS (for the small model), FGLM (for the
medium model), or FGLL (for the large model). For
Fastgraph, the library name is FGS (for the small
model), FGM (for the medium model), or FGL (for the
large model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGMSCS (for the small
model), FGMSCM (for the medium model), or FGMSCL
(for the large model). Fastgraph/Light does not use
extended libraries.
The /E linker option is not required but will produce a smaller .EXE file if
specified.
Chapter 1: Introduction 9
For example, to compile the program 01-01.C under the medium memory
model and then link it with Fastgraph, you could use the following CL
command:
CL /AM 01-01.C /link FGM FGMSCM /E
Although we specified the extended library name FGMSCM on the command line,
we didn't need to in this example because the program doesn't call any of the
compiler-specific Fastgraph routines listed in Appendix D. If you were using
Fastgraph/Light instead of Fastgraph, the CL command would be:
CL /AM 01-01.C /link FGLM /E
For more information about memory models or other compilation and linking
options, please refer to the Microsoft C Optimizing Compiler User's Guide,
published by Microsoft Corporation.
Microsoft FORTRAN
Microsoft FORTRAN programs are compiled and linked by entering an FL
command at the DOS command prompt. The format of the FL command for
compiling a program and linking it with Fastgraph is
FL /FPi /4I2 /4Nt <model> <filename> /link <fg_library> [<fg_extended>] [/E]
where:
<model> specifies the compiler memory model you'll be using.
It must be either /AM (for the medium model) or /AL
(for the large model). Microsoft FORTRAN does not
support the small model.
<filename> is the name of the file containing your
program. It may include a path specification.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLM (for the medium model) or FGLL (for the
large model). For Fastgraph, the library name is
FGM (for the medium model) or FGL (for the large
model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGMSFM (for the medium
10 Fastgraph User's Guide
model) or FGMSFL (for the large model).
Fastgraph/Light does not use extended libraries.
The /E linker option is not required but will produce a smaller .EXE file if
specified.
For example, to compile the program 01-03.FOR under the medium memory
model and then link it with Fastgraph, you could use the following FL
command:
FL /FPi /4I2 /4Nt /AM 01-03.FOR /link FGM FGMSFM /E
Although we specified the extended library name FGMSFM on the command line,
we didn't need to in this example because the program doesn't call any of the
compiler-specific Fastgraph routines listed in Appendix D. If you were using
Fastgraph/Light instead of Fastgraph, the FL command would be:
FL /FPi /4I2 /4Nt /AM 01-03.FOR /link FGLM /E
For more information about memory models or other compilation and linking
options, please refer to the Microsoft FORTRAN Optimizing Compiler User's
Guide, published by Microsoft Corporation.
All the remaining example programs in the Fastgraph User's Guide are
written in the C programming language. However, when you install Fastgraph
for the Microsoft FORTRAN compiler, the installation procedure copies FORTRAN
versions of the example programs to the \FG\EXAMPLES directory.
Microsoft QuickBASIC
Microsoft QuickBASIC allows you to compile and link a program directly
from the DOS command line, or from within its programming environment. To
use Fastgraph from QuickBASIC's programming environment, just specify the
quick library name FGQB when starting QuickBASIC, as shown below.
QB /lFGQB
If you are using Fastgraph/Light, use the library name FGLQB instead of FGQB.
You also can compile and link a QuickBASIC program from the DOS command
line using the BC and LINK commands. The format of these commands for
compiling a program and linking it with Fastgraph is
BC <filename>;
LINK [/E] <object_file>,,NUL,<fg_library>
where:
Chapter 1: Introduction 11
<filename> is the name of the file containing your
program. It may include a path specification.
<object_file> is the name of the object file produced by the BC
command. By default, this will be the same as
<filename>, but with an extension of .OBJ rather
than .BAS.
<fg_library> is the name of the standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLQB. For Fastgraph, the library name is
FGQB. QuickBASIC does not use extended Fastgraph
libraries.
The /E linker option is not required but will produce a smaller .EXE file if
specified.
For example, to compile the program 01-02.BAS and then link it with
Fastgraph, you could use the following commands:
BC 01-02.BAS;
LINK /E 01-02.OBJ,,NUL,FGQB
If you were using Fastgraph/Light instead of Fastgraph, the commands would
be:
BC 01-02.BAS;
LINK /E 01-02.OBJ,,NUL,FGLQB
For more information about other compilation and linking options, please
refer to the Microsoft QuickBASIC: Programming in BASIC manual, published by
Microsoft Corporation.
All the remaining example programs in the Fastgraph User's Guide are
written in the C programming language. However, when you install Fastgraph
for Microsoft QuickBASIC, the installation procedure copies QuickBASIC
versions of the example programs to the \FG\EXAMPLES directory.
Microsoft QuickC
Microsoft QuickC allows you to compile and link a program directly from
the DOS command line, or from within its programming environment. To use
Fastgraph from the QuickC programming environment, you must make sure the
compiler options match one of Fastgraph's available memory models (small,
medium, or large) and then create a make file that includes one or more of
the corresponding Fastgraph libraries (as listed below).
You also can compile and link a QuickC program from the DOS command line
using the QCL command. The format of the QCL command for compiling a program
and linking it with Fastgraph is
QCL <model> <filename> /link <fg_library> [<fg_extended>] [/E]
12 Fastgraph User's Guide
where:
<model> specifies the compiler memory model you'll be using.
It must be either /AS (for the small model), /AM
(for the medium model), or /AL (for the large
model).
<filename> is the name of the file containing your
program. It must include the file extension
(typically .C) and may include a path
specification.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLS (for the small model), FGLM (for the
medium model), or FGLL (for the large model). For
Fastgraph, the library name is FGS (for the small
model), FGM (for the medium model), or FGL (for the
large model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGMSCS (for the small
model), FGMSCM (for the medium model), or FGMSCL
(for the large model). Fastgraph/Light does not use
extended libraries.
The /E linker option is not required but will produce a smaller .EXE file if
specified.
For example, to compile the program 01-01.C under the medium memory
model and then link it with Fastgraph, you could use the following QCL
command:
QCL /AM 01-01.C /link FGM FGMSCM /E
Although we specified the extended library name FGMSCM on the command line,
we didn't need to in this example because the program doesn't call any of the
compiler-specific Fastgraph routines listed in Appendix D. If you were using
Fastgraph/Light instead of Fastgraph, the QCL command would be:
QCL /AM 01-01.C /link FGLM /E
For more information about memory models or other compilation and linking
options, please refer to the Microsoft QuickC Tool Kit manual, published by
Microsoft Corporation.
Chapter 1: Introduction 13
Power C
Power C programs are compiled and linked from the DOS command line using
the PC and PCL commands. The format of these commands for compiling a
program and linking it with Fastgraph is
PC <model> <filename>
PCL <mix_file> ;<fg_library> [;<fg_extended>]
where:
<model> specifies the compiler memory model you'll be using.
It must be either /ms (for the small model), /mm
(for the medium model), or /ml (for the large
model).
<filename> is the name of the file containing your
program. It may include a path specification.
<mix_file> is the name of the object file produced by the
PC command. By default, this will be the same
as <filename>, but with an extension of .MIX
rather than .C.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLS (for the small model), FGLM (for the
medium model), or FGLL (for the large model). For
Fastgraph, the library name is FGS (for the small
model), FGM (for the medium model), or FGL (for the
large model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGPCS (for the small
model), FGPCM (for the medium model), or FGPCL (for
the large model). Fastgraph/Light does not use
extended libraries.
For example, to compile the program 01-01.C under the medium memory
model and then link it with Fastgraph, you could use the following commands:
PC /mm 01-01.C
PCL 01-01.MIX ;FGM ;FGPCM
Although we specified the extended library name FGPCM on the command line, we
didn't need to in this example because the program doesn't call any of the
compiler-specific Fastgraph routines listed in Appendix D. If you were using
Fastgraph/Light instead of Fastgraph, the commands would be:
14 Fastgraph User's Guide
PC /mm 01-01.C
PCL 01-01.MIX ;FGPCM
For more information about memory models or other compilation and linking
options, please refer to the Power C manual, published by Mix Software, Inc.
Turbo C and Turbo C++
Turbo C and Turbo C++ allow you to compile and link a program directly
from the DOS command line, or from within their integrated development
environment (IDE). To use Fastgraph from the IDE, you must make sure the
compiler options match one of Fastgraph's available memory models (small,
medium, or large) and then create a project file that links with the
corresponding Fastgraph libraries (as listed below).
You also can compile and link a Turbo C or Turbo C++ program from the
DOS command line using the TCC command. The format of the TCC command for
compiling a program and linking it with Fastgraph is
TCC <model> <filename> <fg_library> [<fg_extended>]
where:
<model> specifies the compiler memory model you'll be using.
It must be either -ms (for the small model), -mm
(for the medium model), or -ml (for the large
model).
<filename> is the name of the file containing your
program. It may include a path specification.
<fg_library> is the name of a standard Fastgraph/Light or
Fastgraph library. For Fastgraph/Light, the library
name is FGLS.LIB (for the small model), FGLM.LIB
(for the medium model), or FGLL.LIB (for the large
model). For Fastgraph, the library name is FGS.LIB
(for the small model), FGM.LIB (for the medium
model), or FGL.LIB (for the large model).
<fg_extended> is the name of an optional compiler-specific
extended Fastgraph library. You need to specify an
extended library name only if your program calls any
of the Fastgraph routines listed in Appendix D. The
extended library name is FGTCS.LIB (for the small
model), FGTCM.LIB (for the medium model), or
FGTCL.LIB (for the large model). Fastgraph/Light
does not use extended libraries.
For example, to compile the program 01-01.C under the medium memory
model and then link it with Fastgraph, you could use the following TCC
command:
TCC -mm 01-01.C FGM.LIB FGTCM.LIB
Chapter 1: Introduction 15
Although we specified the extended library name FGTCM.LIB on the command
line, we didn't need to in this example because the program doesn't call any
of the compiler-specific Fastgraph routines listed in Appendix D. If you
were using Fastgraph/Light instead of Fastgraph, the TCC command would be:
TCC -mm 01-01.C FGLM.LIB
For more information about memory models or other compilation and linking
options, please refer to the Turbo C User's Guide and the Turbo C Reference
Guide, both published by Borland International.
Turbo Pascal
Turbo Pascal allows you to compile and link a program directly from the
DOS command line with the TPC command, or from within its integrated
development environment (IDE) with the TURBO command. To use Fastgraph from
the IDE, just start the IDE as you would for any other Pascal program, making
sure the standard unit (FGTP.TPU) and extended unit (FGTPX.TPU) reside in one
of the directories listed in the Unit Directories option.
You also can compile and link a Turbo Pascal program from the DOS
command line using the TPC command. The format of the TPC command for
compiling a program and linking it with Fastgraph is
TPC <filename>
where:
<filename> is the name of the file containing your
program. It may include a path specification.
For example, to compile the program 01-04.PAS and then link it with
Fastgraph, you could use the following command:
TPC 01-04.PAS
For more information about other compilation and linking options, please
refer to the Turbo Pascal User's Guide, published by Borland International.
All the remaining example programs in the Fastgraph User's Guide are
written in the C programming language. However, when you install Fastgraph
for Turbo Pascal, the installation procedure copies Pascal versions of the
example programs to the \FG\EXAMPLES directory.
16 Fastgraph User's Guide
Fastgraph/Light Video Driver
As mentioned earlier, running any program created with Fastgraph/Light
requires an external program called the Fastgraph/Light Video Driver. The
video driver is a terminate and stay resident program (TSR) that provides an
interface between your program and Fastgraph. Once loaded, the video driver
uses about 60,000 bytes of conventional memory.
To load the video driver, enter the command FGDRIVER at the DOS command
prompt (assuming FGDRIVER.EXE is in the current directory, or the \FG
directory is in your DOS path specification). The driver will display a
message indicating whether or not it loaded successfully. After you load the
driver, just run a program created with Fastgraph/Light as you would any
other program. If you try running a program that uses Fastgraph/Light
without first loading the video driver, the message "Fastgraph/Light video
driver not installed" will appear.
You don't need to load the driver before running each program, just once
per system boot (in fact, the driver will display an "already loaded" message
if you try to load it more than once). If you want to unload the video
driver, just enter FGDRIVER /U at the DOS command prompt. The unload
operation will work completely only if the video driver was the last TSR
loaded. If it wasn't the last TSR, the driver will still unload, but the
memory it uses will not be released back to DOS.