50/60Hz Speed Differences

SGDK only sub forum

Moderator: Stef

Post Reply
themrcul
Interested
Posts: 44
Joined: Fri Apr 15, 2016 2:21 pm

50/60Hz Speed Differences

Post by themrcul » Thu Dec 08, 2016 3:33 am

Hi peeps,
I have genuinely searched/scoured the forums to try to find the answer, but I haven't yet, and would really appreciate some advice before delving into my first MD SGDK project!

I live in a PAL region, so getting the PAL version of a game running at the correct speed as the NTSC version is close to my heart.

My question is, how to do you get the PAL version of a MD game to run at (relatively) the same speed as the NTSC version? Especially in terms of sprite/tile animations, and all of the object movement speeds.

I would love for there to be one version of the cartridge that detects the region on startup and does H40 V28 60Hz for NTSC and H40 V30 50Hz for PAL with the speed corrected for the difference. And before writing a ton of code I would like to know how to best go about getting the speed right first, rather than having to fix it all up later.

How do you guys do movement speeds and animation speeds for the 20% difference in speed each region has?

Thanks everyone!

TheMrCul

cero
Very interested
Posts: 200
Joined: Mon Nov 30, 2015 1:55 pm

Re: 50/60Hz Speed Differences

Post by cero » Thu Dec 08, 2016 11:21 am

I don't bother, since modern TVs support 60Hz, and Mega Drive wasn't that popular in PAL 50Hz territories. Many of the still active fans have modded consoles that can run at 60Hz.

User avatar
Stef
Very interested
Posts: 2627
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: 50/60Hz Speed Differences

Post by Stef » Thu Dec 08, 2016 2:48 pm

You "just" have to consider animation to be *time* based instead of *frame* based and that is ;)
For instance if your walking animation is 15 FPS:

Code: Select all

// 15 FPS animation speed
const fix16 animSpeed = FIX16(1d/15d);

fix16 curTime = 0;

// main loop
while(TRUE)
{
  ...
  
  // add frame time
  if (IS_PALSYSTEM) curTime += FIX16(1d/50d)
  else curTime += FIX16(1d/60d)

  if (curTime >= animSpeed)
  {
    curTime -= animSpeed;
    // pass to next animation frame
    nextAnimationFrame();
  }
  
  ...
  
  VDP_waitVSych();
}
that is the basic idea.

themrcul
Interested
Posts: 44
Joined: Fri Apr 15, 2016 2:21 pm

Re: 50/60Hz Speed Differences

Post by themrcul » Fri Dec 09, 2016 12:16 pm

Thanks guys, that's really helpful. I'll post again when I have something to share!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest