# Config file for Majora's Mask NTSC 1.0 Recompilation.

[input]
entrypoint = 0x80080000
# Paths are relative to the location of this config file.
output_func_path = "RecompiledFuncs"
relocatable_sections_path = "overlays.us.rev1.txt"
# elf_path = "mm.us.rev1.rom_uncompressed.elf"
symbols_file_path = "Zelda64RecompSyms/mm.us.rev1.syms.toml"
rom_file_path = "mm.us.rev1.rom_uncompressed.z64"

[patches]
stubs = [
    # Stub out unused functions that directly manipulate RCP status.
    "RcpUtils_PrintRegisterStatus",
    "RcpUtils_Reset",
    # Stub out an unnecessary function that accesses kseg1 addresses.
    "CIC6105_Init"
]

ignored = [
    # Not actually a function
    "D_80186028"
]

# Single-instruction patches

# Write audio dlists to kseg0 (cached, 0x80...) addresses instead of kseg1 (uncached, 0xA0...) ones.
# This saves the recompiler from needing to handle checking for kseg1 addresses on every memory operation.
[[patches.instruction]]
func = "AudioHeap_WritebackDCache"
vram = 0x8018B510
value = 0x3C010000 # lui $at, 0x2000 -> lui $at, 0x0000

# These two may not be needed with RCP timeout detection disabled
# # Pretend the RSP has already halted so that the game doesn't attempt to directly manipulate RSP registers.
# [[patches.instruction]]
# func = "Sched_HandleAudioCancel"
# vram = 0x801763D8
# value = 0x240F0001 # lw	$t7, 0x0($s1) -> li $t7, 1

# # Ditto.
# [[patches.instruction]]
# func = "Sched_HandleGfxCancel"
# vram = 0x80176534
# value = 0x240F0001 # lw	$t7, 0x0($s1) -> li $t7, 1

# Disable RCP timeout detection (sometimes throws false positives, not needed)
[[patches.instruction]]
func = "AudioMgr_HandleRetrace"
vram = 0x80172DBC
value = 0x00000000 # jal osSetTimer -> nop

# Ditto.
[[patches.instruction]]
func = "Graph_TaskSet00"
vram = 0x80174218
value = 0x00000000 # jal osSetTimer -> nop

# Prevent the minimap from drawing at a point where it can cause a crash when pausing.
[[patches.instruction]]
func = "func_80106644"
vram = 0x80106684
value = 0x29E10003 # slti $at, $t7, 0x4 -> slti $at, $t7, 0x3
