home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src_ansi / ace / c / gfx.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-05  |  22.0 KB  |  994 lines

  1. /* << ACE >>
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Parser: graphics functions **
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.    Date: 26th October-30th November, 1st-13th December 1991,
  24.    14th,20th-27th January 1992, 
  25.    2nd-17th, 21st-29th February 1992, 
  26.    1st,13th,14th,22nd,23rd March 1992,
  27.    21st,22nd April 1992,
  28.    2nd,3rd,11th,15th,16th May 1992,
  29.    7th,8th,9th,11th,13th,14th,28th,29th,30th June 1992,
  30.    2nd-8th,14th-19th,26th-29th July 1992,
  31.    1st-3rd,7th,8th,9th August 1992,
  32.    6th,7th,12th,13th December 1992,
  33.    4th January 1993,
  34.    1st July 1993,
  35.    6th February 1994,
  36.    14th July 1994,
  37.    28th August 1994
  38.  */
  39.  
  40. #include "acedef.h"
  41. #include <string.h>
  42.  
  43. /* locals */
  44. static char *frame_ptr[] = {"(a4)", "(a5)"};
  45.  
  46. /* externals */
  47. extern int sym;
  48. extern int lev;
  49. extern int obj;
  50. extern SHORT shortval;
  51. extern CODE *curr_code;
  52. extern SYM *curr_item;
  53. extern char id[MAXIDSIZE];
  54.  
  55. /* functions */
  56. void pset (void)
  57. {
  58.   BOOL relative;
  59.   BOOL colorset = FALSE;
  60.  
  61.   insymbol ();
  62.   if (sym == stepsym)
  63.     {
  64.       insymbol ();
  65.       relative = TRUE;
  66.     }
  67.   else
  68.     relative = FALSE;
  69.  
  70.   if (sym != lparen)
  71.     _error (14);
  72.   else
  73.     {
  74.       /* x-coordinate */
  75.       insymbol ();
  76.       make_sure_short (expr ());
  77.       if (sym != comma)
  78.     _error (16);
  79.       else
  80.     {
  81.       /* y-coordinate */
  82.       insymbol ();
  83.       make_sure_short (expr ());
  84.       if (sym != rparen)
  85.         _error (9);
  86.       else
  87.         {
  88.           insymbol ();
  89.           if (sym == comma)
  90.         {
  91.           /* pen color */
  92.           insymbol ();
  93.           make_sure_short (expr ());
  94.           gen ("move.w", "(sp)+", "d0");
  95.           gen ("move.l", "_RPort", "a1");
  96.           gen ("move.l", "_GfxBase", "a6");
  97.           gen ("jsr", "_LVOSetAPen(a6)", "  ");
  98.           enter_XREF ("_LVOSetAPen");
  99.           enter_XREF ("_GfxBase");
  100.           enter_XREF ("_RPort");
  101.           colorset = TRUE;
  102.         }
  103.           else
  104.         colorset = FALSE;
  105.         }
  106.       /* pop y-coordinate */
  107.       gen ("move.w", "(sp)+", "d1");
  108.     }
  109.       /* pop x-coordinate */
  110.       gen ("move.w", "(sp)+", "d0");
  111.     }
  112.  
  113.   /* plot point */
  114.   if (!colorset)
  115.     {
  116.       gen ("move.l", "_GfxBase", "a6");
  117.       enter_XREF ("_GfxBase");
  118.       gen ("move.l", "_RPort", "a1");
  119.       enter_XREF ("_RPort");
  120.     }
  121.  
  122.   if (relative)
  123.     {
  124.       gen ("add.w", "36(a1)", "d0");    /* x + RPort->cp_x */
  125.       gen ("add.w", "38(a1)", "d1");    /* y + RPort->cp_y */
  126.       gen ("jsr", "_LVOMove(a6)", "  ");
  127.       enter_XREF ("_LVOMove");
  128.     }
  129.  
  130.   /* 
  131.      ** Save appropriate registers for call to WritePixel()
  132.      ** since Move() may clobber them.
  133.    */
  134.   gen ("move.l", "a1", "a3");
  135.   gen ("move.w", "d0", "d3");
  136.   gen ("move.w", "d1", "d4");
  137.  
  138.   gen ("jsr", "_LVOMove(a6)", "  ");
  139.  
  140.   /* 
  141.      ** Restore appropriate registers for call to WritePixel().
  142.    */
  143.   gen ("move.w", "d4", "d1");
  144.   gen ("move.w", "d3", "d0");
  145.   gen ("move.l", "a3", "a1");
  146.  
  147.   gen ("jsr", "_LVOWritePixel(a6)", "  ");
  148.  
  149.   enter_XREF ("_LVOMove");    /* Must call Move() to change pen pos'n */
  150.   enter_XREF ("_LVOWritePixel");
  151.  
  152.   if (colorset)
  153.     {
  154.       /* change back to old pen */
  155.       gen ("move.w", "_fgdpen", "d0");
  156.       gen ("move.l", "_RPort", "a1");
  157.       gen ("move.l", "_GfxBase", "a6");
  158.       gen ("jsr", "_LVOSetAPen(a6)", "  ");
  159.       enter_XREF ("_fgdpen");
  160.     }
  161. }
  162.  
  163. void paint (void)
  164. {
  165.   BOOL paintcolor = FALSE;
  166.   BOOL bordercolor = FALSE;
  167.  
  168.   /* PAINT (X,Y)[,paintcolor-id[,bordercolor-id]] */
  169.  
  170.   insymbol ();
  171.   if (sym != lparen)
  172.     _error (14);
  173.   else
  174.     {
  175.       insymbol ();
  176.       make_sure_short (expr ());    /* X */
  177.  
  178.       if (sym != comma)
  179.     _error (16);
  180.       else
  181.     {
  182.       insymbol ();
  183.       make_sure_short (expr ());    /* Y */
  184.  
  185.       if (sym != rparen)
  186.         _error (9);
  187.       else
  188.         {
  189.           insymbol ();
  190.           if (sym == comma)
  191.         {
  192.           insymbol ();
  193.           if (sym != comma)
  194.             {
  195.               make_sure_short (expr ());    /* paintcolor-id */
  196.               paintcolor = TRUE;
  197.             }
  198.  
  199.           if (sym == comma)
  200.             {
  201.               insymbol ();
  202.               make_sure_short (expr ());    /* bordercolor-id */
  203.               bordercolor = TRUE;
  204.             }
  205.         }
  206.         }
  207.       /* pop parameters */
  208.       if (bordercolor)
  209.         gen ("move.w", "(sp)+", "d3");
  210.       else
  211.         gen ("moveq", "#-1", "d3");        /* flag no border color-id */
  212.  
  213.       if (paintcolor)
  214.         gen ("move.w", "(sp)+", "d2");
  215.       else
  216.         gen ("moveq", "#-1", "d2");        /* flag no paint color-id */
  217.  
  218.       gen ("move.w", "(sp)+", "d1");    /* Y */
  219.       gen ("move.w", "(sp)+", "d0");    /* X */
  220.  
  221.       /* call paint routine */
  222.       gen ("jsr", "_paint", "  ");
  223.       enter_XREF ("_paint");
  224.       enter_XREF ("_GfxBase");
  225.     }
  226.     }
  227. }
  228.  
  229. void circle (void)
  230. {
  231.   BOOL relative;
  232.   BOOL colorset = FALSE;
  233.   BOOL start_angle = FALSE;
  234.   BOOL end_angle = FALSE;
  235.   BOOL aspect = FALSE;
  236.  
  237.   insymbol ();
  238.   if (sym == stepsym)
  239.     {
  240.       insymbol ();
  241.       relative = TRUE;
  242.     }
  243.   else
  244.     relative = FALSE;
  245.  
  246.   if (sym != lparen)
  247.     {
  248.       _error (14);
  249.       return;
  250.     }
  251.   else
  252.     {
  253.       /* x-coordinate */
  254.       insymbol ();
  255.       make_sure_short (expr ());
  256.       if (sym != comma)
  257.     {
  258.       _error (16);
  259.       return;
  260.     }
  261.       else
  262.     {
  263.       /* y-coordinate */
  264.       insymbol ();
  265.       make_sure_short (expr ());
  266.       if (sym != rparen)
  267.         {
  268.           _error (9);
  269.           return;
  270.         }
  271.       else
  272.         {
  273.           insymbol ();
  274.           if (sym != comma)
  275.         {
  276.           _error (29);
  277.           return;
  278.         }        /* radius expected -> no point going on */
  279.           else
  280.         {
  281.           /* radius */
  282.           insymbol ();
  283.           gen_Flt (expr ());
  284.         }
  285.         }
  286.     }
  287.     }
  288.  
  289.   if (sym == comma)
  290.     {
  291.       /* color */
  292.       insymbol ();
  293.       if (sym != comma)        /* else skipping to next parameter (start angle) */
  294.     {
  295.       make_sure_short (expr ());
  296.       gen ("move.w", "(sp)+", "d0");
  297.       gen ("move.l", "_RPort", "a1");
  298.       gen ("move.l", "_GfxBase", "a6");
  299.       gen ("jsr", "_LVOSetAPen(a6)", "  ");
  300.       enter_XREF ("_LVOSetAPen");
  301.       enter_XREF ("_GfxBase");
  302.       enter_XREF ("_RPort");
  303.       colorset = TRUE;
  304.     }
  305.     }
  306.   else
  307.     colorset = FALSE;
  308.  
  309.   /* start & end angle in <<degrees>> */
  310.  
  311.   if (sym == comma)
  312.     {
  313.       insymbol ();
  314.       if (sym != comma)        /* else skip to end angle */
  315.     {
  316.       gen_Flt (expr ());
  317.       gen ("move.l", "(sp)+", "d3");    /* start angle */
  318.       start_angle = TRUE;
  319.     }
  320.  
  321.       if (sym == comma)
  322.     {
  323.       insymbol ();
  324.       if (sym != comma)    /* else skip to aspect */
  325.         {
  326.           if (!start_angle)
  327.         _error (30);    /* no start angle! */
  328.           gen_Flt (expr ());
  329.           gen ("move.l", "(sp)+", "d4");    /* end angle */
  330.           end_angle = TRUE;
  331.         }
  332.     }
  333.       else
  334.     _error (16);
  335.  
  336.       if (sym == comma)
  337.     {
  338.       /* aspect */
  339.       insymbol ();
  340.       gen_Flt (expr ());
  341.       gen ("move.l", "(sp)+", "d5");    /* aspect */
  342.       aspect = TRUE;
  343.     }
  344.     }
  345.  
  346.   /* pop radius & (x,y) coordinates */
  347.   gen ("move.l", "(sp)+", "d2");    /* radius */
  348.   gen ("move.w", "(sp)+", "_shorty");    /* y */
  349.   gen ("move.w", "(sp)+", "_shortx");    /* x */
  350.  
  351.   if (relative)
  352.     {
  353.       gen ("move.l", "_RPort", "a1");
  354.  
  355.       gen ("move.w", "_shortx", "d0");
  356.       gen ("add.w", "36(a1)", "d0");    /* x + RPort->cp_x */
  357.       gen ("move.w", "d0", "_shortx");
  358.  
  359.       gen ("move.w", "_shorty", "d0");
  360.       gen ("add.w", "38(a1)", "d0");    /* y + RPort->cp_y */
  361.       gen ("move.w", "d0", "_shorty");
  362.     }
  363.  
  364.   /* convert x & y values to floats */
  365.   gen ("move.w", "_shortx", "d0");
  366.   gen ("ext.l", "d0", "  ");
  367.   gen ("move.l", "_MathBase", "a6");
  368.   gen ("jsr", "_LVOSPFlt(a6)", "  ");
  369.   gen ("move.l", "d0", "_floatx");
  370.  
  371.   gen ("move.w", "_shorty", "d0");
  372.   gen ("ext.l", "d0", "  ");
  373.   gen ("move.l", "_MathBase", "a6");
  374.   gen ("jsr", "_LVOSPFlt(a6)", "  ");
  375.   gen ("move.l", "d0", "_floaty");
  376.  
  377.   gen ("move.l", "_floatx", "d0");
  378.   gen ("move.l", "_floaty", "d1");
  379.  
  380.   if (!start_angle)
  381.     gen ("moveq", "#0", "d3");    /* default is zero */
  382.   if (!end_angle)
  383.     gen ("move.l", "#$b3800049", "d4");        /* default is 359 */
  384.   if (!aspect)
  385.     gen ("move.l", "#$e147af3f", "d5");        /* default is .44 */
  386.  
  387.   gen ("jsr", "_ellipse", "  ");
  388.   enter_XREF ("_ellipse");
  389.   enter_XREF ("_GfxBase");
  390.   enter_XREF ("_MathBase");
  391.   enter_XREF ("_MathTransBase");    /* need these 3 libs for _ellipse */
  392.  
  393.   enter_BSS ("_shortx", "ds.w 1");
  394.   enter_BSS ("_shorty", "ds.w 1");
  395.   enter_BSS ("_floatx", "ds.l 1");
  396.   enter_BSS ("_floaty", "ds.l 1");
  397.  
  398.   if (colorset)
  399.     {
  400.       /* change back to old pen */
  401.       gen ("move.w", "_fgdpen", "d0");
  402.       gen ("move.l", "_RPort", "a1");
  403.       gen ("move.l", "_GfxBase", "a6");
  404.       gen ("jsr", "_LVOSetAPen(a6)", "  ");
  405.       enter_XREF ("_fgdpen");
  406.     }
  407. }
  408.  
  409. void draw_line (void)
  410. {
  411.   BOOL relative = FALSE;
  412.   BOOL colorset = FALSE;
  413.   BOOL box = FALSE;
  414.   BOOL boxfill = FALSE;
  415.   CODE *cx, *cx1, *cx2, *cx3, *cx4, *cx5, *cx6;
  416.  
  417.   if (sym == stepsym)
  418.     {
  419.       relative = TRUE;
  420.       insymbol ();
  421.     }
  422.   else
  423.     relative = FALSE;
  424.  
  425.   if (sym != lparen)
  426.     _error (14);
  427.   else
  428.     {
  429.       insymbol ();
  430.       make_sure_short (expr ());    /* x */
  431.       if (sym != comma)
  432.     _error (16);
  433.       else
  434.     {
  435.       insymbol ();
  436.       make_sure_short (expr ());    /* y */
  437.       if (sym != rparen)
  438.         _error (9);
  439.       else
  440.         {
  441.           gen ("move.w", "(sp)+", "d1");    /* ymin */
  442.           gen ("move.w", "(sp)+", "d0");    /* xmin */
  443.  
  444.           /* save x1 & y1 since they may be changed by expr() calls below. */
  445.           gen ("move.w", "d0", "_xmin");
  446.           cx1 = curr_code;
  447.           gen ("move.w", "d1", "_ymin");
  448.           cx2 = curr_code;
  449.           enter_BSS ("_xmin", "ds.w 1");
  450.           enter_BSS ("_ymin", "ds.w 1");
  451.  
  452.           gen ("move.l", "_RPort", "a1");
  453.           gen ("move.l", "_GfxBase", "a6");
  454.           enter_XREF ("_GfxBase");
  455.           enter_XREF ("_RPort");
  456.  
  457.           if (!relative)
  458.         {
  459.           /* move to x,y */
  460.           gen ("jsr", "_LVOMove(a6)", "  ");
  461.           cx = curr_code;    /* don't need this Move for boxfill */
  462.           /* XREF declared by box or line (see below) */
  463.         }
  464.  
  465.           insymbol ();
  466.         }
  467.  
  468.       /* second coordinate clause ? */
  469.       if (sym != minus)
  470.         {
  471.           if (relative)
  472.         {
  473.           /* no second coordinate clause */
  474.           /* draw line from last pen position to x,y */
  475.           gen ("move.l", "_RPort", "a1");
  476.           gen ("move.l", "_GfxBase", "a6");
  477.           gen ("jsr", "_LVODraw(a6)", "  ");
  478.           enter_XREF ("_LVODraw");
  479.         }
  480.           else
  481.         _error (21);
  482.         }
  483.       else
  484.         {
  485.           insymbol ();
  486.           if (sym != lparen)
  487.         _error (14);
  488.           else
  489.         {
  490.           insymbol ();
  491.           make_sure_short (expr ());    /* x */
  492.           if (sym != comma)
  493.             _error (16);
  494.           else
  495.             {
  496.               insymbol ();
  497.               make_sure_short (expr ());    /* y */
  498.               if (sym != rparen)
  499.             _error (9);
  500.               else
  501.             {
  502.               /* pen color ? */
  503.               insymbol ();
  504.               if (sym == comma)
  505.                 {
  506.                   insymbol ();
  507.                   if (sym != comma)        /* ",," -> no color-id */
  508.                 {
  509.                   colorset = TRUE;
  510.                   gen ("move.w", "_xmin", "-(sp)");    /* save d0 & d1 */
  511.                   cx3 = curr_code;
  512.                   gen ("move.w", "_ymin", "-(sp)");
  513.                   cx4 = curr_code;
  514.                   make_sure_short (expr ());
  515.                   gen ("move.l", "_RPort", "a1");
  516.                   gen ("move.l", "_GfxBase", "a6");
  517.                   gen ("move.w", "(sp)+", "d0");
  518.                   gen ("jsr", "_LVOSetAPen(a6)", "  ");
  519.                   gen ("move.w", "(sp)+", "_ymin");
  520.                   cx5 = curr_code;
  521.                   gen ("move.w", "(sp)+", "_xmin");    /* restore d0 & d1 */
  522.                   cx6 = curr_code;
  523.                   enter_XREF ("_LVOSetAPen");
  524.                 }
  525.                   else
  526.                 colorset = FALSE;
  527.                 }
  528.  
  529.               /* box or boxfill? */
  530.               if (sym == comma)
  531.                 {
  532.                   insymbol ();
  533.                   if (sym == ident)
  534.                 {
  535.                   if ((id[0] == 'B') && ((id[1] == '\0') || (id[1] == ':')))
  536.                     box = TRUE;
  537.                   else if (((id[0] == 'B') && (id[1] == 'F'))
  538.                      && ((id[2] == '\0') || (id[2] == ':')))
  539.                     boxfill = TRUE;
  540.                   else
  541.                     _error (20);
  542.                   insymbol ();
  543.                 }
  544.                 }
  545.  
  546.               /* draw the line, outline box, or filled box */
  547.               if (box)
  548.                 {
  549.                   gen ("move.w", "(sp)+", "d5");    /* y2 */
  550.                   gen ("move.w", "(sp)+", "d4");    /* x2 */
  551.                   gen ("move.w", "_ymin", "d3");    /* y1 */
  552.                   gen ("move.w", "_xmin", "d2");    /* x1 */
  553.                   /* x1=d2; y1=d3 x2=d4; y2=d5 */
  554.                   /* already moved to x1,y1 */
  555.                   gen ("move.l", "_RPort", "a1");
  556.                   gen ("move.l", "_GfxBase", "a6");
  557.                   gen ("move.w", "d4", "d0");
  558.                   gen ("move.w", "d3", "d1");
  559.                   gen ("jsr", "_LVODraw(a6)", "  ");    /* x1,y1 - x2,y1 */
  560.                   gen ("move.w", "d4", "d0");
  561.                   gen ("move.w", "d5", "d1");
  562.                   gen ("jsr", "_LVODraw(a6)", "  ");    /* x2,y1 - x2,y2 */
  563.                   gen ("move.w", "d2", "d0");
  564.                   gen ("move.w", "d5", "d1");
  565.                   gen ("jsr", "_LVODraw(a6)", "  ");    /* x2,y2 - x1,y2 */
  566.                   gen ("move.w", "d2", "d0");
  567.                   gen ("move.w", "d3", "d1");
  568.                   gen ("jsr", "_LVODraw(a6)", "  ");    /* x1,y2 - x1,y1 */
  569.                   enter_XREF ("_LVODraw");
  570.                   enter_XREF ("_LVOMove");
  571.                   enter_BSS ("_xmin", "ds.w 1");
  572.                   enter_BSS ("_ymin", "ds.w 1");
  573.                 }
  574.               else if (boxfill)
  575.                 {
  576.                   change (cx, "nop", "  ", "  ");    /* don't need Move */
  577.                   gen ("move.l", "_RPort", "a1");
  578.                   gen ("move.l", "_GfxBase", "a6");
  579.                   gen ("move.w", "(sp)+", "d3");    /* ymax */
  580.                   gen ("move.w", "(sp)+", "d2");    /* xmax */
  581.                   gen ("move.w", "_ymin", "d1");    /* ymin */
  582.                   gen ("move.w", "_xmin", "d0");    /* xmin */
  583.                   gen ("jsr", "_LVORectFill(a6)", "  ");
  584.                   enter_XREF ("_LVORectFill");
  585.                   enter_BSS ("_xmin", "ds.w 1");
  586.                   enter_BSS ("_ymin", "ds.w 1");
  587.                 }
  588.               else
  589.                 {
  590.                   /* draw line */
  591.                   gen ("move.l", "_RPort", "a1");
  592.                   gen ("move.l", "_GfxBase", "a6");
  593.                   gen ("move.w", "(sp)+", "d1");    /* y2 */
  594.                   gen ("move.w", "(sp)+", "d0");    /* x2 */
  595.                   /* already moved to x1,y1 */
  596.                   gen ("jsr", "_LVODraw(a6)", "  ");
  597.                   enter_XREF ("_LVODraw");
  598.                   enter_XREF ("_LVOMove");
  599.                   /* don't need to save x1 & x2 in _xmin & _ymin */
  600.                   change (cx1, "nop", "  ", "  ");
  601.                   change (cx2, "nop", "  ", "  ");
  602.                   if (colorset)
  603.                 {
  604.                   change (cx3, "nop", "  ", "  ");
  605.                   change (cx4, "nop", "  ", "  ");
  606.                   change (cx5, "nop", "  ", "  ");
  607.                   change (cx6, "nop", "  ", "  ");
  608.                 }
  609.                 }
  610.             }
  611.             }
  612.         }
  613.         }
  614.     }
  615.     }
  616.   if (colorset)
  617.     {
  618.       /* change back to old pen */
  619.       gen ("move.w", "_fgdpen", "d0");
  620.       gen ("move.l", "_RPort", "a1");
  621.       gen ("move.l", "_GfxBase", "a6");
  622.       gen ("jsr", "_LVOSetAPen(a6)", "  ");
  623.       enter_XREF ("_fgdpen");
  624.     }
  625. }
  626.  
  627. void color (void)
  628. {
  629.   /* foreground color */
  630.   insymbol ();
  631.   make_sure_short (expr ());
  632.   gen ("move.w", "(sp)+", "d0");
  633.   gen ("move.w", "d0", "_fg");    /* foreground pen for text color change */
  634.   gen ("move.w", "d0", "_fgdpen");    /* change global foreground color holder */
  635.   gen ("move.l", "_RPort", "a1");
  636.   gen ("move.l", "_GfxBase", "a6");
  637.   gen ("jsr", "_LVOSetAPen(a6)", "  ");
  638.   enter_XREF ("_LVOSetAPen");
  639.   enter_XREF ("_GfxBase");
  640.   enter_XREF ("_RPort");
  641.   enter_XREF ("_fgdpen");
  642.   enter_BSS ("_fg", "ds.w 1");
  643.  
  644.   if (sym == comma)
  645.     {
  646.       /* background color */
  647.       insymbol ();
  648.       make_sure_short (expr ());
  649.       gen ("move.w", "(sp)+", "d0");
  650.       gen ("move.w", "d0", "_bg");    /* background pen for text color change */
  651.       gen ("move.w", "d0", "_bgpen");    /* change global background pen color */
  652.       gen ("move.l", "_RPort", "a1");
  653.       gen ("move.l", "_GfxBase", "a6");
  654.       gen ("jsr", "_LVOSetBPen(a6)", "  ");
  655.       enter_XREF ("_LVOSetBPen");
  656.       enter_XREF ("_bgpen");
  657.       enter_BSS ("_bg", "ds.w 1");
  658.     }
  659.   else
  660.     {
  661.       /* default to current background pen */
  662.       gen ("move.w", "_bgpen", "_bg");
  663.       enter_XREF ("_bgpen");
  664.       enter_BSS ("_bg", "ds.w 1");
  665.     }
  666.  
  667.   /* call text color change routine */
  668.   gen ("move.w", "_fg", "d0");
  669.   gen ("move.w", "_bg", "d1");
  670.   gen ("jsr", "_changetextcolor", "  ");
  671.   enter_XREF ("_changetextcolor");
  672.   enter_XREF ("_DOSBase");
  673. }
  674.  
  675. void area (void)
  676. {
  677.   BOOL relative;
  678.   /* AREA [STEP](x,y) */
  679.  
  680.   insymbol ();
  681.   if (sym == stepsym)
  682.     {
  683.       insymbol ();
  684.       relative = TRUE;
  685.     }
  686.   else
  687.     relative = FALSE;
  688.  
  689.   if (sym != lparen)
  690.     _error (14);
  691.   else
  692.     {
  693.       /* x-coordinate */
  694.       insymbol ();
  695.       make_sure_short (expr ());
  696.       if (sym != comma)
  697.     _error (16);
  698.       else
  699.     {
  700.       /* y-coordinate */
  701.       insymbol ();
  702.       make_sure_short (expr ());
  703.       if (sym != rparen)
  704.         _error (9);
  705.       else
  706.         {
  707.           /* pop y-coordinate */
  708.           gen ("move.w", "(sp)+", "d1");
  709.           insymbol ();
  710.         }
  711.     }
  712.       /* pop x-coordinate */
  713.       gen ("move.w", "(sp)+", "d0");
  714.     }
  715.  
  716.   /* include point in area info' */
  717.   if (relative)
  718.     {
  719.       gen ("add.w", "_last_areaX", "d0");    /* d0 = x + lastareaY */
  720.       gen ("add.w", "_last_areaY", "d1");    /* d1 = y + lastareaY */
  721.       enter_XREF ("_last_areaX");
  722.       enter_XREF ("_last_areaY");
  723.     }
  724.  
  725.   gen ("jsr", "_area", "  ");
  726.  
  727.   enter_XREF ("_area");
  728.   enter_XREF ("_GfxBase");
  729.  
  730. }
  731.  
  732. void areafill (void)
  733. {
  734.   /* AREAFILL [mode] */
  735.  
  736.   insymbol ();
  737.  
  738.   if ((sym == shortconst) && ((shortval == 0) || (shortval == 1)))
  739.     {
  740.       switch (shortval)
  741.     {
  742.     case 0:
  743.       gen ("move.w", "#0", "d0");
  744.       break;
  745.     case 1:
  746.       gen ("move.w", "#1", "d0");
  747.       break;
  748.     }
  749.       insymbol ();
  750.     }
  751.   else
  752.     gen ("move.w", "#0", "d0");
  753.  
  754.   gen ("jsr", "_areafill", "  ");
  755.  
  756.   enter_XREF ("_areafill");
  757.   enter_XREF ("_GfxBase");
  758. }
  759.  
  760. void pattern (void)
  761. {
  762.   char addrbuf[40];
  763.   char numbuf[20];
  764.   BOOL linepatterncalled;
  765.  
  766.   /* PATTERN [line-pattern][,area-pattern] | RESTORE */
  767.  
  768.   insymbol ();
  769.  
  770.   if (sym == restoresym)
  771.     {
  772.       /* restore default pattern */
  773.       gen ("move.l", "#1", "d1");    /* RESTORE flag */
  774.       gen ("jsr", "_linepattern", "  ");
  775.       enter_XREF ("_linepattern");
  776.       gen ("move.l", "#1", "d1");    /* RESTORE flag */
  777.       gen ("jsr", "_areapattern", "  ");
  778.       enter_XREF ("_areapattern");
  779.       insymbol ();
  780.     }
  781.   else
  782.     {
  783.       if (sym != comma)
  784.     {
  785.       /* get line-pattern */
  786.       make_sure_short (expr ());
  787.       gen ("move.w", "(sp)+", "d0");    /* line-pattern */
  788.       gen ("move.l", "#0", "d1");    /* RESTORE flag */
  789.       gen ("jsr", "_linepattern", "  ");
  790.       enter_XREF ("_linepattern");
  791.       linepatterncalled = TRUE;
  792.     }
  793.       else
  794.     linepatterncalled = FALSE;
  795.  
  796.       if (sym == comma)
  797.     {
  798.       /* area-pattern */
  799.       insymbol ();
  800.       if ((sym == ident) && (obj == variable) && (exist (id, array)))
  801.         {
  802.           if (curr_item->type != shorttype)
  803.         _error (28);
  804.           else
  805.         {
  806.           if (!linepatterncalled)
  807.             {
  808.               /* line-pattern must be set
  809.                  to $FFFF if none specified,
  810.                  otherwise area-pattern doesn't
  811.                  seem to work! 
  812.                */
  813.               gen ("move.l", "#1", "d1");    /* set line-pattern to $FFFF */
  814.               gen ("jsr", "_linepattern", "  ");
  815.               enter_XREF ("_linepattern");
  816.             }
  817.  
  818.           /* get address of array */
  819.           itoa (-1 * curr_item->address, addrbuf, 10);
  820.           strcat (addrbuf, frame_ptr[lev]);
  821.           gen ("move.l", addrbuf, "a0");    /* start address of array */
  822.  
  823.           /* size of array? */
  824.           sprintf (numbuf, "#%ld", curr_item->size / 2);
  825.           gen ("move.l", numbuf, "d0");        /* size of array */
  826.  
  827.           gen ("move.l", "#0", "d1");    /* RESTORE flag */
  828.           gen ("jsr", "_areapattern", "  ");
  829.           enter_XREF ("_areapattern");
  830.           enter_XREF ("_MathBase");
  831.           enter_XREF ("_MathTransBase");    /* need to find Log2(size) */
  832.         }
  833.  
  834.           insymbol ();
  835.         }
  836.       else
  837.         _error (28);    /* short integer array expected */
  838.     }
  839.     }
  840. }
  841.  
  842. void scroll (void)
  843. {
  844.   /* SCROLL (xmin,ymin)-(xmax,ymax),delta-x,delta-y */
  845.  
  846.   insymbol ();
  847.  
  848.   if (sym != lparen)
  849.     _error (14);
  850.   else
  851.     {
  852.       insymbol ();
  853.       make_sure_short (expr ());    /* xmin */
  854.       if (sym != comma)
  855.     _error (16);
  856.       else
  857.     {
  858.       insymbol ();
  859.       make_sure_short (expr ());    /* ymin */
  860.       if (sym != rparen)
  861.         _error (9);
  862.       else
  863.         {
  864.           insymbol ();
  865.           if (sym != minus)
  866.         _error (21);
  867.           else
  868.         {
  869.           insymbol ();
  870.           if (sym != lparen)
  871.             _error (14);
  872.           else
  873.             {
  874.               insymbol ();
  875.               make_sure_short (expr ());    /* xmax */
  876.               if (sym != comma)
  877.             _error (16);
  878.               else
  879.             {
  880.               insymbol ();
  881.               make_sure_short (expr ());    /* ymax */
  882.               if (sym != rparen)
  883.                 _error (9);
  884.               else
  885.                 {
  886.                   insymbol ();
  887.                   if (sym != comma)
  888.                 _error (16);
  889.                   else
  890.                 {
  891.                   insymbol ();
  892.                   make_sure_short (expr ());    /* delta-x */
  893.                   if (sym != comma)
  894.                     _error (16);
  895.                   else
  896.                     {
  897.                       insymbol ();
  898.                       make_sure_short (expr ());    /* delta-y */
  899.                     }
  900.                 }
  901.                 }
  902.  
  903.               /* pop parameters */
  904.               gen ("move.w", "(sp)+", "d1");    /* delta-y */
  905.               gen ("neg.w", "d1", "  ");
  906.               gen ("move.w", "(sp)+", "d0");    /* delta-x */
  907.               gen ("neg.w", "d0", "  ");
  908.               gen ("move.w", "(sp)+", "d5");    /* ymax */
  909.               gen ("move.w", "(sp)+", "d4");    /* xmax */
  910.               gen ("move.w", "(sp)+", "d3");    /* ymin */
  911.               gen ("move.w", "(sp)+", "d2");    /* xmin */
  912.  
  913.               /* call ScrollRaster function */
  914.               gen ("movea.l", "_RPort", "a1");    /* RastPort */
  915.               gen ("movea.l", "_GfxBase", "a6");
  916.               gen ("jsr", "_LVOScrollRaster(a6)", "  ");
  917.               enter_XREF ("_LVOScrollRaster");
  918.               enter_XREF ("_GfxBase");
  919.               enter_XREF ("_RPort");
  920.             }
  921.             }
  922.         }
  923.         }
  924.     }
  925.     }
  926. }
  927.  
  928. void text_style (void)
  929. {
  930. /* STYLE n */
  931.   int stype;
  932.  
  933.   insymbol ();
  934.   stype = expr ();
  935.  
  936.   if (stype == stringtype)
  937.     _error (4);
  938.   else
  939.     {
  940.       if (make_integer (stype) == shorttype)
  941.     make_long ();
  942.       gen ("jsr", "_change_text_style", "  ");
  943.       gen ("addq", "#4", "sp");
  944.       enter_XREF ("_change_text_style");
  945.       enter_XREF ("_GfxBase");
  946.     }
  947. }
  948.  
  949. void text_font (void)
  950. {
  951. /* FONT name,size */
  952.   int ftype;
  953.  
  954.   insymbol ();
  955.  
  956.   if (expr () != stringtype)
  957.     _error (4);
  958.   else
  959.     {
  960.       if (sym != comma)
  961.     _error (16);
  962.       else
  963.     {
  964.       insymbol ();
  965.       ftype = expr ();
  966.  
  967.       if (ftype == stringtype)
  968.         _error (4);
  969.       else
  970.         {
  971.           if (make_integer (ftype) == shorttype)
  972.         make_long ();
  973.  
  974.           gen ("jsr", "_change_text_font", "  ");
  975.           gen ("addq", "#8", "sp");
  976.           enter_XREF ("_change_text_font");
  977.           enter_XREF ("_GfxBase");
  978.         }
  979.     }
  980.     }
  981. }
  982.  
  983. void gfx_get (void)
  984. {
  985. /* GET */
  986.   insymbol ();
  987. }
  988.  
  989. void gfx_put (void)
  990. {
  991. /* PUT */
  992.   insymbol ();
  993. }
  994.