# Game functions replaced by host code (docs/RECOMPILER.md "Hooks").
#
#   <symbol> [us] [pal] [jp] [kr]  the function's body moves to <fn>_orig; HLE(<symbol>) replaces it
#                              and may call callOriginal(c, "<symbol>")
#   <symbol> all               <symbol> is the USA name; the hook applies to every version: the
#                              recompiler finds the matched function (config/<id>/us_map.txt) and
#                              gives it the USA name there, so one HLE(<USA name>) serves all four
#   <module>::<symbol>         a function of a REL module (name from config/<id>/rels/<module>.txt);
#                              with "all": the USA fn_<id>_<offset>, matched via rels_us_map.txt
#   patch <id> <addr> <word>   runtime-switchable instruction patch (setPatch(id, on)); with "all"
#                              <addr> is the USA address, mapped into a hash-matched function
#
# Every named DOL function is replaceable by name already (no line needed; names like the SDK's
# are the same in every version); lines here are for auto-named and REL functions and patches.
# Prefer "all" (docs/SETUP.md "Version-aware code"). A line without "all" applies to the USA build
# unless it is tagged only "pal", "jp" and/or "kr"; to the European / Japanese / Korean build only
# when tagged "pal" / "jp" / "kr", and then <symbol> is that version's own name. A build fails
# when an entry matches nothing.

# Audio (docs/AUDIO.md "Surround output"): with F1 > Sound > Output 5.1 / 7.1 the port keeps NW4R's
# Dolby Pro Logic II mode: City Folk's `bl AxManager::SetOutputMode(STEREO)` right after
# InitSoundSystem (in fn_801CE6B0) becomes a nop. Switched by hle_audio.cpp (SCGetSoundMode).
patch 30 801CE714 60000000 all

# Content from other regions (src/game/cf_region.cpp, docs/REGION_CONTENT.md "Content from other
# regions in the port"): the event calendar's "event runs on this date" test (region mask + date
# rule), Mother's Day and Father's Day date rules.
fn_80089890 all
fn_800895E0 all
fn_800897B0 all
# The region getter itself, answered per call site (Nook's seasonal item, event letters).
fn_801069D0 all
# The town's region group (0 JP, 1 USA, 2 Europe, 3 Korea), for the villager house-type data of
# d_a_str_fieldNP (other regions' houses).
fn_80169890 all
# Calendar / hemisphere / real-time weather (src/game/cf_calendar.cpp, cf_weather.cpp; docs/CALENDAR.md).
fn_8016D40C all  # game clock getter
fn_8016DD58 all  # date -> term index
fn_8016DDA8 all  # date -> spring/summer/fall/winter
fn_80090E2C all  # date -> fish period
fn_800BD450 all  # month -> insect table
fn_800C6024 all  # month/day -> item season
fn_801C973C all  # month/day -> weather period
fn_801C9E48 all  # town weather of an hour
fn_801C9EC0 all  # city weather of an hour

# Grass wear (src/game/cf_grass.cpp, docs/FEATURES.md "Grass wear"): the step wear (player steps and
# town generation) and the daily regrowth.
fn_8008D6B4 all
fn_800A7F9C all

# Skin tone (src/game/cf_skin.cpp, docs/FEATURES.md "Skin tone"): the player's skin palette index
# (d_a_playerNP, same offset in all versions) and the daily tan update.
d_a_playerNP::fn_80_2080 all
fn_80137D34 all

# Random::setSeed(this, seed) (stw r4,0(r3)): CF_RNG_SEED test aid in src/game/cf_game.cpp.
fn_802AA1A0 all
# Random::next (LCG x*0x19660D+0x3C6EF35F): CF_RNG_SEED keeps other threads off the main stream.
fn_802AA1A8 all

# Photos to the screenshots folder (src/game/cf_sd_card.cpp, docs/FEATURES.md "Photos to the
# screenshots folder"): the PrFILE2 wrappers only the photo code calls (attach, detach, mount,
# unmount, errnum, fsfirst, fsnext, mkdir, create, write, close, remove, rmdir) are an SD card host
# over the screenshots folder; Erase All's photo check and erase see no photos.
fn_8021C600 all
fn_8021C820 all
fn_8021CA84 all
fn_8021CC38 all
fn_8021C8C8 all
fn_8021C934 all
fn_8021C960 all
fn_8021CA58 all
fn_8021C7F4 all
fn_8021C98C all
fn_8021C908 all
fn_8021CBE0 all
fn_8021CC0C all
fn_8008F950 all
fn_8008FB48 all

# Save diagnosis (temporary, src/recomp/hle_ios.cpp): the save/check thread start and the
# WiiConnect24 task start the save path waits on (auto names are only hookable when listed).
fn_800D284C all
fn_80177F44 all

# Menu navigation (src/game/cf_menu_nav.cpp, docs/CONTROLS.md "Snap pointer to menu items"): the
# game's gui::Manager::update (a copy of the HOME Menu's homebutton::gui library).
fn_80314AF4 all
# The pane-tree walk the game's menus hit-test the pointer with (Bounding panes named "B*").
fn_802B5598 all

# Enhanced world (src/game/cf_world.cpp, docs/RENDERING.md "Enhanced world"): dWeather_c's per-frame
# update (its weather state at +0x5884).
fn_801C92F0 all
# Planar reflections of characters (src/game/cf_tags.cpp): the worn Mii mask's RFL head draws
# (opaque / translucent wrappers of RFLDrawOpaCore / RFLDrawXluCore; hash-matched in all four).
fn_802B3950 all
fn_802B39B0 all

# Nintendo events (docs/DISTRIBUTIONS.md): the game keeps a Nintendo letter from a WiiConnect24
# package (save letter slot, letter, item, letter id); src/recomp/distributions.cpp records which
# distribution the town received and calls the original (all versions; live delivery too).
fn_8010F194 all
# Pete hands a kept Nintendo letter over (copies it into the player's mail); logged by distributions.cpp.
fn_80104520 all

# Enhanced lighting (src/game/cf_light.cpp, docs/RENDERING.md "Enhanced lighting (City Folk)"): the
# stage draw (both ScnRoot passes + effects of the field/room scene) brackets the 3D scene.
d_s_stageNP::fn_125_C0 all

# Frame interpolation (src/game/cf_tags.cpp, docs/WII.md "Town interpolation (branch interp-town)"):
# one field object (tree, bush, flower, fence, ...) of the town's ScnProc draw, r3 = its record
# (+0x8 kind, +0x14 position): each object its own tag scope, keyed by its place.
d_fg_drawNP::fn_112_2184 all

# Shadows of objects outside the view (src/game/cf_shadow_casters.cpp, docs/RENDERING.md "Shadows
# of objects outside the view"): the game camera's sphere-in-frustum test (field objects), daSTR_c's
# draw and its cull test with the flat window / line tests inside (structures). g3d's
# ScnObjGather::Add and ScnGroup::Insert are hooked by name.
fn_802B777C all
d_a_strNP::fn_99_2B04 all
d_a_strNP::fn_99_2548 all
fn_80166CDC all
fn_8018ABC8 all
# Branch shadow-casters-2: villagers / NPCs (base draw + its flat window test), other players
# (draw + window test), the line behind the camera (trees fn_112_17F0, d_fgobj_managerNP's object
# draw fn_111_E4C), a main.dol actor with the frustum test, blob shadow registrations.
fn_8001665C all
fn_800284F8 all
d_a_playerNP::fn_80_E20 all
d_a_playerNP::fn_80_248C all
fn_8018AB88 all
d_fgobj_managerNP::fn_111_E4C all
fn_80181978 all
fn_801C863C all
fn_801C874C all

# Online letters research (src/recomp/online_mail.cpp CF_MAIL_PROBE): Pelly's post office checks.
fn_80177D78
fn_801165F4
fn_80178580
fn_80013F1C
fn_800E97E8
fn_800EA800
fn_800EA0DC
fn_800EABAC
fn_800EAC00
fn_800EAC74
fn_800E9878
fn_800EAF28
fn_8017856C
fn_80404BBC
fn_80404DB8
fn_803F9D44
fn_8019B84C
fn_80178244
fn_801782A0
fn_800E9D34
d_a_npc_sp_perikoNP::fn_34_5E9C
d_a_npc_sp_perikoNP::fn_34_2C3C
fn_800FBDA8

# Pointer over the whole window in ultrawide (src/game/cf_pointer.cpp, docs/CONTROLS.md "Pointer in
# ultrawide"): the game's "pointer on the screen" test, the KPAD pointer getter it reads, and the
# player's "pointer inside the limits" test before walking to it, widened in x by the pointer range.
fn_8017FF4C all
fn_800FA6AC all
d_a_playerNP::fn_80_2DB28 all

# Mii maker (src/game/cf_mii.cpp, docs/MIIS.md): the game's Mii icon queue (RFLMakeIcon for each
# pending request), run at the start of the stage draw (d_s_stageNP fn_125_C0). The F1 > Miis
# preview is drawn by RFLMakeIcon right after the game's own icons. (RFLSetMtx, hooked for the
# preview's rotation, is a named SDK function: no line needed.)
fn_8000A57C all

# The structures' window glow (daSTR_c light controller, d_a_strNP fn_99_A40: lerps TEV colour 1
# of m_light / m_window / m_spotlight / m_museum ... by the light amount at controller +0, ScnMdl
# at +0x2C): night lights follow the game's own lights-on state.
d_a_strNP::fn_99_A40 all

# Move in from Wild World (docs/MOVE_IN.md; src/recomp/hle_mp.cpp, src/game/cf_move_in.cpp): the
# RevoEX MP / MPDL libraries (DS wireless: DS Download Play of DSApp/*.srl, then MP data) answered
# on the host, with a virtual DS child in the role of Vaga_Sign.srl (the Moving Van) that sends the Wild World save
# the player picked. The game's link manager, protocol, checks and import run unchanged.
fn_803FAA64 all  # MP startup (config: ggid +0x10, indication callback +0x194)
fn_803FAC4C all  # MP cleanup
fn_803FBC4C all  # MP set user game info (beacon bytes, <= 0x70)
fn_803FE8FC all  # MP set a callback (the game passes an empty one)
fn_803FCA0C all  # MP disconnect every child (0 = done)
fn_803FBDB8 all  # MP send async (data, len, aid mask, port, result*, callback, arg)
fn_8040141C all  # MPDL startup (download-play config: program image, banner, ggid)
fn_8040171C all  # MPDL cleanup
fn_80401A2C all  # MPDL: children that have the program (aid bit mask)
fn_804017C8 all  # MPDL: boot those children (aid bit mask)
fn_80401B04 all  # MPDL: booted children (aid bit mask)
fn_8040193C all  # MPDL: child info (aid, 0x28-byte out)
# The game's MP link poll (once a frame, outside the link mutex): delivers the MP indications.
fn_800E3EE4 all
# "Imported resident exists" (Rover's resident list): with one resident picked in the port's
# window only that one is offered.
fn_80085894 all

# Warps (src/game/cf_warp.cpp, docs/WARPS.md): the stage manager's "go to stage, arrive at
# pos/angle" (every door) and its change request, logged with CF_WARP_LOG; warps call them.
fn_80163064 all
fn_80162EC8 all

# Wii Speak (src/recomp/online_voice.cpp, docs/ONLINE.md "Wii Speak voice chat"): the PMIC library's
# API answered by the host (PC microphone through SDL3 capture, opt-in): Init, Quit, Probe, Open,
# Close, Start, Stop, Read, the speaker echo-reference resampler/writer and the device control
# requests (three set-parameter calls, the reset pulse). The game's VCT runs as is.
fn_80225CE4 all
fn_80225FE0 all
fn_802260CC all
fn_802261A0 all
fn_802262C8 all
fn_80226358 all
fn_8022646C all
fn_80228FD4 all
fn_802290BC all
fn_802291F8 all
fn_80229B50 all
fn_80229C28 all
fn_8022A15C all
fn_8022A238 all
# The game's echo suppressor (mic frame vs the voices being played): F1 "Echo suppression" off
# (headphones) skips it, so both players can talk at once.
fn_80229D08 all

# Unused items at Nook's (src/game/cf_unused_items.cpp, docs/FEATURES.md "Unused items at Nook's"):
# the day's stock generator (shop stock at save + 0x630C0; called by the daily update fn_8014406C
# and by d_shop_fgNP when the shop is rebuilt) and the save-write starters (each computes the
# save's checksum and starts the save worker: the replacement is taken out of the stock first, so
# it never reaches the save file).
fn_801456B4 all
# The item value every buy / sell / price reader uses (record price, stationery by sheets): the
# port's prices for the unused walls, floors, boxes, bench, pikmin and Blue Falcon at all times.
fn_800A5F74 all
fn_800D256C all
fn_800D25D8 all
fn_800D2648 all
fn_800D26B0 all
fn_800D2720 all
fn_800D2780 all
fn_800D27E0 all
fn_800D2830 all

# Furniture lights (src/game/cf_furniture_light.cpp): a furniture glow helper's per-frame update
# (lp_m / tv_m / mn_m / fr_m amount 0..1 at helper +0, ResMatData at +0x14), and daFTR_c's per-frame
# update (its model -> its item record at +0x3A0).
d_a_ftrNP::fn_15_767C all
d_a_ftrNP::fn_15_3100 all

# Circle wipe (src/game/cf_hud.cpp, docs/WII.md "The circle wipe"): mWipeFader_c::draw, the iris
# wipe of doors, stage changes and the arrival in the town; drawn in a ws::WipeScope so it covers
# windows wider than 16:9.
fn_802B6B48 all

# Indoor lighting (src/game/cf_furniture_light.cpp, docs/RENDERING.md "Indoor lighting"):
# dEnvAmbLight_c's per-frame update, the room's ambient brightening when a lamp or candle is on
# (scaled to "Room fill from lamps" with furniture lights).
fn_80197E1C all

# The game's texture capture (src/game/cf_game.cpp): its buffer is marked as CPU-read before the
# EFB copy, so photos (1 button) are read back into guest memory (they were black).
fn_802B7A7C all
