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/fl8clin.c $
21  * $Revision: 1.7 $
22  * $Author: kevin $
23  * $Date: 1994/10/17 14:59:57 $
24  *
25  * Routine to draw an rgb shaded line to a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8clin.c $
30  * Revision 1.7  1994/10/17  14:59:57  kevin
31  * Use palette macros in preparation for switch to palette globals.
32  *
33  * Revision 1.6  1994/06/11  01:24:08  lmfeeney
34  * guts of the routine moved to fl8{c,s}lin.h, per fill type
35  * line drawers are created by defining macros and including
36  * this file
37  *
38  * Revision 1.5  1994/05/06  18:18:38  lmfeeney
39  * rewritten for greater accuracy and speed
40  *
41  * Revision 1.4  1994/05/01  05:34:38  lmfeeney
42  * rewritten using simple dda algorithm (+ bit twiddle hack) for greater
43  * speed (20/30%) and improvement for e.g. diagonal lines
44  *
45  * Revision 1.3  1993/10/19  09:50:19  kaboom
46  * Replaced #include <grd.h" with new headers split from grd.h.
47  *
48  * Revision 1.2  1993/10/01  15:43:46  kaboom
49  * Pared down include files to reduce dependencies.
50  *
51  * Revision 1.1  1993/07/01  22:11:55  spaz
52  * Initial revision
53  */
54 
55 #include "cnvdat.h"
56 #include "fix.h"
57 #include "plytyp.h"
58 #include "scrdat.h"
59 #include <stdlib.h>
60 
61 // MLA #pragma off (unreferenced)
62 
63 #define fix_make_nof(x) fix_make(x, 0x0000)
64 #define macro_get_ipal(r, g, b) (long)((r >> 19) & 0x1f) | ((g >> 14) & 0x3e0) | ((b >> 9) & 0x7c00)
65 
66 #undef macro_plot_rgb
67 #define macro_plot_rgb(x, p, i) \
68     do {                        \
69         p[x] = grd_ipal[i];     \
70     } while (0)
71 
gri_flat8_ucline_norm(long c,long parm,grs_vertex * v0,grs_vertex * v1)72 void gri_flat8_ucline_norm(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
73 #include "fl8clin.h"
74 }
75 
76 #undef macro_plot_rgb
77 #define macro_plot_rgb(x, p, i)                        \
78     do {                                               \
79         p[x] = (long)(((uchar *)parm)[(grd_ipal[i])]); \
80     } while (0)
81 
gri_flat8_ucline_clut(long c,long parm,grs_vertex * v0,grs_vertex * v1)82 void gri_flat8_ucline_clut(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
83 #include "fl8clin.h"
84 }
85 
86 #undef macro_plot_rgb
87 #define macro_plot_rgb(x, p, i)      \
88     do {                             \
89         p[x] = p[x] ^ (grd_ipal[i]); \
90     } while (0)
91 
gri_flat8_ucline_xor(long c,long parm,grs_vertex * v0,grs_vertex * v1)92 void gri_flat8_ucline_xor(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
93 #include "fl8clin.h"
94 }
95 
96 /* punt */
97 #undef macro_plot_rgb
98 #define macro_plot_rgb(x, p, i)                        \
99     do {                                               \
100         p[x] = (long)(((uchar *)parm)[(grd_ipal[i])]); \
101     } while (0)
102 
gri_flat8_ucline_blend(long c,long parm,grs_vertex * v0,grs_vertex * v1)103 void gri_flat8_ucline_blend(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
104 #include "fl8clin.h"
105 }
106