Пример #1
0
int main(void)
{
    vga_init();

    /* Create virtual screen. */
    vbuf = malloc(VWIDTH * VHEIGHT);
    gl_setcontextvirtual(VWIDTH, VHEIGHT, 1, 8, vbuf);

    /* Set Mode X-style 320x240x256. */
    vga_setmode(G320x240x256);
    gl_setrgbpalette();
    vga_clear();

    boxes();

    demo1();

    demo2();

    vga_setmode(G320x200x256);	/* Set linear 320x200x256. */
    gl_setrgbpalette();

    demo3();

    vga_setmode(TEXT);
    exit(0);
}
Пример #2
0
void vga_init(void)
{
#if 0	
	card_base = pci_lookupclass(0x300);
	if (!card_base)
		card_base = pci_lookupclass(0x0001);
	if (!card_base)
		return;
#endif
	x = 0;
	y = 0;
	attrib = 7;
#if 0
	vendor = pci_read_config_word(card_base, PCI_VENDOR_ID);
	device = pci_read_config_word(card_base, PCI_DEVICE_ID);
#endif
	io_base = (volatile char *)0x00000000;
	charmap = (volatile char *)0x000b8000;
	scrmem  = (volatile char *)0x000b8000;

	io_base[0x3c3] = 1;

	vendor = 0;
	device = 0;
	
	vga_load_regs(list, vendor, device);

	io_base[0x3c0] = 0x20;
	io_base[0x3c6] = 0xff;

	vga_clear();
	vga_setcursor();

	display_fn = vga_print;
}
Пример #3
0
void win()
{
	vga_clear();
	offset(4, graphic_vict, vga_get_width()/2 - 150, vga_get_height()/2 - 150);
	vga_addpoly(4, graphic_vict);
	vga_sync();
	while(1);
}
Пример #4
0
void game_over()
{
	vga_clear();
	offset(6, graphic_game_over, vga_get_width()/2 - 150, vga_get_height()/2 - 150);
	vga_addpoly(6, graphic_game_over);
	vga_sync();
	while(1);
}
Пример #5
0
device_t *vga_init()
{
        get_cursor_pos(&xpos, &ypos);
        vga_clear();

        vga_device.read = 0;
        vga_device.write = vga_write;

        return &vga_device;
}
Пример #6
0
void x_cleardev(void)
{
#ifdef GGI
 ggiSetGCForeground (ggiVis, ggi_getcolor (0));
 ggiFillscreen(ggiVis);
 ggiSetGCForeground (ggiVis, ggi_getcolor (xg_color));
#else
 vga_clear();
#endif
}
Пример #7
0
void bootscreen(void)
{
   vga_setcolor(0x07);
   vga_clear();
   vga_setcolor(C_BLUESCR);
   
   int location = vga_getloc();
   for(size_t i=0; i<80; i++)    { addch(HLINE1); }
   vga_moveptr(location+4);
   printf("[ Avian Kernel " VERSION " ]\n\n");
   
   vga_setcolor(0x07);
}
Пример #8
0
static int pcconsole_open(cfe_devctx_t *ctx)
{
    pcconsole_t *softc = ctx->dev_softc;

    pcconsole_current = softc;

    softc->kbd_in = 0;
    softc->kbd_out = 0;

    vga_clear(&(softc->vga));
    vga_setcursor(&(softc->vga),0,0);
    
    return 0;
}
Пример #9
0
void avian_main(void) 
{  
   bootscreen();
   init();
   
   //anica_format_device(2880,512,0);
   system("mount fda C");
   system("enter C:$");

   printf("Entering shell\n");
   shell();
   
   vga_clear();
   printf("Kernel has shut down\n");
}
Пример #10
0
void main(uint32_t magic, const multiboot_info_t *mbi)
{
    vga_clear();
    check_multiboot(magic, mbi);
    init_memory(mbi);

    //-----

    struct kmem_cache *cache = kmem_cache_create("test", 1024, 1024);

    void *obj1 = kmem_cache_alloc(cache, KMEM_ZEROED);
    void *obj2 = kmem_cache_alloc(cache, KMEM_ZEROED);
    void *obj3 = kmem_cache_alloc(cache, KMEM_ZEROED);
    void *obj4 = kmem_cache_alloc(cache, KMEM_ZEROED);
    void *obj5 = kmem_cache_alloc(cache, KMEM_ZEROED);

    printf("obj1: 0x%p\n", obj1);
    printf("obj2: 0x%p\n", obj2);
    printf("obj3: 0x%p\n", obj3);
    printf("obj4: 0x%p\n", obj4);
    printf("obj5: 0x%p\n", obj5);

    kmem_cache_free(cache, obj2);
    obj2 = kmem_cache_alloc(cache, KMEM_DEFAULT);
    printf("obj2: 0x%p\n", obj2);

    kmem_cache_free(cache, obj1);
    kmem_cache_free(cache, obj2);
    kmem_cache_free(cache, obj3);
    kmem_cache_free(cache, obj4);
    kmem_cache_free(cache, obj5);

    kmem_cache_print_info(cache);

    kmem_cache_destroy(cache);

    init_interrupts();

    __asm__ __volatile__("int $0x3");
    __asm__ __volatile__("int $0x4");

    while (1)
    {
    }

    ASSERT_MSG(0, "control reached end of main");
}
Пример #11
0
static void vga_write_string(const char *buffer, int len)
{
	int i;

	for (i = 0; i < len; i++) {
		switch (buffer[i]) {
		case 8:
			if (x > 0)
				x -= 1;
			break;

		case 9:
			x = (x | 7) + 1;
			break;

		case '\n':
			y += 1;
			x = 0;
			break;

		case '\r':
			x = 0;
			break;

		case 12:
			vga_clear();
			break;

		case 31 ... 255:
			scrmem[(y * NUM_COLS + x) * 2] = buffer[i];
			scrmem[(y * NUM_COLS + x) * 2 + 1] = attrib;
			x += 1;
			break;
		}

		if (x >= NUM_COLS) {
			x = 0;
			y += 1;
		}
		if (y >= NUM_ROWS)
			y = 0;
//y = NUM_ROWS;
	}
}
Пример #12
0
void kmain( struct multiboot_info * info )
{
	page_init();	/* we start up with a hacked segment base, so */
	gdt_init();		/* get paging enabled and a real GDT installed first. */
	
	vga_clear();
	
	put_status_line( 1, "Paging enabled." );
	put_status_line( 1, "Starting Physical Memory Allocator..." );
	phys_alloc_init( info );
	
	put_status_line( 1, "Starting Kernel Heap Allocator..." );
	kmalloc_init();	
	page_init_finish();
	
	/* install other default handlers */
	
	timer_init( 50 );
	
	/* test the heap allocator */
	int * foo = kmalloc( 240 );
	vga_puts( "Allocation test: " );
	vga_put_hex( (u32) foo );
	vga_puts( "\n" );
	
	*foo = 42;	/* shouldn't die */
	
	put_status_line( 1, "Scanning PCI buses..." );
	pci_enum_devices();
	
	/* finished initializing, so turn on the interrupts */
	enable_interrupts();
	
//	asm volatile( "int $0x3" );
	
	for(;;)
		halt();
}
Пример #13
0
int vga_init(void)
{
        assert(!initialized);

        vga.base   = (uint8_t *) VGA_BASE;
        vga.row    = 0;
        vga.column = 0;

        /*
         * NOTE:
         *     Set the first scan line for the cursor, and the blinking
         *     mode. First scan line is 11, so that we have a visible
         *     cursor.
         */
        port_out8(VGA_COMMAND_PORT, VGA_SET_CURSOR_START);
        port_out8(VGA_DATA_PORT,    ((0x2 << 5) | 11));

        vga_clear();

        initialized = 1;

        return 1;
}
Пример #14
0
void gui_main(int argc, char **argv)
{
	extern unsigned long BootPageDirectory;
	paging_map(&BootPageDirectory, (void *)0xC0400000, (void *)0x400000, 1024*1024*8, 0x7);


	lx = x = GUI_WIDTH/2;
	ly = y = GUI_HEIGHT/2;
	x = y = 50;

	task_create(gui_daemon, 0, "moused", 0);
	
	unsigned long frames = 0;
	unsigned long tickstart = kinfo.ticks;
	while (1)
	{
		if (running == 0)
		{
			if (kinfo.gui == 1)
			{
				vga_set_mode(vgadev, GUI_WIDTH, GUI_HEIGHT, GUI_BPP);
				running = 1;
				tickstart = kinfo.ticks;
				frames = 0;
			}
			continue;
		}
		else if (kinfo.gui == 0)
		{
			vga_unset_mode(vgadev);
			running = 0;
			tty_scrolldown();
			continue;
		}
		
		frames++;
		
		// Clear
		vga_clear(vgadev, COLORBG);
		
		// Destop text
		vga_draw_string(vgadev, 0, 0, COLOR4, "EOS (Built %s %s)\n", __DATE__, __TIME__);
		vga_draw_string(vgadev, 0, 8, COLOR4, "Processor: %s", kinfo.cpuname);
		vga_draw_string(vgadev, 0, 16, COLOR4, "Memory: %dMB", kinfo.memory / 1024);
		vga_draw_string(vgadev, 0, 24, COLOR4, "Memory Used: %d", mm_used());

		vga_draw_string(vgadev, 0, 40, COLOR4, "mSPF %d", (kinfo.ticks-tickstart)/frames);
		if (kinfo.ticks - tickstart > 100)
			vga_draw_string(vgadev, 0, 48, COLOR4, "FPS %d", frames / ((kinfo.ticks-tickstart)/100));
		
		// Desktop icons
		//gui_draw_icon(vgadev, 8, 8);
		int winxnow, winynow;
		winxnow = winx;
		winynow = winy;
		gui_draw_window(vgadev, winxnow, winynow, 320, 240);
		gui_draw_icon(vgadev, winxnow+24, winynow+64);
		vga_draw_string(vgadev, winxnow+64, winynow+68, COLOR4, "Devices");
		gui_draw_icon(vgadev, winxnow+24, winynow+96);
		vga_draw_string(vgadev, winxnow+64, winynow+100, COLOR4, "Users");

		gui_draw_widget(vgadev, x, y);
		vga_flip(vgadev);
	}
}
Пример #15
0
/***
 * set up vga:
 *
 * set cursor to (0, 0)
 * set default fg/bg color
 * clear screen
 */
void vga_init() {
    //VGA_STATE.fg = GREEN, VGA_STATE.bg = BLACK;
    vga_set_cursor_enable(true);
    vga_clear();
}
Пример #16
0
void
console_init(void)
{
	vga_clear();
	printk_register_handler(vga_puts);
}
Пример #17
0
void lex_clear(int argc, char* argv[])
{
   vga_clear();
}
Пример #18
0
void game_main()
{
  keymap_t keys;
  vga_init();
  
  go_initialize();
  srand(time(NULL));
  
  game_object_t* ship_o = go_getempty();
  ship_o->enabled = 1;
  ship_o->poly_points = 4;
  ship_o->poly = ship;
  ship_o->center_point.x = 320;
  ship_o->center_point.y = 240;
  ship_o->location.x = vga_get_width()/2 - 320;
  ship_o->location.y = vga_get_height()/2 - 240;
  ship_o->identifier = OI_SHIP;
  
   int i;
  for (i = 0; i < 4; i++){
	go_createasteroid(1);
	}
  
  while(1)
  {
	go_tick();
    vga_sync();
    
    keys = input_get_keys();
    if(keys & KEY_SHOOT)
    {
		if (shoot_limit == 0)
		{
			shoot_limit = 25;
			game_object_t* bullet_o = go_getempty();
		  bullet_o->location.x = ship_o->location.x;
		  bullet_o->location.y = ship_o->location.y;
		  bullet_o->xvel = bullet_speed * cosine(ship_o->angle + 4.71);
		  bullet_o->yvel = bullet_speed * sine(ship_o->angle + 4.71);
		  bullet_o->center_point.x = 320;
          bullet_o->center_point.y = 240;
		  bullet_o->angle = ship_o->angle;
		  bullet_o->enabled = 1;
		  bullet_o->poly = bullet_p;
		  bullet_o->poly_points = 2;
		  bullet_o->nowrap = 1;
		  bullet_o->identifier = OI_BULLET;
		}
    }
    if(keys & KEY_LEFT)
    {
      ship_o->angle -= rotate_amount;
    }
    if(keys & KEY_RIGHT)
    {
		ship_o->angle += rotate_amount;
    }
    if(keys & KEY_UP)
    {
		//TODO: lookup table
		ship_o->xvel += ship_accel * cosine(ship_o->angle + 4.71);
		ship_o->yvel += ship_accel * sine(ship_o->angle + 4.71);
    }  
    /*if(keys & KEY_DOWN)
    {
		ship_o->angle += 3.14;
    }*/
    
    if (shoot_limit > 0) shoot_limit--;
    if (go_currentstate == STATE_DEAD) game_over();
    if (go_currentstate == STATE_VICT) win();
    
    vga_clear();
    go_draw();
  }
}
Пример #19
0
void console_clear(void)
{
    vga_clear();
    _.curs_x = _.curs_y = 0;
    _.cleared = true;
}