Ejemplo n.º 1
0
Archivo: main.c Proyecto: Nemh/chip8
int gui(Exec_info exec_info)
{
	unsigned char path[100] = {'\0'};
	int exec_time, exec_frequency;
	int key = 0;
	int handle = -1;
	nio_DrawConsole(&c1);

	if(exec_info.cycles_count != 0) {
		exec_time = (int)((exec_info.tick_end - exec_info.tick_start)/128);
		exec_frequency = exec_info.cycles_count/(exec_time * 1000);
		nio_printf(&c1, "Game terminated. Execution time : %d s.\n > Average execution frequency : %d kHz\n > ", exec_time, exec_frequency);
	}

#ifndef EMULATOR
	while(handle < 0) {
		nio_GetStr(&c1, path);
		if(!strcmp(path, "exit")) {
			while(1) {
				GetKey(&key);
			}
		}
		else if(!strcmp(path, "help")) nio_printf(&c1, "Type name of the file you want to load\n or, if you want to leave me , write 'exit' :(\n > ");
		else if(!strcmp(path, "fb")) {
#endif
			fileBrowser(path, (unsigned char*)"*.ch", (unsigned char*)"*.CH8", (unsigned char*)"*.ch8", "Files");
			nio_DrawConsole(&c1);
			if(strcmp(path, "")) {
				handle = CC_open_file(path+7);
				if(handle < 0) nio_printf(&c1, "Error opening %s ... Check if the file exists\n > ", path);
				else {
					return handle;
				}
			}
#ifndef EMULATOR
		}
		else {
			handle = CC_open_file(path);
			if(handle < 0) nio_printf(&c1, "Error opening %s ... Check if the file exists\n > ", path);
			else {
				return handle;
			}
		}	
	}
#endif
}
Ejemplo n.º 2
0
int main()
{
	Bdisp_AllClr_VRAM();
	Bdisp_EnableColor(1);
	
	// Initialize console 1.
	nio_console c1;

	// The screen can hold up to 64 columns and 27 rows
	// 64 columns, 14 rows. 0px offset for x/y. Background color 15 (white), foreground color 0 (black)
	nio_InitConsole(&c1,64,14,0,0, NIO_COLOR_BLACK, NIO_COLOR_WHITE);
	nio_DrawConsole(&c1);
	
	nio_console c2;
	nio_InitConsole(&c2,64,13,0,14*8, NIO_COLOR_BLACK, NIO_COLOR_WHITE);
	nio_DrawConsole(&c2);
	
	// Just showing printf
	nio_printf(&c1,"%s build at %s, %s\n",__FILE__,__DATE__,__TIME__);
	nio_printf(&c2,"256 text colors available! ");
	int i;
	for(i = 1; i<16; i++)
	{
		nio_SetColor(&c2, 0, i);
		nio_printf(&c2, "%d ", i);
	}
	nio_printf(&c2,"\n");

	// Press EXE to exit
	while(1)
	{
		char text[100];
		// If no text was entered, exit
		if(!nio_GetStr(&c1,text))
			break;
		// Write the text into 2nd console
		nio_printf(&c2,"%s\n",text);
		//Bdisp_PutDisp_DD();
	}
	
	nio_CleanUp(&c1);
	nio_CleanUp(&c2);
	
	return 0;
}
Ejemplo n.º 3
0
void dConsoleGets(char * s)
{
	nio_GetStr(&csl,s);
}