home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 227_01 / graf.s < prev    next >
Encoding:
Text File  |  1988-02-09  |  61.3 KB  |  1,814 lines

  1. .tr ~ 
  2. .SA 1
  3. .PH "''Compatible graphics library''"
  4. .PF "''Page \\\\nP''"
  5. .DS C
  6. Public Domain Compatible Graphics Library
  7. .sp 1
  8. The C User's Group
  9. .sp 1
  10. Author
  11. Rainer Gerhards
  12. Petronellastr. 6
  13. D-5112 Baesweiler
  14. West Germany
  15. .sp 1
  16. Library Version
  17. 2.1, 11/15/1987
  18. .sp 1
  19. Documentation Version
  20. 2.1 (11/15/87 16:56:50)
  21. .sp 2
  22. supported operating systems
  23. MS-DOS or PC-DOS 2.0 or higher
  24. .sp 1
  25. supported C compilers
  26. Lattice C 3.0
  27. Datalight C 2.23
  28. Borland Turbo C 1.0
  29. [Microsoft C]
  30. .sp 1
  31. supported graphics cards
  32. Hercules monochrome graphics card
  33. enhanced graphics adapter (EGA)
  34. IBM std. BIOS interface
  35. Elsa PC XXHR vector graphics board
  36. .sp 1
  37. supported graphics printer
  38. Nec pinwriter P6 / P7
  39. Epson \(*TM compatible printers
  40. .sp 1
  41. supported plotters
  42. --- currently none ---
  43. .DE
  44. .bp
  45. .ll -10
  46. .in +10
  47. .fi
  48. This document describes the compatible
  49. graphics library for almost every (strong words, I know)
  50. computer. Everybody is free to copy,
  51. adapt or modify the listed sources
  52. and documentation. It would be nice, if
  53. you copy this acknowledgment and the authors
  54. name and address too.
  55. .br
  56. If you have new ideas or improvements
  57. please contact the author.
  58. .ll +10
  59. .in -10
  60. .sp 0
  61. .SK
  62. .H 1 "Introduction"
  63. .H 2 "Design history and background"
  64. .fi
  65. This library was first designed as a demonstration library for very fast
  66. assembly language routines.
  67. But after a while using it, I think that this C library is much more powerful
  68. than the assembly language library is.
  69. Ok, the assembly language library is somewhat faster, but it hasn't the ability to run on all well-known graphics devices for the IBM PC.
  70. And I think it will be a horrible task to port the library to a really different
  71. environment - an Unix machine for example.
  72. This is a much more easy task with the C language library.
  73. .br
  74. So this C library builds the base of a compatible graphics system, which will
  75. run
  76. on a CP/M machine as well as on a big Unix system.
  77. Currently only parts of the IBM personal computer hardware are supported,
  78. because I own no other hardware. I hope, that other users will help to
  79. make this library really portable and powerful.
  80. .sp 1
  81. While the first version implemented only the basic tasks, the current version
  82. (2.1) has many intersting features and is greatly enhanced
  83. above version 1.1. 
  84. It is very nice to move from one video device to another without source-code
  85. changes.
  86. I also improved the speed and memory requirements of the library dramatically,
  87. and so 
  88. I think this version covers a lot of serious projects.
  89. .sp 1
  90. I hope that some of you
  91. have some interesting ideas and algorithms and want to tell me about them.
  92. So I hope to get a full praxis-driven library.
  93. In addition, I hope that some of you want to port the low-level parts of the
  94. library to different machines and graphics environments, making the library
  95. really portable.
  96. Everybody should feel free to contact me!
  97. .H 2 "Current features"
  98. .fi
  99. The most powerful feature of the library is its compatibility and hardware
  100. independency.
  101. You may use the library on many machines, as long as there's driver
  102. available.
  103. And new drivers can be very simply added.
  104. .sp 1
  105. The library currently supports:
  106. .DL
  107. .LI
  108. switching between different display modes (graphics/nongraphics)
  109. .LI
  110. drawing pixels
  111. .LI
  112. drawing lines
  113. .LI
  114. drawing polylines
  115. .LI
  116. drawing boxes
  117. .LI
  118. filling boxes with given colors (e.g. clear windows)
  119. .LI
  120. draw any ellipses in full or in part
  121. .LI
  122. paint any region on the screen with a given color. The region is defined by
  123. a border color.
  124. .LI
  125. you may use a global coordinate system, freeing you from the given hardware
  126. parameters. Also very useful in numerical applications.
  127. .LI
  128. print graphics screens as a hardcopy function.
  129. This is currently limited to the Hercules graphics card and Epson compatible
  130. printers.
  131. .LI
  132. clear the graphics screen.
  133. .LI
  134. read the color of a specified pixel.
  135. .LI
  136. output text in different styles with user selectable foreground and background
  137. colors.
  138. .LI
  139. use a library error-code system. Errors occurred while processing graphics
  140. Information may be printed with a function like perror.
  141. .LI
  142. a full turtle graphics system
  143. .LI
  144. different device write modes.
  145. New drawing may be modifyed according to the old video contents (XOR them,
  146. e. g.).
  147. .LE
  148. .H 2 "new features and enhancements of version 2.1"
  149. The following new features, enhancements and bug fixes have been applied to
  150. the library since version 2.1:
  151. .DL
  152. .LI
  153. A bug in the medium-level header file has been fixed.
  154. The EGA-mode was defined in this header file, resulting in bad coding
  155. sequences for devices other than EGA.
  156. This define has been moved to the right place in the EGA low-level header
  157. file.
  158. .br
  159. Note that the version 1.1 distribution disk was corrupted by this bug.
  160. .LI
  161. A bad bug in herc.c, the C-part of the hercules low-level driver has been
  162. detected and removed.
  163. Mr. Decker of Nuernberg, West Germany reported my, that the given port
  164. address in this low-level driver were incorrect.
  165. As a result, the switch into the hercules graphic mode was unsuccessful.
  166. I'm sorry, the Hercules emulation I use on the QuadEGA switched always
  167. correctly to graphics mode, so I don't saw an error.
  168. Sorry to all Hercules users who only saw a black screen!
  169. This bug has been corrected (two addresses, dammed!).
  170. .LI
  171. The low-level driver for the Hercules graphics card and the EGA have been
  172. greatly improved and speeded up.
  173. New internal function calls have been added, resulting in a great speedup of
  174. the whole library code.
  175. This effect is extreme in function paint and line.
  176. .LI
  177. The hercules low-level driver has a much better hardcopy routine. 
  178. The new routine optimizes the print-output before sending it to the printer,
  179. resulting in a great decrease of print-time, if the screen is nearly blank.
  180. The more information is presented on the graphics screen, the less the
  181. decrease of print time will be, but I think it's really good for many
  182. applications.
  183. .LI
  184. The stack space needed by function paint has been dramatically reduced.
  185. It now requires only about 20% of the original space.
  186. Also the processing time has been reduced.
  187. .LI
  188. The assembly language macros have been implemented.
  189. Version 1.1 used the Lattice macros, which couldn't be distributed due
  190. to copyright limitations.
  191. The now written macro package implements all used Lattice macros in a manner,
  192. that makes moving to a new compiler an relatively easy task.
  193. Also some macros have been defined for this reason, which weren't implemented
  194. in the Lattice package.
  195. You may find the macro package also of interest for your own assembly language
  196. routines, the documentation should be good enough to use them.
  197. They are not documented as part of the library, because their internal
  198. implementation is not guaranteed to be the same in the next release.
  199. .br
  200. Nevertheless, there are some parameters the user must set to correct assemble
  201. the sources.
  202. This parameters are described below.
  203. .LI
  204. A new set of parameters have been added to the medium-/high-level header file 
  205. "graphics.h".
  206. These parameters allows it the user to modify some minor configuration
  207. parameters.
  208. The usage of this mechanism will be described below.
  209. .LI
  210. The text-output system has been added.
  211. It is currently not complete implemented, but offers a good chance to do
  212. most text-output jobs.
  213. .LI
  214. The new function polyline has been added.
  215. It allows the user to draw a complex figure or line with only one function
  216. call.
  217. It is able to work on a variable table which holds line coordinates.
  218. All the coordinates are concatenated with a user-specified color.
  219. .LI
  220. An error system has been implemented.
  221. Functions, which may detect error conditions return -1 if an actual error
  222. occurred, 0 otherwise.
  223. In case of an error return, the global variable "gr_error" may be examined
  224. for the exact error reason.
  225. The function "grperror" has been added to print the error message in a
  226. human-readable form.
  227. It is much like perror, but with increased functionality.
  228. The error system is described in greater detail below.
  229. .LI
  230. A complete turtle graphics system has been added.
  231. This system supports all of the common turtle graphics commands including
  232. turtle positioning, moving and hiding/showing.
  233. This package is described below in more detail.
  234. .LI
  235. A new, powerful feature has been added: You now can specify an so-called
  236. write mode.
  237. This write mode is applied to all pixel drawing operations.
  238. It allows you to modify the display contents in respect to its old state.
  239. E. g. the old pixel color may be XORed with the new color.
  240. .LI
  241. A basic-equivalence header file has been added.
  242. This allows it user's who like the basic names for some graphics primitives
  243. to use them, without destroying compatibility to users (and library
  244. versions), who do not.
  245. .br
  246. This feature is an idea of Michael Yokoyama of Aiea, HI 96701.
  247. .LI
  248. Some documentation bugs have been fixed and the whole documentation has been
  249. upgraded to reflect the latest version of the library.
  250. .LI
  251. The whole library is now maintained internally by Unix SCCS, so the SCCS
  252. version numbering scheme has been adapted.
  253. All version numbers are now starting at one.
  254. The old version 1.1 has been renamed to 1.1.
  255. .LI
  256. Some minor bugs have been fixed.
  257. .H 2 "Release compatibility"
  258. The graphics library is upward compatible.
  259. This means, that programs that used version 1.1 of the library will run
  260. without modification using version 2.1 of the library.
  261. Note that not all 2.1 functions are supported by version 1.1 of the library,
  262. so you can not move user code from 2.1 to 1.1.
  263. Even if it may be possible (no extended functionality used), you should always
  264. use the latest version of the library because of bug fixes and execution speed.
  265. .sp 1
  266. When moving form version 1.1 to 2.1, you need not to recompile the user code
  267. if you don't need the extended functionality.
  268. .sp 1
  269. Note that low-level drivers written for Version 1.1 of the library are
  270. still functional under 2.1.
  271. If this are assembly language drivers, they should be upgraded to use the
  272. new macro support facility.
  273. This easies the task to move them to other compilers.
  274. .H 1 "Library design"
  275. The library uses three logical parts: one medium-level, completely machine
  276. independent
  277. graphics kernel, a medium-level machine-independent part and one low-level
  278. machine dependent part.
  279. There are header (.h) files for the high- and low-level parts.
  280. .br
  281. The user program hasn't to know which function resides in which part of
  282. the graphics library.
  283. If it uses the official entry points, it must be portable to any new 
  284. video device, if it's supported by the library.
  285. The available entry points are listed under "User program interface".
  286. .H 2 "High-level library part"
  287. The high-level library part is completely hardware and operating system
  288. independent.
  289. It's written entirely in C.
  290. It contains all the more complex drawing operations based on the medium-
  291. and low-level part.
  292. .sp 1
  293. There's no need to recompile the high-level part for the different video
  294. devices.
  295. This makes it possible to use loadable device drivers, which allows
  296. dynamically reconfiguration of the user-program for
  297. different video devices - all at runtime without recompilation.
  298. .sp 1
  299. Currently this feature isn't implemented and there aren't a lot of
  300. functions in the high-level category.
  301. .H 2 "medium-level library part"
  302. This part was called high-level in version 1.1.
  303. It's written completely in C.
  304. It includes all the graphics primitives like line drawing, area filling and
  305. so on.
  306. This part uses no direct hardware parameters or interfaces. 
  307. It uses standardized interfaces to the low-level routines instead.
  308. If you need special coding for special hardware or greater speed, you may
  309. include this coding in the medium-level part, but use conditional compilation
  310. to keep it portable.
  311. .br
  312. Though this part is hardware independent, it needs to be recompiled for 
  313. every new video device.
  314. The medium-level part must know some common hardware parameters like the
  315. screen resolution.
  316. Also there is different coding to be activated for different devices.
  317. This ensures the best throughput by using hardware-specific features and
  318. also ensures compatibility by also implementing a general, sometimes slower
  319. routine.
  320. .sp 1
  321. To perform the recompilation successfully the medium-level routines uses the
  322. information contained in the low-level header files.
  323. So it's very important, that every new device\*f
  324. .FS
  325. device is here used as an alias for the low-level device driver functions.
  326. .FE
  327. defines it's hardware parameters in it's corresponding header-file.
  328. There must also for every device a unique mode-identifier be defined. 
  329. This identifier allows it the medium-level routines
  330. to use special hardware features but remain compatible.
  331. .H 2 "Low-level library part"
  332. The low-level part is written in C and assembler.
  333. This C-coding must use non-standard functions\*F
  334. .FS
  335. like hardware port I/O
  336. .FE
  337. to perform its work.
  338. A recompilation of this parts with different compilers may be difficult.
  339. Only tasks, which couldn't be performed in C are written in assembler.
  340. These are most common only the write and read pixel functions.
  341. As many coding as possible should be written in C!
  342. .sp 1
  343. The low-level functions are called very often from the medium-level routines,
  344. especially the read and write pixel functions.
  345. To guarantee a good throughput, these functions should be optimized.
  346. It is a good practice, to look very sceptic to these two functions and the
  347. whole low-level driver.
  348. .sp 1
  349. The low-level routines may implement as many functions as possible, but the
  350. user program should only use the standard functions of the low-level part.
  351. These are listed in the chapter "User program interface".
  352. Using non-standard functions may cause incompatibilities, because some
  353. hardware may not be able to perform specific tasks.
  354. .br
  355. The list of accessible low-level functions may grew in the future, but it
  356. must be granteed that almost every current video device\*F
  357. .FS
  358. These are not only DOS devices - remember the other popular systems like
  359. Apple Mac and Unix systems.
  360. .FE
  361. is able to perform the task.
  362. An example for such tasks may by bytewise addressing of the video memory
  363. - but is this identical on all video devices? I think no.
  364. So it's a better practice to add new or optimize old high- or medium-level
  365. functions.
  366. They are much more flexible.
  367. .H 2 "Stages of compatibility"
  368. The implementation goal of this library was (and is) her great compatibility
  369. on a wide range of machines.
  370. Though this goal is currently reached nearly 100% in the DOS environment,
  371. the design process showed that
  372. there are some useful functions which can only be implemented on many, but not
  373. all devices.
  374. An example for such functions is the video pages system.
  375. On systems, where is no direct access to the video memory information,
  376. the execution time needed to read a full screen via the read pixel function
  377. is much to large to allow a page change.
  378. But this function is very useful and can be implemented on many video
  379. devices.
  380. If you strict exclude such functions, which can't be implemented an all
  381. devices, you can't implement a graphics paging system.
  382. But if you implement this system only on devices which support them, you
  383. destroy the whole compatibility.
  384. .br
  385. So I decided to declare a class of "pseudo-portable" functions:
  386. These functions are available on almost every video device, but return
  387. an error value to the caller.\*F
  388. .FS
  389. using the now implemented error system.
  390. .FE
  391. This value may say the following: "This function can't be performed by
  392. this video device!".
  393. It's now the responsibility of the user program to make use of this 
  394. information and react correctly.
  395. Note that there is a great difference between this implementation philosophy
  396. and "not to implement" the feature.
  397. An error message may also be generated if the feature is available with the
  398. current video devices, but there are not enough resources available to use
  399. it (not enough memory, e. g.).
  400. So the user program has always to look and react at the error codes.
  401. .sp 1
  402. Though this is a way of implementing hardware-specific features in this
  403. library, I think it should only be used on limited tasks, which should be
  404. common to many video devices.
  405. There should be as less functions which use such hardware-specific features
  406. as possible!
  407. .H 1 "Installation of the library"
  408. This section covers the whole installation process, which must performed
  409. by you in order to get the library working.
  410. To ease this task, only the pure installation process is described, not
  411. the way to make the library suit your meets.
  412. This task is covered in the section "Modifying the library", where useful
  413. information about extended configuration parameters can be found.
  414. .br
  415. But be warned: this section was intended for use by those who want
  416. to part the library to a new environment or make serious changes.
  417. The information presented there is very technical.
  418. .H 2 "Bringing up the library"
  419. The following files are guaranteed to be on the distribution disc.
  420. .DS CB N
  421. File name    file description
  422. graf.s        This documentation file in nroff
  423.         source code format.
  424. graf.txt    This documentation file as pure
  425.         ASCII text.
  426. readme.doc    Contains latest information, which
  427.         is not included in this document.
  428. grafturt.c    First part of the high-level library part,
  429.         contains the turtle graphics system.
  430. graf.c        First part of the medium-level library
  431.         part.
  432. graftext.c    Second part of the medium-level library
  433.         part.
  434. herc.c        First part of the hercules low-level
  435.         driver
  436. herca.asm    Second part of the hercules low-level
  437.         driver.
  438. ega.c        First part of the ega low-level driver.
  439. egaa.asm    Second part of the ega low-level
  440.         driver.
  441. bios.c        Standard BIOS low-level driver.
  442. xxhr.c        Driver for the Elsa PC XXHR graphics card.
  443. btrigtab.c    Program to build trigonometric tables.
  444. graphics.h    High-level header file.
  445. herc.h        Low-level hercules device header file.
  446. ega.h        Low-level ega device header file.
  447. bios.h        Low-level BIOS header file.
  448. xxhr.h        Low-level xxhr header file.
  449. dos.mac        Macro file for the assembly language
  450.         modules.
  451. allglob.h    Header file for programs, which want to use
  452.         the world coordinate system only.
  453. basnames.h    Basic equivalence macros. For users who
  454.         like basic function names.
  455. stdfont.h    Standardfont for use by graftext.c.
  456. trigtab.h    Precomputed trigonometric tables. Should be
  457.         rebuild on the target machine using btrigtab.c.
  458. blddsk.bat    MS-DOS library disk build routine.
  459. .DE
  460. This file list may be extended in the future.
  461. .sp 1
  462. The distribution disk shipped to you may contain additional object (.obj)
  463. files.
  464. Especially the assembly language files will come per-assembled, because
  465. not everybody will own an assembler.
  466. .br
  467. But the availability of object files will be depending on the free space
  468. on the distribution disk.
  469. I try to copy all object files for every supported compiler and memory
  470. model to the distribution disk.
  471. But these files need a lot of space, so it can't be guaranteed that these
  472. files will be on the disk.
  473. .sp 1
  474. Look at the file "readme.doc" for the current file organization on the
  475. distribution disk.
  476. .sp 1
  477. To install, you have first to copy all the files you need from the
  478. distribution disk to either a new floppy or your working directory on
  479. your hard-disk.
  480. You need at least the high- and medium-level source code and header files and
  481. one
  482. complete (C and ASM source and header file) low-level driver.
  483. .br
  484. If the objects for your compiler and memory model are on the distribution
  485. disk, the installation is done and you can begin using the library.
  486. If not, you have to compile the source files with your compiler.
  487. If your compiler is not currently supported by the library, switch to
  488. section "Modifying the library", where some useful information for the port
  489. to a new compiler can be found.
  490. Also switch to this section, if you want to make some configuration changes
  491. to the library.
  492. .br
  493. To compile the delivered version of the library, first choose which
  494. graphics device do you want to use.
  495. After that, copy the corresponding
  496. low-level header to the generic low-level header
  497. file "graf.h".
  498. After that, simply compile the high- and medium-level library files as listed
  499. above.
  500. Than compile the low-level file and assemble the assembly language
  501. part of the low-level driver, if given.
  502. .br
  503. Note that you have to modify the file "dos.mac" to your requirements to
  504. perform the assembly successful.
  505. See the following subsection "Configuring dos.mac" for information about
  506. this task.
  507. .br
  508. You should combine the resulting object files to a single library, which
  509. simplifies the link-procedure.
  510. .br
  511. If you need multiple memory model support, perform the above steps for
  512. each memory model you selected to use.
  513. .sp 1
  514. After doing the compilations, you may have to modify your
  515. link-batchfiles. For example, the Lattice C compiler comes with 8 batchfiles
  516. named LINKS, LINKD, LINKP, LINKL, LINKMS, LINKMD, LINKMP, and LINKML.
  517. These batchfiles don't allow you to specify your own librarys. You have
  518. to modify them like in the following example:
  519. .DS
  520. LINKS contains:
  521. link /lc/s/c +%1 %2,%1,%1/map,/lc/s/lc
  522. .sp 1
  523. You modify this to:
  524. link /lc/s/c +%1 %2,%1,%1/map,/lc/s/lc+"name of your graphic library"
  525. .sp 1
  526. Note: Slash (/) were used as path delimiter!
  527. .DE
  528. After you have done this, you are ready to use the library.
  529. .sp 1
  530. If you use the a compiler with cc-like utility (integrated compile/link),
  531. just name your library on the command line.
  532. It will be automatically included in the link procedure.
  533. .H 2 "Configuring dos.mac"
  534. The assembly routines need to know about the environment, in which they
  535. have to execute.
  536. They have to know about the calling compiler and the memory model used.
  537. This environmental data is kept in file dos.mac.
  538. .br
  539. In order to successful reassemble the assembly language files, you have
  540. to modify file "dos.mac" so that it represents the execution environment you
  541. decided to use.
  542. In order to ease this job, there are predefined tags in file "dos.mac".
  543. The following display list is extracted from dos.mac and lists these tags 
  544. and gives a brief description.
  545. .DS
  546. ;
  547. ;    Define Memory-model to use
  548. ;    --------------------------
  549. ;    Equate the memory model to use to 1, all others to 0.
  550. ;
  551. S_MODEL    equ    1
  552. D_MODEL    equ    0
  553. P_MODEL    equ    0
  554. L_MODEL    equ    0
  555.  
  556. ;
  557. ;    Define C-compiler to use
  558. ;    ------------------------
  559. ;    Equate the label, that describes your C-compiler to his current
  560. ;    version (major version number * 10 + 1st digit of minor version
  561. ;    number). All other labels must be equated to 0.
  562. ;
  563. LC    equ    0            ; Lattice C
  564. DLC    equ    22            ; Datalight C V. 2.2x
  565. MSC    equ    0            ; Microsoft C  NOT TESTED
  566. TC    equ    0            : Borland Turbo C
  567. .DE
  568. As listed above, you have to equate the memory model to use to 1, all others
  569. to 0.
  570. If your compiler supports different memory models, select one of the above
  571. according to the following table:
  572. .DS
  573. Model    Code    Data
  574. S    64K    64K
  575. P    unlmtd    64K
  576. D    64K    unlmtd
  577. L    unlmtd    unlmtd
  578. .DE
  579. The equate of your compiler to his version number makes calling-sequence
  580. changes\*F
  581. .FS
  582. that may occur during compiler development
  583. .FE
  584. transparent to the graphics library.
  585. .br
  586. Note that these configuration tags will be extensive error-checked and
  587. all detected errors will be reported during assembly.
  588. Nevertheless, you should be very carefully, when modifying these parameters,
  589. because not all errors can be detected (e. g. wrong memory model chosed).
  590. .sp 1
  591. Be aware of the fact, that the MSC macros aren't tested yet.
  592. I think the work, but I've currently no access to MSC.
  593. So expect some trouble if you decide to use the MSC driver.
  594. .H 1 "User program interface"
  595. .H 2 "Header files"
  596. The user program interface is defined in the various header (.h) files.
  597. There are two classes of header files: First ONE (and only one) header file
  598. defining the high- and medium-level functions and constants.
  599. .br
  600. This header file is named "graphics.h".
  601. .br
  602. Second there are many header
  603. files defining the low-level functions and constants.
  604. .sp 1
  605. These low-level header files may be used in two different ways:
  606. .br
  607. First you may include the device dependent header files by name, e. g.
  608. "hercgraf.h" for the Hercules graphics card.
  609. This way has the disadvantage of missing hardware independency of the user
  610. code. 
  611. If you want to move to a different video device, you have first to change
  612. the header file names in all of your sources.
  613. .br
  614. The second way to use the header files is to include a generic filename,
  615. e.\ g.
  616. "graf.h".
  617. You may copy than the correct header file (e. g. "hercgraf.h") to this generic
  618. file.
  619. If you want to switch another video device, just copy the new header file to
  620. the generic file.
  621. There is nothing more to do, no code must be changed!
  622. .sp 1
  623. I think this second method is much better and should always be used.
  624. The medium- and high-level routines use this method too\*F.
  625. .FS
  626. See "Modifying the library"
  627. .FE
  628. To aid you in using this "good"\*F
  629. .FS
  630. hope you think so too
  631. .FE
  632. method, the medium-level header file does a #include "graf.h".
  633. If you don't want this, please do a #define NOLLHINC \*F
  634. .FS
  635. NO Low-Level Header file INClude
  636. .FE
  637. before #including the high level header file.
  638. .H 2 "Available function calls"
  639. The following is a brief description of the available function calls.
  640. It is guaranteed that these functions will work in every implementation.
  641. .br
  642. Each function is listed with her name, parameters and a description.
  643. These information can also be found in the sources, from where it is
  644. extracted.
  645. If you need more information about a particular function, look at the
  646. sources.
  647. There can be much more information found than in this document.
  648. But beware of the fact, that the internal algorithms are subject to
  649. change without notice!
  650. .bp
  651. .H 3 "Box function"
  652. .VL 15
  653. .LI name
  654. box
  655. .LI class
  656. medium-level
  657. .LI synopsis
  658. box(x1, y1, x2, y2, color);
  659. .nf
  660. int x1, y1;            upper left corner
  661. int x2, y2;            lower right corner
  662. int color;             border color
  663. .LI description
  664. This function draws a border of "color" covering the
  665. given box. The box is specified through the upper
  666. left (x1, y1) and to lower right (x2, y2) corner. The
  667. box itself isn't modified (e. g. must be cleared
  668. explicitly).
  669. .LE
  670. .bp
  671. .H 3 "circle function"
  672. .VL 15
  673. .LI name
  674. circle
  675. .LI class
  676. medium-level
  677. .LI synopsis
  678. circle(x, y, radius, color, aspect)
  679. .nf
  680. int x, y;              center coordinate
  681. int radius;            circle radius
  682. int color;             circle color
  683. float aspect;          aspect ratio
  684. .fi
  685. .LI description
  686. This function draws a circle according to the given parameters.
  687. Note that this function is only capable of drawing a full circle.
  688. .LI see~also
  689. ellipsis
  690. .LE
  691. .bp
  692. .H 3 "convxco function"
  693. .VL 15
  694. .LI name
  695. convxco
  696. .LI class
  697. medium-level
  698. .LI synopsis
  699. locx = convxco(x)
  700. .nf
  701. float x      x coordinate to convert
  702. int locx     hardware x coordinate
  703. .fi
  704. .LI description
  705. This function converts a global coordinate to a local,
  706. hardware dependent coordinate. Its return value may be
  707. directly passed to other functions.
  708. .LI see~also
  709. convyco, convxdis, convydis
  710. .LE
  711. .bp
  712. .H 3 "convxdis function"
  713. .VL 15
  714. .LI name
  715. convxdis
  716. .LI class
  717. medium-level
  718. .LI synopsis
  719. locxdist = convxdis(xdis)
  720. .nf
  721. double xdis  distance to convert
  722. int locxdist hardware distance
  723. .fi
  724. .LI description
  725. This function converts a global x distance to a local,
  726. hardware dependent x distance.
  727. Its return value may be directly passed to other functions.
  728. .LI see also
  729. convxco, convyco, convydis
  730. .LE
  731. .bp
  732. .H 3 "convyco function"
  733. .VL 15
  734. .LI name
  735. convyco
  736. .LI class
  737. medium-level
  738. .LI synopsis
  739. locy = convyco(y)
  740. .nf
  741. float y      y coordinate to convert
  742. int locy     hardware y coordinate
  743. .fi
  744. .LI description
  745. This function converts a global coordinate to a local,
  746. hardware dependent coordinate. Its return value may be
  747. directly passed to other functions.
  748. .LI see~also
  749. convxco, convxdis, convydis
  750. .LE
  751. .H 3 "convydis function"
  752. .VL 15
  753. .LI name
  754. convydis
  755. .LI class
  756. medium-level
  757. .LI synopsis
  758. locydist = convydis(ydis)
  759. .nf
  760. double ydis  distance to convert
  761. int locydist hardware distance
  762. .fi
  763. .LI description
  764. This function converts a global y distance to a local,
  765. hardware dependent y distance.
  766. Its return value may be directly passed to other functions.
  767. .LI see also
  768. convxco, convyco, convxdis
  769. .LE
  770. .bp
  771. .H 3 "ellipsis function"
  772. .VL 15
  773. .LI name
  774. ellipsis
  775. .LI class
  776. medium-level
  777. .LI synopsis
  778. ellipsis(x, y, rx, ry, ws, we, color)
  779. .nf
  780. int x, y      center coordinate
  781. int rx        x - 'radius'
  782. int ry        y - 'radius'
  783. int ws        begin angle 0..360
  784. int we        end  angle 0..360
  785. int color     line color
  786. .fi
  787. .LI description
  788. This function draws any sort of ellipsis. It is often
  789. called circle, but I think this name should better be
  790. reserved for a function, which only draws a FULL
  791. circle (see above). 
  792. This function may not only draw a circle or any possible
  793. ellipsis, it is also capable of drawing only parts of.
  794. them. This feature is often used in pie-charts. Because
  795. of its great flexibility, this function is much slower
  796. than circle. If you only want a full circle (or
  797. ellipsis) you should call circle.
  798. .LI see~also
  799. circle, fellipsis
  800. .LE
  801. .bp
  802. .H 3 "fellipsis function"
  803. .VL 15
  804. .LI name
  805. fellipsis
  806. .LI class
  807. medium-level
  808. .LI synopsis
  809. fellipsis(x, y, rx, ry, ws, we, color)
  810. .nf
  811. int x, y      center coordinate
  812. int rx        x - 'radius'
  813. int ry        y - 'radius'
  814. int ws        begin angle 0..360
  815. int we        end  angle 0..360
  816. int color     line color
  817. .fi
  818. .LI description
  819. This function is much like ellipsis(), but it's faster because
  820. it uses only full angles to draw the ellipsis.
  821. Note that this function produces good results only for small radius-values.
  822. .LI also
  823. ellipsis, circle
  824. .LE
  825. .bp
  826. .H 3 "fillbox function"
  827. .VL 15
  828. .LI name
  829. fillbox
  830. .LI class
  831. medium-level
  832. .LI synopsis
  833. fillbox(x1, y1, x2, y2, color);
  834. .nf
  835. int x1, y1;            upper left corner
  836. int x2, y2;            lower right corner
  837. int color;             fill color
  838. .fi
  839. .LI description
  840. This function fills a given box with the specified color.
  841. The box is specified through the upper left (x1, y1) and
  842. the lower right (x2, y2) corner.
  843. This function is the counterpart to box, which draws the
  844. border.
  845. .LE
  846. .bp
  847. .H 3 "getpixel function"
  848. .VL 15
  849. .LI name
  850. getpixel
  851. .LI class
  852. low-level
  853. .LI synopsis
  854. color = getpixel(x, y);
  855. .nf
  856. int x, y;    coordinate of the pixel
  857. int color;    returned color of that pixel
  858. .fi
  859. .LI description
  860. This function reads ("gets") the color of a
  861. specified pixel.
  862. .LE
  863. .bp
  864. .H 3 "grperror - print last error"
  865. .VL 15
  866. .LI name
  867. grperror
  868. .LI class
  869. medium-level
  870. .LI synopsis
  871. grperror(fil);
  872. .nf
  873. FILE *fil;      file to put error-message in (or NULL if
  874.                 to put on current display).
  875. char *msg;      error-message header text (like perror).
  876. .fi
  877. .LI description
  878. This function prints the last detected error that occurred
  879. in the graphics library.
  880. It has the ability to write to a user text file or to the
  881. current graphics screen. Writing to a file may be useful
  882. for not destroying your graphics display. You chose between
  883. this both modes by your file pointer: if it is NULL, the
  884. function writes to the display, otherwise it uses your file
  885. pointer to write to that file.
  886. No write errors are reported.
  887. The function writes first the user-specified message, than
  888. the internal error-message.
  889. .LE
  890. .bp
  891. .H 3 "gt_backw function"
  892. .VL 15
  893. .LI name
  894. gt_backw
  895. .LI class
  896. high-level
  897. .LI synopsis
  898. gt_backw(count)
  899. .nf
  900. int count;      count to move backward
  901. .fi
  902. .LI description
  903. This function is the opposite to function gt_forwd.
  904. It moves the turtle the specified position in backward
  905. direction.
  906. .LI see also
  907. gt_forwd
  908. .LE
  909. .bp
  910. .H 3 "gt_dir function"
  911. .VL 15
  912. .LI name
  913. gt_dir
  914. .LI class
  915. high-level
  916. .LI synopsis
  917. gt_dir(degrees);
  918. .nf
  919. int degrees;      new turtle direction in degrees.
  920. .fi
  921. .LI description
  922. This function sets the absolute turtle direction in
  923. degrees for further moves.
  924. If the value contained in
  925. "degrees" is invalid, it will be converted into the
  926. range 0..359. Negative degrees will be correctly converted
  927. to their positive counterpart.
  928. .LI see also
  929. gt_tleft, gt_trgth
  930. .LE
  931. .bp
  932. .H 3 "gt_forwd function"
  933. .VL 15
  934. .LI name
  935. gt_forwd
  936. .LI class
  937. high-level
  938. .LI synopsis
  939. gt_forwd(count)
  940. .nf
  941. int count;      count to move forward
  942. .fi
  943. .LI description
  944. This function moves the turtle forward the specified count
  945. of 'logical' pixel (or backward, if negative).
  946. .LI see also
  947. gt_backw
  948. .LE
  949. .bp
  950. .H 3 "gt_hide function"
  951. .VL 15
  952. .LI name
  953. gt_hide
  954. .LI class
  955. high-level
  956. .LI synopsis
  957. gt_hide();
  958. .LI description
  959. The turtle isn't shown after drawing operations if
  960. this function is called.
  961. .LE
  962. .bp
  963. .H 3 "gt_home function"
  964. .VL 15
  965. .LI name
  966. gt_home
  967. .LI class
  968. high-level
  969. .LI synopsis
  970. gt_home();
  971. .LI description
  972. This function sets the turtle to the home position.
  973. After this function call, the turtle will be located
  974. at (0,0) (middle of screen) and points in upward direction.
  975. .LE
  976. .bp
  977. .H 3 "gt_init function"
  978. .VL 15
  979. .LI name
  980. gt_init
  981. .LI class
  982. high-level
  983. .LI synopsis
  984. gt_init();
  985. .LI description
  986. This function initializes the turtle-graphics package.
  987. It clears the graphics screen and initializes the global
  988. to local coordinate system with the default turtle window
  989. size. All turtle parameters are reset to their defaults,
  990. which are as follows:
  991. .sp 1
  992. .DS
  993. - turtle position                    (0,0)
  994. - turtle direction                    0
  995. - turtle visible                      no
  996. - turtle delay                        none
  997. - turtle window                       -400,200,400,-200
  998. - turtle pen up                       no
  999. - turtle pen color                    1
  1000. .DE
  1001. .sp 1
  1002. Note: This function MUST be called before any other turtle
  1003. graphics function. If it's not called, the other function
  1004. may crash. This function MAY be called at any time to reset
  1005. the turtle graphics system.
  1006. .LE
  1007. .bp
  1008. .H 3 "gt_pcolr function"
  1009. .VL 15
  1010. .LI name
  1011. gt_pcolr
  1012. .LI class
  1013. high-level
  1014. .LI synopsis
  1015. gt_pcolr(color);
  1016. .nf
  1017. color;        new pen color
  1018. .fi
  1019. .LI description
  1020. This function sets the turtle pen color. All further
  1021. drawing will use the specified color.
  1022. .sp 1
  1023. Note: The pen status is not modified, so if the pen is lift up,
  1024. no drawing will take place.
  1025. .LE
  1026. .bp
  1027. .H 3 "gt_pendn function"
  1028. .VL 15
  1029. .LI name
  1030. gt_pendn
  1031. .LI class
  1032. high-level
  1033. .LI synopsis
  1034. gt_pendn();
  1035. .LI description
  1036. This function lifts the turtle pen down, so that a line
  1037. will be drawn by further movements. The pen may be lift
  1038. up by function gt_penup.
  1039. .LI note
  1040. It is not reported as error, if the function is called
  1041. while the turtle pen is already lift down.
  1042. .LI see also
  1043. gt_penup
  1044. .LE
  1045. .bp
  1046. .H 3 "gt_penup function"
  1047. .VL 15
  1048. .LI name
  1049. gt_penup
  1050. .LI class
  1051. high-level
  1052. .LI synopsis
  1053. gt_penup();
  1054. .LI description
  1055. This function lifts the turtle pen up, so that no line
  1056. will be drawn by further movements. The pen may be lift
  1057. down by function gt_pendn.
  1058. .LI note
  1059. It is not reported as error, if the function is called
  1060. while the turtle pen is already lift up.
  1061. .LI see also
  1062. gt_pendn
  1063. .LE
  1064. .bp
  1065. .H 3 "gt_setco function"
  1066. .VL 15
  1067. .LI name
  1068. gt_setco
  1069. .LI class
  1070. high-level
  1071. .LI synopsis
  1072. gt_setco(x, y);
  1073. .nf
  1074. int x,y;     new turtle coordinates.
  1075. .fi
  1076. .LI description
  1077. This function sets the turtle to the given position. The
  1078. position is a turtle graphics coordinate. No line is draw
  1079. while repositioning the turtle.
  1080. .LE
  1081. .bp
  1082. .H 3 "gt_show function"
  1083. .VL 15
  1084. .LI name
  1085. gt_show
  1086. .LI class
  1087. high-level
  1088. .LI synopsis
  1089. gt_show();
  1090. .LI description
  1091. The turtle is shown after each drawing operation if
  1092. this function is called.
  1093. .LE
  1094. .bp
  1095. .H 3 "gt_tleft function"
  1096. .VL 15
  1097. .LI name
  1098. gt_tleft
  1099. .LI class
  1100. high-level
  1101. .LI synopsis
  1102. gt_tleft(degrees);
  1103. .nf
  1104. int degrees;      turtle rotate count in degrees
  1105. .fi
  1106. .LI description
  1107. This function rotates the turtle in left direction, using
  1108. the rotate count specified in degrees. Negative counts mean
  1109. rotate to right position.
  1110. .LI see also
  1111. gt_trght, gt_dir
  1112. .LE
  1113. .bp
  1114. .H 3 "gt_trght function"
  1115. .VL 15
  1116. .LI name
  1117. gt_trght
  1118. .LI class
  1119. high-level
  1120. .LI synopsis
  1121. gt_tleft(degrees);
  1122. .nf
  1123. int degrees;      turtle rotate count in degrees
  1124. .fi
  1125. .LI description
  1126. This function rotates the turtle in right direction, using
  1127. the rotate count specified in degrees. Negative counts mean
  1128. rotate to left position.
  1129. .LI see also
  1130. gt_dir, gt_tleft
  1131. .LE
  1132. .bp
  1133. .H 3 "gt_usrmv function"
  1134. .VL 15
  1135. .LI name
  1136. gt_usrmv
  1137. .LI class
  1138. high-level
  1139. .LI synopsis
  1140. gt_usrmv(speedtab);
  1141. .nf
  1142. int *speedtab;      speed table for moves.
  1143. .fi
  1144. .LI description
  1145. This function allows it the program to give the user control over turtle
  1146. movement.
  1147. The function accepts single keystroke commands.
  1148. The commands are not echoed.
  1149. The caller may supply a table of speed values for each
  1150. supported speed (0 .. 9). This table consists of 10
  1151. int-type entries, which holds the movement entity in the
  1152. selected speed. If the user wishes to use the default
  1153. speed table, he must supply a NULL pointer.
  1154. Commands available:
  1155. .DS
  1156. 0 .. 9 : select turtle speed.
  1157. n      : turtle direction north
  1158. e      : turtle direction east
  1159. w      : turtle direction west
  1160. s      : turtle direction south
  1161. h      : home turtle
  1162. b      : move turtle backward
  1163. f      : move turtle forward
  1164. l      : turn turtle left 1 degree
  1165. L      : turn turtle left 5 degrees
  1166. r      : turn turtle right 1 degree
  1167. R      : turn turtle right 5 degrees
  1168. g      : go, change no direction
  1169. q      : quit this function
  1170. .DE
  1171. .sp 1
  1172. Note: The turtle system must be initialized before calling this
  1173. function. The current state of the turtle system is not
  1174. altered before execution, so all parameters are as set by
  1175. you.
  1176. .LE
  1177. .bp
  1178. .H 3 "gtgetdir function"
  1179. .VL 15
  1180. .LI name
  1181. gtgetdir
  1182. .LI class
  1183. high-level
  1184. .LI synopsis
  1185. degrees = gtgetdir();
  1186. .nf
  1187. int degrees;      current turtle direction in degrees.
  1188. .fi
  1189. .LI description
  1190. This function returns the current turtle position in degrees.
  1191. The returned value will be in range 0 .. 359.
  1192. .LE
  1193. .bp
  1194. .H 3 "Line function"
  1195. .VL 15
  1196. .LI name
  1197. line
  1198. .LI class
  1199. medium-level
  1200. .LI synopsis
  1201. line(x1, y1, x2, y2, color);
  1202. .nf
  1203. int x1, y1;            starting coordinate
  1204. int x2, y2;            ending coordinate
  1205. int color;             line color
  1206. .fi
  1207. .LI description
  1208. This function draws a line of "color" between the
  1209. starting (x1, y1) and ending (x2, y2) coordinate.
  1210. .LE
  1211. .bp
  1212. .H 3 "paint function"
  1213. .VL 15
  1214. .LI name
  1215. paint
  1216. .LI class
  1217. medium-level
  1218. .LI synopsis
  1219. paint(x, y, paintclr, border)
  1220. .nf
  1221. int x, y;       coordinate of a point within the area
  1222. int paintclr;   the color used to paint
  1223. int border;     is the color of the border defining the
  1224.                 area
  1225. .fi
  1226. .LI description
  1227. This function paints an area. The area is defined by a
  1228. border of a specified color ("border") and the coordinate
  1229. of one pixel within the area (x, y). The color used to
  1230. paint is given in "paintclr".
  1231. This function uses several subroutines and a recursive
  1232. algorithm! It's only the "initializer", the main work is
  1233. performed by the other Routines.
  1234. .LE
  1235. .bp
  1236. .H 3 "polyline function - draw complex lines"
  1237. This function may be used to draw charts or complex geometric figures.
  1238. .VL 15
  1239. .LI name
  1240. polyline
  1241. .LI class
  1242. medium-level
  1243. .LI synopsis
  1244. ret = polyline(color, coords, ...)
  1245. .nf
  1246. int ret;     0 on success, -1 otherwise.
  1247. int color    color of the line
  1248. int coords   coordinate list (x, y), ends with -1, -1
  1249. .fi
  1250. .LI description
  1251. This function draws a polyline. That means a line, which
  1252. is made of multiple coordinates. You supply as many
  1253. coordinates as you need to describe the line in an integer
  1254. array. They must be in (x,y) order. The end of the coordinate
  1255. list is indicated by the coordinate pair (-1,-1).
  1256. The function starts now at the first coordinate and draws a
  1257. line from this point to the second coordinate. From there it
  1258. draws a line to the third coordinate and so on, until the end
  1259. of coordinate list is reached. If the coordinate list is in-
  1260. valid, the function returns a true (-1) result, otherwise
  1261. it returns false (0). In case of an error return the graphics
  1262. error variable may be examined.
  1263. The line is drawn in color "color".
  1264. .LE
  1265. .bp
  1266. .H 3 "print screen function - hardcopy"
  1267. This function allows a program-controlled hardcopy of the current graphics
  1268. page. 
  1269. .sp 1
  1270. Warning: currently only available for the hercules graphics card!
  1271. .VL 15
  1272. .LI name
  1273. prtgraf
  1274. .LI class
  1275. medium-level
  1276. .LI synopsis
  1277. ret = prtgraf();
  1278. .nf
  1279. int ret;      0 if successful, -1 otherwise.
  1280. .fi
  1281. .LI description
  1282. This function prints the entire graphics-screen on a
  1283. dot-matrix printer. The function was developed using a
  1284. NEC P6 printer, but should run with little alteration on
  1285. every EPSON compatible printer.
  1286. The function return 0 if successful, -1 if not. In case
  1287. of an error return the error system holds an extended
  1288. or code.
  1289. .LE
  1290. .bp
  1291. .H 3 "putmsg - complex text output function"
  1292. .VL 15
  1293. .LI name
  1294. putmsg
  1295. .LI class
  1296. medium-level
  1297. .LI synopsis
  1298. putmsg(x, y, foreg, backg, string, font, mode);
  1299. .nf
  1300. int x, y;            starting coordinate (upper left corner)
  1301. int foreg;           foreground color
  1302. int backg;           background color
  1303. char *string;        string to draw
  1304. int font;            font-number to use
  1305. int mode;            output mode (font modifier)
  1306. .fi
  1307. .LI description
  1308. This function draws the string pointed to by "string" on the
  1309. graphics screen. The string must be \0-terminated. Drawing
  1310. begins at x,y, which is the upper left corner of the first
  1311. character in the string. The characters are painted in color
  1312. foreg, the character-background is painted in color backg.
  1313. The font to use must be specified in font. Currently only
  1314. STDFONT is supported. Field mode contains the string output
  1315. mode, which is a font modifier. This field may be used to
  1316. select italics or other output modes. Currently only
  1317. OM_NORM, OM_ITAL and OM_RITAL are supported.
  1318. .LE
  1319. .bp
  1320. .H 3 "setgloco function"
  1321. .VL 15
  1322. .LI name
  1323. setgloco
  1324. .LI class
  1325. medium-level
  1326. .LI synopsis
  1327. setgloco(x_beg, y_beg, x_end, y_end)
  1328. .nf
  1329. float x_beg, y_beg    minimum coordinates values
  1330. float x_end, y_end    maximum coordinates values
  1331. .fi
  1332. .LI description
  1333. This function initializes the global/local coordinate
  1334. system. This system allows you to address your pixels
  1335. based on a global coordinate system. This system is
  1336. independent from the hardware coordinate system. Global
  1337. coordinates may be converted to local coordinates,
  1338. which are to be used to address the hardware.
  1339. So your application hasn't to look at the present video
  1340. hardware but use always a hardware independent own
  1341. coordinate system.
  1342. In addition you may use floats, not only integers as
  1343. coordinates. This is a great advantage in numerical
  1344. applications.
  1345. .LI warning
  1346. This function initializes the system, so any call to the
  1347. convert routines will return garbage, until this function
  1348. is called!
  1349. .LE
  1350. .bp
  1351. .H 3 "setpixel function"
  1352. .VL 15
  1353. .LI name
  1354. setpixel
  1355. .LI class
  1356. low-level, old call, compatibility class
  1357. .LI synopsis
  1358. setpixel(x, y, color);
  1359. .nf
  1360. int x, y;    coordinate of the pixel
  1361. int color;    pixel-color
  1362. .fi
  1363. .LI description
  1364. This function sets a pixel of color "color" at
  1365. the specified coordinate.
  1366. .LI warning
  1367. This function is superseded by function wrtpixel.
  1368. It's included mainly for compatibility reasons.
  1369. It does not \fInot\fP support the graphics write mode.
  1370. Do not use this function call, if you do not absolutely need backward
  1371. compatibility to version 1.1 of the library!
  1372. .LE
  1373. .bp
  1374. .H 3 "setwm function"
  1375. .VL 15
  1376. .LI name
  1377. setwm
  1378. .LI class
  1379. medium-level
  1380. .LI synopsis
  1381. setwm(mode);
  1382. .nf
  1383. WRITEMOD mode;            new write mode
  1384. .fi
  1385. .LI description
  1386. This function sets the library write mode. All write
  1387. operations are performed in respect to the current
  1388. write mode.
  1389. For a list of currently supported write modes see the
  1390. definition of WRITEMOD in graphics.h!
  1391. .LE
  1392. .bp
  1393. .H 3 "wrtpixel function"
  1394. .VL 15
  1395. .LI name
  1396. wrtpixel
  1397. .LI class
  1398. medium-level
  1399. .LI synopsis
  1400. wrtpixel(x, y, color);
  1401. .nf
  1402. int x, y;              pixel coordinate
  1403. int color;             pixel color
  1404. .fi
  1405. .LI description
  1406. This function sets a pixel in the given color at the
  1407. specified coordinate. The pixel is set in respect to
  1408. the current write mode.
  1409. .LE
  1410. .H 2 "Linking using object files or librarys"
  1411. There are two ways to link the graphics routines into your program.
  1412. The first were described above: You may use the librarys build during the
  1413. installation process.
  1414. Then you have only to alter your link-batchfiles, the rest is automatic.
  1415. This is normally the best method.
  1416. But this method has the disadvantage of including the librarys in every
  1417. of your link-sessions. 
  1418. This needs time (especially on floppy-based systems).
  1419. So, if you only need the libraries in a few programs, you may think that
  1420. this way isn't the right.
  1421. .sp 1
  1422. Then you may use the second method: You may not only specify the libraries,
  1423. you also may specify the routines as stand-alone objects.
  1424. So link only the object files in your program.
  1425. You have to name the files each link-session (or construct a short batch-file).
  1426. Please remember, that there are low, medium and high level routines.
  1427. You have to include all of them in the link-process.
  1428. .br
  1429. Here is a sample link-call using the std. Lattice link-files and the hercules
  1430. low-level driver:
  1431. .br
  1432. LINKMS your-program +graf+herc+herca
  1433. .br
  1434. Note that you do not always have to include three object files. 
  1435. The standard BIOS driver, for example, has only one low-level object file,
  1436. because the complete low-level handling can be done in C.
  1437. However, I think there will be mostly two low-level drivers.
  1438. .br
  1439. You may specify the object-file names at any position, the above given is only
  1440. one possible specification.
  1441. You must only link your main program first, because this is the name Lattice
  1442. uses for the .EXE file.
  1443. .sp 1
  1444. Caution: The general medium-level driver must be compiled separately for each
  1445. low-level device (as stated above).
  1446. So you have to use different medium-level object files. 
  1447. Using wrong medium-level drivers may cause link errors and/or program crashes!
  1448. .H 1 "Customization of the library"
  1449. This section contains information about how to customize the library to
  1450. your specific needs.
  1451. .sp 1
  1452. In general the library is unmodified usable, though the this version may
  1453. not the best for your needs.
  1454. In order to make the library more useful, there is a facility to change
  1455. the behaviour of the library with only a few configuration parameters.
  1456. This parameters are contained in file "graphics.h".
  1457. By setting this parameters to new values, you can create a version that's
  1458. more special to your needs, without completely modifying the library.
  1459. .sp 1
  1460. This facility should allow you to configure many library features to your
  1461. needs, although it is not as powerful as really modifying library source
  1462. code.
  1463. But I think it will be powerful enough for most purposes.
  1464. .sp 1
  1465. The configuration parameters are explained in the top part of "graphics.h".
  1466. For a detailed description of configuration changes see this file.
  1467. .sp 1
  1468. Note: after changing configuration parameters,
  1469. \fBthe whole library must be recompiled\fP!
  1470. .H 1 "Modifying the library"
  1471. If the above described way of customizing the library is not powerful
  1472. enough for your needs, or if you plan to port the library to a new
  1473. environment, the information needed therefore is contained in this chapter.
  1474. .sp 1
  1475. But be aware of the fact, that modifying the library requires working
  1476. knowledge of the C programming language and porting the library requires
  1477. good knowledge of the target machine.
  1478. If you do not fulfill the above requirements, ask someone else for help or
  1479. you can become frustrated!
  1480. .sp 1
  1481. The following sections contain information about the internal implementation
  1482. and general philosophy of this library.
  1483. If you modify the library,
  1484. please don't violate the basic concepts,
  1485. .FS
  1486. like the high-, medium and low-level driver concept
  1487. .FE
  1488. because such violations will cause problems with newer releases.
  1489. It also would be fine, if you not only extend or port the library, but also
  1490. update this manual.
  1491. If you use new or significant faster algorithms, please notify the author,
  1492. so he can make these changes common to all users and include them in further
  1493. developments and enhancements.
  1494. In either case, please inform the author of bugs.
  1495. The will be fixed as fast as possible (if you developed a fix, please send it
  1496. too!).
  1497. .br
  1498. For a general overview see sections "Library design".
  1499. You should read this section before continuing here.
  1500. .H 2 "Basic rules"
  1501. This section points out the basic rules for modifying the library.
  1502. NEVER violate these rules, otherwise you can not be sure to move to new levels
  1503. of the library without problems.
  1504. Coding, which violates these rules, isn't accepted nor enhanced by the author.
  1505. .br
  1506. I think these rules are so basic software-engeneering rules that I can point
  1507. out them for short.
  1508. .AL
  1509. .LI
  1510. Never use compiler-specific features. This is the dead for portability!
  1511. .LI
  1512. Never use undocumented routines.
  1513. They may be removed or modifyed without notice.
  1514. .LI
  1515. Use only the documented interfaces.
  1516. Static variables only contain useful information, if such is guaranteed!
  1517. .LI
  1518. Never change the documented interface of a function.
  1519. .br
  1520. You would destroy portability.
  1521. If you add new functionality to a procedure, which requires a new parameter,
  1522. use a different function call name.
  1523. You may internally call the old function to avoid duplicate coding.
  1524. .FS
  1525. or use sub-subroutines
  1526. .FE
  1527. .LI
  1528. Never introduce a routine which is hardware-specific.
  1529. Use at least a pseudo-hardware-independent function, as stated above.
  1530. But do use such functions only if absolutely necessary and it is supported
  1531. by most video-devices (I think at least 75%).
  1532. Remember, that
  1533. one goal of the library was the portability on a wide range of machines.
  1534. So there have to be as less as possible hardware-dependent functions.
  1535. .br
  1536. You may use hardware-dependent functions internal, but they should not 
  1537. be documented as legal functions.
  1538. .LI
  1539. You should try to implement new features in the hardware-independent,
  1540. high- or
  1541. medium-level part of the library.
  1542. So porting this function to a new environment isn't painful.
  1543. .LI
  1544. Never implement hardware-dependent functions in the high- or medium-level part.
  1545. .br
  1546. If you introduce a hardware-dependent function, which is common to many video
  1547. devices (and may be emulated by the others), put this in the low-level parts.
  1548. This makes implementation of the library more visible.
  1549. In addition, ones who want to port the library to new devices can be sure,
  1550. that they must not modify the high- and medium-level part.
  1551. .LI
  1552. You may modify parts of the medium-level routines to call some hardware-specific
  1553. routines
  1554. .FS
  1555. which are then implemented in the low-level part
  1556. .FE
  1557. if, and only if, there is also a implementation of the same thing using the
  1558. standard read/write pixel interface.
  1559. You have to use conditional compilation to activate your coding for a special
  1560. video-device.
  1561. .br
  1562. Such an implementation makes sense, if you can reduce the runtime
  1563. significantly.
  1564. An example for this is the EGA device.
  1565. .LI
  1566. Always document a new function or function enhancement.
  1567. Use the standard function header
  1568. .FS
  1569. See the library sources for an example.
  1570. .FE
  1571. in your source to document a new function.
  1572. If you port the library to a new operating system, compiler or video device,
  1573. please complete the information in the header page of this document.
  1574. .H 2 "Library Modes"
  1575. The graphics header-files are included in both user and
  1576. library programs.
  1577. However, these files have to do different jobs in each case.
  1578. In order to simplify maintenance, the header files contain information to
  1579. do all jobs correctly.
  1580. The current job is selected via the library mode preprocessor variable
  1581. LIB_MODE.
  1582. This variable has to be defined before #including the graphics header
  1583. files.
  1584. .sp 1
  1585. This variable may hold different values, thus selecting different coding in
  1586. the header-files.
  1587. Currently modes 0, 1 and 2 are defined, but new can be added on demand.
  1588. .VL 8
  1589. .LI mode~0
  1590. is the user mode.
  1591. It is also set if LIB_MODE isn't defined.
  1592. In mode 0 all library internal features are disabled.
  1593. .LI mode~1
  1594. is the primary library mode.
  1595. All internal features are enabled, but library variables are declared to
  1596. be external.
  1597. .LI mode~2
  1598. is much like mode 1, except that the library variables will be allocated.
  1599. So this mode can only be set in one module.
  1600. This module is called the master module, because it allocates the whole
  1601. library external data space.
  1602. .LE
  1603. .H 2 "Function sets"
  1604. The medium-level library part contains two function sets.
  1605. The function set are almost identical in the calling sequence.
  1606. This two sets are introduced by the write mode system.
  1607. Generally drawing is done in normal write mode, what means directly with
  1608. the user-specified color.
  1609. But if it's done in one of the other modes, the color must first selected
  1610. according to the user-specified color and the previous contents of the
  1611. display buffer.
  1612. Thus the second approach is much more time consuming, even because some
  1613. optimizations can't be applied to write modes other than normal.
  1614. .sp 1
  1615. So most functions have two forms: one very fast, strictly optimized normal
  1616. write mode version, and one more general but also slower all write modes
  1617. function.
  1618. This design is completely invisible to the user program, because the user
  1619. program always calls the fast alternative and this function switches to its
  1620. slower pendant if needed.
  1621. .sp 1
  1622. Note that this approach is unique to the medium-level library part.
  1623. If you plan to extend this part you have to know, that there is a function
  1624. which supports write-mode applications.
  1625. It's function sel_color(), which automatically selects the drawing color
  1626. for the pixel it is called for.
  1627. Note that this function will be included in \fIall\fP further releases and
  1628. so it's save to use it.
  1629. It's not documented because it's invisible to user programs.
  1630. For the calling sequence look at the source code function header in file
  1631. graf.c.
  1632. .H 2 "Modifying High-Level Parts"
  1633. The high-level library part has to be completely hardware independent.
  1634. So no calls to hardware specific routines or other hardware specific
  1635. features can be included.
  1636. Do only use the documented interfaces of the medium- and low-level library
  1637. parts.
  1638. Always remember, that the lower level parts will be dynamically loadable in
  1639. the future.
  1640. .sp 1
  1641. I think that the high-level library part will be the least part modified.
  1642. I also think such modifications make only sense in case of bug fixes and
  1643. functionality enhancements.
  1644. .H 2 "Modifying medium-level parts"
  1645. The medium-level library parts should be hardware-INdependent.
  1646. Though, you may include some special hardware-calls if you use conditional
  1647. compilation.
  1648. .FS
  1649. #if(?) ... #else ... #endif
  1650. .FE
  1651. This way may be chosen, if the performance may grew rapidly.
  1652. However, if you use this way, implement the hardware-dependent parts as calls
  1653. to low-level routines performing the job.
  1654. Also there must be always a routine implemented, which only uses the basic
  1655. low-level routines for reading and writing a pixel.
  1656. This guarantees portability.
  1657. .br
  1658. All #define's, which are common to almost every video-device should be done
  1659. in the medium-level header file (same as the high-level header file).
  1660. There should also all documented functions be prototyped.
  1661. Please use conditional compilation, if you use newer language features like
  1662. void or enum, so these constructs can be easily commented out.
  1663. Use different names for each new feature, because some compiler implement
  1664. part of this new features.
  1665. They should be used if possible.
  1666. Note that the word USE_VOID e. g. is currently in use by the library to
  1667. implement the void keyword.
  1668. .br
  1669. Whatever you do, keep in mind that the medium-level part should be as portable
  1670. and hardware-independent as possible.
  1671. But you should also remember, that the medium-level part must be recompiled 
  1672. for each low-level driver...
  1673. .H 2 "Modifying low-level parts"
  1674. You may modify everything except the few documented and guaranteed
  1675. function-interfaces.
  1676. But you should try to implement as much coding as possible in C, because
  1677. you may use parts of existing low-level drivers or others may use your
  1678. drivers to implement another video-device.
  1679. Also a port of existing drivers to another operating system may be simpler,
  1680. if the driver is written nearly complete in C.
  1681. .br
  1682. You should use low-level routines only if it's impossible to do the same with
  1683. medium-level routines (or to get a much better performance).
  1684. Please let your low level-routine communicate with the medium-level routine only
  1685. by using strictly defined interfaces.
  1686. .br
  1687. Do not introduce a low-level routine for common usage, if it can't be
  1688. implemented on almost every video-device!
  1689. .H 2 "Modifying header files"
  1690. Header files play a very important part in the library design - so do not
  1691. forget them.
  1692. Every new high- or medium-level routine or definition should be added to the
  1693. ONE AND ONLY medium-level header file "graphics.h".
  1694. Do not add a second or third high/medium-level Header file!
  1695. Put a device-id in every low-level header file (HERCGRAF is an example).
  1696. So the medium-level routine knows which is the current low-level driver and may
  1697. activate different coding.
  1698. It may also be of interest for the user-program to know which video-device is
  1699. active.
  1700. .H 1 "Development environment"
  1701. It may be interested for you to here something about my development
  1702. environment.
  1703. The library were implemented on 2 IBM-AT's.
  1704. One is equipped with a hercules-compatible monochrome graphics card, one with
  1705. the Quad-EGA and a monochrome display.
  1706. So there could be no development done for color-graphics, but I think the
  1707. EGA-routines will run using color-graphics, too.
  1708. One AT is equipped with 2.5Mb, one with 512Kb memory, both without 80287.
  1709. Both are running under PC_DOS 3.1 (German version), one under XENIX,
  1710. and one under Mikroport's Unix System V.
  1711. There were some resident programs loaded.
  1712. .br
  1713. The software environment consist of the sh and related utilities by Allen
  1714. Holub,
  1715. .FS
  1716. , which are really great!!!!
  1717. .FE
  1718. the Lattice, Datalight, Datalight optimizing and Borland's Turbo C compiler
  1719. and Microsoft MASM 4.0 and related products.
  1720. The files were edited using the Turbo Pascal editor.
  1721. This document was edited under UNIX, using vi, nroff and the mm macro
  1722. package.
  1723. My (new) own AT is the one equipped with 2.5Mb, no 80287 and the Quad-EGA.
  1724. I currently own the sh and utilities, the Datalight, Datalight optimizing
  1725. and Borland's Turbo~C compiler, the
  1726. Blaise runoff formatter and the standard IBM PC linker.
  1727. I also own the PC/vi editor, which is really great, and Mr. Holub's nr text
  1728. formatter, which is much better than the Runoff formatter (and much less
  1729. expensive!).
  1730. The system is also equipped with Hersey Mikro Consultings Fansi-Console,
  1731. which greatly speeds up consol writing, but unfortunately needs a lot of
  1732. memory (50 Kb from small 640 Kb DOS memory).
  1733. And I'm running Microport's UNIX System V-AT since one month.
  1734. .br
  1735. Now think about new features, which can be developed with this environment...
  1736. .H 1 "Future enhancements"
  1737. This chapter list the current and planed developments, which will be made
  1738. available in the future.
  1739. In addition to these points I want to get some feedback from you, resulting in
  1740. a better and better library.
  1741. This feedback may be in form of new ideas, algorithms and, of course, critic.
  1742. I really love to hear your comments, because I myself cover only a little span
  1743. of potential applications, so my library will always be restricted, until you
  1744. send my new ideas.
  1745. .SP 1
  1746. But enough of the feedback, here are the facts about future enhancements:
  1747. .DL
  1748. .LI
  1749. First of all, the high-level library part will be greatly enhanced.
  1750. I hope I can implement many useful high-level functions in the near future.
  1751. This will include a metafile system and related plotter drivers (have you
  1752. seen the new plotter entry in the heading page?).
  1753. .LI
  1754. text output
  1755. .br
  1756. will be advanced.
  1757. .br
  1758. The current text-output function only supports a limited functionality.
  1759. This functionality will be greatly enhanced. More style-modifiers and 
  1760. loadable character sets will be implemented.
  1761. Also a font-editor may come with the next release.
  1762. .LI
  1763. virtual graphics pages will be implemented
  1764. .br
  1765. These implementation of virtual pages will base on a hardware-independent
  1766. algorithm, so that multiple display pages will also be available on devices
  1767. which not directly support them.
  1768. In addition, because graphics need a lot of memory, which is not available
  1769. at some systems, the library will implement an algorithm, which is able to
  1770. use mass-storage for inactive pages (virtual memory management).
  1771. .LI
  1772. I try to port the library to the UNIX operating system
  1773. .br
  1774. I'm not sure, that these port will be successful in the end.
  1775. I'm not very similar with the UNIX operating system, nor with graphics
  1776. programming using UNIX and, of course, graphics terminals.
  1777. My first attempt to implement the library was not successful, but I learned
  1778. that an operating system like UNIX is very, very secure (so secure that
  1779. my I/O-instructions don't work).
  1780. .br
  1781. Don't misunderstand my: I really love the way UNIX goes, but I don't know
  1782. currently how to implement the library.
  1783. .br
  1784. But I also think that the port will be possible now, where I can use my own
  1785. Unix.
  1786. .sp 1
  1787. .in +10
  1788. .ll -10
  1789. .ft B
  1790. Help!
  1791. .br
  1792. If someone has some information about this job, please write me.
  1793. I would happily receive each piece of information.
  1794. .ft R
  1795. .in -10
  1796. .ll +10
  1797. .LE
  1798. .H 1 "Final observations"
  1799. At this point, thanks to all "heros", which read this whole document.
  1800. I know, my English is very bad, so I hope you excuse all the little 
  1801. (or should I better say big!?) errors in spelling and grammar.
  1802. .br
  1803. I hope my English will grew better in the future, so the documents will grew
  1804. better, too.
  1805. .sp 1
  1806. In addition, I want to thank all people which will contact my (I hope there
  1807. will be some). I also want to thank the
  1808. .ft B
  1809. C User's Group
  1810. .ft R
  1811. for distributing the library and this document.
  1812. .TC
  1813. .\ " VI : set wm=5 :
  1814.