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