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
;
92 Neuro_SetImgPos(v_elem
*eng
, u16 px
, u16 py
)
101 if (Graphics_GetSafeDrawOp() == 0)
109 dst
.x
= eng
->current
->dx
;
110 dst
.y
= eng
->current
->dy
;
111 dst
.w
= eng
->current
->src
.w
;
112 dst
.h
= eng
->current
->src
.h
;
114 Lib_FillRect(Neuro_GetScreenBuffer(), &dst
, 0);
116 eng
->current
->dx
= px
;
117 eng
->current
->dy
= py
;
123 Neuro_SetImgSrcPos(v_elem
*eng
, Rectan
*psrc
)
132 if (Graphics_GetSafeDrawOp() == 0)
138 dst
.x
= eng
->current
->dx
;
139 dst
.y
= eng
->current
->dy
;
140 dst
.w
= eng
->current
->src
.w
;
141 dst
.h
= eng
->current
->src
.h
;
143 Lib_FillRect(Neuro_GetScreenBuffer(), &dst
, 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
)
227 eng
->current
->type
= TDRAW_STATIC
;
229 /* flag the algorithm to tell it something changed
230 * and an action needs to be taken.
232 Neuro_RedrawScreen();
233 /* draw_this_cycle = 1; */
242 Neuro_DestroyDraw(v_elem
*eng
)
250 if (Graphics_GetSafeDrawOp() == 0)
253 if (eng
->current
->type
== TDRAW_STATIC
)
256 if (Graphics_DrawIsPresent(eng
) == 0)
259 /* eng->current->type = TDRAW_SDESTROY; */
261 /* the official way of deleting an element */
262 Graphics_DestroyElement(eng
);
264 /* clean_object(eng); */
268 Neuro_RedrawScreen();
269 /* draw_this_cycle = 1; */
275 Neuro_PushStaticDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
277 Graphics_AddDrawingInstruction(layer
, TDRAW_STATIC
, isrc
, idst
, isurface
);
281 Neuro_PushDynamicDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
283 Graphics_AddDrawingInstruction(layer
, TDRAW_DYNAMIC
, isrc
, idst
, isurface
);
286 /* push a drawing instruction that will be deleted from the queue and raw
287 * after being drawn. This replaces the hackish override method with an
288 * ultra versatile one and much less costy ;P.
291 Neuro_PushVolatileDraw(u32 layer
, Rectan
*isrc
, Rectan
*idst
, v_object
*isurface
)
293 Graphics_AddDrawingInstruction(layer
, TDRAW_VOLATILE
, isrc
, idst
, isurface
);