home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_07 / MARK_WC2.LZH / INCLUDE / LINEA.H < prev    next >
C/C++ Source or Header  |  1988-04-27  |  14KB  |  363 lines

  1. /*
  2.  * linea.h -- C interface to Atari line A graphics routines.
  3.  *
  4.  * Copyright (c) 1986-1988, Mark Williams Company, Chicago
  5.  * This file and its contents may not be copied or distributed
  6.  * without permission.
  7.  */
  8. /*
  9.  * Each of the following line A functions consists of only a few
  10.  * lines of assembler code that save registers, load parameters,
  11.  * execute one of the unimplemented line 'a' instructions, restore
  12.  * registers, and return.
  13.  *
  14.  * Most of the line A functions pass their parameters through the
  15.  * structure "la_data", which is referenced through
  16.  * the pointer in the structure "la_init"; this, in turn,
  17.  * is initialized by the function linea0().
  18.  *
  19.  * The bitblt and sprite functions are exceptions to this rule.
  20.  *
  21.  * The structure "la_ext" contains late additions to the linea
  22.  * documentation.  This structure occupies the memory directly
  23.  * below "la_data" in memory.
  24.  *
  25.  * The address of the linea data structure is fixed in the rom, so on
  26.  * any given machine the address returned by "linea0()" will always be
  27.  * the same.  If LINEA_AD is defined when this file is compiled, then its
  28.  * absolute address will be used for referencing linea data items instead
  29.  * of the more expensive pointer address references.
  30.  * The value specified for LINEA_AD should be the address of the la_ext
  31.  * structure, ie the value of ((long)la_init.li_a0)-46.
  32.  */
  33. #ifndef LINEA_H
  34. #define LINEA_H
  35.  
  36. extern linea0();    /* () Initialize */
  37. extern linea1();    /* () Put pixel */
  38. extern linea2();    /* () Get pixel */
  39. extern linea3();    /* () Draw line */
  40. extern linea4();    /* () Draw horizontal line */
  41. extern linea5();    /* () Draw filled rectangle */
  42. extern linea6();    /* () Draw filled polygon */
  43. extern linea7();    /* (struct la_blit *bp) BitBlt */
  44. extern linea8();    /* () TextBlt */
  45. extern linea9();    /* () Show mouse */
  46. extern lineaa();    /* () Hide mouse */
  47. extern lineab();    /* () Transform mouse */
  48. extern lineac();    /* (char *sp) Undraw sprite */
  49. extern linead();    /* (long x,y; char *p,*q) Draw sprite */
  50. extern lineae();    /* () Copy raster form */
  51. extern lineaf();    /* () Seedfill */
  52.  
  53. /*
  54.  * Calling linea0() fetchs the following structure from
  55.  * the system and stores it in external memory.
  56.  */
  57. struct linea_init {
  58.     /* Early versions of TOS do not implement all possible functions */
  59.     long li_d0;        /* 0 if old system bugs persist */
  60.     long li_a0;        /* pointer to linea data structure */
  61.     struct la_font **li_a1;    /* system font vector */
  62.     long (*li_a2)();    /* linea function vector */
  63. };
  64.  
  65. extern struct linea_init la_init;
  66. /*
  67.  * The system data structure implements graphics.
  68.  * This is not well documented.
  69.  */
  70. struct la_data {
  71.     int    ld_vplanes;    /* Number of video planes: 1, 2, or 4 */
  72.     int    ld_vwrap;    /* Number of bytes/video line */
  73.     int    *ld_contrl;    /* Pointer to CONTRL array */
  74.     int    *ld_intin;    /* Pointer to INTIN array */
  75.     int    *ld_ptsin;    /* Pointer to PTSIN array */
  76.     int    *ld_intout;    /* Pointer to INTOUT array */
  77.     int    *ld_ptsout;    /* Pointer to PTSOUT array */
  78.     int    ld_colbit[4];    /* Color bit-plane[i] value */
  79.     int    ld_lstlin;    /* -1 */
  80.     int    ld_lnmask;    /* Line-style mask */
  81.     int    ld_wmode;    /* Writing mode 0:replace, 1:transparent,
  82.                    2:exclusive OR, 3:inverse transparent */
  83.     int    ld_x1;        /* X1 coordinate */
  84.     int    ld_y1;        /* Y1 coordinate */
  85.     int    ld_x2;        /* X2 coordinate */
  86.     int    ld_y2;        /* Y2 coordinate */
  87.     int    *ld_patptr;    /* Fill pattern pointer */
  88.     int    ld_patmsk;    /* Fill pattern mask */
  89.     int    ld_mfill;    /* Multi-plane fill flag */
  90.     int    ld_clip;    /* Clipping flag */
  91.     int    ld_xmincl;    /* Minimum X clipping value */
  92.     int    ld_ymincl;    /* Minimum Y clipping value */
  93.     int    ld_xmaxcl;    /* Maximum X clipping value */
  94.     int    ld_ymaxcl;    /* Maximum Y clipping value */
  95.     int    ld_xdda;    /* Accumulator for textblt dda */
  96.     int    ld_ddainc;    /* Fixed point scale factor */
  97.     int    ld_scaldir;    /* Scale direction flag */
  98.     int    ld_mono;    /* Current font is monospaced */
  99.     int    ld_srcx;    /* X coord of character in font */
  100.     int    ld_srcy;    /* Y coord of character in font */
  101.     int    ld_dstx;    /* X coord of character on screen */
  102.     int    ld_dsty;    /* Y coord of character on screen */
  103.     int    ld_delx;    /* Width of character */
  104.     int    ld_dely;    /* Height of character */
  105.     int    *ld_fbase;    /* Pointer to start of font form */
  106.     int    ld_fwidth;    /* Width of font form */
  107.     int    ld_style;    /* Textblt special effects flags */
  108.     int    ld_litemsk;    /* Lightening mask */
  109.     int    ld_skewmsk;    /* Skewing mask */
  110.     int    ld_weight;    /* Thickening factor */
  111.     int    ld_roff;    /* Skew offset above baseline */
  112.     int    ld_loff;    /* Skew offset below baseline */
  113.     int    ld_scale;    /* Scaling flag */
  114.     int    ld_chup;    /* Character rotation vector */
  115.     int    ld_textfg;    /* Text foreground color */
  116.     int    *ld_scrtchp;    /* Text special effects buffer */
  117.     int    ld_scrpt2;    /* Offset to scaling buffer from above */
  118.     int    ld_textbg;    /* Text background color */
  119.     int    ld_copytran;    /* Copy raster form type flag */
  120.     int    (*ld_seedabort)();    /* Seedfill end detect function */
  121. };
  122.  
  123. /*
  124.  * The extended linea data block.
  125.  */
  126. struct la_ext {
  127.     short    ld_cel_ht;    /* Height of character cell */
  128.     short    ld_cel_mx;    /* Maximum horizontal cell index */
  129.     short    ld_cel_my;    /* Maximum vertical cell index */
  130.     short    ld_cel_wr;    /* Screen width (bytes) * cel_ht */
  131.     short    ld_col_bg;    /* Background color index */
  132.     short    ld_col_fg;    /* Foreground color index */
  133.     long    ld_cur_ad;    /* Cursor address */
  134.     short    ld_cur_off;    /* Byte offset to cursor from screen base */
  135.     short    ld_cur_cx;    /* Cursor horizontal cell index */
  136.     short    ld_cur_cy;    /* Cursor vertical cell index */
  137.     char    ld_cur_cnt;    /* Cursor flash shorterval (frames) */
  138.     char    ld_cur_tim;    /* Cursor flash countdown */
  139.     long    ld_fnt_ad;    /* Font table address */
  140.     short    ld_fnt_nd;    /* Last ascii code in font */
  141.     short    ld_fnt_st;    /* First ascii code in font */
  142.     short    ld_fnt_wr;    /* Width of font form (bytes) */
  143.     short    ld_x_max;    /* Maximum horizontal pixel index */
  144.     long    ld_off_ad;    /* Font offset table address */
  145.     char    ld_status;    /* Text status byte */
  146.     char    ld_fill;    /* Filler byte */
  147.     short    ld_y_max;    /* Maximum vertical pixel index */
  148.     short    ld_x_wr;    /* Width of screen (bytes) */
  149. };
  150.  
  151. /*
  152.  * Accept an absolute specification for the linea la_data address.
  153.  * Note that programs compiled with such an option will not work
  154.  * on machines which have their linea la_data at some other address.
  155.  * The location for your machine should be determined by calling
  156.  * linea0() and displaying the address returned for la_init.li_a0.
  157.  */
  158. #ifndef LINEA_AD
  159. #define LINEA_AD    (la_init.li_a0-sizeof(struct la_ext))
  160. #endif
  161.  
  162. #define LA_EXT    ((struct la_ext *)LINEA_AD)
  163. #define LA_DATA    ((struct la_data *)(LINEA_AD+sizeof(struct la_ext)))
  164.  
  165. /*
  166.  * Definitions to make the names described in the Atari
  167.  * linea.doc and linea.ext accessible.
  168.  */
  169. #define VPLANES    LA_DATA->ld_vplanes
  170. #define VWRAP    LA_DATA->ld_vwrap
  171. #define CONTRL    LA_DATA->ld_contrl
  172. #define INTIN    LA_DATA->ld_intin
  173. #define PTSIN    LA_DATA->ld_ptsin
  174. #define INTOUT    LA_DATA->ld_intout
  175. #define PTSOUT    LA_DATA->ld_ptsout
  176. #define COLBIT0    LA_DATA->ld_colbit[0]
  177. #define COLBIT1    LA_DATA->ld_colbit[1]
  178. #define COLBIT2    LA_DATA->ld_colbit[2]
  179. #define COLBIT3    LA_DATA->ld_colbit[3]
  180. #define LSTLIN    LA_DATA->ld_lstlin
  181. #define LNMASK    LA_DATA->ld_lnmask
  182. #define WMODE    LA_DATA->ld_wmode
  183. #define X1    LA_DATA->ld_x1
  184. #define Y1    LA_DATA->ld_y1
  185. #define X2    LA_DATA->ld_x2
  186. #define Y2    LA_DATA->ld_y2
  187. #define PATPTR    LA_DATA->ld_patptr
  188. #define PATMSK    LA_DATA->ld_patmsk
  189. #define MFILL    LA_DATA->ld_mfill
  190. #define CLIP    LA_DATA->ld_clip
  191. #define XMINCL    LA_DATA->ld_xmincl
  192. #define YMINCL    LA_DATA->ld_ymincl
  193. #define XMAXCL    LA_DATA->ld_xmaxcl
  194. #define YMAXCL    LA_DATA->ld_ymaxcl
  195. #define XDDA    LA_DATA->ld_xdda
  196. #define DDAINC    LA_DATA->ld_ddainc
  197. #define SCALDIR    LA_DATA->ld_scaldir
  198. #define MONO    LA_DATA->ld_mono
  199. #define SRCX    LA_DATA->ld_srcx
  200. #define SRCY    LA_DATA->ld_srcy
  201. #define DSTX    LA_DATA->ld_dstx
  202. #define DSTY    LA_DATA->ld_dsty
  203. #define DELX    LA_DATA->ld_delx
  204. #define DELY    LA_DATA->ld_dely
  205. #define FBASE    LA_DATA->ld_fbase
  206. #define FWIDTH    LA_DATA->ld_fwidth
  207. #define STYLE    LA_DATA->ld_style
  208. #define LITEMSK    LA_DATA->ld_litemsk
  209. #define SKEWMSK    LA_DATA->ld_skewmsk
  210. #define WEIGHT    LA_DATA->ld_weight
  211. #define ROFF    LA_DATA->ld_roff
  212. #define LOFF    LA_DATA->ld_loff
  213. #define SCALE    LA_DATA->ld_scale
  214. #define CHUP    LA_DATA->ld_chup
  215. #define TEXTFG    LA_DATA->ld_textfg
  216. #define SCRTCHP    LA_DATA->ld_scrtchp
  217. #define SCRPT2    LA_DATA->ld_scrpt2
  218. #define TEXTBG    LA_DATA->ld_textbg
  219. #define COPYTRAN    LA_DATA->ld_copytran
  220. #define SEEDABORT    LA_DATA->ld_seedabort
  221.  
  222. #define V_CEL_HT    LA_EXT->ld_cel_ht
  223. #define V_CEL_MX    LA_EXT->ld_cel_mx
  224. #define V_CEL_MY    LA_EXT->ld_cel_my
  225. #define V_CEL_WR    LA_EXT->ld_cel_wr
  226. #define V_COL_BG    LA_EXT->ld_col_bg
  227. #define V_COL_FG    LA_EXT->ld_col_fg
  228. #define V_CUR_AD    LA_EXT->ld_cur_ad
  229. #define V_CUR_OFF    LA_EXT->ld_cur_off
  230. #define V_CUR_CX    LA_EXT->ld_cur_cx
  231. #define V_CUR_CY    LA_EXT->ld_cur_cy
  232. #define V_CUR_CNT    LA_EXT->ld_cur_cnt
  233. #define V_CUR_TIM    LA_EXT->ld_cur_tim
  234. #define V_FNT_AD    LA_EXT->ld_fnt_ad
  235. #define V_FNT_ND    LA_EXT->ld_fnt_nd
  236. #define V_FNT_ST    LA_EXT->ld_fnt_st
  237. #define V_FNT_WR    LA_EXT->ld_fnt_wr
  238. #define V_X_MAX        LA_EXT->ld_x_max
  239. #define V_OFF_AD    LA_EXT->ld_off_ad
  240. #define V_STATUS    LA_EXT->ld_status
  241. #define V_Y_MAX        LA_EXT->ld_y_max
  242. #define V_X_WR        LA_EXT->ld_x_wr
  243.  
  244. /*
  245.  * Macros for the easiest line A functions.
  246.  */
  247. #define putpixel(x,y,v)    ((PTSIN[0]=x),(PTSIN[1]=y),(INTIN[0]=v),linea1())
  248. #define getpixel(x,y)    ((PTSIN[0]=x),(PTSIN[1]=y),linea2())
  249. #define showmouse()    (linea9())
  250. #define hidemouse()    (lineaa())
  251.  
  252. /*
  253.  * The mouse hidden flag/counter is at an undocumented negative offset
  254.  * from the structure pointed to by a0 after a linea0 (init) call.
  255.  * It is 0 when the mouse is shown.
  256.  * This is true in 11/20/85 USA rom and later, and appears to be
  257.  * true for all ROM versions of TOS.
  258.  */
  259. #define mousehidden    *((int *)((long)la_init.li_a0-598))
  260.  
  261. /*
  262.  * The mouse position and button state information is also available
  263.  * at a negative offset from the structure pointed to by a0 after a
  264.  * linea0 (init) call.  Do not modify these values.
  265.  */
  266. #define    mousebutstate    *((int *)((long)la_init.li_a0-596))
  267. #define    mouseposx    *((int *)((long)la_init.li_a0-344))
  268. #define    mouseposy    *((int *)((long)la_init.li_a0-342))
  269.  
  270. /*
  271.  * linea7() = BitBlt parameter block:
  272.  * source and destination description blocks.
  273.  */
  274. struct la_blk {
  275.     int    bl_xmin;        /* Minimum x */
  276.     int    bl_ymin;        /* Minimum y */
  277.     int    *bl_form;        /* Word aligned memory form */
  278.     int    bl_nxwd;        /* Offset to next word in line */
  279.     int     bl_nxln;        /* Offset to next line in plane */
  280.     int     bl_nxpl;        /* Offset to next plane */
  281. };
  282.  
  283. struct la_blit {
  284.     int    bb_b_wd;        /* Width of block in pixels */
  285.     int    bb_b_ht;        /* Height of block in pixels */
  286.     int    bb_plane_ct;        /* Number of planes to blit */
  287.     int    bb_fg_col;        /* Foreground color */
  288.     int    bb_bg_col;        /* Background color */
  289.     char    bb_op_tab[4];        /* Logic for fg x bg combination */
  290.     struct la_blk bb_s;        /* Source info block */
  291.     struct la_blk bb_d;        /* Destination info block */
  292.     int    *bb_p_addr;        /* Pattern buffer address */
  293.     int    bb_p_nxln;        /* Offset to next line in pattern */
  294.     int    bb_p_nxpl;        /* Offset to next plane in pattern */
  295.     int    bb_p_mask;        /* Pattern index mask */
  296.     char    bb_fill[24];        /* Work space */
  297. };
  298. /*
  299.  * Offsets to next word in plane:
  300.  */
  301. #define HIGH_NXWD    2
  302. #define MED_NXWD    4
  303. #define LOW_NXWD    8
  304. /*
  305.  * Scan line widths of the screen:
  306.  */
  307. #define HIGH_NXLN    80
  308. #define MED_NXLN    160
  309. #define LOW_NXLN    160
  310. /*
  311.  * Offsets between planes:
  312.  */
  313. #define NXPL        2
  314. /*
  315.  * linead() = Draw sprite, sprite definition block.
  316.  *    sprite save block is 10+VPLANES*64 bytes big.
  317.  */
  318. struct la_sprite {
  319.     int    ls_xhot;    /* X hot spot offset */
  320.     int    ls_yhot;    /* Y hot spot offset */
  321.     int    ls_form;    /* 1 for VDI, -1 for XOR */
  322.     int    ls_bgcol;    /* Background color index */
  323.     int    ls_fgcol;    /* Foreground color index */
  324.     int    ls_image[32];    /* Background/foreground interleaved image */
  325. };
  326. /*
  327.  * Font header. Taken from GEM VDI Programmers Guide G-2
  328.  */
  329. struct la_font {
  330.     int    font_id;        /* Face identifier */
  331.     int    font_size;        /* Font size in points */
  332.     char    font_name[32];        /* Face name */
  333.     int    font_low_ade;        /* Lowest ASCII value in face */
  334.     int    font_hi_ade;        /* Highest ASCII value in face */
  335.                     /* Distance from char baseline */
  336.     int    font_top_dst;        /* Top line distance */
  337.     int    font_ascent_dst;    /* Ascent line distance */
  338.     int    font_half_dst;        /* Half line distance */
  339.     int    font_descent_dst;     /* Descent line distance */
  340.     int    font_bottom_dist;     /* Bottom line distance */
  341.     int    font_fatest;        /* Width of widest char in font */
  342.     int    font_fat_cell;        /* Width of widest char cell in font */
  343.     int    font_left_off;        /* Left offset */
  344.     int    font_right_off;        /* Right offset */
  345.     int    font_thickening;     /* No. of pixles to widen chars */
  346.     int    font_underline;        /* Width in pixles of underline */
  347.     int    font_lightening;     /* Mask used to drop pixles out */
  348.     int    font_skewing;        /* Mask used to determine skewing */
  349.     unsigned default_font:1;     /* Set if default system font */
  350.     unsigned horiz_ofset:1;        /* Use horizontal offset tables */
  351.     unsigned byte_swap:1;        /* Byte swap flag */
  352.     unsigned mono_space:1;        /* Monospaced font */
  353.     int    *font_horiz_off;     /* Pointer to horizontal offset table */
  354.     int    *font_char_off;        /* Pointer to char offset table */
  355.     char    *font_data;        /* Pointer to font data */
  356.     int    font_width;        /* Font width */
  357.     int    font_height;        /* Font height */
  358.     char    *font_next;        /* Pointer to next font */
  359. };
  360. #endif
  361.  
  362. /* End of linea.h */
  363.