1 #include <lib/gdi/gfbdc.h>
3 #include <lib/base/init.h>
4 #include <lib/base/init_num.h>
6 #include <lib/gdi/accel.h>
10 gFBDC *gFBDC::instance;
18 eFatal("no framebuffer available");
20 fb->SetMode(720, 576, 32);
22 for (int y=0; y<576; y++) // make whole screen transparent
23 memset(fb->lfb+y*fb->Stride(), 0x00, fb->Stride());
30 surface.stride = fb->Stride();
31 surface.data = fb->lfb;
34 surface.data_phys = 50*1024*1024; // FIXME
36 int fb_size = surface.stride * surface.y;
38 if (fb->getNumPages() > 1)
40 m_enable_double_buffering = 1;
41 surface_back.type = 0;
44 surface_back.bpp = 32;
45 surface_back.bypp = 4;
46 surface_back.stride = fb->Stride();
47 surface_back.offset = surface.y;
48 surface_back.data = fb->lfb + fb_size;
49 surface_back.data_phys = surface.data_phys + fb_size;
53 m_enable_double_buffering = 0;
55 eDebug("%dkB available for acceleration surfaces.", (fb->Available() - fb_size)/1024);
57 if (gAccel::getInstance())
58 gAccel::getInstance()->setAccelMemorySpace(fb->lfb + fb_size, surface.data_phys + fb_size, fb->Available() - fb_size);
60 surface.clut.colors = 256;
61 surface.clut.data = new gRGB[surface.clut.colors];
63 surface_back.clut = surface.clut;
65 m_pixmap = new gPixmap(&surface);
67 memset(surface.clut.data, 0, sizeof(*surface.clut.data)*surface.clut.colors);
75 delete[] surface.clut.data;
79 void gFBDC::calcRamp()
82 float fgamma=gamma ? gamma : 1;
85 for (int i=0; i<256; i++)
87 float raw=i/255.0; // IIH, float.
88 float corr=pow(raw, fgamma) * 256.0;
90 int d=corr * (float)(256-brightness) / 256 + brightness;
97 rampalpha[i]=i*alpha/256;
100 for (int i=0; i<256; i++)
104 d=(d-128)*(gamma+64)/(128+64)+128;
105 d+=brightness-128; // brightness correction
112 rampalpha[i]=i*alpha/256;
115 rampalpha[255]=255; // transparent BLEIBT bitte so.
118 void gFBDC::setPalette()
120 if (!surface.clut.data)
123 for (int i=0; i<256; ++i)
125 fb->CMAP()->red[i]=ramp[surface.clut.data[i].r]<<8;
126 fb->CMAP()->green[i]=ramp[surface.clut.data[i].g]<<8;
127 fb->CMAP()->blue[i]=ramp[surface.clut.data[i].b]<<8;
128 fb->CMAP()->transp[i]=rampalpha[surface.clut.data[i].a]<<8;
133 void gFBDC::exec(gOpcode *o)
137 case gOpcode::setPalette:
145 if (m_enable_double_buffering)
148 surface = surface_back;
151 fb->setOffset(surface_back.offset);
155 case gOpcode::waitVSync:
163 gettimeofday(&now, 0);
165 int diff = (now.tv_sec - l.tv_sec) * 1000 + (now.tv_usec - l.tv_usec) / 1000;
166 eDebug("%d ms latency (%d fps)", diff, t * 1000 / (diff ? diff : 1));
182 void gFBDC::setAlpha(int a)
190 void gFBDC::setBrightness(int b)
198 void gFBDC::setGamma(int g)
206 void gFBDC::saveSettings()
210 void gFBDC::reloadSettings()
220 // eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
222 eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");