# 英雄傳說 閃之軌跡III 1.0.0
# BID: 37C3FAEFC9A4C374
# Button polling is 2x more sensitive to holding any button at 60 FPS
# Fishing timer is decreasing 2x faster at 60 FPS
# Bike is turning 2x faster at 60 FPS

DECLARATIONS:
  -
    type: variable
    name: fps_lock
    value_type: uint32
    default_value: 33333333
    evaluate: "FRAMETIME_TARGET * 930000"
  -
    type: variable
    name: frame_time
    value_type: float
    default_value: 0.0333333333
  -
    type: code
    name: dynamicSpeed
    instructions: [
      [str, d0, [x8, 0x20]],
      [fcvt, s4, d0],
      [adrp, x8, $frame_time],
      [str, s4, [x8, $frame_time]],
      [ret]
    ]
MASTER_WRITE:
  # Move loading FPS lock time
  ## REF: MOV with 0x1FCA055
  -
    type: asm_a64
    main_offset: 0x4FEC28
    instructions: [
      [adrp, x9, $fps_lock],
      [ldr, w9, [x9, $fps_lock]]
    ]
  # Write game's loop time as float
  ## Ref: Replace STR D0, [X8,#0x20] below
  -
    type: asm_a64
    main_offset: 0x4FEC94
    instructions: [
      [bl, _dynamicSpeed()]
    ]
  # Read lowest timing float factor
  ## REF: 20 20 22 1E EA 03 00 32, replace ADRP + FMINM + LDR
  -
    type: asm_a64
    main_offset: 0x5E4AC
    instructions: [
      [adrp, x8, $frame_time],
      [fminnm, s1, s1, s2],
      [ldr, s2, [x8, $frame_time]]
    ]