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/fl8wclin.c $
21  * $Revision: 1.3 $
22  * $Author: kevin $
23  * $Date: 1994/10/17 15:00:00 $
24  *
25  * Routines to draw wire polys.
26  *
27  * This file is part of the 2d library.
28  *
29  */
30 
31 #include "cnvdat.h"
32 #include "plytyp.h"
33 #include "scrdat.h"
34 
35 #define gr_get_ipal_index(r, g, b) (long)((((r) >> 19) & 0x1f) | (((g) >> 14) & 0x3e0) | (((b) >> 9) & 0x7c00))
36 #define do_hline_inc_x                               \
37     do {                                             \
38         c = grd_ipal[gr_get_ipal_index(r0, g0, b0)]; \
39         p[x] = c;                                    \
40         r0 += dr, g0 += dg, b0 += db;                \
41         x++;                                         \
42     } while (x < x_new)
43 #define do_hline_dec_x                                   \
44     if (x == x_new) {                                    \
45         c = grd_ipal[gr_get_ipal_index(r0, g0, b0)];     \
46         p[x] = c;                                        \
47         r0 += dr, g0 += dg, b0 += db;                    \
48     } else                                               \
49         do {                                             \
50             x--;                                         \
51             c = grd_ipal[gr_get_ipal_index(r0, g0, b0)]; \
52             p[x] = c;                                    \
53             r0 += dr, g0 += dg, b0 += db;                \
54         } while (x > x_new)
55 
56 // MLA #pragma off (unreferenced)
gri_flat8_wire_poly_ucline_norm(long c,long parm,grs_vertex * v0,grs_vertex * v1)57 void gri_flat8_wire_poly_ucline_norm(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
58 #include "fl8wclin.h"
59 }
60     // MLA #pragma on (unreferenced)
61 
62 #undef do_hline_inc_x
63 #define do_hline_inc_x                               \
64     do {                                             \
65         c = grd_ipal[gr_get_ipal_index(r0, g0, b0)]; \
66         p[x] = clut[c];                              \
67         r0 += dr, g0 += dg, b0 += db;                \
68         x++;                                         \
69     } while (x < x_new)
70 #undef do_hline_dec_x
71 #define do_hline_dec_x                                   \
72     if (x == x_new) {                                    \
73         c = grd_ipal[gr_get_ipal_index(r0, g0, b0)];     \
74         p[x] = clut[c];                                  \
75         r0 += dr, g0 += dg, b0 += db;                    \
76     } else                                               \
77         do {                                             \
78             x--;                                         \
79             c = grd_ipal[gr_get_ipal_index(r0, g0, b0)]; \
80             p[x] = clut[c];                              \
81             r0 += dr, g0 += dg, b0 += db;                \
82         } while (x > x_new)
83 
gri_flat8_wire_poly_ucline_clut(long c,long parm,grs_vertex * v0,grs_vertex * v1)84 void gri_flat8_wire_poly_ucline_clut(long c, long parm, grs_vertex *v0, grs_vertex *v1) {
85     uchar *clut = (uchar *)parm;
86 #include "fl8wclin.h"
87 }
88