/**
 * Initialize the driver. (Required)
 * \param drvthis  Pointer to driver structure.
 * \retval 0       Success.
 * \retval <0      Error.
 */
MODULE_EXPORT int
debug_init(Driver *drvthis)
{
	PrivateData *p;

	report(RPT_INFO, "%s()", __FUNCTION__);

	/* Allocate and store private data */
	p = (PrivateData *) calloc(1, sizeof(PrivateData));
	if (p == NULL)
		return -1;
	if (drvthis->store_private_ptr(drvthis, p))
		return -1;

	p->width = DEFAULT_WIDTH;
	p->height = DEFAULT_HEIGHT;
	p->cellwidth = DEFAULT_CELLWIDTH;
	p->cellheight = DEFAULT_CELLHEIGHT;
	p->contrast = DEFAULT_CONTRAST;
	p->brightness = DEFAULT_BRIGHTNESS;
	p->offbrightness = DEFAULT_OFFBRIGHTNESS;

	p->framebuf = malloc(p->width * p->height);
	if (p->framebuf == NULL) {
		report(RPT_INFO, "%s: unable to allocate framebuffer", drvthis->name);
		return -1;
	}

	debug_clear(drvthis);

	return 0;
}
示例#2
0
文件: debug.c 项目: theanine/chip8
void debug_end(void)
{
	if (!debug_enabled) {
		printf("%s", debug_buffer);
		debug_idx = 0;
		return;
	}
	
	int count = str_count(debug_buffer, '\n');
	if (count > DEBUG_Y_SIZE) {
		char* next_line = strchr(debug_buffer, '\n') + 1;
		memmove(debug_buffer, next_line, strlen(next_line)+1);
	}
	
	display_saveCursor();
	debug_clear();
	printf("%s", debug_buffer);
	printf("                                            ");
	debug_idx = strlen(debug_buffer);
	display_loadCursor();
}
示例#3
0
文件: game.cpp 项目: EXL/NXEngine
void Game::tick(void)
{
	debug_clear();
	
	if (game.paused)
	{
		tickfunctions[game.paused].OnTick();
	}
	else
	{
		// record/playback replays
		Replay::run();
		
		// run scripts
		RunScripts();
		
		// call the tick function for the current game mode
		tickfunctions[game.mode].OnTick();
	}
	
	DrawDebug();
	console.Draw();
}