added files that were missing
[neuro.git] / src / video / drawing.c
blobbc4aefb92e156e604e79d20706aa79feb3a5ecba
1 /* drawing.c
2 * interface functions to core functions
3 */
5 /*-------------------- Extern Headers Including --------------------*/
8 /*-------------------- Local Headers Including ---------------------*/
9 #include <graphics.h>
10 #include <extlib.h>
12 /*-------------------- Main Module Header --------------------------*/
13 #include "video.h"
16 /*-------------------- Other ----------------------------*/
18 /*-------------------- Global Variables ----------------------------*/
20 /*-------------------- Static Variables ----------------------------*/
22 /*-------------------- Static Prototypes ---------------------------*/
26 /*-------------------- Static Functions ----------------------------*/
28 /*-------------------- Global Functions ----------------------------*/
29 v_elem *
30 Neuro_PushDraw(u32 layer, Rectan *isrc, Rectan *idst, v_object *isurface)
32 Graphics_SetSafeDrawOp(1);
33 return Graphics_AddDrawingInstruction(layer, TDRAW_STATIC, isrc, idst, isurface);
36 int
37 Neuro_FetchDraw(v_elem *eng, Rectan **psrc, u16 **px, u16 **py, v_object **osurface)
39 if (!eng)
40 return 1;
42 if (!eng->current)
43 return 1;
45 if (Graphics_GetSafeDrawOp() == 0)
46 return 1;
48 if (psrc)
49 *psrc = &eng->current->src;
51 if (px)
52 *px = &eng->current->dx;
54 if (py)
55 *py = &eng->current->dy;
57 if (osurface)
59 /*Debug_Val(0, "surface_ptr 0x%x addr surface_ptr 0x%x\n",
60 eng->surface_ptr, &eng->surface_ptr);*/
61 *osurface = eng->current->surface_ptr;
64 return 0;
67 int
68 Neuro_SetDraw(v_elem *eng, v_object *isurface)
70 if (!eng)
71 return 1;
73 if (!eng->current)
74 return 1;
76 if (!isurface)
77 return 1;
79 if (Graphics_GetSafeDrawOp() == 0)
80 return 1;
82 eng->current->surface_ptr = isurface;
84 return 0;
87 int
88 Neuro_CleanDraw(v_elem *eng)
90 Rectan buf;
91 v_object *screen;
93 if (!eng)
94 return 1;
96 if (!eng->current)
97 return 1;
99 if (Graphics_GetSafeDrawOp() == 0)
100 return 1;
102 buf.x = eng->current->dx;
103 buf.y = eng->current->dy;
104 buf.w = eng->current->src.w;
105 buf.h = eng->current->src.h;
107 /* we start by redrawing above the static
108 * image location to reset its image.
109 * it may be the background or black.
111 /*if (background)
113 Lib_BlitObject(background, &buf, sclScreen2, NULL);
115 else*/
117 screen = Neuro_GetScreenBuffer();
119 Lib_FillRect(screen, &buf, 0);
121 /* redraw_erased_for_object(eng); */
122 Graphics_RedrawSection(eng);
124 return 0;
127 /* this function is to tag the element to be
128 * redrawn.
131 Neuro_FlushDraw(v_elem *eng)
133 if (!eng)
134 return 1;
136 if (!eng->current)
137 return 1;
139 if (Graphics_GetSafeDrawOp() == 0)
140 return 1;
142 if (eng->current->type == TDRAW_SDRAWN)
144 eng->current->type = TDRAW_SREDRAW;
146 /* flag the algorithm to tell it something changed
147 * and an action needs to be taken.
149 Neuro_RedrawScreen();
150 /* draw_this_cycle = 1; */
152 else
153 return 1;
155 return 0;
159 Neuro_DestroyDraw(v_elem *eng)
161 if (!eng)
162 return 1;
164 if (!eng->current)
165 return 1;
167 if (Graphics_GetSafeDrawOp() == 0)
168 return 1;
170 if (eng->current->type == TDRAW_STATIC)
171 return 1;
173 if (Graphics_DrawIsPresent(eng) == 0)
174 return 1;
176 eng->current->type = TDRAW_SDESTROY;
177 /* clean_object(eng); */
179 Neuro_RedrawScreen();
180 /* draw_this_cycle = 1; */
182 return 0;
185 void
186 Neuro_PushStaticDraw(u32 layer, Rectan *isrc, Rectan *idst, v_object *isurface)
188 Graphics_AddDrawingInstruction(layer, TDRAW_STATIC, isrc, idst, isurface);
191 void
192 Neuro_PushDynamicDraw(u32 layer, Rectan *isrc, Rectan *idst, v_object *isurface)
194 Graphics_AddDrawingInstruction(layer, TDRAW_DYNAMIC, isrc, idst, isurface);
197 /* push a drawing instruction that will be deleted from the queue and raw
198 * after being drawn. This replaces the hackish override method with an
199 * ultra versatile one and much less costy ;P.
201 void
202 Neuro_PushVolatileDraw(u32 layer, Rectan *isrc, Rectan *idst, v_object *isurface)
204 Graphics_AddDrawingInstruction(layer, TDRAW_VOLATILE, isrc, idst, isurface);