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/fl8fl8.c $
21  * $Revision: 1.5 $
22  * $Author: kaboom $
23  * $Date: 1993/10/19 09:50:21 $
24  *
25  * Routines for drawing flat 8 bitmaps into a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8fl8.c $
30  * Revision 1.5  1993/10/19  09:50:21  kaboom
31  * Replaced #include <grd.h" with new headers split from grd.h.
32  *
33  * Revision 1.4  1993/10/08  01:15:13  kaboom
34  * Changed quotes in #include liness to angle brackets for Watcom problem.
35  *
36  * Revision 1.3  1993/07/12  23:30:56  kaboom
37  * Inline memmove() uses movs.
38  *
39  * Revision 1.2  1993/03/29  18:22:11  kaboom
40  * Changed to inline version of memmove.
41  *
42  * Revision 1.1  1993/02/16  14:14:16  kaboom
43  * Initial revision
44  *
45  ********************************************************************
46  * Log from old flat8.c:
47  * Revision 1.7  1992/12/14  18:08:40  kaboom
48  * Added handing for transparency in the flat8_flat8_ubitmap()
49  * routine.
50  */
51 
52 #include "bitmap.h"
53 #include "cnvdat.h"
54 #include "lg.h"
55 #include <string.h>
56 
flat8_flat8_ubitmap(grs_bitmap * bm,short x,short y)57 void flat8_flat8_ubitmap(grs_bitmap *bm, short x, short y) {
58     uchar *m_src;
59     uchar *m_dst;
60     int w = bm->w;
61     int h = bm->h;
62     int i;
63     int brow, grow;
64 
65     brow = bm->row;
66     grow = grd_bm.row;
67 
68     m_src = bm->bits;
69     m_dst = grd_bm.bits + grow * y + x;
70 
71     if (bm->flags & BMF_TRANS)
72         while (h--) {
73             for (i = 0; i < w; i++)
74                 if (m_src[i] != 0)
75                     m_dst[i] = m_src[i];
76             m_src += brow;
77             m_dst += grow;
78         }
79     else
80         while (h--) {
81             memmove(m_dst, m_src, w);
82 
83             m_src += brow;
84             m_dst += grow;
85         }
86 }
87