# 영웅전설 섬의 궤적 IV -THE END OF SAGA- 1.0.0
# BID: 0BBD86F62F380844
# Button polling is 2x more sensitive to holding any button

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, x0, [x19, 8]],
      [fcvt, s4, d0],
      [adrp, x8, $frame_time],
      [str, s4, [x8, $frame_time]],
      [ret]
    ]
MASTER_WRITE:
  # Move loading FPS lock time
  ## REF: MOV with 0x1FC7945
  -
    type: asm_a64
    main_offset: 0x5B22F8
    instructions: [
      [adrp, x20, $fps_lock],
      [ldr, w20, [x20, $fps_lock]]
    ]
  # Write game's loop time as float
  ## REF: 1F 01 09 EB 00 08 61 1E, replace STR X0, [X19,#8] below it
  -
    type: asm_a64
    main_offset: 0x5B2358
    instructions: [
      [bl, _dynamicSpeed()]
    ]
  # Read lowest timing float factor
  ## REF: E8 03 1F 2A 00 20 22 1E 60 5E 1A BD, MOV with 0x3D088889 + FMINM + FMOV above it
  -
    type: asm_a64
    main_offset: 0x5F8E0
    instructions: [
      [adrp, x8, $frame_time],
      [fminnm, s0, s0, s2],
      [ldr, s2, [x8, $frame_time]],
      [nop]
    ]