home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / GFX < prev    next >
Encoding:
Text File  |  1994-05-29  |  6.3 KB  |  188 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    GFX.gfx.h
  12.     Author:  Copyright © 1992, 1993 Edouard Poor and Jason Williams
  13.     Version: 0.70 (30 May 1994)
  14.     Purpose: Graphics manipulation commands
  15. */
  16.  
  17.  
  18. #ifndef __dl_gfx_h
  19. #define __dl_gfx_h
  20.  
  21. /* Plot codes to be used with the GFX_Plot function. */
  22.  
  23. #define  plot_SOLIDBOTH       0x00
  24. #define  plot_SOLIDEXFINAL    0x08
  25. #define  plot_DOTTEDBOTH      0x10
  26. #define  plot_DOTTEDEXFINAL   0x18
  27. #define  plot_SOLIDEXINIT     0x20
  28. #define  plot_SOLIDEXBOTH     0x28
  29. #define  plot_DOTTEDEXINIT    0x30
  30. #define  plot_DOTTEDEXBOTH    0x38
  31. #define  plot_POINT           0x40
  32. #define  plot_HHORZLINEFILLNB 0x48
  33. #define  plot_TRIANGLEFILL    0x50
  34. #define  plot_HORIZLINEFILLB  0x58
  35. #define  plot_RECTANGLEFILL   0x60
  36. #define  plot_HORIZLINEFILLF  0x68
  37. #define  plot_PARALLELFILL    0x70
  38. #define  plot_HORIZLINEFILLNF 0x78
  39. #define  plot_FLOODTOBACK     0x80
  40. #define  plot_FLOODTOFORE     0x88
  41. #define  plot_CIRCLE          0x90
  42. #define  plot_CIRCLEFILL      0x98
  43. #define  plot_CIRCLEARC       0xA0
  44. #define  plot_SEGMENT         0xA8
  45. #define  plot_SECTOR          0xB0
  46. #define  plot_BLOCK           0xB8
  47. #define  plot_ELLIPSE         0xC0
  48. #define  plot_ELLIPSEFILL     0xC8
  49. #define  plot_GRAPHICSCHAR    0xD0
  50. #define  plot_SPRITE          0xE8
  51.  
  52. /* Within each block of eight the offset from the base number means: */
  53. #define  plot_MOVECURSORREL   0
  54. #define  plot_DRAWRELFORE     1
  55. #define  plot_DRAWRELINVERSE  2
  56. #define  plot_DRAWRELBACK     3
  57. #define  plot_MOVECURSORABS   4
  58. #define  plot_DRAWABSFORE     5
  59. #define  plot_DRAWABSINVERSE  6
  60. #define  plot_DRAWABSBACK     7
  61.  
  62.  
  63. /* The above applies except for plot_BLOCK where the codes are as follows: */
  64. #define  plot_BMOVEREL        0
  65. #define  plot_BMOVERECTREL    1
  66. #define  plot_BCOPYRECTREL    2
  67.  
  68. #define  plot_BMOVEABS        4
  69. #define  plot_BMOVERECTABS    5
  70. #define  plot_BCOPYRECTABS    6
  71.  
  72.  
  73. /*
  74.  *  GFX_Plot(PlotCode, X, Y) 
  75.  *
  76.  *    Executes one OS Plot command.
  77.  *      plotcode is the Plot code (as above)
  78.  *      x and y are the X and Y screen coordinates to use
  79.  */
  80. extern void GFX_Plot(int plotcode, int x, int y);
  81.  
  82.  
  83.  
  84. /*  GFX_ miscellaneous drawing macros ------------------------------
  85.  *
  86.  *  Below are some macros using GFX_Plot to make life easier for you.
  87.  *  the "By" form (MoveBy, etc) moves/draws relative to the current cursor
  88.  *  position, while the other form draws in absolute OS coords.
  89.  *
  90.  *  GFX_Move(X, Y)  Moves the graphics cursor to the OS co-ordinates X, Y
  91.  *  GFX_Plot(X, Y)  Plots a pixel at the specified position
  92.  *  GFX_Draw(X, Y)  Draws a line from the current cursor position to x,y
  93.  */
  94.  
  95. #define GFX_Move(x, y) GFX_Plot(plot_SOLIDBOTH + plot_MOVECURSORABS, x, y)
  96. #define GFX_MoveBy(x, y) GFX_Plot(plot_SOLIDBOTH + plot_MOVECURSORREL, x, y)
  97. #define GFX_PlotPoint(x, y) GFX_Plot(plot_POINT + plot_DRAWABSFORE, x, y)
  98. #define GFX_PlotPointBy(x, y) GFX_Plot(plot_POINT + plot_DRAWRELFORE, x, y)
  99. #define GFX_Draw(x, y) GFX_Plot(plot_SOLIDBOTH + plot_DRAWABSFORE, x, y)
  100. #define GFX_DrawBy(x, y) GFX_Plot(plot_SOLIDBOTH + plot_DRAWRELFORE, x, y)
  101.  
  102.  
  103. /*  outline/filled rectangle ---------------------------------------
  104.  *  GFX_Rectangle(x, y, width, height)     Draws a rectangle outline
  105.  *  GFX_RectangleFill(x, y, width, height  Draws a filled rectangle
  106.  */
  107. extern void GFX_Rectangle(int x, int y, int w, int h);
  108.  
  109. #define GFX_RectangleFill(x, y, w, h)                       \
  110.   {                                                         \
  111.     GFX_Move(x, y);                                         \
  112.     GFX_Plot(plot_RECTANGLEFILL + plot_DRAWRELFORE, w, h);  \
  113.   }
  114.  
  115.  
  116. /*  Circles  ------------------------------------------------------- */
  117. #define GFX_Circle(x, y, r)                                 \
  118.   {                                                         \
  119.     GFX_Move(x, y);                                         \
  120.     GFX_Plot(plot_CIRCLE + plot_DRAWRELFORE, (r), 0);       \
  121.   }
  122.  
  123. #define GFX_CircleFill(x, y, r)                             \
  124.   {                                                         \
  125.     GFX_Move(x, y);                                         \
  126.     GFX_Plot(plot_CIRCLEFILL + plot_DRAWRELFORE, (r), 0);   \
  127.   }
  128.  
  129.  
  130.  
  131. /*
  132.  *  GFX_CLG()
  133.  *
  134.  *    Clears the current graphics window to the current background colour
  135.  */
  136. extern void GFX_CLG(void);
  137.  
  138.  
  139. /*  GFX_VDU(char)
  140.  *    (An OS_WriteC veneer)
  141.  *    Writes the given ASCII character to the VDU stream
  142.  *    A macro is defined to allow use of the form VDU() as well as GFX_VDU()
  143.  */
  144. extern void GFX_VDU(char ch);
  145. #define VDU(C) GFX_VDU(C)
  146.  
  147.  
  148. /*  GFX_GCOL(action, colour)
  149.  *    Sets graphics colour and action.
  150.  *    A macro is defined to emit a VDU sequence to change graphics colours
  151.  */
  152. #define GFX_GCOL(A,C) {GFX_VDU(18); GFX_VDU(A); GFX_VDU(C);}
  153.  
  154.  
  155. /*
  156.  *  GFX_Write0(zero-terminated-string)
  157.  *    Writes the given zero-terminated string to the VDU stream
  158.  *    (veneer for SWI "OS_Write0")
  159.  */
  160. extern void GFX_Write0(char *string);
  161.  
  162.  
  163. /*
  164.  *  GFX_WriteN(string, numchars)
  165.  *    Writes 'numchars' characters from the given string to the VDU stream
  166.  *    (veneer for SWI "OS_WriteN")
  167.  */
  168. extern void GFX_WriteN(char *string, int numchars);
  169.  
  170.  
  171. /*
  172.  *  GFX_Wait()         [equivalent to WAIT, *FX 19, OS_Byte 19]
  173.  *
  174.  *    This call does not return until the vertical refresh has finished.
  175.  *    This means that you get control back after the hardware has
  176.  *    finshed updating the screen so if you do any drawing immediately
  177.  *    after this call it will be done while the screen is not being
  178.  *    drawn. This helps reduce flicker. Calling this procedure in Wimp
  179.  *    applications should be only used sparingly as overuse will slow down
  180.  *    screen output to an unacceptable level. Generally only use by
  181.  *    experimentation--write your graphics code, if it flickers too much try
  182.  *    putting in a GFX_Wait() and see if it help. If it does and the update
  183.  *    speed isn't adversly affected then leave it in.
  184.  */
  185. extern void GFX_Wait(void);
  186.  
  187. #endif
  188.