#===============================================================================#
# Handle incrementing speed stages if $CanToggle allows it
# (Modified so that we adjust the effective time when cycling speeds)
#===============================================================================#
module Input
def self.update
update_KGC_ScreenCapture
pbScreenCapture if trigger?(Input::F8)
if $CanToggle && trigger?(Input::AUX1)
# Record the current multiplier
old_multiplier = SPEEDUP_STAGES[$GameSpeed]
$GameSpeed += 1
$GameSpeed = 0 if $GameSpeed >= SPEEDUP_STAGES.size
# Get the new multiplier
new_multiplier = SPEEDUP_STAGES[$GameSpeed]
# Adjust the effective uptime so that animations aren’t disrupted:
System.adjust_multiplier(old_multiplier, new_multiplier)
$PokemonSystem.battle_speed = $GameSpeed if $PokemonSystem && $PokemonSystem.only_speedup_battles == 1
$RefreshEventsForTurbo = true
end
end
end
#===============================================================================#
# Return System.Uptime with a multiplier to create an alternative timeline
# (Modified to be continuous across multiplier changes)
#===============================================================================#
module System
class << self
alias_method :unscaled_uptime, :uptime unless method_defined?(:unscaled_uptime)
end
# New: a time offset so that uptime remains continuous even if the multiplier changes
@time_offset = 0
def self.uptime
current_unscaled = unscaled_uptime
# Effective uptime = offset + (current multiplier × unscaled time)
return @time_offset + SPEEDUP_STAGES[$GameSpeed] * current_unscaled
end
# New: When the multiplier changes, adjust @time_offset so that the effective uptime remains continuous.
def self.adjust_multiplier(old_multiplier, new_multiplier)
current_unscaled = unscaled_uptime
# Effective time before the change:
effective_time = @time_offset + old_multiplier * current_unscaled
# Set new offset so that: new_offset + new_multiplier * current_unscaled == effective_time
@time_offset = effective_time - new_multiplier * current_unscaled
end
end