1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Source: r:/prj/lib/src/2d/RCS/fl8vlin.c $
21  * $Revision: 1.7 $
22  * $Author: lmfeeney $
23  * $Date: 1994/08/12 01:10:20 $
24  *
25  * Routines for drawing vertical lines into a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8vlin.c $
30  * Revision 1.7  1994/08/12  01:10:20  lmfeeney
31  * get  fill/solid parm from right place
32  *
33  * Revision 1.6  1994/06/11  01:44:53  lmfeeney
34  * unclipped flat8 line drawer routines for each fill type
35  * added canvas values as parameters
36  *
37  * Revision 1.5  1993/10/19  09:51:05  kaboom
38  * Replaced #include <grd.h" with new headers split from grd.h.
39  *
40  * Revision 1.4  1993/10/08  01:15:38  kaboom
41  * Changed quotes in #include liness to angle brackets for Watcom problem.
42  *
43  * Revision 1.3  1993/05/04  18:44:04  kaboom
44  * Changed vline to be inclusive of its endpoints.
45  *
46  * Revision 1.2  1993/03/02  19:42:08  kaboom
47  * Changed not to draw the bottommost pixel.
48  *
49  * Revision 1.1  1993/02/22  14:44:38  kaboom
50  * Initial revision
51  */
52 
53 #include "cnvdat.h"
54 #include "ctxmac.h"
55 #include "fill.h"
56 
57 /* unclipped vertical line with integral coordinates. */
58 
59 // MLA #pragma off (unreferenced)
60 
61 /* clut should be in _ns everywhere, it doesn't need its own function */
62 
gri_flat8_uvline_ns(short x0,short y0,short y1,long c,long parm)63 void gri_flat8_uvline_ns(short x0, short y0, short y1, long c, long parm) {
64     uchar *p;
65     short t;
66     int grow = grd_bm.row;
67 
68     if (y0 > y1) {
69         t = y0;
70         y0 = y1;
71         y1 = t;
72     }
73     if (gr_get_fill_type() == FILL_SOLID)
74         c = (uchar)parm;
75 
76     p = grd_bm.bits + y0 * grow + x0;
77     for (; y0 <= y1; y0++) {
78         *p = c;
79         p += grow;
80     }
81 }
82 
gri_flat8_uvline_clut(short x0,short y0,short y1,long c,long parm)83 void gri_flat8_uvline_clut(short x0, short y0, short y1, long c, long parm) {
84     uchar *p;
85     short t;
86     int grow = grd_bm.row;
87 
88     if (y0 > y1) {
89         t = y0;
90         y0 = y1;
91         y1 = t;
92     }
93     c = (long)(((uchar *)parm)[c]);
94     p = grd_bm.bits + y0 * grow + x0;
95     for (; y0 <= y1; y0++) {
96         *p = c;
97         p += grow;
98     }
99 }
100 
gri_flat8_uvline_xor(short x0,short y0,short y1,long c,long parm)101 void gri_flat8_uvline_xor(short x0, short y0, short y1, long c, long parm) {
102     uchar *p;
103     short t;
104     int grow = grd_bm.row;
105 
106     if (y0 > y1) {
107         t = y0;
108         y0 = y1;
109         y1 = t;
110     }
111     p = grd_bm.bits + y0 * grow + x0;
112     for (; y0 <= y1; y0++) {
113         *p = *p ^ c;
114         p += grow;
115     }
116 }
117 
118 /* punt */
gri_flat8_uvline_blend(short x0,short y0,short y1,long c,long parm)119 void gri_flat8_uvline_blend(short x0, short y0, short y1, long c, long parm) {
120     uchar *p;
121     short t;
122     int grow = grd_bm.row;
123 
124     if (y0 > y1) {
125         t = y0;
126         y0 = y1;
127         y1 = t;
128     }
129     p = grd_bm.bits + y0 * grow + x0;
130     for (; y0 <= y1; y0++) {
131         *p = c;
132         p += grow;
133     }
134 }
135