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: n:/project/lib/src/2d/RCS/fl8chfl8.c $
21  * $Revision: 1.4 $
22  * $Author: kevin $
23  * $Date: 1993/10/26 02:23:49 $
24  * $Log: fl8chfl8.c $
25  * Revision 1.4  1993/10/26  02:23:49  kevin
26  * Use default clut if passed cl=NULL.
27  *
28  * Revision 1.3  1993/10/19  09:50:17  kaboom
29  * Replaced #include <grd.h" with new headers split from grd.h.
30  *
31  * Revision 1.2  1993/10/08  01:15:07  kaboom
32  * Changed quotes in #include lines to angle brackets for Watcom.
33  *
34  * Revision 1.1  1993/10/06  14:39:25  kevin
35  * Initial revision
36  */
37 
38 #include "cnvdat.h"
39 #include "scrmac.h"
40 
41 /* draw an unclipped, horizontally flipped flat 8 bitmap to a flat 8
42    canvas through a color lookup table (clut). */
flat8_clut_hflip_flat8_ubitmap(grs_bitmap * bm,short x,short y,uchar * cl)43 void flat8_clut_hflip_flat8_ubitmap(grs_bitmap *bm, short x, short y, uchar *cl) {
44     short w;    /* bitmap width */
45     short h;    /* height */
46     uchar *src; /* pointer into source bitmap */
47     uchar *dst; /* pointer into canvas memory */
48     ushort row;
49 
50     if (cl == NULL)
51         cl = gr_get_clut();
52     h = bm->h;
53     src = bm->bits;
54     dst = grd_bm.bits + y * grd_bm.row + x + bm->w - 1;
55     while (h--) {
56         w = bm->w;
57         while (w--)
58             *dst-- = cl[*src++];
59         src += bm->row - bm->w;
60         dst += grd_bm.row + bm->w;
61     }
62 }
63