1 #include <sys/syscalls.h>
5 #include <newos/drivers.h>
6 //#include "Renderer_vga.h"
7 #include "GraphicsContext.h"
9 #include "WindowManager.h"
10 #include "Renderer_vesa.h"
12 using namespace os::gui
;
19 struct ColorMapEntry
{
278 {255, 255, 255} // Transparent color
289 if(pci_find(&cfg
,VENDOR
,DEVICE
)) return 0;
290 fb
= (uchar
*) (cfg
.base
[0] & 0xfffffff0);
291 if(area_create(0x100000, 0, (void**) &(fb
), AREA_PHYSMAP
) < 0){
296 for(i
=0;i
<1024*768;i
++) fb
[i
] = i
/ 3072;
302 char *argv
[] = { "/boot/www", "www", 0 };
307 // char *vmem = (char*) 0xa0000;
308 char *vmem
= mga_find();
309 if(vmem
== 0) return 1;
311 // area_create(64*1024, 0, (void**) &vmem, AREA_PHYSMAP);
312 memset((void*) vmem
, 0, 1024 * 768);
314 Renderer
*screen
= new Renderer_vga((char*) vmem
, 1024, 768, 1024);
315 for (int i
= 0; i
< 256; i
++)
316 SetPalette(i
, colorTable
[i
].red
, colorTable
[i
].green
, colorTable
[i
].blue
);
318 new WindowManager(screen
);
320 execve(argv
[0],argv
,0);
325 int vesa_find(Renderer
**renderer
)
328 devfs_framebuffer_info fb
;
332 fd
= open("/dev/graphics/vesa/fb/0", 0);
334 printf("error opening vesa device\n");
338 err
= ioctl(fd
, IOCTL_DEVFS_GET_FRAMEBUFFER_INFO
, &fb
, sizeof(fb
));
340 printf("error getting framebuffer info\n");
344 err
= ioctl(fd
, IOCTL_DEVFS_MAP_FRAMEBUFFER
, &framebuffer
, sizeof(framebuffer
));
346 printf("error mapping framebuffer\n");
350 switch(fb
.color_space
) {
351 case COLOR_SPACE_RGB555
:
352 *renderer
= new Renderer_vesa_555((char *)framebuffer
, fb
.width
, fb
.height
, fb
.width
* 2);
361 int main(int argc
, char **argv
)
366 err
= vesa_find(&screen
);
368 printf("unable to find framebuffer\n");
373 Rect r = screen->Bounds();
376 screen->FillRect(r, 0xffffffff);
380 for(i = 0; i < 256; i++) {
381 screen->DrawLine(rand() % r.Width(), rand() % r.Height(), rand() % r.Width(), rand() % r.Height(), 0);
386 for(i = 0; i < 256; i++) {
392 source.SetTo(rand() % r.Width(), rand() % r.Height(), rand() % r.Width(), rand() % r.Height());
393 dest.SetTo(rand() % r.Width(), rand() % r.Height(), rand() % r.Width(), rand() % r.Height());
394 screen->CopyRect(source, dest);
398 Rect source(100, 100, 200, 200);
399 Rect dest(150, 150, 250, 250);
401 screen->CopyRect(source, dest);
407 Rect source(300, 300, 400, 400);
408 Rect dest(250, 250, 350, 350);
410 screen->CopyRect(source, dest);
413 WindowManager
*wm
= new WindowManager(screen
);