refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / graphics / writepixel.c
blob29b829f6ccb5c7623757628728356722bcf182cf
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function WritePixel()
6 Lang: english
7 */
9 #include <graphics/rastport.h>
10 #include <graphics/clip.h>
11 #include <proto/graphics.h>
13 #include "graphics_intern.h"
14 #include "gfxfuncsupport.h"
16 static LONG pix_write(APTR pr_data, OOP_Object *bm, OOP_Object *gc,
17 WORD x, WORD y, struct GfxBase *GfxBase);
19 /*****************************************************************************
21 NAME */
23 AROS_LH3(LONG, WritePixel,
25 /* SYNOPSIS */
26 AROS_LHA(struct RastPort *, rp, A1),
27 AROS_LHA(WORD , x, D0),
28 AROS_LHA(WORD , y, D1),
30 /* LOCATION */
31 struct GfxBase *, GfxBase, 54, Graphics)
33 /* FUNCTION
34 Write the primary (A) pen colour to the given coordinates of a
35 RastPort.
37 INPUTS
38 rp - destination RastPort
39 x,y - coordinate
41 RESULT
42 0: pixel could be written
43 -1: coordinate was outside rastport
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
54 This function takes layers into account. Some pixel that is
55 being read is not found on the display-bitmap but in some
56 clipped rectangle (cliprect) in a layer structure.
58 *****************************************************************************/
60 AROS_LIBFUNC_INIT
62 IPTR pix;
64 FIX_GFXCOORD(x);
65 FIX_GFXCOORD(y);
67 if ((rp->Flags & RPF_NO_PENS) != 0)
69 HIDDT_GC_Intern *_gc = GCINT(&((rp)->longreserved[1]));
70 pix = _gc->fg;
72 else
73 pix = BM_PIXEL(rp->BitMap, (UBYTE)rp->FgPen);
75 return do_pixel_func(rp, x, y, pix_write, (APTR)pix, TRUE, GfxBase);
77 AROS_LIBFUNC_EXIT
78 } /* WritePixel */
81 static LONG pix_write(APTR pr_data, OOP_Object *bm, OOP_Object *gc,
82 WORD x, WORD y, struct GfxBase *GfxBase)
84 HIDD_BM_PutPixel(bm, x, y, (IPTR)pr_data);
86 return 0;