Plan for customisable frame rates

From OHRRPGCE-Wiki
Jump to: navigation, search

Currently nightly builds (to be released in Callipygous have an option to adjust the frame rate. However more work is needed before this is 'done'.

Battles run at 18.3 fps regardless of the setting. To change this, attack and caption delays, which are currently denominated in ticks, need to be converted to seconds.

It was agreed that animation frame lengths should continue to be measured in ticks, as that keeps things simple. Instead of measuring waits in seconds, changing the frame rate could automatically scale the length of the waits in all animations.

When the framerate target can't be met[edit]

We should probably consider the issue of unexpected tick lengths. If you ask for 60 fps you're at a much higher risk of getting less than that if running on a slow computer or if your game is script heavy. In addition, vsync, on by default for gfx_directx, will reduce the frame rate, easily drastically.

We could do automatic frame skipping, which still runs scripts and everything else as normal, but skips drawing the screen to try to make up time. However frame skipping can't solve the problem if most of the time is being spent in the script interpreter -- but if that's the case it's no longer the engine's problem.

The alternative to frame skipping is that the game proceeds more slowly as the frame rate drops: the current behaviour.

Remaining tasks[edit]

  • Come up with some better way to specify walkabout walking speed. This is going to require fractional pixels per tick. Neither pixels per tick nor ticks per tile are good enough.
  • Make the walking toggle speed flexible so it can be changed automatically
    • In the longer term, customisable animations will replace these, but that may not be a good reason not to add a walk toggle speed option now, for walk-in-place NPCs.
  • Make attack animation speeds flexible
  • Convert battle delays to seconds
  • Add a prompt to automatically adjust all animation and movement
  • Add an option to set whether vsync is should be on or off by default, because different games will want different things. Vsync is good when you're scrolling the screen quickly, but otherwise probably unwanted.
  • Implement frame skipping
    • Add an option to turn on frame skipping (rather than running visibly slower)
    • Frame skipping will also be very useful for playing back recorded .ohrkey files, for the shift+tab turbo speed debug key, and for a future script command to set a frame rate multiplier.
  • Add a waitsec script command or equivalent command to wait in seconds instead of ticks. However because the whole engine slows down if the target fame rate isn't met, its use shoudl be encouraged.
    • If the idea of units is implemented, then it would be possible to write wait(1.2 sec) and a separate command won't be necessary
    • If floating point isn't implemented yet, a waitms command could be added instead.
  • Possibly add a wait command which measures in 18ths of a second, for porting old scripts.
    • This unit of time could be called an old tick or dos tick.
  • (Future) Add a setting to run an old game at a higher framerate. This would draw interpolating frames between the normal game ticks. This should be a setting both in Custom and in-game.
    • It could also be automatically turned on if a scan of the game's scripts reveals that it doesn't use any script commands which this could screw up
      • Bad commands include anything for positioning. walk npc/hero might also have to be disallowed, since I believe Siv: journey of an egg exploited these to give the same effect as putnpc and puthero.