home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ucb_logoppc / source / amiterm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-23  |  6.9 KB  |  234 lines

  1. /*
  2.    amiterm.h         Amiga graphics macros
  3.  
  4.    Copyright (C) 1997 Tony Belding, <tlbelding@htcomp.net>
  5.  
  6.    This program is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 2 of the License, or
  9.    (at your option) any later version.
  10.  
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. /* System includes */
  22. #include <graphics/gfxmacros.h>
  23. #include <intuition/screens.h>
  24. #include <intuition/intuition.h>
  25. #include <exec/memory.h>
  26. #include <clib/graphics_protos.h>
  27. #include <clib/intuition_protos.h>
  28. #include <libraries/asl.h>
  29. #include <proto/asl.h>
  30.  
  31. // #include <libraries/reqtools.h>
  32. // #include <proto/reqtools.h>
  33.  
  34.  
  35. /* PROTOTYPES FOR AMITERM.C */
  36.  
  37. extern BOOL save_prefs(void);
  38. extern BOOL load_prefs(void);
  39. extern void default_prefs(void);
  40. extern void amiga_open_graphics_screen(void);
  41. extern NODE *lam_prefs(void);
  42. extern NODE *lam_version(void);
  43. extern void amiga_splitscreen(void);
  44. extern void amiga_fullscreen(void);
  45. extern void amiga_textscreen(void);
  46. extern void get_con_position(void);
  47. extern void logofill(void);
  48. extern void ami_print(char *);
  49. extern void set_palette(int,unsigned int,unsigned int,unsigned int);
  50. extern void get_palette(int,unsigned int *,unsigned int *,unsigned int*);
  51. extern int check_amiga_stop(ULONG);
  52. extern void amiga_wait(unsigned int);
  53.  
  54. /* Filehandle for the AmigaDOS console window. */
  55. extern BPTR console;
  56.  
  57. /* name of our public screen, so "ed" and "CON:" can find it */
  58. extern char screenname[];
  59.  
  60. /* Many of the macros refer to the graphics window */
  61. extern struct Window* win;
  62.  
  63.  
  64. /* Amiga window does not have a visible flag so we store this separately */
  65. extern int current_vis;
  66.  
  67.  
  68. /* How much space to leave for recording */
  69. #define GR_SIZE 1
  70.  
  71. /********************************************************************/
  72. /* Define or declare everything needed by GRAPHIC.C */
  73.  
  74. #define prepare_to_draw  if(win==NULL)amiga_splitscreen()
  75. #define done_drawing
  76.  
  77. #define prepare_to_draw_turtle
  78. #define done_drawing_turtle
  79.  
  80. #define screen_height (win->Height - (win->BorderTop + win->BorderBottom))
  81. #define screen_width  (win->Width - (win->BorderLeft + win->BorderRight))
  82.  
  83. #define screen_left   (win->BorderLeft)
  84. #define screen_right  (win->Width - win->BorderRight - 1)
  85. #define screen_top    (win->BorderTop)
  86. #define screen_bottom (win->Height - win->BorderBottom - 1)
  87.  
  88. #define screen_x_center (screen_left+screen_width/2)
  89. #define screen_y_center (screen_top+screen_height/2)
  90.  
  91. #define turtle_height (18.0*0.5)
  92. #define turtle_half_bottom (6.0*0.5)
  93. #define turtle_side (19.0*0.5)
  94.  
  95. #define turtle_left_max          (-(screen_width/2))
  96. #define turtle_right_max         ((screen_width-1)/2)
  97. #define turtle_top_max           (screen_height/2)
  98. #define turtle_bottom_max        (-((screen_height-1)/2))
  99.  
  100. #define screen2x( sx) ((sx) - win->BorderLeft - (screen_width/2.0))
  101. #define screen2y( sy) (win->BorderTop + (screen_height/2.0) - (sy))
  102.  
  103. #define x2screen(x) (win->BorderLeft + (screen_width/2.0) + (x))
  104. #define y2screen(y) (win->BorderTop + (screen_height/2.0) - (y))
  105.  
  106. #define screen_x_coord x2screen(turtle_x)
  107. #define screen_y_coord y2screen(turtle_y)
  108.  
  109. #define clear_screen     erase_screen()
  110.  
  111. #define line_to(x,y)     if (current_vis==0)\
  112.                               Draw( win->RPort, (int)(x),(int)(y));\
  113.                          else Move( win->RPort, (int)(x),(int)(y));
  114.  
  115. #define move_to(x,y)       Move( win->RPort, (int)(x),(int)(y))
  116. #define draw_string(s)     Text( win->RPort, (char*)(s), strlen( (char*)(s)))
  117. #define label( s)          draw_string(s)
  118.  
  119. #define set_pen_vis(v)     current_vis = (v)
  120. #define set_pen_mode(m)    SetDrMd( win->RPort, m)
  121. #define set_pen_color(c)   SetAPen( win->RPort, MapColor(c));
  122. #define pen_color          RevMapColor(GetAPen( win->RPort))
  123. #define set_back_ground(c) SetBPen( win->RPort, MapColor(c))
  124. #define set_pen_width(w)
  125. #define set_pen_height(h)
  126. #define set_pen_x(x)       Move( win->RPort, (int)(x), win->RPort->cp_y)
  127. #define set_pen_y(y)       Move( win->RPort, win->RPort->cp_x, (int)(y))
  128.  
  129. #define full_screen amiga_fullscreen()
  130. #define split_screen amiga_splitscreen()
  131. #define text_screen amiga_textscreen()
  132.  
  133. /* This seems wrong, but we would really need a reverse color lookup
  134.    to do any better (I think)
  135. */
  136. #define back_ground 1
  137.  
  138. /*
  139.    pen_info is a stucture type with fields for the various
  140.    pen characteristics.  The types are system dependant.
  141. */
  142.  
  143. typedef struct {
  144.    WORD     x;
  145.    WORD     y;
  146.    int      vis;
  147.    ULONG    fcolor;
  148.    ULONG    bcolor;
  149.    UWORD    pattern;
  150.    ULONG    mode;
  151. } pen_info;
  152.  
  153. #define p_info_x(p) (p).x
  154. #define p_info_y(p) (p).y
  155.  
  156. #define pen_width    1
  157. #define pen_height   1
  158. #define pen_mode     GetDrMd( win->RPort)
  159. #define pen_vis      current_vis
  160. #define pen_x        (win->RPort->cp_x)
  161. #define pen_y        (win->RPort->cp_y)
  162.  
  163. #define get_node_pen_pattern Get_node_pen_pattern()
  164. #define get_node_pen_mode    Get_node_pen_mode()
  165.  
  166.  
  167. /* Various pen mode settings */
  168. #define pen_reverse          SetDrMd( win->RPort, COMPLEMENT)
  169. #define pen_erase            SetDrMd( win->RPort, JAM2 | INVERSVID)
  170. #define pen_down             SetDrMd( win->RPort, JAM1)
  171.  
  172.  
  173. /*
  174.    These defines cover the fixed palette area of a Logo screen.  Anything
  175.    above 15 is subject to being allocated and redefined.
  176. */
  177. #define WB_GRAY   0
  178. #define BLACK     1
  179. #define WHITE     2
  180. #define WB_BLUE   3
  181. #define BLUE      4
  182. #define GREEN     5
  183. #define CYAN      6
  184. #define RED       7
  185. #define MAGENTA   8
  186. #define YELLOW    9
  187. #define BROWN     10
  188. #define TAN       11
  189. #define FOREST    12
  190. #define AQUA      13
  191. #define SALMON    14
  192. #define PURPLE    15
  193. #define ORANGE    16
  194. #define GRAY      18
  195.  
  196. #define button  0
  197. #define mouse_x win->MouseX
  198. #define mouse_y win->MouseY
  199.  
  200. void save_pen(struct pen_info  *p);
  201. void restore_pen(struct pen_info *p);
  202.  
  203. #define plain_xor_pen() pen_reverse
  204.  
  205. typedef struct {      /* structure for user preferences */
  206.    ULONG DisplayID;
  207.    UWORD DisplayWidth;
  208.    UWORD DisplayHeight;
  209.    UWORD DisplayDepth;
  210.    UWORD OverscanType;
  211.    char font[80];
  212.    char editor[256];
  213. } BAL_Prefs;
  214.  
  215. extern BAL_Prefs prefs;
  216.  
  217. /* Make a noise for the given pitch and duration */
  218. #define tone(pitch,duration)
  219. #define get_pen_pattern(p)       /* Maybe this could be implemented? */
  220. #define set_pen_pattern(p)       /* and this */
  221. #define set_list_pen_pattern(p)  /* What is this? */
  222.  
  223. extern ULONG MapColor( FIXNUM logo_color);
  224. extern FIXNUM RevMapColor( ULONG);
  225. extern NODE *Get_node_pen_pattern( void);
  226. extern NODE *Get_node_pen_mode( void);
  227. extern void erase_screen( void);
  228.  
  229.  
  230. /* I have no clue why this should be defined here, since it is part of
  231.    math.c... just tradition I guess!
  232. */
  233. extern double degrad;
  234.