# Batman: The Enemy Within 1.0.3
# BID: AAC6FB02E03062EF

DECLARATIONS:
  -
    type: code
    name: tripleBuffer
    instructions: [
      [stp, x29, x30, [sp, -16], "!"],
      [ldr, x0, [x26, 0x10]],
      [cbz, x0, :goto1],
      [adrp, x8, 0x1751000],
      [ldr, x8, [x8, 0x150]],
      [ldr, x8, [x8]],
      [blr, x8],
      [b, :goto2],
      :goto1, [mov, w0, 0xc0],
      [bl, 0x72bb40],
      [str, x0, [x26, 0x10]],
      :goto2, [ldr, x22, [x27]],
      [adrp, x27, 0x1750000],
      [ldr, x21, [x25]],
      [ldr, x27, [x27, 0xff8]],
      [adrp, x23, 0x1751000],
      [ldr, x8, [x27]],
      [ldr, x23, [x23, 0xb30]],
      [mov, x0, x23],
      [blr, x8],
      [mov, x2, x0],
      [mov, x0, x21],
      [mov, x1, x22],
      [bl, 0x1a80],
      [mov, x21, x0],
      [ldr, x0, [x25]],
      [bl, 0x1ac0],
      [ldr, x8, [x28]],
      [mov, x1, x0],
      [mov, x0, x23],
      [mov, x2, x21],
      [blr, x8],
      [ldr, x0, [x26, 0x10]],
      [ldr, x8, [x24]],
      [mov, x1, x23],
      [blr, x8],
      [adrp, x22, 0x1751000],
      [ldp, x29, x30, [sp], 16],
      [ret]
    ]

MASTER_WRITE:
# Remove double buffer
  -
    type: asm_a64
    main_offset: 0x64A8
    instructions: [
      [mov, w2, 3],
      [madd, x1, x8, x2, x9]
    ]
  -
    type: bytes
    main_offset: 0xC526D0
    value_type: uint32
    value: 0x1887D70
  -
    type: bytes
    main_offset: 0x1751C50
    value_type: uint32
    value: 0x1887D70
  -
    type: asm_a64
    main_offset: 0x5ED8
    instructions: [
      [bl, _tripleBuffer()]
    ]
  -
    type: asm_a64
    main_offset: 0x5FB0
    instructions: [
      [mov, w1, 3]
    ]
  -
    type: asm_a64
    main_offset: 0x5F7C
    instructions: [
      [mov, x2, 0x1950000]
    ]


