home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / GRAPHICS.E < prev    next >
Text File  |  1993-06-18  |  4KB  |  171 lines

  1.   -------------------------------------
  2.   -- graphics & sound: MSDOS version --
  3.   -------------------------------------
  4.  
  5. -- machine() commands
  6. constant SOUND          = 1,
  7.      LINE           = 2, 
  8.      PALETTE        = 3,
  9.      PIXEL          = 4,
  10.      GRAPHICS_MODE  = 5,
  11.      CURSOR         = 6,
  12.      WRAP           = 7,
  13.      SCROLL         = 8,
  14.      SET_T_COLOR    = 9,
  15.      SET_B_COLOR    =10,
  16.      POLYGON        =11,
  17.      TEXTROWS       =12,
  18.      VIDEO_CONFIG   =13
  19.  
  20. -- graphics modes: argument to graphics_mode()
  21. --    0  40 x 25 text, 16 grey
  22. --    1  40 x 25 text, 16/8 color
  23. --    2  80 x 25 text, 16 grey
  24. --    3  80 x 25 text, 16/8 color
  25. --    4  320 x 200, 4 color
  26. --    5  320 x 200, 4 grey
  27. --    6  640 x 200, BW
  28. --    7  80 x 25 text, BW
  29. --   11  720 x 350, BW 
  30. --   13  320 x 200, 16 color 
  31. --   14  640 x 200, 16 color
  32. --   15  640 x 350, BW
  33. --   16  640 x 350, 4 or 16 color 
  34. --   17  640 x 480, BW
  35. --   18  640 x 480, 16 color
  36. --   19  320 x 200, 256 color
  37. --  256  640 x 400, 256 color
  38. --  257  640 x 480, 256 color
  39. --  258  800 x 600, 16 color
  40. --  259  800 x 600, 256 color
  41. --  260  1024 x 768, 16 color
  42. --  261  1024 x 768, 256 color
  43.  
  44. type mode(integer x)
  45.     return (x >= -3 and x <= 19) or (x >= 256 and x <= 261)
  46. end type
  47.  
  48. type color(integer x)
  49.     return x >= 0 and x <= 255
  50. end type
  51.  
  52. type boolean(integer x)
  53.     return x = 0 or x = 1
  54. end type
  55.  
  56. type positive_int(integer x)
  57.     return x >= 1 
  58. end type
  59.  
  60. type point(sequence x)
  61.     return length(x) = 2
  62. end type
  63.  
  64. type point_sequence(sequence x)
  65.     return length(x) >= 2 
  66. end type
  67.  
  68. global procedure draw_line(color c,
  69.                positive_int w,
  70.                point_sequence xyarray)
  71. -- draw a line connecting the 2 or more points 
  72. -- in xyarray: {{x1, y1}, {x2, y2}, ...}
  73. -- using a certain color and width w
  74.     machine_proc(LINE, {c, w, 0, xyarray})
  75. end procedure
  76.  
  77. global procedure polygon(color c,
  78.              positive_int w,
  79.              boolean fill,
  80.              point_sequence xyarray)
  81. -- draw a polygon
  82. -- 3 or more vertices are given in xyarray
  83. -- using a certain color and width w
  84. -- fill the area if fill is TRUE 
  85.     machine_proc(POLYGON, {c, w, fill, xyarray})
  86. end procedure
  87.  
  88. global procedure pixel(color c, point p)
  89. -- set a pixel to a certain color
  90.     machine_proc(PIXEL, {c, p})
  91. end procedure
  92.  
  93. global procedure graphics_mode(mode m)
  94. -- set up a graphics mode
  95.    machine_proc(GRAPHICS_MODE, m) 
  96. end procedure
  97.  
  98. global constant VC_COLOR = 1,
  99.         VC_MODE  = 2,
  100.         VC_LINES = 3,
  101.         VC_COLUMNS = 4,
  102.         VC_XPIXELS = 5,
  103.         VC_YPIXELS = 6,
  104.         VC_NCOLORS = 7
  105. global function video_config()
  106. -- return sequence of information on video configuration
  107. -- {color?, mode, text lines, text columns, xpixels, ypixels, #colors}
  108.     return machine_func(VIDEO_CONFIG, 0)
  109. end function
  110.  
  111. -- cursor styles:
  112. global constant NO_CURSOR  = 8192,
  113.      UNDERLINE_CURSOR  = 1543,
  114.      BLOCK_CURSOR      = 7,
  115.      HALF_BLOCK_CURSOR = 1031
  116.  
  117. global procedure cursor(integer style)
  118. -- choose a cursor style 
  119.     machine_proc(CURSOR, style)
  120. end procedure
  121.  
  122. global function text_rows(positive_int rows) 
  123.     return machine_func(TEXTROWS, rows)
  124. end function
  125.  
  126. global procedure wrap(boolean on)
  127. -- on = 1: characters will wrap at end of long line
  128. -- on = 0: lines will be truncated
  129.     machine_proc(WRAP, on)
  130. end procedure
  131.  
  132. global procedure scroll(integer amount)
  133. -- amount > 0: scroll the screen up by amount lines
  134. -- amount < 0: scroll down by amount lines
  135.     machine_proc(SCROLL, amount)
  136. end procedure
  137.  
  138. global procedure text_color(color c)
  139. -- set the foreground text color to c - text or graphics modes
  140. -- add 16 to get blinking
  141.     machine_proc(SET_T_COLOR, c)
  142. end procedure
  143.  
  144. global procedure bk_color(color c)
  145. -- set the background color to c - text or graphics modes
  146.     machine_proc(SET_B_COLOR, c)
  147. end procedure
  148.  
  149. type mixture(sequence s)
  150.     return length(s) = 3 -- {red, green, blue}
  151. end type
  152.  
  153. global function palette(color c, mixture s)
  154. -- choose a new mix of {red, green, blue} to be shown on the screen for
  155. -- color number c. Returns previous mixture as {red, green, blue}.
  156.     return machine_func(PALETTE, {c, s})
  157. end function
  158.  
  159. -- Sound Effects --
  160.  
  161. type frequency(integer x)
  162.     return x >= 0
  163. end type
  164.  
  165. global procedure sound(frequency f)
  166. -- turn on speaker at frequency f 
  167. -- turn off speaker if f is 0
  168.     machine_proc(SOUND, f)
  169. end procedure
  170.  
  171.