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/fl8p24.c $
21  * $Revision: 1.5 $
22  * $Author: kevin $
23  * $Date: 1994/10/17 14:59:59 $
24  *
25  * Routines for drawing 24-bit pixels onto a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  */
29 
30 #include "clpcon.h"
31 #include "cnvdat.h"
32 #include "rgb.h"
33 #include "scrdat.h"
34 
35 /* set an unclipped pixel in bank-switched memory.  draws 8-8-8 long
36    rgb c at (x,y). */
flat8_set_upixel24(long c,short x,short y)37 void flat8_set_upixel24(long c, short x, short y) {
38     uchar *p;
39     int i;
40 
41     i = gr_index_lrgb(c);
42     p = grd_bm.bits + grd_bm.row * y + x;
43     *p = grd_ipal[i];
44 }
45 
46 /* set a clipped pixel in bank-switched memory.  draws an 8-8-8 long
47    rgb c at (x,y).  return the clip code. */
flat8_set_pixel24(long c,short x,short y)48 int flat8_set_pixel24(long c, short x, short y) {
49     uchar *p;
50     int i;
51 
52     if (x < grd_clip.left || x > grd_clip.right || y < grd_clip.top || y > grd_clip.bot)
53         return CLIP_ALL;
54     i = gr_index_lrgb(c);
55     p = grd_canvas->bm.bits + grd_canvas->bm.row * y + x;
56     *p = grd_ipal[i];
57 
58     return CLIP_NONE;
59 }
60