home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / clarion / library / pcx3 / pcx3.doc < prev    next >
Text File  |  1992-08-19  |  21KB  |  459 lines

  1.   Welcome to my graphics LEM.  Let me start off by apologizing for my inability
  2. to spell.  Also recognize that this program was written to suit the specific
  3. needs where I work and it might not do everything you want it to do.  However,
  4. I think its a very useful set of utilities for any Clarion programmer.    Any
  5. comments or suggestions will be at least concidered in subsequent releases.
  6. Note also that I hate writing documentation worse than anything.  So forgive
  7. me if I'm a little short on explanations.  Just send me a message if this
  8. document and the demos provided don't answer all your questions.
  9.  
  10.   Jay Cotton
  11.   Rt.3 Box 3184
  12.   Royston, GA 30622
  13.   (404) 542-5765
  14.  
  15.   Clarion BBS userid is KPayne
  16.  
  17.   Compuserve ID is 70761,3223
  18.  
  19.  
  20.    Version 3 changes:
  21.     -added ability to print on HP Laser Jets and Epson compatibles
  22.  
  23.     -changed mouse commands (no more GETMX(),GETMY(),GETMB())
  24.  
  25.     -new command: OUTPUT('string') sends a character string to LPT1:
  26.  
  27.     -new command: INPUT('prompt') returns user answer from text or
  28.        graphics screens
  29.  
  30.     -new commands: BLOB() and SAVEBLOB() to create and display cursors,
  31.        pointers, icons, pictures, etc. independent of screen mode
  32.  
  33.     -support for displaying 24 bit PCX pictures in grey on VGA displays
  34.  
  35.     -changed use of SETVCARD() to set EGA, VGA, SuperVGA
  36.  
  37.     -added SETVMEM() command to set super VGA memory size
  38.  
  39.     -many commands now report errors...PCX(),SETPCX(),SAVEPCX(),EPDUMP(),
  40.        HPDUMP(),SETVMODE(),SETVCARD(),SETVMEM(),SETVMONITOR(),BLOB(),
  41.        SAVEBLOB().
  42.  
  43.     -built in support for additional SuperVGA cards
  44.       3-Tseng: ET3000, EVA 1024; MicroLabs: VGA Solution; Genoa: VGA;
  45.             STB: VGA EM/16, VGA Extra/EM; Orchid: ProDesigner Plus VGA;
  46.             Quadram: QuadVGA Spectra; Sigma Designs: SigmaVGA;
  47.             Willow: VGA-TV/Publisher's
  48.       4-Tseng: ET4000, Orchid: ProDesigner II; MicroLabs: Ultimate VGA
  49.             STB: EM 16+, PowerGraph, PowerView;
  50.             Sigma Designs: SigmaVGA Legend
  51.       5-Paradise: All standard SVGA modes
  52.       6-ATI: All standard SVGA modes ... not fully tested
  53.       7-Video7: All standard SVGA modes ... not fully tested
  54.  
  55.  
  56.    First and foremost...I've put alot of work in this program and I never
  57. intend to give it away.     It is not in the public domain.  It is shareware.
  58. This means you can scope it out.  You can give copies to other people as long
  59. as they get this file with it.    You may not put it in your programs unless
  60. you pay a small fee.
  61.  
  62.    The cost of the program is $30.00 (US dollars).  I will provide a limited
  63. amount of technical support and a very reduced rate on updates.     And, in
  64. keeping with the Clarion tradition, there is no fee (beyond the normal
  65. one time registration fee) for distributing software created using PCX3.
  66.  
  67.    I put too much time in this program to provide source code for free.     If
  68. anyone is interested in purchasing the source, contact me and we can work
  69. something out.    If any dealer's are interested in marketing this LEM I will
  70. concider reasonable offers (and continue to offer service for a fee).
  71.  
  72.    The primary drive behind this program was to provide access to PCX files
  73. in ways the Clarion graphics LEM just cannot do.  This program supports all
  74. PCX formats that I have run across other than one 4 color CGA file. If you
  75. have a picture that it cannot view let me know.     It will display all 2,4,8,16
  76. color files on a 16 color EGA/VGA/SVGA screen, and all 256 color files on a
  77. 256 color VGA/SVGA screen.  It will also display 24 bit PCX pictures on VGA or
  78. SVGA screens in 64 level grey scale.
  79.  
  80.    The next reason is size.  Clarions graphic LEM while providing great
  81. graphing and statistical functions is huge.  Not everyone has 40K+ to spare.
  82. You may only need to PCX functions and my program provides them without too
  83. much overhead.    The PCX functions alone would be a valuable language extension.
  84. But I figured it needed a few drawing commands to compliment it.
  85.  
  86.   I've included a demo which is a simplified paint program.  Almost all the
  87. commands are used in this demo.     If you read the demo code, alot of your
  88. questions may be answered.  Feel free to modify the demo in any way you see
  89. fit.  View the PAINT.CLA file for instructions on how to operate the paint
  90. demo.
  91.  
  92.  
  93.   Well, here we go.  Over 40 commands to make your video card strut its stuff.
  94. One of the nice features is the user definable patterns.  These patterns
  95. are useful for drawing bar charts with combinations of colors and patterns.
  96. I'll leave it to you to write the routines to draw the graphs.
  97. Sorry, no region FILL with patterns...yet.  Only the DISC and BOX commands
  98. use the patterns.
  99.  
  100.    I would like to thank Richard Wilton and Steve Rimmer for writing the books
  101. I used for reference.  If you are interested in this type of programming
  102. these two books are excellent.
  103.  
  104. Steve Rimmer            Richard Wilton
  105. Bit-Mapped Graphics        Programmer's Guide to PC & PS/2 Video Systems
  106. 1990 Windcrest Books        1987 Microsoft Press
  107.  
  108.  
  109. ------------------------------------------------------------------------------
  110. Setup commands:
  111. ------------------------------------------------------------------------------
  112. SETVMODE(video_mode)        Selects video mode
  113. SETVCARD(video_card)        Selects type of video card
  114. SETVMONITOR(video_monitor)  Selects type of video monitor
  115. SETSVGA(svga_type)        Selects type of Super VGA card
  116.  
  117.  
  118. ------------------------------------------------------------------------------
  119. Graphics Commands:
  120. ------------------------------------------------------------------------------
  121. DOT(x,y,pal#)            Draws one dot on the screen
  122. LINE(x1,y1,x2,y2,pal#)        Draws a line from x1,y1 to x2,y2
  123. CIRCLE(x,y,w,h,pal#)        Draws a circle centered at x,y
  124. DISC(x,y,w,h,pal#)        Draws and fills a circle with current pattern
  125. FRAME(x1,y1,x2,y2,pal#)        Draws a rectangle
  126. BOX(x1,y1,x2,y2,pal#)        Draws and fills a rectangle with current pattern
  127. CLRSCREEN(pal#)            Clears screen to specified color (graphics only)
  128. SETCOLOR(pal#,r,g,b)        Change the value in a palette register
  129. FILL(x,y,pal#)            Shades a region of the screen
  130. SETPOS(x,y)            Sets current draw position
  131. DRAWTO(x,y,pal#)        Draws a line from the current position to x,y
  132. DRAW('string',pal#)        Draws a vector shape defined by string
  133. SETPATTERN(pat#,'pattern')  Create a user defined pattern
  134. USEPATTERN(pat#)        Selects current pattern
  135. BLOB(file,x,y,a)        Draws a BLOB (Binary Loaded Object Block?)
  136. SAVEBLOB(file,x1,y1,x2,y2)  Creates a BLOB from the screen data
  137.  
  138.  
  139. ------------------------------------------------------------------------------
  140. Graphics Functions:
  141. ------------------------------------------------------------------------------
  142. VMODE()        Returns current video mode
  143. WIDTH()        Returns screen width in pixels
  144. DEPTH()        Returns screen depth in pixels
  145. RED(pal#)    Returns red value of a palette register
  146. GREEN(pal#)    Returns green value of a palette register
  147. BLUE(pal#)    Returns blue value of a palette register
  148. READDOT(x,y)    Returns color (pal#) of a pixel
  149. GETX()        Returns current x coordinate
  150. GETY()        Returns current y coordinate
  151.  
  152.  
  153. ------------------------------------------------------------------------------
  154. PCX Commands:
  155. ------------------------------------------------------------------------------
  156. PCX(file)        Auto selects display mode and shows PCX file.
  157. SETPCX(file,x,y,w,d)    Places PCX picture on current screen if possible.
  158. SAVEPCX(file,x,y,w,d)    Save a portion of the screen as a PCX file.
  159.  
  160.  
  161. ------------------------------------------------------------------------------
  162. MOUSE Commands:
  163. ------------------------------------------------------------------------------
  164. MOUSEINIT        Initializes mouse
  165. MOUSEON            Turns on mouse cursor
  166. MOUSEOFF        Turns off mouse cursor
  167. SETMPOS(x,y)        Sets position of mouse cursor
  168. GETMPOS(x,y,b)        Runs BIOS routine to read mouse
  169. WINDOW(x1,y1,x2,y2)    Sets mouse movement window
  170. MSPEED()        Sets speed of mouse
  171.  
  172.  
  173. ------------------------------------------------------------------------------
  174. PRINTER Commands:
  175. ------------------------------------------------------------------------------
  176. HPDUMP(x1,y1,x2,y2,size,backgroud)    Prints graphics to HP Laser Jet
  177. EPDUMP(x1,y1,x2,y2,size,backgroud)    Prints graphics to Epson compatibles
  178. SETMATRIX('set','norm','double','quad','bump',spacing)      Sets printer codes
  179. OUTPUT('string')                        Sends 'string' to LPT1:
  180.  
  181.  
  182.  
  183.  
  184. ------------------------------------------------------------------------------
  185. Extended descriptions
  186. ------------------------------------------------------------------------------
  187. SETVCARD selects the type of video card in the computer. This value is used
  188. by the PCX command to determine the best mode to display a picture.
  189.   1 = EGA
  190.   2 = VGA *default
  191.   3 = Tseng ET3000
  192.   4 = Tseng ET4000
  193.   5 = Paradise
  194.   6 = ATI        ;not tested... Let me know it it works on your computer.
  195.   7 = Video 7        ;not tested... I don't have a way to test them.
  196.  
  197. SETVMONITOR, like SETVCARD, is used by the PCX command to determine the best
  198. video mode for a picture.
  199.   1 = EGA 640X350
  200.   2 = VGA 640X480  *default
  201.   3 = SVGA 800X600
  202.   4 = SVGA 1024X768
  203.  
  204. SETVMEM, like SETVCARD and SETVMONITOR is used by the PCX command to determine
  205. the best video mode for displaying a picture.
  206.   1 = 256K  *default  (EGA,VGA use this value)
  207.   2 = 512K
  208.   3 = 1024K
  209.  
  210.  
  211. SETMODE calls the DOS BIOS function to select a video mode.  An attempt to set
  212. a video mode not supported by your video card will return a errorcode() = 1, or
  213. error() = 'Invalid Function Number.'
  214.  
  215.   EGA or VGA modes:
  216.      3 - standard color text
  217.     13 - 320X200X16
  218.     14 - 640x200x16
  219.     16 - 640x350x16
  220.  
  221.   VGA only modes:
  222.     18 - 640x480x16
  223.     19 - 320x200x256
  224.  
  225.   SVGA modes: (uses VESA mode numbers although VESA not yet supported)
  226.     100 - 640x400x256
  227.     101 - 640x480x256
  228.     102 - 800x600x16
  229.     103 - 800x600x256
  230.     104 - 1024x768x16    -PCX only. No support for drawing commands.
  231.     105 - 1024x768x256
  232.  
  233.  
  234.  
  235. GRAPHICS COMMANDS:
  236.    Most of the graphics commands and functions use a value called "pal#."
  237. "pal#" refers to an internal palette register which holds a color. The DOS
  238. BIOS has a default set of colors for any given screen. This palette can be
  239. altered by the SETCOLOR or PCX commands. SETCOLOR changes a specific palette
  240. register, while PCX set the entire palette to that of the picture. After using
  241. the PCX command don't expect the default palette to be in effect. For example
  242. drawing with pal# = 15 might not be white (usually pal#=15 is bright white.)
  243. One more note regarding pal#...on 16 color screens, only 0-15 produce different
  244. colors, and on 256 color screens, 0-255 produce different colors. By adding
  245. 256 to any pal# on a drawing command will cause to value to be XORed on the
  246. screen. This will allow the user to remove a drawing by repeating the same
  247. command.
  248.   ex.    CIRCLE(100,100,50,50,15+256) will draw a white circle if the backgroud
  249.                      is black
  250.     CIRCLE(100,100,50,50,15+256) will erase the previous circle.
  251.    Just play with it and see what happens when you use it on backgrounds other
  252. then black.
  253.  
  254.  
  255.    DRAW is an oversimplified vector drawing routine to draw shapes on the
  256. screen.     The 'string' variable is a list of instructions on how to draw a shape.
  257. See the PAINT.CLA demo for an example of the DRAW command.
  258.     L[n]    draws to the left by 'n' pixels. 'n' is optional (2-9)
  259.     R[n]    draws to the right
  260.     U[n]    draws up
  261.     D[n]    draws down
  262.     E[n]    draws up and right
  263.     F[n]    draws right and down
  264.     G[n]    draws down and left
  265.     H[n]    draws up and left
  266.  
  267.  
  268.    SETPATTERN allows the user to define a pattern for use with BOX and DISC.
  269. The pattern is an 8 digit string containing the pixel pattern of an 8X8 cell
  270. matrix in binary format. The default pattern is 0 which is a solid fill.
  271. Valid values for pat# are 0-15.
  272.  
  273. PAT    STRING(8)
  274. PATB    BYTE,DIM(8),OVER(PAT)
  275.  
  276.     PATB[1] = 10001000b
  277.     PATB[2] = 01000100b
  278.     PATB[3] = 00100010b
  279.     PATB[4] = 00010001b
  280.     PATB[5] = 10001000b
  281.     PATB[6] = 01000100b
  282.     PATB[7] = 00100010b
  283.     PATB[8] = 00010001b
  284.     SETPATTERN(1,PAT)
  285.  
  286.    USEPATTERN selects which pattern to use on the next BOX or DISC.
  287.  
  288.  
  289.    SETCOLOR allows the user to change the red, green, and blue values of a
  290. palette register.  RED(), GREEN(), and BLUE() return the values. Values for
  291. r,g, and b are 0-63. 0 is none and 63 is full intensity.
  292.  
  293.    BLOB and SAVEBLOB are commands needed to create and display pictures or
  294. objects.  These objects can be anything from an animated cursor (See PAINT
  295. demo) to an icon.  The Paint demo can be used to draw and save these BLOBs.
  296. The demo as is will save any BLOB as 'TEMP.BLB' in the current directory. The
  297. Paint demo could be changed to allow the user to type in a name for the BLOB.
  298. To create a BLOB simply use the SAVEBLOB command with the screen coordinates
  299. of the shape to save:
  300.    SAVEBLOB('MYBLOB.BLB',100,100,120,120) ...this command will save a BLOB of
  301.                          size 21 by 21 pixels into the file
  302.                          named 'MYBLOB.BLB'.  *note the BLB
  303.                          extension is NOT required. Rather
  304.                          it is a convention like the PCX
  305.                          extension.
  306.  
  307.   To display a BLOB simply use the BLOB command and specify where and how to
  308. display the BLOB. *note that BLOBs are screen independent. This means that a
  309. BLOB created on a 320X200X256 screen will display on a 640X400X16 screen using
  310. only the first 16 colors:
  311.    BLOB('MYBLOB.BLB',50,50,0)  ...this command will display a BLOB at the
  312.                   screen coordinates 50,50 using draw mode 0.
  313.  
  314.    Draw modes for BLOB:
  315.    0- Normal  -the BLOB will replace whatever is in the screen area
  316.    1- XOR     -the BLOB will be XORed with the screen contents
  317.    2- Outline -the BLOB will replace the screen anywhere the BLOB has a
  318.            foreground (non zero) color attribute)
  319.  
  320.    The Normal mode behaves similar to the SETPCX command but with BLOBs.  Any
  321. BLOB drawn on the screen will replace the screen contents with the BLOB
  322. contents (including any blank/background area saved with the BLOB).
  323.    Using the XOR (1) mode a BLOB can be drawn and then erased by a subsequent
  324. BLOB() call using the same parameters (See the Paint demo mouse function).
  325.    The Outline (2) mode allows irregular shaped BLOBs (pointers, icons, etc) to
  326. be displayed without blacking out the square area around the BLOB.
  327.  
  328.  
  329.  
  330. MOUSE COMMANDS:
  331.    MOUSEINIT must be run before any other mouse commands.  MOUSEON and MOUSEOFF
  332. are relative commands. If MOUSEOFF is issued twice then MOUSEON must be issued
  333. twice to get the mouse back on. This way a subroutine which does something like
  334. SAVEPCX can issue MOUSEOFF at the beginning and MOUSEON at the end, and leave
  335. the mouse in the state it was before.
  336.  
  337.  
  338.    GETMPOS(x,y,b) will set the variables in the parenthesis to the mouse
  339. coordinates and button status.    IMPORTANT: the variables for x,y, and b must be
  340. declared as SHORT.
  341.  
  342. example:
  343. MOUSEX    SHORT
  344. MOUSEY    SHORT
  345. MOUSEB    SHORT
  346.  
  347.     CODE
  348.     GETMPOS(MOUSEX,MOUSEY,MOUSEB)
  349.     IF MOUSEB = 1 THEN DRAWTO(MOUSEX,MOUSEY).
  350.  
  351.  
  352.  
  353. PCX COMMANDS:
  354.   The PCX command and the SETPCX commands are used differently.     The PCX command
  355. will choose the optimal screen size and resolution based on the picture, video
  356. card, and available video memory.  2,4,8, and 16 color pictures always display
  357. on a 16 color screen.  256 color and 24 bit pictures always display on a 256
  358. color screen.  The screen size is determined by the picture size.  The PCX
  359. command will place the picture on a screen large enough to display all of the
  360. picture as long as the video mode is supported.     For example, if the picture
  361. is 800x600x256 and the user has a standard VGA card, the picture will be
  362. displayed in video mode 19 (13h). If the user has a super VGA card with 256K
  363. of video RAM the picture will be displayed on the 640x400x256 screen for that
  364. card. If the user has a super VGA card with 512K of video RAM and a monitor
  365. which can display 800x600 the picture will be displayed on the 800x600x256
  366. screen. The same picture will NOT display on an EGA display system.
  367.   The SETPCX command makes no attempt to determine a video mode.  Instead, it
  368. will display a picture on whichever screen has been selectly...if it can.  The
  369. user will first select a video mode using SETVMODE and then use the SETPCX
  370. command to place the picture.  If the picture and the video mode are not
  371. compatible the picture will not display.  For example, to display a 320x200x256
  372. picture in the upper right corner of a 640x400x256 screen:
  373.   SETVMODE(100h)
  374.   SETPCX('picture.pcx',320,0,639,199)
  375.  
  376. If the picture is not found, no action is taken and the error 'FILE NOT FOUND'
  377. will be set (check with IF ERROR() command.)  If the file is not a PCX file,
  378. no action is taken and the error 'INVALID FORMAT' is returned.    If the file is
  379. a PCX, but is corrupted, an error message will be returned and the picture may
  380. or may not be displayed (depends on extent of corruption.)
  381.  
  382.  
  383.  
  384. PRINTER COMMANDS:
  385.   Both EPDUMP (Epson dump) and HPDUMP (Hewlett Packard Dump) have a size and a
  386. background parameter.  The size parameter will tell the printer which
  387. resolution to print.
  388.   On HP printers:    size=0    300 dpi (tiny)
  389.             size=1    150 dpi (medium)
  390.             size=2     75 dpi (big)
  391.  
  392.   On Epson printers:    size=0    quad density graphics (tiny)
  393.             size=1    double density graphics (medium)
  394.             size=2    standard graphics mode (big)
  395.  
  396.   The background parameter selects the palette register to treat as the back-
  397. ground color. Normally this is 0. However, if you fill a screen with white
  398. (palette #7) and draw with black lines, you would probably want to see the
  399. output as black on white.
  400.   On 16 color screens the background# may be 0-15, on 256 color screens 0-255.
  401. Any color on the screen equal to the background# will be white; any other
  402. color will print black.
  403.   The HPDUMP command will print 16 level half-tone grey scale if the background
  404. is set to 256 or greater.  This results in a picture 4 times larger than the
  405. equivalant 2 color printout (due to a 4 by 4 half-tone pixel).    The largest
  406. picture printable is 600X800.
  407.  
  408.   EPDUMP(0,0,640,480,2,7) will print the screen to an Epson printer in standard
  409.       mode and use pal# 7 (white) as the background (not-printed) color.
  410.   HPDUMP(0,0,640,480,0,256) will print the screen to an HP printer at 300 dpi
  411.       and use 16 level half-tone grey scale.
  412.  
  413.   Both EPDUMP and HPDUMP will print the image at the current printer row, but
  414. the HPDUMP command also prints at the current print column.  To place a picture
  415. on the right side of the paper on an HP, place the cursor at the desired
  416. position before using the HPDUMP command.  Examples for HPDUMP:
  417.  
  418.   OUTPUT(ALL(' ',40))           !space the cursor 40 columns to the right
  419.   OUTPUT(CHR(13) & '          ')   !move cursor 10 spaces from left margin
  420.   OUTPUT(CHR(27) & '*p1200x1600Y') !place cursor near middle of page
  421.  
  422.   *see LaserJet user's manual for explanations and other escape sequences
  423.  
  424.   If an error occurs while printing, Clarion will usually prompt a printer
  425. message, and an error message will be returned if the user selects the option
  426. to return the error to the program.
  427.  
  428.  
  429.  
  430.   SETMATRIX allows the user to set the EPDUMP command for near Epson compatible
  431. printers: Star, Texas Instruments, IBM graphics, etc.  This command is only
  432. necessary when a printer cannot be selected as an Epson compatible.  Some
  433. printers (Panasonic, Okidata) have the ability to emulate Epsons exactly. This
  434. command will not be needed on these.  This command will not work on printers
  435. that are programmed completely differently (Okidata Pacemark, Qume, others).
  436.   Examples:
  437.      SETMATRIX('@','K','L','Z','J',24)     ! Epson (default)
  438.      SETMATRIX('@','K','Y','Z','J',24)     ! Epson (hi-speed mode 1)
  439.      SETMATRIX('@','K','L','O','3',24)     ! TI 850 (IBM graphics?)
  440.      SETMATRIX('@','K','y','z','J',16)     ! Star NX10
  441.  
  442.  
  443.   INPUT allows the program to prompt the user for a response on text or
  444. graphics screens.  The 'prompt' parameter will be displayed on the screen and
  445. the command will wait for input from the user.
  446.   Example:
  447.       SETCURSOR(10,10)                ;place the cursor
  448.       file = INPUT('Enter file to load: ')  ;ask for user input
  449.       PCX(file)                    ;display a picture
  450.  
  451.  
  452.   OUTPUT allows the user to send any character string to the printer.  Font
  453. codes, setup strings, special graphic commands, and regular test can be sent
  454. to LPT1.
  455.   Example:
  456.       OUTPUT('E')    !sends reset command to an HP laser printer (Esc + 'E')
  457.               !Hold down the Alt key while typing '27' to get the Esc
  458.  
  459.