4 * Low-level graphics handling
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Glass.
13 * Glass is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Glass is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with Glass. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 /*----- Header files ------------------------------------------------------*/
31 * ANSI standard headers
44 #include "steel/Steel.h"
46 #include "steel/bbc.h"
47 #include "steel/colourtran.h"
62 /*----- Private variables -------------------------------------------------*/
64 static int window__dashPos; /* Current rotating dash position */
66 /*----- Main code ---------------------------------------------------------*/
69 * void window__colourChange(int col1,int col2)
72 * Sets up the current foreground colour so that when plotted over colour
73 * col1 it looks like col2 and vice-versa. The effects of plotting over
74 * other colours is defined to be psychedelically interesting, but not
77 * Basically, all it does is suss out what the colours really mean and XOR
81 * int col1,int col2 == the Wimp colour numbers to swap between
84 void window__colourChange(int col1,int col2)
88 wimpt_noerr(wimp_readpalette(&pal));
89 wimpt_noerr(colourtran_return_colournumber(pal.c[col1],&x));
90 wimpt_noerr(colourtran_return_colournumber(pal.c[col2],&y));
91 if (os_swiv(XOS_SetColour,3,x^y))
95 wimpt_noerr(colourtran_colournumbertoGCOL(x^y,&x));
97 bbc_vduq(23,17,2,(x & 3)<<6,0,0,0,0,0,0);
105 * void window__setXORColour(glass_windPointer *w,int col)
108 * Sets up the current foreground colour so that it appears to be WIMP
109 * colour col on the specified window background. Lots of tedious
110 * ColourTransing to do on this, with no real reward, but at least it will
111 * look vaguely right in 256 colour modes.
114 * glass_windPointer *w == the window in which to set the colour
115 * int col == the colour to set
118 void window__setXORColour(glass_windPointer *w,int col)
120 int old=w->def->desc.w.colours[3];
122 /* --- Make sure the background isn't transparent --- */
127 window__colourChange(old,col);
131 * void window__makeDashPattern(int ptn)
134 * Sets the OS dash pattern to the given pattern (only the lowest byte
138 * int ptn == the LSB of this word contains the dash pattern as a bit
142 void window__makeDashPattern(int ptn)
147 wimpt_noerr(os_byte(163,&byte1,&byte2)); /* Dot-dash length */
148 bbc_vduq(23,6,ptn,ptn,ptn,ptn,ptn,ptn,ptn,ptn);
152 * void window__setDash(void)
155 * Sets the dashed pattern so that it looks as if a 'rotating' box is being
156 * dragged, like the WIMP's, only better... The box is set up so that a
157 * SINGLE exclusive-or plot will move the dash round.
160 #define SECTION(x,i) ((((x)<<(i)) & 0xff00) >> 8)
162 void window__setDash(void)
164 int dash=SECTION(0xFCFCFC,window__dashPos);
167 if (window__dashPos>7)
169 newDash=SECTION(0xFCFCFC,window__dashPos);
171 window__makeDashPattern(dash);
172 window__setXORColour(window__dragWind(),window__DRAGCOL);
176 * void window__rotate(int by)
179 * Rotates the current rotating-dash pattern by a given amount. This is
180 * used to rotate the dash box while the box is moving.
183 * int by == the number of steps to rotate the dash pattern.
186 void window__rotate(int by)
189 if (window__dashPos<0)
191 else if (window__dashPos>7)
193 window__makeDashPattern(SECTION(0xFCFCFC,window__dashPos));
194 window__setXORColour(window__dragWind(),window__DRAGCOL);
198 * void window__rectangle(int x,int y,int w,int h)
201 * Draws a rectangle, using the current dotted line pattern
204 * int x == the left side of the rectangle
205 * int y == the right side of the rectangle
206 * int w == the width of the rectangle (may be <0)
207 * int h == the height of the rectangle (may be <0)
210 void window__rectangle(int x,int y,int w,int h)
212 bbc_plot(bbc_DottedBoth+bbc_MoveCursorAbs,x,y);
213 bbc_plot(bbc_DottedBoth+bbc_DrawRelFore,0,h);
214 bbc_plot(bbc_DottedExInit+bbc_DrawRelFore,w,0);
215 bbc_plot(bbc_DottedExInit+bbc_DrawRelFore,0,-h);
216 bbc_plot(bbc_DottedExBoth+bbc_DrawRelFore,-w,0);