It is currently Mon Dec 18, 2017 6:03 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Jan 20, 2016 4:53 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1517
What are good ways to create a game, so that the NTSC and PAL version run at the same speed?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Wed Jan 20, 2016 5:55 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
You can always simply run the game loop 6 times over 5 frames, but that will stutter and look stupid.

You could adjust parameters in the game so that objects move 6/5 as fast, fixed point math helps here, but it's tricky and error prone, and you sometimes end up with bugs/exploits that only work in one region of the game.

Or you could just say 'screw it' and do nothing to the game speed like 95% of all PAL released NES games. Europe got shafted so hard with crappy ports.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Wed Jan 20, 2016 7:14 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19355
Location: NE Indiana, USA (NTSC)
A lot of background tasks in Thwaite and RHDE are on a 10 Hz timer. They run every 6 frames on NTSC or every 5 frames on PAL NES or Dendy.

Thwaite moves the cursor and missiles every frame (60 Hz on NTSC, 50 on PAL). These have their speed adjusted using fixed-point math. Velocities need to be 20% bigger on PAL, accelerations need to be 44% bigger, and times need to be 17% shorter, but for a lot of things, it cheats a bit, multiplying by 19/16 or 13/16 (thus adding or subtracting 18.75%). It also clocks explosions every other frame (30 Hz on NTSC, 25 on PAL), and the number of frames for each of the six cels is set higher on NTSC.

Games using the Pently music engine version 3 or later (Thwaite, Action 53 menu, and RHDE) use a Bresenham-type algorithm to know when to advance to the next row. The tempo value (in rows per minute) is added to a counter every frame, and when that exceeds the TV system's frames per minute (3000 for PAL NES and Dendy or 3606 for NTSC), another row is played. In addition, it transposes music up a semitone on PAL NES only because of its slower APU.

For cursor movement in RHDE, I just said screw it. But I did make the playfield update much faster on a PAL NES: 2 frames to copy everything instead of 5, or 1 to copy a single side instead of 3. (I couldn't do the same for Dendy because tapping into post-render time is more complicated.)


Top
 Profile  
 
PostPosted: Wed Jan 20, 2016 9:52 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2983
Location: Tampere, Finland
I don't think there's one "good" solution, all of them have their compromises.
Dwedit wrote:
You can always simply run the game loop 6 times over 5 frames, but that will stutter and look stupid.

If this is done in a naive way (running the update routine twice in a single 50 Hz frame's time), the processing load will be distributed very unevenly. A non-naive implementation (actually running the internal game logic at 60 Hz and dropping frames to get to 50 Hz) is pretty tricky to pull off since you need a 60 Hz timer source and very careful decoupling of the game logic from PPU drawing. There might be some holes in this idea, I haven't thought much about it. Definitely it'd make the implementation much more complex. I don't think it'd look too bad though (easy to test by recording 60 Hz footage from existing games and converting to 50 Hz with something like AviSynth).

In STREEMERZ the game logic runs at 50 Hz and every 5th frame is duplicated when running on NTSC NES. (Why? Because the original Flash game ran at 50 Hz.) It doesn't look too bad, but giving up the 60 Hz update rate feels wrong given that most of the homebrew market is NTSC.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 8:57 am 
Offline

Joined: Thu Mar 02, 2006 12:30 pm
Posts: 169
Another simple option for low-action games would be to design the game around 50Hz, and skip updates (except for vital ones like controller reads, you don't want any dead frames for input) one out of six frames on NTSC. Useless for any games that scroll, but for single-screen puzzle-type games, it could be a workable method. For a game like 2048, the player probably couldn't even notice the difference. Even more so if you delay triggering of an animation if the dropped frame would occur in the middle of the animation (and your animations are short, like 2-3 frames, as that would be the threshold for delaying).

_________________
Read my blog! The Incoherent Ramblings of a Lowly Geek


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 10:00 am 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1517
Dwedit wrote:
You can always simply run the game loop 6 times over 5 frames, but that will stutter and look stupid.

I don't think I will have time to update six times in five frames. I fear I'll even need to do some more optimizations in the next days in my game as it is, so I definitely don't have time for rendering an additional frame.

Dwedit wrote:
Or you could just say 'screw it' and do nothing to the game speed like 95% of all PAL released NES games. Europe got shafted so hard with crappy ports.

This will probably be done when I don't find an elegant solution. In this case, I'll only adjust the music. Or let it adjust automatically by setting FamiTone to PAL in the second build of the ROM.

Splitting the code into timed stuff that works independently from the frames per second would require a completely new concept for my game. So, I don't think I can split the tasks.

Also, I don't completely separate game logic and graphics output. O.k., the graphics output is pretty independent. But the game logic does set the ID of the current metasprite/animation frame as well as X and Y for each character.

LocalH wrote:
Another simple option for low-action games would be to design the game around 50Hz, and skip updates (except for vital ones like controller reads, you don't want any dead frames for input) one out of six frames on NTSC.

In my opinion, that's just evil. :evil: I would never create the PAL version as the master version and the NTSC version as some afterthought hack. Either both formats are equally valid (for example calculate the game with 300 frames per seconds and output every fifth frame on NTSC and every sixth frame on PAL, which is obviously not possible on the NES due to processor speed) or the PAL version is the adjusted version.


By the way, what method does the PAL version of "Super Mario Bros." use? As far as I know, this isn't just the NTSC version with altered music, right?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 10:07 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19355
Location: NE Indiana, USA (NTSC)
Apart from music, SMB1 has two kinds of changes:
  • A bunch of speeds are increased and frame counts are decreased.
  • The 21-frame task timer is changed to 18 frames.
Years ago, I made an absurdly detailed comparison based on a diff.


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 11:11 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
The PAL version of SMB1 is pretty much broken, so it's not a good example.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 1:55 pm 
Offline

Joined: Sat Mar 29, 2014 10:01 pm
Posts: 107
Location: Australia
PAL smb1 is broken? How? It's what we grew up on!!!!!!! Is the ntsc version somehow better?


Top
 Profile  
 
PostPosted: Thu Jan 21, 2016 3:08 pm 
Offline

Joined: Mon Jan 23, 2012 11:27 pm
Posts: 141
thefox wrote:
I don't think there's one "good" solution, all of them have their compromises.
Dwedit wrote:
You can always simply run the game loop 6 times over 5 frames, but that will stutter and look stupid.

If this is done in a naive way (running the update routine twice in a single 50 Hz frame's time), the processing load will be distributed very unevenly. A non-naive implementation (actually running the internal game logic at 60 Hz and dropping frames to get to 50 Hz) is pretty tricky to pull off since you need a 60 Hz timer source and very careful decoupling of the game logic from PPU drawing. There might be some holes in this idea, I haven't thought much about it. Definitely it'd make the implementation much more complex. I don't think it'd look too bad though (easy to test by recording 60 Hz footage from existing games and converting to 50 Hz with something like AviSynth).

In STREEMERZ the game logic runs at 50 Hz and every 5th frame is duplicated when running on NTSC NES. (Why? Because the original Flash game ran at 50 Hz.) It doesn't look too bad, but giving up the 60 Hz update rate feels wrong given that most of the homebrew market is NTSC.


I would not have guessed. I've spent enough time on your game that I would have picked out things bothering me, but I haven't noticed a stutter at all. You did a fantastic job all around, btw.


Top
 Profile  
 
PostPosted: Fri Jan 22, 2016 4:32 am 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1517
tepples wrote:
Years ago, I made an absurdly detailed comparison based on a diff.

Thanks for linking to the list.

Is there any NES game where NTSC and PAL run at the same speed and play the same?

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Fri Jan 22, 2016 6:13 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19355
Location: NE Indiana, USA (NTSC)
DRW wrote:
Is there any NES game where NTSC and PAL run at the same speed and play the same?

The Codemasters games adapt at runtime to differences between NTSC and PAL NES, but I don't know to what extent they actually scale speed. Thwaite and RHDE do scale most speeds (as I mentioned).


Top
 Profile  
 
PostPosted: Sat Jan 23, 2016 9:15 am 
Offline

Joined: Thu Mar 02, 2006 12:30 pm
Posts: 169
DRW wrote:
LocalH wrote:
Another simple option for low-action games would be to design the game around 50Hz, and skip updates (except for vital ones like controller reads, you don't want any dead frames for input) one out of six frames on NTSC.

In my opinion, that's just evil. :evil: I would never create the PAL version as the master version and the NTSC version as some afterthought hack. Either both formats are equally valid (for example calculate the game with 300 frames per seconds and output every fifth frame on NTSC and every sixth frame on PAL, which is obviously not possible on the NES due to processor speed) or the PAL version is the adjusted version.

Well, of course this idea wouldn't work for scrolling action games. Only low-action games where the skipped update wouldn't be noticeable, and where it would be overkill to do a more advanced optimization. The only way to reverse this quick and dirty cheap method would be to run visual updates twice in one of six frames on PAL (but in such a case on the "double frame" I wouldn't recommend applying input again as you'd get doubled input 10 times a second).

_________________
Read my blog! The Incoherent Ramblings of a Lowly Geek


Top
 Profile  
 
PostPosted: Thu Apr 28, 2016 6:38 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19355
Location: NE Indiana, USA (NTSC)
The producer of a game I'm involved with is considering a PAL version as a stretch goal. Like Super Mario Bros., this is a platformer. Other than Super Mario Bros. and Codemasters games, what other NES games ported from NTSC to PAL have their accelerations, velocities, and delays adjusted?


Top
 Profile  
 
PostPosted: Sat Apr 30, 2016 10:23 pm 
Offline

Joined: Sat Apr 25, 2015 1:47 pm
Posts: 337
Location: FL
Super Turrican is allegedly another one that adjusts itself to NTSC, but I've never personally verified that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group