// Visit https://github.com/ethteck/splat/wiki/Adding-Symbols for documentation about this file
entrypoint = 0x80061600; // type:func
// Named boot_main rather than main: a recompiled function called main clashes with C's main().
boot_main = 0x80061660; // type:func

// ---------------------------------------------------------------------------
// Game boot code (not libultra)
// ---------------------------------------------------------------------------
// Builds a "MIO0" header in place, then calls the handwritten decoder below.
mio0_decompress_chunk = 0x80061890; // type:func
mio0_decode = 0x80061940; // type:func
// ---------------------------------------------------------------------------
// toplevel (ROM file 0, decompressed by main to 0x8006A8A0)
// ---------------------------------------------------------------------------
// Entry point of the decompressed game code; main jumps here after loading it.
toplevel_entry = 0x8006B794; // type:func

// func_80061938 is an unreferenced `b .` hang loop; left unnamed.

// ---------------------------------------------------------------------------
// libultra functions
// ---------------------------------------------------------------------------
__osSetWatchLo = 0x80061910; // type:func
// Unreferenced duplicate of osGetCount; listed in [patches].ignored in kengriffey.toml.
boot_GetCount = 0x80061920; // type:func
__osSetCount = 0x8006192C; // type:func
osInvalDCache = 0x800619E0; // type:func
osSetIntMask = 0x80061A90; // type:func
osWritebackDCacheAll = 0x80061B30; // type:func
osInitialize = 0x80061B60; // type:func
__osSiRawReadIo = 0x80061DF0; // type:func
__osSiRawWriteIo = 0x80061E40; // type:func
osPiGetStatus = 0x80061E90; // type:func
osPiRawReadIo = 0x80061EA0; // type:func
osPiReadIo = 0x80061F00; // type:func
// The boot loader calls osPiRawStartDma directly to load toplevel, and N64ModernRuntime only has a
// fatal stub for it. Renamed so it can be implemented natively (SlugfestRecomp runtime_stubs.cpp).
boot_osPiRawStartDma = 0x80061F40; // type:func
osPiRawWriteIo = 0x80062020; // type:func
osPiWriteIo = 0x80062070; // type:func
bzero = 0x800620B0; // type:func

// ll.c
__ull_rshift = 0x80062150; // type:func
__ull_rem = 0x8006217C; // type:func
__ull_div = 0x800621B8; // type:func
__ll_lshift = 0x800621F4; // type:func
__ll_rem = 0x80062220; // type:func
__ll_div = 0x8006225C; // type:func
__ll_mul = 0x800622B8; // type:func
__ull_divremi = 0x800622E8; // type:func
__ll_mod = 0x80062348; // type:func
__ll_rshift = 0x800623E4; // type:func

// exceptasm.s
__osExceptionPreamble = 0x80062410; // type:func size:0x10
__osException = 0x80062420; // type:func
// send_mesg also contains the tail of __osException (handle_CpU, 0x80062A08-0x80062A3C).
// Both are ignored by N64Recomp, so the boundary doesn't matter.
send_mesg = 0x80062954; // type:func
__osEnqueueAndYield = 0x80062A3C; // type:func
__osEnqueueThread = 0x80062B3C; // type:func
__osPopThread = 0x80062B84; // type:func
__osDispatchThread = 0x80062B94; // type:func size:0x17C
__osCleanupThread = 0x80062D10; // type:func

__osGetSR = 0x80062D20; // type:func
osInvalICache = 0x80062D30; // type:func
__osSetFpcCsr = 0x80062E10; // type:func
__osSetSR = 0x80062E20; // type:func
osWritebackDCache = 0x80062E30; // type:func
osMapTLBRdb = 0x80062EB0; // type:func
osDestroyThread = 0x80062F10; // type:func
osSetEventMesg = 0x80063020; // type:func
__osDequeueThread = 0x80063090; // type:func
osVirtualToPhysical = 0x800630D0; // type:func
__osSiDeviceBusy = 0x80063150; // type:func

// leointerrupt.c
__osLeoInterrupt = 0x80063180; // type:func
__osLeoAbnormalResume = 0x80063824; // type:func
__osLeoResume = 0x8006390C; // type:func

__osGetCause = 0x80063A00; // type:func
osGetCount = 0x80063A10; // type:func
__osDisableInt = 0x80063A20; // type:func
__osRestoreInt = 0x80063A40; // type:func
__osProbeTLB = 0x80063A60; // type:func
osCreateMesgQueue = 0x80063B20; // type:func
osRecvMesg = 0x80063B50; // type:func
osStartThread = 0x80063C90; // type:func
osEPiRawStartDma = 0x80063DE0; // type:func
osLeoDiskInit = 0x80064010; // type:func

// xprintf.c / xlitob.c / xldtob.c (plain C, recompiled normally)
_Putfld = 0x80064110; // type:func
_Printf = 0x80064780; // type:func
_Litob = 0x80065910; // type:func
_Genld = 0x80065BB0; // type:func
_Ldtob = 0x80066120; // type:func

osCreateThread = 0x80064DD0; // type:func
__osGetActiveQueue = 0x80064F20; // type:func
osStopThread = 0x80064F30; // type:func
__osSpRawReadIo = 0x80064FF0; // type:func
__osSpRawWriteIo = 0x80065040; // type:func
osCreatePiManager = 0x80065090; // type:func
osCartRomInit = 0x80065220; // type:func
__osDevMgrMain = 0x80065320; // type:func
__osPiCreateAccessQueue = 0x800657B0; // type:func
__osPiGetAccess = 0x80065800; // type:func
__osPiRelAccess = 0x80065844; // type:func
memcpy = 0x80065870; // type:func
strlen = 0x8006589C; // type:func
strchr = 0x800658C4; // type:func
osGetThreadPri = 0x80066670; // type:func
__osResetGlobalIntMask = 0x80066690; // type:func
osSendMesg = 0x800666F0; // type:func
__osSetGlobalIntMask = 0x80066840; // type:func
osSetThreadPri = 0x80066890; // type:func
osYieldThread = 0x80066970; // type:func
__osSpDeviceBusy = 0x800669C0; // type:func
osEPiRawReadIo = 0x800669F0; // type:func
osEPiRawWriteIo = 0x80066B90; // type:func
lldiv = 0x80066D20; // type:func
ldiv = 0x80066E20; // type:func

// ---------------------------------------------------------------------------
// libultra data
// ---------------------------------------------------------------------------
osTvType = 0x80000300; // type:s32
osRomBase = 0x80000308; // type:u32
osResetType = 0x8000030C; // type:s32
osAppNMIBuffer = 0x8000031C; // size:0x40

osClockRate = 0x80067FD0; // type:u64
osViClock = 0x80067FD8; // type:s32
__OSGlobalIntMask = 0x80067FE0; // type:u32
__osThreadTail = 0x80068010; // size:0x8
__osRunQueue = 0x80068018; // type:u32
__osActiveQueue = 0x8006801C; // type:u32
__osRunningThread = 0x80068020; // type:u32
__osFaultedThread = 0x80068024; // type:u32
__osPiDevMgr = 0x80068080; // size:0x1C
__osPiTable = 0x8006809C; // type:u32
__osCurrentHandle = 0x800680A0; // size:0x8
__osPiAccessQueueEnabled = 0x800680B0; // type:u32
__osRcpImTable = 0x80068110;
__osFinalrom = 0x80068360; // type:u32
__osThreadSave = 0x80068370;
__osEventStateTab = 0x80068520;
LeoDiskHandle = 0x800695A0;
__osDiskHandle = 0x80069614; // type:u32
CartRomHandle = 0x8006A7F0;
__osPiAccessQueue = 0x8006A878;

// ---------------------------------------------------------------------------
// toplevel libultra (the game links its own copies of these; the OS core,
// threads and message queues come from the boot segment above)
// ---------------------------------------------------------------------------
// Timers / messages
osGetTime = 0x80079790; // type:func
osJamMesg = 0x80079820; // type:func
osSetTimer = 0x80079970; // type:func
osStopTimer = 0x80079A50; // type:func
__osTimerServicesInit = 0x80079B40; // type:func
__osTimerInterrupt = 0x80079BCC; // type:func
__osSetTimerIntr = 0x80079D44; // type:func
__osInsertTimer = 0x80079DB8; // type:func
osGetCurrFaultedThread = 0x80079F40; // type:func
__osSetCompare = 0x80082D50; // type:func

// AI / DP / SP
osAiGetLength = 0x8007DBC0; // type:func
osAiSetFrequency = 0x8007DBD0; // type:func
osAiSetNextBuffer = 0x8007DD30; // type:func
__osAiDeviceBusy = 0x80087C50; // type:func
osDpGetStatus = 0x8007DDE0; // type:func
__osSpGetStatus = 0x8007DDF0; // type:func
__osSpSetStatus = 0x8007DE00; // type:func
_VirtualToPhysicalTask = 0x8007DE10; // type:func
osSpTaskLoad = 0x8007DF2C; // type:func
osSpTaskStartGo = 0x8007E0BC; // type:func
osSpTaskYield = 0x8007E100; // type:func
osSpTaskYielded = 0x8007E120; // type:func
__osSpSetPc = 0x80087C80; // type:func
__osSpRawStartDma = 0x80087CC0; // type:func

// VI
osViGetCurrentFramebuffer = 0x8007E1A0; // type:func
osViGetNextFramebuffer = 0x8007E1E0; // type:func
osCreateViManager = 0x8007E220; // type:func
viMgrMain = 0x8007E3A8; // type:func
osViSetEvent = 0x8007E580; // type:func
osViSetMode = 0x8007E5F0; // type:func
osViSetSpecialFeatures = 0x8007E660; // type:func
osViSetYScale = 0x8007E820; // type:func
osViSwapBuffer = 0x8007E880; // type:func
__osViSwapContext = 0x8007E8D0; // type:func
osViBlack = 0x8007EC30; // type:func
__osViInit = 0x80087D50; // type:func
__osViGetCurrentContext = 0x80087E90; // type:func

// PI
// osPiStartDma(mb, pri, direction, devAddr, vAddr, nbytes, mq): message types 0xB/0xC.
osPiStartDma = 0x800826A0; // type:func
osPiGetCmdQueue = 0x80089900; // type:func

// SI / controllers
osContStartQuery = 0x8007ECA0; // type:func
osContGetQuery = 0x8007ED24; // type:func
osContStartReadData = 0x8007ED50; // type:func
osContGetReadData = 0x8007EDDC; // type:func
__osPackReadData = 0x8007EE84; // type:func
osContInit = 0x8007EF70; // type:func
__osContGetInitData = 0x8007F0E0; // type:func
__osPackRequestData = 0x8007F1B0; // type:func
osContSetCh = 0x8007F2B0; // type:func
__osSiRawStartDma = 0x80087EA0; // type:func
__osSiCreateAccessQueue = 0x80087F50; // type:func
__osSiGetAccess = 0x80087FA0; // type:func
__osSiRelAccess = 0x80087FE4; // type:func

// Controller Pak (PFS) and rumble
osPfsChecker = 0x8007F320; // type:func
corrupted_init = 0x8007F9E4; // type:func
corrupted = 0x8007FB98; // type:func
osPfsAllocateFile = 0x8007FD80; // type:func
__osPfsDeclearPage = 0x80080204; // type:func
__osClearPage = 0x80080468; // type:func
osPfsDeleteFile = 0x80080530; // type:func
__osPfsReleasePages = 0x80080810; // type:func
__osBlockSum = 0x80080A58; // type:func
__osPfsGetNextPage = 0x80080B50; // type:func
osPfsReadWriteFile = 0x80080C4C; // type:func
osPfsFileState = 0x80081070; // type:func
osPfsFindFile = 0x80081360; // type:func
osPfsFreeBlocks = 0x80081520; // type:func
osPfsNumFiles = 0x80081670; // type:func
osPfsInitPak = 0x800817C0; // type:func
osPfsRepairId = 0x80081A60; // type:func
__osPfsGetStatus = 0x80081CC0; // type:func
__osPfsRequestOneChannel = 0x80081DA4; // type:func
__osPfsGetOneChannelData = 0x80081E64; // type:func
osMotorStop = 0x80081F00; // type:func
osMotorStart = 0x800820A0; // type:func
_MakeMotorData = 0x80082240; // type:func
osMotorInit = 0x800823BC; // type:func
__osContAddressCrc = 0x80088010; // type:func
__osContDataCrc = 0x800880C0; // type:func
__osContRamRead = 0x80088190; // type:func
__osPackRamReadData = 0x800883AC; // type:func
__osContRamWrite = 0x800884F0; // type:func
__osPackRamWriteData = 0x800886F4; // type:func
__osSumcalc = 0x80088860; // type:func
__osIdCheckSum = 0x800888BC; // type:func
__osRepairPackId = 0x80088924; // type:func
__osCheckPackId = 0x80088D3C; // type:func
__osGetId = 0x80088ED4; // type:func
__osCheckId = 0x80089130; // type:func
__osPfsRWInode = 0x8008922C; // type:func
__osPfsSelectBank = 0x8008954C; // type:func
osPfsIsPlug = 0x800895C0; // type:func
__osPfsRequestData = 0x80089760; // type:func
__osPfsGetInitData = 0x80089830; // type:func

// libc / compiler helpers
bcopy = 0x800827B0; // type:func
// __d_to_ll has no label of its own in splat's output; this splits it off the end of bcopy.
__d_to_ll = 0x80082AC0; // type:func
__f_to_ll = 0x80082ADC; // type:func
__d_to_ull = 0x80082AF8; // type:func
__f_to_ull = 0x80082B98; // type:func
__ll_to_d = 0x80082C34; // type:func
__ll_to_f = 0x80082C4C; // type:func
__ull_to_d = 0x80082C64; // type:func
__ull_to_f = 0x80082C98; // type:func
proutSprintf = 0x80082CD0; // type:func
sprintf = 0x80082CF4; // type:func

// toplevel libultra data
__osTimerList = 0x800936B0; // type:u32
__osViCurr = 0x80094770; // type:u32
__osViNext = 0x80094774; // type:u32
__osCurrentTime = 0x800F8580; // type:u64
__osBaseCounter = 0x800F8588; // type:u32
__osViIntrCount = 0x800F858C; // type:u32
__osContPifRam = 0x800F9800; // size:0x40
__osContLastCmd = 0x800F9840; // type:u8
__osMaxControllers = 0x800F9841; // type:u8
__osPfsPifRam = 0x800F9AF0; // size:0x40

// ---------------------------------------------------------------------------
// arts libultra (PI handle API; the rest of arts' 0x8012F34C-0x80131070 range is game code
// that reads ROM headers through osPiRawReadIo)
// ---------------------------------------------------------------------------
// osEPiStartDma(handle, mb, direction): message types 0xF/0x10.
osEPiStartDma = 0x8012E590; // type:func
osEPiLinkHandle = 0x8012E670; // type:func
osEPiReadIo = 0x8012E6C0; // type:func
osEPiWriteIo = 0x8012E710; // type:func

// ---------------------------------------------------------------------------
// frontend libultra: FlashRAM driver (flash.c order; command bytes E1/D2/3C/78/4B/B4/A5/F0)
// ---------------------------------------------------------------------------
osFlashInit = 0x80199C28; // type:func segment:frontend
osFlashReadStatus = 0x80199D7C; // type:func segment:frontend
osFlashReadId = 0x80199E48; // type:func segment:frontend
osFlashClearStatus = 0x80199F60; // type:func segment:frontend
osFlashAllErase = 0x80199FCC; // type:func segment:frontend
osFlashSectorErase = 0x8019A0E8; // type:func segment:frontend
osFlashWriteBuffer = 0x8019A214; // type:func segment:frontend
osFlashWriteArray = 0x8019A2E0; // type:func segment:frontend
osFlashReadArray = 0x8019A3E4; // type:func segment:frontend

// ---------------------------------------------------------------------------
// Small functions splat merged into the preceding function (they start right after its
// `jr $ra`). Both are only reached through function pointers in gamebase's data, so N64Recomp
// needs them as real functions for the runtime lookup.
// ---------------------------------------------------------------------------
func_80166870_gamebase = 0x80166870; // type:func segment:gamebase
func_8016B52C_gamebase = 0x8016B52C; // type:func segment:gamebase
