#include "defines.h"
#ifdef USE_DFB_API
-static IDirectFB *dfb=NULL;
-static IDirectFBSurface *primary_surface=NULL;
-static int screen_width=0;
-static int screen_height=0;
+// static IDirectFB *dfb=NULL;
+// static IDirectFBSurface *primary_surface=NULL;
+// static IDirectFBFont *font=NULL;
+// static int screen_width=0;
+// static int screen_height=0;
#endif
int display_init(int x,int y,int z,display *display,void *cell,int *argc,char **argv)
{
#ifdef USE_DFB_API
DFBSurfaceDescription surface_dsc;
- // DFBFontDescription font_dsc;
#endif
/* store dimensions */
/* the api(s) */
#ifdef USE_DFB_API
DirectFBInit(argc,&argv);
- DirectFBCreate(&dfb);
- dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
+ DirectFBCreate(&(display->dfb));
+ display->dfb->SetCooperativeLevel(display->dfb,DFSCL_FULLSCREEN);
surface_dsc.flags=DSDESC_CAPS;
surface_dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING;
- dfb->CreateSurface(dfb,&surface_dsc,&primary_surface);
- primary_surface->GetSize(primary_surface,&screen_width,&screen_height);
- display->dfb=dfb;
- display->primary_surface=primary_surface;
- display->screen_width=screen_width;
- display->screen_height=screen_height;
+ display->dfb->CreateSurface(display->dfb,&surface_dsc,&(display->primary_surface));
+ display->primary_surface->GetSize(display->primary_surface,&(display->screen_width),&(display->screen_height));
+
#endif
return 23;
}
+int display_release(display *display)
+{
+#ifdef USE_DFB_API
+ display->primary_surface->Release(display->primary_surface);
+ display->dfb->Release(display->dfb);
+#endif
+
+ return 23;
+}
+
+#ifdef USE_DFB_API
+int dfb_choose_color(u32 *cell_p,unsigned char *r,unsigned char *g,unsigned char *b)
+{
+ if((*cell_p&AMORPH)==AMORPH)
+ {
+ *r=0xff;
+ *g=0x00;
+ *b=0x00;
+ } else
+ {
+ *r=0x00;
+ *g=0x00;
+ *b=0xff;
+ }
+ return 23;
+}
+#endif
+
int display_draw(display *display,int x,int y,int z)
{
#ifdef USE_DFB_API
- int x_c,y_c;
+ int menu_x,menu_y,menu_w,menu_h; /* for the yellow box */
+ int x_c,y_c,z_c;
+ unsigned char r,g,b,a;
int display_faktor_x,display_faktor_y;
+ a=0xff; /* no alpha blending */
if(((display->max_x+display->max_y+DISPLAY_X_FREE)>=display->screen_width)|
((display->max_y+display->max_z+DISPLAY_Y_FREE)>=display->screen_height))
{
puts("resolution too low!");
return -23;
}
- display_faktor_x=display->screen_width/(display->max_x+display->max_y);
- display_faktor_y=display->screen_height/(display->max_z+display->max_y);
- /* draw x-z surface */
- // for(x_c=1;x_c<=display->max_x,x_c++)
- // {
-
-
+ display_faktor_x=display->screen_width/(display->max_x+display->max_y+DISPLAY_X_FREE);
+ display_faktor_y=display->screen_height/(display->max_z+display->max_y+DISPLAY_Y_FREE);
+ // if(display_faktor_x<display_faktor_y) display_faktor_y=display_faktor_x;
+ // if(display_faktor_y<display_faktor_x) display_faktor_x=display_faktor_y;
+ /* draw x-z surface */
+ y_c=y;
+ for(x_c=0;x_c<display->max_x;x_c++)
+ {
+ for(z_c=0;z_c<display->max_z;z_c++)
+ {
+ dfb_choose_color((u32 *)(display->cell_p+x_c+y_c*(display->max_x-1)+z_c*(display->max_x-1)*(display->max_y-1)),&r,&g,&b);
+ display->primary_surface->SetColor(display->primary_surface,r,g,b,a);
+ display->primary_surface->DrawRectangle(display->primary_surface,x_c*display_faktor_x+DISPLAY_X_FREE/3,z_c*display_faktor_y+DISPLAY_Y_FREE/3,display_faktor_x,display_faktor_y);
+ }
+ }
+ /* draw y-z surface */
+ x_c=x;
+ for(y_c=0;y_c<display->max_y;y_c++)
+ {
+ for(z_c=0;z_c<display->max_z;z_c++)
+ {
+ dfb_choose_color((u32 *)(display->cell_p+x_c+y_c*(display->max_x-1)+z_c*(display->max_x-1)*(display->max_y-1)),&r,&g,&b);
+ display->primary_surface->SetColor(display->primary_surface,r,g,b,a);
+ display->primary_surface->DrawRectangle(display->primary_surface,(y_c+display->max_x)*display_faktor_x+2*DISPLAY_X_FREE/3,z_c*display_faktor_y+DISPLAY_Y_FREE/3,display_faktor_x,display_faktor_y);
+ }
+ }
+ /* draw x-y surface */
+ z_c=z;
+ for(x_c=0;x_c<display->max_x;x_c++)
+ {
+ for(y_c=0;y_c<display->max_y;y_c++)
+ {
+ dfb_choose_color((u32 *)(display->cell_p+x_c+y_c*(display->max_x-1)+z_c*(display->max_x-1)*(display->max_y-1)),&r,&g,&b);
+ display->primary_surface->SetColor(display->primary_surface,r,g,b,a);
+ display->primary_surface->DrawRectangle(display->primary_surface,x_c*display_faktor_x+DISPLAY_X_FREE/3,(y_c+display->max_z)*display_faktor_y+2*DISPLAY_Y_FREE/3,display_faktor_x,display_faktor_y);
+ }
+ }
+ /* display info window */
+ r=0xff;
+ g=0xff;
+ b=0x00;
+ a=0xff;
+ menu_x=2*DISPLAY_X_FREE/3+display->max_x*display_faktor_x;
+ menu_y=2*DISPLAY_Y_FREE/3+display->max_z*display_faktor_y;
+ menu_w=display->max_y*display_faktor_x;
+ menu_h=display->max_y*display_faktor_y;
+ display->primary_surface->SetColor(display->primary_surface,0,0,0,0);
+ display->primary_surface->FillRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h);
+ display->primary_surface->SetColor(display->primary_surface,r,g,b,a);
+ display->primary_surface->DrawRectangle(display->primary_surface,menu_x,menu_y,menu_w,menu_h);
+ /* flip all to surface */
+ display->primary_surface->Flip(display->primary_surface,NULL,0);
#endif
return 23;
}