Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timers are not frame accurate #1702

Closed
fmatthew5876 opened this issue Mar 16, 2019 · 7 comments
Closed

Timers are not frame accurate #1702

fmatthew5876 opened this issue Mar 16, 2019 · 7 comments

Comments

@fmatthew5876
Copy link
Contributor

fmatthew5876 commented Mar 16, 2019

We don't run timer updates at the right time. As per Cherry:

Main update methods for common events run (they just check if they are parallel process and the condition is met and then invoke the parallel process worker for them)
Main update methods for map events run (they do a bunch of things, described in my previous post - but actually even more, because after the check for whether there is any active event page, they will run their parallel process worker and then check once more for active)
Message window updates
Timer updates
Screen effects update
Pictures update
Foreground worker runs
Panorama updates

Also I did some quick test and saw that our lsd chunks for timers are not frame accurate.

In HH3, I noticed some case where I would load an RPG_RT save game and the timer would appear with "00:01" when it shouldn't.

Leaving this issue as a placeholder to investigate timer behavior and setup test cases.

@fmatthew5876
Copy link
Contributor Author

fmatthew5876 commented Mar 16, 2019

Test Cases 1 - Basic Timer Operations

  1. Setup EV01 parallel
Timer 1 Set 00:01
Timer 1 start
OpenSaveMenu
OpenSaveMenu
Wait 0.9s
Wait 0.0s
Wait 0.0s
Wait 0.0s
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 119 1 1 0
2 118 1 1 1
3 60 1 1 59
4 59 0 0 60
5 59 0 0 61
  1. Change EV01 to parallel
Timer 1 Set 00:01
Timer 1 start
OpenSaveMenu
OpenSaveMenu
Wait 0.9s
Wait 0.0s
Wait 0.0s
Wait 0.0s
OpenSaveMenu
OpenSaveMenu
Timer1 start
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 119 1 1 0
2 118 1 1 1
3 60 1 1 59
4 59 0 0 60
5 58 ❗ 0 0 61

Result:
Starting the timer causes it to tick down by 1

  1. Change EV01 to parallel
Timer 1 start
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 0 1 1 0
2 0 1 1 1

Result: Timer stays active forever with "00:00" RPG_RT bug?? ❗

  1. Change EV01 to parallel
Timer 1 Set 00:00
Timer 1 start
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 59 1 1 0
2 58 0 0 1
  1. Change EV01 to parallel
Wait 0.0s
Timer 1 Set 00:00
Timer 1 start
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 58 0 0 1
  1. Change EV01 to autostart
Timer 1 Set 00:00
Timer 1 start
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 59 1 1 1
2 58 0 0 1
  1. Change EV01 to autostart
Timer 1 Set 00:01
Timer 1 start
OpenSaveMenu
OpenSaveMenu
Timer 1 stop
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 119 1 1 1
2 118 1 1 1
3 117 0 0 1
4 117 0 0 1
  1. Change EV01 to autostart
Timer 1 Set 00:01
Timer 1 start
Timer 1 stop
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 119 0 0 1
  1. Change EV01 to autostart
Timer 1 Set 00:01
Loop:
  OpenSaveMenu
Save timer1 secs timer1 active timer1 visible stop count
1 119 0 0 1

Conclusion:

  • timer1_secs gets initialized to TIME + 59 frames
  • When timer1_secs >= 60, the update routine ticks once and then disables the timer
  • Timer does not tick during pre-update
  • Timer updates before autostart, so autostart event shows initial values
  • Calling timer start when timer1_secs >= 60, causes it to tick once and then stop

@fmatthew5876
Copy link
Contributor Author

fmatthew5876 commented Mar 16, 2019

Test Cases 2 - Timer conditionals

  1. Setup autostart event
If timer1 > 00:00
  OpenSaveMenu
EraseEvent
Save timer1 secs timer1 active timer1 visible
1 0 0 0
  1. Setup autostart event
If timer1 > 00:01
  OpenSaveMenu
EraseEvent

Result: No Trigger

  1. Setup autostart event
Set timer1 00:00
If timer1 > 00:00
  OpenSaveMenu
EraseEvent
Save timer1 secs timer1 active timer1 visible
1 59 0 0
  1. Setup autostart event
Set timer1 00:01
Timer1 start
WAIT
If timer1 > 00:01
  OpenSaveMenu
EraseEvent
WAIT timer1 secs timer1_active saves?
0 119 1 Y
1 118 1 Y
59 60 1 Y
60 N
  1. Setup parallel event
Wait 0.0s
Set timer1 00:01
Timer1 start
WAIT
If timer1 > 00:01
  OpenSaveMenu
EraseEvent
WAIT timer1 secs timer1_active saves?
0 118 1 Y
1 117 1 Y
58 60 1 Y
59 59 0 Y

Conclusion

  • For autostart and parallel events stated in pre-update, waiting 1.0s (60 frames) will cause the conditional to trigger
  • For parallel events not started on pre-update, waiting 59 frames will cause the conditional to trigger!

@fmatthew5876
Copy link
Contributor Author

Test Cases 3 - Multiple timers

  1. Create autostart event
Timer1 start
Timer2 start
EraseEvent

Result: timer 1 shown in upper left, timer 2 in upper right.

  1. Create autostart event
Timer1 start
EraseEvent

Result: timer 1 shown in upper left

  1. Create autostart event
Timer2 start
EraseEvent

Result: timer 2 shown in upper right

@fmatthew5876
Copy link
Contributor Author

fmatthew5876 commented Mar 16, 2019

Test Cases 4 - time visibility on start

  1. Setup parallel event
Set timer1 01:01
Start timer1
EraseEvent

Result: Timer is visible when map fades in

  1. Change event to autostart

Result: Timer appears after fade in

@fmatthew5876
Copy link
Contributor Author

fmatthew5876 commented Mar 16, 2019

Test Cases 5 - when is : visible?

  1. Setup parallel event
Set timer1 01:01
Wait 0.1s (x4)
Wait 0.0s (x5)
OpenSaveMenu
OpenSaveMenu

Result: : is visible before fade out to first save, invisible on fade out to next save

  1. Setup parallel event
Start timer1
EraseEvent

Result: Timer is frozen at 00:00 and : is not visible

fmatthew5876 added a commit to fmatthew5876/Player that referenced this issue Mar 16, 2019
* Refactor interface to be more user friendly
* Frame accurate timer behavior See EasyRPG#1702 test cases
* Fix : visibily to use timer frames, so that it is save game
  compatible.
@fmatthew5876
Copy link
Contributor Author

Fixed by #1701

@fdelapena fdelapena added this to the 0.6.1 milestone Mar 16, 2019
fmatthew5876 added a commit to fmatthew5876/Player that referenced this issue Mar 17, 2019
* Refactor interface to be more user friendly
* Frame accurate timer behavior See EasyRPG#1702 test cases
* Fix : visibily to use timer frames, so that it is save game
  compatible.
@Ghabry
Copy link
Member

Ghabry commented Mar 22, 2019

Can't remember if this was Celestial Silfate Story but one game also had a flickering timer (which was then fixed), good for a regression test.

fmatthew5876 added a commit to fmatthew5876/Player that referenced this issue Mar 26, 2019
* Refactor interface to be more user friendly
* Frame accurate timer behavior See EasyRPG#1702 test cases
* Fix : visibily to use timer frames, so that it is save game
  compatible.
fmatthew5876 added a commit to fmatthew5876/Player that referenced this issue Mar 31, 2019
* Refactor interface to be more user friendly
* Frame accurate timer behavior See EasyRPG#1702 test cases
* Fix : visibily to use timer frames, so that it is save game
  compatible.
@fmatthew5876 fmatthew5876 reopened this May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants