How to control the framerate

Hi I'm a video game developer, but not yet professional on Sega Saturn. I need to coordinate the framerate on this machine. Anyone know, how can do this?. For example I need to reproduce a function like SDL_GetTicks() from SDL.


Thanks.


PD: sorry for my english :cwm3:
 
In terms of hardware, you could use an SH-2 timer, or maybe even the H-position register in VDP2. I don't know how it would be done in SGL/SBL.
 
If you just want to do frame rate limiting then you could poll bit 3 of TVSTAT, which is set during VBlank (see the VDP2 maunal).
 
Maybe something like this for getticks :

Code:
Uint16 previouscount=0;



int SDL_InitSubSystem(Uint32 flags)

{

	if(flags &= SDL_INIT_AUDIO)

	{

		char sound_map[] =  {0xff,0xff};//,0xff,0xff,0xff,0xff,0xff,0xff,0xff};


#ifdef ACTION_REPLAY

		slInitSound(sddrvstsk , sizeof(sddrvstsk) , (Uint8 *)sound_map , sizeof(sound_map)) ;

#else

#define	SDDRV_NAME	"SDDRVS.TSK"

#define	SDDRV_SIZE	26610

#define	SDDRV_ADDR	0x00202000//0x6080000

unsigned char *drv;

		//slPrint("driver loaded",slLocate(1,1));

		drv = (unsigned char *)malloc(SDDRV_SIZE);

		GFS_Load(GFS_NameToId((Sint8*)SDDRV_NAME),0,(void *) tutu,SDDRV_SIZE);

		slInitSound(drv , SDDRV_SIZE , (Uint8 *)sound_map , sizeof(sound_map)) ;

		free(drv);		

#endif

	}


	if(flags &= SDL_INIT_TIMER)

	{

		TIM_FRT_INIT(TIM_CKS_32);

		TIM_FRT_SET_16(0);

	}


	return 0;

}



Uint32 SDL_GetTicks(void)

{

previouscount += TIM_FRT_CNT_TO_MCR(TIM_FRT_GET_16()) / 1000; 

	TIM_FRT_SET_16(0); 

	return previouscount;

}


about waiting for vblank (from Charles Mac Donald samples) :

Code:
#define TVSTAT      (*(Uint16 *)0x25F80004)


void wait_vblank(void)

{

     while((TVSTAT & 8) == 0);

     while((TVSTAT & 8) == 8);

}
 
Back
Top