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/fl8gpix.c $
21 * $Revision: 1.3 $
22 * $Author: kaboom $
23 * $Date: 1993/10/19 09:50:32 $
24 *
25 * Routines for reading pixels from a flat 8 canvas.
26 *
27 * This file is part of the 2d library.
28 *
29 * $Log: fl8gpix.c $
30 * Revision 1.3 1993/10/19 09:50:32 kaboom
31 * Replaced #include <grd.h" with new headers split from grd.h.
32 *
33 * Revision 1.2 1993/10/08 01:15:15 kaboom
34 * Changed quotes in #include lines to angle brackets for Watcom.
35 *
36 * Revision 1.1 1993/02/16 14:15:28 kaboom
37 * Initial revision
38 */
39
40 #include "cnvdat.h"
41
42 /* returns value of the unclipped pixel at (x, y). */
flat8_get_upixel(short x,short y)43 long flat8_get_upixel(short x, short y) {
44 uchar *p;
45
46 p = grd_bm.bits + grd_bm.row * y + x;
47 return (long)*p;
48 }
49
50 /* returns value of the clipped pixel at (x, y). returns -1 if pixel isn't
51 in the window bounds. */
flat8_get_pixel(short x,short y)52 long flat8_get_pixel(short x, short y) {
53 uchar *p;
54
55 if (x < grd_clip.left || x >= grd_clip.right || y < grd_clip.top || y >= grd_clip.bot)
56 return -1;
57
58 p = grd_bm.bits + grd_bm.row * y + x;
59 return (long)*p;
60 }
61