Esempio n. 1
0
File: gui.c Progetto: adtools/db101
void cleanup()
{
	remove_hook();
	if (!isattached)
		killtask();

	free_symbols();
	close_all_elfhandles();
	stabs_free_stabs();

	hex_close_window();
	breakpoints_close_window();
	modules_close_window();
	main_close_window();
	arexx_close_port();
	
	IExec->FreeSysObject(ASOT_PORT, AppPort);
	
	pipe_cleanup();
	
	variables_cleanup();
	console_cleanup();
	stacktrace_cleanup();
	source_cleanup();
	disassembler_cleanup();
	sourcelist_cleanup();
	
	freemem_free_hook(main_freemem_hook);

	char sysstring[1024] = "";	
	sprintf(sysstring, "setenv DB101_LASTDIR SAVE \"%s\"", lastdir);
	IDOS->SystemTags(sysstring, TAG_END);
}
Esempio n. 2
0
static void
fbdev_cleanup( video_module_t *m ) 
{
	if( cv->is_open )
		vclose();
	if( cv->fd != -1 )
		close( cv->fd );
	if( cv->color_table )
		free( cv->color_table );
	free_vmodes();

	console_cleanup();
}
Esempio n. 3
0
int main() {
	Console co;
	Console* t = &co;
	struct {int w, h;} dim;
	console_init(t);
	point reso = {800, 600};
	console_init_graphics(&co, reso, FONT);

	console_getbounds(t, &dim.w, &dim.h);

	bmp4* r  = bmp4_new(dim.w, dim.h);
	gen_pal(t, color3);
	float time = getpid();
	int k;
	while((k = console_getkey_nb(t)) == CK_UNDEF || !(k & CK_MASK)) {
		plasma3(r, &time, sinvalc4, pal);
		draw(t, r);
		console_sleep(t, 30);
	}
	console_cleanup(t);
	printf("got %d, cols %d\n", k, cols);
}
Esempio n. 4
0
int
main(int argc, char *argv[])
{
	int port = 2344;
	const char *config = "sys161.conf";
	const char *kernel = NULL;
	int usetcp=0;
	char *argstr = NULL;
	int j, opt;
	size_t argsize=0;
	int debugwait=0;
	int pass_signals=0;
#ifdef USE_TRACE
	int profiling=0;
#endif
	int use_second_console=0;
	const char *second_console = NULL;
	unsigned ncpus;

	/* This must come absolutely first so msg() can be used. */
	console_earlyinit();
	
	if (sizeof(u_int32_t)!=4) {
		/*
		 * Just in case.
		 */
		msg("sys161 requires sizeof(u_int32_t)==4");
		die();
	}

	while ((opt = mygetopt(argc, argv, "c:f:p:Pst:wk:"))!=-1) {
		switch (opt) {
		    case 'c': config = myoptarg; break;
		    case 'f':
#ifdef USE_TRACE
			set_tracefile(myoptarg);
#endif
			break;
		    case 'p': port = atoi(myoptarg); usetcp=1; break;
		    case 'P':
#ifdef USE_TRACE
			profiling = 1;
#endif
			break;
		    case 's': pass_signals = 1; break;
		    case 't': 
#ifdef USE_TRACE
			set_traceflags(myoptarg); 
#endif
			break;
		    case 'w': debugwait = 1; break;
		    case 'k':
		    use_second_console = 1;
		    second_console = myoptarg;
		    break;
		    default: usage(); break;
		}
	}
	if (myoptind==argc) {
		usage();
	}
	kernel = argv[myoptind++];
	
	for (j=myoptind; j<argc; j++) {
		argsize += strlen(argv[j])+1;
	}
	argstr = malloc(argsize+1);
	if (!argstr) {
		msg("malloc failed");
		die();
	}
	*argstr = 0;
	for (j=myoptind; j<argc; j++) {
		strcat(argstr, argv[j]);
		if (j<argc-1) strcat(argstr, " ");
	}

	/* This must come before bus_config in case a network card needs it */
	mkdir(".sockets", 0700);
	
	console_init(pass_signals, use_second_console, second_console);
	clock_init();
	ncpus = bus_config(config);

	initstats(ncpus);
	cpu_init(ncpus);

	if (usetcp) {
		gdb_inet_init(port);
	}
	else {
		unlink(".sockets/gdb");
		gdb_unix_init(".sockets/gdb");
	}

	unlink(".sockets/meter");
	meter_init(".sockets/meter");

	load_kernel(kernel, argstr);

	msg("System/161 %s, compiled %s %s", VERSION, __DATE__, __TIME__);
#ifdef USE_TRACE
	print_traceflags();
	if (profiling) {
		prof_setup();
	}
#endif

	if (debugwait) {
		stoploop();
	}
	
	run();

#ifdef USE_TRACE
	if (profiling) {
		prof_write();
	}
#endif

	bus_cleanup();
	console_cleanup();
	clock_cleanup();
	
	return 0;
}
Esempio n. 5
0
int main(int argc, char** argv) {
	char* filename;
	int scaleFullScreen = 0;
	Console co;
	Console* t = &co;
	int cx; int cy;
	int w, h;
	int iterX, iterY;

	struct Pix* pngfile;
	struct Pix* ping;
	struct Pix* palette;
	struct Pix* pix32;
	int i, ix, iy;
	int c;
	
	for (i = 1; i<argc; i++) {
		if (strlen(argv[i]) > 1 && !memcmp(argv[i], "-f", 2)) 
			scaleFullScreen=1;
		else filename = argv[i];
	}

	if (access(filename, R_OK)) {
		puts("file not found!");
		puts("c0npix by rofl0r");
		puts("================");
		printf("arguments: %s [-f] somefile.[jpg|png|bmp|tiff]\n", argv[0]);
		puts("where -f means scale to fullscreen");
		puts("export TERM=xterm-256color before usage is recommended.");
		exit(1);
	}

	console_init(t);
	point reso = {800, 600};
	console_init_graphics(&co, reso, FONT);

	console_getbounds(t, &cx, &cy);

	pngfile = pixRead(filename);

	pixGetDimensions(pngfile, &w, &h, NULL);

	ping = pixScale(pngfile, 2.0, 1.0 );
	
	pixDestroy(&pngfile);
	
	palette = pixOctreeColorQuant(ping, 240, 1);
	
	if (palette == NULL) { puts("palette is nul"); goto finish_him; }

	pix32 = pixConvertTo32(palette);

	iterX = pix32->w;
	iterY = pix32->h;

	int* bufptr = (int*) pix32->data;
	if (bufptr == NULL) {
		puts("bufptr is null");
		goto finish_him;
	}
	
	int startx = 0;
	int starty = 0;
	
	paint:
	for(iy = starty; iy < starty + cy; iy++) {
		bufptr = (int*) pix32->data + (iy * pix32->w) + startx;
		for(ix = startx; ix < startx + cx; ix++) {
			console_setcolor(t, 0, *((rgb_t*) bufptr));
			console_goto(t, ix - startx, iy - starty);
			console_addchar(t, ' ', 0);
			bufptr++;
		}
	}
	console_draw(t);
	//console_printfxy(t, 0, 0, "%d", (int) c);
	
	while ((c = console_getkey(t)) != 'q') {

		console_setcolor(t, 0, RGB(0,0,0));
		
		switch(c) {
			case CK_CURSOR_UP: 
				if(starty > 0) starty--;
				break;
			case CK_CURSOR_DOWN:
				if(starty < (int) pix32->h - cy)
					starty++;
				break;
			case CK_CURSOR_LEFT:
				if(startx > 0)
					startx--;
				break;
			case CK_CURSOR_RIGHT:
				if(startx < (int) pix32->w - cx)
					startx++;
				break;
			default:
				goto loopend; // ignore mouse movement and similar stuff
				break;
		}
		goto paint;
		loopend: ;
	}
	
	pixDestroy(&palette);
	pixDestroy(&pix32);

	console_refresh(t);
	
	finish_him:
	//console_getkey(t);
	
	console_cleanup(t);

	return 0;
}