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/fl8g24.c $
21  * $Revision: 1.4 $
22  * $Author: kevin $
23  * $Date: 1994/10/17 14:59:58 $
24  *
25  * Routines for reading 24-bit pixels from a flat 8 canvas.
26  *
27  * This file is part of the 2d library.
28  *
29  * $Log: fl8g24.c $
30  * Revision 1.4  1994/10/17  14:59:58  kevin
31  * Use palette macros in preparation for switch to palette globals.
32  *
33  * Revision 1.3  1993/10/19  09:50:22  kaboom
34  * Replaced #include <grd.h" with new headers split from grd.h.
35  *
36  * Revision 1.2  1993/10/01  15:44:52  kaboom
37  * Converted to include clpcon.h instead of clip.h.
38  *
39  * Revision 1.1  1993/09/02  20:03:41  kaboom
40  * Initial revision
41  */
42 
43 #include "clpcon.h"
44 #include "cnvdat.h"
45 #include "scrdat.h"
46 
47 /* set an unclipped pixel in bank-switched memory. */
flat8_get_upixel24(short x,short y)48 long flat8_get_upixel24(short x, short y) {
49     uchar *p;
50     long *r;
51     int i;
52 
53     p = grd_canvas->bm.bits + grd_canvas->bm.row * y + x;
54     i = *p;
55     r = (long *)(grd_pal + 3 * i);
56     return *r & 0x00ffffff;
57 }
58 
59 /* set a clipped pixel in bank-switched memory.  return the clip code. */
flat8_get_pixel24(short x,short y)60 long flat8_get_pixel24(short x, short y) {
61     uchar *p;
62     long *r;
63     int i;
64 
65     if (x < grd_clip.left || x >= grd_clip.right || y < grd_clip.top || y >= grd_clip.bot)
66         return CLIP_ALL;
67     p = grd_canvas->bm.bits + grd_canvas->bm.row * y + x;
68     i = *p;
69     r = (long *)(grd_pal + 3 * i);
70     return *r & 0x00ffffff;
71 }
72