libs/neuronet: Implemented the new function NNet_GetMaster.
[neuro.git] / src / video / pixels.c
blobdefb72e90378bbfd1bfd29ea7b93fa7efebf7a93
2 /*
3 * libneuro, a light weight abstraction of high or lower libraries
4 * and toolkit for applications.
5 * Copyright (C) 2005-2006 Nicholas Niro, Robert Lemay
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 /* pixels.c
23 * Module : Pixels
25 * not yet included in the main stream, this is a dormant module
28 /*-------------------- Extern Headers Including --------------------*/
31 /*-------------------- Local Headers Including ---------------------*/
32 #include <global.h>
33 #include <extlib.h> /* Lib_PutPixel and Lib_GetPixel */
35 /*-------------------- Main Module Header --------------------------*/
36 #include "video.h"
39 /*-------------------- Other ----------------------------*/
41 /*-------------------- Global Variables ----------------------------*/
43 /*-------------------- Static Variables ----------------------------*/
45 /* 1 is that the pixels will be cleaned during this cycle and 0 is no it won't */
46 static u8 clean_pixel_in_this_cycle;
48 /* the pixels buffer */
49 static EBUF *_Pixel;
51 typedef struct PIXEL_ENGINE
53 u32 x, y;
54 }PIXEL_ENGINE;
56 /*-------------------- Static Prototypes ---------------------------*/
60 /*-------------------- Static Functions ----------------------------*/
62 static void
63 cleanPixels(void)
65 EBUF *tmp;
66 Rectan buf;
67 PIXEL_ENGINE *pix;
68 u32 current;
70 tmp = _Pixel;
72 current = Neuro_GiveEBufCount(tmp);
74 if (current <= 0)
75 return;
78 if (!Neuro_EBufIsEmpty(tmp))
80 while (current-- > 0)
82 pix = Neuro_GiveEBuf(tmp, current);
83 buf.x = pix->x;
84 buf.y = pix->y;
86 buf.w = 1;
87 buf.h = 1;
90 Neuro_CleanEBuf(&_Pixel);
93 /*-------------------- Global Functions ----------------------------*/
95 void
96 Graphics_PutPixel(v_object *vobj, u32 x, u32 y, u32 pixel)
98 /*EBUF *tmp;
99 PIXEL_ENGINE *buf;
100 u32 current;
101 Rectan check;
104 check.x = x;
105 check.y = y;
106 check.h = 1;
107 check.w = 1;
109 if (secureBoundsCheck(&check))
111 printf("Unsecure Pixel position have been catched, dropping the instruction\n");
112 return;
115 tmp = _Pixel;
116 Neuro_AllocEBuf(tmp, sizeof(PIXEL_ENGINE*), sizeof(PIXEL_ENGINE));
118 current = Neuro_GiveEBufCount(tmp);
119 buf = Neuro_GiveEBuf(tmp, current);*/
121 Lib_PutPixel(vobj, x, y, pixel);
123 buf->x = x;
124 buf->y = y;
129 Graphics_GetPixel(v_object *vobj, u32 x, u32 y)
131 return Lib_GetPixel(vobj, x, y);
134 void
135 Graphics_CleanPixels(void)
137 clean_pixel_in_this_cycle = 1;
139 cleanPixels();
142 /*-------------------- Poll ----------------------------------------*/
144 void
145 Pixels_Poll(void)
150 /*-------------------- Constructor Destructor ----------------------*/
153 Pixels_Init(void)
155 Neuro_CreateEBuf(&_Pixel);
157 return 0;
160 void
161 Pixels_Clean(void)
163 Neuro_CleanEBuf(&_Pixel);