# Config file for Banjo-Kazooie NTSC 1.0 Recompilation.

[input]
entrypoint = 0x80000400
# Paths are relative to the location of this config file.
output_func_path = "RecompiledFuncs"
rom_file_path = "banjo.us.v10.decompressed.z64"
symbols_file_path = "BanjoRecompSyms/bk.us.rev0.syms.toml"
# elf_path = "banjo.us.v10.elf"
# use_mdebug = true
# trace_mode = true
bss_section_suffix = "_bss"

manual_funcs = [
    { name = "boot___osLeoAbnormalResume", section = ".boot_bk_boot", vram = 0x800037E4, size = 0xE8 },
    { name = "boot___osLeoResume", section = ".boot_bk_boot", vram = 0x800038CC, size = 0xEC },
]

mdebug_file_mappings = [
    { filename = "src/TTC/ch/clam.c", input_section = ".text", output_section = ".TTC" },
    { filename = "src/TTC/ch/blubber.c", input_section = ".text", output_section = ".TTC" },
    { filename = "src/TTC/ch/lockup.c", input_section = ".text", output_section = ".TTC" },
    { filename = "src/TTC/ch/treasure.c", input_section = ".text", output_section = ".TTC" },
    { filename = "src/SM/ch/attacktutorial.c", input_section = ".text", output_section = ".SM" },
    { filename = "src/SM/ch/vegetables.c", input_section = ".text", output_section = ".SM" },
]

[patches]

ignored = [
    "boot_n_aspMainTextStart",
    "boot_gSPF3DEX_fifoTextStart",
    "boot_gSPL3DEX_fifoTextStart",
]

renamed = [
    "wmemcpy"
]

stubs = [
    # Boot segment libultra duplicates
    "boot___ll_div",
    "boot___ll_lshift",
    "boot___ll_mod",
    "boot___ll_mul",
    "boot___ll_rem",
    "boot___ll_rshift",
    "boot___ull_div",
    "boot___ull_divremi",
    "boot___ull_rem",
    "boot___ull_rshift",
    "boot_osPiRawStartDma",
    "boot_osPiGetStatus",
    "boot___osSetSR",
    "boot___osGetSR",
    "boot___osSetFpcCsr",
    "boot___osSiRawReadIo",
    "boot___osSiRawWriteIo",
    "boot___osExceptionPreamble",
    "boot___osExceptionPreamble2",
    "boot___osException",
    "boot_send_mesg",
    "boot_handle_CpU",
    "boot___osEnqueueAndYield",
    "boot___osEnqueueThread",
    "boot___osPopThread",
    "boot___osDispatchThread",
    "boot___osCleanupThread",
    "boot_osWritebackDCache",
    "boot_osInvalICache",
    "boot_osMapTLBRdb",
    "boot_osPiRawReadIo",
    "boot_osVirtualToPhysical",
    "boot___osSiDeviceBusy",
    "boot___osDequeueThread",
    "boot___osLeoInterrupt",
    "boot___osLeoAbnormalResume",
    "boot___osLeoResume",
    "boot_osSetEventMesg",
    "boot_func_80003A30",
    "boot_osDestroyThread",
    "boot___osProbeTLB",
    "boot_osLeoDiskInit",
    "boot_osEPiRawStartDma",
    "boot___osDisableInt",
    "boot___osRestoreInt",
    "boot_osCreatePiManager",
    "boot_osCartRomInit",
    "boot_osCreateMesgQueue",
    "boot___osPiCreateAccessQueue",
    "boot___osPiGetAccess",
    "boot___osPiRelAccess",
    "boot_osGetThreadPri",
    "boot_osSetThreadPri",
    "boot_osCreateThread",
    "boot___osDevMgrMain",
    "boot_osStartThread",
    "boot_osSendMesg",
    "boot_osRecvMesg",
    "boot___osResetGlobalIntMask",
    "boot_osEPiRawWriteIo",
    "boot_osEPiRawReadIo",
    "boot___osSetGlobalIntMask",
    "boot_osYieldThread",
    # Unnamed exceptasm functions:
    "func_8026A2E0",
    "func_8026A824",
    # Misspelled functions
    "osWriteBackDCacheAll",
]

# Single-instruction patches

[[patches.instruction]]
func = "viewport_setRenderPerspectiveMatrix"
vram = 0x8024C9A8
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000

[[patches.instruction]]
func = "anctrl_setDuration"
vram = 0x8028768C
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000

[[patches.instruction]]
func = "func_802D3DA4"
vram = 0x802D3DAC
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000

[[patches.instruction]]
func = "func_8038F4C0"
vram = 0x8038F4E0
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000

[[patches.instruction]]
func = "func_8038AC04"
vram = 0x8038AC0C
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000

[[patches.instruction]]
func = "func_80388D48"
vram = 0x80388D50
value = 0x3C0E8000 # lui $t6, 0xA000 -> lui $t6, 0x8000
