Ejemplo n.º 1
0
/*	sync	*/
void shinku(global_game_variables_t *gv)
{
	word x = (0) + gv->video.page[/*!*/(gv->video.p)].dx; // follow the screen
	word y = (0) + gv->video.page[/*!*/(gv->video.p)].dy; // follow the screen
	word w = 64, h = 8, col = 7, bgcol = 0, type = 1;
	byte o,o2,i;
	//modexCopyPageRegion(pip[1].page, pip[2].page, 16, 16, 16, 16, (14*8)+4, 8+4);
	/* block copy to visible RAM from offscreen */
//	vga_setup_wm1_block_copy();
//	modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x+w, 0, w, h);
// 	o =	*(gv->video.page[2].data); // source offscreen
// 	o2 =	*(gv->video.page[shinku_fps_indicator_page].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
// 	for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
	/* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
//	vga_restore_rm0wm0();
	if(elapsed_timer(gv) >= (1.0 / gv->kurokku.frames_per_second))
	{
		sprintf(gv->pee, "%.0f fps", (double)gv->kurokku.tiku/ticktock(gv));
		//modexClearRegion(&(gv->video.page[shinku_fps_indicator_page]), x, y, w, h, 45);
		modexprint(&(gv->video.page[/*!*/(gv->video.p)]), x, y, type, col, bgcol, gv->pee);
		gv->kurokku.tiku=0;
		/* block copy to visible RAM from offscreen */
//		vga_setup_wm1_block_copy();
// 		o =	*(gv->video.page[shinku_fps_indicator_page].data); // source offscreen
// 		o2 =	*(gv->video.page[2].data)+(y * vga_state.vga_stride) + (x >> 2); // dest visible (original stride)
// 		for (i=0;i < h;i++,o += vga_state.vga_draw_stride,o2 += vga_state.vga_stride) vga_wm1_mem_block_copy(o2,o,w >> 2);
//		modexCopyPageRegion(&(gv->video.page[shinku_fps_indicator_page]), &(gv->video.page[!shinku_fps_indicator_page]), x, y, x, 0, w, h);
		/* must restore Write Mode 0/Read Mode 0 for this code to continue drawing normally */
//		vga_restore_rm0wm0();
	}else //copy dat sheet
	gv->kurokku.tiku++;

	switch(gv->kurokku.fpscap)
	{
		case 0:
			//modexprint(&(gv->video.page[shinku_fps_indicator_page]), x, y+8, type, col, bgcol, "sanic!");
			gv->kurokku.frames_per_second=1;
		break;
		case 1:
			//turn this off if XT
			//modexWaitBorder();
			vga_wait_for_vsync();
			gv->kurokku.frames_per_second=60;
		break;
	}
	if(pageflipflop){
	if(gv->video.r){
		//vga_setup_wm1_block_copy();
		//_fmemcpy((gv->video.page[(gv->video.p)]).data, (gv->video.page[(!gv->video.p)]).data, gv->video.page[(!gv->video.p)].pagesize);
		//vga_restore_rm0wm0();
		if(!pageploop) modexCopyPageRegion(&(gv->video.page[(gv->video.p)]), &(gv->video.page[(!gv->video.p)]), 0, 0, 0, 0, gv->video.page[gv->video.p].width, gv->video.page[!gv->video.p].height);
		modexShowPage(&(gv->video.page[gv->video.p]));
		if(!pageploop) gv->video.p=!gv->video.p;
		gv->video.r=!gv->video.r;
		//0000gv->video.tickclk = ((*clockw)-gv->video.startclk)/18.2;
	}
	}
}
Ejemplo n.º 2
0
Archivo: g.c Proyecto: ifbe/live
void main()
{
	init();

	while(1)
	{
		//print world
		printworld();

		//wait
		int key=waitevent();

		//change
		cleanup();
		switch(key)
		{
			case -1:return;
			case 0x1b:return;
			case 0x20:		//press
			{
				if(release==0) speed++;
				break;
			}
			case 0xa0:		//release
			{
				release=1;
				break;
			}
			case 0x40000052:	//up
			{
				if(y0>=16)
				{
					y0-=16;
					y-=16;
				}
				break;
			}
			case 0x40000051:	//down
			{
				if(y0<752)
				{
					y0+=16;
					y+=16;
				}
				break;
			}
			case 0xff:
			{
				ticktock();
				break;
			}
			default:continue;
		}
	
	}

}
Ejemplo n.º 3
0
int
main(int argc, char *argv[])
{
    int i, desired;
    SDL_TimerID t1, t2, t3;
    Uint32 start32, now32;
    Uint64 start, now;

    /* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

    if (SDL_Init(SDL_INIT_TIMER) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return (1);
    }

    /* Start the timer */
    desired = 0;
    if (argv[1]) {
        desired = atoi(argv[1]);
    }
    if (desired == 0) {
        desired = DEFAULT_RESOLUTION;
    }
    t1 = SDL_AddTimer(desired, ticktock, NULL);

    /* Wait 10 seconds */
    SDL_Log("Waiting 10 seconds\n");
    SDL_Delay(10 * 1000);

    /* Stop the timer */
    SDL_RemoveTimer(t1);

    /* Print the results */
    if (ticks) {
        SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
                desired, (double) (10 * 1000) / ticks);
    }

    /* Test multiple timers */
    SDL_Log("Testing multiple timers...\n");
    t1 = SDL_AddTimer(100, callback, (void *) 1);
    if (!t1)
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
    t2 = SDL_AddTimer(50, callback, (void *) 2);
    if (!t2)
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
    t3 = SDL_AddTimer(233, callback, (void *) 3);
    if (!t3)
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());

    /* Wait 10 seconds */
    SDL_Log("Waiting 10 seconds\n");
    SDL_Delay(10 * 1000);

    SDL_Log("Removing timer 1 and waiting 5 more seconds\n");
    SDL_RemoveTimer(t1);

    SDL_Delay(5 * 1000);

    SDL_RemoveTimer(t2);
    SDL_RemoveTimer(t3);

    start = SDL_GetPerformanceCounter();
    for (i = 0; i < 1000000; ++i) {
        ticktock(0, NULL);
    }
    now = SDL_GetPerformanceCounter();
    SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());

    SDL_Log("Performance counter frequency: %"SDL_PRIu64"\n", (unsigned long long) SDL_GetPerformanceFrequency());
    start32 = SDL_GetTicks();
    start = SDL_GetPerformanceCounter();
    SDL_Delay(1000);
    now = SDL_GetPerformanceCounter();
    now32 = SDL_GetTicks();
    SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());

    SDL_Quit();
    return (0);
}
Ejemplo n.º 4
0
int
main(int argc, char *argv[])
{
    int i, desired;
    SDL_TimerID t1, t2, t3;
    Uint64 start, now;

    if (SDL_Init(SDL_INIT_TIMER) < 0) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return (1);
    }

    /* Start the timer */
    desired = 0;
    if (argv[1]) {
        desired = atoi(argv[1]);
    }
    if (desired == 0) {
        desired = DEFAULT_RESOLUTION;
    }
    SDL_SetTimer(desired, ticktock);

    /* Wait 10 seconds */
    printf("Waiting 10 seconds\n");
    SDL_Delay(10 * 1000);

    /* Stop the timer */
    SDL_SetTimer(0, NULL);

    /* Print the results */
    if (ticks) {
        fprintf(stderr,
                "Timer resolution: desired = %d ms, actual = %f ms\n",
                desired, (double) (10 * 1000) / ticks);
    }

    /* Test multiple timers */
    printf("Testing multiple timers...\n");
    t1 = SDL_AddTimer(100, callback, (void *) 1);
    if (!t1)
        fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError());
    t2 = SDL_AddTimer(50, callback, (void *) 2);
    if (!t2)
        fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError());
    t3 = SDL_AddTimer(233, callback, (void *) 3);
    if (!t3)
        fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError());

    /* Wait 10 seconds */
    printf("Waiting 10 seconds\n");
    SDL_Delay(10 * 1000);

    printf("Removing timer 1 and waiting 5 more seconds\n");
    SDL_RemoveTimer(t1);

    SDL_Delay(5 * 1000);

    SDL_RemoveTimer(t2);
    SDL_RemoveTimer(t3);

    start = SDL_GetPerformanceCounter();
    for (i = 0; i < 1000000; ++i) {
        ticktock(0);
    }
    now = SDL_GetPerformanceCounter();
    printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());

    SDL_Quit();
    return (0);
}