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/fl8hlin.c $
21  * $Revision: 1.8 $
22  * $Author: lmfeeney $
23  * $Date: 1994/08/12 01:09:33 $
24  *
25  * Routines for horizontal drawing lines into a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8hlin.c $
30  * Revision 1.8  1994/08/12  01:09:33  lmfeeney
31  * get fill/solid from right place
32  *
33  * Revision 1.7  1994/06/14  00:04:22  lmfeeney
34  * fixed stupid error in xor lines
35  *
36  * Revision 1.6  1994/06/11  01:46:09  lmfeeney
37  * unclipped flat8 line drawers routines for each fill type
38  * canvas values as parameters
39  *
40  * Revision 1.5  1993/10/19  09:50:34  kaboom
41  * Replaced #include <grd.h" with new headers split from grd.h.
42  *
43  * Revision 1.4  1993/10/08  01:15:17  kaboom
44  * Changed quotes in #include liness to angle brackets for Watcom problem.
45  *
46  * Revision 1.3  1993/05/04  18:43:15  kaboom
47  * Changed hline to be inclusive of its endpoints.
48  *
49  * Revision 1.2  1993/03/02  19:38:32  kaboom
50  * Changed not to draw rightmost pixel.
51  *
52  * Revision 1.1  1993/02/22  14:44:24  kaboom
53  * Initial revision
54  */
55 
56 #include "cnvdat.h"
57 #include "ctxmac.h"
58 #include "fill.h"
59 #include "lg.h"
60 #include <string.h>
61 
62 /* draw an unclipped horizontal line with integral coordinates. */
63 
64 // MLA #pragma off (unreferenced)
65 
66 /* clut should be in _ns everywhere, it doesn't need its own function */
67 
gri_flat8_uhline_ns(short x0,short y0,short x1,long c,long parm)68 void gri_flat8_uhline_ns(short x0, short y0, short x1, long c, long parm) {
69     uchar *p;
70     short t;
71 
72     if (x0 > x1) {
73         t = x0;
74         x0 = x1;
75         x1 = t;
76     }
77     if (gr_get_fill_type() == FILL_SOLID)
78         c = (uchar)parm;
79     p = grd_bm.bits + y0 * grd_bm.row + x0;
80     memset(p, c, x1 - x0 + 1);
81 }
82 
gri_flat8_uhline_clut(short x0,short y0,short x1,long c,long parm)83 void gri_flat8_uhline_clut(short x0, short y0, short x1, long c, long parm) {
84     uchar *p;
85     short t;
86 
87     if (x0 > x1) {
88         t = x0;
89         x0 = x1;
90         x1 = t;
91     }
92 
93     c = (long)(((uchar *)parm)[c]);
94     p = grd_bm.bits + y0 * grd_bm.row + x0;
95     memset(p, c, x1 - x0 + 1);
96 }
97 
gri_flat8_uhline_xor(short x0,short y0,short x1,long c,long parm)98 void gri_flat8_uhline_xor(short x0, short y0, short x1, long c, long parm) {
99     uchar *p;
100     short t;
101 
102     if (x0 > x1) {
103         t = x0;
104         x0 = x1;
105         x1 = t;
106     }
107 
108     for (p = grd_bm.bits + y0 * grd_bm.row + x0; x0 <= x1; p++, x0++)
109         *p = *p ^ c;
110 }
111 
112 /* punt */
gri_flat8_uhline_blend(short x0,short y0,short x1,long c,long parm)113 void gri_flat8_uhline_blend(short x0, short y0, short x1, long c, long parm) {
114     uchar *p;
115     short t;
116 
117     if (x0 > x1) {
118         t = x0;
119         x0 = x1;
120         x1 = t;
121     }
122     p = grd_bm.bits + y0 * grd_bm.row + x0;
123     memset(p, c, x1 - x0 + 1);
124 }
125