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/fl8fl8c.c $
21  * $Revision: 1.2 $
22  * $Author: kevin $
23  * $Date: 1994/10/04 18:45:42 $
24  *
25  * Routines for drawing flat8 bitmaps into a flat8 canvas through a clut.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8fl8c.c $
30  * Revision 1.2  1994/10/04  18:45:42  kevin
31  * added clut fill mode specific function.  Renamed old proc.
32  *
33  * Revision 1.1  1994/03/15  13:15:51  kevin
34  * Initial revision
35  *
36  */
37 
38 #include "bitmap.h"
39 #include "cnvdat.h"
40 #include "fl8tf.h"
41 
gri_flat8_fill_clut_ubitmap(grs_bitmap * bm,short x,short y)42 void gri_flat8_fill_clut_ubitmap(grs_bitmap *bm, short x, short y) {
43     gri_flat8_clut_ubitmap(bm, x, y, (uchar *)(grd_gc.fill_parm));
44 }
45 
gri_flat8_clut_ubitmap(grs_bitmap * bm,short x,short y,uchar * cl)46 void gri_flat8_clut_ubitmap(grs_bitmap *bm, short x, short y, uchar *cl) {
47     uchar *src, *dst, *srcf;
48     short w = bm->w;
49     short h = bm->h;
50     int ds = bm->row - w;
51     int dd = grd_bm.row - w;
52 
53     src = bm->bits;
54     dst = grd_bm.bits + grd_bm.row * y + x;
55 
56     if (bm->flags & BMF_TRANS)
57         while (h--) {
58             for (srcf = src + w; src < srcf; src++, dst++)
59                 if ((*src) != 0)
60                     *dst = cl[*src];
61             src += ds;
62             dst += dd;
63         }
64     else
65         while (h--) {
66             for (srcf = src + w; src < srcf; src++, dst++)
67                 *dst = cl[*src];
68             src += ds;
69             dst += dd;
70         }
71 }
72