2 * libneuro, a light weight abstraction of high or lower libraries
3 * and toolkit for applications.
4 * Copyright (C) 2005-2006 Nicholas Niro, Robert Lemay
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * interface functions to core functions
26 /*-------------------- Extern Headers Including --------------------*/
27 #include <string.h> /* memcpy */
29 /*-------------------- Local Headers Including ---------------------*/
33 /*-------------------- Main Module Header --------------------------*/
37 /*-------------------- Other ----------------------------*/
39 /*-------------------- Global Variables ----------------------------*/
41 /*-------------------- Static Variables ----------------------------*/
43 /*-------------------- Static Prototypes ---------------------------*/
47 /*-------------------- Static Functions ----------------------------*/
49 /*-------------------- Global Functions ----------------------------*/
51 Neuro_PushDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
53 if (Graphics_GetSafeDrawOp() == 0)
57 return Graphics_AddDrawingInstruction(layer
, TDRAW_STATIC
, isrc
, idst
, isurface
);
61 Neuro_FetchDraw(v_elem
*eng
, Rectan
*psrc
, u16
*px
, u16
*py
, v_object
**osurface
)
69 if (Graphics_GetSafeDrawOp() == 0)
73 memcpy(psrc
, &eng
->current
->src
, sizeof(Rectan
));
76 *px
= eng
->current
->dx
;
79 *py
= eng
->current
->dy
;
83 /*Debug_Val(0, "surface_ptr 0x%x addr surface_ptr 0x%x\n",
84 eng->surface_ptr, &eng->surface_ptr);*/
85 *osurface
= eng
->current
->surface_ptr
;
93 Neuro_SetImgPos(v_elem
*eng
, u16 px
, u16 py
)
101 if (Graphics_GetSafeDrawOp() == 0)
107 eng
->current
->dx
= px
;
108 eng
->current
->dy
= py
;
114 Neuro_SetImgLayer(v_elem
*eng
, u32 layer
)
122 if (Graphics_GetSafeDrawOp() == 0)
125 eng
->current
->layer
= layer
;
131 Neuro_SetImgSrcPos(v_elem
*eng
, Rectan
*psrc
)
139 if (Graphics_GetSafeDrawOp() == 0)
145 memcpy(&eng
->current
->src
, psrc
, sizeof(Rectan
));
151 Neuro_SetDraw(v_elem
*eng
, v_object
*isurface
)
162 if (Graphics_GetSafeDrawOp() == 0)
165 eng
->current
->surface_ptr
= isurface
;
171 Neuro_CleanDraw(v_elem
*eng
)
182 if (Graphics_GetSafeDrawOp() == 0)
185 buf
.x
= eng
->current
->dx
;
186 buf
.y
= eng
->current
->dy
;
187 buf
.w
= eng
->current
->src
.w
;
188 buf
.h
= eng
->current
->src
.h
;
190 /* we start by redrawing above the static
191 * image location to reset its image.
192 * it may be the background or black.
196 Lib_BlitObject(background, &buf, sclScreen2, NULL);
200 screen
= Neuro_GetScreenBuffer();
202 Lib_FillRect(screen
, &buf
, 0);
204 /* redraw_erased_for_object(eng); */
205 Graphics_RedrawSection(eng
);
210 /* this function is to tag the element to be
214 Neuro_FlushDraw(v_elem
*eng
)
222 if (Graphics_GetSafeDrawOp() == 0)
225 if (eng
->current
->type
== TDRAW_SDRAWN
)
229 dst
.x
= eng
->current
->dx
;
230 dst
.y
= eng
->current
->dy
;
231 dst
.w
= eng
->current
->src
.w
;
232 dst
.h
= eng
->current
->src
.h
;
235 eng
->current
->type
= TDRAW_STATIC
;
237 /* flag the algorithm to tell it something changed
238 * and an action needs to be taken.
240 Neuro_RedrawScreen();
241 /* draw_this_cycle = 1; */
250 Neuro_DestroyDraw(v_elem
*eng
)
258 if (Graphics_GetSafeDrawOp() == 0)
261 if (eng
->current
->type
== TDRAW_STATIC
)
264 if (Graphics_DrawIsPresent(eng
) == 0)
267 /* eng->current->type = TDRAW_SDESTROY; */
269 /* the official way of deleting an element */
270 Graphics_DestroyElement(eng
);
272 /* clean_object(eng); */
276 Neuro_RedrawScreen();
277 /* draw_this_cycle = 1; */
283 Neuro_PushStaticDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
285 Graphics_AddDrawingInstruction(layer
, TDRAW_STATIC
, isrc
, idst
, isurface
);
289 Neuro_PushDynamicDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
291 Graphics_AddDrawingInstruction(layer
, TDRAW_DYNAMIC
, isrc
, idst
, isurface
);
294 /* push a drawing instruction that will be deleted from the queue and raw
295 * after being drawn. This replaces the hackish override method with an
296 * ultra versatile one and much less costy ;P.
299 Neuro_PushVolatileDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
301 Graphics_AddDrawingInstruction(layer
, TDRAW_VOLATILE
, isrc
, idst
, isurface
);