diff --git a/.github/instructions/ghidra.instructions.md b/.github/instructions/ghidra.instructions.md index dba9325..a499fae 100644 --- a/.github/instructions/ghidra.instructions.md +++ b/.github/instructions/ghidra.instructions.md @@ -7,6 +7,7 @@ applyTo: "**" ## Safety Guardrails - Never create a git commit on your own. +- Never save or explicitly persist Ghidra project/program changes yourself, including through MCP endpoints or scripts. Leave requested database edits pending in the live session and let the user handle saving them in Ghidra. - Never run a command that may delete files outside a temporary folder unless you first ask the user with `vscode_askQuestions` and get explicit confirmation. - If a request could remove or overwrite repository files, pause and confirm before proceeding. diff --git a/.github/skills/reverse-engineer-anything/SKILL.md b/.github/skills/reverse-engineer-anything/SKILL.md new file mode 100644 index 0000000..b464167 --- /dev/null +++ b/.github/skills/reverse-engineer-anything/SKILL.md @@ -0,0 +1,220 @@ +--- +name: reverse-engineer-anything +description: Reverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. +metadata: + version: "37" +--- + +# REA + +Use REA when a claim depends on a shipped binary or package, decompilation, +passive application runtime evidence, or comparison with +behavior not established by available source. For ordinary analysis of a +complete source repository, use normal repository tools and do not run REA +readiness or provider commands. + +## Connect only when needed + +Installing this skill supplies instructions; it does not register the REA MCP +server, install analysis engines, or add tools to an already-running agent. + +If REA tools are available and their registration is not known to be stale, +proceed directly to the target. Do not run diagnostics or setup before every +investigation. Use the connected server's actual tool list and input schemas; +a skill installed from repository main may describe capabilities absent from +an older npm release. Keep complete inline Evidence when that server does not +advertise retained references. + +If tools are absent, a call is blocked by the client, or a required provider is +unavailable, read [connection and recovery](references/connection-and-recovery.md). +Diagnose the observed blocker, continue useful supported work, and resume the +original task after repair. Client approval, shell PATH, registration and engine +availability have different remedies; avoid repeating setup for all of them. + +Prefer an existing `rea` CLI. When none is installed and REA package acquisition +is within the authorized scope, use `npx -y rea-agents@latest` in its place. +Configuration repair starts with a read-only setup plan; show paths, backups and +skill replacement before applying authorized changes. Preserve existing approval +and target-execution boundaries. REA setup never installs or upgrades unrelated +software, including Node.js, npm, Homebrew, Java, Ghidra, IDA, JADX, Binwalk or Unblob. + +## Route the target first + +Choose the first tool from the target the user supplied. Use `open_binary` for +active-target native or archive workflows; target-free tools take their own +explicit path or endpoint and do not need it. + +- ASAR or extracted JavaScript/Electron tree: + `analyze_javascript_application`. +- Archive/package member inventory (ZIP/APK/IPA/MSIX/AppX or DMG): + `open_binary` with the supplied local path; use `inspect_artifact` when its + graph and findings help answer the question. +- Android APK code, classes, methods, or incoming references: + `inspect_android_package`, then focused Android tools when advertised. + Archive member inventory still uses the archive route above. +- Managed PE/CLI assembly: `inspect_managed_artifact`. +- Firmware image: `inspect_firmware_regions` when advertised. Use + `extract_firmware` when extraction is requested, with a caller-selected new + absolute output directory. These tools use caller-supplied Binwalk/Unblob on + Linux; see the [firmware guide](https://github.com/morluto/rea/blob/main/docs/firmware-analysis.md). +- .NET NativeAOT PE/ELF: native Ghidra analysis. Native code can yield pseudocode; + consult the NativeAOT workflow in `references/native-and-artifacts.md` for + optional metadata recovery and its supported host/layout boundary. +- User-owned browser page already open: `list_browser_targets`. +- Retained HAR/native mitmproxy capture: `inspect_web_network_capture`. Select + original record ordinals when useful; inspect producer fields and byte/number + sidecars without fetching recorded URLs or claiming live attribution. See + [historical captures](https://github.com/morluto/rea/blob/main/docs/web-network-captures.md) for the exact upstream + profile and credential exclusions. +- User-owned Electron runtime already open: `list_electron_targets`. +- Explicit local EVM bytecode carrier: `inspect_evm_interface` with caller-selected + `raw` or `hex` encoding. Preserve carrier/decoded digests and treat selectors, + argument strings and mutability as inferred candidates; this performs no chain + lookup or target execution. See the + [EVM bytecode guide](https://github.com/morluto/rea/blob/main/docs/evm-bytecode.md). +- Explicit Linux ELF file for offline layout, symbols, relocations or static + mitigation evidence: `inspect_binary_layout`. This target-free operation uses + caller-supplied pwntools without opening a disassembler database. Preserve its + raw locations and inference/coverage limits; see the + [offline binary guide](https://github.com/morluto/rea/blob/main/docs/binary-diagnostics.md). +- Supplied Linux x86-64 ELF core: `inspect_recorded_crash`. Read every recorded + thread, raw note and source-bound register without opening a live target. + Historical PIDs do not select live processes. Request `include_debugger_context` + only when core-only mapping candidates help; see the + [recorded crash guide](https://github.com/morluto/rea/blob/main/docs/recorded-crashes.md). +- PE resource type/name/language trees and static icon group references: + `inspect_pe_resources` with an explicit path. This portable operation requires + no active target or engine; opaque payloads retain file ranges and SHA-256. +- Native executable, library, or analysis database: `open_binary`, then + use focused analysis tools directly; call `binary_overview` when metadata or + inventory context is useful and available from the selected provider. + +For an existing IDA MCP configuration, use `open_binary` with the original +input binary and `provider_id: "ida"`; do not pass an `.idb` or `.i64` database. +The legacy attached profile binds the already-open GUI input by SHA-256 and +leaves its database open. The modern headless profile creates and closes an +owned private database without saving. Installation and registration reuse +[mrexodia/ida-pro-mcp](https://github.com/mrexodia/ida-pro-mcp); see the +[IDA provider guide](https://github.com/morluto/rea/blob/main/docs/ida-provider.md). +Proceed directly to `analyze_function`, pseudocode, or function/string searches +after opening; IDA does not supply `binary_overview`. Consult session availability +when composing broader workflows. Modern direct callers and unsupported dossier +facets remain unknown; live IDA results are not replayed from snapshots. + +If the user says only "my app" without a name, path, or target already selected +for this task, ask which app before searching for artifacts. Paths in unrelated +saved reports and nearby test fixtures do not select the user's target. Resolve +an actual human-readable app name to one clear installed artifact when possible; +ask when matches are ambiguous. Never choose an example app on the user's behalf. + +In a target-free session, use `open_binary` to bind any archive/package or +native target whose analysis tool operates on the active target. Do not call an +unadvertised tool; inspect `binary_session` with `{}` and its +`result.tool_availability` for availability reasons and remediation. The tool +list stays complete; availability depends on the operation, target, and host. + +## Work summary-first + +Start with the default result and use its inline Evidence and graph context. +For a JavaScript application or ELF layout whose size is unknown or large, +call `analyze_javascript_application` or `inspect_binary_layout` with +`"detail": "summary"`, then inspect the retained `parent_evidence_id` with +`inspect_analysis_view`. +Page module identities and select the returned `node_id` before requesting an +item; a single file path can represent several graph roles. Do not repeat an +identical analysis or rejected call without a changed input or resolved blocker. +Recheck session state when a lifecycle change makes that status useful. +Make a focused follow-up only when the +returned result leaves a specific question unanswered. + +If MCP reports `resource_constraint` with `details.resource: "transport"`, call +`inspect_analysis_view` with its reported same-session Evidence reference for a +summary, one section/module, or a stable page. Use `trace_application_feature` +once a seed is known, or call `export_evidence_bundle` to write the complete +session to a selected path. The analysis remains complete in the ledger; avoid +repeating it merely to request the same oversized response. Complete CLI JSON +output also streams without a single MCP frame. + +When the retained parent ID is unknown, use `get_evidence_bundle` with +`detail: "summary"` and exact filters for operation, target SHA-256, +analysis-profile digest or canonical procedure address. Select its returned +Evidence ID for the next view instead of requesting the complete bundle. +`retention: "complete-record"` means the whole record is stored; native +value-flow truncation and unknown metadata remain separate. For an exported +portable bundle, use `rea inspect-evidence-bundle` with JSON containing `path`, +`detail: "summary"` and the same `filters`. Reading that file still requires +validating its full contents within the local memory budget. + +A client can also truncate a successful tool result without a REA transport +error. Treat that preview as incomplete; use the retained parent ID for smaller +views or export when the full record is needed. Do not parse the preview as +canonical JSON or repeat the producer. For JavaScript, read the +[module-view and trace recipes](references/javascript-applications.md) before +drilling into a large graph; a broad bidirectional trace can expand unrelated +containment relationships even after summary analysis. + +Every conclusion must distinguish observations, inferences, and unknowns. Cite +Evidence IDs, preserve limitations and incomplete coverage, and never imply +that static analysis observed execution. Runtime requests execute the declared +target and lifecycle; do not broaden the target or action beyond those fields. + +Within the user's requested investigation, call available analysis tools +directly. REA does not require permission grants or per-call approval flags. +The agent client can independently require approval. Follow the declared request +scope and the host's actual access requirements; use the recovery guide for an +observed client-policy rejection. + +## Plan broader investigations + +For requests that span multiple features or subsystems, use a staged workflow: + +1. Turn the request into a checklist of questions and the evidence each answer + needs. Resolve target identity and constraints from the conversation and + workspace before asking for information again. +2. Inspect the current REA session, artifact identity, saved analysis database, + bookmarks, and prior evidence. Reuse matching state; do not open duplicate + sessions or repeat identical analysis. +3. Start with the smallest useful overview or inventory. Follow each question + from its entry point through relevant data and state changes to its result. + Batch related operations around a specific hypothesis, then expand only when + the returned evidence leaves a concrete gap. +4. Inspect relevant packaged resources and configuration alongside code when + they affect the question. Use format-aware inventory and parsers; do not + infer behavior from filenames, strings, or layout alone. +5. Corroborate a conclusion with the evidence type it requires. Use runtime + observation only when static evidence cannot answer the question and the + required host runtime and OS access are available. For JavaScript behavior, + run probes against the actual app through the available browser, Electron, + or process capture workflow. +6. Decompose work into independent questions. When parallel workers are + available and the questions do not depend on one another, assign distinct + scopes, point workers to existing evidence, and ask them to return sources, + conclusions, and unresolved gaps. Otherwise, work sequentially. +7. Keep a concise finding ledger linking each conclusion to Evidence IDs, + confidence/evidence type, search boundary, and remaining unknowns. Update + the shared index or investigation report so later passes can reuse results. + +Before finishing, revisit the original checklist. Mark each question as +answered, partially answered, or unresolved based on its evidence; keep +bounded negative searches bounded, and do not describe a broad investigation +as complete while required questions remain open. + +## Read only the relevant guide + +- Native binaries, managed assemblies, archives, and extraction: + [references/native-and-artifacts.md](references/native-and-artifacts.md) +- ASARs, extracted JavaScript, feature tracing, and version comparison: + [references/javascript-applications.md](references/javascript-applications.md) +- Android APK declarations, classes, methods, and static references: + [references/android-applications.md](references/android-applications.md) +- Passive browser/Electron observation and static/runtime reconciliation: + [references/runtime-observation.md](references/runtime-observation.md) +- Evidence paging, comparisons, residual unknowns, and verification: + [references/evidence-workflows.md](references/evidence-workflows.md) + +## Finish the task + +Explain findings in plain language and tie them to returned evidence. When the +user asks to build something, use normal coding tools and separate observed +behavior from design choices. Close an opened native session with +`close_binary` when the investigation is complete. diff --git a/.github/skills/reverse-engineer-anything/references/android-applications.md b/.github/skills/reverse-engineer-anything/references/android-applications.md new file mode 100644 index 0000000..896f15f --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/android-applications.md @@ -0,0 +1,34 @@ +# Android application artifacts + +Use the connected server's advertised Android tools. Repository main and npm +4.1.0 include this family. A skill installation alone cannot add it to an +older server. + +Start with `inspect_android_package` on the caller's APK path for package +identity, manifest declarations, coverage, and inline Evidence. Use +`search_android_classes` to find candidates, `inspect_android_class` for one +class's members, `inspect_android_method` for decompilation, and +`trace_android_references` for incoming static references. Each call takes its +own APK path and explicit selectors; do not open a native session first. +Choose an `overload_index` from the class inventory when methods are ambiguous +instead of guessing. + +The provider requires a separately supplied headless JADX MCP JAR 0.7.1 and +Java 17 or newer. `REA_JADX_MCP_JAR` selects the absolute JAR path; `JAVA_HOME` +can select Java. REA setup does not install or configure that JAR, and doctor +provider scopes cover Hopper/Ghidra rather than JADX. Use existing tools and +report missing prerequisites for the Android task specifically. + +Linux and macOS use the POSIX owned-process boundary. Windows x64 requires the +matching bundled native controls and uses an owned Job Object with bidirectional +stdio. A full JDK, including `jdk.compiler`, is required on every host; Windows +`JAVA_HOME` selects `bin\java.exe`. Consult the Android guide for actual host +verification coverage. Calls use one worker and provider deadlines; optional +`REA_JADX_HEAP_MIB` selects the JVM heap. The APK is never launched, +and no emulator is required. + +Manifest entries and decompiled text are static observations, not execution or +policy enforcement. Incoming references are recovered static relationships; +reflection, dynamic loading, and unresolved calls remain unknown. Preserve +artifact digests, locations, diagnostics, and incomplete coverage. For archive +members rather than code analysis, use `open_binary` and `inspect_artifact`. diff --git a/.github/skills/reverse-engineer-anything/references/connection-and-recovery.md b/.github/skills/reverse-engineer-anything/references/connection-and-recovery.md new file mode 100644 index 0000000..5e5f625 --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/connection-and-recovery.md @@ -0,0 +1,127 @@ +# Connection and task recovery + +Read this guide only for an observed connection, command, approval or provider +blocker. Keep the user's target and question in view. Explain what prevented the +operation and the next useful step; after repair, continue the investigation. + +Commands below use an installed `rea`. If none is available, use the package +invocation in `SKILL.md` when acquiring REA is authorized. Follow the connected +server's schemas and the installed CLI's help rather than assuming repository +main and an older release expose the same arguments. + +## Choose the remedy from the observed failure + +| Observation | Meaning and next step | +| --------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| No REA tools in the active session | Inspect registration with `rea doctor --client codex --json`. A skill installation alone does not register MCP. | +| Missing, malformed or stale registration | Prepare a scoped setup plan; apply only authorized changes with backups. | +| Aligned registration, but no connected tools | Restart/reconnect the client. Doctor checks registration; it cannot establish the current agent's connection. Inspect the client's launch error if reconnection fails. | +| `MCP tool call requires approval, but approval policy is never` | Codex rejected the call before REA executed it. Do not install an engine or repeat setup to solve this client-policy decision. See the approval section below. | +| REA returns `provider_unavailable` or an unavailable tool entry | Read that operation's provider diagnostics or `binary_session.result.tool_availability`. Resolve only the prerequisite needed for the task; a complete tool catalog does not imply every operation is available. | +| `rea` is missing in a child shell, or Node is incompatible | Inspect the actual shell PATH and launcher/runtime. A prefix installation may be absent from a login shell's PATH; this does not establish a broken MCP registration. | + +If the client cannot launch its shell/sandbox helper or read the installed skill, +inspect its launch diagnostic. For example, Codex can refuse helper aliases when +CODEX_HOME is under `/tmp`; use an authorized profile outside the OS temporary +directory. REA setup cannot repair the client's executor. Preserve the sandbox +instead of silently disabling it to make an analysis command work. + +Static JavaScript and ordinary ZIP inventory need neither Hopper nor Ghidra. +HAR inspection is offline and does not require a live browser. Native +decompilation, Android analysis and firmware extraction have their own +bring-your-own prerequisites. Use supported inventory/static evidence when it +answers part of the question, and name the unavailable evidence separately. +Do not substitute another target. Label observations from ordinary shell tools +as such; only actual REA output supplies REA Evidence. + +## Repair registration when needed + +For Codex: + +```bash +rea doctor --client codex --json +rea setup --client codex --dry-run --json +``` + +Use the current supported client's ID: `claude_code`, `claude_desktop`, `codex`, +`cursor`, `gemini_cli`, `windsurf`, `devin`, `opencode`, `antigravity`, +`copilot_cli`, `commandcode`, `qwen_code`, `vscode`, `grok_build`, `omp`, `pi`, +`hermes`, or `grok_bot`. If unknown, inspect `doctor --json` before choosing a +scope. `grok_bot` uses a chat registration step rather than local `mcp.json`. +For unsupported clients, use version-pinned manual stdio registration or CLI. + +Show the plan's exact paths, backups, changes and bundled-skill replacement. +Obtain approval for writes when that concrete scope is not already authorized, +then apply the same scope with `rea setup --client codex --yes`. Add +`--install-hopper` only when separately needed and explicitly approved. Do not +install or upgrade unrelated prerequisites. Restart/reconnect, verify tools +actually appear, and resume the original task. If they remain absent, inspect +the launch failure rather than looping through setup. + +## Codex tool approval is separate from REA readiness + +REA tools have no permission-grant handshake. Codex can still require approval +because an operation creates owned resources, launches a helper or has cleanup +effects. An advertised tool or successful doctor result does not override that +client policy. `workspace-write` alone does not resolve an MCP approval +rejection, and `approval_policy = "never"` does not mean every MCP tool is +preapproved. + +When interactive approval is available, use the client's approval flow for the +requested operation. In an unattended run, continue through an authorized CLI +workflow if the execution environment permits it, or report the blocked +operation and the approval needed to proceed. Do not retry the same rejected +call, silently broaden approvals, or rewrite MCP effects as read-only. + +For an operator who explicitly wants to preapprove named operations in a +disposable Codex profile, current Codex supports per-tool configuration. For +example, opening and closing an analysis session can be scoped independently: + +```toml +[mcp_servers.rea.tools.open_binary] +approval_mode = "approve" + +[mcp_servers.rea.tools.close_binary] +approval_mode = "approve" +``` + +Use the actual server ID and only the operations whose effects were approved; +this example does not approve inspection, extraction or runtime execution. +Show the proposed config edit and preserve unrelated entries and backups before +writing. Managed policy can constrain client settings. Consult the +[Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference) +for the installed client's supported settings. This is an optional recovery +choice, not a prerequisite for every REA task. + +## Continue through an installed CLI + +Check the command environment only if the launcher fails: + +```bash +command -v rea +command -v node +node --version +rea --version +``` + +Use the public launcher at its known installation path with a supported existing +Node on PATH when the child shell loses a prefix installation. Avoid internal +`dist/cli.js` entrypoints or global toolchain changes. MCP may have its own valid +launcher even when a shell cannot resolve `rea`. + +For a user-supplied JavaScript tree or ASAR, select output files in the authorized +workspace and save complete Evidence before reading a view: + +```bash +rea analyze-javascript-application /absolute/path/to/app --json > app-evidence.json +jq -c '{source: {kind: "inline", evidence: .}, view: {kind: "summary"}}' app-evidence.json > app-view.json +rea inspect-analysis-view app-view.json +``` + +These commands do not register MCP or install an analysis engine. CLI JavaScript +JSON is complete and can be very large; redirect it rather than loading it into +context. Use an existing JSON processor if `jq` is absent, without installing +one just for this recipe. Inspect a module page or item using the same inline +source and the [JavaScript recipes](javascript-applications.md). Preserve graph +coverage, limitations and unknowns. Native CLI analysis still requires its +selected engine, and all CLI operations retain the host's execution permissions. diff --git a/.github/skills/reverse-engineer-anything/references/evidence-workflows.md b/.github/skills/reverse-engineer-anything/references/evidence-workflows.md new file mode 100644 index 0000000..97e873a --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/evidence-workflows.md @@ -0,0 +1,48 @@ +# Evidence, comparison, and verification workflows + +Evidence-producing tools return the complete Evidence record directly in MCP +`structuredContent` and CLI JSON. Read `normalized_result` for operation data, +and cite `evidence_id` when another tool or your explanation needs a stable +reference. Preserve authority, limitations, coverage, and residual unknowns. If a result +is incomplete or paginated, continue only when the remaining data matters to +the task; do not fetch a bundle or resource merely to read a result already +returned inline. When complete `inspect_binary_layout` or +`analyze_javascript_application` Evidence is already retained, call +`inspect_analysis_view` for a summary, one section/symbol/module, or a stable +page instead of repeating the producer. + +Use `record_unknown` to track unresolved questions in the user's investigation +and name the authority or environment still required. Supply supporting and +contradicting evidence IDs. It updates the session registry directly. +Use `update_unknown` with the current revision; reread after a stale revision +instead of retrying blindly. Only qualifying observed evidence can verify a +resolution. + +Use comparisons with complete, compatible page sets when claiming equivalence +or absence: + +- `compare_artifacts` compares inventory pages by occurrence path, content, + metadata, and graph relations. +- `compare_functions` compares explicit function Evidence, not fuzzy + whole-binary matches. +- `compare_bundles` compares canonical bundle membership and unknown history. +- `find_changed_behavior` combines existing comparisons; static differences + remain candidates, not causal proof. +- `build_call_path` needs explicit function dossiers from one artifact/provider; + an incomplete frontier makes absence unknown. +- `correlate_static_and_runtime` uses explicit mappings; matching patterns are + hypotheses, not causality. +- `verify_reconstruction` evaluates a finite typed specification. A pass covers + only declared comparable claims, not global equivalence. + +Process captures are opt-in behavioral evidence, not a security sandbox. V3 +captures cannot be upgraded to V4; rerun the original scenario. Distinguish root +exit from descendant settlement and require freshness when the task needs it. +A timed-out target that must write a final report needs `finalization_ms`: REA +sends SIGTERM to the captured root, keeps observing, and sends SIGKILL once +only if the target has not exited by the end of the interval. +`exit.finalization.signals` lists each attempt with its delivery result; the +observed exit signal stays in `exit.signal`, `exit.code` is null for every +deadline exit, and the code of a finalizer that exited on its own is in +`exit.finalization.exit_code` (null on a signal exit or when no exit was +observed). diff --git a/.github/skills/reverse-engineer-anything/references/javascript-applications.md b/.github/skills/reverse-engineer-anything/references/javascript-applications.md new file mode 100644 index 0000000..4d4a1fe --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/javascript-applications.md @@ -0,0 +1,149 @@ +# JavaScript and Electron application artifacts + +Use `analyze_javascript_application` directly on the operator-supplied ASAR or +extracted tree. When size is unknown or large and the connected schema advertises +`detail`, request `detail: "summary"`. This returns an `inspect_analysis_view` +Evidence record with a distinct ID and a `normalized_result.parent_evidence_id` +for the complete retained application analysis. Source-map contents are part of +that static analysis. Read findings, coverage, limitations and unknowns, then +follow a specific unanswered question. Older servers without `detail` return +the complete application Evidence inline when it fits. + +When the connected schema advertises `max_heap_mb` and `analysis_timeout_ms`, +these select the isolated source analyzer's old-space heap and per-source +deadline. Defaults are 1024 MiB and 300000 ms. They do not change the MCP +process heap. Resource-limited analyses preserve completed static facts and +report partial semantic coverage with specific unknown scopes; this does not +mean the source is malformed. Inspect those limits before retrying a source. +When expanded relationships exceed the parent's available memory, inspect the +file's modules item view for retained `static_analysis` and +`semantic_module_analysis`. Their facts remain available even when graph links +are unknown. Cumulative result exhaustion can stop analysis before every file +is examined; the inventory and remaining unknown scopes distinguish that case. +Timeout or cancellation after source analysis begins retains partial Evidence +in the same session. A returned `error.details.partial_observation` reference +can be supplied directly to `inspect_analysis_view`. If the SDK cancels locally, retrieve its recorded ID from +the Evidence bundle before inspecting the partial analysis. + +## Read a module without repeating analysis + +Use the actual returned parent ID, on the same connection, as `source.evidence_id`. +The following IDs are placeholders to replace with returned values. When the +module's node ID is not already known, page identities before selecting an item. +Pages return only node IDs, paths and roles; choose a useful page size and follow +`coverage.next_offset` when another page matters: + +```json +{ + "source": { + "kind": "retained-evidence", + "evidence_id": "ev_ACTUAL_PARENT_ID" + }, + "view": { "kind": "page", "collection": "modules", "offset": 0, "limit": 16 } +} +``` + +Select the relevant page entry by its exact `node_id` and recorded role: + +```json +{ + "source": { + "kind": "retained-evidence", + "evidence_id": "ev_ACTUAL_PARENT_ID" + }, + "view": { + "kind": "item", + "collection": "modules", + "selector": { "node_id": "jag_node_ACTUAL_NODE_ID" } + } +} +``` + +Module pages include asset, bundled and source module roles, so one path can +identify several entries. Use `selector.path` only when uniqueness is established; +the returned node ID avoids needing a complete inventory to prove uniqueness. On ambiguity, +select the matching node ID from the page or the error's candidates. Follow +`next_offset` when another page matters. An item exposes that module node's +recorded observations, identity, hashes, exports and source ranges; it does not +include every child syntax observation, related edge or original source file. +An absent item fact is not evidence of absence from the whole application. + +## Trace only the remaining question + +Use `trace_application_feature` on the parent application Evidence for one +literal node ID, route, string, API, IPC channel, module, or native export. +Select `incoming` for relationships leading to the seed, `outgoing` for those +leaving it, and `both` when the question needs both. Trace traversal includes +containment relationships, so even a narrow seed can expand many nodes; a +bidirectional trace can reach unrelated sibling modules. A module item or page +is preferable when its observations already answer the question. Do not treat +all reached nodes as participants in the feature. + +Reuse retained parent Evidence when the server advertises it, or supply complete +Evidence inline. Include Hopper or Ghidra Evidence only when its artifact digest +matches exactly. + +## Recover an oversized display + +An oversized response reports `resource_constraint` and +`details.resource: "transport"`. Reuse +`details.reported_limits.evidence_reference` with `inspect_analysis_view` for a +summary, one module, or a stable page of module identities. +`export_evidence_bundle` writes the complete canonical session to a +caller-selected file. These workflows keep the original Evidence and coverage; +a broad follow-up can also exceed framing. + +A client can truncate a successful result inside its text envelope without a +REA `resource_constraint`. Treat a truncation notice or incomplete JSON as a +display limitation; do not claim the full record was examined. Reuse the known +parent ID for smaller views, or export complete Evidence to a selected file +while the session remains open. If the parent ID was lost from the preview, +use the prior analysis summary or explicit ledger entries to recover it; do +not invent an ID or rerun analysis just to reproduce the same display. + +BrowserWindow preferences, preload and contextBridge surfaces, IPC +registrations, utility processes, and native binding requests are static syntax +observations. Only a unique exact literal IPC channel match supports an inferred +pairing. Dynamic or ambiguous channels remain unresolved. A requested `.node` +member is not a verified native export. Never claim runtime reachability, +registration, defaults, or policy enforcement from static analysis. + +For version comparison, analyze each version once, then call +`compare_application_versions`. Accept only its digest, source-map, structural +fingerprint, or non-module semantic matches. Module ordinals and minified names +are not persistent identity. Report added or removed only with complete +opposite-side coverage; otherwise report unknown. + +When the question asks how one exact exported callable's returned object shape +changed, analyze each version once and then call +`compare_javascript_export_shapes` with explicit module paths and export names. +Use the returned IDs on the same connection, or complete inline Evidence +records, from both analysis calls. Accept variant +pairing only through the tool's unique exact literal discriminant. Read +`property_inventories` and each change's `presence` before treating `unknown` as +"the name was not observed": inventories list observed property names even when +values stay unknown, with a `source_range` for each paired or unpaired variant. +Array holes and mutation-invalidated slots are not observed properties. +Complete parent coverage reports presence-only +`added`/`removed` independently of unresolved values. Cite the +comparison Evidence and report JSON Pointer changes; dynamic values, ambiguous +variants, and incomplete parent-property coverage stay unknown. This is static +inference, not runtime behavior. When runtime semantics are needed, run +behavioral probes against the relevant application versions and capture them +through the available browser, Electron, or process workflows. + +## Reusing application Evidence + +When advertised by the connected server, application trace and compare tools +accept complete inline Evidence or +`{"kind":"retained-evidence","evidence_id":"ev_<64 lowercase hex characters>"}` +for their application input (`application`, or `left`/`right`). `inspect_analysis_view` +uses the same retained-reference form in `source`, or portable inline Evidence, +to project a summary, module page, or one module with its recorded observations. This notation is +a template: replace it with the actual returned ID. Versions before 4.1.0 accept only full +inline Evidence. Use the exact ID +returned by the producer on the same MCP connection. Resolution does not run +analysis or select a provider; findings remain inline. Native observation +arrays still take full Evidence. `close_binary` clears retained references; +export a bundle before closing, or supply portable inline Evidence in another +connection. A missing reference includes its ID and recovery guidance. diff --git a/.github/skills/reverse-engineer-anything/references/native-and-artifacts.md b/.github/skills/reverse-engineer-anything/references/native-and-artifacts.md new file mode 100644 index 0000000..0a28106 --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/native-and-artifacts.md @@ -0,0 +1,167 @@ +# Native, managed, and packaged artifacts + +## Recorded Linux crashes + +Use `inspect_recorded_crash` with an explicit Linux x86-64 ELF core path to +inspect historical thread registers, signals, raw notes and original file +ranges. It is independent of the active disassembler target. Source-bound +register values and note bytes are observations; missing notes, signal-thread +association and current executable/library identity remain unknown. PIDs are +historical metadata and never authorize live attach or control. + +The optional `include_debugger_context` facet adds mapping candidates through +caller-supplied GDB/pwndbg in an owned core-only session. Display names do not +establish current file identity; zero reported flags leave permissions unknown. +Requested unavailable context fails with setup guidance. See +[recorded crashes](https://github.com/morluto/rea/blob/main/docs/recorded-crashes.md) +for exact upstream profiles, bounds and verification coverage. + +## Offline ELF layout + +Use `inspect_binary_layout` with an explicit local ELF path for file-backed +sections, symbols, relocations, linkage names, and static mitigation inferences +without opening a disassembler target. When that complete record is already +retained, call `inspect_analysis_view` for a summary, mitigations or linkage +facet, one section or symbol, or a stable page. Do not re-run the decoder to +read a single object. + +## Native targets + +After `open_binary`, use focused search, procedure, or function tools directly. +Use `binary_overview` when target metadata or inventory context helps answer the +question. Prefer literal search, names, decompilation, callers, callees, and +cross-references. Addresses and recovered pseudocode are analysis observations, +not original source. Provider unavailability and unsupported metadata remain +unknown rather than false. + +For a completed `analyze_function` dossier, use `inspect_analysis_view` with +`view: {kind: "native", facet: "value_flow_operations", offset: 0, limit: 32}` +and the exact retained Evidence ID to read selected facts without reanalysis. +Native facets also include procedure, pseudocode, assembly, basic blocks, +comments, callers/callees, references, unresolved calls, referenced strings and +names, the native API record, and value-flow summaries. Pseudocode offsets and limits count UTF-16 +code units; use the returned `next_offset` for continuation. Provider limitations +and unavailable facts remain explicit; the complete parent Evidence is retained. + +To see which functions or Objective-C methods a Mach-O actually calls in one +run, use `observe_native_calls` with explicit breakpoints and a bounded +`duration_ms`/`max_events`. It launches a new process under LLDB, so the target +runs and may change files or use the network. Hardened-runtime targets need the +`get-task-allow` entitlement. + +Use `binary_session` with no arguments to check the open target, selected +provider, and alignment. Its default `result.tool_availability` includes the +complete tool inventory with availability reasons and remediation. When choosing +a tool, use its entry in that result; `tools/list` retains the complete catalog +when the target or provider state changes. + +## DOS MZ with Ghidra + +For an admitted DOS MZ target, use `inspect_native_load_image` to check measured +loaded bytes, file mappings, relocations and the entry against the immutable +snapshot. Keep `mismatch` and `unsupported` explicit. Verified import covers the +reported static image, not runtime DOS or PC-98 hardware behavior. + +Use `read_bytes` for initialized analysis memory and `address_to_file_offset` to +anchor one observed address to original file bytes. Loader fixups can change a +word; a source offset does not imply byte equality. Complete function body ranges +use inclusive ends and can contain gaps. Do not treat the enclosing span as code. +For packed targets, retain the original and separately derived artifact identities; +decompiling an unpacking stub does not recover the unpacked program. + +When reading Objective-C dispatch metadata, distinguish class implementation +methods from protocol requirements: class methods report null requirement +flags, while decoded protocol declarations retain required and optional facts. +Property attributes remain raw name/value tokens; use the property's +`atomicity` field for the decoded `N` marker or the default atomic behavior. +Null class/meta flags, ivar counts, atomicity, or read-only values mean the +selected provider did not establish that fact. Symbol names alone do not prove +that a class is a root class or has no ivars. + +## Managed PE/CLI + +Start with `inspect_managed_artifact`. REA's canonical managed inspection is +execution-free: do not claim it loaded, reflected, executed, or resolved the +assembly. Keep managed/native boundaries and unavailable reconstruction facts +explicit. A bring-your-own reconstruction oracle is separate from the canonical +parser and must not become an implicit setup dependency. + +### .NET NativeAOT + +NativeAOT binaries contain native machine code, so ordinary CIL decompilers +cannot recover the original method bodies. When managed metadata/CIL is absent, +classify that as a native-analysis route rather than claiming source recovery. +Open the native image with the selected deep provider and inspect functions, +strings, calls, and references; describe decompiler output as pseudocode and +inference. + +NativeAOT images can be PE/COFF, ELF, or Mach-O executables and shared +libraries. Use file bytes and loader metadata rather than suffixes to identify +them. For packaged apps, inventory/extract with REA's artifact tools and retain +the exact contained image identity. PDB, ELF debug, or dSYM sidecars are +additional evidence only when the provider accepts and matches them. + +For deeper type recovery, the optional third-party +[Ghidra NativeAOT analyzer](https://github.com/Washi1337/ghidra-nativeaot) +rehydrates ReadyToRun metadata and can recover method tables, type relationships, +frozen objects, and strings. This is a Ghidra extension with its own install and +interactive workflow; it is not currently part of REA's managed parser or +headless Ghidra bridge. Treat its annotations as analysis evidence, retain the +binary identity, and do not present recovered types as original source. Header +discovery may require a symbol or analyst identification of the ReadyToRun +header, depending on the binary and analyzer version. + +## Packages and extraction + +Use `inspect_artifact` for application bundles, archives, ZIP/APK/IPA/MSIX/AppX, +ASAR, or DMG inputs when the artifact graph and findings help answer the +question. It returns the complete artifact graph inline. Cite graph manifest +IDs when using them. + +For an IPA or a macOS `.app`, ZIP, or DMG, pass the inventory Evidence to +`project_apple_application_graph`. It reports application roots and nested +bundles by path convention: app extensions, XPC services, frameworks, login +items, system and driver extensions, and plug-ins. It also lists privileged +helpers, launchd plists, symlinks, and each bundle's `info_plist_path` and +executable candidates. Roles are path conventions, not parsed plists; read the +listed plists with `inspect_plist`. + +After `open_binary` on a `.app` or Mach-O, use `trace_dylib_resolution` to see +which file each `@rpath`, `@loader_path` and `@executable_path` load reaches for +every executable in the bundle. It also lists missing or weak loads and earlier +`@rpath` candidates that are absent. Narrow large bundles with `roots` or +`architecture`. System paths stay undetermined because the dyld shared cache +provides them. + +Use `extract_artifact` when materialized files are needed. It takes no arguments +and materializes all regular files into a fresh temporary directory chosen by +REA. Symlinks and encrypted entries are inventory facts, not extractable files. +The result reports the materialized directory; callers do not choose the +destination. No separate permission grant is needed. + +Native DMG traversal automatically uses a read-only mount on supported macOS +hosts, with an owned temporary mount directory and cleanup. It needs no approval +flag. Unsupported hosts or mount failures remain explicit limitations; do not +claim child inventory when only root identity is available. Extraction is a +separate filesystem-writing operation. + +For headerless DOS COM, explicitly open with `format: "dos-com"` (CLI +`--target-format dos-com`). Inspect the load image before trusting function +analysis: the entry is `0x10100`, file offset zero, with imposed real-mode segment +context. PSP/stack/device state remains unmodeled. See [DOS guide](https://github.com/morluto/rea/blob/main/docs/ghidra-dos.md). + +### Function annotations in Ghidra + +Use `annotate_native_function` for one function name and/or entry comments, with at least one explicit change. Review its annotation readback and refreshed dossier inline. Changes are atomic and session-scoped; empty comments clear them, omitted fields preserve them. Later MCP calls observe edits until close. CLI `annotate-native-function` returns the updated analysis before discarding the session. Original executable bytes are unchanged; edits invalidate immutable snapshots. Windows P0 does not admit database mutations. For naming only, `set_address_name` / `set_addresses_names` also work with Ghidra: they name function entries or data addresses (primary labels) and return compact per-address success booleans instead of a dossier. + +## Offline PE resource inventory + +Use `inspect_pe_resources` with an absolute `path`, or +`rea inspect-pe-resources ./selected.exe --json`, for portable PE32/PE32+ +resource inspection without opening a native target. Preserve returned Evidence: +type/name/language IDs and UTF-16 names, original directory/data/payload ranges, +code pages, payload hashes and static icon-group references. Same-language icon +resolution is explicit; missing references and size mismatch remain visible. +Other payloads are opaque, and this operation does not decode images or simulate +Windows resource loading. Consult the budgets and supported tree profile in +[offline binary diagnostics](https://github.com/morluto/rea/blob/main/docs/binary-diagnostics.md). diff --git a/.github/skills/reverse-engineer-anything/references/runtime-observation.md b/.github/skills/reverse-engineer-anything/references/runtime-observation.md new file mode 100644 index 0000000..3e16a3e --- /dev/null +++ b/.github/skills/reverse-engineer-anything/references/runtime-observation.md @@ -0,0 +1,28 @@ +# Passive browser and Electron observation + +Supply the existing browser or Electron instance's literal-port loopback CDP +endpoint in the request. No separate permission configuration or per-call +approval flag is needed. Browser discovery lists eligible HTTP(S) pages; +`allowed_origins` optionally filters them. An individual capture defaults to the +selected page's current origin. Electron discovery lists eligible local +`file://` targets without a configured file-root allowlist. + +Start browser work with `list_browser_targets`; start Electron runtime work with +`list_electron_targets`. Inspect the target selected for the user's task. Observation +is passive: never claim REA clicked, navigated, evaluated page JavaScript, +invoked IPC, captured prior activity, or contained the page's network. + +Credentials, cookies, authorization headers, storage values, and raw +WebSocket/JSON bodies are deliberately absent. Local URLs retain ordinary query +values and fragments; userinfo credentials are removed. Browser accessibility +text, console primitives, value-free shapes, script sources, source maps, and +storage key names have request-specific capture options. Electron script +sources are also optional. Use `capture_web_screenshot` when pixels are needed. +Treat scope filtering, truncation, and attach-window coverage as limitations. +Page-declared WebMCP tools are untrusted inventory and are never invoked by REA. + +Use `reconcile_javascript_runtime` only after static application Evidence and +passive browser/Electron Evidence exist. Prefer captured-source digest identity; +report path/digest disagreement as a mismatch and preserve ambiguity. Explicit +path mappings are inference inputs and never broaden filesystem or CDP authority. +A bundle observed at runtime does not prove every contained module executed. diff --git a/.gitignore b/.gitignore index d1c86ac..689b055 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ rebuild/**/imported/** **/dist/** **/.vite/** *.log +JP/** \ No newline at end of file diff --git a/Crusader.rep/idata/00/~0000000e.db/db.11.gbf b/Crusader.rep/idata/00/~0000000e.db/db.44.gbf similarity index 86% rename from Crusader.rep/idata/00/~0000000e.db/db.11.gbf rename to Crusader.rep/idata/00/~0000000e.db/db.44.gbf index 3c1612c..b6a726c 100644 Binary files a/Crusader.rep/idata/00/~0000000e.db/db.11.gbf and b/Crusader.rep/idata/00/~0000000e.db/db.44.gbf differ diff --git a/Crusader.rep/idata/00/~0000000e.db/db.10.gbf b/Crusader.rep/idata/00/~0000000e.db/db.45.gbf similarity index 86% rename from Crusader.rep/idata/00/~0000000e.db/db.10.gbf rename to Crusader.rep/idata/00/~0000000e.db/db.45.gbf index e71f38e..66f4f7e 100644 Binary files a/Crusader.rep/idata/00/~0000000e.db/db.10.gbf and b/Crusader.rep/idata/00/~0000000e.db/db.45.gbf differ diff --git a/Crusader.rep/idata/00/~0000000e.db/tmp8053461288306487346.ps b/Crusader.rep/idata/00/~0000000e.db/tmp8053461288306487346.ps new file mode 100644 index 0000000..e554759 Binary files /dev/null and b/Crusader.rep/idata/00/~0000000e.db/tmp8053461288306487346.ps differ diff --git a/Crusader.rep/idata/01/~00000015.db/change.data.gbf b/Crusader.rep/idata/01/~00000015.db/change.data.gbf index 1cf95a6..7777952 100644 Binary files a/Crusader.rep/idata/01/~00000015.db/change.data.gbf and b/Crusader.rep/idata/01/~00000015.db/change.data.gbf differ diff --git a/Crusader.rep/idata/01/~00000015.db/change.map.gbf b/Crusader.rep/idata/01/~00000015.db/change.map.gbf index 73cce28..64fe25f 100644 Binary files a/Crusader.rep/idata/01/~00000015.db/change.map.gbf and b/Crusader.rep/idata/01/~00000015.db/change.map.gbf differ diff --git a/Crusader.rep/idata/01/~00000015.db/db.138.gbf b/Crusader.rep/idata/01/~00000015.db/db.155.gbf similarity index 94% rename from Crusader.rep/idata/01/~00000015.db/db.138.gbf rename to Crusader.rep/idata/01/~00000015.db/db.155.gbf index 0f6497d..157b742 100644 Binary files a/Crusader.rep/idata/01/~00000015.db/db.138.gbf and b/Crusader.rep/idata/01/~00000015.db/db.155.gbf differ diff --git a/Crusader.rep/idata/01/~00000015.db/db.137.gbf b/Crusader.rep/idata/01/~00000015.db/db.156.gbf similarity index 94% rename from Crusader.rep/idata/01/~00000015.db/db.137.gbf rename to Crusader.rep/idata/01/~00000015.db/db.156.gbf index a2498e7..ec062c8 100644 Binary files a/Crusader.rep/idata/01/~00000015.db/db.137.gbf and b/Crusader.rep/idata/01/~00000015.db/db.156.gbf differ diff --git a/Crusader.rep/projectState b/Crusader.rep/projectState index 6244408..855ae5a 100644 --- a/Crusader.rep/projectState +++ b/Crusader.rep/projectState @@ -9,7 +9,314 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/Crusader.rep/user/00/~00000008.db/db.72.gbf b/Crusader.rep/user/00/~00000008.db/db.78.gbf similarity index 99% rename from Crusader.rep/user/00/~00000008.db/db.72.gbf rename to Crusader.rep/user/00/~00000008.db/db.78.gbf index 817670c..04d57ab 100644 Binary files a/Crusader.rep/user/00/~00000008.db/db.72.gbf and b/Crusader.rep/user/00/~00000008.db/db.78.gbf differ diff --git a/Crusader.rep/user/00/~00000008.db/db.73.gbf b/Crusader.rep/user/00/~00000008.db/db.79.gbf similarity index 99% rename from Crusader.rep/user/00/~00000008.db/db.73.gbf rename to Crusader.rep/user/00/~00000008.db/db.79.gbf index 8248d8c..6b0ca92 100644 Binary files a/Crusader.rep/user/00/~00000008.db/db.73.gbf and b/Crusader.rep/user/00/~00000008.db/db.79.gbf differ diff --git a/Crusader.rep/user/00/~0000000c.db/db.15.gbf b/Crusader.rep/user/00/~0000000c.db/db.15.gbf new file mode 100644 index 0000000..89c6168 Binary files /dev/null and b/Crusader.rep/user/00/~0000000c.db/db.15.gbf differ diff --git a/Crusader.rep/user/00/~0000000c.db/db.7.gbf b/Crusader.rep/user/00/~0000000c.db/db.16.gbf similarity index 54% rename from Crusader.rep/user/00/~0000000c.db/db.7.gbf rename to Crusader.rep/user/00/~0000000c.db/db.16.gbf index d355125..2673597 100644 Binary files a/Crusader.rep/user/00/~0000000c.db/db.7.gbf and b/Crusader.rep/user/00/~0000000c.db/db.16.gbf differ diff --git a/Crusader.rep/user/00/~0000000c.db/db.8.gbf b/Crusader.rep/user/00/~0000000c.db/tmp3020596019393564293.ps similarity index 54% rename from Crusader.rep/user/00/~0000000c.db/db.8.gbf rename to Crusader.rep/user/00/~0000000c.db/tmp3020596019393564293.ps index 6a2e48a..8f46f01 100644 Binary files a/Crusader.rep/user/00/~0000000c.db/db.8.gbf and b/Crusader.rep/user/00/~0000000c.db/tmp3020596019393564293.ps differ diff --git a/Crusader_Decomp.code-workspace b/Crusader_Decomp.code-workspace index 69a37ec..129dced 100644 --- a/Crusader_Decomp.code-workspace +++ b/Crusader_Decomp.code-workspace @@ -10,10 +10,16 @@ "path": "../Crusader-vscode" }, { - "path": "../GhidraMCP" + "path": "../crusader_map_viewer" }, { - "path": "../crusader_map_viewer" + "path": "../../mcp/GhidraMCP" + }, + { + "path": "C:/RE/CRUSADER_JP_ISO" + }, + { + "path": "G:/games/Crusader No Remorse" } ], "settings": { diff --git a/JP/CRUSADER.EXE b/JP/CRUSADER.EXE new file mode 100644 index 0000000..cd7d373 Binary files /dev/null and b/JP/CRUSADER.EXE differ diff --git a/crusader_segment_coverage_ledger.csv b/crusader_segment_coverage_ledger.csv index 1fa776e..daba4d8 100644 --- a/crusader_segment_coverage_ledger.csv +++ b/crusader_segment_coverage_ledger.csv @@ -1,15 +1,15 @@ "Segment","Type","FileOffset","Length","CoverageStatus","KnownSubsystem","KeyNamedFunctions","Blockers","NotesSource" "1","code","0x37600","0x8400","Deep","Gameplay cursor/input/projectiles","cursor_update_hover; entity_fire_weapon; projectile_update_tick","Broader gameplay subsystem still spans adjacent segments","crusader_decompilation_notes.md; plan-mid.md" -"2","code","0x40000","0x2B0","None","","","","crusader_ne_segments.csv" -"3","code","0x40400","0x55A","None","","","","crusader_ne_segments.csv" -"4","code","0x40A00","0x10B1","Foothold","Reset/cache entry path","runtime_cache_reset_sequence","ASYLUM.24 and downstream reset callers still need tighter classification","crusader_decompilation_notes.md; plan-mid.md" +"2","code","0x40000","0x2B0","Partial","Resource image records, viewport row loading, and palette conversion","resource_image_record_allocate_and_load_1008_0032; resource_image_record_open_and_read_1008_0098; resource_image_read_rows_into_vport_1008_0167; resource_palette_rgb_to_vga6_1008_01eb; resource_palette_triplet_alloc_callback_1008_028c","All five functions in this short segment are identified; the complete resource-record schema and broader file-loader ownership remain partially characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"3","code","0x40400","0x55A","Partial","Tile area search and solid/damage overlap","AreaSearch_FindItemAtWorldPosition_1010_0032; AreaSearch_FindItemAtTilePosition_1010_0061; AreaSearch_FindItemInTileRect_1010_007d; Item_CheckSolidDamageOverlap_1010_02de","The four documented helpers have no exact auto-names remaining; broader area-search and overlap call paths are not fully characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"4","code","0x40A00","0x10B1","Partial","Configuration file loading and option persistence","LoadConfigFile; SaveOptionsToConfigFile","Loader validation and malformed/unknown-option behavior remain incompletely characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" "5","code","0x41E00","0x8D7","Partial","Startup/display transition prepare/driver lane","startup_display_transition_prepare; startup_display_transition_driver","The two main seg005 bodies are now named and tied to caller-side validation through vtable +0x0c, the seg108 0x4f38 sprite/object helper lane, the shared active-dispatch hold byte at 0x6828, the seg049 watch/controller lane at 0x2bd8, and the seg126 follow-up path; the exact higher-level state label is still unresolved","crusader_decompilation_notes.md; plan-mid.md" -"6","code","0x42C00","0x75E","Foothold","Gameplay-side masked materializer and local state/value selector lane","entity_vm_context_try_create_mask_0008_slot30_with_offset; entity_vm_context_try_create_mask_0010_slot08_with_offset_if_ready","Outer callers for the renamed seg006 helpers are still unresolved, and the higher-level gameplay subsystem owning the local state-selector and adjacent class-linked value family still needs caller-side recovery","plan-mid.md; docs/raw-0008-000c.md" -"7","code","0x43600","0x484","None","","","","crusader_ne_segments.csv" -"8","code","0x43C00","0x1386","None","","","","crusader_ne_segments.csv" -"9","code","0x45400","0x495","None","","","","crusader_ne_segments.csv" -"10","code","0x45A00","0xD92","None","","","","crusader_ne_segments.csv" -"11","code","0x46E00","0x5B1","None","","","","crusader_ne_segments.csv" +"6","code","0x42C00","0x75E","Partial","Gamepal Xformpal palette resources and greyscale fade processes","Gamepal_Init; Gamepal_InitXformpalDatStruct; Gamepal_LoadXformpalDat; Gamepal_ReadXformpal_1028_0348; Gamepal_ReleaseXformpalResources_1028_02dc; Palette_FadeToGreyscale; FadeProcess_Create_2; FadeProcess1_Run_PausesCycle; FadeProcess2_Run","Xformpal data parsing/resource ownership and fade-process scheduling are not fully traced in the active CRUSADER.EXE; prior gameplay-side helper evidence is from raw segment 0006, not this live selector","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md; docs/raw-0008-000c.md" +"7","code","0x43600","0x484","Partial","Animation-process render-state publication","AnimProcess_BeginRenderStateUpdate_1030_02a5; AnimProcess_CommitRenderStateAndClearFlag_1030_02b2","The remaining process creation, dispatch, timer, and lifecycle routines need behavioral characterization","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"8","code","0x43C00","0x1386","Partial","Item collision masks and gravity-process movement","AreaSearch_CheckCollision (1038:0000 wrapper; 1038:0072 core); GravityProcess_CreateProcess; GravityProcess_Finish_1038_04bc; GravityProcess_Run; GravityProcess_CheckDownwardSweep_1038_1131; GravityProcess_FastAreaCleanup; Item_Hurl; Item_Fall","Full GravityProcess_Run state transitions and caller-side interpretation of the collision mask remain open","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"9","code","0x45400","0x495","Partial","DOS extender calls and gravity trajectory helpers","DosExtenderCallInterrupt_1040_0000; DosExtenderCallInterrupt_1040_0035; DosExtenderCallInterrupt_1040_0041; DosExtenderCallInterrupt_1040_005a; Runtime_InitializeCommandLineAndRunLoop_1040_0079; Item_BuildHurlTrajectoryParams_1040_00a6; Item_HurlWithParams; Ensure_GravityProcess; Filespec_CopyCandidateIfExists_1040_039e; dos_free_disk_space","INT 21h/2Fh service/register contracts and caller-side purpose of the gravity-proximity helper are unresolved","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"10","code","0x45A00","0xD92","Partial","Game initialization, teardown, and command-line handling","Init_Everything; Uninitialize; HandleCommandlineArgs; Runtime_InitializeAndHandleCommandLine_1048_01dc; Runtime_DrawStartupBanner_1048_025b","Subsystem initialization/teardown dependencies and the remaining helper/config-dispatch behavior need closer characterization","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"11","code","0x46E00","0x5B1","Partial","Savegame slot metadata, quick-save, and restore","Savegame_Init; Savegame_GetFilename; Savegame_QuickSave; Savegame_LoadProbably; SavegameSlot_GetLabelPtr; SavegameSlot_SetLabel; File_CloseAndMaybeFree","Save-file schema/versioning and malformed-file or partial-load behavior remain open","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" "12","code","0x47600","0x94B","None","","","","crusader_ne_segments.csv" "13","code","0x48200","0x1F6C","None","","","","crusader_ne_segments.csv" "14","code","0x4AA00","0x526","None","","","","crusader_ne_segments.csv" @@ -28,7 +28,7 @@ "27","code","0x5B400","0x57B","None","","","","crusader_ne_segments.csv" "28","code","0x5BA00","0x788","None","","","","crusader_ne_segments.csv" "29","code","0x5C400","0x190A","Partial","Area-search collision move and step-aware sweep helper lane","AreaSearch_CollideMove; AreaSearch_SweepShapeBetweenPoints; AreaSearch_SweepItemToPointWithStepUp; AreaSearch_SweepShapeBetweenPointsWithStepUp","Current direct callers are still all movement/collision-side and the remaining gap is the earlier policy layer deciding when those paths instantiate the 0x236 queue or whether any non-collision lane feeds it","plan-mid.md; docs/ne-hole-filling-priorities.md; docs/raw-0008-000c.md" -"30","code","0x5E000","0x5071","None","","","","crusader_ne_segments.csv" +"30","code","0x5E000","0x5071","Partial","Process embedded EntityDispatchEntry destructor-copy cluster","Process_DestroyEmbeddedDispatchEntries; Process_DestroyEmbeddedDispatchEntries_10e8_41e3; Process_DestroyEmbeddedDispatchEntries_10e8_4744","28 exact FUN_ candidates remain; owning Process class/role and callers unresolved","docs/crusader-exe-function-identification-map.md" "31","code","0x64000","0x6EE","Partial","StorageDataProcess queue create/run/release helpers","StorageDataProcess_Create; StorageDataProcess_Run; StorageDataProcess_Release; StorageDataProcess_RunAndTerminateProcs; storage_process_ref_list_create; storage_process_ref_list_append; storage_process_ref_list_terminate_item_matches; storage_process_ref_list_destroy","Still needs caller-side recovery beyond the verified collision producer and any stronger subsystem naming than the local hit/got-hit storage queue","plan-mid.md; docs/ne-hole-filling-priorities.md; docs/raw-0008-000c.md" "32","code","0x64800","0x56A","Foothold","Item type / typename.dat loader helpers","ItemType_Init; ItemType_LoadTypeflagDat; ItemType_Load_TypenameDat; ItemType_GetTypenameRecordPtrAtIndex; ItemType_FindTypenameRecordIndex; Item_GetShapeFamilyOfShape","The segment is now clearly an item-type helper lane. The remaining gap is not local contract recovery but broader caller-side integration and any later higher-level item-family helpers that still sit outside this small loader-focused window.","plan-mid.md; docs/function-knowledge-roadmap.md" "33","code","0x65000","0x10D7","Partial","NPC action / stand / pace / surrender / guard / loiter AI processes","NPCActionProcess_Create; NPCActionProcess_RunNoop; NPCActionProcess_Destroy; NPCActionProcess_VtableSlot10Noop; StandProcess_Run; StandProcess_Destroy; PaceProcess_CreateProcess; PaceProcess_Run; PaceProcess_Destroy; SurrenderProcess_CreateProcess; SurrenderProcess_Destroy; SurrenderProcess_Run; GuardProcess_CreateProcess; GuardProcess_Run; GuardProcess_Destroy; LoiterProcess_CreateProcess; LoiterProcess_Run; LoiterProcess_Destroy; LoiterProcess_VtableSlot10DispatchByShapeIfAlive; NPC_DoRandomIdleAnimTwiceIfNotBusy","The live AI-process lane now has owner-first Remorse class lifting in addition to run ownership, slot-1 destructor ownership, and the local slot-10 helper split. The remaining uncertainty in this immediate window is mostly higher-level behavior-policy meaning and whether the family is ready for a safe provisional datatype, especially what the slot-10/slot-11 transitions represent semantically beyond the now-named local function objects.","plan-mid.md; docs/function-knowledge-roadmap.md; docs/npc-action-process-class-layout.md" @@ -137,10 +137,10 @@ "136","code","0xD7600","0x5BD","Partial","Shared active dispatch-entry owner and hold-state controller","active_dispatch_entry_mark_enabled; active_dispatch_entry_mark_disabled; active_dispatch_entry_create_default","The shared active entry is now tied to the seg126 DS:0x6341 transition-animation path and to the shared 0x31a2 break/hold depth; current evidence also separates its borrowed +0x40 presentation hold token from the seg108-local 0x4f38 bit-0x40 lane, but the exact higher-level transition/callback subsystem name is still unresolved","crusader_decompilation_notes.md; plan-mid.md" "137","code","0xD7E00","0xFBB","Partial","Palette and dispatch-entry emission helper family","entity_dispatch_entry_init_runtime_state; entity_dispatch_entry_release_runtime_state; vga_palette_set_all_black; vga_palette_set_all_white; vga_palette_set_all_rgb; dispatch_entry_create_black_palette_state_active; dispatch_entry_create_grayscale_palette_state_active; dispatch_entry_create_solid_palette_state_active","Higher-level event/script meaning is still unresolved, especially the paired 0x68bf object and the exact role of the 0004:5ad4-5b6e caller sequence","crusader_decompilation_notes.md; plan-mid.md" "138","code","0xD9200","0x32E4","Partial","Entity cleanup/finalize with callback, watch-controller release, and dispatch-entry palette emission","entity_cleanup_resources_and_dispatch; sprite_redraw_global_if_active; FUN_000d_938c","Concrete callback-object subsystem naming is still unresolved, but this lane now has verified caller-side control of watch/controller state at 0x2bd8, uses the shared active-dispatch byte +0x40 as a borrowed presentation hold token rather than a local owner install, and emits two distinct 0x4588 payload pairs (entity +0x12d/+0x12f and +0x74f/+0x751) in addition to the palette-emission helpers","crusader_decompilation_notes.md; plan-mid.md" -"139","code","0xDCC00","0x984","None","","","","crusader_ne_segments.csv" -"140","code","0xDD800","0xC6F","None","","","","crusader_ne_segments.csv" -"141","code","0xDE600","0x2B","None","","","Short stub-sized segment","crusader_ne_segments.csv" -"142","code","0xDE800","0x4371","None","","","","crusader_ne_segments.csv" -"143","code","0xE3400","0x6F5","None","","","","crusader_ne_segments.csv" +"139","code","0xDCC00","0x984","Partial","Item SFX data cleanup and no-op method","Sound_FreeItemSfxData_1450_00ec; NoOpMethod_1450_074b","The global item-SFX data owner and the no-op method's higher-level role remain unverified","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"140","code","0xDD800","0xC6F","Partial","Viewport RLE bitmap drawing and callback forwarding","VPort_DrawRleBitmapRows_1458_04b0; VPort_DrawRleBitmapRowsWithSkip_1458_09d4; Callback_ForwardToSlot009d_1458_0b1c; Callback_ForwardToSlot00a5_1458_0bc1","No direct callers were recovered for these functions; the higher-level drawing and callback roles remain structural","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"141","code","0xDE600","0x2B","Partial","MSB-first packed-stream bit extraction","ExtractBitsMSBFirst_1460_0000","Used by the 1468 video decoders; the wider packed-video format remains only partially characterized","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"142","code","0xDE800","0x4371","Partial","Video playback, packed-row decoding, palette, and display lifecycle","VideoPlayer_DecodePackedRowsToWords_1468_04f9; VideoPlayer_DecodePackedRowsToDwords_1468_0995; VideoPlayer_DecodePackedRowsToBytes_1468_0e51; VideoPlayer_DecodePackedRowsToWords_1468_12fe; VideoPlayer_UpdateTimedMessage_1468_1da1; VideoPlayer_BuildFadePalette_1468_354a; VideoPlayer_StopAndDestroy_1468_3d36; VideoPlayer_ReleasePlaybackResources_1468_3d7a","The compressed-frame format and some callback contracts remain partially inferred; no exact auto-names remain in this segment","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" +"143","code","0xE3400","0x6F5","Partial","Video subtitle file loading, parsing, and timed-record access","VideoSubtitle_InitAndLoad_1470_005e; VideoSubtitle_ParseFile_1470_0239; VideoSubtitle_GetNextTimedRecord_1470_01ef; VideoSubtitle_ParseFrameTag_1470_05cc","The subtitle record format is behaviorally traced but not fully documented; no exact auto-names remain in this segment","crusader_ne_segments.csv; docs/crusader-exe-function-identification-map.md" "144","data","0xE3C00","0x8DBC","None","","","Large data segment not yet classified","crusader_ne_segments.csv" "145","data","0x0","0x0","None","","","Zero-length data segment placeholder","crusader_ne_segments.csv" \ No newline at end of file diff --git a/docs/REA/ghidra-dos.md b/docs/REA/ghidra-dos.md new file mode 100644 index 0000000..d8353fb --- /dev/null +++ b/docs/REA/ghidra-dos.md @@ -0,0 +1,217 @@ +# DOS MZ and COM analysis with Ghidra + +REA can analyze DOS MZ executables and explicitly selected COM images through the bring-your-own Ghidra adapter. +The Linux x64 and macOS arm64 verification lanes exercise actual 16-bit disassembly and +decompilation through the CLI and stdio MCP. Provider admission accepts Ghidra +12.1.x and that installation's declared JDK range. The verification lane uses +Ghidra 12.1.4 and JDK 21; no DOS emulator or cross-compiler is required. + +## Open and inspect + +```bash +rea inspect /absolute/path/to/legacy.exe --provider ghidra --json +rea search /absolute/path/to/legacy.exe entry --kind procedures --provider ghidra --json +rea instructions /absolute/path/to/legacy.exe entry --provider ghidra --json +rea function /absolute/path/to/legacy.exe entry --provider ghidra --json +rea inspect-native-load-image /absolute/path/to/legacy.exe --provider ghidra --json +rea read-bytes /absolute/path/to/legacy.exe 0x10000 --length 16 --provider ghidra --json +rea address-to-file-offset /absolute/path/to/legacy.exe 0x10000 --provider ghidra --json +``` + +Use an observed procedure name or address from discovery when the target does +not name its entry function `entry`. MCP uses `open_binary`, `list_procedures`, +`procedure_info`, `read_function_instructions`, and `analyze_function` with the +same admitted target and provider semantics. + +The classifier validates MZ page counts, initialized module length, header and +relocation-table bounds, relocation destinations, and the initialized entry +point. It distinguishes DOS load-module and relocation bytes from the Windows +new-header field. PE remains PE; NE, LE, and LX declarations are explicitly +unsupported. A damaged declared Windows header does not silently become DOS. +Inventory classification returns `unknown` when its bounded prefix cannot +establish the format; this is distinct from the complete target admission check. + +Ghidra imports a private target snapshot with `MzLoader`, language +`x86:LE:16:Real Mode`, and compiler specification `default`. These settings, +the fixed Ghidra load segment `0x1000`, and the linear address convention are +committed in the analysis profile. The handshake rejects language or compiler +drift. Closing the session deletes the temporary project and snapshot. + +The profile also commits `function_body_evidence: complete-inclusive-ranges-v1`, +so snapshots from older length-only Ghidra results do not satisfy the current +profile. + +## Headerless COM images + +COM has no identifying header. Select its interpretation explicitly; neither the +`.com` suffix nor arbitrary unrecognized bytes are enough to admit it. + +```bash +rea inspect /absolute/path/to/legacy.com --target-format dos-com --provider ghidra --json +rea function /absolute/path/to/legacy.com 0x10100 --target-format dos-com --provider ghidra --json +rea inspect-native-load-image /absolute/path/to/legacy.com --target-format dos-com --provider ghidra --json +``` + +```json +{ + "name": "open_binary", + "arguments": { + "path": "/absolute/path/to/legacy.com", + "format": "dos-com", + "provider_id": "ghidra" + } +} +``` + +The caller's interpretation applies to the complete file, even if its filename +suggests another format. Files must contain 1..65280 bytes: the 64 KiB COM segment +minus the 256-byte PSP prefix. Ghidra uses `BinaryLoader` with real-mode language +and maps file offset zero at `1000:0100` (linear `0x10100`). A packaged pre-analysis +script seeds the entry function and CS/DS/ES/SS context `0x1000`. These settings +and the preparation policy are committed in the analysis profile; a failed +preparation prevents the resident bridge from serving results. + +Load-image verification checks all original and modified file bytes, complete +source mapping/memory digests, absence of relocations, entry and measured register +context. The context is imposed for analysis, not observed from execution. PSP +memory, initial stack contents/SP, DOS interrupts and PC-98 devices are not +modeled. COM has no MZ header, relocation table or appended-overlay model; all +selected bytes belong to its analysis module. The original file stays unchanged. + +## Addresses and function extent + +Returned default-space addresses are linear byte coordinates. A Ghidra +segment:offset address has linear value `segment * 16 + offset`; multiple +segment aliases can identify the same byte. REA accepts the returned linear +address for subsequent lookups and leaves instruction decoding context with +Ghidra. These coordinates are analysis load addresses, not file offsets or +observations of a running DOS system. + +Offsets that Ghidra would truncate to a different address are rejected before +reading or annotating a function. This also applies to explicit or encoded +address-space names; leading zeros preserve the numeric offset. + +`procedure_info` and function dossiers include `body` evidence: + +```json +{ + "available": true, + "provenance": "ghidra-function-body-address-set", + "ranges": [ + { "start": "0x10000", "end": "0x1000d" }, + { "start": "0x10060", "end": "0x10065" } + ], + "total_bytes": 20, + "span_bytes": 102, + "non_contiguous": true, + "contains_entry": true +} +``` + +Each end is **inclusive**. `total_bytes` counts the complete observed +AddressSet; `span_bytes` measures its enclosing span and is null across address +spaces. Gaps and shared tails must not be treated as owned bytes. This is +Ghidra's database observation, not a proof of original source ownership or +exhaustive code discovery. Providers that do not report complete ranges return +`available: false` and an explicit reason. + +## Loaded-image evidence + +`inspect_native_load_image` independently checks the immutable session snapshot +against the loaded Ghidra Program. It measures complete original and modified +FileBytes digests, every source mapping and its memory digest, relocation records +(including multiplicity), and external entry points. It verifies MZ header and +module partitions, relocation fixups and linear coordinates rather than relying +on the imported executable SHA alone. + +The result is `verified`, `mismatch`, or `unsupported`. Every check retains its +expected and observed values. A memory-digest mismatch identifies the source +range's file offset and analysis address; it does not locate the first differing +byte inside that range. Mapping ends are **inclusive**, unlike the exclusive ends +from `list_segments`. Appended overlays remain in source-file identity and are +excluded from initialized module coverage. Uninitialized allocations are reported; +their contents and DOS runtime semantics are not verified. Formats other than MZ and explicit COM return +`unsupported` with measured observations, not a successful MZ verification. + +`read_bytes` returns initialized provider memory, including loader fixups; an +unmapped or uninitialized byte ends the read with an explicit returned length and +`complete: false`. `address_to_file_offset` uses the provider's source mapping; +unmapped, uninitialized and ambiguous mappings fail explicitly. A relocated word +can differ from the original file word even when its source offset is known. + +## Coverage boundaries + +Static decompilation does not execute the target or emulate BIOS, DOS +interrupts, device ports, or self-modifying code. PC-98 hardware behavior and +recovered calling conventions can remain uncertain; provider pseudocode and +diagnostics are retained for analyst review. + +For a packed executable, importing the original can analyze its unpacking +stub. Analyze a separately prepared unpacked copy to inspect the original +program's recovered code. Retain both artifact digests and the transformation +evidence; REA never silently replaces the admitted target. Appended overlays +are separate from the initialized MZ module. Raw COM files and DOS extenders +without an admitted MZ real-mode entry are outside this import boundary. + +DOS MZ is available through Ghidra, with no Hopper support claim. It is outside +the Windows native PE P0 boundary. macOS x64 DOS verification remains unverified. + +## Real verification + +```bash +npm run verify:ghidra:dos +``` + +The lane generates a small public fixture from source at runtime. It verifies +16-bit instruction bytes, a near call, a segment-relocated far call, actual +decompilation, disjoint function ranges, stable CLI/MCP observations, unchanged +input bytes, and session/process cleanup. It does not require external +executable fixtures, an emulator, or an existing analysis database. + +Provider p-code representations can contain process-specific address-space selector +tokens. The lane preserves those reported values and compares stable dossier +observations rather than asserting cross-process identity of raw p-code. + +## Local Verification (2026-10-10) + +The connected VS Code MCP server identified itself as `rea-agents` 6.3.0, loaded +from `C:\Users\Maddo\AppData\Local\npm-cache\_npx\ec0ab2283efe73f6\node_modules\rea-agents`. +The session had no active binary when checked. The REA tool catalog exposed +native binary opening, procedure listing, function analysis, and loaded-image +inspection. + +| Check | Result | +|---|---| +| Requested Ghidra installation | `I:\Apps\ghidra_12.1.4_PUBLIC` exists and contains `ghidraRun.bat` and `support\analyzeHeadless.bat`. Its `Ghidra\application.properties` reports Ghidra 12.1.4 and Java minimum 21; the maximum is unspecified. | +| Requested JDK | `C:\Program Files\Microsoft\jdk-25.0.3.9-hotspot\bin\java.exe` exists and reports Microsoft OpenJDK 25.0.3. | +| Ghidra headless startup | With both `JAVA_HOME` and `GHIDRA_JAVA_HOME` set to that JDK, `analyzeHeadless.bat -help` printed usage, then exited with code 1. Startup also reported an invalid manifest in the user `GhidraMCP` extension (`GHIDRA_MODULE_NAME` and `GHIDRA_MODULE_DESC` were rejected). This is evidence of launcher startup, not a successful analysis run; whether that extension warning affects the REA provider is unknown. | +| REA open of Crusader | `open_binary` with provider `ghidra` rejected `K:\ghidra\Crusader_Decomp\CRUSADER.EXE` as `unsupported NE executable in MZ image`. The file is 991,878 bytes. Rejection occurred before Ghidra analysis, so no Crusader functions, strings, or loaded-image checks were produced by REA. | +| REA end-to-end Ghidra analysis | Not verified. The installed npm package lists a `verify:ghidra:dos` command but does not include its referenced `scripts/verify-real-ghidra-dos.mjs` test runner; no DOS MZ/COM fixture was found in the workspace search. Antivirus blocked generation of a temporary MZ smoke-test image. | + +The installed Ghidra/JDK pair is present, and the Ghidra headless launcher reached +its command-line usage path under JDK 25. That does **not** prove the REA provider +is configured to use these exact installations or that it can analyze Crusader. +The observed target-format rejection agrees with the provider boundary above: +the DOS workflow accepts validated MZ and explicitly selected COM images, not +NE. For the current Crusader executable, REA cannot replace the existing NE +Ghidra workflow. A future REA NE provider or a separately justified conversion +would be required before this MCP can analyze the game executable. + +## Function annotations + +`annotate_native_function` changes the name and/or comments at one exact local function entry, verifies readback, and returns a refreshed dossier. This is useful when recording recovered DOS function roles; it does not claim original-source names. Name writes preserve the existing namespace; readback returns the fully qualified name used by function inventories. Regular comments map to Ghidra PRE comments and inline comments to EOL comments. Empty text clears a comment; omitted fields preserve it. The whole edit rolls back if a setter, readback or analysis fails. + +```json +{ + "procedure": "0x10100", + "name": "entry", + "comment": "Recovered startup role", + "inline_comment": "Inspect segment setup" +} +``` + +```bash +rea annotate-native-function /local/program.com 0x10100 --target-format dos-com --provider ghidra --name entry --comment 'Recovered startup role' --json +``` + +The CLI returns the updated analysis before closing its isolated session. MCP edits remain visible to later reads until `close_binary`. Original bytes remain unchanged, database edits are discarded on close, and immutable analysis snapshots are invalidated after edits. This operation does not save a Ghidra project, change ABI/types/body ranges, patch instructions, or emulate a DOS runtime. Windows P0 does not admit it. diff --git a/docs/ROGUE/cheats-and-debug.md b/docs/ROGUE/cheats-and-debug.md new file mode 100644 index 0000000..2674226 --- /dev/null +++ b/docs/ROGUE/cheats-and-debug.md @@ -0,0 +1,92 @@ +# Rogue Squadron 3D: PC Cheats and Debug Features + +## Summary + +The correct gameplay target is `Rogue Squadron.EXE`, not the neighboring `ROGUE.EXE` launcher. Static analysis of the gameplay binary found a 35-slot passcode hash table, with 16 slots mapped to 29 spellings so far. The binary confirms which spellings match its table; published PC cheat lists supply most claimed effects, which were not runtime-tested here. + +Editor-style debug UI survives in the executable, but the normal startup path disables its `Config` menu before construction. The `Alt+T` caption is therefore a conditional editor command, not an established retail gameplay shortcut. If the menu were enabled by another build or runtime state, it would open a `Debug Data` panel for switching among registered subsystem diagnostics, not a gameplay-cheat menu. + +## Scope and Method + +- Gameplay target: `C:\RE\Star Wars - Rogue Squadron 3D\ROGUE\Rogue Squadron.EXE`, PE32 x86, SHA-256 `0764709692e559e9de8ed125b9c59389cda2b594339dca5f47266deb10c2d43c`. +- `ROGUE.EXE` is the InstallShield launcher, not the gameplay executable; its SHA-256 is `a10f271a9708fe17e107072fa81243ed003155ab47bdff8514d338d04b847563`. +- Analysis used REA with Ghidra 12.1.4. The binary was loaded into an ephemeral analysis project; no executable bytes were changed, no project was saved, and neither executable was run. +- Addresses below are virtual addresses in `Rogue Squadron.EXE`. Hash-table slot numbers are zero-based. +- Binary observations establish code paths and passcode hash matches, not that a menu or cheat is reachable in a particular runtime state. External cheat effects are attributed to the linked guides and are not treated as binary-confirmed behavior. + +## Passcode Recognition + +`FUN_0042959e` constructs a 256-entry CRC table using polynomial `0xedb88320`. `FUN_00429549` hashes the requested byte count from seed `0xfac5fac5`; `FUN_004291e0` hashes ten bytes and compares the result against 35 dwords beginning at `0x5eb300`. Matching a slot updates its bit in `DAT_00704248`; slots 7 through 18 are made mutually exclusive. The surrounding lookup wrapper `FUN_004294eb` returns the matching slot or `35` when no table entry matches. These findings are from the executable's pseudocode, not from readable plaintext cheat strings. REA Evidence: CRC table `ev_35bb19672e88b04c20689b7020203e367784d26a151d31fc23632b0fe04cf53e`; hash routine `ev_e04a9605c1db82129bc4a0d7c605dc09786f53509ae9720e8bd872c5de8e7a85`; table matcher `ev_caf5048103c29b0dfee21f185db388b6310ef33cbdd828a601646237e0699bf6`. + +The spellings below reproduce these table slots when represented in the ten-byte input consumed by the matcher. Shorter strings were tested with trailing NUL padding. A matching hash establishes recognition by this executable's table, not the reported gameplay effect. + +| Slot | Accepted passcode spellings | Published effect (not runtime-tested) | +| ---: | --- | --- | +| 0 | `WIMPAMI` | Unlock bonus missions/levels. [1][4] | +| 2 | `WOOKIEPELT`, `PKDWXE`, `CRBSIFA` | Unlock the Millennium Falcon. [1][2][3][4] | +| 3 | `GOODGUYTIE`, `AAAAFNPDJY` | Unlock a TIE ship, described as the TIE Interceptor or TIE Fighter; some guides say the Falcon must be unlocked first. [1][2][3][4] | +| 5 | `CNDDOBY` | Display a developer-team picture. [1] | +| 11 | `CREDITS`, `ONCHHZU` | View the credits. [1][2][3][4] | +| 14 | `WOOKIYRWMW`, `AAAABDBOHP` | Effect unresolved; GameFAQs groups these with other unknown codes. [1] | +| 15 | `CHICKEN`, `OTOOJKH` | Control an AT-ST; one guide reports it unavailable on Taloraan. [1][2][3][4] | +| 19 | `MAESTRO` | Open the Concert Hall / listen to the music themes. [1][2][3][4] | +| 20 | `DIRECTOR`, `EAAAABUMFU` | View cutscenes; guides direct players to High Scores > At The Movies. [1][2][3][4] | +| 22 | `IAMDOLLY` | Infinite lives. [1][2][3][4] | +| 24 | `TOUGHGUY`, `NAKASGMQ`, `MLVBHF` | All power-ups or a technology upgrade, depending on the guide's wording. [1][2][3][4] | +| 25 | `NDAAFXWSFQ`, `EAAAABYCBA` | Effect unresolved; GameFAQs lists these among unknown codes. [1] | +| 28 | `OOMPAWAMPA`, `GCTHNME` | Conflicting reports: level select versus bonus-mission unlock. [1][2][3][4] | +| 30 | `USEDAFORCE`, `FSSRNB`, `JKQCNMH` | Use any ship available in the current level. [1][2][3][4] | +| 33 | `GUNDARK` | Change joystick force-feedback resistance based on velocity. The bundled README describes forces for varying stick resistance with velocity. [1][2][3][4][5] | +| 34 | `LEIAWRKOUT` | Enable acceleration/deceleration force feedback. The bundled README documents these forces and the `-i` command-line option for desensitizing craft movement caused by them. [1][2][3][4][5] | + +The 19 remaining table slots (`1`, `4`, `6`-`10`, `12`-`13`, `16`-`18`, `21`, `23`, `26`-`27`, `29`, `31`-`32`) are not mapped to passcode spellings in this pass. Tested guide-listed candidates `HIKEN`, `NEUC`, `ACE`, `LOKJOT`, and `RECUER` did not match a table hash under the tested ten-byte normalization. This is a bounded mismatch result for those candidates, not proof that all other published lists or game builds are wrong. + +### Reported Entry Method and Source Disagreements + +The PC guides describe entering passcodes from the main menu through **Settings > Passcodes**; the bundled README specifically places the two force-feedback codes in **General Settings**. This menu interaction was not tested in the game. + +Guide wording is not fully consistent. `OOMPAWAMPA`/`GCTHNME` are called a level-select code by Cheat Code Central, GameRevolution, and Super Cheats, while GameFAQs calls them a bonus-mission unlock. Reports also vary between “TIE Fighter” and “TIE Interceptor” for `GOODGUYTIE`, and whether that ship requires the Millennium Falcon first. Treat these as guide claims, not resolved binary semantics. Codes such as `ACE` (Expert Mode), `RECUER` (Imperial Shuttle), `HIKEN` (bonus weapons), and `NEUC` (radar destruction) occur in guide material but did not match the tested hash table for this executable. + +## Debug Features + +### Reachability and Opening + +- `FUN_005081d0` builds an editor-style menu containing `X`, `File`, `Object`, `Tools`, and `Config`. It creates the `Config` menu and its entries only when its second argument is nonzero. The startup routine `FUN_004ea9f0` writes zero to `DAT_00658df0` at `0x4eaa71` and later passes that value to the menu builder. Its two resolved callers are `FUN_004dd07c` and `FUN_004ea726`; both use this initialization path. +- The only direct write found for `DAT_00658df0` is that startup write of zero. The menu callback `FUN_004eba88` also returns without handling events unless `DAT_00658df0 != 0` and the UI event phase is `5`. If enabled, callback item `0x11` (17) invokes `FUN_004f2beb(2)`, which toggles the separate panel-display flag `DAT_00669adc`. +- The caption at `0x62d26c` is `Toggle Debug (Alt+t)`. Its menu-table slot is 17 and matches callback case `0x11`; this proves the intended command in the editor menu, not a working retail shortcut. The conditional route, if another build or state enables `Config`, is **Config > Toggle Debug** or the displayed **Alt+T** accelerator. No normal-play route that sets the gate nonzero was found. The matching menu builder, callback, and toggle are `FUN_005081d0`, `FUN_004eba88`, and `FUN_004f2beb`. + +### Panel and Modules + +- The `swe_debug` module registers the panel initializer and cleanup callbacks through its `LECMODULE=swe_debug` descriptor. `FUN_004f26f2` queries the `DEBUG` registry, stores each entry's display callback, and initializes its state to zero. It accepts at most 20 entries (indices 0-19); this executable contains seven `DEBUG=` registrations listed below. Missing entries or handlers take logged error paths. +- When enabled, the panel is titled **Debug Data** and has a **Set...** control. Activating it opens **Choose module to modify** with the registered module names. The panel draws the available names as rows. Selecting one sends state `-1` to that module and `0` to every other module; closing the panel clears its display flag and sends state `0` to all handlers. This is a one-module-at-a-time diagnostic selector, not a multi-option cheat menu. REA Evidence: panel builder `ev_aff919a807c9db7b2ee6fc76459630541650ce05764b6c1097ad09318ad8d2e7`; event/draw handler `ev_b0cefbd060522a6ca5a55aec191d2db41b262790e3308fe975e7fb3133f9c213`; cleanup `ev_a8cd442e451cdeac0b07ab05b15f853a1129dee7f531072fd556e44ad318ba48`. + +| Registry key | Chooser label | Embedded module description | Initializer | +| --- | --- | --- | --- | +| `DEBUG=swe_link_debug` | `Text Links` | `SWEET text hyperlink System`; debugging interface for the SWEET text-hyperlink module. | `FUN_004f1370` | +| `DEBUG=swe_dirtyrect_debug` | `Dirty Rectangles` | `SWEET Dirty Rectangle System`; debugging interface for the SWEET dirty-rectangles module. | `FUN_00502ee0` | +| `DEBUG=animframe` | `Insane AnimFrame` | `Insane AnimFrame Debug Interface`; debugging interface for the Insane Animation Frame module. | `FUN_00508d40` | +| `DEBUG=insane_animplay` | `Insane AnimPlay` | `Insane AnimPlay Debug Interface`; debugging interface for the Insane Animation module. | `FUN_00509c60` | +| `DEBUG=insane_clami_debug` | `Clami Script` | `Clami Script Debug.`; debugging interface for the Clami Scripting module. | `FUN_0050db50` | +| `DEBUG=insane_bundle` | `File Bundler` | `Insane File-bundler Debug.`; description says “Insance file-bundling system” in the binary. | `FUN_0051e6d8` | +| `DEBUG=insane_cache` | `File Cache` | `Insane File-caching Debug.`; description says “Insance file-caching system” in the binary. | `FUN_0051fbe0` | + +The module callbacks' displayed names/descriptions and state setters are present, but this pass did not trace every subsystem's downstream rendering or diagnostic side effects. The names establish the areas covered, not a complete list of counters, overlays, or commands inside each module. + +### Other Diagnostic Markers + +The binary also contains two separate memory-registry identifiers, `MEMORY=rogue_debug` at `0x60b3c4`/`0x60b3d8` and `MEMORY=insane_debug` at `0x63908c`/`0x6390a0`. They are not entries in the `DEBUG` selector described above. These strings alone do not establish supported command-line switches or visible features. The literal string inventory is recorded in REA Evidence `ev_a5b5fafa357ab084dc9545fa066d67ecb6e8fcb38f74886efebf9410ca0c88c7`. + +## Evidence and Confidence + +- **High, binary-observed:** executable identity and digest; CRC table construction; ten-byte hash routine; 35-slot comparison table; the mapped spellings' hash matches; Config-menu gating and startup zeroing; the conditional Alt+T callback; Debug Data panel construction, module selection/state behavior, and seven registered diagnostic module labels. See the Evidence IDs attached above. +- **Medium, source-reported:** gameplay effects and passcode entry steps. Multiple PC guides agree on many effects, but they are user-submitted or secondary references and were not tested against this executable. +- **Unresolved:** meanings of the 19 unmapped hash slots; effects of the codes in slots 14 and 25; the `OOMPAWAMPA` effect conflict; exact TIE ship/prerequisite; whether another build/runtime state can set `DAT_00658df0` nonzero; what each diagnostic module renders or logs after activation; differences among regional or repackaged builds. +- **Not performed:** launching the game, entering passcodes, observing the Debug Data panel at runtime, patching bytes, or saving a Ghidra project. + +## External References + +1. [GameFAQs: Rogue Squadron 3D (PC) cheats](https://gamefaqs.gamespot.com/pc/70612-star-wars-rogue-squadron-3d/cheats) — community-submitted code aliases and reported effects, including unresolved entries. +2. [Cheat Code Central: Star Wars: Rogue Squadron cheats for PC](https://www.cheatcc.com/articles/star-wars-rogue-squadron-cheats-codes-cheat-codes-walkthrough-guide-faq-unlockables-for-pc-pc/) — PC code list and instructions. +3. [GameRevolution: Star Wars: Rogue Squadron PC Cheats](https://www.gamerevolution.com/guides/29965-star-wars-rogue-squadron-pc-cheats) — PC code list. +4. [Super Cheats: Cheat Mode for Rogue Squadron 3D](https://www.supercheats.com/pc/star-wars-rogue-squadron-3d/14926/cheat-mode/) — PC code list; the site notes submissions are not usually tested. +5. `C:\RE\Star Wars - Rogue Squadron 3D\ROGUE\README.TXT`, “Force Feedback Support” — documents `LEIAWRKOUT`, `GUNDARK`, and the `-i` option. \ No newline at end of file diff --git a/docs/SOTE/cheats-and-debug.md b/docs/SOTE/cheats-and-debug.md new file mode 100644 index 0000000..1567275 --- /dev/null +++ b/docs/SOTE/cheats-and-debug.md @@ -0,0 +1,124 @@ +# Shadows of the Empire: PC Cheats and Debug Menu + +## Summary + +Static analysis of the PC game executable confirms four embedded gameplay-secret instructions, several pilot-name hooks, and a functional hidden debug menu. The debug menu has a PC keyboard activation path; do not assume the N64 pause-screen sequence works on PC. The player-facing secrets overlap substantially with documented N64 unlocks, but that does not establish that every N64 input sequence or prerequisite is identical on PC. + +## Scope and Method + +- Target: `Sdata/Shadows.exe`, PE32 x86, SHA-256 `bb63e515b39467947adad5e7c94fce1b0d00f0a815ca5f8cd24d67b373b46175`. +- Launcher: `SOTE.EXE`, SHA-256 `be596ee755afbd4f3a50de366a07866d8dfed032f3341b63f539e5f93773ff77`. Its WinMain path delegates to MFC startup; it is not the gameplay executable analyzed here. +- Analysis: REA with Ghidra 12.1.4; static inspection plus the user's runtime confirmation that the debug menu appears only while the game is paused and the pause menu is visible. The agent did not launch either executable. Ghidra's imported program was ephemeral; no executable bytes or saved project data were changed. +- Addresses below are virtual addresses in `Shadows.exe`. + +## PC Findings + +### Embedded Gameplay Secrets + +The binary contains four secret-instruction strings in the `0x4c6c60`-`0x4c6d70` range. Their instructions describe these actions: + +| Address | Instruction described | Reported effect / comparison | +| --- | --- | --- | +| `0x4c6c60` | Hold the camera button for five seconds while on foot. | Leebo scanner / overhead view. The N64 guides report this as the Leebo Scanner unlock. | +| `0x4c6cb8` | Hold the camera button for five seconds during the Skyhook sequence. | Change ship, cycling through the X-Wing and TIE fighter. N64 guides report this unlock on Skyhook. | +| `0x4c6d18` | Hold crouch for fifteen seconds while on foot. | Invincibility and weapon/ammo replenishment. N64 guides report this on-foot secret on Hard. | +| `0x4c6d70` | Complete the Jedi-difficulty condition for friendly Wampas. | Matches the N64 friendly-Wampa reward at a high level; the N64 guide describes collecting all challenge points on Jedi, so the exact PC prerequisite should be verified in-game. | + +These are confirmed as embedded PC instructions, not as runtime-tested behavior. Unlock prerequisites mentioned in the comparison column come from N64 documentation and may differ by platform or build. + +### Pilot-Name Hooks + +The profile-name checker at `FUN_0040d0c0` compares the current pilot name character by character against strings in the executable. The strings include: + +| Address | Embedded name | Finding | +| --- | --- | --- | +| `0x4cae14` | `R Testers ROCK` | The checker accepts this name. PC references describe it as granting access to all levels; the same accepted name also passes the debug-menu eligibility check described below. | +| `0x4cadf0` | ` Wampa Stompa` | Exact spacing, including the leading space and two spaces between the words, is present in the checker. Its flag is consumed elsewhere in gameplay; N64 references associate the similarly spaced name with enemy-control cheats. The precise PC effects were not fully traced. | +| `0x4cade0` | ` WIPE ALL DATA` | The checker invokes a cleanup routine for this name. Treat it as destructive: do not enter it on a profile containing data you want to keep. | + +The leading spaces shown above are part of the embedded strings. External guides use underscores to represent spaces in pilot names. + +### Hidden Debug Menu + +- **Dispatcher gates:** `FUN_00491f10` first checks `DAT_0073e668`. If it is already set, the routine calls `FUN_00492770` and returns; otherwise it calls `FUN_00493150` only when `FUN_00410be0()` returns `1` and `DAT_006ef1a8` is `0`. `FUN_00410be0()` is just a getter for `DAT_004caf40`; `FUN_0041088c` changes that global, but its deeper runtime meaning is not established. Modes other than `0` go through other input paths. **Runtime confirmation from the user:** the game must be paused with the pause menu visible for F12 to open the debug menu. The static global checks do not, by themselves, reveal that pause-menu requirement. +- **Keyboard polling:** `FUN_0041d280` initializes the input-slot table, including slot `0x58`. `FUN_0041dfa0` scans populated input slots from `0` through `0x283` and returns the first currently pressed input via `FUN_004a95e0`. That helper returns no input when `DAT_00760e54` is `0`; this is a necessary input-ready gate, although the exact conditions that set it are not established here. The scan can also report another held key or controller input before it reaches F12. +- **Press and release:** `FUN_00493150` skips the scan on certain competing input-transition/release paths (`FUN_0041ef30` / `FUN_0041eec0`). Otherwise, it stores the detected code in `DAT_0073e6fc` while an input is down. It dispatches the stored code only on a later poll that finds no input down, then clears the latch. The `0x58` case is the F12 path; holding F12 alone is not enough. The slot is present in the initialized input table, so no separate F12 key-binding requirement was found. +- **Profile eligibility:** the F12 case calls `FUN_0040d0c0`, which compares the current in-memory pilot-name buffer at `DAT_008d6348` against `R Testers ROCK`. That exact, case- and space-sensitive name returns true unconditionally. Other names depend on `DAT_004cada0`. The profile file containing the string is not proof that this is the name currently loaded in memory. +- **Activation result:** a successful check sets `DAT_0073e668`. On the next update, `FUN_00491f10` routes directly to `FUN_00492770`, before the ordinary input-mode checks. No additional campaign-completion, difficulty, or multi-key condition appears in this F12 path. Once active, F12 is no longer processed by `FUN_00493150`; use the menu's directional and confirm inputs instead. +- **What is drawn:** `FUN_00426440` is the relevant display path. With the menu active it calls `FUN_0042b870`, formats the current selection as `~c~o%s`, and passes that text to `FUN_00427ae0`. The menu-specific text is one styled selection label, not a 20-row list or an explicit “F12 accepted” message. The selection index `DAT_0073e670` starts at `0` in the image, so the initial label should be **Get all stuff**. Static analysis establishes the text path, not its exact screen position or how noticeable it is at runtime. +- **Menu navigation:** `FUN_00492770` wraps the selection over indices `0` to `19`. Its input masks decrement on `0x10500`, increment on `0x20200`, and confirm on `0x3800`. `FUN_0041c900` maps the executable's default keyboard bindings into the states consumed by those masks: Left Arrow or numpad 4 decrements; Right Arrow or numpad 6 increments. D and Space also feed the decrement group, and A feeds the increment group. Enter and numpad Enter confirm, but the same confirm mask also includes Escape, F1, X, and Z. Thus Escape is not a cancel/back command here: it confirms and executes the currently highlighted option. Confirmation clears `DAT_0073e668`; user-configured bindings may alter these defaults. +- **Live adjustment input:** menu entries read a signed input axis (`DAT_008a5c64`), not the menu's Left/Right selection masks. The input update routine builds this value from configured control slots and has a keyboard fallback, but the default key mapping for that fallback has not been identified. The user's runtime test found that Up/Down did not change the selected values, so do not assume those keys work. A configured controller axis may supply the value directly. Changes are applied continuously when the axis magnitude exceeds a dead zone; live entries do not require Enter. + +The table describes all 20 menu entries. `Enter` means the command is dispatched by the confirm input; `Input axis, live` means the highlighted value consumes the signed adjustment axis. Numeric ranges are the code's clamps, not recommendations. + +| Index | Display label | Input | Command/effect | +| --- | --- | --- | --- | +| 0 | Get all stuff | Enter | Runs the inventory/resource grant helpers and sets a related counter to 1000; the exact resource represented by that counter was not identified. | +| 1 | Invincibility | Enter | Toggles the invincibility state. | +| 2 | Debug Display | Enter | Toggles the debug-display mode. | +| 3 | 50 Lives | Enter | Sets the lives counter to 50. | +| 4 | Villains aren't sleepy | Input axis, live | Changes the villain behavior's 0/1 state. The default keyboard binding is unresolved. | +| 5 | Kill Dash | Enter | Runs the labeled Dash kill action through entity/action helpers. | +| 6 | Teleport | Enter | Runs teleport helpers for available actor/vehicle candidates; exact target and destination were not resolved. | +| 7 | Next Level | Enter | Calls the shared level-change handler for the next-level entry. | +| 8 | This Level | Enter | Calls the shared level-change handler for the current-level entry. | +| 9 | Prev Level | Enter | Calls the shared level-change handler for the previous-level entry. | +| 10 | Wall Ghost OFF (dynamic) | Input axis, live | Changes the wall-ghost 0/1 state; the displayed label reflects its current state. The default keyboard binding is unresolved. | +| 11 | Fog ON (dynamic) | Input axis, live | Changes the fog 0/1 state; the displayed label reflects its current state. The default keyboard binding is unresolved. | +| 12 | vertFOV: xxxxxxxx | Input axis, live | Adjusts vertical field of view, clamped to 4-120 degrees. | +| 13 | aspect: xxxxxxxx | Input axis, live | Adjusts aspect ratio, clamped to 0.1-10.0. | +| 14 | Fog Max xxxxxxxx | Input axis, live | Adjusts fog maximum, clamped to 10-999. | +| 15 | Fog Thick xxxxxxxx | Input axis, live | Adjusts fog thickness, clamped to 10-996. | +| 16 | Fog Red xxxxxxxx | Input axis, live | Adjusts the red fog/light component, clamped to 0-255. | +| 17 | Fog Green xxxxxxxx | Input axis, live | Adjusts the green fog/light component, clamped to 0-255. | +| 18 | Fog Blue xxxxxxxx | Input axis, live | Adjusts the blue fog/light component, clamped to 0-255. | +| 19 | Revert Fog and Lights | Enter | Resets vertical FOV to 67.5 and aspect ratio to 4:3, and clears the view override. The full fog/light reset effect was not separately resolved. | + +Confirming a command closes the debug overlay after dispatch. Invincibility and Debug Display are confirm-based toggles; entries described as live consume the signed input axis. The default keyboard control for that axis remains unresolved, and the user's test found that Up/Down did not change the values. Avoid Escape unless you intend to execute the highlighted command; it shares the confirm mask rather than cancelling. + +**Practical use:** pause the game and leave the pause menu visible, then press and release F12. The debug menu appears as one selected label, initially `Get all stuff`. Use Left/Right (or numpad 4/6) to cycle entries. Live value adjustment requires the signed input axis; its default keyboard binding is not yet established, and Up/Down did not work in the user's test. If a controller is configured, try its vertical axis while a live entry is selected. If F12 fails in the required pause state, check that the live pilot-name buffer is exactly `R Testers ROCK`, `DAT_004caf40` is `1`, the input mode is `0`, and the keyboard input-ready flag is nonzero. The meanings/runtime values of those flags were not observed. + +The N64 GameFAQs debug-mode report instead describes a pilot name rendered `.Wampa..Stompa`, followed by a pause-screen button and analog-stick sequence. That sequence is not the PC activation path observed in this executable. IGN's PC cheats page does not document that N64 debug sequence. + +### Enemy-Control Carryover + +**Conclusion: enemy control survived at least in part on PC.** The clearest directly documented PC example is the Battle of Hoth AT-ST: IGN and GameFAQs report holding numpad `4+6+8` for about five seconds, then pressing `Tab` to cycle views until the AT-ST view appears. This is distinct from the N64 D-pad/C-Right sequence. + +The PC executable also contains internal evidence for a broader Wampa-related actor/control mode: + +- `FUN_0040d0c0` recognizes the exact pilot string ` Wampa Stompa` and sets `DAT_004cad98`. +- The gameplay input/state routine `FUN_00471e90` checks that flag before enabling a second, level-mapped control chord; the chord tables are indexed by the current level/state. This sets the separate state `DAT_004caad8`. +- `FUN_00497680` is a stateful input-sequence handler with multiple branches that set the Wampa flag. One branch also dispatches four-byte identifiers through `FUN_00410cf0`; their exact game-level meaning was not resolved, so they are not treated as proof of a specific enemy spawn. +- `DAT_004caad8` is consumed by actor/update and rendering routines, including `FUN_0040a960` and `FUN_0040c060`; the latter changes the render scale under the special state. Other event paths also test it. This is consistent with a gameplay actor/control mode, not just an unused profile string, but static evidence does not identify every resulting player action. + +The N64 guide describes the related ` Wampa Stompa` name as unlocking control of a Wampa, Snowtrooper, AT-ST, or Xizor guard using D-pad/C-Right inputs. The shared profile-name hook and PC control-state paths make it likely that some of this system carried over. The PC references directly confirm only the AT-ST method; they do not establish that the N64 enemy roster, capture sequence, or movement/attack controls work unchanged on PC. + +## N64 Carryover Comparison + +The PC binary's four embedded secret instructions closely match the following N64 guide entries: + +- Camera hold for the Leebo Scanner. +- Camera hold during the Skyhook battle to switch to X-Wing/TIE. +- Crouch hold for invincibility and ammunition. +- Friendly Wampas on Jedi difficulty. + +The shared effects are strong evidence of gameplay-secret carryover. The PC strings themselves are direct evidence for the PC build; challenge-point requirements and exact controls in the external guides are N64-only evidence unless independently confirmed above. + +Name-based behavior also overlaps: the PC binary contains `R Testers ROCK` and ` Wampa Stompa`, while N64 guides report `R_Testers_ROCK` and `_Wampa__Stompa` (underscores denote spaces). A matching name string alone does not prove identical effects. + +## Evidence and Confidence + +- **High, binary-observed:** target identity and hashes; secret string locations and described actions; profile-name strings and exact spacing; the F12 polling/latch/eligibility path; dispatcher gates; default navigation and confirm binding groups; all 20 menu labels and their selection indices; the single-label rendering path. +- **Runtime-confirmed by the user:** the game must be paused with the pause menu visible for the debug menu to open, and its labels appear. Up/Down did not change the selected live values. +- **Medium, external comparison:** exact gameplay effects and unlock prerequisites, because the pages below document N64 behavior and PC entries but are user-contributed guides, not tests of this specific executable. +- **Unresolved:** the default keyboard binding for the live adjustment axis; the source of `DAT_004cada0`; the runtime meanings and values of `DAT_004caf40`, `DAT_006ef1a8`, and `DAT_00760e54`; the exact on-screen position of the menu label; whether all four secrets trigger under precisely the same requirements as N64; compatibility across PC releases. + +The user confirmed F12 activation and label visibility at runtime. The agent did not independently test the keyboard navigation/confirmation, destructive pilot name, or full effects of `Wampa Stompa`. + +## External References + +- [IGN: PC Cheats](https://www.ign.com/wikis/star-wars-shadows-of-the-empire/PC_Cheats) +- [IGN: N64 Cheats](https://www.ign.com/wikis/star-wars-shadows-of-the-empire/N64_Cheats) +- [GameFAQs: N64 Cheats](https://gamefaqs.gamespot.com/n64/198789-star-wars-shadows-of-the-empire/cheats) + +The GameFAQs debug-mode entry and other submitted codes should be treated as reported community instructions, not independently verified behavior. \ No newline at end of file diff --git a/docs/SOTE/level-modules.md b/docs/SOTE/level-modules.md new file mode 100644 index 0000000..98f9da7 --- /dev/null +++ b/docs/SOTE/level-modules.md @@ -0,0 +1,67 @@ +# Shadows of the Empire PC Level Modules + +## Scope and Method + +- Target: the installed PC v1.1 build in `C:\RE\Star Wars - Shadows of the Empire\Sdata`; `Shadows.exe` SHA-256 `bb63e515b39467947adad5e7c94fce1b0d00f0a815ca5f8cd24d67b373b46175`. +- The installation contains `DATA00.DLL` through `DATA31.DLL`. They are PE32 modules, not loose `.map` files. +- Static inspection of each export found `GetLevelStub` returning the module's numeric suffix (0 through 31; module 00 returns zero). Each module also has an embedded `EEEENNNNDDDD` title marker. No DLL was loaded or executed during this inspection. +- In `Shadows.exe`, `FUN_00441540` builds `sdata\data%02d` and bounds the requested module ID to 0–31 (out-of-range values fall back to 2). `FUN_00441660` loads the DLL and resolves `GetTheDataStub` and `GetLevelStub`. + +## Finding + +No dedicated debug/test map was identified in the shipped 32-module set. Every module has a title identifying it as a menu, a campaign segment, or a cutscene. A static scan of printable strings found no explicit `debug`, `test level`, `unused level`, `prototype map`, `development map`, `training level`, or `sandbox` label. + +This is a bounded negative finding, not proof that every module is played on every route. `FUN_0044f270` uses a next-level override, while `FUN_0044f570` remaps some requested IDs (`9 -> 10`, `11/13 -> 14`, `18/19 -> 20`, `23 -> 24`, `28 -> 29`). The remapper is used by gameplay and debug-menu paths, so those remaps alone do not establish reachability. Follow-up tracing found a separate state-4 path to module 12; its trigger and ordinary-campaign reachability remain unresolved. Chapter-number gaps in the titles are likewise not enough to call a map cut. + +**Conclusion:** no clearly labeled leftover debug map is present among `DATA00.DLL`–`DATA31.DLL`. The installation does contain cutscene and special-flow modules in addition to playable mission segments; whether any particular one is unreachable in every normal route remains unresolved. + +## DATA12: End Game (Cut 02) + +`DATA12.DLL` is a 55,296-byte PE32 module. Its `GetLevelStub` returns 12, `GetTheDataStub` returns the module data table at `0x1000B768`, and its embedded title marker is `EEEENNNNDDDDEnd Game (Cut 02)` (file offset `0x9b0c`). The payload also contains the string `Where am I?` at file offset `0x9978`; its use is not established by this static inspection. + +The executable has an explicit special-flow route to this module: + +- `FUN_0041088c` calls `FUN_00411660(-2)` when the game-state value at `DAT_004caf34` is 4. +- `FUN_00411660` translates `-2` to level ID 12 and passes it through `FUN_0044f570` as the next-level override. +- `FUN_0044f570` does not remap 12, and the normal transition routine then loads module 12 through the common level loader. + +This establishes that DATA12 is not merely a numbered DLL with an interesting title or a debug-selector option: the executable contains a distinct runtime path that requests it. The code examined here does not identify what sets state 4, so it does not prove which ending condition reaches the path or whether it is exercised in an ordinary campaign run. The debug `Select Level` option provides a separate direct way to request ID 12. + +## Module Index + +| Module ID | File | Embedded title | Classification | +| ---: | --- | --- | --- | +| 0 | `DATA00.DLL` | Cut 00 (Intro) | Cutscene | +| 1 | `DATA01.DLL` | Cut 01 (Hoth) | Cutscene | +| 2 | `DATA02.DLL` | Main Menu | Menu | +| 3 | `DATA03.DLL` | 1. Battle on Hoth | Campaign segment | +| 4 | `DATA04.DLL` | 2a. Hoth Base | Campaign segment | +| 5 | `DATA05.DLL` | 2b. Hoth Base | Campaign segment | +| 6 | `DATA06.DLL` | 3. Asteroid Chase | Campaign segment | +| 7 | `DATA07.DLL` | Cut 03 (Train) | Cutscene | +| 8 | `DATA08.DLL` | 4a. Train | Campaign segment | +| 9 | `DATA09.DLL` | Cut 04 (IG 88) | Cutscene | +| 10 | `DATA10.DLL` | 4b. Junk Heap | Campaign segment | +| 11 | `DATA11.DLL` | Cut 05 (Gorge) | Cutscene | +| 12 | `DATA12.DLL` | End Game (Cut 02) | Special end-game cutscene; state-4 route exists, trigger unresolved | +| 13 | `DATA13.DLL` | Cut 06 (Gorge Trans) | Cutscene | +| 14 | `DATA14.DLL` | 6a. Gall Cliff Base | Campaign segment | +| 15 | `DATA15.DLL` | 6b. Gall Cliff Base | Campaign segment | +| 16 | `DATA16.DLL` | Cut 07 (Bike Intro) | Cutscene | +| 17 | `DATA17.DLL` | 7. Speeder Bike Chase | Campaign segment | +| 18 | `DATA18.DLL` | Cut 08 (Bike End) | Cutscene | +| 19 | `DATA19.DLL` | Cut 09 (Freighter) | Cutscene | +| 20 | `DATA20.DLL` | 9a. Space Freighter | Campaign segment | +| 21 | `DATA21.DLL` | 9b. Space Freighter | Campaign segment | +| 22 | `DATA22.DLL` | 9c. Space Freighter | Campaign segment | +| 23 | `DATA23.DLL` | Cut 10 (Throne) | Cutscene | +| 24 | `DATA24.DLL` | Cut 11 (Sewer) | Cutscene | +| 25 | `DATA25.DLL` | 10. Sewer | Campaign segment | +| 26 | `DATA26.DLL` | 11a. Xizor Palace | Campaign segment | +| 27 | `DATA27.DLL` | 11b. Xizor Palace | Campaign segment | +| 28 | `DATA28.DLL` | Cut 12 (Battle) | Cutscene | +| 29 | `DATA29.DLL` | 12. Station Chase | Campaign segment | +| 30 | `DATA30.DLL` | 13. Skyhook Battle | Campaign segment | +| 31 | `DATA31.DLL` | Cut 13 (Finale) | Cutscene | + +Titles are extracted from the installed module files. “Campaign segment,” “cutscene,” and “menu” are classifications based on those titles, not independent runtime observations. The PC executable also contains a separate debug-menu level navigation path; its existence does not make the corresponding module a debug map. diff --git a/docs/Yoda/cheats-and-debug.md b/docs/Yoda/cheats-and-debug.md new file mode 100644 index 0000000..9efb6e0 --- /dev/null +++ b/docs/Yoda/cheats-and-debug.md @@ -0,0 +1,41 @@ +# Yoda Stories: PC Cheats and Debug Artifacts + +## Summary + +Static REA/Ghidra analysis of `Yodesk.exe` found two exact-match strings handled by one game routine: `goyoda` and `gojedi`. The first produces an `Invincible!` message and sets a handler field; the actual invulnerability effect was not traced. The second produces `Super Jedi!` and routes seven fixed game-data entries through an item-list helper. Their record names and exact gameplay effects remain unresolved. + +A hardcoded `c:\yodalog.txt` writer is also present. No debug menu, console command, or debug-named game procedure was confirmed in the searched strings/procedure names. The logger is a diagnostic artifact, not evidence of a user-facing debug interface. + +## Scope and Method + +- Target: `C:\RE\Yoda_Stories\Star Wars - Yoda Stories (1997)(LucasArts)\Yoda\Yodesk.exe`, PE x86, SHA-256 `4d9876339d494cab141c3f4178f37a2725d178e41c7785887c84d021a8e695e7`. +- Analysis: REA with Ghidra 12.1.4. The executable was analyzed statically in an ephemeral project. The game was not launched, executable bytes were not changed, and the Ghidra project was not saved. +- The selected image contains 2,051 analyzed procedures and 999 defined strings. Addresses below are virtual addresses in `Yodesk.exe`. +- String and procedure searches were bounded to cheat/debug-related terms. A negative search does not exclude encoded checks, unnamed logic, or behavior supplied by external game data. + +## Embedded Codes + +`FUN_00418cb0` compares the byte string at `this + 0x17c` against two embedded lowercase strings. The comparison is exact and case-sensitive. The strings are at `0x457214` (`goyoda`) and `0x457200` (`gojedi`); each has one direct reference in this handler. REA Evidence: handler pseudocode `ev_004e22d593fd6345794a575f11a6992f6f482a02a1513377ba49ce4db56d641f`; string inventory/search `ev_ade26cfa241bee347b0fd23213ff40f18c6361e54fb63ee6554a7ed3acfbdf50`; string xrefs `ev_1165b25725959f7b15e6e778150ae6104ba146717c74db2272159e1ff7c72701` and `ev_e20e0aaa72523fcb0b1b24587335bb51a9417256dc69a88e6bcce3f99eea3bee`. + +| Code | Binary-observed behavior | What remains unverified | +| --- | --- | --- | +| `goyoda` | Passes `Invincible!` to UI helper `FUN_0041a7b0` at coordinates derived from the current game position, then sets `this + 0x180` to `1`. The input field is reset afterward. | The handler does not itself show a health/damage update. Whether `this + 0x180` enables player invulnerability elsewhere was not traced; treat the label as a strong hint, not a fully established gameplay effect. | +| `gojedi` | Looks up table indices `0x1ff`, `0x200`, `0x201`, and `0x202` (the last four times) through `FUN_00404a70`, then passes the returned objects to `FUN_0041c3f0`. It displays `Super Jedi!` through the same UI helper and resets the input field. | `FUN_0041c3f0` inserts object-backed entries into a list, but the object names and exact gameplay effects are not recoverable from these executable references alone. The `YODESK.DTA` data records were not analyzed. | + +The call to `FUN_0041a7b0` changes UI state and presents the supplied text; its use here is evidence for confirmation messages, not by itself proof of the associated cheat effect. The `gojedi` sequence and list behavior are visible in `FUN_00418cb0` and `FUN_0041c3f0`. REA Evidence: UI helper `ev_490ffce462d90c42b84b82a6272592d0345486c9f34128a7aacfa5dd97fdc72c`; list helper `ev_2a7abff77116595fc5e73e592ce41f3756dfeffd35a7cde29f0ff51d0b54a865`. + +### Input Reachability + +REA decoded a direct `CALL 0x00418cb0` at `0x41a088`. However, that callsite is not assigned to an analyzed procedure, and the resolved procedure-caller list for `FUN_00418cb0` is empty. The field at `this + 0x17c` is clearly compared with the two code strings, but this pass did not establish where the field is populated, the user-facing entry method, or whether the call is reachable in ordinary play. Do not infer a keyboard sequence or menu path from the comparisons alone. REA Evidence: callsite instruction `ev_a56dae62e987e14da434113e153ae803dbe6f13047c68829b7f1ed8a2f91d5d4`; caller result `ev_2f0331f64092b877fcb0cec7167ab0e1e76e3c865cc80a074621d4be53db6ec8`. + +## Debug and Logging Artifacts + +- `FUN_00401d20` opens the hardcoded path `c:\yodalog.txt`, writes its string argument, flushes, and closes the file. Its one resolved caller is `FUN_00423ef0`; the logger's file mode and the caller's precise logging conditions were not established. This supports the presence of file-based diagnostics, not an interactive debug facility. REA Evidence: logger pseudocode `ev_abd833e0e171e35a25a50a8bfd99fe2b2f39a1d915aeb907727ae94e8e0aef83`; caller list `ev_40c9282abeabc1b563740c277d22cf7b288f7831b5950cb8e953688f892d706b`. +- Searches of the defined strings for `debug`, `cheat`, `secret`, `console`, `developer`, `test`, and related terms returned the two code strings, `c:\yodalog.txt`, `Invincible!`, and an MFC `CTestCmdUI` type string, but no named debug menu or console. Procedure-name search produced no game-specific debug/cheat routine. REA Evidence: string searches `ev_71610c8b15e3236479e7db351c31d39c296e0b4d15d1fab5e45427aac7e8bf7d`, `ev_49ae904a90daa0b4f76e6d2c053de584e71502204f4036bb99b2b1873db7242c`, and `ev_ade26cfa241bee347b0fd23213ff40f18c6361e54fb63ee6554a7ed3acfbdf50`; procedure search `ev_ee150208cd3debdd877edf3d8436ffe202e335ce55dc8b3f10d0244544897512`. + +## Evidence and Confidence + +- **High, binary-observed:** target identity; the exact lowercase strings; the two comparison branches; the `Invincible!` and `Super Jedi!` messages; the fixed `gojedi` table-index sequence; the UI/list helper behavior; and the hardcoded log writer. +- **Medium, inference:** `goyoda` is intended to signal an invincibility cheat, and `gojedi` is intended to provide a special item loadout. The code names/messages support these interpretations, but the actual game-state effects and item identities were not independently traced. +- **Unresolved:** how the compared field is filled; whether either check is reachable in normal gameplay; whether `this + 0x180` affects damage handling; the object names behind indices `0x1ff`-`0x202`; logger mode/conditions; and any debug behavior not represented by searched plaintext strings or analyzed procedure names. +- **Not performed:** launching the game, testing either code, analyzing `YODESK.DTA`, patching bytes, or saving a Ghidra project. \ No newline at end of file diff --git a/docs/crusader-exe-function-identification-map.md b/docs/crusader-exe-function-identification-map.md new file mode 100644 index 0000000..cf6402f --- /dev/null +++ b/docs/crusader-exe-function-identification-map.md @@ -0,0 +1,1753 @@ +# CRUSADER.EXE Function Identification Map + +## Scope + +This backlog tracks exact Ghidra auto-names in live `CRUSADER.EXE` code blocks. The first inventory queried on 2026-10-09 contained 1,047 functions; a read-only live scan on 2026-10-10 found 381 candidates across 46 code blocks. The per-block table is that dated snapshot; later batches below record candidates cleared since then. + +These are unresolved naming candidates, not a claim that every function has no existing behavioral evidence. Some may already have leads in subsystem notes or neighboring analysis; check those sources before redoing work or promoting a name. This list intentionally excludes `nullfn_*`, generic-but-authored names such as `Process_...`, and known no-op/thunk labels. Those can still merit review, but they are not exact Ghidra `FUN_` auto-names. + +## How To Read The Map + +`Code N` is the memory-block number shown by the current Ghidra database. The selector column is the segment portion of the live Ghidra `segment:offset` address. For example, Code142 / selector `1468`, offset `04f9` is symbol `FUN_1468_04f9` at `1468:04f9`. Only code blocks with remaining exact auto-names appear; omitted code blocks currently have none. Data and external blocks are out of scope. + +## Identification Backlog + +This table contains only exact Ghidra auto-names that remain in live `CRUSADER.EXE` code blocks. Clearing these exact auto-names is the completion target tracked here; this does not claim that generic authored names or `nullfn_*` stubs have been behaviorally identified. + +| Ghidra code block | Selector | Remaining count | Remaining entry offsets (`FUN__`) | +|---|---:|---:|---| +| Code1 | `1000` | 2 | `018a, 2bf2` | +| Code87 | `12b0` | 13 | `0000, 003d, 0066, 00c1, 011c, 01b8, 0254, 0286, 02b8, 02e8, 0318, 039d, 048c` | +| Code88 | `12b8` | 15 | `0000, 002a, 0071, 015c, 0183, 01f9, 027d, 02aa, 02d7, 0344, 03b4, 0406, 0492, 04ab, 04f0` | +| Code89 | `12c0` | 7 | `0000, 0029, 006e, 00c2, 00f2, 012d, 01bd` | +| Code91 | `12d0` | 3 | `02eb, 06ca, 06e7` | +| Code92 | `12d8` | 8 | `00f5, 01cb, 024e, 02d3, 0346, 04d0, 050d, 0560` | +| Code95 | `12f0` | 8 | `0298, 0495, 0a3e, 0bc1, 0bd7, 0bee, 0c29, 0c64` | +| Code96 | `12f8` | 8 | `0000, 004b, 01a5, 036b, 038a, 044a, 0463, 055f` | +| Code97 | `1300` | 16 | `0000, 0138, 0264, 02e8, 08ad, 0920, 0941, 0942, 0b5c, 0c55, 0c6c, 0c75, 0c7e, 0d04, 0d2d, 0d44` | +| Code98 | `1308` | 7 | `0000, 001d, 0151, 0254, 0371, 04cd, 04fd` | +| Code99 | `1310` | 6 | `0000, 002e, 02c2, 02fe, 0317, 0330` | +| Code100 | `1318` | 3 | `01f9, 025a, 063d` | +| Code101 | `1320` | 19 | `0146, 0624, 0935, 09f7, 0cbd, 0dfc, 0e0e, 0ebc, 0f8b, 1018, 11bf, 12cc, 130f, 14bf, 1525, 16b6, 1705, 1734, 175d` | +| Code102 | `1328` | 5 | `006b, 00d7, 0267, 0652, 06ab` | +| Code103 | `1330` | 13 | `0000, 00ea, 031d, 03bc, 0517, 065a, 0b8a, 12d7, 1363, 137c, 1502, 163c, 1693` | +| Code104 | `1338` | 5 | `0109, 01cf, 02c5, 02ed, 0342` | +| Code105 | `1340` | 12 | `010f, 011c, 0129, 02e3, 0420, 0540, 0685, 0706, 075f, 079c, 084d, 096a` | +| Code106 | `1348` | 24 | `019b, 02c6, 03da, 0823, 090b, 09bb, 0b0d, 0b39, 0bdc, 0c92, 0d07, 0d81, 0e2e, 0e7f, 0f0f, 0f70, 1025, 1212, 1288, 1377, 1561, 15d4, 164b, 169a` | +| Code108 | `1358` | 15 | `037f, 03a5, 0a46, 0a92, 0b92, 0cbd, 0ce9, 0d06, 0e1f, 0e93, 0f41, 0fc9, 0fd6, 1108, 1120` | +| Code109 | `1360` | 21 | `017a, 01c7, 0218, 0269, 05d4, 078d, 084d, 0c35, 0c6a, 0c7d, 0c90, 107b, 10d8, 118e, 1297, 12b2, 12cd, 135d, 1395, 13e6, 1412` | +| Code110 | `1368` | 2 | `0000, 0352` | +| Code111 | `1370` | 4 | `0105, 0275, 02af, 0428` | +| Code112 | `1378` | 17 | `0177, 02ee, 0465, 05dc, 06e1, 0790, 0a00, 0b04, 0bd3, 0d4c, 1309, 13da, 13fd, 141a, 1608, 1618, 1644` | +| Code113 | `1380` | 3 | `00cc, 0219, 02e5` | +| Code114 | `1388` | 11 | `016e, 01c9, 0248, 0400, 048a, 051b, 0566, 0685, 07ab, 0c12, 0ca2` | +| Code115 | `1390` | 11 | `02c2, 05ce, 05e1, 0639, 064c, 07d3, 080a, 085e, 08c0, 0934, 0953` | +| Code116 | `1398` | 4 | `02d1, 0487, 0887, 0a2a` | +| Code117 | `13a0` | 2 | `304b, 305c` | +| Code118 | `13a8` | 9 | `0088, 0117, 01ee, 0361, 048a, 04b3, 0524, 0587, 0837` | +| Code120 | `13b8` | 8 | `01ce, 04f7, 0580, 05e8, 06b4, 0758, 07c7, 0983` | +| Code121 | `13c0` | 2 | `006d, 08f5` | +| Code122 | `13c8` | 5 | `28e1, 2c90, 2d19, 2e16, 2eca` | +| Code124 | `13d8` | 5 | `008d, 01a0, 031a, 037d, 03b7` | +| Code126 | `13e8` | 19 | `007d, 0af8, 0f56, 0f77, 1086, 10a5, 140c, 2b74, 2dad, 307f, 3253, 32f2, 334e, 338d, 3796, 37b4, 388f, 3ec3, 3f83` | +| Code129 | `1400` | 5 | `0123, 0149, 0a14, 0c7e, 0cd9` | +| Code132 | `1418` | 1 | `0172` | +| Code133 | `1420` | 8 | `011b, 0134, 0181, 05db, 0cb3, 1ffd, 2010, 209f` | +| Code134 | `1428` | 16 | `00bf, 0251, 03a3, 041d, 043a, 05ac, 0651, 07f2, 0860, 087b, 0c31, 0cf6, 0d7a, 0dd8, 0e2f, 0e86` | +| Code136 | `1438` | 1 | `03fb` | +| Code137 | `1440` | 2 | `07be, 0ea3` | +| Code138 | `1448` | 3 | `0000, 0031, 1ec9` | +| Code139 | `1450` | 2 | `00ec, 074b` | +| Code140 | `1458` | 4 | `04b0, 09d4, 0b1c, 0bc1` | +| Code141 | `1460` | 1 | `0000` | +| Code142 | `1468` | 14 | `04f9, 0995, 0e51, 12fe, 1d4d, 1da1, 354a, 37c4, 3a3d, 3c23, 3d36, 3d7a, 4206, 4217` | +| Code143 | `1470` | 12 | `0000, 005e, 00cc, 00fb, 01c6, 01ef, 0239, 0398, 04a0, 04f8, 05cc, 0692` | + +## Processed Functions + +### Batch 1: Code30 (`10e8`) + +- `10e8:3e68` (`FUN_10e8_3e68` -> `Process_DestroyEmbeddedDispatchEntries`): destroys the `Process` object's embedded `EntityDispatchEntry` fields at `+0x0c` (slot 0) and `+0x10` (slot 2); if `param_2` bit 0 is set, calls `Process_AssertNotTerminating`. Decompilation and the exact function body support this structural name. Ghidra reports no callers or xrefs, so the concrete owner/class role remains unresolved. +- `10e8:38bc` (`FUN_10e8_38bc` -> `ByteRecord_StoreAtOffset8AndReturnTrue`): stores `val` at byte offset `+8` from `ptr` and returns `1`. The nearby `NPC_GetDifficultyLevel` at `10e8:38cd` reads the global `g_difficultyLevel`, so the two functions are not treated as a getter/setter pair. No callers or xrefs resolve here; the record type and field meaning remain unknown. + +### Batch 2: Code30 (`10e8`) + +- `10e8:3e47` (`FUN_10e8_3e47` -> `AvatarItemState_Initialize`): calls `malloc_0x17_bytes_if_needed` with the address of `g_avatarItemNo`. The helper initializes a 0x17-byte block, setting bytes 0 and 1 to `1, 0` and bytes `0x0b` and `0x0c` to `3, 0`; because the wrapper passes a fixed, non-null global address, the helper's allocation branch is not taken. References to the global support its avatar-item association, but Ghidra has no direct caller/xref to the wrapper. +- `10e8:3eb9`, `10e8:3f0a`, and `10e8:3f5b` decompile identically to `Process_DestroyEmbeddedDispatchEntries` at `10e8:3e68`. No callers/xrefs resolve for these copies, so they remain unnamed until table/owner context distinguishes their roles. + +### Batch 3: Code30 (`10e8`) + +- `10e8:38d5` (`FUN_10e8_38d5` -> `Savegame_Load_InvokeCallbackAndRestoreRng`): called by `Savegame_LoadProbably` at `1050:043a` after the preceding load readers. It invokes the callback from `(*(param_3 + 8) + 0x0c)`, then restores the RNG seed from `DAT_1478_7e26` through `Random_SetSeed`. +- `10e8:3905` (`FUN_10e8_3905` -> `Savegame_Save_CaptureRngAndInvokeCallback`): called by `Savegame_QuickSave` at `1050:023c` after item-cache and NPC serialization. It captures the current seed with `Get_RandomSeed`, invokes the callback from `(*(param_3 + 8) + 0x10)` with fixed arguments including `&g_avatarItemNo`, and returns `NPC_GetDifficultyLevel()`. +- The save/load callback targets and serialized record schema remain unresolved; the names describe the verified caller role and local operations only. + +### Batch 4: Code30 destructor copies (`10e8`) + +- `10e8:3eb9` -> `Process_DestroyEmbeddedDispatchEntries_10e8_3eb9` +- `10e8:3f0a` -> `Process_DestroyEmbeddedDispatchEntries_10e8_3f0a` +- `10e8:3f5b` -> `Process_DestroyEmbeddedDispatchEntries_10e8_3f5b` +- `10e8:3fac` -> `Process_DestroyEmbeddedDispatchEntries_10e8_3fac` +- `10e8:3ffd` -> `Process_DestroyEmbeddedDispatchEntries_10e8_3ffd` +- `10e8:404e` -> `Process_DestroyEmbeddedDispatchEntries_10e8_404e` +- `10e8:409f` -> `Process_DestroyEmbeddedDispatchEntries_10e8_409f` +- `10e8:40f0` -> `Process_DestroyEmbeddedDispatchEntries_10e8_40f0` + +All eight bodies match `Process_DestroyEmbeddedDispatchEntries` at `10e8:3e68`: they destroy the embedded dispatch entries at `+0x0c` and `+0x10` and conditionally assert that the process is not terminating. Each has an address-qualified structural name because no caller was recovered to establish the owning class. The suffixes preserve the distinction between separate function bodies without claiming they are interchangeable. + +### Batch 5: Code30 destructor copies (`10e8`) + +- `10e8:41e3` -> `Process_DestroyEmbeddedDispatchEntries_10e8_41e3` +- `10e8:4234` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4234` +- `10e8:4285` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4285` +- `10e8:42d6` -> `Process_DestroyEmbeddedDispatchEntries_10e8_42d6` +- `10e8:4327` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4327` +- `10e8:4378` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4378` + +All six decompile identically: they null-check the process, destroy `loadsaveFnPtr2` and `loadsavefnPtr` as dispatch slots 0 and 2, and conditionally call `Process_AssertNotTerminating` when `param_2` bit 0 is set. Each has an address-qualified structural name and a decompiler comment recording this evidence; the owning class/role remains unresolved. + +### Batch 6: Code30 destructor copies (`10e8`) + +- `10e8:4141` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4141` +- `10e8:43c9` -> `Process_DestroyEmbeddedDispatchEntries_10e8_43c9` +- `10e8:441a` -> `Process_DestroyEmbeddedDispatchEntries_10e8_441a` +- `10e8:446b` -> `Process_DestroyEmbeddedDispatchEntries_10e8_446b` +- `10e8:44bc` -> `Process_DestroyEmbeddedDispatchEntries_10e8_44bc` +- `10e8:450d` -> `Process_DestroyEmbeddedDispatchEntries_10e8_450d` +- `10e8:455e` -> `Process_DestroyEmbeddedDispatchEntries_10e8_455e` + +All seven decompile to the same cleanup routine and compare byte-for-byte with the 79-byte body at `10e8:3e68`. Each null-checks the process, destroys `loadsaveFnPtr2` and `loadsavefnPtr` as dispatch slots 0/2, and conditionally calls `Process_AssertNotTerminating`. No direct callers or xrefs resolve; address-qualified names preserve the distinct entries without guessing their owning classes. + +### Batch 7: Code30 destructor copies (`10e8`) + +- `10e8:45af` -> `Process_DestroyEmbeddedDispatchEntries_10e8_45af` +- `10e8:4600` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4600` +- `10e8:4651` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4651` +- `10e8:46a2` -> `Process_DestroyEmbeddedDispatchEntries_10e8_46a2` +- `10e8:46f3` -> `Process_DestroyEmbeddedDispatchEntries_10e8_46f3` +- `10e8:4744` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4744` + +All six decompile to the same cleanup routine and compare byte-for-byte with the 79-byte body at `10e8:3e68`. Each null-checks the process, destroys `loadsaveFnPtr2` and `loadsavefnPtr` as dispatch slots 0/2, and conditionally calls `Process_AssertNotTerminating`. No direct callers or xrefs resolve; address-qualified names preserve the distinct entries without guessing their owning classes. + +### Batch 8: Code30 destructor copies (`10e8`) + +- `10e8:4795` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4795` +- `10e8:47e6` -> `Process_DestroyEmbeddedDispatchEntries_10e8_47e6` +- `10e8:4837` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4837` +- `10e8:4888` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4888` +- `10e8:48d9` -> `Process_DestroyEmbeddedDispatchEntries_10e8_48d9` +- `10e8:492a` -> `Process_DestroyEmbeddedDispatchEntries_10e8_492a` +- `10e8:497b` -> `Process_DestroyEmbeddedDispatchEntries_10e8_497b` +- `10e8:49cc` -> `Process_DestroyEmbeddedDispatchEntries_10e8_49cc` +- `10e8:4a1d` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4a1d` +- `10e8:4a6e` -> `Process_DestroyEmbeddedDispatchEntries_10e8_4a6e` + +All ten decompile to the same cleanup behavior as `10e8:3e68`: they null-check the process, destroy `loadsaveFnPtr2` and `loadsavefnPtr` as dispatch slots 0 and 2, and call `Process_AssertNotTerminating` when `param_2` bit 0 is set. The owning class remains unresolved, so the names retain address-qualified suffixes. Each entry has a decompiler comment with this evidence. + +### Program-Wide Exact Duplicate Scan (`2026-10-09`) + +A live read-only Ghidra script scanned all 3,033 defined functions and grouped functions by the exact ordered bytes of their decoded instructions. The report below includes groups with at least 16 instruction bytes and either two or more exact `FUN_...` candidates, or an exact match to at least one authored-name function. `candidate` means the name matched Ghidra's exact `FUN__` form at scan time. All 100 auto-named functions listed in these groups have since been renamed; the assigned name is the stem below plus `__`. Byte identity supports the behavior-level names but does not establish each function's owner or higher-level role. Tiny boilerplate-only groups and groups without an auto-named member are omitted; this scan does not find semantically equivalent code whose instruction bytes differ. + +| Exact body | Auto-named members (all now renamed) | Assigned name stem | Evidence and behavior | +|---|---|---| +| 58 bytes | `1308:05a2, 1308:05dc, 1308:0650, 1320:1782, 1330:1659, 1340:09bc, 1348:1660, 1348:16ad, 1348:16e7, 1348:1721, 1348:175b, 1370:03b4, 1370:03ee, 1370:044f, 1378:143a, 1378:14ac, 1378:14e6, 1378:1520, 1378:155a, 1378:1594, 1378:15ce, 1380:0432, 1380:046c, 13c8:305c, 13c8:3096, 13c8:30d0, 13c8:310f` | `SpriteNode_DestroyAndMaybeFree` | Exact matches include `1308:0616` (`ButtonGump_Destroy`), `13a0:306f` (`usecode_debugger_menu_destroy`), and `13c0:0a94` (`KeypadButtonGump_Destroy`). Representative `1308:05a2` destroys a `SpriteNode` and conditionally frees the gump. | +| 79 bytes | `10e8:4abf, 10e8:4b10, 10e8:4b61, 10e8:4bb2, 10e8:4c03, 10e8:4c54, 10e8:4ca5, 10e8:4cf6, 10e8:4d47, 10e8:4d98, 10e8:4de9, 10e8:4e3a, 10e8:4e8b, 10e8:4edc, 10e8:4f2d, 10e8:4f7e, 10e8:4fcf, 10e8:5020` | `Process_DestroyEmbeddedDispatchEntries` | Exact copies of the previously named family (39 named bodies in the group). They destroy dispatch slots 0 and 2 and optionally assert that the process is not terminating. | +| 23 bytes | `1350:02b1, 1350:02c8, 13f8:055e, 13f8:0575` | `Object_InvokeVtableOffset3C` | Identical indirect virtual-call stubs through object offset `+0x3c`. | +| 53 bytes | `1070:1bfe, 1070:1c33, 10b8:06a2` | `Object_Call1220_0000_ThenMaybeFree` | Null-check, call `FUN_1220_0000`, then conditionally free the object. | +| 28 bytes | `1370:037c, 1378:1474, 1380:03fa` | `Object_SetField39TrueAndUpdate` | Set object field `+0x39` to 1 and call `FUN_1360_078d`. | +| 28 bytes | `1370:0398, 1378:1490, 1380:0416` | `Object_SetField39FalseAndUpdate` | Set object field `+0x39` to 0 and call `FUN_1360_078d`. | +| 78 bytes | `1150:3321, 11c0:0643` | `Process_DestroyEmbeddedDispatchEntries` | Exact copies among 16 authored-name destructor functions, including `PathfinderProcess_Destroy` and `DeathSilenceProcess_Destroy`. Destroy embedded dispatch slots 0/2 and optionally assert process state. | +| 58 bytes | `1350:03cd, 1368:048a` | `Gump_DestroyCommonAndMaybeFree` | Exact matches include `usecode_debugger_gump_destroy`, `usecode_debugger_watch_pane_destroy`, and `usecode_debugger_source_pane_destroy`. Representative calls `GumpShared_DestroyCommon`, then conditionally frees the object. | +| 58 bytes | `1370:0093, 13c0:00c4` | `MainMenuOptionsMenuButtonGump_DrawLabel` | Exact match to the authored draw-label function; forwards gump data and object fields at `+0x35/+0x37/+0x39` to `FUN_1338_0109`. | +| 58 bytes | `1370:023b, 1370:0342` | `MainMenuOptionsPanelButtonGump_DrawLabel` | Exact match to the authored draw-label function; uses fields at `+0x39/+0x3b/+0x3d`. | +| 51 bytes | `1028:072b, 1098:0845` | `File_CloseAndMaybeFree` | Exact match to the authored helper: close file, then optionally free its wrapper. | +| 29 bytes | `1340:0668, 1388:078e` | `Object_InvokeVtableOffset10` | Exact matches include three usecode debugger pane event-forwarding functions. Representative dispatches through the function pointer at object offset `+0x10`. | +| 238 bytes | `1350:02df, 1368:039c` | `Text_DrawMultiline` | Identical multi-line text rendering: split at newline boundaries, measure each line, and draw the lines. | +| 207 bytes | `1298:0bf7, 1298:11f3` | `BufferCursor_ReadValue` | Exact byte copies of a buffered read helper. No direct callers or xrefs resolve; name intentionally avoids asserting a data width or owner. | +| 200 bytes | `1298:0b2d, 1298:0f79` | `BufferCursor_ReadValue` | Exact byte copies of a related buffered read helper. No direct callers or xrefs resolve; name intentionally avoids asserting a data width or owner. | +| 112 bytes | `12b0:03d1, 12c0:0283` | `LinkedCallbackChain_Destroy` | Invoke each node callback, advance through its links, then clear the head/tail fields. | +| 93 bytes | `12d0:0391, 12d0:0442` | `Debug_PrintPositionedMessageIfLevel` | Exact copies of a debug-print wrapper with a message-level threshold and positioned output. | +| 75 bytes | `12b0:0441, 12c0:02f3` | `LinkedList_GetNextAndTest` | Initialize from the head if empty, otherwise follow the current node's link; return whether a node remains. | +| 72 bytes | `10c0:0a46, 10c0:0da7` | `Item_IsWithinBounds` | Exact item-coordinate-in-bounds tests using `g_itemX`, `g_itemY`, and stored rectangle limits. | +| 61 bytes | `1268:008a, 1268:00c7` | `Rectangle_ContainsPoint` | Exact inclusive rectangle containment tests over four bounds. | +| 53 bytes | `1068:04f1, 1070:1bc9` | `Object_Call1068_02e2_ThenMaybeFree` | Exact copies of a null-checked object cleanup that calls `FUN_1068_02e2` and conditionally frees the object. | +| 53 bytes | `12b0:04d7, 12c0:033e` | `LinkedList_CountNodes` | Exact linked-list length traversals. | +| 28 bytes | `1370:00cd, 1380:01e1` | `Object_SetField35TrueAndUpdate` | Set object field `+0x35` to 1 and call `FUN_1360_078d`. | +| 28 bytes | `1370:00e9, 1380:01fd` | `Object_SetField35FalseAndUpdate` | Set object field `+0x35` to 0 and call `FUN_1360_078d`. | +| 79 bytes | `1090:0afe` | `Process_DestroyEmbeddedDispatchEntries` | Exact match to 11 authored-name process destructors, including `MapJumpProcess_Destroy`, `FadeProcess1_Destroy`, `AnimProcess_Destroy`, and `SnapProcess_Destroy`; same embedded dispatch-entry cleanup as the Code30 group. | +| 84 bytes | `1448:3221` | `Process_DestroyEmbeddedDispatchEntries` | Exact match to four authored-name process destructors, including `DumbTimerProcess_Destroy`, `CycleProcess_Destroy`, `FadeProcAlt_Destroy`, and `FlicWaitProcess_Destroy`. | +| 27 bytes | `11c0:072d` | `Object_InvokeVtableOffset8` | Exact matches to `AnimOneFrameDelayProcess_Run` and `FlicWaitProcess_Run`; indirect virtual call through function-pointer offset `+8`. | +| 72 bytes | `1230:00e6` | `Palette_Free` | Exact match to the authored helper: free the contained allocation, clear its pointer, and optionally free the wrapper. | +| 58 bytes | `13e8:3f49` | `BaseCameraProcess_VtableSlot11FreeBuffer` | Exact match to the authored helper; invoke `FUN_12b0_003d`, then optionally free the object. | +| 36 bytes | `1000:7ac6` | `memcpy` | Exact match to authored `memcpy`; copies words, handles an odd trailing byte, and returns the destination. | + +The two buffered-read groups have no direct callers or xrefs, so their names avoid asserting element width or owner. All 100 duplicate-group renames applied with zero failures; post-rename signature verification found no remaining auto-named member in these 30 groups. The per-block table remains a pre-rename snapshot. + +### Batch 9: Code1 runtime and DOS helpers (`1000`) + +- `1000:0164` -> `CallbackQueue_RunHighestPriorityPass_1000_0164`: one-call wrapper to `1000:01f7`. +- `1000:018a` remains `FUN_1000_018a`: pushes `0`, `CS:0x181`, and `DS:0x5d`, then calls imported `Ordinal_89` at `1488:0070`. `CallOrdinal89` also invokes it from the exit path. The 1994 Phar Lap SDK's `PHAPI.H` contains named API declarations but no ordinal-to-service map, so the service identity remains unresolved. +- `1000:01b3` -> `CallbackQueue_RunLowestPriorityFirst_1000_01b3`: walks six-byte callback records, chooses the lowest non-disabled priority byte at `+1`, marks the record disabled, invokes its near/far callback at `+2`, and repeats. +- `1000:01f7` -> `CallbackQueue_RunHighestPriorityFirst_1000_01f7`: same record/callback mechanism, selecting the highest priority byte first. Direct callers are `1000:0164` plus its own repeat-dispatch branches. +- `1000:0238` -> `DOS_WriteStderr_1000_0238`: invokes DOS `INT 21h`, function `40h`, with handle 2; writes `CX` bytes from `DS:DX`. +- `1000:0240` was initially left unnamed because Ghidra reports a body from `1000:0240` through `1000:2aa0` with bad/overlapping instruction data. After tracing startup, allocation, and fatal-output callers, Batch 23 named it `runtime_fatal_error_exit_1000_0240`; its unreliable body boundary remains unchanged. +- `1000:2bf2` remains `FUN_1000_2bf2`: called from `1000:0240`; decompilation mixes implicit registers with a divide-error message buffer, and the reported function body begins before its entry point. Its role remains unresolved. +- `1000:3138` -> `DOS_GetDefaultDrive_1000_3138`: calls `dos_get_default_drive` and returns the drive number. +- `1000:3163` -> `DOS_GetFileAttributes_1000_3163`: DOS `INT 21h`, `AX=4300h`; returns attributes from `CX` through the output pointer, or dispatches errors through `FUN_1000_83ec`. +- `1000:3183` -> `DOS_SetFileAttributes_1000_3183`: DOS `INT 21h`, `AX=4301h`, passing the path in `DS:DX` and attributes in `CX`; dispatches errors through `FUN_1000_83ec`. + +All seven renames applied with zero failures and were verified at their addresses. The three entries left auto-named are held back for explicit evidence gaps rather than treated as identified functions. + +### Batch 10: Code1 runtime and DOS helpers (`1000`) + +- `1000:31ed` -> `NoOp_1000_31ed`: one-byte `RETF`, with no additional behavior. +- `1000:32d0` -> `DOS_GetDateWords_1000_32d0`: DOS `INT 21h`, `AH=2ah`; stores the returned year (`CX`) and month/day (`DX`) to the caller's output buffer. Used by `dos_get_datetime_words`. +- `1000:32e3` -> `DOS_GetTimeWords_1000_32e3`: DOS `INT 21h`, `AH=2ch`; stores the returned hour/minute (`CX`) and second/hundredths (`DX`) to the output buffer. Also used by `dos_get_datetime_words`. +- `1000:332f` -> `DOS_GetDriveAllocationInfo_1000_332f`: far thunk that pushes the two output pointers and a zero drive selector before calling `dos_get_drive_allocation_info` at `1000:3344`. +- `1000:338b` -> `SignedLongDivideNear_1000_338b`: near-call veneer that adjusts the return frame before entering the shared signed 32-bit division engine. +- `1000:338e` -> `SignedLongDivideFar_1000_338e`: far-call entry for signed quotient mode; this was previously mislabeled `random_something` despite implementing the shared divide engine. +- `1000:3395` -> `UnsignedLongDivideFar_1000_3395`: far-call entry selecting unsigned quotient mode; callers include `Kernel_11d0_2a86`, `UProcess_1420_062f`, and `usecode_debugger_source_buffer_load_text`. +- `1000:339a` -> `SignedLongRemainderNear_1000_339a`: near-call veneer that adjusts the return frame before entering signed remainder mode. +- `1000:339d` -> `SignedLongRemainderFar_1000_339d`: far-call entry for signed remainder mode; callers include `KeypadGump_CheckCode` and `Interpreter_NextUsecodeOp`. +- `1000:34a1` -> `Stack_AllocateAndCopyBytes_1000_34a1`: reserves `param_2` bytes on the stack, then copies that many bytes from the far source pointer `param_1` into the reserved area. Multiple callers use the helper, including `Filespec_1238_032e`, `AutoFirerProcess_OnTimer`, and `AnimPrimitiveProcess_Run`. +- `1000:34c2` -> `DOS_HandleIsDevice_1000_34c2`: DOS `INT 21h`, `AX=4400h` for the supplied handle; returns the device bit (`DX & 0x80`). Called from `open_stream_with_mode`. + +All ten renames applied with zero failures and were verified at their live addresses. Disassembly and call sites confirm the near/far veneers and the signed-quotient, unsigned-quotient, and signed-remainder mode flags; these entries share the core at `1000:33a8`. + +### Batch 11: Code1 runtime, temporary-file, RNG, and DOS helpers (`1000`) + +- `1000:34d3` -> `format_long_as_ascii_base_1000_34d3`: converts a 32-bit value to digits for radix 2 through 36, with caller-selected alphabet and optional sign handling. The existing `itoa` wrapper and the decimal-formatting helper support this role. +- `1000:3555` -> `format_unsigned_long_decimal_1000_3555`: formats a 32-bit value as unsigned decimal text. It is used by the temporary-filename builder to append its numeric component. +- `1000:359e` -> `build_temp_filename_1000_359e`: copies a prefix (default `TMP`), appends a decimal counter, then appends a suffix into the selected output buffer. The collision probe and temporary-file cleanup path use it; the exact suffix text is not recorded here. +- `1000:35fb` -> `find_unused_temp_filename_1000_35fb`: advances a counter, builds a candidate path, and repeats while `DOS_GetFileAttributes` succeeds. It returns after the helper reports an error; the precise DOS error policy beyond that remains unresolved. No direct callers were recovered. +- `1000:3654` -> `set_memory_retry_callback_1000_3654`: stores a callback pointer and companion word in globals read by the allocation-retry path, and returns the previous callback pointer. No direct callers were recovered. +- `1000:36c0` -> `retry_memory_allocation_with_callback_1000_36c0`: retries the memory-manager allocation helper and invokes the configured callback between failed attempts. The returned high-word/status representation is not fully resolved, so the name describes only the verified loop behavior. +- `1000:3764` -> `gameplay_lcg_seed_from_word_1000_3764`: stores the supplied word as the low part of the gameplay RNG state and clears its high word. No direct callers were recovered. +- `1000:3775` -> `gameplay_lcg_next_15bit_1000_3775`: advances the state using the local multiply/add step and returns the high 15 bits. Callers span item damage/explosion, attacks, pathfinding, and other gameplay code. `docs/raw-porting-progress.md` describes a separate raw seg091 RNG state; no raw-address/name mapping is asserted for this helper. +- `1000:3cbe` -> `NoOp_1000_3cbe`: an empty function called three times by `vsscanf_number_parser`. +- `1000:4007` -> `dos_get_file_size_by_handle_1000_4007`: calls the DOS seek helper with a zero offset and returns its result; `File_1228_0909` consumes that result as the file extent before choosing a seek position, and `File_1228_0962` delegates through that path. + +All ten names were applied successfully and then verified by querying each live address. The temporary-file, allocation-retry, and file-size roles are grounded in their callers; unresolved error-code and return-value details remain intentionally conservative. + +### Batch 12: Code1 character, formatter, and video helpers (`1000`) + +- `1000:4021` -> `ascii_toupper_1000_4021`: preserves `0xffff`; otherwise indexes the character classification table and subtracts `0x20` when the table marks the byte as lowercase. Callers include save-name input and usecode-debugger expression formatting. +- `1000:4065` was initially left unnamed because no callers or owner context were recovered. Batch 23 named it `runtime_array_cleanup_and_free_1000_4065` after confirming reverse-order callback dispatch and conditional backing-allocation release. +- `1000:457a` -> `format_packed_bcd_byte_1000_457a`: converts the packed-BCD argument used by the custom format parser into ASCII output. +- `1000:45b9` -> `format_output_append_char_1000_45b9`: writes one pending byte to the formatter's output buffer, invokes its callback when the buffer fills, and updates the output position. +- `1000:45c2` -> `format_flush_output_buffer_1000_45c2`: sends the buffered bytes through the formatter callback, then resets the buffer state and advances the output position. Both helpers are called by the variadic parser at `1000:47e9`. +- `1000:4a55` -> `video_text_cell_address_1000_4a55`: computes a far word address from the current text-grid base, row, and column globals. +- `1000:4a7a` -> `video_aware_memmove_words_1000_4a7a`: performs overlap-aware word copying; in active video mode it synchronizes copies against VGA status-port transitions. +- `1000:4af4` -> `copy_c_string_return_end_1000_4af4`: copies a NUL-terminated string and returns the address of its terminator. The temporary-filename helper is its recovered caller. +- `1000:4b28` -> `video_mode_setup_wrapper_1000_4b28`: invokes the display-layout helper with global geometry and then sets the VGA video mode. The title/configuration-screen routine at `1048:025b` calls it. +- `1000:4b51` -> `video_update_control_bits_1000_4b51`: replaces bits `0x8f` in a shared video-control byte while preserving bits `0x70`; called by the display setup routine at `1048:025b`. + +Nine names applied successfully and were verified at their live addresses; `1000:4065` remains intentionally unresolved pending caller/owner evidence. + +### Batch 13: Code1 text console, rectangle, and DOS helpers (`1000`) + +- `1000:4b66` -> `text_attr_set_background_1000_4b66`: replaces text-attribute bits `0x70` from the low three bits of its argument, preserving foreground/blink bits. +- `1000:4b7f` -> `text_attr_set_1000_4b7f`: stores the complete text-attribute byte. No callers were recovered. +- `1000:4b9d` -> `video_console_write_chars_1000_4b9d`: writes a character range using the current text attribute, handles control characters including line advance and carriage return, and scrolls the active text region when needed. +- `1000:4ccf` -> `video_console_printf_1000_4ccf`: variadic formatted-output wrapper around the console character writer. +- `1000:4cf0` -> `scanf_float_formats_not_linked_fatal_1000_4cf0`: writes the diagnostic `scanf: floating point formats not linked` to DOS handle 2, then jumps to the fatal-report path. +- `1000:4d68` -> `video_set_cursor_if_in_bounds_1000_4d68`: checks a requested cursor position against the active text bounds before issuing the BIOS video operation. Callers include the title/configuration screen and positioned debug output. +- `1000:4db1` -> `video_text_rect_copy_to_buffer_1000_4db1`: validates a text-grid rectangle and copies its rows from video memory to a linear buffer. +- `1000:4e07` -> `video_text_rect_copy_from_buffer_1000_4e07`: validates a text-grid rectangle and copies rows from a linear buffer to video memory. +- `1000:4e5d` -> `dos_get_stdin_status_or_ready_1000_4e5d`: returns DOS `INT 21h` function `0Bh` standard-input status unless a global override is set, in which case it returns 1. Called by `MemoryInitializeManager`. +- `1000:4e6f` -> `video_move_text_rectangle_1000_4e6f`: validates source and destination rectangles, then copies rows in overlap-safe order within the text grid. + +All ten names were applied and verified at their live addresses. The fixed diagnostic text at `1478:6f29` and the copy helper's source/destination behavior were checked directly. + +### Batch 14: Code1 text-grid memory and timing helpers (`1000`) + +- `1000:4f0c` -> `video_console_put_single_char_1000_4f0c`: forwards one stack-supplied character to the console writer. No direct callers were recovered; the body is consistent with a one-character callback. +- `1000:4f33` -> `video_text_offset_to_row_column_1000_4f33`: converts a byte offset into a text-grid row and column using the current row width. It is used by the mixed-memory copy helper. +- `1000:4f6b` -> `video_advance_text_cursor_1000_4f6b`: advances the text cursor column, wraps at the configured width, and synchronizes the video mode when the cursor state changes. +- `1000:4f9f` -> `video_copy_words_mixed_memory_1000_4f9f`: copies words between pointers when either side may be video memory, using the cursor and mode helpers for hardware-backed access. +- `1000:5069` -> `video_text_memmove_words_1000_5069`: dispatches word moves to the VGA-aware copy path when active video memory is available, otherwise to the mixed-memory fallback. +- `1000:50a5` -> `video_text_rect_is_in_bounds_1000_50a5`: validates ordered text-grid rectangle bounds against configured width and height. Used by the rectangle copy/move routines. +- `1000:50fa` -> `video_fill_text_buffer_with_spaces_1000_50fa`: fills a linear word buffer with spaces carrying the current text attribute. +- `1000:511c` -> `video_adjust_text_viewport_1000_511c`: updates/redraws the active text viewport using rectangle moves, row copies, and space-filled staging when the window scrolls; otherwise it refreshes the video mode. +- `1000:52e0` -> `dos_wait_seconds_precise_1000_52e0`: waits for the requested number of DOS second transitions, then waits until the hundredths field reaches the starting threshold. Its recovered caller is `Flicplay_CreateFlicProcess`. +- `1000:5349` -> `video_set_mode_and_reset_text_attr_1000_5349`: selects the requested (or default) VGA mode, lets the mode helper refresh geometry and video-memory state, then restores the default text attribute. + +All ten names applied successfully and were verified at their live addresses. The window/copy names describe observed local operations, not a higher-level UI owner. + +### Batch 15: Code1 file and buffered-stream helpers (`1000`) + +- `1000:5368` -> `video_get_cursor_position_1000_5368`: issues the BIOS cursor-position query and returns the packed cursor coordinates used by the text-console routines. +- `1000:541a` -> `dos_set_file_readonly_from_flags_1000_541a`: reads a file's DOS attributes and sets or clears the read-only bit according to the supplied flag. Called by two file-object helpers. +- `1000:5481` -> `dos_extend_file_with_zero_fill_1000_5481`: compares the requested extent with the current file size and writes zero blocks when extending; `File_1228_0909` then seeks to the requested position or prior end. +- `1000:5605` -> `stream_close_and_remove_temp_file_1000_5605`: releases an owned buffer, closes the DOS handle, resets the stream state, and removes its temporary backing file when present. +- `1000:578a` -> `stream_read_bounded_token_1000_578a`: reads and NUL-terminates a token into a caller buffer, bounded by the caller capacity and ten bytes. `UProcess_1420_062f` uses it while scanning process-symbol records. +- `1000:58c8` -> `filespec_parse_components_1000_58c8`: wrapper to the shared path parser at `1000:6c73`; the `Filespec_1238_032e` caller supplies the component output buffers before recomposing the normalized path. +- `1000:5d9f` -> `stream_sync_position_and_newline_state_1000_5d9f`: synchronizes a buffered stream with its DOS file position, handles the special end-relative case, and refreshes buffered newline state. No direct callers were recovered. +- `1000:5f0a` -> `stream_normalize_all_buffer_slots_1000_5f0a`: scans the 20 stream slots and normalizes/refills entries carrying the `0x300` state bits. +- `1000:5f48` -> `stream_refill_buffer_1000_5f48`: reads into the stream's buffer, updates cursor/count and status bits, and reports EOF/error through the stream flags. +- `1000:5fc0` -> `stream_read_next_byte_1000_5fc0`: advances the stream cursor and delegates to the buffered byte reader at `1000:5fd8`. + +All ten names were applied and verified at their live addresses. `1000:5d9f` retains an address-qualified behavioral name because no direct caller was recovered. + +### Batch 16: Code1 DOS paths, file-open, and stream-write helpers (`1000`) + +- `1000:5fd8` -> `stream_read_buffered_byte_1000_5fd8`: returns the next buffered byte, refilling through the DOS-read path as needed and setting EOF/error state when no byte is available. +- `1000:60d2` -> `dos_get_current_directory_alloc_1000_60d2`: builds the current-drive root and current-directory path, allocating a caller-sized buffer when none is supplied. +- `1000:6160` -> `dos_get_drive_current_directory_alloc_1000_6160`: performs the same path construction for a requested drive, using the default drive when the drive selector is zero. +- `1000:629a` -> `format_long_as_ascii_base_1000_629a`: thin adapter to the shared long-to-base formatter, forwarding caller register options and output/value arguments. No direct callers were recovered. +- `1000:62b7` -> `format_long_base_signed_decimal_1000_62b7`: shared formatter adapter that enables signed handling for base 10 and uses unsigned handling for other bases. No direct callers were recovered. +- `1000:63c0` -> `memmove_far_1000_63c0`: far-pointer `memmove` wrapper; area-search and item-find routines use it for overlapping copies. +- `1000:63e1` -> `dos_create_file_with_attributes_1000_63e1`: DOS `INT 21h/AH=3Ch` create-file wrapper with DOS error dispatch. +- `1000:63fc` -> `dos_truncate_file_at_current_position_1000_63fc`: DOS `INT 21h/AH=40h` zero-byte write on the supplied handle, truncating at its current position. +- `1000:640e` -> `open_stream_with_dos_mode_1000_640e`: opens or creates a DOS file according to runtime mode bits, configures device/append/truncate state, and records stream flags. Called by `open_stream_with_mode`. +- `1000:65e7` -> `stream_put_char_1000_65e7`: decrements the stream's buffered count and delegates the character write to the common output routine at `1000:6603`. + +All ten names applied successfully and were verified at their live addresses. The DOS create and truncate wrappers were confirmed from the surrounding instruction/register setup. + +### Batch 17: Code1 stream writing, Filespec parsing, and formatting (`1000`) + +- `1000:6603` -> `stream_write_byte_1000_6603`: writes one character through the stream buffer or DOS handle, supports append mode, and translates newline output for text streams. +- `1000:6798` -> `stream_write_char_to_static_stream_1000_6798`: forwards a character to the statically allocated stream record at `1000:6c46`. No direct callers were recovered. +- `1000:67ac` -> `stream_write_block_1000_67ac`: writes a byte block using stream buffering or direct DOS I/O and returns the completed count. Its recovered caller is `fwrite_buffered`. +- `1000:69af` -> `dos_read_file_with_text_translation_1000_69af`: reads DOS file bytes and, for text streams, handles CR/LF translation and Ctrl-Z EOF while correcting the underlying file position. +- `1000:6a9d` -> `stream_initialize_buffer_1000_6a9d`: validates and initializes a stream record, closes/releases prior state, and optionally allocates/configures its buffer and mode. +- `1000:6bba` -> `copy_string_bounded_1000_6bba`: copies a string up to the supplied capacity and always writes a terminating NUL when a destination exists. +- `1000:6c13` -> `filespec_path_tail_delimiter_check_1000_6c13` (Batch 23): dispatches on NUL, `/`, `:`, or `\\`; the colon case also checks the preceding byte. The adjacent filespec parser supports the path-tail role. +- `1000:6c73` -> `filespec_parse_components_core_1000_6c73`: trims leading spaces, copies at most 80 characters, and dispatches on the final path character to populate component outputs. The Filespec caller and wrapper at `1000:58c8` support this role. +- `1000:6e93` -> `format_buffer_append_callback_1000_6e93`: appends formatted bytes to the output buffer, advances its offset, and maintains a NUL terminator. +- `1000:6ed3` -> `sprintf_to_buffer_1000_6ed3`: initializes an output buffer and runs the shared formatter with the append callback and caller's variadic arguments. + +Nine names were applied and verified; `1000:6c13` remains unresolved pending evidence for its dispatch table. + +### Batch 18: Code1 string scanning, formatting, and comparison (`1000`) + +- `1000:6ef5` -> `vsprintf_to_buffer_1000_6ef5`: resets the destination buffer and runs the shared formatter using an explicit variadic-argument pointer and the buffer-append callback. +- `1000:6f16` -> `string_scan_next_char_1000_6f16`: reads and advances one byte from the scanner cursor, returning `0xffff` at the terminating NUL. No direct callers were recovered. +- `1000:6f3e` -> `string_scan_unget_char_1000_6f3e`: backs up the scanner cursor by one byte. No direct callers were recovered. +- `1000:6f6c` -> `sscanf_far_string_1000_6f6c` (Batch 23): passes the string scanner callbacks and caller format/varargs to `vsscanf_engine`; the nearby floating-point message is an engine diagnostic, not a fixed wrapper format. +- `1000:6fcf` -> `strcmp_far_1000_6fcf`: compares two far strings and returns the unsigned-byte difference at the first mismatch. +- `1000:6fff` -> `strcpy_far_1000_6fff`: copies the source string including its NUL terminator and returns the destination. +- `1000:7088` -> `ascii_lowercase_string_in_place_1000_7088`: converts uppercase ASCII letters to lowercase in place. Used by config loading and typename lookup. +- `1000:70ac` -> `strncpy_zero_padded_far_1000_70ac`: copies up to the requested count and pads the remainder with NUL bytes. +- `1000:70dd` -> `ascii_strnicmp_1000_70dd`: compares at most the requested number of bytes, folding lowercase ASCII to uppercase before comparison. +- `1000:7121` -> `strstr_far_1000_7121`: searches a far string for a non-empty substring and returns the match pointer or null. Callers include Filespec/path, process-symbol, and typename handling. + +Nine names applied and verified; `1000:6f6c` remains unresolved pending format/caller evidence. + +### Batch 19: Code1 numeric parsing, timezone, and stream lifecycle (`1000`) + +- `1000:718f` -> `number_scan_next_char_1000_718f`: reads and advances one byte in the integer scanner, returning `-1` at NUL. No direct callers were recovered. +- `1000:71b6` -> `number_scan_unget_char_1000_71b6`: backs up the integer scanner cursor by one byte. No direct callers were recovered. +- `1000:71c1` -> `scan_signed_integer_from_string_1000_71c1`: skips leading whitespace, parses a signed integer through the shared scanner, reports conversion errors, and optionally returns the advanced input pointer. Used by process-symbol parsing. +- `1000:72a5` -> `ascii_uppercase_string_in_place_1000_72a5`: converts lowercase ASCII letters to uppercase in place. Called while opening video media files. +- `1000:72c9` -> `dos_datetime_to_epoch_seconds_1000_72c9`: converts DOS date/time fields to the runtime epoch representation, applying the configured timezone and daylight-saving adjustment. +- `1000:73f3` -> `epoch_seconds_to_dos_datetime_1000_73f3`: converts the runtime epoch value back to DOS date/time fields, including timezone and daylight-saving adjustment. +- `1000:75f7` -> `timezone_initialize_from_environment_1000_75f7`: parses the `TZ` environment variable or applies the built-in `EST`/`EDT` defaults, then stores timezone and daylight-saving state. +- `1000:77e5` -> `timezone_is_daylight_saving_1000_77e5`: evaluates the configured month/week/day transition rules for a supplied local date/time. +- `1000:78c4` -> `dos_write_file_with_text_translation_1000_78c4`: writes bytes to a DOS handle and inserts carriage returns before newlines for text-mode streams. +- `1000:7a51` -> `stream_close_all_open_1000_7a51`: scans the stream table and closes entries marked open or active. + +All ten names were applied and verified at their live addresses. The case-conversion direction for `1000:7088` was corrected after checking the exact ASCII range test. + +### Batch 20: Code1 compiler heap manager (`1000`) + +- `1000:7ac6` was already named `memcpy_1000_7ac6`: copies the requested bytes, including an odd trailing byte, and returns the destination. +- `1000:7c04` -> `heap_free_and_coalesce_block_1000_7c04`: marks a block free, coalesces adjacent free neighbors, inserts the result in the free list when needed, and refreshes heap state. +- `1000:7c49` -> `heap_initialize_free_list_1000_7c49`: clears the heap metadata and initializes the free-list head through the block allocator. +- `1000:7c80` -> `heap_insert_free_block_1000_7c80`: inserts a newly freed block into the doubly linked free list. +- `1000:7ca6` -> `heap_allocate_from_free_list_1000_7ca6`: finds a suitable free block, splits or unlinks it, and refreshes heap state. +- `1000:7d14` -> `heap_resize_block_in_place_1000_7d14`: resizes an allocation in place by splitting its tail or merging a following free block. +- `1000:7dcb` -> `heap_copy_realloc_payload_1000_7dcb`: copies the retained payload from the old block into the replacement allocation. Called by the realloc wrapper at `1000:8023`. +- `1000:7df0` -> `heap_walk_allocated_block_chain_1000_7df0`: follows physical block sizes from the heap base until it reaches a free block or the end sentinel. +- `1000:7e01` -> `heap_largest_free_block_size_1000_7e01`: walks the free list and returns the largest free payload size in `DX`. +- `1000:7e30` -> `heap_release_block_and_update_region_map_1000_7e30`: frees the block and updates the manager's segment/region index; used by the malloc/realloc wrappers. + +Nine names were applied and verified; the existing `memcpy_1000_7ac6` symbol was left unchanged. + +### Batch 21: Code1 heap wrappers and video-mode helpers (`1000`) + +- `1000:7e77` -> `heap_allocate_with_region_growth_1000_7e77`: searches existing regions for a fitting free block, requests a first region or grows the heap when needed, then retries allocation. +- `1000:7ef9` -> `heap_allocate_far_region_1000_7ef9` (Batch 24): invokes `Ordinal_40` for the far-region allocation path; the import identity remains unknown. +- `1000:7f34` -> `heap_initialize_first_region_1000_7f34`: requests an initial region, reducing the requested size on failure, and initializes its free-list metadata when successful. +- `1000:7f8d` -> `heap_grow_region_1000_7f8d`: requests an additional region and initializes its free-list metadata on success. +- `1000:7fc7` -> `heap_try_resize_in_place_1000_7fc7`: attempts to resize an existing allocation in place, or releases it when the requested size is zero. +- `1000:8023` -> `heap_reallocate_1000_8023`: handles realloc's null/zero cases, tries in-place resizing, then allocates, copies the retained payload, and releases the old block. +- `1000:8091` -> `heap_reallocate_far_region_1000_8091` (Batch 24): handles null/zero-size cases locally and delegates nonzero region resizing to `Ordinal_42`; the import identity remains unknown. +- `1000:80d9` -> `string_has_prefix_1000_80d9`: returns true when its first string argument is a prefix of the second. +- `1000:8108` -> `video_query_ega_configuration_1000_8108`: issues BIOS video service `INT 10h/AH=12h, BL=10h` to query extended EGA configuration. +- `1000:81a5` -> `video_initialize_from_current_mode_1000_81a5`: queries the active video mode, initializes mode-dependent state, and stores the masked BIOS display-status value. + +Eight names were applied and verified. The two wrappers involving `Ordinal_40` and `Ordinal_42` remain unresolved pending import semantics or stronger call-site evidence. + +### Batch 22: Code1 stream, video, and support helpers (`1000`) + +- `1000:7a8e` -> `stream_normalize_four_open_buffers_1000_7a8e`: scans four stream records and invokes the existing buffer flush/reset helper for entries with active read/write flags. This entry had been missed between the Batch 19 endpoint and the already named `memcpy` at `1000:7ac6`. +- `1000:81c6` -> `video_initialize_display_state_1000_81c6`: reconciles the requested and current BIOS video modes, detects display characteristics, selects the framebuffer segment, and resets text cursor state. +- `1000:8322` -> `runtime_coreleft_bytes_1000_8322`: computes the long value used by the debugger's `*M` expression, displayed as `Coreleft: %ld`. +- `1000:8351` -> `far_pointer_advance_1000_8351`: near-call adapter for the far-return pointer-advance helper at `1000:8356`; buffered read/write loops use it between chunks. +- `1000:8356` -> `far_pointer_advance_impl_1000_8356`: advances a far buffer pointer between buffered I/O chunks. +- `1000:83a0` -> `compare_unsigned_32bit_values_1000_83a0`: compares two unsigned 32-bit values and returns whether the first is less; called by `memmove`. +- `1000:83ec` -> `dos_error_status_passthrough_1000_83ec`: records the DOS error through `dos_error_1000_83a7` and returns the original status. Used by file-attribute wrappers. + +Seven names were applied and verified. The adjacent `dos_ioctl` at `1000:82d7` and `dos_error_1000_83a7` were already named. + +### Batch 23: Code1 runtime failure, array cleanup, and scanner helpers (`1000`) + +- `1000:0240` -> `runtime_fatal_error_exit_1000_0240`: startup, allocation, and unsupported-float error paths converge here; it writes the fixed stderr message and calls the runtime exit wrapper. Its live function body still spans `1000:0240`–`1000:2aa0` and includes overlapping/bad instruction data, so the boundary was not changed. +- `1000:2bf2` remains `FUN_1000_2bf2`: its only apparent call is inside the malformed `0240` body. Ghidra reports a body beginning at `1000:2b40`, while the entry at `2bf2` is a jump to `2b80`; boundary analysis did not identify a reliable standalone extent. +- `1000:4065` -> `runtime_array_cleanup_and_free_1000_4065`: dispatches cleanup callbacks across array elements in reverse order, then conditionally frees the backing allocation and header. No direct callers were recovered. +- `1000:6c13` -> `filespec_path_tail_delimiter_check_1000_6c13`: dispatches on NUL, `/`, `:`, or `\\`; the colon case additionally checks a preceding byte. The adjacent filespec parser supports the path-tail interpretation. +- `1000:6f6c` -> `sscanf_far_string_1000_6f6c`: supplies the far-string get/unget callbacks and caller format/varargs to `vsscanf_engine`; the nearby floating-point diagnostic is emitted by the engine, not a fixed wrapper format. + +Four names were applied and verified. The remaining exact-name entries are `1000:018a`, `1000:2bf2`, `1000:7ef9`, and `1000:8091`. + +### Batch 24: Code1 far-region heap wrappers (`1000`) + +- `1000:7ef9` -> `heap_allocate_far_region_1000_7ef9`: the null-region allocation path calls imported `Ordinal_40` and returns the resulting far region on success; failure returns a null far pointer. The import itself remains unidentified. +- `1000:8091` -> `heap_reallocate_far_region_1000_8091`: allocates through `7ef9` when the old region is null, releases through `heap_release_block_and_update_region_map_1000_7e30` for a zero-size request, and delegates nonzero resizing to imported `Ordinal_42`. The import itself remains unidentified. +- `Ordinal_40` is referenced only by the first-region and far-region allocation paths; `Ordinal_42` is referenced by heap growth and far-region resizing. Local extender notes and the import table expose no service names. +- `Ordinal_89` is called from startup and from the exit lifecycle wrapper, but its service contract remains unknown; keep `1000:018a` unnamed. + +Two exact-name entries remain: `1000:018a` and `1000:2bf2`. + +### Batch 25: Image records and palette conversion (`1008`) + +- `1008:0032` -> `resource_image_record_allocate_and_load_1008_0032`: allocates a `0x43a`-byte image record when passed a null buffer, loads the file into it, and returns the record. No direct callers were recovered. +- `1008:0098` -> `resource_image_record_open_and_read_1008_0098`: opens a resource image file, reads its 14-byte file header and fixed `0x428`-byte record payload, and stores the open file handle in the record. Used by HelpGump and Credits loading. +- `1008:0167` -> `resource_image_read_rows_into_vport_1008_0167`: seeks to the image data offset and reads the declared row count into successive VPort scanlines using the row-byte count in the record. Used by HelpGump and Credits. +- `1008:01eb` -> `resource_palette_rgb_to_vga6_1008_01eb`: converts 256 four-byte palette records into 768 VGA RGB components by shifting each channel right two bits, then HelpGump applies the result through `Palette_SetVideoCardPalette`. +- `1008:028c` -> `resource_palette_triplet_alloc_callback_1008_028c`: allocation callback that preserves a non-null pointer or allocates a three-byte RGB triplet; passed by the palette conversion helper for its 256 output entries. + +All five names were applied and verified. The live `FUN_1008_` search returned no remaining auto-named functions. + +### Batch 26: Tile area search and item overlap (`1010`) + +- `1010:0032` -> `AreaSearch_FindItemAtWorldPosition_1010_0032`: converts world X/Y to tile coordinates and Z to the corresponding vertical unit, then searches the single containing tile. +- `1010:0061` -> `AreaSearch_FindItemAtTilePosition_1010_0061`: searches the single tile at the supplied tile coordinates and Z. +- `1010:007d` -> `AreaSearch_FindItemInTileRect_1010_007d`: converts an inclusive tile rectangle and Z range to world-coordinate bounds before calling `AreaSearch_FindItemContainedInRange`. +- `1010:02de` -> `Item_CheckSolidDamageOverlap_1010_02de`: gathers nearby items in the source item's bounds, filters by XY/Z overlap, combines solid/damaging masks from `ShapeData_GetDamagingAndSolidFlags`, and tests for a relevant overlap. + +All four names were applied and verified. The live `FUN_1010_` search returned no remaining auto-named functions. + +### Batch 27: Xformpal lifecycle and animation render state (`1028`, `1030`) + +- `1028:0216` -> `Gamepal_CloseXformpalAndMaybeFree_1028_0216`: releases the Xformpal resource state when present and optionally frees the outer record when flag bit 0 is set. +- `1028:02dc` -> `Gamepal_ReleaseXformpalResources_1028_02dc`: frees the owned transformed-palette buffer, clears stored pointers, and invokes the palette reader object's cleanup slot before clearing that reference. +- `1028:040a` -> `Gamepal_InvokeResourceReaderVfunc10_1028_040a`: calls virtual slot `+0x10` on the resource-reader object stored in the record; no direct callers were recovered, so the slot's higher-level purpose remains open. +- `1030:02a5` -> `AnimProcess_BeginRenderStateUpdate_1030_02a5`: sets the animation-process byte flag at `+0x54` before the camera render pass. +- `1030:02b2` -> `AnimProcess_CommitRenderStateAndClearFlag_1030_02b2`: copies the current animation-list pointer from `+0x40` to the published list at `+0x44`, then clears the `+0x54` flag. The published list is consumed by `DList_AnimateShapes`. + +All five names were applied and verified. The live `FUN_1028_` and `FUN_1030_` searches returned no remaining auto-named functions. + +### Batch 28: Gravity, runtime startup, and item trajectory (`1038`, `1040`, `1048`) + +- `1038:1131` -> `GravityProcess_CheckDownwardSweep_1038_1131`: probes the item's current XY at an adjusted Z when gravity is downward or canceled; returns true when the sweep fails and gravity should stop early. Called by `GravityProcess_Run`. +- `1040:0079` -> `Runtime_InitializeCommandLineAndRunLoop_1040_0079`: initializes command-line state, then enters the extender timer/event loop with the startup callback. +- `1040:00a6` -> `Item_BuildHurlTrajectoryParams_1040_00a6`: computes horizontal step velocities and vertical acceleration for a hurl trajectory; called by `ItemIntrinsic08A` before `Item_HurlWithParams`. +- `1040:039e` -> `Filespec_CopyCandidateIfExists_1040_039e`: resolves a candidate filename under the supplied path and copies the candidate back only when the resolved file exists. No direct callers were recovered. +- `1048:01dc` -> `Runtime_InitializeAndHandleCommandLine_1048_01dc`: initializes the runtime command-line object, displays its startup banner, processes command-line arguments, then invokes the object's final virtual method. +- `1048:025b` -> `Runtime_DrawStartupBanner_1048_025b`: configures text video and prints the startup title, violence-mode variant, and copyright banner. + +All six names were applied and verified. The live `FUN_1038_`, `FUN_1040_`, and `FUN_1048_` searches returned no remaining auto-named functions. + +### Batch 29: Item-cache allocation, compaction, and validation (`1060`) + +- `1060:02a1` -> `ItemCache_ClearTypeCallbacks_1060_02a1`: clears the four-byte callback-table slot selected by a cache type ID; called by the type-registration object's destructor. +- `1060:0474` -> `ItemCache_AllocateBlock_1060_0474`: allocates a typed cache block, splitting/relinking a free block as needed and updating block and byte accounting. +- `1060:0705` -> `ItemCache_ReleaseBlock_1060_0705`: invokes the type release callback, clears the handle-table entry, and returns the block to the cache free list. +- `1060:091a` -> `ItemCache_ReleaseDataPointer_1060_091a`: converts a data pointer back to its cache-block header and releases the block. +- `1060:0943` -> `ItemCache_MakeRoom_1060_0943`: reclaims cache space by releasing blocks and coalescing free areas until the requested allocation can fit. +- `1060:0ecf` -> `ItemCache_CoalesceFreeBlock_1060_0ecf`: merges a neighboring free-block header into the current block and updates list links and cache totals. +- `1060:0fc0` -> `ItemCache_MoveBlockBackward_1060_0fc0`: relocates a block's contents toward a lower cache address, updates its handle entry, and notifies its type callback. +- `1060:10ba` -> `ItemCache_RelocateBlock_1060_10ba`: moves a block into the adjacent available region, repairs links and accounting, and notifies the type callback of the new data address. +- `1060:1244` -> `ItemCache_ReleaseFirstBlockOfType_1060_1244`: scans the cache list and releases the first block matching the requested type. +- `1060:12ea` -> `ItemCache_ValidateInvariants_1060_12ea`: checks cache list structure, handle references, block types, and aggregate size/count accounting. +- `1060:18d2` -> `ItemCache_GetUsagePercent_1060_18d2`: returns used cache bytes as a percentage of total capacity. +- `1060:1c70` -> `ItemCache_LoadIndexFromStream_1060_1c70`: reads cache metadata and handle entries from a buffered stream, relocates embedded offsets, and closes the stream. +- `1060:1f43` -> `ItemCache_ResetIndexPointers_1060_1f43`: clears the cache base and three list-root pointers. + +All thirteen names were applied and verified. The live `FUN_1060_` search returned no remaining auto-named functions. + +### Batch 30: Cached resource access and typed-block lifecycle (`1068`) + +- `1068:026a` -> `ItemCache_GetSubentryDataPointer_1068_026a`: resolves a cached resource, indexes its eight-byte subentry table, and returns the far pointer for that entry's data. Font/glyph and menu-sprite callers confirm it is not limited to one resource type. +- `1068:02e2` -> `ItemCache_DestroyTypeCallbacks_1068_02e2`: invalidates the callback object's type tag, clears its per-type cache callback slot, and optionally frees the object. +- `1068:0452` -> `ItemCache_AllocateType7Block_1068_0452`: allocates a cache block with type 7 and inserts its header after the cache-list head. + +All three names were applied and verified. The live `FUN_1068_` search returned no remaining auto-named functions. + +### Batch 31: Shape-frame cache operations (`1070`) + +- `1070:0187` -> `CacheShapeHand_GetShapeDimensions_1070_0187`: ensures the shape header is cached, then returns its width, height, and frame count to the caller. +- `1070:046c` -> `CacheShapeHand_EnsureFrameLoaded_1070_046c`: creates the shape-cache record as needed and loads the requested frame when its cache entry is absent. +- `1070:0706` -> `CacheShapeHand_GetFrameMetadataWord_1070_0706`: ensures the requested frame is loaded and returns the 16-bit field at offset `+4` in its eight-byte frame record; no direct callers were recovered. +- `1070:0787` -> `CacheShapeHand_CheckFrameCacheConsistency_1070_0787`: compares loaded frame entries against their shape ID and frame index, returning the first mismatch status or success; no direct callers were recovered. +- `1070:0880` -> `CacheShapeHand_ReleaseAllFrames_1070_0880`: releases every cached frame belonging to a shape and then releases the shape-cache block. +- `1070:0946` -> `CacheShapeHand_ReleaseFrame_1070_0946`: releases one loaded frame entry when its index and cache handle are valid. +- `1070:0dad` -> `CacheShapeHand_Destroy_1070_0dad`: runs the shape-cache cleanup path, releases both attached resource objects, clears callback registration, and optionally frees the handler. +- `1070:12d2` -> `CacheShapeHand_ValidateShapeData_1070_12d2`: in partial-install mode, checks type-flag/resource data across all `0x800` shapes, clears inconsistent entries, and closes the associated file. +- `1070:14c0` -> `CacheShapeHand_SetFrameCacheEntry_1070_14c0`: writes a supplied frame-cache value into the indexed eight-byte entry of a loaded shape record. +- `1070:1ae4` -> `CacheShapeHand_FinalizeShapeCacheFiles_1070_1ae4`: closes/unlinks the static shape-cache file, chooses the shape-data validation path when required, and removes the partial-install data file. + +All ten names were applied and verified. The live `FUN_1070_` search returned no remaining auto-named functions. + +### Batch 32: Item-cache header and list primitives (`1078`) + +- `1078:037e` -> `ItemCache_GetHeaderField09_1078_037e`: returns the 32-bit header field at offset `+9`; its meaning is not yet established. +- `1078:03a0` -> `ItemCache_GetBlockSize_1078_03a0`: returns the 32-bit block-size field at offset `+4` through `EAX`. +- `1078:03c2` -> `ItemCache_GetBlockLink15_1078_03c2`: returns the 32-bit link stored at offset `+0x15` through `EAX`. +- `1078:03e4` -> `ItemCache_GetBlockLink19_1078_03e4`: returns the 32-bit link stored at offset `+0x19` through `EAX`. +- `1078:0406` -> `DList_GetNextLink_1078_0406`: returns the list link at offset `+0xd` through `EAX`. +- `1078:0428` -> `DList_GetPreviousLink_1078_0428`: returns the list link at offset `+0x11` through `EAX`. +- `1078:04c3` -> `ItemCache_SetHeaderField09_1078_04c3`: writes the 32-bit header field at offset `+9`; its meaning is not yet established. +- `1078:04e5` -> `DList_SetNextLink_1078_04e5`: writes the list link at offset `+0xd`. +- `1078:0507` -> `DList_SetPreviousLink_1078_0507`: writes the list link at offset `+0x11`. +- `1078:0548` -> `ItemCache_SetBlockDataSize_1078_0548`: writes the one-byte header field at offset `+8`, paired with the existing getter. +- `1078:0568` -> `ItemCache_SetBlockIndex_1078_0568`: writes the 16-bit block index at offset `+2`. +- `1078:0588` -> `ItemCache_MoveBlockContentsBackward_1078_0588`: moves a complete block toward a lower address, updates its handle-table pointer, and relinks the block. +- `1078:0617` -> `ItemCache_ExpandBlockBackward_1078_0617`: moves the `0x1d`-byte block header backward and increases its size by the displacement. + +All thirteen names were applied and verified. The live `FUN_1078_` search returned no remaining auto-named functions. + +### Batch 33: Container legality and item-record helpers (`1088`) + +- `1088:0094` -> `Item_CanContainItem_1088_0094`: rejects NPC objects and invalid containment cycles, checks NPC equipment/weight constraints, and verifies available container volume; used by legal moves and nearby stacking. +- `1088:0315` -> `Item_ContainerHasVolumeForShape_1088_0315`: computes required volume for the supplied shape/quantity and checks the target container's remaining capacity, including zero-volume contained-container cases. +- `1088:0486` -> `Item_IsInsideNPC_1088_0486`: follows the item's containing chain to its outer owner and reports whether that owner is an NPC. +- `1088:0784` -> `Item_CompareItemRecordPrefix_1088_0784`: compares two records' first two dwords and the low byte of the following word; no direct callers were recovered. + +All four names were applied and verified. The live `FUN_1088_` search returned no remaining auto-named functions. + +### Batch 34: Glob-data cache and egg hatch helpers (`1098`) + +- `1098:0151` -> `ItemGlob_GetDataSize_1098_0151`: invokes the glob-cache object's size virtual method, whose hidden output value is returned in `EAX` and used to size the cached glob-data block. +- `1098:0325` -> `ItemGlob_InvalidateCacheSlot_1098_0325`: sets the glob-number slot selected by the supplied cache index to `0xffff`; no direct callers were recovered. +- `1098:0339` -> `ItemGlob_HatchEggForItem_1098_0339`: resolves an item's glob number and world coordinates, then calls the glob-egg hatch operation. Called by `World_HatchGlobEggs`. +- `1098:077d` -> `ItemGlob_ReleaseCachedGlob_1098_077d`: finds the cache slot for a glob number, releases its item-cache block, and invalidates the slot; no direct callers were recovered. +- `1098:07db` -> `ItemGlob_GetFirstDataWord_1098_07db`: retrieves a glob's cached data pointer and returns its first 16-bit word. + +All five names were applied and verified. The live `FUN_1098_` search returned no remaining auto-named functions. + +### Batch 35: World-item cleanup and fast-area transitions (`10a0`, `10a8`) + +- `10a0:3042` -> `World_GetType2ObjectFieldAtPoint_10a0_3042`: finds a world object at the supplied point, accepts object type 2, and returns its field at `+0x18`; otherwise clears the output and reports failure. +- `10a8:0386` -> `World_CleanupFastAreaTile_10a8_0386`: settles live gravity processes in one tile bucket, then moves or destroys remaining fast-area items. +- `10a8:04c9` -> `World_DestroyNonNpcFastAreaItems_10a8_04c9`: walks fast-area tile buckets, removes items from the fast area, destroys non-NPC contents/items, and pushes NPCs through the item cache. +- `10a8:0abf` -> `World_ReloadCurrentMapWithCachedItems_10a8_0abf`: cleans current world items, restores cached item state, and rebuilds the fast area using the saved map and camera position. +- `10a8:0b32` -> `World_ReloadCurrentMapFromFixedDat_10a8_0b32`: cleans current world items, reloads the active map from fixed data, and rebuilds the fast area. +- `10a8:13dd` -> `World_UpdateFastAreaForCameraAndMap_10a8_13dd`: loads a changed map if needed, removes blocks leaving the camera fast area, hatches glob eggs in newly active blocks, and adds those blocks. +- `10a8:1612` -> `World_RefreshFastAreaForCurrentMap_10a8_1612`: sets the map-change sentinel and rebuilds the fast area around the current camera position. +- `10a8:19a2` -> `World_UnlinkItemFromTileList_10a8_19a2`: removes an item from its tile's linked list and decrements that tile's item count. +- `10a8:27a6` -> `World_CalculateAvailableItemSlots_10a8_27a6`: computes remaining world item capacity after counting non-fast-only items, nested contents, and peak local glob-egg reservations. +- `10a8:2969` -> `Item_CountFreeFastSlots_10a8_2969`: counts unused item IDs in the fast-item range `2..255`. + +All ten names were applied and verified. The live `FUN_10a0_` and `FUN_10a8_` searches returned no remaining auto-named functions. + +### Batch 36: Damage FLEX.DAT cleanup (`10b8`) + +- `10b8:00e8` -> `DamageFlexDat_Destroy_10b8_00e8`: closes the attached file object, frees the auxiliary allocation, clears the global damage FLEX.DAT handle, and optionally frees the owner. + +The name was applied and verified. The live `FUN_10b8_` search returned no remaining auto-named functions. + +### Batch 37: Item-finder iterator and predicates (`10c0`) + +- `10c0:0077` -> `ItemFind_AdvanceToFirstMatch_10c0_0077`: seeds the iterator from its initial candidate and advances past entries rejected by the configured predicate. +- `10c0:06aa` -> `ItemFind_CreateAndPrimeSearch_10c0_06aa`: allocates and initializes a 0x28-byte search context, copies predicate data, and primes the first result. +- `10c0:0a08` -> `ItemFind_SearchMapBlock_10c0_0a08`: converts map-block coordinates to a world-coordinate rectangle and invokes the area-search initializer. +- `10c0:0cca` -> `ItemFind_AdvanceDepthFirst_10c0_0cca`: advances through item contents and sibling links, applying the search predicate until a match is found. +- `10c0:0def` -> `ItemFind_StartFromItemContents_10c0_0def`: seeds a search from the supplied item's contents, copies predicate state, and primes the first result. +- `10c0:0e4c` -> `ItemFind_StartFromContentsAtCoordinate_10c0_0e4c`: seeds the contents search while also setting the iterator's starting coordinate field. +- `10c0:0eb3` -> `ItemFind_AdvanceToNextMatch_10c0_0eb3`: walks through contained items and siblings to the next candidate accepted by the predicate. +- `10c0:1338` -> `ItemFind_MatchItemWithinBounds_10c0_1338`: checks candidate shape extents and Z against the iterator bounds, setting the match mode on success. + +All eight names were applied and verified. The live `FUN_10c0_` search returned no remaining auto-named functions. + +### Batch 38: Fixed-size buffer helpers (`10f0`) + +- `10f0:0000` -> `Memory_Zero32Bytes_10f0_0000`: clears sixteen 16-bit words, or 32 bytes, at the supplied far pointer. +- `10f0:02a7` -> `Memory_AllocateOrClear32Bytes_10f0_02a7`: allocates a 32-byte buffer when passed null, otherwise reuses the supplied buffer, then clears all 32 bytes. + +Both names were applied and verified. The live `FUN_10f0_` search returned no remaining auto-named functions; the prior descriptive suffixes incorrectly said 16 bytes. + +### Batch 39: Random DTable byte selection (`1118`) + +- `1118:0497` -> `DTable_SelectRandomConfiguredByte_1118_0497`: counts a contiguous prefix of up to three nonzero per-shape table bytes and selects one uniformly with the 15-bit RNG; returns zero when the first entry is absent. No direct callers were recovered. + +The name was applied and verified. + +### Batch 40: Item hurl/range helpers and sentinel reset (`1128`) + +- `1128:109a` -> `Item_HurlAtTarget_1128_109a`: derives signed horizontal and vertical deltas from two items' coordinates and calls the hurl routine with the requested magnitude; no direct callers were recovered. +- `1128:1090` -> `ItemDamage_NoOp_1128_1090`: empty stub called by `Item_GetDamaged` when the item's damage path lacks the owner-row hit-event flag. +- `1128:1b09` -> `Item_GetVisibleRangeWithinThreshold_1128_1b09`: adjusts the target height using its shape type flags, computes rounded 3D range, and returns the visible range only when it is within the threshold; no direct callers were recovered. +- `1128:22b4` -> `ResetStoredXYZToInvalidSentinels_1128_22b4`: writes `0xffff`, `0xffff`, and `0xff` to three coordinate-like globals. The live data-use scan found no other reads or writes, so their higher-level role remains unknown. + +All four names were applied and verified. The live `FUN_1128_` search returned no remaining auto-named functions. + +### Batch 41: Weapon-fire and controller follow-up (`1130`) + +- `1130:01a5` -> `WeaponFire_SetRemainingBurstCount_1130_01a5`: records the remaining weapon burst count and sets the controller-process firing flag; called by `Crusader_TryToFireWeapon`. +- `1130:2d48` -> `Crusader_GetControlledNPCZPlusOffset_1130_2d48`: returns the controlled NPC's Z (including its containing-object resolution) plus the global Z offset; no direct callers were recovered. +- `1130:2db6` -> `Crusader_AlertVisibleNPCsAfterWeaponFire_1130_2db6`: scans visible on-screen NPCs and starts guard/attack behaviors against the controlled NPC after weapon fire. +- `1130:2fa6` -> `ControllerProc_UpdateAndNotifyAutoFirer_1130_2fa6`: updates the controller process, then invokes the attached auto-firer object's callback when present. + +All four names were applied and verified. The live `FUN_1130_` search returned no remaining auto-named functions. + +### Batch 42: Sprite process helpers (`1138`) + +- `1138:0007` -> `Sprite_ApplyExplosionShapeOffset_1138_0007`: applies the configured world-position adjustment for the explosion-shape set before sprite-process creation. +- `1138:066d` -> `SpriteProcess_ReleaseResourcesAndCount_1138_066d`: frees the process's two optional auxiliary word lists, then decrements the active sprite-process count. +- `1138:1dc0` -> `Sprite_IsShapeInSpecialSet_1138_1dc0`: tests a shape number against the zero-terminated special-shape list. + +All three names were applied and verified. The live `FUN_1138_` search returned no remaining auto-named functions. + +### Batch 43: Bounds and packed-shape geometry (`1140`) + +- `1140:0000` -> `Bounds3D_Initialize_1140_0000`: initializes a six-coordinate 3D bounds record; the item-direction caller supplies the extent values from item type data. +- `1140:0031` -> `Bounds3D_Intersects_1140_0031`: tests overlap between two 3D bounds records on all three axes. +- `1140:018e` -> `Bounds3D_Translate_1140_018e`: adds an X/Y/Z translation to both corners of a 3D bounds record. +- `1140:01c8` -> `ShapeFrame_HasPixelInRegion_1140_01c8`: tests packed shape-frame pixel data against a queried region; callers use it for item-point and Gump hit tests. + +All four names were applied and verified. The live `FUN_1140_` search returned no remaining auto-named functions. + +### Batch 44: Fast-only item creation and Gump action (`1148`) + +- `1148:0000` -> `Item_CreateFastOnlyAtValidPosition_1148_0000`: checks whether a position is valid, creates the requested shape/frame there, and marks the created item `FastOnly`. +- `1148:05e8` -> `ControllerProc_SubmitGumpActionIfIdle_1148_05e8`: when the controlled NPC is idle, submits a controller event from the Gump interaction path. + +Both names were applied and verified. The live `FUN_1148_` search returned no remaining auto-named functions. + +### Batch 45: Directional item bounds calculation (`1150`) + +- `1150:2f4b` -> `Item_CalculateDirectionalBounds_1150_2f4b`: derives shape extents from item type data, initializes a temporary 3D bounds record from the supplied position, then translates it by item direction and elevation. No direct callers or references were recovered, and the temporary result has no observed consumer, so its higher-level purpose remains unresolved. + +The name was applied and verified. The live `FUN_1150_` search returned no remaining auto-named functions. + +### Batch 46: Fast-only item creation with optional container (`1158`) + +- `1158:0000` -> `Item_CreateFastOnlyWithOptionalContainer_1158_0000`: creates the requested shape/frame, marks the item `FastOnly`, optionally moves it into the supplied container, and returns its item number. No direct callers were recovered. + +The name was applied and verified. The live `FUN_1158_` search returned no remaining auto-named functions. + +### Batch 47: Animation stream sizing and buffer lifecycle (`1160`) + +- `1160:00aa` -> `AStream_CalculateAllocationSize_1160_00aa`: computes the stream buffer allocation size in bytes from its format flag and unit-count byte; animation loaders use the result for file reads and allocation. +- `1160:00e2` -> `AStream_InitializeWithUnitCount_1160_00e2`: sets the stream's size-driving unit-count byte, then initializes its backing buffer. +- `1160:01d2` -> `AStream_FreeBuffer_1160_01d2`: frees the stream's allocated buffer and clears both pointer words. + +All three names were applied and verified. The live `FUN_1160_` search returned no remaining auto-named functions. + +### Batch 48: Animation archive index and block operations (`1168`) + +- `1168:0091` -> `AnimFile_InitializeIndexFile_1168_0091`: creates and names an animation file, initializes its 2,048-entry index to zero, then closes it. +- `1168:0103` -> `AnimFile_ReadFrameStreamData_1168_0103`: reads an animation index entry, initializes the selected stream, and reads its frame payload when present. +- `1168:0348` -> `AnimFile_RebuildOptimizedArchive_1168_0348`: rebuilds the `anim_opt` companion by scanning animation entries and copying/rewriting indexed blocks. +- `1168:066a` -> `AnimFile_CopyIndexedBlockIfPresent_1168_066a`: copies a present 0x400-byte indexed block between file positions. +- `1168:06bf` -> `AnimFile_CreateZeroedIndexedBlock_1168_06bf`: writes a zero index entry and a zero-filled 0x400-byte block at the current file position. +- `1168:0732` -> `AnimFile_ClearIndexEntry_1168_0732`: clears the four-byte index entry for the requested block. + +All six names were applied and verified. The live `FUN_1168_` search returned no remaining auto-named functions. + +### Batch 49: Animation-file global initialization (`1170`) + +- `1170:099a` -> `AnimFile_InitializeGlobalHandle_1170_099a`: ensures the global animation-file object has its 8-byte file handle initialized. No direct callers or references were recovered. + +The name was applied and verified. The live `FUN_1170_` search returned no remaining auto-named functions. + +### Batch 50: Camera, map-view, and render helpers (`1180`) + +- `1180:049e` -> `MapView_PickWorldItemAtScreenPoint_1180_049e`: resolves a screen point to world coordinates and an optional hit item; callers use the result for moving/validating items. +- `1180:06dd` -> `Camera_RebuildVisibleItemDrawList_1180_06dd`: scans map blocks in the camera range, filters item visibility/bounds, and rebuilds item draw nodes. +- `1180:0c29` -> `Camera_RefreshVisibleMapBlockRects_1180_0c29`: copies visible map-block rectangle records into the destination grid and stores its origin. +- `1180:152b` -> `Camera_DrawAnchorMarker_1180_152b`: converts the configured world anchor to screen coordinates and draws its four-edge marker. +- `1180:1cb1` -> `Camera_ResetMapOverlayState_1180_1cb1`: clears overlay-related state and refreshes the map range; its exact caller-specific purpose remains unresolved. +- `1180:1ce5` -> `MapView_DrawIsometricWorldRangeOutline_1180_1ce5`: converts a world position and XYZ extents to screen coordinates, then draws the four-edge isometric outline. +- `1180:1df9` -> `Item_ClearRenderTrackingFlags_1180_1df9`: forwards to the item helper that clears status and two item-membership bit flags. + +All seven names were applied by address and verified. The live `FUN_1180_` search returned no remaining auto-named functions. + +### Batch 51: Viewport rectangle cache (`1188`) + +- `1188:0414` -> `ViewportCache_ExpireTimedEntries_1188_0414`: decrements the eight cache-entry timers; when one expires, invalidates its stored viewport rectangle and frees its backing allocation. +- `1188:094a` -> `ViewportCache_InitializeEntryTable_1188_094a`: initializes the global table as eight entries of 0x19 bytes, using `1188:0968` as the identity callback. +- `1188:0968` -> `IdentityPointerCallback_1188_0968`: returns its input pointer unchanged for the table initializer's callback contract. + +All three names were applied by address and verified. The live `FUN_1188_` search returned no remaining auto-named functions. + +### Batch 52: Display-list manager (`1190`) + +- `1190:01b4` -> `DList_FreeNodeAllocator_1190_01b4`: frees the global node allocator and clears its metadata. +- `1190:02a8` -> `DList_ProcessPendingAndVisibleQueues_1190_02a8`: promotes eligible pending nodes into the visible queue and dispatches or defers their callbacks. +- `1190:03fa` -> `DList_QueueChildNodesForProcessing_1190_03fa`: queues child nodes not already pending or active. +- `1190:045a` -> `DList_UpdateViewportClipRectangle_1190_045a`: clips the requested rectangle to the viewport and processes queued nodes. +- `1190:053d` -> `DList_AddOrderedNodeRelation_1190_053d`: allocates a relation record connecting two nodes in their ordering lists. +- `1190:059f` -> `DList_QueueNodeForProcessing_1190_059f`: marks and appends one node to the pending queue. +- `1190:05ca` -> `DList_RemoveNodeRelationsAndQueue_1190_05ca`: removes a node's relation records and pending-queue membership, queuing affected neighbors as needed. +- `1190:069c` -> `DList_InsertNodeIntoSpatialBins_1190_069c`: inserts a node across its covered map bins while checking ordered overlaps. +- `1190:08a0` -> `DList_TryLinkNodePairByOrder_1190_08a0`: compares node priority/depth and creates the corresponding ordering relation. +- `1190:0936` -> `DList_RebuildNodeSpatialLinks_1190_0936`: checks intersecting nodes across covered bins and rebuilds ordering links. +- `1190:0bbe` -> `DList_TryLinkNodePairByOrder_1190_0bbe`: second ordering helper with the same comparison/link behavior as `1190:08a0`; address retained because callers differ. +- `1190:0de4` -> `DList_FreeGlobalStorage_1190_0de4`: frees the node allocator, relation pool, and both item bitsets. +- `1190:0e2a` -> `DList_RemoveNodeAndReturnToPool_1190_0e2a`: removes a node and returns it to the global node pool. +- `1190:0e48` -> `DList_UnlinkAndRecycleRelation_1190_0e48`: unlinks one ordering relation and recycles its record. +- `1190:0e71` -> `DList_FindNodeAtWorldPoint_1190_0e71`: tests nodes in the containing map bin and returns the hit node. +- `1190:0fe2` -> `DList_QueueNodesIntersectingRect_1190_0fe2`: queues nodes intersecting a rectangle and sets their item-number bits in a tracking mask. +- `1190:1153` -> `DList_UpdateAnimatedItemVisibilityMask_1190_1153`: transfers changed, visible animated items from one item bitset to another. +- `1190:1398` -> `DList_CollectVisibleAnimatedItems_1190_1398`: collects visible animated item numbers whose shape frame needs updating. +- `1190:1919` -> `DList_ClearSpatialBinsAndMasks_1190_1919`: removes nodes from all 5-by-6 bins and clears both item bitsets. +- `1190:19b4` -> `LinkedList_LinkNodeBetweenNeighbors_1190_19b4`: links an intrusive-list node between its supplied neighbors. +- `1190:19ec` -> `LinkedList_UnlinkAdjacentNodes_1190_19ec`: reconnects an intrusive-list node's neighbors. +- `1190:1a25` -> `DList_CheckPendingNodeDependencies_1190_1a25`: checks whether child nodes are still pending before allowing queue processing. +- `1190:1a80` -> `DListRelationPool_PopFreeNode_1190_1a80`: pops a relation record from the free-node pool. +- `1190:1ab8` -> `DListRelationPool_PushFreeNode_1190_1ab8`: returns a relation record to the free-node pool. +- `1190:1b5a` -> `DListRelationPool_Free_1190_1b5a`: frees the global relation-record pool and clears its metadata. +- `1190:1b7f` -> `DList_AllocateOverlapRelation_1190_1b7f`: obtains a relation record and links it into the two node relation lists. +- `1190:1c14` -> `DList_UnlinkOverlapRelation_1190_1c14`: unlinks a relation record from both nodes' relation lists. + +All 27 names were applied by address and verified. The live `FUN_1190_` search returned no remaining auto-named functions. + +### Batch 53: Display-list ordering, lookup, and redraw (`1198`) + +- `1198:0000` -> `DList_CompareOverlappingNodeOrder_1198_0000`: compares two overlapping nodes using item position, shape bounds, and depth ordering. +- `1198:0dcb` -> `DList_ClearItemTrackingFlags_1198_0dcb`: clears the item's display-list status and membership bits in two global bitsets. +- `1198:0e4b` -> `DList_FindItemNodeInSpatialBins_1198_0e4b`: searches the requested map-bin rectangle for a node matching an item number. +- `1198:0efc` -> `DList_FindItemRenderNode_1198_0efc`: derives an item's shape bounds and looks up its display-list node in the covered bins. +- `1198:13d5` -> `DList_ProcessCurrentItem_1198_13d5`: processes the global current item, building/updating its node and contributing its bounds to display-list state. +- `1198:1890` -> `DList_RefreshQueueForCurrentBounds_1198_1890`: applies accumulated bounds, refreshes the viewport, and processes pending display-list nodes. +- `1198:192e` -> `DList_AccumulateClippedRedrawBounds_1198_192e`: clips a rectangle and unions it into the tracked redraw and overlay bounds. +- `1198:19e5` -> `DList_FlushAccumulatedSpriteRedraw_1198_19e5`: dispatches the accumulated sprite redraw bounds and clears the dirty flag. +- `1198:1a39` -> `DList_HitTestNodeAtScreenPoint_1198_1a39`: checks a node's bounds and optionally its cached shape pixels at the supplied point. +- `1198:1d28` -> `DList_GetIgnoreShapeHitTestFlag_1198_1d28`: returns the global flag used to ignore configured shapes during hit testing. + +All ten names were applied by address and verified. The live `FUN_1198_` search returned no remaining auto-named functions. + +### Batch 54: Viewport overlays and savegame callback registry (`11a0`) + +- `11a0:0d16` -> `Camera_DrawRegisteredViewportOverlays_11a0_0d16`: walks the registered callback chain and draws each rectangle through the viewport overlay routine. +- `11a0:0eef` -> `Savegame_FinalizeAndInvokeCallbacks_11a0_0eef`: called by `Savegame_QuickSave`; invokes the file object's finalization callbacks around seek and file-state operations. +- `11a0:1009` -> `SavegameCallbackRegistry_InitializeGlobals_11a0_1009`: initializes global callback-chain heads and the default process load/save function table. +- `11a0:1047` -> `SavegameCallbackRegistry_DestroyGlobals_11a0_1047`: destroys the global process dispatch entry and callback chain, then resets the chain head. +- `11a0:106c` -> `CallbackChain_DestroyAndMaybeFree_11a0_106c`: destroys a callback chain and frees its owner when flag bit 0 is set. +- `11a0:10a3` -> `CallbackChain_DestroyAndMaybeFree_11a0_10a3`: second chain-destroy/free helper with the same decompiled behavior. + +All six names were applied by address and verified. The live `FUN_11a0_` search returned no remaining auto-named functions. + +### Batch 55: Avatar-details overlay viewports (`11b0`) + +- `11b0:0000` -> `AvatarDetails_DisableOverlayThunk_11b0_0000`: short wrapper that invokes the overlay-disable routine. +- `11b0:0006` -> `AvatarDetails_EnableOverlayThunk_11b0_0006`: short wrapper that invokes the overlay-enable routine. +- `11b0:000c` -> `AvatarDetails_InitializePanelViewports_11b0_000c`: initializes the 20-entry, 13-byte panel-state table and creates a viewport for each panel rectangle. +- `11b0:0192` -> `AvatarDetails_RefreshOverlappingPanelRegions_11b0_0192`: checks linked-list item bounds against panel rectangles, marks affected entries, and refreshes the corresponding display regions. +- `11b0:08aa` -> `AvatarDetails_RedrawChangedPanelRegions_11b0_08aa`: draws each panel region marked changed and clears its change flag. +- `11b0:091b` -> `AvatarDetails_SetOverlayEnabled_11b0_091b`: selects the enable or disable path based on its argument; gameplay input-transition callers use both paths. +- `11b0:0932` -> `AvatarDetails_EnableOverlay_11b0_0932`: enables panel updates, notifies the NPC UI fields, narrows the mouse cursor range, and refreshes the gump. +- `11b0:098f` -> `AvatarDetails_DisableOverlay_11b0_098f`: disables panel updates, restores the cursor range, and refreshes the gump. + +All nine names were applied by address and verified. The live `FUN_11b0_` search returned no remaining auto-named functions. `11b0:09d9` initializes the panel-tracking table through the same generic flagged table initializer used by `ViewportCache_InitializeEntryTable_1188_094a`, with a 13-byte record size, count 5, flags 5, and an identity callback. + +### Batch 56: Key-daemon process state (`11b8`) + +- `11b8:025c` -> `KeyDaemon_ClearCurrentProcess_11b8_025c`: clears the global `g_keyDaemonProcess` far pointer. +- `11b8:026d` -> `KeyDaemon_LoadAndSetCurrentProcess_11b8_026d`: invokes the process load/save dispatch callbacks, then stores the process pointer in `g_keyDaemonProcess`. + +Both names were applied by address and verified. The live `FUN_11b8_` search returned no remaining auto-named functions. + +### Batch 57: System timer and AccWait timer methods (`11c0`) + +- `11c0:0141` -> `SystemTimer_WaitForTickDelta_11c0_0141`: busy-waits until the system-timer process counter advances by the requested 32-bit tick delta; `ComputerGump_NextCharacter` uses a one-tick delay before returning after text feedback. +- `11c0:05aa` -> `AccWaitProcess_UnregisterTimerEvents_11c0_05aa`: clears the process's timer-active byte and unregisters it from timer events. +- `11c0:05c3` -> `AccWaitProcess_RegisterTimerEvents_11c0_05c3`: sets the active byte, resets the process timer counters, and registers it for timer events. +- `11c0:05ea` -> `AccWaitProcess_HandleTimerEvent_11c0_05ea`: dispatches the `(2, 0)` event to the AccWait counter update, rolling its subcounter into the adjacent count every ten events. + +All four names were applied by address and verified. The live `FUN_11c0_` search returned no remaining auto-named functions. + +### Batch 58: BIOS timer counter setter (`11c8`) + +- `11c8:03a5` -> `BiosTimer_SetCounters_11c8_03a5`: writes the two 32-bit counter values at offsets `+0x40` and `+0x44` in a BIOS timer process; called by kernel initialization and savegame restoration. + +The name was applied by address and verified. The live `FUN_11c8_` search returned no remaining auto-named functions. + +### Batch 59: Kernel process scheduling and maintenance (`11d0`) + +- `11d0:0255` -> `Kernel_RunProcessSchedulerIteration_11d0_0255`: scans the process table, runs eligible process callbacks, handles immediate timer and keyboard work, and performs scheduler housekeeping. +- `11d0:04cd` -> `Kernel_MaybeShrinkProcessTables_11d0_04cd`: periodically checks spare process slots and shrinks the process pointer/name/size tables when occupancy allows. +- `11d0:1a0b` -> `Kernel_InvokeProcessSlot10ForMatchingFlags_11d0_1a0b`: invokes process callback slot `+0x10` for every process or only those whose flags match the supplied mask. +- `11d0:31cf` -> `Kernel_RunTimedSchedulerLoop_11d0_31cf`: repeatedly runs a scheduler iteration, invokes an optional callback, and waits for the configured system-timer delta; entered by `Runtime_InitializeCommandLineAndRunLoop`. + +All four names were applied by address and verified. The live `FUN_11d0_` search no longer returns these functions; remaining candidates begin at `11d0:2dbc`. + +### Batch 60: Timer interrupt and vector management (`11d0`) + +- `11d0:2dbc` -> `Kernel_GetTimerInterruptHandlerOffset_11d0_2dbc`: selects the active timer-handler offset according to the current real/protected-mode state. +- `11d0:2fe0` -> `Kernel_RestoreDosInt21Vector_11d0_2fe0`: restores the saved protected-mode DOS `INT 21h` vector when its hook-installed flag is set. +- `11d0:3045` -> `Kernel_RestoreBiosTimerVector_11d0_3045`: restores the saved BIOS timer vector for interrupt 8 when its replacement is active. +- `11d0:307d` -> `Kernel_EnableTimerInterruptHandling_11d0_307d`: enables or defers timer interrupt/PIC handling as timer processes are registered. +- `11d0:30bb` -> `Kernel_DisableTimerInterruptHandling_11d0_30bb`: disables the timer interrupt path and clears its pending state when timer handling is no longer needed. +- `11d0:30e5` -> `Kernel_RecomputeTimerDivisor_11d0_30e5`: compares registered timer-process periods and reprograms the hardware divisor when the fastest requested period changes. + +All six names were applied by address and verified. The live `FUN_11d0_` search now begins at `11d0:3232`. + +### Batch 61: Timer interrupt dispatch and BIOS keyboard state (`11d0`) + +- `11d0:3232` -> `Kernel_EndTimerProcessUpdate_11d0_3232`: completes a timer-process update and applies the pending PIC-mask change when required. +- `11d0:3248` -> `Kernel_BeginTimerProcessUpdate_11d0_3248`: records the pending timer-interrupt state and masks the timer interrupt while process timing state is modified. +- `11d0:3264` -> `Kernel_RunTimerCallbacksOnInterruptStack_11d0_3264`: prepares an interrupt stack/context, dispatches timer callbacks, and returns the updated interrupt frame. +- `11d0:3325` -> `Kernel_DispatchTimerProcessTicks_11d0_3325`: ticks registered timer processes and restores or updates the active timer-interrupt state. +- `11d0:342c` -> `NoOpCallback_11d0_342c`: empty callback stub. +- `11d0:3447` -> `BiosKeyboard_SetStatusFlags_11d0_3447`: writes the BIOS Data Area keyboard-status word at `0040:0017`. + +All six names were applied by address and verified. The live `FUN_11d0_` search now begins at `11d0:3a3c`. + +### Batch 62: Keyboard vector and repeat settings (`11d0`) + +- `11d0:3a3c` -> `Kernel_RestoreKeyboardInterruptVector_11d0_3a3c`: restores the saved interrupt-9 keyboard vector when the replacement handler is active; used by kernel teardown and state restoration. +- `11d0:3d59` -> `Keyboard_SetRepeatDelay_11d0_3d59`: clamps the repeat-delay setting to two bits and reapplies the BIOS keyboard repeat configuration. +- `11d0:3d6b` -> `Keyboard_SetRepeatRate_11d0_3d6b`: clamps the repeat-rate setting to five bits and reapplies the BIOS keyboard repeat configuration. + +All three names were applied by address and verified. The live `FUN_11d0_` search now begins at `11d0:3eb4`. + +### Batch 63: Item-process flags and process accounting (`11d0`) + +- `11d0:3eb4` -> `Item_IsProcessPresent_11d0_3eb4`: tests the per-item process-present bitset. +- `11d0:3f22` -> `Item_ClearProcessTypeFlag_11d0_3f22`: clears one process-type bit for an item. +- `11d0:3f59` -> `Item_ReconcileProcessTypeFlag_11d0_3f59`: refreshes the item's process-type state when its process exists, otherwise clears the stale bit. +- `11d0:3f95` -> `Item_HasProcessTypeFlag_11d0_3f95`: tests whether a process-type bit is set for an item; used by `NPC_IsBusy` and item interaction code. +- `11d0:3fd4` -> `Kernel_ClearProcessTypeCounters_11d0_3fd4`: clears the per-process-type counter array during process-table initialization. +- `11d0:3fe8` -> `Kernel_IncrementCurrentProcessTypeCounter_11d0_3fe8`: increments the counter for the currently running process type. +- `11d0:41e8` -> `Kernel_InitializeEventProcessLists_11d0_41e8`: resets the timer, keyboard, and mouse process-ID lists to the shared empty-list sentinel. +- `11d0:4259` -> `Kernel_DestroyEventProcessLists_11d0_4259`: destroys the timer, keyboard, and mouse process-ID lists. + +All eight names were applied by address and verified. The live `FUN_11d0_` search returned no remaining auto-named functions. + +### Batch 64: Process expiry, Notlist relations, and timer periods (`11e0`) + +- `11e0:0379` -> `Process_UnlinkIfTimerExpired_11e0_0379`: compares a process deadline against the system timer, dispatches its expiry callback when enabled, and unlinks the expired entry. +- `11e0:046b` -> `Process_CleanupLinearAndNotlistState_11e0_046b`: transfers linear-process status to a replacement process when needed and cleans up Notlist relationships before process destruction. +- `11e0:06e0` -> `Process_HandleNotlistTermination_11e0_06e0`: resolves Notlist child/dependency entries during process termination, propagating failure state and notifying eligible processes. +- `11e0:0973` -> `Notlist_ClearEntryFlag0800_11e0_0973`: clears entry bit `0x0800` and removes the list word when no retention condition applies. +- `11e0:0a43` -> `Notlist_ClearEntryFlag1000_11e0_0a43`: clears entry bit `0x1000` and conditionally removes the list word. +- `11e0:0b13` -> `Notlist_ClearEntryFlag2000_11e0_0b13`: clears entry bit `0x2000` and conditionally removes the list word. +- `11e0:0be3` -> `Notlist_ClearEntryFlag4000_11e0_0be3`: clears entry bit `0x4000` and conditionally removes the list word. +- `11e0:118e` -> `Process_InvokeSlot10ForMatchingFlags_11e0_118e`: forwards process-selection parameters to the kernel's slot-`+0x10` callback dispatcher. +- `11e0:11b1` -> `Process_NotifyInterruptCapableProcess_11e0_11b1`: invokes a process's slot-`+0x10` callback when its interrupt-capable flag is set. +- `11e0:18c7` -> `Process_SetTimerUpdatePeriod_11e0_18c7`: writes a process's timer-period fields and asks the kernel to recompute the timer divisor. + +All ten names were applied by address and verified. The live `FUN_11e0_` search returned no remaining auto-named functions. + +### Batch 65: MList lookup and savegame serialization (`11e8`) + +- `11e8:054f` -> `MList_FindWordIndex_11e8_054f`: scans a counted word list and returns the index of a matching value. +- `11e8:07b3` -> `MList_ReadFromFile_11e8_07b3`: allocates list storage and reads its word contents from a file. +- `11e8:081c` -> `MList_WriteToFile_11e8_081c`: writes the allocated word-list contents to a file; called during savegame finalization. + +All three names were applied by address and verified. The live `FUN_11e8_` search returned no remaining auto-named functions. + +### Batch 66: Standard interrupt-handler lifecycle and PIC EOI (`11f0`) + +- `11f0:0205` -> `StdIntHandlerProcess_OnTerminating_11f0_0205`: releases the handler process's owned word list and clears the global singleton pointer during termination. +- `11f0:024e` -> `StdIntHandlerProcess_LoadState_11f0_024e`: runs base process load hooks and the handler-specific load callback. +- `11f0:0283` -> `StdIntHandlerProcess_SaveState_11f0_0283`: runs base process save hooks and the handler-specific save callback. +- `11f0:032f` -> `StdIntHandler_SetActiveProcess_11f0_032f`: assigns the global standard interrupt-handler process pointer. +- `11f0:04ce` -> `Pic_SendEndOfInterrupt_11f0_04ce`: sends EOI to the slave PIC when the IRQ exceeds 7 and always sends EOI to the master PIC. +- `11f0:0506` -> `Process_InvokeTerminatingCallback_11f0_0506`: dispatches the process vtable callback invoked by `Process_SetTerminating` before generic termination. + +All six names were applied by address and verified. The live `FUN_11f0_` search returned no remaining auto-named functions. + +### Batch 67: DOSFix32 descriptor helpers (`1200`) + +- `1200:0000` -> `Descriptor_InitZeroed_1200_0000`: allocates an 8-byte descriptor when passed null and zeroes the descriptor storage. +- `1200:0038` -> `Descriptor_Equals_1200_0038`: compares two descriptor entries byte-for-byte across all 8 bytes. +- `1200:007a` -> `Descriptor_SetBase_1200_007a`: writes the descriptor's base-address bytes while leaving its other fields intact. +- `1200:00bd` -> `Descriptor_SetLimit20_1200_00bd`: writes the low 20 limit bits and preserves the upper flag nibble. +- `1200:00e5` -> `Descriptor_GetBaseLow_1200_00e5`: reads the low base-offset word. +- `1200:013f` -> `Descriptor_GetLimit20_1200_013f`: combines the low limit word with the high limit nibble. +- `1200:017a` -> `Descriptor_SetLimitAndUpperWord_1200_017a`: writes the low limit word and the full word at descriptor offset `+6`. +- `1200:019a` -> `Descriptor_GetLimitAndUpperWord_1200_019a`: combines the low limit word with the full word at descriptor offset `+6`. +- `1200:02e4` -> `Descriptor_WriteBySelector_1200_02e4`: selects the GDT/LDT table from the selector's TI bit and writes its descriptor entry. +- `1200:032b` -> `Descriptor_ReadBySelector_1200_032b`: selects the GDT/LDT table from the selector's TI bit and reads its descriptor entry. + +All ten names were applied by address and verified. The live `FUN_1200_` search returned no remaining auto-named functions. + +### Batch 68: DOSFix32 static pointer initialization (`1208`) + +- `1208:0000` -> `DosFix32_InitStaticPointer16_1208_0000`: stores the CS-relative far pointer `CS:0016` in the first global pointer pair. +- `1208:000b` -> `DosFix32_InitStaticPointer438_1208_000b`: stores the CS-relative far pointer `CS:0438` in the second global pointer pair. + +Both names were applied by address and verified. The live `FUN_1208_` search returned no remaining auto-named functions. + +### Batch 69: DOSFix32 code-selector setup (`1210`) + +- `1210:07d0` -> `DosFix32_InitCodeSelectorAndLimits_1210_07d0`: records the current CS selector and two fixed descriptor-limit values used by Spanker setup. + +The name was applied by address and verified. The live `FUN_1210_` search returned no remaining auto-named functions. + +### Batch 70: DOSFix32 vectors, teardown, and profile buffering (`1218`) + +- `1218:0000` -> `DosFix32_TeardownAndExit_1218_0000`: runs the shared teardown path and then calls Phar Lap ordinal 7. +- `1218:0021` -> `DosFix32_Teardown_1218_0021`: wrapper for the shared teardown path. +- `1218:0530` -> `DosFix32_RestoreDescriptorTables_1218_0530`: restores saved descriptor entries, invokes the second selector routine, and releases mapped table storage; called by `TeardownOnce`. +- `1218:059b` -> `DosFix32_SetPassUpProtectedVector_1218_059b`: installs a pass-up protected-mode vector via `DOSSETPASSTOPROTVEC` and preserves the descriptor state. +- `1218:064a` -> `DosFix32_SetRealModeProtectedVector_1218_064a`: installs a real-mode/protected-mode vector via `DOSSETREALPROTVEC`. +- `1218:06fd` -> `DosFix32_SetProtectedVector_1218_06fd`: installs a protected-mode vector via `DOSSETPROTVEC`. +- `1218:07a6` -> `DosFix32_InvokeSelectorRoutineA_1218_07a6`: invokes the first dynamically assigned selector routine. +- `1218:07af` -> `DosFix32_InvokeSelectorRoutineB_1218_07af`: invokes the second dynamically assigned selector routine. +- `1218:08ab` -> `Spanker_FlushProfileAddressQueue_1218_08ab`: flushes queued four-byte entries into the profile-address buffer. +- `1218:0953` -> `Spanker_CollectProfileAddresses_1218_0953`: drains pending addresses into the profile stream and triggers output at capacity. + +All ten names were applied by address and verified. The live `FUN_1218_` search returned no remaining auto-named functions. + +### Batch 71: Fastflex file and entry-table helpers (`1220`) + +- `1220:0000` -> `File_CloseAndFreeOwnedBuffer_1220_0000`: closes the file object, releases its owned buffer, and optionally frees the object. +- `1220:01bb` -> `Fastflex_CopyEntryToTable_1220_01bb`: copies one 8-byte entry into the in-memory indexed table. +- `1220:01e2` -> `Fastflex_WriteEntryToFile_1220_01e2`: writes one indexed 8-byte entry at file offset `0x80 + index * 8`. +- `1220:022f` -> `Fastflex_ReadEntriesFromFile_1220_022f`: reads the indexed 8-byte entries from file offset `0x80` into the table buffer. +- `1220:0263` -> `Fastflex_InitializeEntry_1220_0263`: allocator callback that creates or clears an 8-byte entry. + +All five names were applied by address and verified. The live `FUN_1220_` search returned no remaining auto-named functions. + +### Batch 72: Configuration parser primitives (`1230`) + +- `1230:019a` -> `Config_ReadToken_1230_019a`: skips leading whitespace and copies the next token up to whitespace or end-of-input. +- `1230:0240` -> `Config_ReadUntilDelimiter_1230_0240`: copies input up to a requested delimiter or end-of-input. +- `1230:02a7` -> `Config_SkipThroughChar_1230_02a7`: advances through a requested character when present. +- `1230:0309` -> `Config_SkipWhitespace_1230_0309`: advances over spaces, tabs, and line endings. +- `1230:0384` -> `Config_SkipThroughNewline_1230_0384`: advances through the next line feed. +- `1230:044c` -> `Config_ReadByte_1230_044c`: reads one byte when available, otherwise returns zero. +- `1230:048e` -> `Config_ReadWord_1230_048e`: reads one word when available, otherwise returns zero. +- `1230:04c8` -> `Config_ReadDword_1230_04c8`: reads one dword when available, otherwise returns zero. +- `1230:0509` -> `Config_ReadQuotedString_1230_0509`: copies a quoted string after leading whitespace when an opening quote is present. + +All nine names were applied by address and verified. The live `FUN_1230_` search returned no remaining auto-named functions. + +### Batch 73: Filespec lifecycle and wildcard operations (`1238`) + +- `1238:056a` -> `Filespec_Init_1238_056a`: initializes the 0x94-byte Filespec object and its search-state fields. +- `1238:05c2` -> `Filespec_InitFromParts_1238_05c2`: initializes a Filespec object from path/name components and optional file data. +- `1238:06eb` -> `Filespec_Destroy_1238_06eb`: closes and releases the owned file object, and optionally frees the Filespec. +- `1238:0756` -> `Filespec_DeleteAllMatches_1238_0756`: enumerates matching paths and unlinks each one. +- `1238:07cd` -> `Filespec_Exists_1238_07cd`: builds the full path and returns the file-existence result. +- `1238:080d` -> `Filespec_FindNext_1238_080d`: advances wildcard enumeration and updates the current match. +- `1238:097a` -> `Filespec_SplitFoundFilename_1238_097a`: separates the found filename into its name and extension fields. +- `1238:09f0` -> `Filespec_CompareFindData_1238_09f0`: compares DOS find-data records produced for two Filespec objects. +- `1238:0baa` -> `Filespec_FindFirst_1238_0baa`: builds the search pattern and starts wildcard enumeration. +- `1238:0c02` -> `Filespec_Reset_1238_0c02`: clears the path/name component buffers and resets the search-state flag. +- `1238:0c68` -> `Filespec_CopyNameComponents_1238_0c68`: copies stored name and extension components into the search fields. + +All eleven names were applied by address and verified. The live `FUN_1238_` search returned no remaining auto-named functions. + +### Batch 74: Flex headers, entries, and stream helpers (`1240`) + +- `1240:0227` -> `Flex_WriteEntryAtIndex_1240_0227`: writes an 8-byte entry at `0x80 + index * 8`. +- `1240:044a` -> `Flex_WriteAtOffset_1240_044a`: positions the Flex writer at the requested offset and forwards the write through its handler. +- `1240:049e` -> `Flex_FlushAndRewind_1240_049e`: invokes the handler flush hook and seeks the file to offset zero. +- `1240:0529` -> `Flex_ReadHeader50_1240_0529`: reads 0x50 bytes from the start of the file. +- `1240:0548` -> `Flex_WriteHeader128_1240_0548`: writes the 0x80-byte header and updates the in-memory entry count. +- `1240:0578` -> `Flex_ReadHeader128_1240_0578`: reads the 0x80-byte header and updates the in-memory entry count. +- `1240:05cb` -> `Flex_WriteRange_1240_05cb`: writes a buffer at a selected file range, fills any required gap, and flushes. +- `1240:0691` -> `Flex_CopyRangeBetweenFiles_1240_0691`: copies a range between file objects and flushes the destination. +- `1240:0756` -> `Flex_ComputePayloadByteSum_1240_0756`: sums payload bytes after the 0x80-byte header. +- `1240:08df` -> `Flex_FindEntryForOffset_1240_08df`: scans indexed entry ranges for the requested file offset. +- `1240:0952` -> `Flex_InitIndexHeader_1240_0952`: allocates or initializes the 0x80-byte index header and its default fields. + +All eleven names were applied by address and verified. The live `FUN_1240_` search returned no remaining auto-named functions. + +### Batch 75: DOS and file-range helpers (`1248`) + +- `1248:00c2` -> `DosCloseAllOpenFilesAndFree_1248_00c2`: closes all tracked DOS handles once and optionally frees the tracking object. +- `1248:01e9` -> `File_CloseAndFree_1248_01e9`: closes a file object and optionally frees it. +- `1248:0218` -> `File_WriteRangeAndExtend_1248_0218`: writes a buffer at the requested file range, extending the backing file when necessary, then flushes. + +All three names were applied by address and verified. The live `FUN_1248_` search returned no remaining auto-named functions. + +### Batch 76: Cache manifest entry-table helpers (`1250`) + +- `1250:067b` -> `CacheBackendObject_ClearEntryTable_1250_067b`: frees each entry string and both entry/ID tables. +- `1250:0ac9` -> `CacheBackendObject_GetEntryNameById_1250_0ac9`: resolves an entry ID through the ID table and returns its stored name. +- `1250:0b22` -> `CacheBackendObject_GetEntryMetadataWordById_1250_0b22`: resolves an entry ID and returns the first metadata word from its record. +- `1250:0ce5` -> `CacheBackendObject_FindEntryIdByName_1250_0ce5`: compares stored entry names and returns the corresponding ID, or `0xffff` when absent. +- `1250:0d45` -> `CacheBackendObject_SortEntriesByName_1250_0d45`: sorts entry records lexicographically by name while keeping IDs aligned. + +All five names were applied by address and verified. The live `FUN_1250_` search returned no remaining auto-named functions. + +### Batch 77: VGA palette readback and nearest-color helpers (`1258`) + +- `1258:00c7` -> `Palette_ReadVideoCardPalette_1258_00c7`: reads RGB triplets from the VGA DAC into the palette buffer; counterpart to `Palette_SetVideoCardPalette`. +- `1258:01eb` -> `Palette_FindNearestColorL1_1258_01eb`: finds the palette entry with the smallest sum of absolute RGB-channel differences. +- `1258:02b9` -> `Palette_FindNearestColorL2_1258_02b9`: finds the palette entry with the smallest squared Euclidean RGB distance. +- `1258:04c2` -> `Palette_BuildStandardColorIndexTable_1258_04c2`: precomputes palette indices for the standard color-cube sample points. + +All four names were applied by address and verified. The live `FUN_1258_` search returned no remaining auto-named functions. + +### Batch 78: Rectangle intersection and VESA mode accessors (`1268`) + +- `1268:01b9` -> `Rect_Intersects_1268_01b9`: tests whether two rectangles intersect, treating shared edges as an intersection. +- `1268:0262` -> `Rect_IntersectInPlace_1268_0262`: replaces the first rectangle with its intersection with the second. +- `1268:0446` -> `VesaModeInfo_Allocate_1268_0446`: allocates a 0x206-byte VESA mode-info object and clears its mode field. +- `1268:0476` -> `VesaModeInfo_CreateForMode_1268_0476`: allocates or reuses the object and queries VESA information for the requested mode. +- `1268:057c` -> `VesaModeInfo_GetBytesPerScanLine_1268_057c`: returns the mode's bytes-per-scanline field or `0xffff` when invalid. +- `1268:059b` -> `VesaModeInfo_GetYResolution_1268_059b`: returns the mode's vertical resolution or `0xffff` when invalid. +- `1268:05ba` -> `VesaModeInfo_GetWindowGranularity_1268_05ba`: returns the mode's window granularity or zero when invalid. + +All seven names were applied by address and verified. The live `FUN_1268_` search returned no remaining auto-named functions. + +### Batch 79: VPort pixel and drawing primitives (`1270`) + +- `1270:002b` -> `VPort_SetPixel_1270_002b`: writes a pixel when its coordinates fall within the VPort bounds. +- `1270:00bc` -> `VPort_GetPixel_1270_00bc`: reads a pixel when its coordinates fall within the VPort bounds. +- `1270:014d` -> `VPort_CopyFullScreenPage_1270_014d`: copies a 64,000-byte screen page between segments. +- `1270:0171` -> `VPort_FillRect_1270_0171`: fills the intersection of a rectangle and VPort bounds with one color. +- `1270:028e` -> `VPort_DrawVerticalLine_1270_028e`: draws a clipped vertical line in one color. +- `1270:0357` -> `VPort_DrawHorizontalLine_1270_0357`: draws a clipped horizontal line in one color. + +All six names were applied by address and verified. The live `FUN_1270_` search returned no remaining auto-named functions. + +### Batch 80: VPort lifecycle and drawing helpers (`1278`) + +- `1278:017b` -> `VPort_ReleaseBackingResources_1278_017b`: releases owned pixel storage and row-offset data according to the VPort flags. +- `1278:020a` -> `VPort_Destroy_1278_020a`: releases VPort resources and optionally frees the VPort object. +- `1278:0238` -> `VPort_CopyDescriptor_1278_0238`: replaces a VPort descriptor from a 24-byte source descriptor and marks the copied resource state. +- `1278:02f6` -> `VPort_DrawLine_1278_02f6`: draws a clipped line using horizontal/vertical fast paths or a Bresenham-style pixel walk. +- `1278:083a` -> `VPort_BlitRect_1278_083a`: blits a rectangle between VPorts, selecting a full-page/display path for matching bounds and flags. +- `1278:0aa4` -> `VPort_BlitTransparentRect_1278_0aa4`: copies a rectangle while treating source color `0xff` as transparent. +- `1278:0b81` -> `BuildLineOutlineQuad_1278_0b81`: computes four outline vertices around a line segment when the geometry is supported. +- `1278:0d71` -> `VPort_DrawLineOutline_1278_0d71`: draws the four edges of the computed line-outline quadrilateral. +- `1278:0f14` -> `InvokeGlobalCallback_1278_0f14`: invokes the function pointer stored at `DAT_1478_4078`; the callback's purpose is not established. + +All nine names were applied by address and verified. The live `FUN_1278_` search returned no remaining auto-named functions. + +### Batch 81: Description buffer and runtime callback thunks (`1280`) + +- `1280:0000` -> `DescriptionBuffer_GetAllocationSize_1280_0000`: returns the fixed allocation size used by the description-buffer constructor. +- `1280:0061` -> `SpriteBlitter_DrawNormal_1280_0061`: dispatches to the active normal, non-flipped sprite blitter. +- `1280:0065` -> `SpriteBlitter_DrawFlipped_1280_0065`: dispatches to the active flipped sprite blitter. +- `1280:0069` -> `SpriteBlitter_DrawInvisible_1280_0069`: dispatches to the active invisible-item blitter. +- `1280:006d` -> `InvokeCallbackSlot_4058_1280_006d`: invokes the callback stored at `DAT_1478_4058`. +- `1280:0071` -> `InvokeCallbackSlot_405c_1280_0071`: invokes the callback stored at `DAT_1478_405c`. +- `1280:0075` -> `InvokeCallbackSlot_4060_1280_0075`: invokes the callback stored at `DAT_1478_4060`. +- `1280:0079` -> `InvokeCallbackSlot_4064_1280_0079`: invokes the callback stored at `DAT_1478_4064`. +- `1280:0080` -> `InvokeCallbackSlot_4068_1280_0080`: invokes the callback stored at `DAT_1478_4068`. +- `1280:0084` -> `InvokeCallbackSlot_406c_1280_0084`: invokes the callback stored at `DAT_1478_406c`. +- `1280:008b` -> `InvokeCallbackSlot_4070_1280_008b`: invokes the callback stored at `DAT_1478_4070`. +- `1280:0092` -> `InvokeCallbackSlot_4074_1280_0092`: invokes the callback stored at `DAT_1478_4074`. +- `1280:0099` -> `InvokeGlobalCallback_1280_0099`: invokes the callback stored at `DAT_1478_4078`. +- `1280:009d` -> `InvokeCallbackSlot_407c_1280_009d`: invokes the callback stored at `DAT_1478_407c`. +- `1280:00a1` -> `InvokeCallbackSlot_4080_1280_00a1`: invokes the callback stored at `DAT_1478_4080`. +- `1280:00a5` -> `InvokeCallbackSlot_4084_1280_00a5`: invokes the callback stored at `DAT_1478_4084`. +- `1280:00a9` -> `InitializeRuntimeFunctionTables_1280_00a9`: initializes the runtime callback slots from the supplied allocation and source tables. +- `1280:0291` -> `DescriptionBuffer_Construct_1280_0291`: allocates and initializes the description buffer and its descriptor metadata. + +All eighteen names were applied by address and verified. The live `FUN_1280_` search returned no remaining auto-named functions. + +### Batch 82: DOS linear-memory manager (`1288`) + +- `1288:00b9` -> `FarStruct_GetWordAtOffset6_1288_00b9`: reads a 16-bit field at byte offset 6 from a far structure. +- `1288:00df` -> `FarStruct_SetWordAtOffset6_1288_00df`: writes a 16-bit field at byte offset 6 in a far structure. +- `1288:00fd` -> `DOSSelector_ResolveLinearAddress_1288_00fd`: resolves the selector descriptor base and adds the stored offset to produce a linear address. +- `1288:0136` -> `DOSLinearMem_AllocateBlock_1288_0136`: finds a suitable DOS linear-memory free block, splits it when possible, and records the allocation type. +- `1288:0761` -> `DOSLinearMem_CompactBlocks_1288_0761`: compacts allocated blocks and coalesces free space during an allocator finalize pass. +- `1288:0d87` -> `DOSLinearMem_GetFreeSpaceStats_1288_0d87`: returns total free bytes and the largest free block for one arena. +- `1288:0e37` -> `DOSLinearMem_ValidateAllBlockChains_1288_0e37`: checks free/allocated list counts, links, and arena coverage for each DOS linear-memory arena. +- `1288:18e4` -> `DOSLinearMem_GetGlobalFreeSpaceStats_1288_18e4`: aggregates total and largest free space across arenas and returns the additional global status word. +- `1288:1a70` -> `MemoryManager_Uninitialize_1288_1a70`: tears down the presentation callback broker and DOS linear-memory manager before returning to DOS. + +All nine names were applied by address and verified. The live `FUN_1288_` search returned no remaining auto-named functions. + +### Batch 83: Selector and descriptor helpers (`1290`) + +- `1290:0000` -> `Selector_GetDescriptorPointer_1290_0000`: maps a selector to its descriptor slot in one of two descriptor-table segments. +- `1290:0033` -> `Selector_GetDescriptorPointerFromWord_1290_0033`: word-argument variant of the descriptor-slot lookup. +- `1290:005f` -> `Selector_GetDescriptorBase_1290_005f`: returns the base address stored in a selector's descriptor. +- `1290:007d` -> `Selector_GetDescriptorBasePointer_1290_007d`: returns the descriptor base as a pointer. +- `1290:0096` -> `Selector_SetDescriptorBaseFromFarPointer_1290_0096`: sets a selector descriptor's base from a far-pointer argument. +- `1290:00df` -> `Selector_SetDescriptorBase_1290_00df`: sets a selector descriptor's base address. +- `1290:0163` -> `Selector_GetNextDescriptorScratch_1290_0163`: returns the next rotating scratch descriptor slot and initializes its selector/base fields. +- `1290:019c` -> `GDT_GetLimit_1290_019c`: executes `SGDT` and returns the GDT limit word. +- `1290:01b7` -> `Selector_AddDescriptorBaseOffset_1290_01b7`: adds an offset to the current descriptor base and stores the result. +- `1290:0211` -> `Selector_AdvanceBaseOffset_1290_0211`: wrapper around the descriptor-base offset update. +- `1290:0228` -> `Descriptor_GetBaseAddress_1290_0228`: reads the descriptor's 32-bit base address. +- `1290:0242` -> `Descriptor_GetEffectiveLimit_1290_0242`: decodes the descriptor limit, applying page granularity when enabled. +- `1290:02ae` -> `Descriptor_SetLimit_1290_02ae`: encodes a byte limit and its granularity flag into a descriptor. + +All thirteen names were applied by address and verified. The live `FUN_1290_` search returned no remaining auto-named functions. + +### Batch 84: Huge-memory mapping helpers (`1298`) + +- `1298:0000` -> `MemoryHuge_FillFarRange_1298_0000`: fills a far memory range across selector-window boundaries, then restores the descriptor base. +- `1298:008c` -> `MemoryHuge_FillFarRangeWrapper_1298_008c`: argument-order wrapper around the far-range fill routine. +- `1298:00a6` -> `MemoryHuge_InitializeEmpty_1298_00a6`: allocates a 0x1b-byte object when needed and zeros its fields. +- `1298:0207` -> `MemoryHuge_InitializeFromSelector_1298_0207`: initializes a huge-memory object from a selector's descriptor base and effective limit. +- `1298:039f` -> `MemoryHuge_CreateRangeMapping_1298_039f`: creates a selector-backed mapping for a source range. +- `1298:056f` -> `MemoryHuge_RebindSelector_1298_056f`: binds the object to the requested selector and refreshes its mapped bounds. +- `1298:0676` -> `MemoryHuge_InitializeRangeView_1298_0676`: initializes a range view, allocating a selector only when the object has none. +- `1298:075d` -> `MemoryHuge_InitializeFixedSizeRegion_1298_075d`: initializes an 8,000,000-byte region at the supplied base address. +- `1298:081c` -> `MemoryHuge_Destroy_1298_081c`: releases the mapping and optionally frees the object. +- `1298:084b` -> `MemoryHuge_ReleaseBackingSelector_1298_084b`: restores/releases the backing selector according to the object's ownership state. +- `1298:0a65` -> `MemoryHuge_GetCurrentMappedByte_1298_0a65`: reads the current mapped byte, refreshing the selector window at its boundary. +- `1298:0e40` -> `MemoryHuge_ResetReadPosition_1298_0e40`: resets the mapping's current position and descriptor base. +- `1298:0eb1` -> `MemoryHuge_GetBaseRelativeByte_1298_0eb1`: reads a byte relative to the mapping's stored base address. + +All thirteen names were applied by address and verified. The live `FUN_1298_` search returned no remaining auto-named functions. + +### Batch 85: Selector descriptor-pool management (`12a0`) + +- `12a0:0000` -> `Selector_InitializeFreeDescriptorList_12a0_0000`: builds the free-descriptor chain and initializes the pool's available-count state. +- `12a0:0114` -> `Selector_ReleaseAllDescriptors_12a0_0114`: walks the allocated-descriptor chain and marks its entries free. +- `12a0:015f` -> `Selector_AllocateDescriptor_12a0_015f`: removes one descriptor from the free chain and returns its selector value. +- `12a0:01f6` -> `Selector_FreeDescriptor_12a0_01f6`: returns a selector's descriptor slot to the free chain. +- `12a0:026f` -> `Selector_SetDescriptorBase_12a0_026f`: writes a 32-bit base address into the selector descriptor. +- `12a0:02b4` -> `Selector_SetDescriptorBaseAndLimit_12a0_02b4`: writes the descriptor base and encodes a byte limit with the appropriate granularity. +- `12a0:0361` -> `Selector_UpdateBasesAfterRelocation_12a0_0361`: updates descriptors whose base matches a relocated memory address. + +All seven names were applied by address and verified. The live `FUN_12a0_` search returned no remaining auto-named functions. + +### Batch 86: Byte replication buffer helpers (`12a8`) + +- `12a8:003c` -> `Buffer_FillWordsWithReplicatedByte_12a8_003c`: fills a far destination with 16-bit words whose high and low bytes both equal the supplied byte; the count is in words. +- `12a8:1596` -> `Buffer_ExpandBytesToReplicatedWords_12a8_1596`: reads source bytes and writes one replicated-byte 16-bit word per byte; callers pass the byte length divided by two. +- `12a8:2eb3` -> `Buffer_ExpandBytesToReplicatedDwords_12a8_2eb3`: reads source bytes and writes one replicated-byte 32-bit dword per byte; callers pass the byte length divided by four. + +All three names were applied by address and verified. The live `FUN_12a8_` search returned no remaining auto-named functions. + +### Batch 87: Linked-list and memory helpers (`12b0`) + +- `12b0:0000` -> `memcpy_far_bytes_12b0_0000`: copies the requested far-memory range in dwords, then copies any remaining bytes. Callers include DOS linear-memory compaction and video/audio chunk paths; the body does not provide overlap-safe semantics. +- `12b0:003d` -> `Object_ResetVtableAndMaybeFree_12b0_003d`: restores the shared base vtable pointer and conditionally frees the object. SpriteNode, UsecodeProcess, and BaseCameraProcess cleanup paths call this shared destructor tail. +- `12b0:0066` / `12b0:00c1` -> `LinkedList_InsertAtTail_12b0_0066` / `LinkedList_InsertAtHead_12b0_00c1`: update the list endpoints and reciprocal node links at offsets `+2` and `+6`. +- `12b0:011c` / `12b0:01b8` -> `LinkedList_InsertBefore_12b0_011c` / `LinkedList_InsertAfter_12b0_01b8`: splice a node before or after an existing node and update the corresponding endpoint when needed. +- `12b0:0254` / `12b0:0286` -> `LinkedList_MoveNodeBefore_12b0_0254` / `LinkedList_MoveNodeAfter_12b0_0286`: unlink a node, then insert it relative to the supplied anchor. +- `12b0:02b8` / `12b0:02e8` -> `LinkedList_MoveNodeToHead_12b0_02b8` / `LinkedList_MoveNodeToTail_12b0_02e8`: unlink a node, then insert it at the selected endpoint. +- `12b0:0318` -> `LinkedList_UnlinkNode_12b0_0318`: repairs neighboring links and list endpoints without freeing the node. +- `12b0:039d` -> `LinkedList_UnlinkAndDestroyNode_12b0_039d`: unlinks a node and invokes its first virtual entry; callers include VM loaded-chunk and sound-cache cleanup. +- `12b0:048c` -> `LinkedList_GetFirstOrNextNode_12b0_048c`: initializes a cursor from the list head or advances it through the node link at `+6`; SpriteNode child traversal is a verified caller. + +All 13 names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 88: Text-output interface and context helpers (`12b8`) + +- `12b8:0000` / `12b8:002a` -> `TextOutput_Destroy_12b8_0000` / `TextOutput_Initialize_12b8_002a`: initialize the 10-byte text-output object with its shared vtable, or restore its base vtable and optionally free it. +- `12b8:0071` / `12b8:015c` -> `TextOutput_WriteChar_12b8_0071` / `TextOutput_WriteString_12b8_015c`: send a character through the output object's virtual methods, with LF/CR cursor handling, or write a NUL-terminated string through that character path. +- `12b8:0183` -> `TextOutput_WriteStringWithinWidth_12b8_0183`: emit characters until the next glyph would exceed the supplied horizontal limit; returns the number emitted. +- `12b8:01f9` -> `TextOutput_MeasureMultilineText_12b8_01f9`: measures the maximum line width and accompanying layout output via the output object's glyph metrics. Dialog sizing and multiline drawing call this helper. +- `12b8:027d` / `12b8:02aa` -> `TextOutput_InvokeVtableSlot10_12b8_027d` / `TextOutput_InvokeVtableSlot10_12b8_02aa`: small wrappers for the output object's virtual slot at `+0x10`; the exact slot contract is not asserted. +- `12b8:02d7` / `12b8:0344` / `12b8:03b4` -> `TextOutput_PrintfAt_12b8_02d7` / `TextOutput_PrintfWithinWidth_12b8_0344` / `TextOutput_VPrintf_12b8_03b4`: format through the shared scratch buffer, then write at a position, within a width limit, or through the active output object respectively. +- `12b8:0406` -> `TextOutput_TranslateBoundsByMetrics_12b8_0406`: queries output metrics and adjusts a four-coordinate rectangle from the measured origin and extent. +- `12b8:0492` / `12b8:04ab` / `12b8:04f0` -> `TextOutput_SetGlobalContext_12b8_0492` / `TextOutput_SaveContextAndSet_12b8_04ab` / `TextOutput_RestoreContextAndMaybeFree_12b8_04f0`: update the active global output context, save the previous pointer pair while installing a new pair, or restore the saved pair and optionally free its token. + +All 15 names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 89: Sound-cache list helpers (`12c0`) + +- `12c0:0000` -> `SndCache_List_Destroy_12c0_0000`: restores the sound-cache list's base vtable and optionally frees its list record; called during sound-cache initialization. +- `12c0:0029` / `12c0:006e` -> `LinkedList_InsertAtHead_12c0_0029` / `LinkedList_InsertAtTail_12c0_006e`: add a node at the selected endpoint and maintain head/tail links. +- `12c0:00c2` -> `LinkedList_MoveNodeToTail_12c0_00c2`: removes a node from its current position and appends it; the sound loader uses this to update record recency. +- `12c0:00f2` -> `LinkedList_UnlinkAndDestroyNode_12c0_00f2`: removes a node, then invokes its first virtual entry. +- `12c0:012d` -> `LinkedList_InsertChainAfterNode_12c0_012d`: inserts a linked chain after a selected node and repairs the tail when the insertion is at the end. +- `12c0:01bd` -> `LinkedList_RemoveNode_12c0_01bd`: removes a selected node, walking the list to find its predecessor when one is not supplied. + +All seven names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 96: CaFont glyph and measurement helpers (`1310`) + +- `1310:0000` -> `CaFont_GetGlyphYOffset_1310_0000`: reads the glyph-record word used as a vertical text-placement offset; its precise field meaning remains unknown. +- `1310:002e` -> `CaFont_DrawGlyphAt_1310_002e`: resolves a glyph subentry from the font cache and blits it at the requested screen coordinates. +- `1310:02c2` -> `CaFont_Destroy_1310_02c2`: restores the CaFont base vtable, destroys its embedded text-output state, and optionally frees the object. +- `1310:02fe` / `1310:0317` -> `CaFont_InvokeMetricSlot10_1310_02fe` / `CaFont_InvokeMetricSlot10_1310_0317`: forwarding wrappers for the inherited text-output metric slot. +- `1310:0330` -> `CaFont_MeasureTextAdapter_1310_0330`: forwards its arguments to the shared multiline text-measurement routine. + +All six names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 97: ComboBox lifecycle and selection (`1318`) + +- `1318:01f9` -> `ComboBox_Destroy_1318_01f9`: releases the two owned text/list buffers, delegates to `SpriteNode::Destroy`, and optionally frees the gump. +- `1318:025a` -> `ComboBox_HandleEvent_1318_025a`: handles combo-box input events, copies the selected option into the editable text buffer, and creates or closes the option-list gump as needed. +- `1318:063d` -> `ComboBox_GetSelectedTextOffset_1318_063d`: returns the text offset for the currently selected option, or zero when the selection index is invalid. The filename-list consumer uses the returned text. + +All three names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 98: Dispatcher and gump helpers (`1320`) + +- `1320:0146` -> `Dispatcher_SetProcess_1320_0146`: loads the process and stores it as the global dispatcher process. +- `1320:0624` -> `Dispatcher_CollectInputEvents_1320_0624`: performs the dispatcher input-collection phases, constructs normalized input records, and forwards them to the dispatch path. +- `1320:0935` -> `Dispatcher_ConvertInputRecord_1320_0935`: converts an input record's type and flags into the compact event fields consumed downstream. +- `1320:09f7` -> `Dispatcher_DispatchPendingEvents_1320_09f7`: drains pending input records and dispatches them through the active process/object path. +- `1320:0cbd` -> `Dispatcher_ValidateAndDispatchTarget_1320_0cbd`: checks the target record's required far-pointer fields, asserts on invalid state, then forwards it to the dispatcher. +- `1320:0dfc` -> `Dispatcher_SetTargetObject_1320_0dfc`: stores the supplied far pointer as the current dispatch target. +- `1320:0e0e` -> `Dispatcher_ClearTargetObject_1320_0e0e`: clears the current dispatch target. +- `1320:0ebc` -> `Dispatcher_FindObjectByPath_1320_0ebc`: searches the registered root array and follows two-byte child keys to find an object. +- `1320:0f8b` -> `Dispatcher_PopTargetAndDispatch_1320_0f8b`: removes the last registered target, creates its dispatch record, and forwards it through target validation. +- `1320:1018` -> `Dispatcher_ClearInputContext_1320_1018`: releases the current input context and clears its global far pointer. +- `1320:11bf` -> `Dispatcher_RecordEvent_1320_11bf`: appends a 20-byte event record to the buffered log and flushes the buffer when full. +- `1320:12cc` -> `Dispatcher_DestroyFlaggedRecordObject_1320_12cc`: invokes the record object's virtual method when its flag bit is set. +- `1320:130f` -> `Dispatcher_CopyRecordValueToGumpOffset34_1320_130f`: copies a four-byte value from the record into the gump field at offset `0x34`. +- `1320:14bf` -> `Dispatcher_ReplaceInputContext_1320_14bf`: updates the target and context pointers, frees the previous context buffer, and optionally frees the supplied wrapper. +- `1320:1525` -> `Dispatcher_ProcessTargetList_1320_1525`: repeatedly advances the base-camera process and dispatches list entries until the list is exhausted. +- `1320:16b6` -> `Dispatcher_ClearQueuedObjectReferences_1320_16b6`: clears queued entries whose stored far pointer matches the supplied object. +- `1320:1705` -> `Dispatcher_InitializeEventQueueStorage_1320_1705`: registers the 12-byte queue-storage allocator/initializer and resets its related globals. +- `1320:1734` -> `Gump_InitBase_1320_1734`: initializes a base gump through the shared constructor. +- `1320:175d` -> `Gump_AllocateIfNull_1320_175d`: allocates a 12-byte gump object only when the input pointer is null. + +All 19 names were applied by address and verified. Exact-name search for `FUN_1320_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 99: Viewport-backed gump and mouse event ring (`1328`) + +- `1328:006b` -> `ViewportBufferedGump_Destroy_1328_006b`: restores the vtable, destroys both owned viewports when initialized, delegates to `SpriteNode::Destroy`, and optionally frees the object. +- `1328:00d7` -> `ViewportBufferedGump_Move_1328_00d7`: restores the old screen rectangle, adjusts the saved bounds to the new location, and blits the updated region through the gump's viewports. +- `1328:0267` -> `ViewportBufferedGump_HandleLifecycleEvent_1328_0267`: handles activation/deactivation, creates and copies viewport backing regions on activation, and releases them on deactivation. Its caller is the related `Gump_HandleViewportLifecycleEvent` implementation. +- `1328:0652` -> `MouseEventRingBuffer_Push_1328_0652`: appends a 16-byte mouse event record to a 10-entry ring buffer unless it is full. +- `1328:06ab` -> `MouseEventRingBuffer_Pop_1328_06ab`: removes and returns the next 16-byte record from that ring buffer; the mouse process is a caller of the push routine. + +All five names were applied by address and verified. Exact-name search for `FUN_1328_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 100: File-selection dialog (`1330`) + +- `1330:0000` -> `FileBox_Create_1330_0000`: allocates and initializes the file box and its embedded combo box. +- `1330:00ea` -> `FileBox_SetPathText_1330_00ea`: stores the supplied path text and updates the file box and combo-box display. +- `1330:031d` -> `FileBox_FreeEntryBuffers_1330_031d`: frees the six owned entry buffers, releases their table, and refreshes the associated list state. +- `1330:03bc` -> `FileSelectionList_HandleEvent_1330_03bc`: handles list selection/activation events and validates selected paths before dispatching the resulting action. +- `1330:0517` -> `FileBox_SetDriveDirectory_1330_0517`: reads the current directory for a DOS drive, normalizes it, and updates the displayed path. +- `1330:065a` -> `FileBox_SetPathAndPattern_1330_065a`: combines a directory and filename pattern into the file box path state. +- `1330:0b8a` -> `FileBox_CommitSelectionOrNavigateUp_1330_0b8a`: commits a selected file or handles the parent-directory entry, then updates the displayed path and file list. +- `1330:12d7` -> `FileSelectionList_Destroy_1330_12d7`: frees the list object's six owned strings and filespec state before common gump destruction. +- `1330:1363` -> `FileBox_DrawPanelBackground_1330_1363`: forwards panel drawing to the shared UI background routine. +- `1330:137c` -> `FileBox_HandleInputEvent_1330_137c`: dispatches file-box input, including drive changes, path/pattern updates, and selection confirmation. +- `1330:1502` -> `FileBox_CopySelectedFilenameParts_1330_1502`: copies the selected combo-box text into the file box's filename and extension fields, returning whether a selection was available. +- `1330:163c` -> `FileBox_SetDefaultBounds_1330_163c`: initializes the file box's default rectangle to `(0, 0)-(0x6e, 0x7b)`. +- `1330:1693` -> `FileBox_DestroyComboBoxChild_1330_1693`: destroys the embedded combo box and optionally frees its storage. + +All 13 names were applied by address and verified. Exact-name search for `FUN_1330_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 101: Cached shapes and keyboard event ring (`1338`) + +- `1338:0109` -> `CachedShape_DrawSubentry_1338_0109`: fetches a cached shape subentry and draws it through the normal sprite blitter or the active transform/palette callback. +- `1338:01cf` -> `CachedShape_TestPixelRegion_1338_01cf`: fetches the cached shape subentry and forwards the requested region/point test to the shape pixel routine. +- `1338:02c5` -> `ItemCache_GetSubentryDataPointer_1338_02c5`: exposes the cached subentry data pointer through the shared item-cache lookup. +- `1338:02ed` -> `KeyboardEventRingBuffer_Push_1338_02ed`: appends a 12-byte keyboard record to a 10-entry ring buffer unless full; called by the keyboard event handler. +- `1338:0342` -> `KeyboardEventRingBuffer_Pop_1338_0342`: removes and returns the next 12-byte keyboard record; called by the dispatcher input collector. + +All five names were applied by address and verified. Exact-name search for `FUN_1338_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 102: Scrolling list control (`1340`) + +- `1340:010f` -> `ListBox_EnableSelectionEvents_1340_010f`: enables the list's selection-event flag. +- `1340:011c` -> `ListBox_DisableSelectionEvents_1340_011c`: disables the list's selection-event flag. +- `1340:0129` -> `ListBox_Draw_1340_0129`: draws the list frame, visible rows, and item text. +- `1340:02e3` -> `ListBox_HandleNavigationKey_1340_02e3`: handles up/down and page navigation keys, updates the selected item, and scrolls when needed. +- `1340:0420` -> `ListBox_HandleLifecycleEvent_1340_0420`: handles list activation/deactivation and emits the corresponding follow-up event. +- `1340:0540` -> `ListBox_HandleMouseEvent_1340_0540`: maps pointer position to a row, updates selection, and scrolls when the pointer leaves the list bounds. +- `1340:0685` -> `ListBox_HandleSelectionEvent_1340_0685`: emits a list selection event when the selection-event flag is enabled. +- `1340:0706` -> `ListBox_SetSelectedIndex_1340_0706`: updates the selected row, invokes the list's selection callback, and redraws. +- `1340:075f` -> `ListBox_SetItems_1340_075f`: stores the item source, count/stride and display parameters, then recalculates layout. +- `1340:079c` -> `ListBox_RecalculateLayout_1340_079c`: determines item count when needed, measures row height, and computes visible rows. +- `1340:084d` -> `ListBox_SortItemsAlphabetically_1340_084d`: sorts the list's string-pointer table alphabetically. +- `1340:096a` -> `ListBox_GetItemByIndex_1340_096a`: returns an indexed item using either pointer-table or fixed-stride storage. + +All 12 names were applied by address and verified. Exact-name search for `FUN_1340_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 103: Sprite-tree layout and menu-bar items (`1348`) + +- `1348:019b` -> `SpriteNode_SyncBoundsFromSource_1348_019b`: synchronizes source-node bounds into a paired gump according to the supplied layout mode. +- `1348:02c6` -> `SpriteNode_HandleGumpLifecycleEvent_1348_02c6`: handles activation/deactivation and updates active-gump and child geometry state. +- `1348:03da` -> `SpriteNode_DispatchPointerToHitChild_1348_03da`: tests sprite-tree bounds, traverses candidate children, and dispatches the pointer event to the selected node. +- `1348:0823` -> `SpriteNode_AttachAndLayoutChild_1348_0823`: attaches a child node and adjusts its bounds based on the parent and child geometry. +- `1348:090b` -> `MenuBarItem_Create_1348_090b`: constructs a labeled menu-bar item; called by the usecode debugger menu builder. +- `1348:09bb` -> `MenuBarItem_Draw_1348_09bb`: draws the menu item background, label, and associated indicator. +- `1348:0b0d` -> `MenuBarItem_MeasureLabel_1348_0b0d`: measures the item's label using the shared multiline text metrics routine. +- `1348:0b39` -> `SpriteNode_HandleGeometryEvent_1348_0b39`: handles geometry-related gump events and normalizes the node's stored extents. +- `1348:0bdc` -> `MenuBarItem_DrawCheckmark_1348_0bdc`: draws the base menu item and overlays its checkmark when enabled. +- `1348:0c92` -> `SpriteNode_UpdateBoundsFromLayout_1348_0c92`: synchronizes paired-node bounds and optionally copies the resolved layout rectangle. +- `1348:0d07` -> `SpriteNode_SetupViewportClip_1348_0d07`: configures the active viewport and clipping rectangle from node bounds. +- `1348:0d81` -> `SpriteNode_RefreshFlaggedChild_1348_0d81`: refreshes the first flagged child and clears its pending state. +- `1348:0e2e` -> `SpriteNode_SetChildrenDirtyFlag_1348_0e2e`: sets or clears bit 3 in each direct child's state flags. +- `1348:0e7f` -> `SpriteNode_FindChildById_1348_0e7f`: recursively searches child lists for a node with the requested identifier. +- `1348:0f0f` -> `SpriteNode_SetSubtreeField38_1348_0f0f`: recursively writes the supplied byte to field `0x38` on a node and its descendants. +- `1348:0f70` -> `SpriteNode_Create8x8_1348_0f70`: constructs a small sprite node with 8x8 extents. +- `1348:1025` -> `SpriteNode_AttachChildAndResizeHeight_1348_1025`: attaches a child and adjusts parent/child vertical bounds to accommodate it. +- `1348:1212` -> `SpriteNode_CopyLayoutMode1_1348_1212`: copies layout coordinates in mode 1 and forwards the associated gump update. +- `1348:1288` -> `MenuBarElement_Create_1348_1288`: constructs an 8x8 menu-bar element; called by the usecode debugger menu builder. +- `1348:1377` -> `SpriteNode_AttachChildAndResizeToText_1348_1377`: measures child text, attaches the child, and expands parent bounds to fit. +- `1348:1561` -> `SpriteNode_PropagateGeometryMode1_1348_1561`: propagates mode-1 geometry and invokes the paired node's update callbacks. +- `1348:15d4` -> `SpriteNode_DrawLine_1348_15d4`: draws a line after translating it relative to the node's bounds. +- `1348:164b` -> `WriteZeroOneDefaults_1348_164b`: writes `0` and `1` to two output fields; the precise semantic labels remain unresolved. +- `1348:169a` -> `SpriteNode_UpdateGeometry_1348_169a`: forwards to the shared sprite-node geometry update routine. + +All 24 names were applied by address and verified. Exact-name search for `FUN_1348_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 104: Mouse process and cursor management (`1358`) + +- `1358:037f` -> `MouseProcess_SetActive_1358_037f`: loads the mouse process and stores it as the active mouse process. +- `1358:03a5` -> `MouseProcess_Destroy_1358_03a5`: destroys cursor viewports, releases the mouse process, and frees the mouse-shape buffer. +- `1358:0a46` -> `MouseCursor_RestoreBackground_1358_0a46`: restores the saved screen rectangle beneath the cursor and clears its drawn-state flag. +- `1358:0a92` -> `MouseCursor_Draw_1358_0a92`: activates and draws the selected cursor shape into the viewport when not already drawn. +- `1358:0b92` -> `MouseCursor_SetShapeAtDepth_1358_0b92`: stores a cursor shape at the current shape-stack depth and redraws it if visible. +- `1358:0cbd` -> `MouseCursor_PushShape_1358_0cbd`: advances the cursor-shape stack depth, clamps it, and applies the supplied shape. +- `1358:0ce9` -> `MouseCursor_ResetShape_1358_0ce9`: resets cursor-shape depth to zero and applies the supplied shape. +- `1358:0d06` -> `MouseCursor_PopShape_1358_0d06`: returns the popped shape, lowers the stack depth, and reapplies the newly current shape. +- `1358:0e1f` -> `MouseProcess_DequeueEvent_1358_0e1f`: returns the next 16-byte mouse event from the ring buffer or pending-event slot. +- `1358:0e93` -> `MouseCursor_BeforeViewportBlit_1358_0e93`: prepares the cursor overlay before a camera viewport rectangle is redrawn. +- `1358:0f41` -> `MouseCursor_AfterViewportBlit_1358_0f41`: refreshes the cursor backing region after the camera viewport blit; paired with the preceding hook in the camera redraw routine. +- `1358:0fc9` -> `Mouse_GetCursorShapeCount_1358_0fc9`: returns the cursor-shape buffer's frame-count limit. +- `1358:0fd6` -> `MouseProcess_UpdateCursorPosition_1358_0fd6`: updates cursor coordinates, queues a movement event, and redraws the cursor overlay. +- `1358:1108` -> `MouseProcess_BeginCursorUpdate_1358_1108`: clears the mouse-process update flag before cursor movement. +- `1358:1120` -> `MouseProcess_EndCursorUpdate_1358_1120`: sets the mouse-process update flag after cursor movement. + +All 15 names were applied by address and verified. Exact-name search for `FUN_1358_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 105: NewGump and sprite-tree core (`1360`) + +- `1360:017a` -> `SpriteNode_MoveChildToTail_1360_017a`: finds a child by far pointer and moves it to the tail of the sibling list. +- `1360:01c7` -> `SpriteNode_RemoveChildAndDestroy_1360_01c7`: finds a child by far pointer, unlinks it through the callback-aware destroy path, and reports success. +- `1360:0218` -> `SpriteNode_RemoveChild_1360_0218`: unlinks a matching child without destroying it and reports success. +- `1360:0269` -> `SpriteNode_GetChildByIndex_1360_0269`: returns the indexed child from the sibling list. +- `1360:05d4` -> `NewGump_DrawTreeRecursive_1360_05d4`: draws a gump and recursively draws eligible descendants with accumulated offsets and clipping. +- `1360:078d` -> `NewGump_DrawWithCameraUpdate_1360_078d`: resolves absolute bounds, draws the gump tree, and optionally advances the camera process. +- `1360:084d` -> `NewGump_FindHitTarget_1360_084d`: recursively hit-tests visible gumps and returns the deepest matching node. +- `1360:0c35` -> `SpriteNode_GetAbsoluteY_1360_0c35`: returns the node's Y coordinate accumulated through its parent chain. +- `1360:0c6a` -> `NewGump_GetRelativeX_1360_0c6a`: converts an event X coordinate to the gump's local coordinate system. +- `1360:0c7d` -> `NewGump_GetRelativeY_1360_0c7d`: converts an event Y coordinate to the gump's local coordinate system. +- `1360:0c90` -> `NewGump_SaveViewportRectOnce_1360_0c90`: saves the current viewport rectangle when the draw-recursion guard allows it. +- `1360:107b` -> `NewGump_AcceptsEventType_1360_107b`: checks an event type against the gump's allow-list, with a sentinel for accept-all. +- `1360:10d8` -> `SpriteNode_UpdateAbsoluteGeometry_1360_10d8`: recomputes absolute bounds by accumulating ancestor offsets. +- `1360:118e` -> `Viewport_SetClipAndRefresh_1360_118e`: applies a viewport rectangle, notifies the camera process, and updates the display. +- `1360:1297` -> `NewGump_DispatchCandidate_1360_1297`: forwards a candidate gump into the shared dispatcher validation path. +- `1360:12b2` -> `Dispatcher_CopyNextRecord_1360_12b2`: forwards to the dispatcher record-copy operation. +- `1360:12cd` -> `Dispatcher_AssertFailure_1360_12cd`: assert-only forwarding shim. +- `1360:135d` -> `NewGump_ValidateId_1360_135d`: validates the stored gump identifier/complement pair and halts on mismatch. +- `1360:1395` -> `SpriteNode_DispatchEventToChildren_1360_1395`: calls each child event callback until one reports the event handled. +- `1360:13e6` -> `StaticSpriteNode_Create_1360_13e6`: creates the fixed global sprite node at `1478:4f9c`. +- `1360:1412` -> `StaticSpriteNode_Destroy_1360_1412`: destroys the fixed global sprite node at `1478:4f9c`. + +All 21 names were applied by address and verified. Exact-name search for `FUN_1360_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 106: Message box and button event filter (`1368`) + +- `1368:0000` -> `MessageBox_CreateWithOKButton_1368_0000`: builds a centered message box, measures its text, creates an OK button, and lays out both within the gump. +- `1368:0352` -> `GumpButton_FilterAndForwardEvent_1368_0352`: forwards the button callback for untyped events and for event types 1 or 4. + +Both names were applied by address and verified. Exact-name search for `FUN_1368_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 107: Cached-shape gump (`1370`) + +- `1370:0105` -> `ShapeGump_HitTestPixel_1370_0105`: checks the gump rectangle, then performs a cached-shape pixel-region hit test. +- `1370:0275` -> `ShapeGump_AdvanceFrame_1370_0275`: advances the frame by three modulo twice the frame count, redraws, and stores the new frame. +- `1370:02af` -> `ShapeGump_Create_1370_02af`: initializes the gump and its cached shape/frame state. +- `1370:0428` -> `ShapeGump_RedrawPreservingFrame_1370_0428`: redraws through the shared gump path while preserving the current frame value. + +All four names were applied by address and verified. Exact-name search for `FUN_1370_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 108: Scrollbar and usecode source pane (`1378`) + +- `1378:0177` -> `ScrollBar_DrawLeftArrow_1378_0177`: draws the left-pointing arrow glyph. +- `1378:02ee` -> `ScrollBar_DrawUpArrow_1378_02ee`: draws the up-pointing arrow glyph. +- `1378:0465` -> `ScrollBar_DrawDownArrow_1378_0465`: draws the down-pointing arrow glyph. +- `1378:05dc` -> `ScrollBar_Create_1378_05dc`: initializes the scrollbar's orientation, bounds, range, and value state; called by the source-pane constructor. +- `1378:06e1` -> `ScrollBar_SetContentExtent_1378_06e1`: computes the scrollbar's scale and thumb dimensions from the content extent. +- `1378:0790` -> `ScrollBar_Draw_1378_0790`: draws the track, thumb, and orientation-dependent borders. +- `1378:0a00` -> `ScrollBar_HandleDrag_1378_0a00`: converts pointer movement into a clamped scrollbar value and dispatches/redraws the change. +- `1378:0b04` -> `ScrollBar_HandleLifecycleEvent_1378_0b04`: handles activation/deactivation and updates the active-gump state. +- `1378:0bd3` -> `ScrollBar_SetPosition_1378_0bd3`: clamps a requested position and updates the thumb rectangle. +- `1378:0d4c` -> `UsecodeDebuggerSourcePane_Create_1378_0d4c`: constructs the usecode debugger source pane and its child controls, including its scrollbar. +- `1378:1309` -> `UsecodeDebuggerSourcePane_HandleEvent_1378_1309`: forwards supported child events, dispatches the resulting event record, and refreshes the pane. +- `1378:13da` -> `SourcePane_ForwardChildVtable48_1378_13da`: forwards to the child gump's vtable slot `0x48`. +- `1378:13fd` -> `SourcePane_ForwardChildVtable4c_1378_13fd`: forwards to the child gump's vtable slot `0x4c`. +- `1378:141a` -> `SourcePane_ForwardChildVtable50_1378_141a`: forwards to the child gump's vtable slot `0x50`. +- `1378:1608` -> `ScrollBar_GetPosition_1378_1608`: returns the stored scrollbar position at offset `0x42`. +- `1378:1618` -> `Gump_InvokeVtable48_1378_1618`: invokes vtable slot `0x48` on the supplied gump. +- `1378:1644` -> `Gump_InvokeVtable48_1378_1644`: invokes vtable slot `0x48` on the supplied gump. + +All 17 names were applied by address and verified. Exact-name search for `FUN_1378_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 109: Message-box buttons (`1380`) + +- `1380:0000` -> `GumpCreate_MsgboxButton`: allocates and initializes a message-box button, measures its label, and initializes its pressed-state and shape fields. +- `1380:00cc` -> `MsgboxButton_Draw_1380_00cc`: draws the button bevel according to its pressed state and renders its label. +- `1380:01e1` -> `Object_SetField35TrueAndUpdate_1380_01e1`: sets the button's pressed-state field at `+0x35` and redraws it. +- `1380:01fd` -> `Object_SetField35FalseAndUpdate_1380_01fd`: clears the button's pressed-state field at `+0x35` and redraws it. +- `1380:0219` -> `MsgboxButton_CreateAlt_1380_0219`: initializes a second message-box button layout with its own pressed-state and text fields; paired with the draw routine at `1380:02e5`. +- `1380:02e5` -> `MsgboxButton_DrawAlt_1380_02e5`: draws the alternate button layout using its pressed-state field at `+0x39` and label pointer at `+0x3c`. +- `1380:03fa` -> `Object_SetField39TrueAndUpdate_1380_03fa`: sets the alternate button's pressed-state field at `+0x39` and redraws it. +- `1380:0416` -> `Object_SetField39FalseAndUpdate_1380_0416`: clears the alternate button's pressed-state field at `+0x39` and redraws it. +- `1380:0432` and `1380:046c` -> `SpriteNode_DestroyAndMaybeFree`: duplicate cleanup entries for sprite-node child state. + +All three exact auto-names were renamed by address and verified. Exact-name search for `FUN_1380_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 110: Text-entry control (`1388`) + +- `1388:016e` -> `TextEntry_DestroyAndMaybeFree_1388_016e`: clears active-control globals when applicable, destroys the sprite node, and optionally frees the allocation. +- `1388:01c9` -> `TextEntry_SetText_1388_01c9`: updates the text pointer and recalculates text length, visible range, and caret/selection indices. +- `1388:0248` -> `TextEntry_Draw_1388_0248`: draws the field and text, including selection highlighting and the caret when active. +- `1388:0400` -> `TextEntry_MeasurePrefix_1388_0400`: measures the rendered width of a character prefix. +- `1388:048a` -> `TextEntry_CharIndexAtX_1388_048a`: finds the character index nearest a horizontal pixel position. +- `1388:051b` -> `TextEntry_EnsureCaretVisible_1388_051b`: adjusts the visible starting index so the caret remains within the field. +- `1388:0566` -> `TextEntry_HandleMouseButton_1388_0566`: activates/deactivates the field on pointer-button events and updates focus/redraw state. +- `1388:0685` -> `TextEntry_HandlePointerEvent_1388_0685`: maps pointer position to a caret/selection index and adjusts it when the pointer moves outside the field. +- `1388:07ab` -> `TextEntry_HandleKeyInput_1388_07ab`: processes text-entry key events, including Enter and Backspace, and updates the caret/text state. +- `1388:0c12` -> `TextEntry_SetFocus_1388_0c12`: transfers the global active text-entry control to this instance and notifies the prior control. +- `1388:0ca2` -> `TextEntry_HandleFocusTransition_1388_0ca2`: clears or transfers focus, invokes the related control callback, and redraws affected gumps. + +All 11 names were applied by address and verified. Exact-name search for `FUN_1388_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 111: Bark gump and placement slots (`1390`) + +- `1390:02c2` -> `BarkGump_Destroy_1390_02c2`: frees the text buffer, releases the placement slot, unlinks the gump, updates the active count, and optionally frees the gump allocation. +- `1390:05ce` -> `BarkGump_UpdateTextWrapper_1390_05ce`: thin wrapper to the bark text-update routine. +- `1390:05e1` -> `BarkGump_ReleasePlacementSlot_1390_05e1`: clears the gump's four-word placement rectangle from the shared table and marks its slot unused. +- `1390:0639` -> `BarkGump_UpdateTextWrapper_1390_0639`: second thin wrapper to the bark text-update routine. +- `1390:064c` -> `BarkGump_UpdateText_1390_064c`: advances the text buffer, updates font and geometry state, selects a non-overlapping placement, and redraws the gump. +- `1390:07d3` -> `BarkGump_LoadPlacementRect_1390_07d3`: copies the selected shared placement rectangle into the gump bounds. +- `1390:080a` -> `BarkGump_HandleEvent_1390_080a`: forwards the recognized event to its parent; other events refresh the bark text. +- `1390:085e` -> `BarkGump_DrawText_1390_085e`: draws the stored text using the gump's font and line offset. +- `1390:08c0` -> `FindTypeCObjectAndInvokeSlot3c_1390_08c0`: searches the type-`C` list and conditionally invokes virtual slot `0x3c`; broader purpose remains unclear. +- `1390:0934` -> `BarkGump_InitPlacementSlots_1390_0934`: initializes the shared 30-entry placement-rectangle table. +- `1390:0953` -> `BarkGump_AllocPlacementSlot_1390_0953`: allocator callback that creates an eight-byte placement-table entry. + +All 11 names were applied by address and verified. Exact-name search for `FUN_1390_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 112: Paged text gump (`1398`) + +- `1398:02d1` -> `PagedTextGump_Draw_1398_02d1`: draws the page frame and text, displaying `` when additional content remains. +- `1398:0487` -> `PagedTextGump_DrawPageText_1398_0487`: renders the current page in a 20-column, 13-line grid, handles `^` line breaks, and tracks pagination. +- `1398:0887` -> `PagedTextGump_HandleClick_1398_0887`: advances to the next page on click or invokes the parent callback when the text is exhausted. +- `1398:0a2a` -> `PagedTextGump_HandleKeyInput_1398_0a2a`: advances or exits the page view in response to Enter/Escape input. + +All four names were applied by address and verified. Exact-name search for `FUN_1398_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 113: Global file-spec lifecycle (`13a0`) + +- `13a0:304b` -> `GlobalFileSpec_Init_13a0_304b`: initializes the fixed `FileSpec` object at `1478:8b97`. +- `13a0:305c` -> `GlobalFileSpec_Destroy_13a0_305c`: destroys that same fixed `FileSpec` object. + +Both names were applied by address and verified. Exact-name search for `FUN_13a0_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 114: Item-drag operations (`13a8`) + +- `13a8:0088` -> `ItemDrag_Initialize_13a8_0088`: records the target screen point, initializes the drag gump, and dispatches its initial setup. +- `13a8:0117` -> `ItemDrag_CreateWorldItem_13a8_0117`: creates the dragged item at its stored world coordinates when appropriate. +- `13a8:01ee` -> `ItemDrag_TryPlaceAtScreenPoint_13a8_01ee`: resolves the world point beneath the pointer, validates it, and moves the preview item if placement succeeds. +- `13a8:0361` -> `ItemDrag_TryDropIntoContainer_13a8_0361`: checks whether the dragged item can enter the target container and transfers it to the requested gump coordinates. +- `13a8:048a` -> `ItemDrag_Cleanup_13a8_048a`: normalizes item quantity, lets the item fall if needed, and clears the drag-state pointer. +- `13a8:04b3` -> `ItemDrag_NormalizeQuantity_13a8_04b3`: sets quantity according to the item's shape family, excluding containers, generic items, and shape `0x4fe`. +- `13a8:0524` -> `ItemDrag_SetTargetContainer_13a8_0524`: resets drag coordinates and stores the target container context. +- `13a8:0587` -> `ItemDrag_FinalizeDrop_13a8_0587`: commits the item to world/container state, attempts stacking, and clears the temporary item reference. +- `13a8:0837` -> `ItemDrag_GetWorldPointFromScreen_13a8_0837`: resolves a screen point to world coordinates, accounting for the dragged item's footprint. + +All nine names were applied by address and verified. Exact-name search for `FUN_13a8_` now returns no remaining functions; selector `13b0` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 115: Bark-gump support and shared list callbacks (`13b8`) + +- `13b8:01ce` -> `Dispatcher_ResolvePathAndInvokeSlot3c_13b8_01ce`: resolves an object path and invokes virtual slot `0x3c` on the result. +- `13b8:04f7` -> `GumpShared_DestroyMatchingTypeCNodes_13b8_04f7`: removes matching type-`C` child nodes, performs common gump destruction, and optionally frees the gump. +- `13b8:0580` -> `BarkGump_FinishAssociatedProcess_13b8_0580`: signals the associated process, clears its process ID, and updates/dispatches the sprite node. +- `13b8:05e8` -> `GumpList_InvokeSlot48ForMatchingTypeCNodes_13b8_05e8`: invokes virtual slot `0x48` on matching type-`C` nodes. +- `13b8:06b4` -> `GumpList_MoveState2TypeCNodesToTail_13b8_06b4`: moves type-`C` list nodes with state `2` to the tail. +- `13b8:0758` -> `GumpList_InvokeSlot3cForMatchingId_13b8_0758`: invokes virtual slot `0x3c` on a type-`C` node matching the supplied ID. +- `13b8:07c7` -> `BarkGump_UpdateAnchorPosition_13b8_07c7`: recomputes the gump position from its item, avatar, or fixed-position anchor. +- `13b8:0983` -> `InitZeroSentinelRecord_13b8_0983`: initializes a small record with zero fields and a `0xffff` sentinel. + +All eight names were applied by address and verified. Exact-name search for `FUN_13b8_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 116: Keypad-button methods (`13c0`) + +- `13c0:006d` -> `KeypadButton_UpdateFrameIndex_13c0_006d`: derives the button frame index from its stored keypad value. +- `13c0:08f5` -> `KeypadButton_Draw_13c0_08f5`: draws the cached-shape button and its configured subentry icons. + +Both names were applied by address and verified. Exact-name search for `FUN_13c0_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 117: Main-menu choice control (`13c8`) + +- `13c8:28e1` -> `MainMenu_DestroyAndClearViewport_13c8_28e1`: restores the mouse background, fades the palette to black, clears/blits the viewport, and destroys the menu gump. +- `13c8:2c90` -> `MainMenuChoice_CommitSelection_13c8_2c90`: stores the selected value, notifies the matching child gump, and redraws the choice and child. +- `13c8:2d19` -> `MainMenuChoice_ClearPressState_13c8_2d19`: clears the pressed state when the stored selection no longer matches. +- `13c8:2e16` -> `MainMenuChoice_Draw_13c8_2e16`: draws the two cached-shape choice states and highlights the selected value. +- `13c8:2eca` -> `MainMenuChoice_RefreshSelection_13c8_2eca`: synchronizes the selected value with its child gump and redraws affected gumps. + +All five names were applied by address and verified. Exact-name search for `FUN_13c8_` now returns no remaining functions; selector `13d0` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 118: Mouse-cursor control (`13d8`) + +- `13d8:008d` -> `MouseCursor_ClassifyPointerRegion_13d8_008d`: initializes the cursor-control bounds, recenters the active rectangle, and classifies the pointer region. +- `13d8:01a0` -> `MouseCursor_SelectDirectionalFrame_13d8_01a0`: maps pointer direction around the tracked point to a cursor frame and clamps it to the available frame count. +- `13d8:031a` -> `MouseCursor_GetDirectionFromFrame_13d8_031a`: derives the eight-way direction index from the active cursor frame. +- `13d8:037d` -> `MouseCursor_Process_Destroy_13d8_037d`: releases mouse-control state and optionally asserts that the process is not terminating. +- `13d8:03b7` -> `MouseCursor_SetActiveProcess_13d8_03b7`: installs the active mouse process and records it in the global cursor-process pointer. + +All five names were applied by address and verified. Exact-name search for `FUN_13d8_` now returns no remaining functions; selectors `13d0` and `13e0` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 119: Gameplay sprite and item interaction (`13e8`) + +- `13e8:007d` -> `Sprite_ClearActiveUseItem_13e8_007d`: clears the active use-item selection and refreshes the sprite state. +- `13e8:0af8` -> `Sprite_ConsumeInventoryItemByShape_13e8_0af8`: consumes a matching inventory item, cycling weapon state or decrementing quality as appropriate. +- `13e8:0f56` -> `Sprite_ResetSpriteAndSoundResources_13e8_0f56`: resets sprite data and stops/compacts sound effects when the manager is active. +- `13e8:0f77` -> `Sprite_CreateInteractionGump_13e8_0f77`: constructs the gameplay interaction sprite gump and initializes its viewport and interaction state. +- `13e8:1086` -> `Sprite_ShowHintAndCenterCursor_13e8_1086`: checks for the gameplay hint and moves the cursor to screen center. +- `13e8:10a5` -> `Sprite_ResetAndPopDispatcher_13e8_10a5`: resets sprite/sound resources and pops the dispatcher target. +- `13e8:140c` -> `Sprite_HandleUseTargetSelection_13e8_140c`: resolves the selected world target, clears cursor state, and notifies the active use-item process. +- `13e8:2b74` -> `Sprite_HandlePointerButton_13e8_2b74`: handles pointer-button actions including look, drop completion, and gameplay action submission. +- `13e8:2dad` -> `Sprite_HandleControlledNpcInput_13e8_2dad`: dispatches controlled-NPC movement/action input and coordinates turning/animation state. +- `13e8:307f` -> `Sprite_HandlePointerMotion_13e8_307f`: updates drag, use-item crosshairs, and NPC-facing state from pointer movement. +- `13e8:3253` -> `Sprite_BeginItemDragAtWorldPoint_13e8_3253`: locates the item under the pointer and initializes drag offsets/state. +- `13e8:32f2` -> `Sprite_GrabItemAndActivateDrag_13e8_32f2`: grabs the temporary item, activates the drag gump, and dispatches its drag event. +- `13e8:334e` -> `Sprite_CompleteItemDrop_13e8_334e`: clears active-gump state and commits the item-drop operation. +- `13e8:338d` -> `Sprite_UpdateDraggedItemPosition_13e8_338d`: resolves and updates the dragged item's screen/world placement from pointer coordinates. +- `13e8:3796` -> `Sprite_ResetUseItemState_13e8_3796`: clears the selected use-item and its associated interaction flag. +- `13e8:37b4` -> `Sprite_UpdateUseItemTargetPosition_13e8_37b4`: updates the use-item target coordinates from the current target record. +- `13e8:388f` -> `Sprite_UpdateUseItemTargetFromItem_13e8_388f`: refreshes the use-item target coordinates from the referenced item. +- `13e8:3ec3` -> `Sprite_NoOpVtableMethod_13e8_3ec3`: empty virtual method stub. +- `13e8:3f83` -> `Sprite_DestroyAndMaybeFree_13e8_3f83`: destroys the linked callback chain and sprite node, optionally freeing the allocation. + +All 19 names were applied by address and verified. Exact-name search for `FUN_13e8_` now returns no remaining functions; selectors `13f0` and `13f8` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 120: Joystick process and direction helpers (`1400`) + +- `1400:0123` -> `Joystick_SetActiveProcess_1400_0123`: initializes the joystick process and stores it as the active process. +- `1400:0149` -> `Joystick_ClearActiveProcess_1400_0149`: shuts down the joystick process and clears the active-process pointer. +- `1400:0a14` -> `Joystick_NotifyControllerProcess_1400_0a14`: submits the configured notification to the controller process and clears its pending flag. +- `1400:0c7e` -> `Joystick_DetectAndEnable_1400_0c7e`: probes the configured joystick/gamepad type, reports detection, and updates the enabled flag. +- `1400:0cd9` -> `Joystick_GetDirectionCode_1400_0cd9`: maps the joystick X/Y dead-zone regions to the direction lookup table. + +All five names were applied by address and verified. Exact-name search for `FUN_1400_` now returns no remaining functions; selectors `1408` and `1410` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 121: Inter state copy (`1418`) + +- `1418:0172` -> `Inter_CopyState_1418_0172`: copies the fixed-size `Inter` state record and its trailing fields from the source object. + +The name was applied by address and verified. Exact-name search for `FUN_1418_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 122: UProcess text and runtime helpers (`1420`) + +- `1420:011b` -> `LinkedList_Append_1420_011b`: wrapper that inserts a node at the linked-list tail. +- `1420:0134` -> `LinkedList_MoveMatchingNodeToHead_1420_0134`: finds the node matching the supplied pointer and moves it to the list head. +- `1420:0181` -> `UProcess_ParseUnderscoreTextMarkup_1420_0181`: parses underscore-delimited text markup for a UProcess. +- `1420:05db` -> `UProcess_NormalizeDollarDelimitedText_1420_05db`: replaces each dollar-delimited span with the marker character `i`. +- `1420:0cb3` -> `EntityVm_Reinitialize_1420_0cb3`: releases and initializes entity-VM slots, then initializes the related runtime and YAMM. +- `1420:1ffd` -> `Kernel_ResetReference_1420_1ffd`: wrapper around the kernel reference reset operation. +- `1420:2010` -> `Process_SetItemSourceTypeEthereal_1420_2010`: finds the process for an item/type pair and changes its source type to `ETHEREAL`. +- `1420:209f` -> `LinkedCallbackChain_DestroyAndMaybeFree_1420_209f`: destroys the linked callback chain and optionally frees the allocation. + +All eight names were applied by address and verified. Exact-name search for `FUN_1420_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 123: YAMM usecode-value table (`1428`) + +- `1428:00bf` -> `Usecode_FreeDataTable_1428_00bf`: frees and clears the global usecode-data table. +- `1428:0251` -> `Usecode_FreeOwnedValues_1428_0251`: releases non-constant values owned by the supplied usecode record. +- `1428:03a3` -> `Usecode_DumpDataTable_1428_03a3`: prints the global value-table entries and allocation metadata. +- `1428:041d` -> `Yamm_ReportFatalError_1428_041d`: reports a fatal YAMM error through the shared error handler. +- `1428:043a` -> `Yamm_CheckValueTableIntegrity_1428_043a`: validates linked-list endpoints and the aggregate size of value-table entries. +- `1428:05ac` -> `Yamm_InvokeValueOperationTwice_1428_05ac`: invokes the value object's virtual operation at offset `0x10` twice. +- `1428:0651` -> `Yamm_ResolveNextValueEntry_1428_0651`: resolves the next entry in the value-table traversal. +- `1428:07f2` -> `Yamm_GetValueByIndexPath_1428_07f2`: traverses the value table by index and returns the selected value storage. +- `1428:0860` -> `Yamm_GetValuePayload_1428_0860`: returns the payload address within a value entry. +- `1428:087b` -> `Yamm_SetValueByIndexPath_1428_087b`: traverses an indexed path and stores the supplied value. +- `1428:0c31` -> `Yamm_FindValueByName_1428_0c31`: searches value entries by name or string content. +- `1428:0cf6` -> `Yamm_ReplaceStringValueAtIndex_1428_0cf6`: frees the old string value when needed and copies replacement bytes into the indexed entry. +- `1428:0d7a` -> `Yamm_WriteMetadataToAllValues_1428_0d7a`: writes the supplied metadata value across the selected table entries. +- `1428:0dd8` -> `Yamm_DebugPrintLongValues_1428_0dd8`: prints long-valued entries. +- `1428:0e2f` -> `Yamm_DebugPrintIntValues_1428_0e2f`: prints integer-valued entries. +- `1428:0e86` -> `Yamm_DebugPrintStringValues_1428_0e86`: prints string-valued entries. + +All 16 names were applied by address and verified. Exact-name search for `FUN_1428_` now returns no remaining functions; selector `1430` had no exact auto-names. A refreshed global exact-name count has not yet been run. + +### Batch 124: Masked triplet transform (`1438`) + +- `1438:03fb` -> `ApplyMaskToThreeByteString_1438_03fb`: for each of three masked bytes, subtracts two and replaces underflow with `?`; returns whether any byte underflowed. + +The name was applied by address and verified. Exact-name search for `FUN_1438_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 125: Palette transitions (`1440`) + +- `1440:07be` -> `Palette_FadeToGamePalette_1440_07be`: fades the active palette to the game palette over `0x28` steps. +- `1440:0ea3` -> `Palette_FadeToBlackBlocking_1440_0ea3`: fades to black, waits for the fade process to complete, and frees its temporary palette. + +Both names were applied by address and verified. Exact-name search for `FUN_1440_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 126: Cursor wrappers and object callback (`1448`) + +- `1448:0000` -> `MouseCursor_RestoreActiveBackground_1448_0000`: restores the active cursor's saved background when its state requires it. +- `1448:0031` -> `MouseCursor_DrawActiveCursor_1448_0031`: redraws the active cursor when enabled; called during fade and FLIC teardown. +- `1448:1ec9` -> `Object_UpdateFlagsAndInvokeSlot8_1448_1ec9`: updates two object state flags and invokes virtual slot `0x08`. + +All three names were applied by address and verified. Exact-name search for `FUN_1448_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 127: Item SFX cleanup and no-op (`1450`) + +- `1450:00ec` -> `Sound_FreeItemSfxData_1450_00ec`: frees and clears the global item-SFX data block when allocated. +- `1450:074b` -> `NoOpMethod_1450_074b`: empty method that returns without side effects. + +Both names were applied by address and verified. Exact-name search for `FUN_1450_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 128: RLE viewport drawing and callback forwarders (`1458`) + +- `1458:04b0` -> `VPort_DrawRleBitmapRows_1458_04b0`: decodes alternating run data and writes bitmap rows through the viewport pixel accessor. +- `1458:09d4` -> `VPort_DrawRleBitmapRowsWithSkip_1458_09d4`: decodes run-coded rows, preserving destination pixels for the `0xff` skip marker. +- `1458:0b1c` / `1458:0bc1` -> `Callback_ForwardToSlot009d_1458_0b1c` / `Callback_ForwardToSlot00a5_1458_0bc1`: forward to the corresponding callback-slot helpers. + +All four names were applied by address and verified. Exact-name search for `FUN_1458_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 129: Packed-stream bit extraction (`1460`) + +- `1460:0000` -> `ExtractBitsMSBFirst_1460_0000`: extracts a requested-width field from a 32-bit word using an MSB-first bit offset; the video decoders use it for 4-bit codes and variable-width values. + +The name was applied by address and verified. Exact-name search for `FUN_1460_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 130: Video decoding and playback lifecycle (`1468`) + +- `1468:04f9` / `1468:12fe` -> `VideoPlayer_DecodePackedRowsToWords_1468_04f9` / `VideoPlayer_DecodePackedRowsToWords_1468_12fe`: decode packed alternating runs into word-width video rows. +- `1468:0995` -> `VideoPlayer_DecodePackedRowsToDwords_1468_0995`: decodes packed alternating runs into dword-width rows. +- `1468:0e51` -> `VideoPlayer_DecodePackedRowsToBytes_1468_0e51`: decodes packed runs and copies byte-width rows. +- `1468:1d4d` -> `VideoPlayer_ClearScaledRectAndResetFlag_1468_1d4d`: clears a scaled viewport rectangle and resets the object's state field. +- `1468:1da1` -> `VideoPlayer_UpdateTimedMessage_1468_1da1`: decrements the display timer and renders/blits the associated timed message; called by `VideoPlayer_AdvanceFrameAndHandleSkip`. +- `1468:354a` -> `VideoPlayer_BuildFadePalette_1468_354a`: builds a playback palette ramp from the current video-card palette. +- `1468:37c4` -> `VideoPlayer_DrawGumpOverlayByHeight_1468_37c4`: selects and draws a cached gump subentry based on the player's height. +- `1468:3a3d` -> `VideoPlayer_WaitForPlaybackCallbacks_1468_3a3d`: registers timer events and waits for the pending playback callback counter; called by video/Flic run paths. +- `1468:3c23` -> `VideoPlayer_RestoreGameDisplayState_1468_3c23`: restores viewport, camera, palette, animation, cycle, NPC, and cursor state. +- `1468:3d36` -> `VideoPlayer_StopAndDestroy_1468_3d36`: conditionally releases playback resources and restores display state before invoking the base callback; called by `VideoPlayer_StopAndDestroyWrapper`. +- `1468:3d7a` -> `VideoPlayer_ReleasePlaybackResources_1468_3d7a`: closes the file, stops audio, restores music, frees buffers/palette, releases selectors, and clears pending keyboard events. +- `1468:4206` / `1468:4217` -> `File_EnsureGlobalDescriptor_1468_4206` / `File_CloseGlobalDescriptor_1468_4217`: initialize or close the shared file descriptor. + +All 14 names were applied by address and verified. Exact-name search for `FUN_1468_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 131: Video subtitle records (`1470`) + +- `1470:0000` / `1470:005e` -> `VideoSubtitle_InitTable_1470_0000` / `VideoSubtitle_InitAndLoad_1470_005e`: initialize the 300-record table, optionally allocating it, and initialize/load the subtitle file. +- `1470:00cc` -> `VideoSubtitle_DestroyTable_1470_00cc`: release the subtitle buffer and optionally free the table. +- `1470:00fb` / `1470:01c6` -> `VideoSubtitle_LoadFileBuffer_1470_00fb` / `VideoSubtitle_FreeFileBuffer_1470_01c6`: read the file into a 4 KB buffer and free that buffer. +- `1470:01ef` -> `VideoSubtitle_GetNextTimedRecord_1470_01ef`: advance through parsed timed records and return the next record when available. +- `1470:0239` -> `VideoSubtitle_ParseFile_1470_0239`: parse line/frame-tag records and optionally measure rendered text through a callback. +- `1470:0398`, `1470:04a0`, and `1470:04f8` -> `VideoSubtitle_ReadNextDisplayLine_1470_0398`, `VideoSubtitle_AdvanceToNextLine_1470_04a0`, and `VideoSubtitle_FindLineDelimiter_1470_04f8`: read valid display lines and advance/search the source buffer. +- `1470:05cc` -> `VideoSubtitle_ParseFrameTag_1470_05cc`: parse the numeric frame value after an `@` tag. +- `1470:0692` -> `WaitForSystemTimerTicks_1470_0692`: wait until the requested system-timer interval elapses; a computer-name gump calls it. + +All 12 names were applied by address and verified. Exact-name search for `FUN_1470_` now returns no remaining functions; a refreshed global exact-name count has not yet been run. + +### Batch 90: Runtime diagnostics and table lifecycle (`12d0`) + +- `12d0:02eb` -> `Runtime_FileOpenFailureBreakOrExit_12d0_02eb`: emits the file-open failure diagnostic once, then executes a debug breakpoint or exits according to runtime state. File, cache, and process-symbol readers call this path. +- `12d0:06ca` -> `Runtime_InitializeVesaAndFileHandles_12d0_06ca`: initializes the VESA mode-info allocation and DOS open-handle table. +- `12d0:06e7` -> `Runtime_CloseAllFileHandles_12d0_06e7`: closes and releases the runtime open-handle table. + +All three names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 91: String, distance, disk, and sound helpers (`12d8`) + +- `12d8:00f5` -> `strdup_far_12d8_00f5`: allocates and copies a far NUL-terminated string. +- `12d8:01cb` -> `ascii_uppercase_string_far_12d8_01cb`: uppercases ASCII characters in a far string in place. +- `12d8:024e` -> `DOS_GetFreeDiskSpaceBytes_12d8_024e`: queries DOS free-space fields and returns their byte product; returns `1` for the observed error sentinel. +- `12d8:02d3` / `12d8:0346` -> `distance_chebyshev_3d_12d8_02d3` / `distance_chebyshev_2d_12d8_0346`: return the maximum absolute coordinate delta across three or two axes respectively. +- `12d8:04d0` / `12d8:050d` / `12d8:0560` -> `Sound_PlaySfxIfInitialized_12d8_04d0` / `Sound_StopSfxByIdIfInitialized_12d8_050d` / `Sound_IsSfxPlaying_12d8_0560`: guard sound-effect playback, stop, and active-state query on the SFX manager initialization flag. The stop helper has callers in the computer-name gump and FLIC playback paths. + +All eight names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 94: Rectangle lists, camera process, and viewport regions (`1300`) + +- `1300:0000` -> `Rectangle_Intersects_1300_0000`: tests two inclusive four-coordinate rectangles for overlap; used by sprite-manager and viewport-region routines. +- `1300:0138` -> `RectangleList_AnyIntersects_1300_0138`: scans the linked rectangle records and returns whether any record intersects the supplied rectangle. +- `1300:0264` -> `ViewportRectNode_InitializeAndReplace_1300_0264`: removes/releases the old viewport rectangle node and initializes the replacement bounds. +- `1300:02e8` -> `ViewportRectList_CoalesceOverlaps_1300_02e8`: merges, removes, or splits overlapping viewport rectangles to maintain a non-overlapping region list used by sprite-manager and camera-overlay redraw. +- `1300:08ad` -> `BaseCameraProcess_Destroy_1300_08ad`: clears the global base-camera pointer, destroys its embedded dispatch entries, and applies the termination assertion when requested. +- `1300:0920` / `1300:0c6c` -> `BaseCameraProcess_EnsureGlobal_1300_0920` / `BaseCameraProcess_EnsureCreated_1300_0c6c`: lazily create and publish the global base-camera process; the latter is a thin wrapper. +- `1300:0941` / `1300:0c75` -> `NoOp_1300_0941` / `NoOp_1300_0c75`: one-byte return and a thin wrapper to it. +- `1300:0942` / `1300:0d44` -> `Camera_RestoreSavedViewportRects_1300_0942` / `Camera_RestoreSavedViewportRects_1300_0d44`: coalesce queued rectangles, redraw each saved viewport region, destroy the queue, and clear its pending state; the second entry is a wrapper. +- `1300:0b5c` / `1300:0c55` -> `Viewport_SaveCurrentRect_1300_0b5c` / `Viewport_ClearSavedRects_1300_0c55`: push the current viewport bounds (or an empty rectangle) into the saved-region chain, or destroy the chain and reset its state. +- `1300:0c7e` -> `Camera_DebugDrawViewportRectsAndWait_1300_0c7e`: clears/redraws fixed viewport test rectangles, restores queued regions, then waits for a key. +- `1300:0d04` / `1300:0d2d` -> `ViewportRectCallbackChain_Initialize_1300_0d04` / `ViewportRectCallbackChain_Destroy_1300_0d2d`: initialize the saved-region callback-list state or destroy its nodes. + +All 16 names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 95: Gump activation and pointer-state methods (`1308`) + +- `1308:0000` -> `Gump_InvokeVtableSlot8_1308_0000`: dispatches the object's virtual slot at `+8`. +- `1308:001d` -> `Gump_HandleActivationEnterExit_1308_001d`: on activation, publishes the active gump and calls the activation slot; on deactivation, clears active state and conditionally creates the follow-up gump when the pointer remains in bounds. +- `1308:0151` -> `Gump_UpdatePointerHoverState_1308_0151`: compares pointer bounds with the hover flag, dispatches the enter/leave virtual slot, and marks the gump dirty. +- `1308:0254` -> `Gump_HandleActivationWithExitCleanup_1308_0254`: wraps activation/deactivation handling and performs the extra leave callback when the shared active state has cleared. +- `1308:0371` -> `Gump_HandleTimedActivationEnterExit_1308_0371`: activation/deactivation variant that records a timer deadline and includes the repeat-state flag. +- `1308:04cd` -> `Gump_UpdateHoverAndInvokeBaseEvent_1308_04cd`: updates pointer hover state, then dispatches the base event slot at `+4`. +- `1308:04fd` -> `Gump_RepeatActivationAfterDelay_1308_04fd`: when the repeat flag is set and its timer expires, advances the deadline and creates the follow-up gump. + +All seven names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 93: VPort panel and UI text helpers (`12f8`) + +- `12f8:0000` -> `VPort_FillInsetRect_12f8_0000`: fills the full rectangle with the base color and its inset with the requested fill color. +- `12f8:004b` -> `VPort_DrawBeveledRect_12f8_004b`: draws the filled interior and contrasting top/left versus bottom/right bevel edges. +- `12f8:01a5` -> `VPort_DrawTopLeftBevel_12f8_01a5`: draws the filled interior with the alternate top/left edge treatment used by adjacent gump classes. +- `12f8:036b` -> `UIObject_AttachCaFont_12f8_036b`: creates the requested `CaFont` and stores its pointer in the UI object. +- `12f8:038a` -> `UIObject_DrawPanelBackground_12f8_038a`: selects the flat or beveled panel renderer from the object's style byte. +- `12f8:044a` -> `Gump_HandleViewportLifecycleEvent_12f8_044a`: forwards the event to the gump viewport lifecycle handler, which creates/restores its offscreen viewports or tears them down and clears active-gump state. +- `12f8:0463` -> `Gump_PrintfClippedToRect_12f8_0463`: formats into a scratch buffer, computes the available gump width, then writes through the width-limited text-output path. Source and watch debugger panes are callers. +- `12f8:055f` -> `SpriteTree_PointInBoundsWrapper_12f8_055f`: forwards the supplied point/object fields to the sprite-tree bounds helper. + +All eight names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 92: Sound-cache management and teardown (`12f0`) + +- `12f0:0298` -> `SndCache_SetResourceInterface_12f0_0298`: stores the resource-interface pointer and resets its companion state; called during SFX manager initialization. +- `12f0:0495` -> `SndCache_ReleaseSlot_12f0_0495`: stops a sound occupying the indexed cache slot, unlinks its record, restores the selector base/limit, and marks the slot unused. +- `12f0:0a3e` -> `SndCache_CompactFreeChunks_12f0_0a3e`: copies data from adjacent unreferenced chunks, coalesces their ranges, repairs selector bases, and removes merged list records. +- `12f0:0bc1` / `12f0:0bd7` -> `SndCache_CallbackChain_ResetHead_12f0_0bc1` / `SndCache_CallbackChain_Clear_12f0_0bd7`: reset the global callback-chain head or reset it and destroy its nodes. +- `12f0:0bee` -> `SndCache_CallbackChain_Destroy_12f0_0bee`: installs the callback-chain vtable, destroys its nodes, and optionally frees the object. +- `12f0:0c29` -> `SndCache_Object_Destroy_12f0_0c29`: restores the base object vtable through the shared helper and optionally frees the object. +- `12f0:0c64` -> `SndCache_List_Destroy_12f0_0c64`: restores the sound-cache list vtable through its shared helper and optionally frees the list. + +All eight names were applied by address and verified. A refreshed global exact-name count has not yet been run. + +### Batch 132: Configuration file load and save (`1018`) + +- `1018:0000` -> `LoadConfigFile`: checks for `CRUSADER.CFG`, then uses the config token/line helpers to parse settings, including audio, controls, display, and path state. Its initialization caller is `Init_Everything` at `1048:03a1`. +- `1018:0ced` -> `SaveOptionsToConfigFile`: serializes current audio, control bindings, display, path, and custom-track settings through the config writer; `MainMenuOptionsMenu_Destroy` calls it at `13c8:1770`. + +The segment contains exactly these two functions, both already named. Loader validation and malformed/unknown-option behavior remain incompletely characterized. + +### Batch 133: Collision masks and gravity item processes (`1038`) + +- `1038:0000` / `1038:0072` -> `AreaSearch_CheckCollision` wrapper/core: the wrapper optionally allocates the result byte and supplies the item's current point and shape; the core scans candidate items, filters by spatial/Z overlap and intersecting solid/damage flags, then accumulates directional collision bits. It returns `0x1f` for the zero-Z case and sets a combined bit when opposing direction pairs are blocked. +- `1038:0395` -> `GravityProcess_CreateProcess`: initializes a gravity process with item, velocity, and gravity state, clears the item's bouncing status, and records NPC falling state and starting Z. +- `1038:04bc` -> `GravityProcess_Finish_1038_04bc`: handles NPC landing/death follow-up, destroys embedded dispatch entries, and optionally asserts termination. +- `1038:06d2` -> `GravityProcess_Run`: drives per-tick gravity and item movement; its downward sweep, area cleanup, and finish helpers are separately identified below. Full tick-state transitions remain open. +- `1038:1131` / `1038:11fd` -> `GravityProcess_CheckDownwardSweep_1038_1131` / `GravityProcess_FastAreaCleanup`: probe downward motion at adjusted Z, or settle the item through an area-search collision move before invoking the process callback when needed. +- `1038:12a6` / `1038:1334` -> `Item_Hurl` / `Item_Fall`: hurl creates a gravity process or adds velocity to the existing one; fall starts downward motion only for non-floating shapes with nonzero weight. + +All nine functions in selector `1038` are named; exact-name search for `FUN_1038_` returned no matches. The complete gravity tick state machine and call-site interpretation of the collision mask remain open. + +### Batch 134: Extender calls and gravity trajectory adapters (`1040`) + +- `1040:0000`, `1040:0035`, `1040:0041`, and `1040:005a` -> `DosExtenderCallInterrupt_1040_0000`, `DosExtenderCallInterrupt_1040_0035`, `DosExtenderCallInterrupt_1040_0041`, and `DosExtenderCallInterrupt_1040_005a`: call or chain through INT 21h/2Fh handlers, with carry-checked paths in the latter two. Exact service numbers and register contracts remain unresolved. +- `1040:0290` -> `Item_HurlWithParams`: forwards gravity and XYZ velocity fields from the supplied parameter record to `Item_Hurl`. +- `1040:02c0` -> `Ensure_GravityProcess`: ends an existing gravity process for the item, creates a replacement from the supplied motion parameters, marks it no-terminate, and returns whether the current point is within a Manhattan distance of `0x32` from the requested point. +- `1040:0429` -> `dos_free_disk_space`: queries DOS free-space fields for the current directory and returns their product; the exact units and error contract remain open. + +All ten functions in selector `1040` are named; exact-name search for `FUN_1040_` returned no matches. The extender interrupt service/register contracts and gravity-proximity helper's caller-side purpose remain unresolved. + +### Batch 135: Game startup, teardown, and command-line options (`1048`) + +- `1048:039b` -> `Init_Everything`: loads configuration and checks free space, initializes the kernel and presentation callbacks, performs a timer/process sanity check, creates viewport/cache state, then initializes item/usecode, NPC, display, savegame, audio, font, camera, mouse, gump, animation, and input systems before calling `Game_Start`. It prefers the static fixed-map archive when present. +- `1048:081b` -> `Uninitialize`: stops audio and floating-point state, tears down gameplay/display/resource subsystems, releases viewports, fades the palette, and shuts down the kernel. +- `1048:09b9` -> `HandleCommandlineArgs`: handles help/exit, usecode override (`-u`), debug, set-version exit, asylum, warp coordinates, skill, map offset, egg, and demo options; unrecognized tokens are passed to `CheckForLaurieArg`. +- `1048:01dc` / `1048:025b` -> `Runtime_InitializeAndHandleCommandLine_1048_01dc` / `Runtime_DrawStartupBanner_1048_025b`: initialize and dispatch command-line processing, or set text video and print the startup banner. + +All 15 functions in selector `1048` are named; exact-name search for `FUN_1048_` returned no matches. Initialization/teardown dependency ordering and the behavior of the remaining weakly characterized helpers remain open. + +### Batch 136: Savegame slots, quick-save, and restore (`1050`) + +- `1050:000d` -> `Savegame_Init`: allocates and clears the 13 slot-label buffers, then opens existing numbered save files to populate slot metadata. +- `1050:00dc` -> `Savegame_GetFilename`: builds a numbered filename under the savegame directory. +- `1050:0115` -> `Savegame_QuickSave`: only writes for controlled avatar 1; suspends audio and clears pending input, then serializes cache, NPC, RNG/callback, process, usecode, and music state before closing the file. +- `1050:02f1` -> `Savegame_LoadProbably`: only loads for controlled avatar 1 and an existing save file; reinitializes kernel/entity VM state, restores cache/NPC/RNG/callback, sprite manager, YAMM, usecode, music, and process state, then rebuilds joystick/audio/spatial state. It restores blast-limit and frame-skip settings after the load. +- `1050:051f` / `1050:0532` -> `SavegameSlot_GetLabelPtr` / `SavegameSlot_SetLabel`: retrieve a slot's label buffer or clear it and copy supplied text. +- `1050:057e` -> `File_CloseAndMaybeFree`: closes a file object and frees it when the low-bit ownership flag is set. + +All seven functions in selector `1050` are named; exact-name search for `FUN_1050_` returned no matches. Save-file schema/versioning and malformed-file or partial-load behavior remain open. + +## Suggested Triage + +- Code30's previously listed 18 candidates were all renamed in the duplicate batch. Ten more Code1 candidates through `1000:4007` were subsequently named; the refreshed Code1 backlog now contains only `1000:018a` and `1000:2bf2`. +- Cross-check each candidate against the segment coverage ledger and subsystem docs before decompiling. Prefer caller/callee role, strings, data references, or verified raw mappings as evidence. +- Rename only after confirming behavior. Keep a concise decompiler comment when a verified raw mapping or external evidence supports the name. +- Refresh this inventory from the live Ghidra database after rename batches; it is a snapshot, not a maintained source of truth. + +## Next Concrete Steps + +1. The address-ordered code-selector scan is complete through the final code segment `1470`; `1478` and `1480` are data segments and `1488` is external memory. The refreshed global `FUN_` search returns exactly `1000:018a` and `1000:2bf2` (the search at offset 2 is empty). +2. Identify `Ordinal_89` for `1000:018a` from an authoritative Phar Lap service table or a verified import map; the local extender notes, live import symbol, and inspected 1994 SDK header do not establish its service contract. +3. Revisit `1000:2bf2` only when caller, raw-mapping, or boundary evidence can separate its entry from the malformed `runtime_fatal_error_exit_1000_0240` body. +4. Keep Ordinals 40 and 42 unnamed until their service contracts are independently verified. +5. Resolve the two remaining exact auto-names only when authoritative ordinal evidence or reliable function-boundary/caller evidence becomes available; rerun the global `FUN_` search after any such change. +6. Refresh the exact-name and per-block candidate inventory after each batch; the dated baseline was 381 functions across 46 code blocks, before Batches 87 and later. diff --git a/docs/jp-remorse-decompilation-progress.md b/docs/jp-remorse-decompilation-progress.md new file mode 100644 index 0000000..bf218fd --- /dev/null +++ b/docs/jp-remorse-decompilation-progress.md @@ -0,0 +1,2259 @@ +# Japanese No Remorse Decompilation Progress + +## Objective and Method + +Map the Japanese Windows executable broadly enough to support a later, evidence-based comparison with the Western edition. The active live Ghidra program for this pass was `/ja/CRUSADER.EXE`, a separate Win32 PE target from the Western DOS/NE executable. All analysis and symbol/comment changes below were made through Ghidra MCP; REA and the offline PyGhidra CLI were not used. + +Ghidra symbol and comment edits are pending in the live project. This pass did not save the Ghidra project or modify executable bytes. JP and Western addresses are not directly interchangeable; compare recovered behavior and data roles, not address values. + +## Coverage Report After Each Batch + +After every verified JP analysis batch, run `tools/jp_executable_documentation_report.py` against the active `/ja/CRUSADER.EXE` through the live Ghidra MCP read-only script endpoint. Pass this script path to `run_readonly_script`: + +```text +K:\ghidra\Crusader_Decomp\tools\jp_executable_documentation_report.py +``` + +Append a dated row below using the generated ledger-tracked function count and percentage, untracked count, function-body byte coverage, and defined-instruction byte coverage. Keep prior rows so progress between batches remains visible. Treat exact function-entry matches in the main progress tables as a tracking proxy, not a semantic-completeness score; the report does not count prose-only references or subsystem-specific JP documents. Run it after the Ghidra analysis and document updates, and do not save the Ghidra project or modify executable bytes. + +| Date | Tracked function entries | Not in main tables | Function-body bytes | Defined instruction bytes | Batch | +|---|---:|---:|---:|---:|---| +| 2026-10-11 | 186 / 1,493 (12.5%) | 1,307 (87.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Baseline after the startup-chain documentation update. | +| 2026-10-11 | 202 / 1,493 (13.5%) | 1,291 (86.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Address-ordered pass `00414698`-`00415d68`; reused the previously documented `00415eec` entry. | +| 2026-10-11 | 222 / 1,493 (14.9%) | 1,271 (85.1%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Keyboard-control/static-overlay batch `004168cc`-`0041a274`; exact ledger report then exposed lower-address gaps beginning at `0040e764`. | +| 2026-10-11 | 242 / 1,493 (16.2%) | 1,251 (83.8%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Filled report-discovered lower-address gaps `0040e764`-`0040fb54` in the viewport/text table. | +| 2026-10-11 | 246 / 1,493 (16.5%) | 1,247 (83.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Normalized the previously documented `004123d0`-`004123e8` accessor range to four exact entry addresses so the report counts them. | +| 2026-10-11 | 266 / 1,493 (17.8%) | 1,227 (82.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0040fc74` through `0041ccc8`, including explicit rows for spatial/process helpers. | +| 2026-10-11 | 286 / 1,493 (19.2%) | 1,207 (80.8%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0041cdf4` through `0041ea3c`, documenting dispatcher and item-notification paths. | +| 2026-10-11 | 299 / 1,493 (20.0%) | 1,194 (80.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 13 report-listed entries from `0041ea78` through `0041f6ec`, documenting viewport grid, render-order, and process-queue paths. | +| 2026-10-11 | 299 / 1,493 (20.0%) | 1,194 (80.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Applied evidence-supported names and comments to 23 tracked functions and two supporting shape-record helpers; address coverage stayed unchanged. | +| 2026-10-11 | 299 / 1,493 (20.0%) | 1,194 (80.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Applied six evidence-supported names to keyed-entry cache helpers, item-shape interaction, and type-`0xf0` process construction; address coverage stayed unchanged. | +| 2026-10-11 | 319 / 1,493 (21.4%) | 1,174 (78.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `0041f954` through `00421c08`, documenting viewport spatial-node lifetime, render-order relations, visible-item animation, and invalidation. | +| 2026-10-11 | 319 / 1,493 (21.4%) | 1,174 (78.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Resolved the previously deferred `0044dc9c` as `item_action_process_dispatch`; address coverage stayed unchanged. | +| 2026-10-11 | 339 / 1,493 (22.7%) | 1,154 (77.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00421f9c` through `00423358`, covering tracked-item viewport state, intrusive-list utilities, and audio cleanup/update paths. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `0042335c` through `004237d0`, covering sound playback setup/shutdown and item-catalog lookup helpers. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Renamed and commented 11 tracked functions from `004071a0` through `0040add8`; tracked generated names fell from 85 to 74. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Renamed and commented 13 functions from `0040ce20` through `0040f920`; tracked generated names fell from 74 to 61. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Renamed and commented 13 functions from `0040fb54` through `00412c10`; tracked generated names fell from 61 to 48. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Renamed and commented 14 functions from `00412ce0` through `0041ccc8`; tracked generated names fell from 48 to 34. | +| 2026-10-11 | 359 / 1,493 (24.0%) | 1,134 (76.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Renamed and commented the final 34 documented candidates from `00422990` through `00458b8c`, and corrected `004059f0`; tracked generated names fell from 34 to 0. | +| 2026-10-11 | 379 / 1,493 (25.4%) | 1,114 (74.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00423830` through `00424d0c`, covering catalog selectors, item shape state, and type-`0xf0`/`0x20f` process paths. | +| 2026-10-11 | 399 / 1,493 (26.7%) | 1,094 (73.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00424f70` through `00425b04`, covering queue operations, fatal reporting, and DirectDraw palette fades. | +| 2026-10-11 | 419 / 1,493 (28.1%) | 1,074 (71.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00425b70` through `00426924`, covering grayscale palette transitions and file-stream operations. | +| 2026-10-11 | 439 / 1,493 (29.4%) | 1,054 (70.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00426c1c` through `004281e4`, covering memory-backed text parsing, path enumeration, usecode caches, and indexed-file helpers. | +| 2026-10-11 | 448 / 1,493 (30.0%) | 1,045 (70.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next nine entries from `00428224` through `00428918`, covering flex reads, indexed-resource cache access, and object initialization helpers. | +| 2026-10-11 | 468 / 1,493 (31.3%) | 1,025 (68.7%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00428934` through `00429fb0`, covering text layout, palette management, process construction, and resource-cache lookup. | +| 2026-10-11 | 488 / 1,493 (32.7%) | 1,005 (67.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `0042a118` through `0042bf18`, covering glob items, gravity processes, indexed resources, and static-resource pools. | +| 2026-10-11 | 508 / 1,493 (34.0%) | 985 (66.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `0042c0b0` through `00431860`, covering usecode dispatch and item containment/shape accessors. | +| 2026-10-11 | 528 / 1,493 (35.4%) | 965 (64.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `0043187c` through `00431db4`, covering item state tables and shape-class helpers. | +| 2026-10-11 | 548 / 1,493 (36.7%) | 945 (63.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00431df8` through `00432c68`, covering item lifecycle hooks, usecode item actions, direction/dimension helpers, and spatial overlap. | +| 2026-10-11 | 568 / 1,493 (38.0%) | 925 (62.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `00432ea0` through `0043399c`, covering item footprint predicates, coordinate/flag accessors, and usecode event helpers. | +| 2026-10-11 | 588 / 1,493 (39.4%) | 905 (60.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 entries from `004339cc` through `00434a94`, covering usecode event selectors, item-state bytes, shape flags, and item transitions. | +| 2026-10-11 | 598 / 1,493 (40.1%) | 895 (59.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the final 10 entries for the requested threshold, from `00434ab0` through `00435100`, covering item helper wrappers, shape action classification, and a usecode spawn path. | +| 2026-10-11 | 618 / 1,493 (41.4%) | 875 (58.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `004352b4` through `00437394`, covering item-grid updates, cell lists, and ID-pool management. | +| 2026-10-11 | 638 / 1,493 (42.7%) | 855 (57.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `004375a4` through `00439284`, covering item-pool transitions, shape-profile helpers, and spatial selectors. | +| 2026-10-11 | 658 / 1,493 (44.1%) | 835 (55.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0043935c` through `0043ca28`, covering selector iteration, shape-footprint queries, joystick polling, and process-table helpers. | +| 2026-10-11 | 678 / 1,493 (45.4%) | 815 (54.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0043ca98` through `00443f24`, covering process notifications, dispatcher records, list/resource helpers, and runtime transitions. | +| 2026-10-11 | 698 / 1,493 (46.8%) | 795 (53.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00444470` through `00446b34`, covering runtime commands, DirectDraw/UI helpers, and process-related arrays. | +| 2026-10-11 | 718 / 1,493 (48.1%) | 775 (51.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00446b78` through `00448740`, covering process-ID lists, shape state, and collision queries. | +| 2026-10-11 | 738 / 1,493 (49.4%) | 755 (50.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00448818` through `0044a798`, covering collision processing, mouse control, and audio voice updates. | +| 2026-10-11 | 747 / 1,493 (50.0%) | 746 (50.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 9 report-listed entries from `0044ab2c` through `0044b980`, completing the 50% address-tracking milestone. | +| 2026-10-11 | 767 / 1,493 (51.4%) | 726 (48.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0044ba18` through `0044c654`, covering audio lifecycle and dispatcher/resource-list helpers. | +| 2026-10-11 | 787 / 1,493 (52.7%) | 706 (47.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0044c6d4` through `0044d910`, covering gump rendering and dispatcher/process helpers. | +| 2026-10-11 | 807 / 1,493 (54.1%) | 686 (45.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0044d984` through `0044f588`, covering shape-state and per-item record helpers. | +| 2026-10-11 | 827 / 1,493 (55.4%) | 666 (44.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0044f5c0` through `00450124`, covering item allocation and shape-slot records. | +| 2026-10-11 | 847 / 1,493 (56.7%) | 646 (43.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00450148` through `00450a48`, covering item action modes and related-slot accessors. | +| 2026-10-11 | 867 / 1,493 (58.1%) | 626 (41.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00450a68` through `00450e54`, covering item option values, packed fields, and runtime action state. | +| 2026-10-11 | 887 / 1,493 (59.4%) | 606 (40.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00450e74` through `00451960`, covering item-value adjustment, linked-item state, and interaction bit flags. | +| 2026-10-11 | 907 / 1,493 (60.8%) | 586 (39.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00451980` through `00455ce8`, covering direction processes, palette transforms, and AVI playback. | +| 2026-10-11 | 927 / 1,493 (62.1%) | 566 (37.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00455fb4` through `00457930`, covering AVI playback lifecycle, shape-resource usage maps, and process filters/setters. | +| 2026-10-11 | 947 / 1,493 (63.4%) | 546 (36.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00457994` through `00458ecc`, covering keyboard categories, process timers, dependency expressions, and relation state. | +| 2026-10-11 | 967 / 1,493 (64.8%) | 526 (35.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00458f3c` through `00459940`, covering process state/timer helpers, static-overlay streams and palettes, rectangle operations, and item-process lists. | +| 2026-10-11 | 987 / 1,493 (66.1%) | 506 (33.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `004599e0` through `0045d0f4`, covering process-list cleanup, savegame state/UI, argument descriptors, and shape-resource caching. | +| 2026-10-11 | 1,007 / 1,493 (67.4%) | 486 (32.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0045d140` through `0045ed80`, covering static-resource swap files, snap-egg item bounds/overlap, and sound-FLX cache management. | +| 2026-10-11 | 1,027 / 1,493 (68.8%) | 466 (31.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0045ee9c` through `00460044`, covering sound-FLX channel management, spatial sound events, and item-event cleanup. | +| 2026-10-11 | 1,046 / 1,493 (70.1%) | 447 (29.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 19 report-listed entries from `0046009c` through `004611f4`, covering sound-event maintenance and the sprite manager/render-region paths. | +| 2026-10-11 | 1,066 / 1,493 (71.4%) | 427 (28.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00461230` through `00463350`, covering sprite-process animation, position-query movement, and cursor-state helpers. | +| 2026-10-11 | 1,086 / 1,493 (72.7%) | 407 (27.3%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00463390` through `00464390`, covering bottom-toolbar state, AVI text/file buffers, shutdown dispatch, and process timing. | +| 2026-10-11 | 1,106 / 1,493 (74.1%) | 387 (25.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Checkpoint for the already documented `00463390`-`00464390` batch; this ledger row was omitted when that batch was first recorded. | +| 2026-10-11 | 1,126 / 1,493 (75.4%) | 367 (24.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00465b88` through `004671b0`, covering mouse/disk helpers, command-line parsing, and Usecode override/resource processing. | +| 2026-10-11 | 1,146 / 1,493 (76.8%) | 347 (23.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00467304` through `0046857c`, covering Usecode process serialization, resource-cache lifetime, random helpers, and bitmap-buffer management. | +| 2026-10-11 | 1,166 / 1,493 (78.1%) | 327 (21.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00468588` through `00469a10`, covering bitmap-buffer operations, clipped drawing/blitting, palette effects, and process setup. | +| 2026-10-11 | 1,186 / 1,493 (79.4%) | 307 (20.6%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added 20 report-listed entries from `00469a2c` through `0046e2a0`, covering runtime flags, item-shape interactions, modal UI state, and viewport selection candidates. | +| 2026-10-11 | 1,226 / 1,493 (82.1%) | 267 (17.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0046fc84` through `00471c99`, covering Usecode value-list operations, item-shape selection UI, and indexed-shape blitters. | +| 2026-10-11 | 1,246 / 1,493 (83.5%) | 247 (16.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00471d49` through `004721b4`, covering pixel-effect blitters, tracked-resource management, RNG, config helpers, and x87 trig routines. | +| 2026-10-11 | 1,266 / 1,493 (84.8%) | 227 (15.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `004721be` through `0047286a`, covering string/path helpers, heap block release, process exit, file modes, and formatted stream output. | +| 2026-10-12 | 1,286 / 1,493 (86.1%) | 207 (13.9%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0047286f` through `00472d68`, covering resource release, runtime utilities, handle-table helpers, and Win32 startup. | +| 2026-10-12 | 1,306 / 1,493 (87.5%) | 187 (12.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00472dd0` through `00473d3b`, covering event interpretation, heap allocation, and formatted input/output. | +| 2026-10-12 | 1,326 / 1,493 (88.8%) | 167 (11.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00473d43` through `00475026`, covering formatted-input conversions, DBCS string helpers, runtime frames, and heap block allocation/free. | +| 2026-10-12 | 1,346 / 1,493 (90.2%) | 147 (9.8%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00475131` through `0047598a`, covering runtime error state, Win32 file operations, buffered streams, and local-time records. | +| 2026-10-12 | 1,366 / 1,493 (91.5%) | 127 (8.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `004759ef` through `00476530`, covering timestamp conversion, runtime signal/exception handling, Win32 handle tables, and mutex acquisition. | +| 2026-10-12 | 1,386 / 1,493 (92.8%) | 107 (7.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00476592` through `0047738c`, covering TLS thread contexts, runtime callback dispatch, event records, exception actions, and virtual-region tracking. | +| 2026-10-12 | 1,406 / 1,493 (94.2%) | 87 (5.8%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00477400` through `00477ba2`, covering virtual-region allocation, numeric conversion, DBCS navigation, and Win32 file/handle helpers. | +| 2026-10-12 | 1,426 / 1,493 (95.5%) | 67 (4.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00477cbf` through `00478a46`, covering buffered file output, runtime math/stack support, calendar conversion, and timezone rules. | +| 2026-10-12 | 1,446 / 1,493 (96.9%) | 47 (3.1%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00478b56` through `0047998a`, covering heap reallocation, thread-context cleanup, virtual regions, and math-error reporting. | +| 2026-10-12 | 1,466 / 1,493 (98.2%) | 27 (1.8%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `00479991` through `0047ae78`, covering exception dispatch, math diagnostics, string comparison, floating-point helper logic, and Win32 import thunks. | +| 2026-10-11 | 1,206 / 1,493 (80.8%) | 287 (19.2%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed entries from `0046e384` through `0046faf0`, covering static-overlay updates, weapon-cache records, and Usecode value heap/list operations. | + +Baseline context: Ghidra reported 1,618 total functions across all address spaces, 110 tracked entries with descriptive names and 76 with generated names, 82 descriptive names outside the main progress tables, 3 functions with function comments, and 46 thunks. Five table addresses did not correspond to function entries; these are switch/option addresses, not missed function starts. These supporting values are useful for triage but are not the primary progress percentage. + +## Address-Ordered Pass: Initial Span Dispatchers + +The lowest mapped address, `00400000`, is the PE/DOS header, not code. The first Ghidra-defined function in the code segment is `0040102e`. This pass starts there and follows function addresses upward; earlier subsystem batches elsewhere in this document remain useful evidence, but are not the continuation cursor. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0040102e` | `dispatch_copy_u8_span_to_u16` | High confidence for the operation. Selects one of `0x140` unrolled bodies at 12-byte spacing. Raw bodies at `00401050` and `00401f44` read successive source bytes and store each as a 16-bit destination value. Called by the run decoder at `00454958`. | +| `00401f58` | `dispatch_copy_u8_span_to_two_u16_dests` | High confidence for the operation. Selects one of `0x140` unrolled bodies at 19-byte spacing. Verified bodies copy each source byte as a 16-bit value to two destinations separated by `0x280` bytes. Called by the run decoder at `00454d0c`. | +| `00403742` | `dispatch_copy_u8_span_to_two_u32_dests` | High confidence for the operation. Selects one of `0xa0` unrolled bodies at 24-byte spacing. Verified bodies expand each source byte to a 32-bit value and write two destinations separated by `0x280` bytes. Called by the run decoder at `00454a90`. | + +The three callers decode run lengths from a packed nibble stream and invoke their dispatcher for selected spans. This supports the span-copy role, but the callers' full image-format and destination-layout contracts remain open. The unrolled target bodies are present as raw executable bytes but are not currently defined as instructions in Ghidra; operation details above were checked directly through MCP memory reads. Function renames and decompiler comments are pending in the live Ghidra session; no bytes were changed and the project was not saved. + +## Verified Batch: NPC Process Helpers + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00404670` | `npc_process_init_base` | High confidence. Allocates a process object, installs `g_npcProcessFnPtrs`, sets base type `0x205`, associates the item, and initializes common flags. `AttackProcess` calls it at `0040af2f`, then replaces the dispatch table and process type with its own (`0x259`). The Stand, Pace, and Guard constructors at `00404904`, `00404d30`, and `00405030` contain the same base initialization sequence. | +| `00404704` | `npc_process_check_target_adjacent` | High confidence for an adjacency/eligibility check; parameter details remain open. It checks neighboring directions and a mode-dependent target/state condition. Callers include `StandProcess_Run` (`004049a8`), `PaceProcess_Run` (`00404dd8`), `GuardProcess_Run` (`004050e0`), and `FUN_00407304`. A true result triggers action `0x71` in Stand/Pace and action `5` in Guard. | + +Decompiler comments were added at both entries to preserve the evidence and the unresolved parameter semantics. Read-back confirmed both renamed functions and comments in the active Ghidra session. +## Address-Ordered Pass: NPC Process Constructors and Run Paths + +The existing verified entries at `00404670` and `00404704` were reused, then this pass continued through the neighboring class-specific constructors and run methods. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00404904` | `StandProcess_00404904` | High confidence for construction: reuses the common NPC base setup, records the item, installs `g_standProcessFnPtrs`, sets type `0x258`, and applies process flags `0x101`. | +| `004049a8` | `StandProcess_Run` | High confidence for the observed path. Checks item-bounds overlap and action state, then uses the shared adjacency test to dispatch action `0x71`; otherwise schedules a 100-unit delay. | +| `00404a18` | `SurrenderProcess_00404a18` | High confidence for setup: installs the surrender table and type `0x25f`, clears fields `+0x40/+0x41`, calls `item_action_process_dispatch` with selector `0x39`, threshold `0`, and replacement flag `0`, then sets bit 0 in the associated item record. The selector's specific action remains unresolved. | +| `00404b84` | `SurrenderProcess_Run` | High confidence for the visible gates, not the complete behavior. Checks global/item state and a spatial query; shape IDs `0x2f4`-`0x2f8`, `0x344`, and `0x597` select table-driven follow-up actions. Failure paths reschedule after 100 units. | +| `00404d30` | `PaceProcess_00404d30` | High confidence for construction: installs `g_paceProcessFnPtrs`, sets type `0x255`, and initializes field `+0x42` to zero after common NPC setup. | +| `00404dd8` | `PaceProcess_Run` | High confidence for the observed branches. Shares Stand's bounds/adjacency action-`0x71` path; remaining paths create/dispatch a type-specific helper and branch on process state and selected item shape IDs. | +| `00405030` | `GuardProcess_00405030` | High confidence for construction: installs `g_guardProcessFnPtrs`, sets type `0x25e`, and sets process flag bit 0 after common NPC setup. | +| `004050e0` | `GuardProcess_Run` | High confidence for the observed path. Checks termination/state, dispatches action `5` when the shared adjacency test succeeds, otherwise queries state and may schedule a 100-unit delay or call mode helpers. | +| `004051fc` | `LoiterProcess_004051fc` | High confidence for setup: installs `g_loiterProcessFnPtrs`, sets type `0x257`, initializes fields `+0x40/+0x42/+0x44/+0x46`, and applies flags in the `+0x30` word. | +| `004052f4` | `LoiterProcess_Run` | High confidence for timer behavior: decrements the timer at `+0x40` and invokes vtable slot `+0x08` at expiry; separate paths perform candidate-position and action queries. | + +The process-type values and immediate actions are supported by direct decompilation. The meanings of the shared action selectors, timer units, and several state fields remain open. + +## Verified Batch: Low-Level Helpers + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00405950` | `load_u16_indirect` | High confidence for the operation only: returns the 16-bit value addressed through incoming `EAX`. The owning field is unresolved. | +| `00405960` | `clear_u16_indirect` | High confidence for the operation only: writes zero to the 16-bit value addressed through incoming `EAX`. The owning field is unresolved. | +| `004059c0` | `noop_callback` | High confidence: empty body, with data references from three function-pointer tables, including `g_npcProcessFnPtrs` at `0047d7f0`. The exact callback slot role is unresolved. | +| `0040a7f0` | `packed_record_has_nonzero_fields` | High confidence for the tested bits only: returns nonzero if either of two packed fields at `+4` or the low nibble at `+7` is nonzero. The record schema is unresolved. | + +These generic names are intentionally mechanical. They improve decompiler readability without asserting the meaning of the word or the table slots. Decompiler comments record the observed operations and caller evidence. +## Address-Ordered Pass: Keyed Entry Cache + +The already documented helpers at `00405950`, `00405960`, and `004059c0` were reused; the next cache-related entries establish a ten-slot table with 256 four-byte pointers per key. Names describe the data structure and operations only; the key domain and entry schema remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00406540` | `keyed_entry_cache_initialize` | High confidence. Clears ten key tags, allocates the shared table, and initializes per-slot state; required allocation failure follows error path `0x2e`. | +| `004065ac` | `keyed_entry_cache_shutdown` | High confidence. Releases non-null entries across 10 x 256 cells, resets tags, then releases and clears the shared table pointer. | +| `00406714` | `keyed_entry_cache_load_key` | High confidence. Loads a missing 16-bit key into the next cyclic slot, clears the replaced slot, populates up to 256 entry pointers, and records the key tag; returns `-1` on failure. | +| `004069d8` | `keyed_entry_cache_read_entry_pair` | High confidence. Finds or loads the key slot and copies two 32-bit words from the indexed entry to caller storage. | +| `00406ab8` | `keyed_entry_cache_copy_entry_fields` | High confidence. Finds or loads the key slot and repacks fields at entry offsets `+4/+6` into a four-byte caller output, with a default-field path when no entry is present. | +| `00407000` | `keyed_entry_cache_has_entry` | High confidence. Finds or loads the key slot, then tests whether the indexed cache pointer is non-null. | + +The six names and decompiler comments were read back in the active Ghidra session. Cache contents and project changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: NPC State Dispatch and Candidate Search + +This span continues upward from the keyed-entry cache, reusing the previously examined entries at `004071a0`, `00407304`, `00407500`, `00407550`, and `004076b0` only after decompiling them again in address order. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004071a0` | `item_action_resolve_position_and_autofirer` | Resolves shape/item properties and an action code, handles the selector-1 AutoFirer state, then queries the position path and optionally applies an item-word-derived update. Selector semantics remain incomplete. | +| `00407304` | `item_shape_dispatch_interaction_rules` | Dispatches by associated-item shape code: codes `0x1e`/`0x1f` take an adjacency/action path, `0x385`/`0x4e6` clear item-record flags, and violent-mode codes `0x576`/`0x596` consult tables at `0047b074`/`0047b084`. Table entry meanings and resulting effects remain unresolved. | +| `00407500` | `keyed_entry_cache_key_is_available` | Resolves the incoming 16-bit key through `004262f8` and returns whether the lookup succeeded. Its sole observed caller, `keyed_entry_cache_load_key`, uses this as a gate before populating a cyclic cache slot; key semantics remain unresolved. | +| `00407550` | `process_0x0f0_construct_for_item` | Constructs process type `0xf0`, associates the supplied item ID, installs vtable `0047da00`, initializes process fields, derives additional fields from the associated item's shape record when present, and copies keyed-entry cache data. The process role remains unresolved. | +| `004076b0` | `item_process_probe_positions_and_update` | Updates process/item state, constructs type-selected temporary process objects, probes candidate coordinates, records process state at `+0x34`, then copies keyed-cache fields and updates the associated item. Candidate and field meanings remain unresolved. | +| `00408744` | `process_update_item_byte_10` | Writes `0`, `1`, or a value derived from process byte `+0x37` to byte `+0x10` of the associated item record (stride `0x79`), based on process flags and state/overlap checks. The field meaning remains unresolved. The rename and decompiler comment were read back through MCP. | + +The function list confirms the next defined entry is `00409ce0`; continue there without skipping intervening function entries. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Process Buffers and Attack Process + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00409ce0` | `set_object_byte_3e_and_increment_counter` | Sets byte `+0x3e` on the incoming object and increments `DAT_0048225e`. The field and counter meanings are unresolved; the rename and comment were read back through MCP. | +| `00409ecc` | `item_process_check_spatial_conflict_and_apply_action` | Calls the spatial helper with a stack result buffer and tests output bit `0x10`. On a clear result it either sets object bit `+0x40:0x10` and calls vtable `+0x0c`, or may call `item_action_process_dispatch(10000,0x3b,1)` and update relative coordinates. Exact query semantics remain unresolved. | +| `0040a004` | `process_apply_direction_code` | Applies direction codes to object byte `+0x36`, resolving codes `0x10`-`0x12` through `00450e54` and adjusting turns by one or two 4-bit steps based on flag `+0x4b:0x40`. The rename and comment were read back through MCP. | +| `0040a7f0` | `packed_record_has_nonzero_fields` | Existing verified helper: tests packed fields at `+4` and the low nibble at `+7`; the record schema remains unresolved. | +| `0040a890` | `draw_packed_shape_geometry_variant_a` | Draws a packed coordinate/extent record through shape and edge helpers; the record schema and rendered object's role are unresolved. | +| `0040a9b8` | `draw_packed_shape_geometry_variant_b` | Related packed-geometry draw variant using the same shape/bounds helpers and two explicit edge calls; record purpose remains unresolved. | +| `0040aa90` | `object_create_from_record_with_context` | Creates a vtable-backed object from a five-byte record, copies two context words and caller state, and stores `DAT_00482670`; concrete object class remains unresolved. | +| `0040aaec` | `object_cleanup_select_mode_by_flag` | Selects object/resource cleanup paths from flag bit 2; the clear-bit path resets/releases the resource and delegates object cleanup, while the set-bit path invokes shared release helpers. | +| `0040ab54` | `object_draw_bounds_at_offset` | Builds bounds from object fields `+0x25` through `+0x2b` and draws through the packed-geometry helper or a simpler path selected by byte `+0x4a`. | +| `0040ac7c` | `object_copy_resource_subrect_to_buffer` | If object resource `+0x46` is present, computes a source subrectangle and copies it through `00428c7c` using a 256-byte stack buffer; resource format remains unknown. | +| `0040adc0` | `memory_fill_register_context_wrapper` | Thin register-context wrapper around `00471f20`; the decompiler does not recover the implicit register contract. | +| `0040add8` | `buffer_resize_from_size_record` | Releases the existing pointer, validates the low-byte size at record `+4`, allocates that many bytes, stores the pointer, and traps on zero size or allocation failure. | +| `0040ae58` | `keyed_entry_cache_entry_buffer_size` | Computes buffer bytes from the descriptor's low-byte count at `+4`: count times `0x40` when mode bit `0x40` at `+7` is clear, otherwise count times `0x80`. Called by `keyed_entry_cache_load_key`; descriptor semantics remain unresolved. | +| `0040ae88` | `keyed_entry_cache_get_entry_address` | Computes an address within a keyed-entry cache buffer from its base, descriptor stride, and packed indices. Without mode bit `0x40`, halves one index and rejects values above 7; `keyed_entry_cache_read_entry_pair` uses the result to copy two dwords. | +| `0040aec8` | `keyed_entry_cache_release_entry_buffer` | Releases the buffer pointer held in a cache-entry record and clears the pointer field. Called while replacing cache entries and during `keyed_entry_cache_shutdown`. | +| `0040af20` | `AttackProcess_0040af20` | Constructs process type `0x259` from the common NPC initializer, initializes attack state, selects timing values from shape/skill conditions, and uses the shared 32-entry table. Many fields and timing units remain unresolved. | +| `0040b524` | `attack_process_initialize_entry_table` | Initializes 32 entries in `DAT_004820c0` using per-index availability checks and allocations, sets `DAT_00482140`, and returns `00426208`'s result. The entry domain remains unresolved; the rename and comment were read back through MCP. | +| `0040b7e4` | `AttackProcess_Run` | Consumes command words from the process buffer at `+0x47`, advances cursor `+0x4b`, and dispatches many cases to action, direction, item, and spatial helpers. This establishes an interpreter-like command stream; individual command meanings remain only partly mapped. | +| `0040ce20` | `process_set_byte_7e_and_randomize_field_75` | Sets byte `+0x7e`, derives a value in roughly the 8-18 range, stores it scaled by 100 at `+0x75`, then adds a helper-produced adjustment. Field units and purpose remain unresolved. | +| `0040ce6c` | `attack_process_fallback_update` | AttackProcess fallback/update path used when process byte `+0x4f` is zero. Checks associated-item and spatial state, computes target direction/distance, updates timing/movement fields, and dispatches action helpers; field and selector meanings remain unresolved. | + +The function list confirms the next defined entry is the previously examined `process_set_byte_7d_one` at `0040dfa0`. Continue there, then inspect every subsequent entry in ascending address order. This pass made no executable-byte changes and did not save the Ghidra project. + +## Address-Ordered Pass: Viewport, Text, and Configuration + +This continuation examined each defined function from `0040dfa0` through `004138e8` in ascending order. Ghidra renames and comments are pending in the live session; no executable bytes were changed and the project was not saved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0040dfa0` | `process_set_byte_7d_one` | Writes `1` to object byte `+0x7d`; its observed caller is `process_choose_direction_to_coords`. Field meaning remains unresolved. | +| `0040e0e8` | `rectangles_overlap_inclusive` | Tests signed-short rectangles and treats touching edges as overlap. | +| `0040e1f8` | `screen_region_queue_clipped_rect` | Clamps a four-short rectangle to 640x480, allocates a five-dword vtable-backed record, copies the clipped bounds, and appends it to the region list. The record's role remains unresolved. | +| `0040e33c` | `screen_region_rect_list_remove_overlaps` | Splits overlapping rectangles into fragments and removes empty/inverted regions; the remaining list is consumed by the rectangle drawing path. | +| `0040e728` | `camera_process_construct_common` | Initializes the common camera-process object and singleton state. `CameraProcess_00410424` installs its own vtable, stores the global process pointer, and sets type `0x219`. | +| `0040e764` | `dirty_rect_process_initialize_or_release` | Branches on an incoming flag to release the object or install its dedicated vtable and initialize state. The concrete class and flag contract remain unresolved. | +| `0040e7b8` | `screen_region_process_dirty_rects` | When dirty-region work is pending, removes overlapping rectangles, draws each remaining region, then clears and destroys the list. No direct callers were found; boundary ownership should remain under review. | +| `0040e7c4` | `screen_region_draw_dirty_rect_list` | Walks the active dirty-rectangle list, removes overlaps, draws each remaining rectangle, and finalizes list iteration. | +| `0040e87c` | `screen_region_add_intersecting_rect` | Intersects the incoming rectangle with active bounds, queues a nonempty clipped rectangle, and increments the pending count. | +| `0040e9d0` | `screen_region_next_pending_rect` | Returns or advances pending screen-region rectangle state. One path returns active bounds; the other decrements the pending count, copies current record bounds, destroys that list node, and writes a zero-sized sentinel when exhausted. | +| `0040eab4` | `screen_region_finish_rect_batch` | Finalizes screen-region rectangle-list iteration through `00422bc8` and stores the returned state word. | +| `0040ed60` | `buffer_replace_with_size_and_attribute` | Replaces the existing allocation, stores the requested size and one-byte attribute beside the pointer, and raises error `0x21` on allocation failure; record ownership remains unresolved. | +| `0040edb4` | `buffer_release_and_clear_pointer` | Releases the pointer stored at the incoming object and clears that field when non-null. | +| `0040edd0`, `0040eef0` | `directdraw_palette_export_rgb6`, `directdraw_palette_import_rgb6` | Convert between DirectDraw palette channels and RGB6 values: export shifts channels right by two; import shifts left by two before uploading entries. | +| `0040f00c` | `object_dispatch_pending_state_transition` | Evaluates shared UI/object conditions and flags, dispatches virtual method `+0x48` on one transition, and updates `DAT_00482162`; callback and event semantics remain unresolved. | +| `0040f0e8` | `object_apply_condition_state_transition` | Evaluates a shared object condition and dispatches virtual method `+0x48` or `+0x4c`, setting or clearing bit `0x20000` in `DAT_00482162`; object state meaning remains unresolved. | +| `0040f144` | `type2_object_construct_variant_a` | Constructs a type-2 object from an option record derived from the incoming byte, installs vtable variant A, sets an object flag, and clears shared state; class role remains unresolved. | +| `0040f1d4` | `type2_object_construct_variant_b` | Constructs a type-2 object from the same option-record layout as variant A but installs vtable variant B; class role and behavioral distinction remain unresolved. | +| `0040f3e4` | `resource_cache_initialize` | Initializes a circular resource-node list and resets its sentinel, slot, node-count, and byte-count state. | +| `0040f458` | `resource_cache_release_transient_nodes` | Walks the node list and destroys entries whose type is below 8; a state byte prevents repeating the sweep. Exact type ownership remains unresolved. | +| `0040f590` | `resource_cache_set_slot` | Stores an incoming pointer in the indexed cache slot and increments the slot count; traps when more than eight entries are registered. | +| `0040f5c8` | `resource_cache_clear_slot` | Clears the cache slot indexed by incoming AX; the caller's index contract remains unresolved. | +| `0040f630` | `resource_cache_node_create` | Allocates and links a cache node containing size, type/key, and associated data; updates list/count/byte totals and records it in the lookup map unless the key is sentinel `0xfffd`. | +| `0040f6d0` | `resource_cache_node_destroy` | Invokes the associated object's release method when present, clears its lookup-map slot, unlinks the node, updates counts, and frees the allocation. | +| `0040f780` | `resource_cache_remove_by_id` | Searches the node list using helper-provided key/state and destroys a matching entry; the helper's register contract and key meaning remain unresolved. | +| `0040f7f4` | `linked_record_move_to_head` | Unlinks a record from a circular doubly linked list and reinserts it after the sentinel. Values `-1` and `-2` take an error path. | +| `0040f920` | `empty_body_register_context_helper` | Ghidra reports an empty one-byte body. Callers consume register state across this entry, so its intended helper contract remains unresolved. | +| `0040fae8` | `text_get_character_width` | Reads cached metrics or calls `GetCharWidthA` for the requested character. | +| `0040fb54` | `resource_state_object_create_for_type` | Allocates a vtable-backed state object, initializes fields from type-indexed tables, validates a type value, and selects a corresponding global data pointer; object class remains unresolved. | +| `0040fc74` | `text_object_initialize_or_release` | Branches on an incoming flag to release the text object or install its vtable and initialize text-related state. The precise flag semantics remain unresolved. | +| `0040fd60` | `text_gdi_contexts_initialize` | Creates shared backing state and initializes four text memory-DC/font contexts with distinct style values. | +| `0040fe10` | `text_gdi_contexts_shutdown` | Deletes four cached GDI contexts and their selected fonts, bitmaps, and palettes, then destroys shared metrics. | +| `004100b4` | `text_create_memory_dc_with_font` | Builds a compatible memory DC with an 8-bit bitmap and grayscale palette, then adjusts font height using `GetTextMetricsA`. | +| `004103e4` | `camera_process_create` | Allocates a camera process, constructs it through `CameraProcess_00410424`, and stores the singleton pointer in `DAT_00482204`. | +| `00410400` | `camera_process_dispatch_callbacks` | If the camera singleton exists, dispatches virtual callbacks at vtable offsets `+0x2c` and `+0x30`; callback timing and semantics remain unresolved. | +| `00410424` | `CameraProcess_00410424` | Camera-process constructor variant that installs the camera vtable and sets process type `0x219`. | +| `00410454` | `viewport_invalidate_and_refresh_visible_items` | Clears two viewport state bytes and delegates refresh work to `00421fbc`; exact refresh scheduling remains unresolved. | +| `004107f8` | `project_xy_to_isometric_screen` | Projects X/Y coordinates using the current view origin and writes the two screen-space components to caller outputs. | +| `0041081c` | `project_xy_to_screen_with_item_height` | Projects coordinates, picks the viewport leaf node at that point, and adjusts outputs using the item's shape height and Z; may also return item ID and a relative-position flag. | +| `00410a0c` | `build_visible_item_render_nodes` | Traverses configured map cells and item chains, filters item/shape flags, computes isometric bounds, culls outside the view, and creates render-list nodes. Node ordering and draw-stage semantics remain open. | +| `00411078` | `update_map_viewport_tile_cache` | Maintains a 5x6 cache of 128-pixel map tiles as the viewport moves, updates tile bounds, removes or retains cached item nodes by overlap, then rebuilds the visible-node set. | +| `00411cb8` | `draw_current_map_region_outline` | Projects `DAT_004821fc` and draws four line segments through `004685d4`; the overlay's higher-level purpose remains unresolved. | +| `00411dc4` | `draw_map_region_grid_and_update_process_20f` | When renderer state is enabled, draws a 3-by-3 grid of map-region outlines; when `DAT_00482614` is set, also updates processes of type `0x20f`. Their roles remain unresolved. | +| `00412398` | `render_state_set_word_004821f2` | Stores incoming AX at the word field beginning at `DAT_004821f0+2`; field meaning is unresolved. | +| `004123d0` | `render_state_get_word_004821ec` | Returns the 16-bit value at `DAT_004821ec`; field meaning is unresolved. | +| `004123d8` | `render_state_get_word_004821ee` | Returns the 16-bit value at `DAT_004821ee`; field meaning is unresolved. | +| `004123e0` | `render_state_get_byte_004821f0` | Returns the byte at `DAT_004821f0`; field meaning is unresolved. | +| `004123e8` | `render_state_get_word_0047b168` | Returns the 16-bit value at `DAT_0047b168`; field meaning is unresolved. | +| `004123f0` | `draw_isometric_outline_from_projected_coords` | Projects a coordinate pair and draws four line segments through `004685d4` using the caller's dimensions and color; outline role remains unresolved. | +| `00412980` | `item_shape_encode_compact_flag_bits` | Maps input byte bit 1 to output bit 0 and bit 6 to bit 5, always setting output bit 15; exact field semantics remain unresolved. | +| `004129a0` | `spatial_query_rect_item_shape_flags` | Scans rectangle candidates, filters item position/Z and shape extents, ORs compact shape-derived flags, and optionally returns the first matching item ID. Flag meanings remain unresolved. | +| `00412c10` | `item_shape_derive_table_value_for_id` | Combines shape-record lookup values for the incoming ID and selector; selectors 2 and 9 take extra table/helper adjustments before a bounded update. Result domain and selector meanings remain unresolved. | +| `00412ce0` | `text_entry_prompt_run_and_wait` | Initializes the text-entry UI, obtains a string, creates a text-entry process if one is returned, runs the dispatcher until completion, then tears down the UI. | +| `00412d10` | `text_entry_process_create_for_string` | Creates a type-0 process, copies the DBCS-aware string into owned storage, initializes editing state, computes/centers bounds, and registers the process. | +| `00413188` | `text_entry_process_draw_and_advance` | Advances a DBCS-aware buffer, measures/draws characters, wraps lines at width limits and control markers, and invalidates affected regions. | +| `00413760` | `config_write_registry_string` | Writes a string value under the JP build's per-user `HKCU\\Software\\Electronic Arts\\Crusader: No Remorse\\J1.21` registry key. | +| `004138e8` | `config_load_registry_and_cfg` | Reads install/CD/Flic paths from HKLM and video, subtitles, blast limit, animation, frame-skip, music/sound volume, and mouse speed from HKCU; the routine also falls back to `crusader.cfg` parsing. | + +This continuation examined defined entries from `0040dfa0` through `004138e8` in ascending order. Ghidra symbol and comment changes remain pending in the live session; no executable bytes were changed and the project was not saved. + +The strict coverage report exposed these previously omitted lower-address entries, which now have evidence-backed operation-level names. Continue from the report's next untracked function rather than assuming the previously recorded `00414698` cursor. + +## Address-Ordered Pass: Registry, Containers, and Controller State + +This continuation reviewed defined entries from `00414698` through `00415d68` in ascending order. Existing evidence for `key_handle_option_cheats_jp` at `00415eec` is reused to keep the address sequence explicit. Names and comments for directly supported functions were applied and read back in Ghidra. Boundary review confirmed `00415670` is a callable low-16-bit entry into `runtime_mode_set`, not a stray boundary. No executable bytes were changed and the project was not saved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00414698` | `config_save_registry_options` | High confidence. Writes the current video mode, subtitles, blast limit, animation, frame skip, music volume, sound volume, and mouse speed through `config_write_registry_string`. Its only observed call is at `00443852`, currently outside a defined Ghidra function. | +| `00415400` | `item_remove_linked_contents` | Called by item removal at `00437394` when linked contents exist. Walks contents for shape classes 6/7; a flagged path uses item coordinates and triggers item-removal/usecode-event work. Whether contents are dropped, transferred, or removed in each case remains unresolved. | +| `00415498` | `item_container_destroy_contents` | High confidence. Walks linked child IDs for shape classes 6 and 7 and removes each through `004320d8` -> `00437394`; nested containers recurse through the same item-removal path. Called by `00432244` and map-unload cleanup at `00435bc0`. | +| `004154c8` | `item_recursive_sum_shape_byte_7` | High confidence for the operation only. Recursively traverses linked child IDs and sums each item's byte at shape-record offset `+7` via `004315d4`, stopping at `DAT_00482224`. The byte's meaning and units remain unresolved. | +| `00415670` | `runtime_mode_set_low16_entry` | High confidence. Two direct calls target this entry (`0041aab0`, `0042d039`). It clears `EAX` above bit 15 with `AND EAX,0xffff`, then falls through the no-op `LEA EAX,[EAX]` into `runtime_mode_set` at `00415678`; retain it as a distinct callable entry. | +| `00415678` | `runtime_mode_set` | High confidence for the state update. Stores the incoming mode in `DAT_0047b1d6` and `DAT_0047b1da`, performs mode-change cleanup/initialization, and refreshes the map viewport tile cache. Called from startup map selection and the JP cheat-key path; individual mode meanings remain unresolved. | +| `004156e0` | `runtime_mode_get` | High confidence. Returns `DAT_0047b1d6`, paired with `runtime_mode_set`; callers include gameplay, target-selection, and controller paths. | +| `004156e8` | `shape_record_code_0d_is_whitelisted` | Reads shape-record code `+0x0d` through `shape_record_get_code_0d` and accepts `0`, `1`, `0x3a`, `0x37`, `0x0b`, `0x10`, `0x20`, or `0x3b`. The code domain remains unresolved. | +| `00415730` | `shape_record_code_0d_passes_input_filter` | Reads shape-record code `+0x0d`; accepts several values directly and otherwise rejects codes `0x22`, `0x23`, or `0x26` through `shape_record_code_0d_is_excluded`. Its caller-level contract remains unresolved. | +| `00415788` | `controller_process_create` | High confidence. Allocates and stores the singleton controller process, installs `g_controllerProcessFnPtrs`, sets process type `0x247`, calls four initialization helpers, and applies flags `0x115`. Its only observed caller is startup code at `004664b6`. | +| `004158c8` | `tracked_item_marker_start_if_eligible` | Under global-state and selected-shape gates, initializes tracked-item marker state and may position it through `tracked_item_marker_reposition`; the initiating action and state ownership remain unresolved. | +| `004159b8` | `tracked_item_marker_periodic_refresh` | Applies a 100-unit clock threshold and event/state filters before delegating an accepted refresh to `tracked_item_marker_update_for_item`. | +| `00415a5c` | `tracked_item_marker_refresh_after_removal` | Conditionally refreshes the tracked-item marker after removal, gated by controller state and follow-up event/query checks. | +| `00415adc` | `tracked_item_marker_update_for_item` | Checks the target through `0041b798`, derives target-relative coordinates, and calls `0046159c` with selector `10`; selector and global meanings remain unresolved. | +| `00415ce4` | `tracked_item_marker_stop` | Clears the active marker path, resets associated globals, and invokes callback/resource cleanup when enabled. | +| `00415d68` | `tracked_item_marker_reposition` | Uses `DAT_0047b1da` as an item ID, reads item/shape properties, computes target-relative values, adjusts a cyclic value in `DAT_0047b1dc`, and updates coordinates through `00460668` or `0046093c`. The exact view/follow behavior remains unresolved. | +| `00415eec` | `key_handle_option_cheats_jp` | Previously verified in the Debug and Test Switches batch; included here to preserve the address-ordered sequence. | + +`runtime_mode_set` has a discontiguous Ghidra body: `00415678`-`004156dd` and `004185a2`-`004186ff`, totaling 452 bytes. The MCP function summary presents the minimum-to-maximum address span, which is not a contiguous body. A later exact-ledger report exposed lower-address executable functions omitted from the primary tables; continue from the report's lowest untracked entry rather than assuming `004168cc` is the global cursor. + +## Address-Ordered Pass: Keyboard Control and Static Overlay + +This batch reviewed the next 20 untracked executable function entries in ascending address order, from `004168cc` through `0041a274`. Direct operations now have descriptive names; ambiguous event selectors and higher-level process roles remain explicitly unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004168cc` | `input_keyboard_event_dispatch_gate` | Filters keyboard event codes and applies a mode-dependent timer/rate gate using `DAT_00482258` before event dispatch. Individual code meanings and timing contract remain unresolved. | +| `00416a0c` | `input_keyboard_adjust_facing` | High confidence for the observed operation. Recognizes two turn-key byte values, adjusts `DAT_0047b1dc`, derives a 16-way direction from coordinates, and updates the caller's direction field. The key mapping and field owner remain unresolved. | +| `00416c7c` | `input_keyboard_handle_gameplay_event` | High confidence for its broad role. Queries tracked key states, dispatches several event-code families, calls `input_keyboard_adjust_facing` for turn input, and ultimately reaches `process_apply_direction_code`. Individual event and modifier meanings remain unresolved. | +| `004180b0` | `input_keyboard_process_interaction_state` | Processes keyboard interaction state, updates input globals, validates item/shape conditions, and emits action events; after a 400-unit interval it delegates candidate scanning to `0041871c`. Exact action semantics remain unresolved. | +| `0041871c` | `input_keyboard_scan_item_candidates` | Scans candidate IDs 2 through 255, excludes the current mode/item value, tests item bounds and state, then conditionally dispatches action selectors or updates selection. Selector and interaction meanings remain unresolved. | +| `004188a4` | `auto_firer_process_stop` | High confidence for the lifecycle operation. Clears AutoFirer/controller state flags and invokes virtual method `+0x08` on the active process object when present; the callback contract remains unresolved. | +| `00418910` | `auto_firer_process_create` | High confidence. Installs the AutoFirer function table, sets process type `0x260`, associates `DAT_0047b1d6`, stores the singleton pointer, and initializes its process state. | +| `00418a08` | `auto_firer_process_reset` | High confidence for the reset behavior. Clears AutoFirer globals and flags, cancels guarded timed/process state, invokes virtual cleanup callbacks, and restores default state fields. Individual globals remain unresolved. | +| `004191f8` | `item_shape_record_apply_cached_entry` | Reads a cache pair for the incoming selector, applies its flag bits through `004319f0`/`0043348c`, writes the selector at shape-record offset `+0x0d`, and clears offset `+0x10`. The cache key domain remains unresolved. | +| `00419420` | `noop_callback_00419420` | High confidence that the body is empty. Its callback-table slot and intended role are not established. | +| `00419480` | `load_u16_indirect_00419480` | High confidence for the operation: returns the 16-bit value addressed through incoming `EAX`. The owning field and caller contract remain unresolved. | +| `004194c0` | `isometric_project_world_xy_to_screen` | Computes screen X as `(X-Y)/2 - DAT_004821da` and screen Y as `(X+Y)/4 - DAT_004821dc`; the caller-specific coordinate units remain unresolved. | +| `0041966c` | `static_overlay_initialize` | High confidence for the initialization path. Resolves the resource named `"static"`, initializes related resource/display state, and stores handles used by the overlay loop. The resource format remains unresolved. | +| `00419874` | `static_overlay_shutdown` | High confidence as the paired teardown. Releases handles initialized by `static_overlay_initialize`, restores display/input state, and clears associated globals. | +| `0041999c` | `static_overlay_run_loop` | High confidence for the lifecycle role. Initializes the overlay, repeatedly services event/update and script state until completion or exit, then calls its teardown. | +| `00419a40` | `static_overlay_process_script` | High confidence for the observed behavior. Advances control bytes and text from the loaded resource, renders text, and starts palette transitions for recognized markers. The full script command vocabulary remains unresolved. | +| `0041a020` | `static_overlay_palette_fade_in_step` | High confidence for the palette operation and direction. Applies a 128-entry palette with the current fade level subtracted from each channel, clamps at zero, then decreases the level toward zero. | +| `0041a114` | `static_overlay_palette_fade_out_step` | High confidence for the palette operation and direction. Applies the same 128-entry channel adjustment while increasing the fade level toward its upper bound. | +| `0041a260` | `active_countdown_reset_to_500` | Resets `DAT_0047b1e8` to 500 only when nonzero. A separate state routine decrements the value; its higher-level timer purpose remains unresolved. | +| `0041a274` | `process_0x261_construct` | Constructs process type `0x261`, installs vtable `0047e18c`, initializes common process state, and sets flags. The process class role remains unresolved. | + +Ghidra names and decompiler comments for the directly supported operations were read back in the live session. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Spatial Queries and Process Dispatch + +This batch continued with the next 20 untracked entries from the exact coverage report. The first five entries (`0040fc74`-`00410454`) are recorded in the preceding viewport/text table to keep that table address-ordered; the remaining fifteen are listed here. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0041a2f8` | `item_decode_packed_position_offsets` | Decodes packed item/shape state into two coordinate outputs and a compact offset/orientation byte. Callers include position-query paths `0041b208` and `0041b798`; packed-field meanings remain unresolved. | +| `0041a410` | `empty_callback_body` | Empty function body; callback or boundary role is unresolved. | +| `0041a414` | `position_state_dispatch_from_stack_selector` | Loads a 16-bit selector from the caller's stack frame and forwards it to `position_state_dispatch_by_selector` with a zero secondary value. | +| `0041a434` | `position_state_dispatch_by_selector` | Large selector-driven dispatcher combining item/shape lookups, process queries, spatial checks, action dispatch, and process construction. Selector values and branch meanings remain unresolved. | +| `0041b1dc` | `timer_check_active_window` | Reads the current clock and checks it against the configured interval at `DAT_00482240` with length `DAT_00482244`; returns packed clock/state data with a distinct outside-window result. | +| `0041b208` | `position_query_build_candidate_and_dispatch` | Uses packed-position decoding to derive candidate coordinates, then dispatches selected cases through `position_state_dispatch_by_selector`; candidate record and return contract remain unresolved. | +| `0041b798` | `target_position_query_from_packed_records` | Scans nonempty packed cache records, derives candidate offsets, tests positions through occupancy and shape-query helpers, and returns a match result. Packed fields and success semantics remain unresolved. | +| `0041bb7c` | `target_position_query_within_axis_threshold` | Forms target-relative coordinates, issues a mode-4 spatial query, then rounds a 3D maximum-axis delta upward in 16-unit steps and accepts values below `0x31`; units and threshold meaning remain unresolved. | +| `0041bcd8` | `process_0x254_construct_variant_a` | Constructs process type `0x254`, installs vtable `PTR_LAB_0047e168`, associates `DAT_004955cc`, and initializes a type-specific field. | +| `0041be20` | `process_0x254_construct_variant_b` | Constructs a second type-`0x254` variant with vtable `PTR_LAB_0047e144`; it shares item/global setup with variant A but uses a different initializer and field value. | +| `0041bf6c` | `process_0x254_create_variant_a` | Allocates a process object and invokes `process_0x254_construct_variant_b` on success. | +| `0041bf6c` | `process_0x254_create_variant_b` | Allocates a process object and invokes `process_0x254_construct_variant_b` on success. | +| `0041bf84` | `process_0x254_create_variant_a` | Allocates a process object and invokes `process_0x254_construct_variant_a` on success. | +| `0041bf9c` | `item_state_map_context_and_selector` | Maps context/selectors through tables near `DAT_0047b20c`/`DAT_0047b260`, with item-catalog and state checks for selectors 8 and `0x2a`; returned values and selector meanings remain unresolved. | +| `0041c2d4` | `CycleProcess_0041c2d4` | Constructs CycleProcess type `0x248`, installs its function table, initializes common process state, stores the singleton in `DAT_004822c4`, and clears two process fields. | +| `0041cbcc` | `shared_storage_and_singleton_initialize` | Allocates shared storage, initializes dispatcher record/playback state, allocates an object, and constructs a singleton; subsystem purpose remains unresolved. | +| `0041cbf8` | `shared_storage_and_singleton_shutdown` | Shuts down dispatcher record/playback state and releases the shared allocation at `DAT_00482308`; startup is the only observed caller. | +| `0041cc24` | `shared_state_object_construct` | Constructs a vtable-backed shared object, runs three initialization helpers, stores it at `DAT_0048230c`, and sets flag bit `0x10`; object class remains unresolved. | +| `0041ccc8` | `dispatcher_two_phase_record_dispatch` | Copies six-dword records through 25-slot rings in phase 1, then processes phase-2 records, optional recording, and virtual callbacks; event schema and phase meanings remain unresolved. | + +Renames and decompiler comments for the directly supported operations were applied and read back through Ghidra MCP. Operation-level names are in place where supported; ambiguous contracts remain unresolved. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Dispatcher and Item Notifications + +This batch reviewed the next 20 report-listed executable entries, from `0041cdf4` through `0041ea3c`. The dispatcher cluster manages bounded event queues and optional record/playback state; the later entries maintain and render timed item-notification overlays. Several record fields and display-state meanings remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0041cdf4` | `dispatcher_record_playback_initialize` | One-time setup for two 25-slot rings of `0x18`-byte records and a five-entry context table; an optional capture/playback allocation path reports `No room for Dispatcher Record/Playback.` | +| `0041d028` | `dispatcher_record_playback_shutdown` | Closes registered contexts, releases the ring/context storage and optional capture/playback data, then clears the initialized flag. | +| `0041d148` | `dispatcher_process_phase3_records` | Processes the `PHASE3` stream, converts sampled event state through `dispatcher_encode_event_record_type`, and queues internal records. Event-field meanings remain unresolved. | +| `0041d4b0` | `dispatcher_encode_event_record_type` | Maps external event-record values into compact internal type codes, including `1`, `2`, `4`, and `0x100`, while preserving payload fields. | +| `0041d8b4` | `dispatcher_unknown_event_type_error` | Thin wrapper calling the shared dispatcher error helper with code `0x33d`; the precise triggering condition remains unestablished. | +| `0041d8c4` | `dispatcher_notify_active_contexts` | Copies a four-word event record and forwards it through `0044c798` for each active dispatcher context. The listener contract remains unresolved. | +| `0041d954` | `dispatcher_register_context` | Adds a context pointer to the bounded dispatcher table while fewer than five slots are occupied; overflow takes the error path. | +| `0041d9f4` | `dispatcher_append_recorded_event` | Appends eligible `0x14`-byte event snapshots to the capture/playback buffer, stores the current dispatcher sequence value, and advances the record count. | +| `0041dac4` | `dispatcher_event_context_create` | Creates a context object with a dedicated vtable, associates it with current dispatcher state, registers it in the bounded table, and notifies the context subsystem. | +| `0041dcb0` | `dispatcher_run_event_loop` | Invokes the active process callback, drains records through `0041ccc8`, waits on the dispatcher completion condition, and releases temporary context state. | +| `0041ddc0` | `dispatcher_clear_queued_context` | Scans pending `0x18`-byte records and clears the context field for entries matching the supplied value. | +| `0041e0ac` | `item_notification_process_initialize` | Initializes the item-notification process object with its dedicated vtable and time-derived field, then calls a shared process helper. The exact meaning of the time field remains unresolved. | +| `0041e0fc` | `item_notification_layout_and_draw` | Checks overlap among eight notification slots, lays out active rows and labels, and requests screen-region refresh for affected bounds. | +| `0041e170` | `memory_zero_fill` | Calls `00471f20` to zero-fill the caller-requested byte span; the call path does not establish a fixed length. | +| `0041e188` | `item_notification_draw_active` | Draws active entries from the eight-slot notification table, including repeated-item counts and optional secondary text, then marks rendered bounds for refresh. | +| `0041e3cc` | `item_notification_clear_dirty_regions` | Passes the saved bounds of active changed notifications to `00468c7c`, then clears each per-slot changed byte. The drawing helper's exact contract remains open. | +| `0041e448` | `item_notification_tick_expiry` | Decrements each active notification's lifetime; on expiry, refreshes its screen region and releases its item/display data. | +| `0041e4d4` | `item_notification_add_or_update` | Updates a matching notification's count/state or allocates a free slot, records display metadata and bounds, starts its timer, and requests redraw. | +| `0041e738` | `item_notification_resolve_label` | Resolves notification type and caption; explicit labels include `KEYCARD` and `CREDITS`, with helper-derived text for other supported item classes. | +| `0041ea3c` | `rect_intersect_bounds` | Intersects two four-short rectangles by raising the first two bounds to their maxima and lowering the final two bounds to their minima. | + +Supported names and decompiler comments were applied and read back through Ghidra MCP. The error code, generic resource semantics, and process-like class remain unresolved despite their operation-level names. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Viewport Spatial Grid and Process Queues + +This batch reviewed the next 13 report-listed executable entries, from `0041ea78` through `0041f6ec`, bringing the exact-address ledger to its 20% target. The functions cover rectangle bounds, a fixed viewport-node pool, queued process state, and render-order relationships across the viewport grid. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0041ea78` | `rect_union_bounds` | Expands the incoming four-short rectangle to include a second rectangle, using minima for the first two bounds and maxima for the final two. | +| `0041eab4` | `viewport_spatial_node_allocate` | Pops a `0x36`-byte node from the shared free list and decrements the available count; returns null when exhausted. | +| `0041ead8` | `viewport_spatial_node_release` | Pushes a node back onto the shared viewport spatial-node free list and increments the available count. | +| `0041eaf8` | `viewport_spatial_node_pool_init` | Allocates and chains `0x5dc` fixed-size `0x36`-byte nodes into the shared free list. | +| `0041ec30` | `viewport_process_queue_update` | Reconciles ready and waiting process queues using viewport bounds and dependency flags; invokes a process callback on the queue-drain path. | +| `0041efa0` | `viewport_render_node_add_order_link` | Allocates a relation record from a secondary pool and links the supplied render-node pair into each other's relation lists. | +| `0041eff8` | `viewport_process_enqueue` | Marks the incoming process runnable and inserts it into the active process queue. | +| `0041f044` | `viewport_process_unlink` | Removes process relations and child links, then detaches a queued process from the active list and clears its runnable flag. | +| `0041f160` | `visible_item_render_node_update_links` | Called by `build_visible_item_render_nodes`; visits the five-column by six-row viewport cells overlapped by the incoming node and builds links for intersecting render bounds. | +| `0041f37c` | `visible_item_render_node_order_link` | Chooses an ordering-link direction using the nodes' depth field and a fallback comparator, then allocates the relation. | +| `0041f3ec` | `map_viewport_tile_cache_update_links` | Called by `update_map_viewport_tile_cache`; revisits covered grid cells and refreshes relationships for overlapping nodes. | +| `0041f67c` | `map_viewport_tile_cache_node_order_link` | Applies the depth/fallback ordering comparison and allocates a relation for map-viewport cache nodes. | +| `0041f6ec` | `viewport_spatial_grid_initialize` | Initializes a five-column by six-row grid of `0x80`-square cells, allocating one node per cell and inserting them into the process queue. | + +Renames and decompiler/disassembly comments were applied and read back through Ghidra MCP. The fallback ordering comparator's exact semantics remain unresolved. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Viewport Spatial Nodes and Animation + +This pass reviewed the next 20 entries reported as untracked, from `0041f954` through `00421c08`. Together they manage viewport spatial-node lifetime and selection, render-order relation records, visible-item collection, animation-frame advancement, and redraw invalidation. The exact phase/timing domain and several shape-bound fields remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0041f954` | `viewport_spatial_grid_release_buffers` | Frees the viewport spatial-node pool, render-order relation pool, and two item-ID bitmaps. Its observed caller is the startup/shutdown cleanup sequence at `00466591`. | +| `0041f9c4` | `viewport_spatial_node_unlink_and_release` | Unlinks one spatial node from the viewport process queue, then returns it to the spatial-node pool. | +| `0041f9d8` | `viewport_render_order_relation_unlink_and_release` | Removes one render-order relation from both endpoint lists and returns the relation record to its pool. | +| `0041f9ec` | `viewport_spatial_pick_leaf_node_at_point` | Maps a point to a grid cell, marks nodes whose virtual hit test accepts it, then returns a marked node with no marked child and clears the temporary mark. The virtual hit-test contract remains unresolved. | +| `0041fb5c` | `viewport_spatial_queue_nodes_intersecting_rect` | Visits cells intersecting an input rectangle, queues overlapping nodes once, and records their item IDs in the pending bitmap. | +| `0041fd34` | `viewport_spatial_filter_pending_items_to_viewport` | Filters pending IDs by item activity and shape bounds against the viewport, sets accepted IDs in the visible bitmap, and clears the pending bitmap. | +| `00420028` | `viewport_collect_visible_items_for_phase` | Compacts visible-bitmap IDs into a caller buffer, rejecting inactive/offscreen items and applying a per-shape comparison with the incoming phase value. The phase domain remains unresolved. | +| `00420368` | `viewport_advance_visible_item_animations` | Builds the visible-item list and updates selected shape/frame state across shape-class branches. The animation selector and timing units remain unresolved. | +| `004206a8` | `viewport_spatial_grid_clear` | Walks the 5-by-6 grid, invokes each node's cleanup callback, unlinks/releases nodes, then frees the grid storage. | +| `0042073c` | `intrusive_list_insert_between` | Inserts a list node between the supplied neighbors by updating its `+4/+8` links and the adjacent nodes. | +| `004207e0` | `viewport_relation_pool_release` | Returns one `0x18`-byte render-order relation record to the pool free list and increments the available count. | +| `00420800` | `viewport_relation_pool_initialize` | Allocates and chains 4,000 render-order relation records of `0x18` bytes each, then initializes the free-list head and count. | +| `0042088c` | `viewport_render_order_relation_attach` | Attaches one relation record to both endpoint nodes' relation lists; called by visible-item render-order linking. | +| `004208bc` | `viewport_render_order_relation_unlink` | Unlinks a relation record from both endpoint lists. The record's additional relation links are not fully understood. | +| `004209d0` | `viewport_render_nodes_compare_overlap_order` | Tests item/shape bounds for overlap and returns ordering code 1 or 2 when one render node precedes the other; returns 0 when no ordering is established. | +| `004214a4` | `viewport_render_node_update_bounds` | Recomputes and stores a render node's screen-space bounds from its item and shape dimensions, including an additional shape-specific adjustment when available. | +| `004218c8` | `viewport_item_clear_spatial_tracking` | Clears an item's bits in the visible and pending bitmaps and calls `004334bc(item, 0xfffe)`; the helper's separate state effect remains unresolved. | +| `00421954` | `viewport_spatial_find_item_node_in_region` | Searches a bounded grid-cell range for a type-2 node associated with an item ID and returns the matching node, if present. | +| `004219f0` | `viewport_spatial_find_item_render_node` | Computes an item's shape footprint in grid coordinates and searches those cells for its type-2 node, falling back to the full 5-by-6 grid. | +| `00421c08` | `viewport_item_invalidate_render_bounds` | Finds the item's render node, updates its bounds, removes its old spatial registration, and marks or redraws the affected viewport rectangle. Dirty-region globals remain unresolved. | + +All 20 names and decompiler comments were read back through Ghidra MCP. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Tracked Item, List, and Audio Helpers + +This pass reviewed the next 20 entries reported as untracked, from `00421f9c` through `00423358`. It resolved the tracked-item viewport refresh path, a doubly linked-list utility family, and guarded audio cleanup/update paths. The three class lifecycle helpers now have operation-level names; their derived-object role remains unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00421f9c` | `viewport_set_tracked_item_id` | Replaces `DAT_004825b0`, refreshing the previous item's viewport spatial/render state first when nonzero. | +| `00421fbc` | `viewport_refresh_tracked_item_spatial_state` | Builds or updates spatial/render state for the tracked item; called by visible-item node building and viewport invalidation paths. | +| `004225d4` | `viewport_publish_pending_dirty_rect` | Publishes accumulated bounds to the renderer, marks viewport update state, and runs `viewport_process_queue_update`. | +| `00422690` | `dispatcher_flush_pending_rect_notification` | Sends the pending four-short rectangle through `dispatcher_notify_active_contexts` and clears the pending flag. | +| `00422990` | `resource_object_release_callback` | Object callback changes its vtable and conditionally releases associated resources/object storage based on flag bits. Flag meanings and class ownership remain unresolved. | +| `004229c0` | `intrusive_list_insert_head` | Inserts a node at the head of a container using next/previous links at node offsets 0/+4. | +| `004229e0` | `intrusive_list_insert_tail` | Inserts a node at the tail of a container using its head/tail pointers. | +| `00422aac` | `intrusive_list_move_before` | Unlinks a node and inserts it before another node, or at the head when the position is null. | +| `00422b08` | `intrusive_list_move_to_head` | Unlinks a node and reinserts it at the container head. | +| `00422b3c` | `intrusive_list_move_to_tail` | Unlinks a node and reinserts it at the container tail. | +| `00422b74` | `intrusive_list_unlink` | Repairs neighboring links and container head/tail pointers to detach one node. | +| `00422bac` | `intrusive_list_unlink_and_destroy` | Unlinks a node, then invokes its vtable callback at node offset +8. | +| `00422bc8` | `intrusive_list_clear_and_destroy` | Calls the vtable callback for each node, then clears the container head and tail. | +| `00422c00` | `intrusive_list_advance_forward` | Advances a cursor through next links, starting at the container head when null. | +| `00422c18` | `intrusive_list_advance_backward` | Advances a cursor through previous links, starting at the container tail when null. | +| `00422c40` | `record_backed_object_create_from_fields` | Allocates and initializes a base object from a five-byte record; a caller installs derived vtable `0047dce4`. The object role is unresolved. | +| `00422c84` | `record_backed_object_resource_cleanup` | Cleanup callback conditionally releases fields `+0x38/+0x3c` and delegates common cleanup. The derived object's role remains unresolved. | +| `004232c8` | `audio_cleanup_pending_resources` | Under `DAT_004825d4`, releases resources through audio-channel cleanup helpers and clears callback state. The guard's broader owner/meaning remains unresolved. | +| `00423310` | `audio_update_pending_channels` | Under `DAT_004825d4`, calls the audio-channel update routine with `0x40`; that value's meaning remains unresolved. | +| `00423358` | `noop_00423358` | Immediate return with no side effects. | + +The ten list-helper names and all seven additional names/comments were read back through Ghidra MCP. The three class lifecycle helpers now have operation-level names; their derived-object roles remain unresolved. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Audio and Item Catalog + +This pass reviewed the next 20 entries reported as untracked, from `0042335c` through `004237d0`. It mapped sound playback shutdown/initialization and the static item-catalog lookup helpers. Catalog fields without caller-confirmed meaning retain offset-based names. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0042335c` | `audio_stop_playback_for_sound_id` | When audio is enabled, finds the playback slot matching the incoming sound ID and stops it if present. | +| `00423378` | `audio_stop_all_playback_channels` | Scans the 12 playback slots, marks occupied slots for stop, invokes the channel object's release method, and clears slot state. | +| `004233b0` | `audio_initialize_sound_flx` | Under the audio-init gate, loads the `sound` FLX resource when needed, initializes playback helpers, and updates the audio-active flag. | +| `004233e0` | `item_catalog_initialize` | Allocates and initializes the catalog backing resource, sets catalog-active state, and opens the `static` resource. | +| `00423424` | `item_catalog_release_if_inactive` | Releases and clears the backing resource only when the catalog-active flag is clear and the pointer is non-null. | +| `0042344c` | `item_catalog_open_static_resource` | Resolves the `static` resource and invokes its object methods; item-name and secondary-item string tables are nearby. | +| `004234c8` | `item_catalog_find_record_index_by_id` | Searches 64 catalog records at stride `0x8e` for the ID at record offset `+0x3e`; returns the index or `-1`. | +| `00423530` | `item_catalog_get_secondary_word_02_by_item_id` | Looks up an item in the 21-record table, follows its related-record index at `+6`, and returns word `+2` from that 8-byte secondary record. | +| `00423574` | `item_catalog_get_item_byte_0a` | Returns byte `+0x0a` from the matching 21-record item row; zero or missing IDs fall back to row zero. | +| `004235b0` | `item_catalog_get_item_word_02` | Returns word `+2` from the matching 21-record item row; zero or missing IDs fall back to row zero. | +| `004235ec` | `item_catalog_get_item_word_04` | Returns word `+4` from the matching 21-record item row; zero or missing IDs fall back to row zero. | +| `00423628` | `item_catalog_lookup_secondary_index_by_id` | Searches the 16-entry, 8-byte secondary table by ID and returns its row index; no match returns zero. | +| `0042364c` | `item_catalog_get_related_record_index_by_item_id` | Searches the 21-record item table by ID and returns the related-record index at `+6`. | +| `00423678` | `item_catalog_get_related_item_id` | Uses the item's related-record index at `+6` to return the related ID from the secondary table. | +| `004236bc` | `item_catalog_get_secondary_item_name` | Searches the secondary table by ID and returns its display-string pointer; a miss falls back to row zero (`INVALID`). | +| `004236e8` | `item_catalog_get_item_word_08` | Returns word `+8` from the matching 21-record item row; zero or missing IDs fall back to row zero. | +| `00423724` | `item_catalog_get_item_byte_0c` | Returns byte `+0x0c` from the matching 21-record item row; zero or missing IDs fall back to row zero. | +| `00423760` | `item_catalog_get_item_word_0d` | Returns word `+0x0d` from the matching item row; the field's semantic meaning is unresolved. | +| `0042379c` | `item_catalog_get_item_name_by_id` | Searches the 21-record item table by ID and returns the corresponding display-name pointer; a miss falls back to `INVALID`. | +| `004237d0` | `item_catalog_get_item_byte_0f` | Returns byte `+0x0f` from the matching 21-record item row; zero or missing IDs fall back to row zero. | + +All 20 names and decompiler comments were read back through Ghidra MCP. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Catalog Selectors and Item Shape State + +This pass reviewed the next 20 exact entries from `00423830` through `00424d0c`. The catalog accessors are named by table size and field where domain semantics remain unknown. Process constructors are named by their verified vtables or type `0xf0`; item-record ownership and the meaning of several state fields remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00423830` | `catalog_9entry_get_word_06_by_id` | Looks up an ID in a nine-entry table at `0047b50c` and returns row word `+0x06`; a miss falls back to row 0. | +| `0042385c` | `catalog_9entry_get_name_by_id` | Uses the same nine-entry lookup and returns its parallel name pointer; row 0 is `INVALID`. | +| `004238ac` | `catalog_12entry_get_word_02_by_id` | Looks up an ID in a twelve-entry table at `0047b4dc` and returns row word `+0x02`; a miss falls back to row 0. | +| `004238d8` | `catalog_12entry_get_name_by_id` | Uses the same twelve-entry lookup and returns its parallel name pointer; row 0 is `INVALID`. | +| `00423904` | `item_catalog_get_item_word_10` | Searches the 21-row item table and returns word `+0x10`; row 0 handles zero/missing IDs. A nonzero upper half at `+0x0e` triggers assertion `0x31e`. | +| `00423964` | `catalog_lookup_name_by_id` | Searches the item table and parallel 12-, 9-, and 16-entry tables by ID, returning a name pointer or `INVALID`. The specific label domains are unresolved. | +| `00423abc` | `catalog_lookup_first_nonzero_word_by_id` | Tests item-row `+0x0d`, then word `+0x02` in the 12- and 9-entry tables, then word `+0x06` in the 16-entry table; returns the first nonzero value. | +| `00423bc0` | `process_create_with_vtable_0047e49c` | Allocates a base process, installs vtable `0047e49c`, sets the common process flag, and clears field `+0x3e`. Derived process role unresolved. | +| `00423d24` | `item_record_create_or_update` | Clears record field `+0x0e`; one path cleans up/projects coordinates and creates from shape ID `+0x02`, while the alternate path updates projected coordinates. Record mode meaning unresolved. | +| `00423e60` | `item_shape_state_initialize` | Resets fields `+0x18/+0x1a` to `-1` and `+0x02` to zero, then stores a nonzero shape ID in a shape-associated record. Called after selecting a spatial leaf of type 2; owning state unresolved. | +| `00423eb0` | `item_shape_state_update` | Processes shape ID `+0x02`; for shape classes `0x20` or `0x90`, validates and updates associated state, then clears `+0x02`. Higher-level purpose unresolved. | +| `004240d8` | `item_record_project_to_screen` | Projects record coordinates, updates projected position, and applies shape-table height/extent offsets. Owning record type unresolved. | +| `004242c0` | `process_create_with_vtable_0047e54c` | Initializes a base process, saves `DAT_004955ce` at `+0x30`, installs vtable `0047e54c`, and sets the global to 1. | +| `00424764` | `process_f0_construct_variant_a` | Creates a type-`0xf0` process with vtable `0047e528`; may create a companion via `004242c0` and stops playback when `DAT_004825d4` is set. Class semantics unresolved. | +| `004247f8` | `process_f0_construct_variant_b` | Creates a type-`0xf0` process with vtable `0047e528`, stores `DAT_0047b984` and an input word in fields `+0x30/+0x32`, and may create the companion process. | +| `00424874` | `item_status_get_high_nibble` | Returns the high nibble of the status byte at `DAT_00482b34 + item ID`. | +| `004248a8` | `item_status_set_high_nibble` | Replaces that status byte's high nibble while preserving its low nibble. | +| `004248d0` | `item_state_get_byte` | Returns the byte at `DAT_00482b38 + item ID`; the field meaning is unresolved. | +| `004249fc` | `EggHatcher_004249fc` | Existing symbol retained. Initializes the base, installs `g_eggHaterProcessFnPtrs`, associates the item, sets process type `0x20f`, and clears `+0x30`. | +| `00424d0c` | `process_20f_draw_item_outline` | Called by `draw_map_region_grid_and_update_process_20f`; draws an item outline from the status nibbles and, in one branch, the per-item Y table. | + +All 19 renamed symbols were read back through Ghidra MCP. The 20-comment batch was accepted, and representative comments were confirmed in decompiler output. `EggHatcher_004249fc` was kept unchanged. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Queue and Palette Fade + +This pass reviewed the next 20 entries from `00424f70` through `00425b04`. It covers a ten-slot queue of 16-byte records, one-shot halted-file reporting, and the RGB6 DirectDraw palette/fade path. The fade-process class purpose beyond its observed process type and vtables remains unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00424f70` | `ring_buffer_enqueue_16byte_record` | Copies a 16-byte record into the ten-entry ring buffer and advances its write index/count; a full queue is unchanged. | +| `00424fd0` | `ring_buffer_dequeue_16byte_record` | Copies the next 16-byte record to the caller and advances the read index/count; an empty queue leaves the destination unchanged. Used by `0044a1dc` to drain queued records. | +| `00425050` | `fatal_report_halted_file_line` | One-shot fatal report formats `Halted file %s` and line number, then enters `win32_shutdown_message_loop`; not a USECODE debugger stop. | +| `00425084` | `fatal_report_halted_file_line_detail` | Adds a detail string to the halted-file report, copying it when it is not the shared buffer, then enters the shutdown message loop. | +| `00425104` | `fatal_report_halted_resource_string_2` | Loads string resource ID 2 and enters the one-shot fatal shutdown/report path. | +| `00425160` | `fatal_report_halted_resource_string_3` | Loads string resource ID 3 and enters the one-shot fatal shutdown/report path. | +| `004251bc` | `release_text_buffer_unless_global` | Releases the supplied text buffer unless it is the shared pointer at `DAT_00495818`. | +| `004251f0` | `release_text_buffer_unless_global_alt` | Duplicate release helper with the same shared-buffer guard as `004251bc`. | +| `00425270` | `palette_fade_process_initialize` | Initializes process type `0x206`, allocates two 256-entry palette buffers, snapshots the current RGB6 palette, and records fade state. Mode zero imports a palette directly. | +| `00425560` | `palette_fade_create_black_process_a` | Creates a process with vtable `0047e5bc`, prepares a black 256-entry palette, and initializes the fade process. | +| `00425600` | `palette_fade_create_black_process_b` | Near-duplicate of `00425560` with different return-value handling; both call paths are in `FUN_0042c6ac`. | +| `004256a0` | `palette_fade_create_process_pair_a` | Creates a vtable-`0047e5bc` fade process from `DAT_00482680`, then creates and registers a vtable-`0047e598` companion. | +| `00425710` | `palette_fade_create_process_pair_b` | Near-duplicate of `004256a0`; initializes the same vtable pair and registers the companion. | +| `0042577c` | `palette_set_black_rgb6` | Fills all 256 RGB6 entries with black, imports them into DirectDraw, and releases the temporary palette buffer. | +| `004257e8` | `palette_set_white_rgb6` | Fills all 256 RGB6 entries with white (`0x3f` per channel), imports them into DirectDraw, and releases the temporary palette buffer. | +| `00425858` | `palette_import_and_clear_fade_flag` | Imports all entries from the supplied RGB6 palette and clears the current palette process's active marker at `+0x3e` when set. | +| `00425884` | `palette_fade_create_for_rgb6_color` | Validates three RGB6 components in `0..0x3f`, creates a vtable-`0047e5bc` process, and initializes its fade toward that color. | +| `0042596c` | `palette_fade_create_registered_process` | Creates and registers a vtable-`0047e5bc` process initialized in mode 1 from `DAT_00482680`. | +| `004259b8` | `palette_fade_create_to_black` | Creates a vtable-`0047e5bc` fade process initialized in mode 1 with a black palette. | +| `00425b04` | `palette_fade_pump_until_complete` | Creates a vtable-`0047e5bc` fade process and pumps window/palette updates until its process flag bit 1 clears. | + +All 20 renamed symbols were read back through Ghidra MCP. The comment batch was accepted, and representative comments were confirmed in decompiler output. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Palette Transition and File Streams + +This pass reviewed the next 20 entries from `00425b70` through `00426924`. The palette routines build grayscale/solid-color RGB6 transitions; the remainder implements a Windows file-stream object with indexed backing records, random-access I/O, range copying, and bounded text-line reads. The indexed-record payload's higher-level format remains unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00425b70` | `palette_fade_to_grayscale` | Exports all 256 RGB6 entries, copies each red component into green/blue to form grayscale, then initializes a vtable-`0047e5bc` fade process. | +| `00425c48` | `palette_fade_to_grayscale_wait` | Starts the grayscale transition and pumps window/palette updates until process flag bit 1 clears. | +| `00425e70` | `file_stream_release_resources` | Closes/frees file-stream backing state through separate cleanup paths selected by flag `4`; exact object-class role remains open. | +| `00425ed0` | `file_stream_load_backing_data` | Closes prior backing state, resolves a file/resource source, then loads and stores backing data at `+0x12`; the source-container contract is unresolved. | +| `00425fb4` | `file_stream_get_indexed_record8` | Copies an eight-byte record from the backing table at `+0x12`, indexed by the supplied short. | +| `00425fc8` | `file_stream_set_indexed_record8` | Updates an eight-byte indexed backing record and persists it through the file writer at offset `0x80 + index*8`. | +| `00426070` | `file_stream_initialize` | Clears object field `+0`, sets handle field `+4` to `-1`, and stores the dispatch/data pointer at `+0x0c`. | +| `00426088` | `file_stream_initialize_and_open` | Initializes the object and immediately opens the supplied path using the supplied access/open flags. | +| `00426114` | `file_stream_open` | Calls `CreateFileA`, stores the handle/access flags, replaces any prior copied path, and keeps a heap copy of the new path. | +| `00426208` | `file_stream_close` | Closes a valid Windows handle, releases the copied path, and resets the handle field to `-1`. | +| `004262b8` | `file_stream_seek` | Moves the file cursor to the supplied offset using the requested `SetFilePointer` origin. | +| `004262f8` | `file_stream_read` | Optionally seeks to an explicit offset, then reads the requested byte count; errors route through the file/line fatal reporter. | +| `0042637c` | `file_stream_write` | Optionally seeks to an explicit offset, then writes the requested byte count; errors route through the file/line fatal reporter. | +| `00426400` | `file_stream_get_size` | Returns `GetFileSize` for the stored handle. | +| `00426440` | `file_stream_flush` | Calls `FlushFileBuffers` on the stored handle. | +| `0042647c` | `file_stream_get_position` | Returns the current cursor position using a zero offset relative to the current position. | +| `004264c4` | `file_stream_copy_range` | Copies a byte range between file streams in chunks and adjusts direction for overlapping ranges in the same file. | +| `0042675c` | `file_stream_set_length` | Seeks to the requested end and calls `SetEndOfFile`; restores the original cursor when extending, while truncation leaves it at the new end. | +| `0042682c` | `file_stream_position_is_within_size` | Returns whether the current cursor is not beyond the file size, restoring the original cursor afterward. | +| `00426924` | `file_stream_read_text_line` | Reads a bounded text line, stops at carriage return or DOS EOF `0x1a`, null-terminates the result, and positions the cursor past the consumed terminator. | + +All 20 renamed symbols were read back through Ghidra MCP. The comment batch was accepted, and representative comments were confirmed in decompiler output. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Memory Readers and Indexed Files + +This pass reviewed the next 20 entries from `00426c1c` through `004281e4`. The functions implement a memory-backed text reader, a shared resource-path builder and wildcard/list-file enumerator, usecode-related caches, and fixed-record indexed-file operations. The selector-table record schema and indexed-file record contract remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00426c1c` | `memory_reader_release` | Releases the memory-reader allocation according to ownership flags, restores its dispatch pointer, and optionally completes object cleanup. | +| `00426c4c` | `memory_reader_skip_whitespace` | Advances the cursor past spaces, tabs, carriage returns, and line feeds, stopping at the buffer end. | +| `00426c94` | `memory_reader_read_token` | Skips leading whitespace, copies the next non-whitespace token, and null-terminates the caller's output. | +| `00426d34` | `memory_reader_read_until` | Copies bytes up to a delimiter or buffer end and null-terminates the output. | +| `00426dbc` | `memory_reader_skip_line` | Advances through the next line feed and consumes it when present. | +| `00426e00` | `memory_reader_read_byte` | Returns the current byte and advances the cursor; returns zero without advancing at end of buffer. | +| `00426e28` | `memory_reader_open_file` | Opens a file through the file-stream layer, allocates a buffer sized to the file, reads the full contents, and initializes memory-reader state. | +| `00426f80` | `resource_path_build` | Joins up to four path/name components in one of five rotating scratch buffers, handling backslash boundaries and a dot before the final component when needed. Callers include audio, catalog, and cache paths. | +| `004272e8` | `file_enumerator_start` | Starts `FindFirstFileA` enumeration; an input prefixed with `@` is opened as a text file containing search patterns, retained for later results. | +| `0042761c` | `file_enumerator_close` | Closes the optional memory-backed pattern-list reader and active `FindFirstFileA` handle. | +| `0042765c` | `resource_path_exists` | Builds a path with the shared helper and returns the result of the path-existence check. | +| `00427684` | `file_enumerator_next` | Advances with `FindNextFileA`, reads another pattern from an `@` list when needed, and copies the selected `WIN32_FIND_DATAA` result into enumerator state. | +| `00427a70` | `selector_table_find_by_id` | Searches 16 records at `0047b600`, each `0x11` bytes, using the supplied short identifier; reports a fatal error if no record matches. | +| `00427aac` | `selector_table_release_resource` | Finds the record matching the supplied short identifier and releases the resource referenced by its field at `+2`; the record schema remains unresolved. | +| `00427b10` | `usecode_cache_release` | Frees two global usecode-related cache buffers when present and resets cached size fields. | +| `00427b54` | `usecode_cache_reload` | Clears/reloads usecode-related buffers, updates cached sizes, enumerates a derived path, and optionally loads an associated data file. | +| `00427e30` | `indexed_file_create` | Creates a fixed-record file with a `0x54`-byte header containing the supplied count and format value, followed by zeroed four-byte entries. | +| `00427ef4` | `indexed_file_open_or_create` | Initializes an indexed-file object, creates and zero-initializes the fixed-record file in create-on-missing mode, or opens an existing file and reads its `0x54`-byte header. | +| `00428054` | `indexed_file_initialize_from_path` | Initializes an indexed-file object from a path, creating the header and zeroed entries in create-on-missing mode or reading the existing `0x54`-byte header. | +| `004281e4` | `indexed_file_select_record` | Checks the requested short index against the count at object `+0x10`, reports out-of-range access, then dispatches through the object's vtable at `+4`; exact record-selection semantics remain open. | + +All 20 renamed symbols were read back through Ghidra MCP. The comment batch was accepted, and representative comments were confirmed in decompiler output. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Flex and Resource Cache Helpers + +This pass reviewed the final nine entries needed to reach the 30% address-tracking target. It covers exact reads from flex/indexed files, a file-stream rewind helper, resource-cache object creation and lookup, and two object initializers. The indexed resource payload format and some cache-context fields remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00428224` | `flex_read_exact` | Resolves the selected record through a virtual method, reads the requested range at the supplied offset, and reports a flex-file error if the read is short. | +| `004283a0` | `file_stream_rewind` | Invokes the object's virtual preparation method, then seeks its file stream to offset zero. | +| `0042865c` | `resource_cache_context_initialize` | Runs two shared initialization helpers and sets field `+0x58` to 1; its cache-context role is inferred from callers. | +| `00428700` | `clear_two_dwords` | Clears two consecutive 32-bit fields; used while initializing a fixed-record file. | +| `00428710` | `resource_cache_object_create` | Initializes and registers a resource-cache object, computes a size/selector field, creates an embedded file-stream object, and invokes its setup method. | +| `004287f4` | `resource_cache_get_by_id` | Resolves a cache slot by ID; on a miss it releases/recreates and reloads the resource, while a hit promotes the entry to the list head. | +| `004288a4` | `resource_cache_get_indexed_data` | Gets the cached resource, reads the indexed relative offset from its table at `+6 + index*8`, and returns the corresponding data pointer. | +| `00428910` | `text_object_initialize` | Installs the text-object dispatch table at object offset `+8`; additional setup is performed by the caller. | +| `00428918` | `resource_state_object_initialize` | Clears three 16-bit state fields and installs the resource-state dispatch table at offset `+8`. | + +All nine renamed symbols were read back through Ghidra MCP. The comment batch was accepted, and representative comments were confirmed in decompiler output. No executable bytes were changed and the Ghidra project was not saved. The exact-entry coverage report confirms 448/1,493 (30.0%) tracked entries. + +## Address-Ordered Pass: Text Layout, Palette, and Runtime Helpers + +This pass reviewed the next 20 entries from `00428934` through `00429fb0`. It covers DBCS-aware text layout and measurement, shared object/rectangle helpers, a game-runtime transition path, palette-manager operations, scheduler/animation process construction, and resource-cache lookup. The two text-context vtable accessors and several process-state fields remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00428934` | `text_layout_advance_character` | Advances one character in the text layout: line feed updates Y and resets X, carriage return resets X, and other characters advance X using renderer metrics. | +| `00428ac8` | `text_measure_multiline_width` | Measures DBCS-aware text through a renderer callback, resets the line width on line feed, and returns the maximum width. | +| `00428ba8` | `text_context_get_vfunc_10` | Calls renderer vtable slot `+0x10` and returns its result; the specific metric and caller contract are unresolved. | +| `00428bc8` | `text_context_get_vfunc_10_alt` | Separate entry calling renderer vtable slot `+0x10`; its caller contract is unresolved. | +| `00428be4` | `text_layout_initialize_and_advance_string` | Initializes text-layout coordinates, then advances the layout for each DBCS-aware character in the shared string. | +| `00428c7c` | `text_layout_advance_to_width_limit` | Advances layout until the next character would exceed the requested width and returns the accepted character count. | +| `00428d40` | `text_layout_advance_string` | Walks the shared string as DBCS-aware characters and advances the current text-layout state. | +| `00428dc8` | `set_shared_object_context` | Stores the incoming object pointer in both shared globals `DAT_0048266c` and `DAT_00482670`. | +| `00428de0` | `rect_set_bounds` | Copies four incoming 16-bit coordinate values into the bounds record. | +| `00428e00` | `game_runtime_transition_dispatch` | Updates runtime mode and palette state, dispatches the event loop, and handles its result through process, resource-cache, map, and item-state paths. | +| `0042923c` | `noop_callback_0042923c` | Empty function body; data references establish callback use, but the callback slot role is unresolved. | +| `00429648` | `process_opcode_d9_construct` | Allocates and initializes a process object; the opcode dispatcher invokes this constructor for command `0xd9`. | +| `004296e0` | `palette_manager_initialize` | Initializes palette-manager buffers and indexed-file state, installs its dispatch table, and initializes the active palette-entry buffer. | +| `004297dc` | `palette_manager_shutdown` | Releases palette-manager buffers and indexed-file state, then clears associated global pointers. | +| `004299f4` | `palette_manager_reset_entry_buffer` | Resets indexed-file entry state and replaces its allocated entry buffer. | +| `00429a78` | `palette_set_grayscale_rgb6` | Copies the current RGB6 palette, replaces green and blue with each entry's red channel, and imports the grayscale palette. | +| `00429ba0` | `scheduler_process_construct` | Constructs and initializes the scheduler process, sets type `0x245`, and calls the scheduler setup helper. | +| `00429c00` | `animation_process_construct` | Constructs and initializes the animation process, sets type `0x230`, and invokes its setup helpers. | +| `00429d34` | `animation_process_reset_timing` | Clears process byte `+0x52` and copies field `+0x3e` to `+0x42`; higher-level timing semantics remain unresolved. | +| `00429fb0` | `resource_cache_get_or_create_by_id` | Looks up an entry by 16-bit ID in a 512-slot tag table; on a miss it reserves or evicts a slot and creates a cache node, while a hit promotes the node to the list head. | + +All 20 names were read back at their exact Ghidra entry addresses, and the decompiler-comment batch was accepted. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Gravity, Glob Items, and Static Resources + +This pass reviewed the next 20 entries from `0042a118` through `0042bf18`. It covers glob-item resource expansion, item-edge overlap queries, gravity-process setup/update, indexed-resource drawing and bounds, and static-resource pool operations. Several resource-record fields and callback roles remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0042a118` | `glob_item_create_for_source` | Resolves a coordinate and forwards it with the source item's Y/Z values to the glob-item loader. | +| `0042a180` | `glob_items_load_from_resource` | Expands compact six-byte resource records into runtime records and creates shape-`0x82` glob items when the target region is eligible; the record schema remains unresolved. | +| `0042a4a8` | `resource_cache_apply_record_entries` | Walks the cached record count and passes each record's byte at offset `+7` to a helper whose semantics remain unresolved. | +| `0042a514` | `static_resource_context_load` | Loads and initializes a static resource, stores it in `DAT_00482aa8`, and halts with a resource error if loading fails. | +| `0042a544` | `static_resource_context_invoke` | Invokes the first method in the initialized resource object's dispatch table with the supplied argument. | +| `0042a65c` | `spatial_query_item_edge_overlap_flags` | Queries nearby item shapes against supplied bounds and builds directional overlap flags; bit `0x10` marks overlap on opposing sides. Shape-flag semantics remain unresolved. | +| `0042aa14` | `gravity_process_construct` | Constructs a process using `g_gravityProcessFnPtrs`, associates the supplied item, sets type `0x203`, and initializes movement/state fields. | +| `0042ad04` | `gravity_process_update` | Reads and updates associated-item coordinates and flags, checks candidates through spatial/edge-overlap queries, and conditionally performs item/process actions; state fields and movement rules remain partly unresolved. | +| `0042b720` | `object_dispatch_cleanup_sequence` | Runs a fixed helper sequence, conditionally invokes vtable slot `+0x08` based on an object flag, and performs cleanup; the caller-specific lifecycle role is unresolved. | +| `0042b7a4` | `gravity_process_apply_position_delta` | Finds the first type-`0x203` process and adds supplied deltas to three stored fields; if absent, conditionally constructs and schedules one. | +| `0042b834` | `gravity_process_create_for_item_if_needed` | Checks the item's shape record and creates/schedules a type-`0x203` process only when record gates pass and none already exists. | +| `0042ba10` | `static_resource_pair_initialize` | Loads two static resources into globals and creates a cache object with selector `0x100`; required load failures take fatal error paths. | +| `0042ba84` | `static_resource_pair_shutdown` | Releases the paired static-resource cache object and resource, then clears their global pointers. | +| `0042bb40` | `draw_indexed_resource_at_position` | Loads indexed resource data and draws it at supplied screen coordinates; index `0x15` also draws associated notification text and updates its state. | +| `0042bcc8` | `indexed_resource_copy_record_to_state` | Loads indexed resource data and passes it with a two-word caller buffer to `004696bc`; the copied record fields remain unresolved. | +| `0042bd14` | `indexed_resource_get_bounds` | Reads width and height from an indexed resource record and writes bounds from `(0,0)` through `(width-1,height-1)`. | +| `0042bdf0` | `resource_cache_object_reset_or_release` | Releases or resets a resource-cache object based on flag bits, updating its dispatch pointer and cache slot on the reset path. | +| `0042be90` | `static_resource_pool_reserve` | Reserves bytes from the static-resource pool, advances pool accounting, and returns the pool address; requests beyond 5000 take a fatal error path. | +| `0042bed4` | `static_resource_pool_initialize` | Loads the static-resource pool backing block, stores its pointer in `DAT_00482ac4`, initializes the allocator helper, and resets the pool offset. | +| `0042bf18` | `static_resource_pool_shutdown` | Releases the static-resource pool backing block and clears `DAT_00482ac4`. | + +All 20 names were read back from the active Ghidra program, and the decompiler-comment batch was accepted. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Usecode and Item Accessors + +This pass reviewed the next 20 entries from `0042c0b0` through `00431860`. Caller checks tie the process initializer and opcode dispatcher to `UsecodeProcess_Create` and `UsecodeProcess_NextOpcode`; the remaining functions provide runtime-mode and item-record accessors for containment, coordinates, shape bounds, and footprint queries. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0042c0b0` | `usecode_process_initialize_program_data` | Initializes a usecode-process execution object, copies optional program bytes, stores runtime arguments, creates backing resource state, and enqueues an initial selector/value pair. | +| `0042c6ac` | `usecode_opcode_dispatch` | Dispatches the current usecode opcode to operation-specific handlers, including process/resource, item, rendering, and audio paths; individual opcode contracts remain partly unresolved. | +| `0042ddc8` | `UsecodeProcess_NextOpcode` | Reads and advances the next opcode from the usecode instruction stream; `UsecodeProcess_Run` calls it before opcode dispatch. | +| `0043120c` | `runtime_mode_matches_value` | Compares the incoming 16-bit value with `DAT_0047b1d6` and returns the equality result; callers use it as a runtime-mode predicate. | +| `00431220` | `item_has_flag_20` | Tests bit `0x20` in the item flags word. | +| `00431240` | `item_get_outermost_x` | Follows item-parent links through the X field while flag bit 3 is set, then returns the outermost item's X coordinate. | +| `00431280` | `item_get_outermost_y` | Follows item-parent links through the X field while flag bit 3 is set, then returns the outermost item's Y coordinate. | +| `004312c4` | `item_get_contained_x_offset` | Returns the low byte of the packed Y field when item flag bit 3 is set, otherwise zero; the contained-position interpretation is supported by paired accessors. | +| `004312f4` | `item_get_contained_y_offset` | Returns the high byte of the packed Y field when item flag bit 3 is set, otherwise zero; the contained-position interpretation is supported by paired accessors. | +| `0043132c` | `item_set_contained_position` | For items with flag bit 3 set, packs two clamped coordinate components into the item's Y field. | +| `0043137c` | `item_get_outermost_z` | Follows item-parent links while flag bit 3 is set, then returns the outermost item's Z value. | +| `004313c4` | `item_get_shape_adjusted_x` | Returns item X adjusted by the X footprint extent decoded from its shape record; the world-bound convention remains unresolved. | +| `00431410` | `item_get_shape_adjusted_y` | Returns item Y adjusted by the Y footprint extent decoded from its shape record; the world-bound convention remains unresolved. | +| `0043145c` | `item_get_shape_adjusted_z` | Returns root-item Z plus the current item's shape-height contribution scaled by four. | +| `004314e4` | `item_set_auxiliary_state_byte` | Stores a byte in `DAT_00482b44` indexed by item ID; the table's state meaning remains unresolved. | +| `004314f8` | `item_set_z` | Stores a new item Z byte when below `0xfa`; larger values take a fatal validation path. | +| `0043152c` | `item_get_outermost_position` | Follows item-parent links and writes the outermost item's X, Y, and Z values to caller storage. | +| `004315d4` | `item_get_shape_byte_7` | Returns byte `+7` from the item's shape record; recursive item aggregation uses it, but its meaning and units remain unresolved. | +| `00431794` | `item_shape_begin_footprint_query` | Starts a shape-footprint selector query for the supplied item ID using mode arguments 1 and 1. | +| `00431860` | `item_get_shape_id` | Returns the shape ID stored for the incoming item ID. | + +All 19 renamed functions were read back at their exact entry addresses. The existing `UsecodeProcess_NextOpcode` symbol was retained, and its comment update was accepted. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item State and Shape-Class Accessors + +This pass reviewed the next 20 entries from `0043187c` through `00431db4`. It covers item shape changes and render invalidation, per-item state-byte tables, shape-class-gated state access, and shape-record bit extraction. The semantic roles of several global byte/word tables remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043187c` | `item_set_shape_id_and_refresh` | Changes the item's shape ID and invokes a shape-change helper when tested rendering flags differ; item flag bit `0x8000` suppresses one transition path. | +| `00431980` | `item_get_render_state_bytes` | Combines the byte at `DAT_00482b28` indexed by item ID with item-record byte `+0x0f`; exact field semantics remain unresolved. | +| `004319f0` | `item_set_render_state_bytes` | Stores both bytes of an item state value and may invalidate its render bounds and refresh the tracked-item selection. | +| `00431ad4` | `item_set_auxiliary_byte_00482b34` | Stores a byte in `DAT_00482b34` indexed by item ID; the table's semantic role remains unresolved. | +| `00431ae8` | `item_get_auxiliary_byte_00482b34` | Returns the byte in `DAT_00482b34` indexed by item ID. | +| `00431afc` | `item_set_auxiliary_byte_00482b38` | Stores a byte in `DAT_00482b38` indexed by item ID; the table's semantic role remains unresolved. | +| `00431b10` | `item_get_auxiliary_byte_00482b38` | Returns the byte in `DAT_00482b38` indexed by item ID. | +| `00431b24` | `noop_callback_00431b24` | Empty function body; no stronger callback role is established. | +| `00431b44` | `item_get_shape_class_10_state` | Returns the per-item word in `DAT_00482b30` only when masked shape-class bits equal `0x10`. | +| `00431b88` | `item_set_shape_class_10_state` | Stores the per-item word in `DAT_00482b30` only when masked shape-class bits equal `0x10`. | +| `00431bc8` | `item_get_shape_class_40_state` | For masked shape-class bits `0x40`, returns the low byte of the per-item word in `DAT_00482b30`. | +| `00431c0c` | `item_get_state_table_value` | Returns the per-item word stored in `DAT_00482b30` without checking the item's shape class. | +| `00431c28` | `item_set_state_and_start_event` | Stores a per-item word in `DAT_00482b30` and starts the associated usecode event process with selector `0x1000`. | +| `00431c58` | `item_get_state_for_shape_class_6_7` | Returns the per-item word in `DAT_00482b30` only when the decoded shape class is 6 or 7. | +| `00431cb0` | `item_get_container_id_if_nested` | Returns the item's X-field parent/container ID only when item flag bit 3 is set; otherwise returns zero. | +| `00431cd8` | `item_get_shape_class_30_state` | For masked shape-class bits `0x30`, returns the per-item word in `DAT_00482b30`. | +| `00431d1c` | `item_set_state_table_value` | Stores a per-item word in `DAT_00482b30` without checking the item's shape class. | +| `00431d34` | `item_set_state_for_shape_class_6_7` | Stores a per-item word in `DAT_00482b30` only when masked shape-class bits equal `0x60` or `0x70`. | +| `00431d80` | `item_get_shape_flags_low_9` | Returns the low nine shape-record flag bits shifted down by four. | +| `00431db4` | `shape_record_test_bit` | Tests one selected bit from a shape-record byte using the low three bits of the supplied selector as the bit index. | + +All 20 names were read back from the active Ghidra program, and a representative decompiler comment was confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Lifecycle and Spatial Helpers + +This pass reviewed the next 20 entries from `00431df8` through `00432c68`. It covers item flag/shape access, item creation and removal hooks, usecode-driven item state updates, direction and dimension helpers, and 3D overlap testing. Several register-context wrappers and action helpers retain explicitly generic names where their contracts remain unclear. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00431df8` | `item_get_flags` | Returns the 16-bit flags word for the incoming item ID. | +| `00431e14` | `item_create_from_shape_and_initialize` | Validates a shape ID, creates an item under the item lock, initializes it with a value from the context object, and returns success. | +| `00431e98` | `item_create_from_shape_with_value` | Validates a shape ID, creates an item under the item lock, initializes it with the supplied value, and returns success. | +| `00432090` | `item_call_helper_00437768` | Register-context wrapper around `00437768`; its implicit register contract is unresolved. | +| `004320a8` | `item_call_helper_00437e40` | Register-context wrapper around `00437e40`; its implicit register contract is unresolved. | +| `004320b4` | `item_update_active_item_position` | Updates the active item's position through two helpers and preserves the stored Y value when the active item is nested. | +| `004320bc` | `item_call_helper_00438000` | Thin wrapper around `00438000`; caller/register semantics remain unresolved. | +| `004320c8` | `item_release_related_state` | Thin wrapper around `0043760c`; its caller-specific lifecycle role remains unresolved. | +| `004320d8` | `item_remove_with_side_effects` | Runs selected-shape, usecode/resource, and optional footprint-query side effects, then delegates to `00437394` for item removal. | +| `00432244` | `item_container_destroy_contents_if_class_6_7` | Decodes the item's shape class and destroys linked contents only for classes 6 or 7. | +| `0043229c` | `usecode_item_update_position_and_event` | Updates item state, starts usecode event selector `0x40000`, and may refresh the tracked-item marker based on mode and shape data. | +| `004324c4` | `item_remove_linked_child_and_start_event` | Runs item helpers and starts usecode event selector `0x40000`; called while processing linked contents during removal. | +| `004324fc` | `usecode_item_apply_guarded_action` | Runs a guarded operation using current-item and shape-derived state, optionally invokes a follow-up helper, and returns the guard result; action semantics remain unresolved. | +| `0043257c` | `item_test_spatial_and_shape_condition` | Tests a spatial/shape condition using the current item and supplied coordinates, reports optional outputs, and initializes a footprint query on selected paths. | +| `004327e0` | `item_restore_position_from_record` | Reads an item-related value from `0043760c` and passes it to `00437768`; record and register contracts remain unresolved. | +| `0043280c` | `item_direction_from_delta` | Calls the eight-way direction helper using the incoming register delta and current item's Y coordinate. | +| `00432898` | `item_direction_to_item` | Computes an eight-way direction from the current and target items' Y coordinates, then normalizes the result into a direction code. | +| `00432904` | `item_direction_from_target_y` | Calls the eight-way direction helper using current and supplied item Y coordinates; this entry discards the helper result. | +| `0043295c` | `item_shape_get_oriented_dimensions` | Decodes shape width, depth, and height into caller outputs, swapping horizontal dimensions when item flag `0x20` is set. | +| `00432c68` | `item_shapes_overlap_spatially` | Tests whether two non-contained items overlap in X, Y, and Z using oriented shape extents. | + +All 20 names were read back at their exact Ghidra entry addresses, and the decompiler-comment batch was accepted. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Footprints and Usecode Events + +This pass reviewed the next 20 entries from `00432ea0` through `0043399c`. Callers place the footprint predicates and event helpers in usecode dispatch, position-state dispatch, item-state updates, and gravity processing; names preserve selector values where the event semantics are not established. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00432ea0` | `item_footprints_overlap_xy` | Tests whether two non-nested items' shape-derived horizontal extents overlap on X and Y; it does not test Z. | +| `00433074` | `item_xy_overlap_at_shape_top_z` | First calls `00432ea0`, then tests whether the current item's Z equals the other item's Z plus that shape's height; called by usecode dispatch. | +| `00433150` | `item_test_contained_footprint_at_top_z` | Compares oriented shape extents and coordinates for a directional footprint-containment condition, then checks top-Z alignment; called by usecode dispatch. | +| `00433364` | `item_get_position_xyz` | Copies the current item's X, Y, and Z coordinates to caller storage. | +| `004333a4` | `item_id_is_nonzero_byte_range` | Returns whether the current item ID is in the range 1 through `0xff`. | +| `004333d8` | `item_check_nested_parent_chain` | Follows nested-parent links and tests whether the encountered parent ID is in the nonzero byte-sized range; the higher-level purpose remains unresolved. | +| `00433460` | `item_invalidate_render_state_if_allowed` | Unless item flag `0x800` is set, invalidates viewport render bounds and updates the tracked-item ID; called by usecode dispatch. | +| `0043348c` | `item_set_flags` | Replaces the current item's 16-bit flags word. | +| `004334a4` | `item_add_flags` | ORs supplied bits into the current item's flags word. | +| `004334bc` | `item_mask_flags` | ANDs the current item's flags word with a supplied mask, preserving only selected bits. | +| `004334d4` | `usecode_start_event_selector_1` | Starts a usecode event process with selector 1 and mode 0. | +| `00433500` | `item_set_flag_8000_and_notify` | If the current item lacks flag `0x8000`, calls `0046540c` and sets the flag on the helper-selected item; called by item-state and usecode paths. | +| `00433558` | `item_clear_flag_8000_and_cleanup` | If the current item has flag `0x8000`, calls `004653ac` and clears the flag on the helper-selected item. | +| `004335b0` | `item_has_flag_8000` | Returns whether the current item's flags word contains bit `0x8000`. | +| `004335d4` | `usecode_start_event_selector_2_if_eligible` | Checks item ID/state helpers and conditionally starts usecode event selector 2; called by usecode dispatch. | +| `00433688` | `usecode_start_event_selector_20` | Starts a usecode event process with selector `0x20`, forwarding the incoming low-byte mode. | +| `004336c4` | `item_try_start_event_selector_40` | Validates item/shape state, may start selector `0x40`, and walks nested parents; called by position-state selector dispatch. | +| `0043388c` | `usecode_start_event_selector_4` | Starts a usecode event process with selector 4 and mode 0. | +| `004338bc` | `item_start_footprint_query` | Initializes a shape-footprint query for the current item with mode 3; callers include gravity processing. | +| `0043399c` | `usecode_start_event_selector_400` | Starts a usecode event process with selector `0x400`, forwarding the incoming low-byte mode. | + +All 20 names were read back at their exact Ghidra entry addresses, and representative decompiler comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item State and Event Transitions + +This pass reviewed the next 20 entries from `004339cc` through `00434a94`. It covers event-selector wrappers, item transition flags, viewport/spatial helpers, shape-record bits, and a per-item state word; names retain generic helper addresses where only the forwarding behavior is known. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004339cc` | `usecode_start_event_selector_800` | Starts usecode selector `0x800`, forwarding the incoming low-byte mode. | +| `004339fc` | `usecode_start_event_selector_10_if_enabled` | Starts selector `0x10` only when the high word of `DAT_0047b982` is nonzero. | +| `00433a70` | `usecode_start_event_selector_4000` | Starts usecode selector `0x4000` with mode 0. | +| `00433aa0` | `item_set_flag_2000_and_process_shape` | Sets item flag `0x2000`, runs shape-class-dependent processing, and may start selector `0x8000`; callers include item helper `00437768`, map cleanup, and usecode dispatch. | +| `00433e38` | `item_clear_flag_2000_and_finalize` | Clears flag `0x2000`, performs item/resource cleanup, and may start selector `0x10000`; callers include item helper `00437768` and map-unload paths. | +| `00434018` | `usecode_start_event_selector_20000` | Starts usecode selector `0x20000`, forwarding the incoming low-byte mode. | +| `00434078` | `usecode_start_event_selector_80000_if_eligible` | Checks byte-sized item eligibility and item state before possibly starting selector `0x80000`. | +| `004340f4` | `viewport_pick_spatial_leaf_class_2` | Picks the spatial leaf at a point and returns its word at offset `0x24` only when its encoded class is 2; otherwise writes zero. | +| `0043412c` | `shape_record_test_flag_10` | Returns bit `0x10` from the first shape-record byte; callers use it in tracked-item-marker eligibility/refresh paths. | +| `00434164` | `shape_record_test_field_bit_12_at_5` | Tests bit `0x1000` of the shape-record word at offset 5. | +| `00434198` | `shape_record_get_flag_01` | Returns bit 0 of the first shape-record byte. | +| `004348e4` | `item_state_get_high_byte` | Returns the high byte of the per-item word in `DAT_00482b30`. | +| `00434904` | `item_state_set_high_byte` | Replaces that per-item word's high byte while preserving its low byte. | +| `00434928` | `item_state_get_low_byte` | Returns the low byte of the per-item word in `DAT_00482b30`. | +| `00434948` | `item_state_set_low_byte` | Replaces that per-item word's low byte while preserving its high byte. | +| `0043496c` | `usecode_query_from_root_item_position` | Follows nested-parent links to root-item coordinates, then passes them and an incoming selector to two query helpers; called by usecode dispatch. | +| `00434a40` | `item_call_helper_0045fa74_if_enabled` | Forwards the current item ID to `0045fa74` when `DAT_004825d4` is nonzero; used by surrender, interaction, and process-state paths. | +| `00434a5c` | `item_call_helper_0045fc28_if_enabled` | Forwards the current item ID to `0045fc28` when `DAT_004825d4` is nonzero; callers include usecode dispatch and process constructors. | +| `00434a78` | `item_call_helper_0045ffb4_if_enabled` | Conditionally forwards the current item ID to `0045ffb4`; the higher-level operation remains unresolved. | +| `00434a94` | `item_call_helper_0045fee0_if_enabled` | Conditionally forwards the current item ID to `0045fee0`; the higher-level operation remains unresolved. | + +All 20 names were read back at their exact Ghidra entry addresses, and representative decompiler comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Helpers and Spawn Path + +This final threshold batch reviewed the next 10 entries from `00434ab0` through `00435100`. The helper wrappers retain address-based names where the target behavior is not established; the larger shape-classifier and usecode spawn path are described by their observed data flow. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00434ab0` | `item_call_helper_0045ffb4_if_enabled` | Forwards the current item ID to `0045ffb4` when `DAT_004825d4` is nonzero; duplicates the conditional path at `00434a78`. | +| `00434acc` | `item_mode_call_helper_0046009c_if_enabled` | Calls `0046009c` only when `DAT_004825d4` is nonzero. | +| `00434ae4` | `item_mode_call_helper_00460164_if_enabled` | Calls `00460164` with the current item ID only when `DAT_004825d4` is nonzero; otherwise returns zero. | +| `00434b04` | `usecode_call_helper_00456c20` | Usecode-dispatch wrapper around `00456c20` with fixed arguments and incoming BX. | +| `00434b24` | `usecode_call_helper_00456d90` | Usecode-dispatch wrapper around `00456d90` with fixed arguments and incoming BX. | +| `00434b44` | `item_call_helper_00456f0c` | Forwards incoming context and BX to `00456f0c`, then returns zero. | +| `00434b58` | `item_has_flag_2000` | Returns whether the current item's flags contain `0x2000`; callers include usecode dispatch and gravity processing. | +| `00434cd0` | `shape_id_get_action_class` | Maps selected shape IDs to action-class values, using `00468354` as a discriminator for several ranges. | +| `00434d84` | `usecode_spawn_item_from_shape_profile` | Usecode-dispatched path that reads per-item state/profile data, creates an item at the current item's coordinates, applies state, and may create a second shape-selected item. | +| `00435100` | `item_shape_id_check_under_lock` | For shape IDs below `0x800`, enters the item lock and performs helper `004477d8` lookup; returns the lookup success byte. | + +All 10 names were read back at their exact Ghidra entry addresses, and representative decompiler comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Grid and Pool Management + +This batch continues at the next report-listed entries after `00435100`. The names describe observed item-grid, cell-list, and ID-pool operations; unresolved flag and shape-record semantics are kept explicit. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004352b4` | `item_test_projected_shape_bounds` | High confidence for the geometry path. Projects the current item's world coordinates to screen space, derives its rendered shape bounds, and passes those bounds to a rectangle test. Callers include NPC adjacency, surrender, and attack update paths. | +| `00435448` | `item_global_state_00482b74_is_set` | High confidence for the operation only: returns whether global word `DAT_00482b74` is nonzero. | +| `00435458` | `shape_id_test_feature_or_sentinel_7fe` | Returns true for shape ID `0x7fe`; otherwise queries a shape-record value and tests a packed bit. The bit's meaning remains unresolved. | +| `0043548c` | `item_test_shape_footprint_at_top_z` | Tests the current item's oriented horizontal footprint against the supplied item's bounds and requires the current item's Z to equal the supplied shape's top Z. Called by usecode dispatch. | +| `004356a0` | `clear_u16_result` | Writes zero to the 16-bit output addressed by incoming `EAX`; the decompilation shows two consecutive zero stores. | +| `004356d4` | `isometric_bounds_contains_tile` | Tests whether a transformed coordinate pair lies within four isometric bounds and rejects coordinates outside the `0..63` tile domain. Used by visible-item rendering. | +| `0043577c` | `item_grid_reserve_ids_for_cell` | Reserves the requested number of item IDs from the free list, initializes their property records, links them into the selected 64x64 cell, and updates cell/free counts. Called while loading glob items. | +| `004358ec` | `item_grid_spawn_globs_for_cell` | Walks items in one grid cell and creates glob objects for entries with shape-class bits `0x30` and nonzero associated state; called by the viewport-region updater. | +| `004359dc` | `item_grid_mark_transition_items` | Walks one grid cell and marks eligible items with flag `0x2000` after outermost-Z, shape, existing-flag, and item-flag checks. The transition's higher-level meaning remains unresolved. | +| `00435a94` | `item_grid_cleanup_transition_items` | Processes items in one grid cell during a transition: cleans matching type-`0x203` processes, then finalizes or removes items based on flag `0x80` and shape checks. | +| `00435bc0` | `item_grid_prune_or_recycle_items` | When enabled, scans all 64x64 cells, finalizes or removes their items, and repairs the small-item free list. Called when the viewport-region updater changes mode. | +| `00435d20` | `item_grid_set_mode_and_rebuild` | Changes the active grid mode, optionally resets item state, rebuilds free-ID and cell lists, restores or removes items, and refreshes the viewport; called by `00436900`. | +| `00436650` | `item_grid_initialize_default_state_tables` | Initializes a sequence of object-vtable state values and clears flag bit 0 across the item flag table. The state-table entry roles remain unresolved. | +| `00436900` | `item_grid_update_viewport_region` | Called by `update_map_viewport_tile_cache`. Handles grid-mode changes and scans transformed tile bounds to run per-cell transition, cleanup, and glob-creation work. | +| `00436dd0` | `item_grid_initialize_storage` | Allocates item property arrays and 64x64 grid tables, opens the static item resource, and initializes free-ID chains and sentinel state. Used during runtime/map initialization. | +| `00436f80` | `item_grid_release_storage` | Releases the static item resource and grid allocations, then frees the item property arrays. | +| `00436fe4` | `item_grid_find_previous_id_in_owner_list` | Finds the previous ID in the current item's owning chain, selecting among free-ID lists, nested-item links, or the item's spatial cell chain. | +| `00437138` | `item_grid_unlink_item_from_cell` | Unlinks the current item from its 64x64 cell chain and decrements that cell's item count. | +| `004371fc` | `item_pool_return_id_to_free_list` | Removes the current item ID from the appropriate small- or large-ID free list and decrements the matching free count. | +| `00437394` | `item_remove_from_world_and_recycle_id` | Runs shape/tracked-marker hooks, removes linked contents, unlinks the item from its owner or cell, returns its ID to a free list, marks Z as `0xfe`, and clears associated map bits. | + +All 20 names were read back at their exact Ghidra entry addresses; decompiler comments were applied to all entries, and representative comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Pool and Spatial Selectors + +This batch follows the item-grid routines with pending/free-ID management, shape-profile helpers, and the next four spatial-selector scans. Names and descriptions stay at the observed operation level where the profile fields or resource format remain unknown. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004375a4` | `item_grid_coords_within_viewport_bounds` | Shifts the supplied coordinates right by 9, writes the resulting grid-cell coordinates to caller outputs, and tests them against the current isometric bounds. | +| `0043760c` | `item_pool_queue_id_for_release` | Detaches the current item from its owner, spatial cell, or free list as applicable, then links its ID onto pending-list head `DAT_00482b08` and sets flag bit `0x08`. Called by removal and grid-rebuild paths. | +| `00437768` | `item_grid_insert_item_at_position` | Adds an item at a world position, updates the destination cell count, obtains an ID from the pending/free pool, and initializes or links item state. Callers include item creation, saved-position restoration, usecode position updates, and grid rebuild. | +| `00437e40` | `item_move_to_outermost_position` | Moves or restores an item at its outermost world position. Shape class `0x60` uses a special pending-ID path; other shapes resolve the outermost position and delegate insertion to `00437768`. | +| `00437f7c` | `item_pool_restore_pending_head` | Processes the pending-list head, routing nested items through `00437e40` or inserting other items through `00437768`, then restores a saved coordinate field. | +| `00438000` | `item_pool_reinsert_pending_id_at_position` | For shape classes `0x60`/`0x70`, removes an ID from the pending list and links it into the item's state chain; other shapes resolve the outermost world position and delegate insertion. | +| `00438154` | `item_pool_discard_pending_head` | Pops one pending ID, clears item flag bit `0x08`, and optionally clears its auxiliary byte for IDs above `0xff`; the observed caller is `0044fed4`. | +| `00438228` | `item_pool_get_pending_head_id` | Returns the low word of `DAT_00482b08`, the current pending-list head ID. | +| `00438230` | `item_pool_discard_large_free_head` | Clears state associated with the large-ID free-list head, then routes that ID through `item_pool_queue_id_for_release`; traps when the large free count is empty. | +| `00438294` | `item_pool_discard_small_free_head` | If the small-ID free-list head exists, clears its associated state and routes the ID through `item_pool_queue_id_for_release`. | +| `004384c0` | `item_resource_streams_initialize` | Initializes the global item-resource stream object, allocates a companion object/buffer, opens the stream through a virtual method, and stores the context at `DAT_00482b10`; resource format remains unknown. | +| `00438594` | `item_resource_streams_release` | Clears `DAT_00482b10`, releases the global stream object when present, and frees its companion allocation. | +| `00438630` | `shape_record_get_flag_0x10_or_default_one` | Reads the shape's six-byte profile record: when byte 0 bit 0 is set, returns its bit 4; otherwise returns 1. The profile field's meaning is unresolved. | +| `0043867c` | `shape_record_first_byte_has_flag_1` | Tests bit 0 of byte 0 in the shape's six-byte profile record. | +| `00438698` | `item_shape_event_selector_40_check_state` | Checks shape-profile and global gates, then evaluates item flag `0x100` and a per-item auxiliary byte; called by `item_try_start_event_selector_40`. | +| `00438734` | `item_apply_shape_event_selector_40` | Applies selector-`0x40` shape-profile behavior: updates item flags and profile-driven state/render bytes, and may replace or remove the item. Profile byte semantics remain unresolved. | +| `00438fc0` | `search_selector_scan_exact_shape` | Advances the spatial selector until an item with the exact requested shape has X/Y inside the stored inclusive rectangle, or the grid scan is exhausted. Called by both spatial-query and shape-footprint selector paths. | +| `004390a0` | `search_selector_scan_family` | Advances the selector until an item's shape-record family field matches the requested value and its X/Y lies inside the inclusive rectangle. | +| `00439188` | `search_selector_scan_shape_set` | Advances the selector until an item's shape ID matches one of the supplied IDs and its X/Y lies inside the inclusive rectangle. | +| `00439284` | `search_selector_scan_two_shapes` | Advances the selector until an item's shape ID matches either requested shape and its X/Y lies inside the inclusive rectangle. | + +All 20 entries are listed in the main address table, with 16 new Ghidra names; four selector names were already descriptive. Names were read back after the two misleading labels were corrected, and representative comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Selector Iteration and Process Helpers + +This batch completes the next 20 report-listed entries after the shape-specific selector scans. It covers selector initialization/iteration and footprint contact, then reaches joystick process methods and paired auxiliary tables used by the process kernel. The auxiliary-table payload semantics remain unresolved. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043935c` | `search_selector_scan_bounds_only` | Advances the spatial selector across grid cells and linked items until an item's X/Y is inside the stored inclusive rectangle, or the scan ends. | +| `00439520` | `search_selector_next_linked_item_match` | Advances through a linked-item chain until the expression matcher accepts a candidate or the chain ends. | +| `00439560` | `search_selector_expression_matches_candidate` | Evaluates the selector expression against the current candidate; shared by spatial, footprint, linked-item, and usecode selector paths. | +| `00439b6c` | `search_selector_init_bounds_and_mode` | Clamps and stores bounds, initializes grid cursors, recognizes query-mode tokens, and finds an initial expression-matching candidate. Called by attack and usecode paths. | +| `00439f4c` | `search_selector_next_spatial_match` | Advances through cell chains and dispatches scanning by query mode: exact shape, family, set, two shapes, or bounds-only. | +| `0043a288` | `search_selector_next_map_cell_match_variant` | Traverses linked/nested item relations while advancing map cells, then checks the selector callback and expression predicate. | +| `0043a454` | `search_selector_set_candidate_from_reference` | Resolves a candidate from the supplied reference/state, stores it in the selector cursor, evaluates the expression, and calls the selector callback on rejection. Used by item snapshots and usecode. | +| `0043a4bc` | `search_selector_set_candidate_with_bound` | Stores the supplied selector bound/state word, resolves a candidate from the reference, and checks its expression before invoking the callback. Called by usecode. | +| `0043a528` | `search_selector_next_coordinate_keyed_match` | Traverses linked or nested item relations, advances candidate state, and returns when the expression matcher accepts an item. | +| `0043a5c0` | `search_selector_init_shape_footprint_query` | Initializes a footprint query from an item, recording position, top-Z, query flags, and dimensions derived from its shape record before setting bounds. | +| `0043a6ec` | `search_selector_init_shape_footprint_bounds` | Initializes clamped grid bounds and query mode for a footprint search, then looks for an initial expression-matching candidate. | +| `0043ac78` | `search_selector_match_shape_footprint_contact` | Tests candidate footprint position and Z constraints, storing contact state 0, 1, or 2 in the selector record. | +| `0043ae30` | `search_selector_next_shape_footprint_match` | Dispatches footprint scanning by query mode and repeats shape/cell scans until a candidate passes the contact test. | +| `0043becc` | `joystick_process_clear_active_state` | Called from `JoystickProcess_Run`; invokes virtual method `+0x28` for active state, then clears process byte `+0x34` and word `+0x3b`. | +| `0043bf58` | `joystick_process_create_singleton` | Initializes a process with the joystick vtable and type `0x262`, sets its fields, and stores the singleton at `DAT_00482b68`. | +| `0043bf6c` | `joystick_poll_button_state` | Calls `joyGetPosEx` for joystick 0 and returns the button-state word; disables the joystick-enabled global on failure. | +| `0043c770` | `kernel_process_aux_table_maintenance_tick` | On timer expiry, scans for the last populated entry and may shrink the paired auxiliary tables; otherwise resets the timer. Called by the process-manager update. | +| `0043c844` | `kernel_process_aux_tables_resize` | Resizes both auxiliary tables, copies the retained dword/word entries, updates global pointers, and resets the maintenance timer. | +| `0043c8fc` | `kernel_process_aux_tables_grow` | Grows both auxiliary tables by 30 entries, zeroes the new slots, updates global count/pointers, and frees the old allocations. Called during process-table insertion. | +| `0043ca28` | `Kernel_GetNumProcesses` | Counts process-table entries matching the requested item ID and process type, excluding entries with process flag bit 3 set. | + +All 20 entries are listed at exact function-entry addresses; eight generated names were replaced with operation-level names. Names were read back, and representative selector/timer comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Process Notifications and Runtime Transitions + +This batch continues through process-table access and notification, then covers a phase-3 record ring, intrusive-list/resource helpers, and mode-driven runtime transition routines. The purpose of the final rectangle lookup remains uncertain, so it is described only as a preset-coordinate table. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043ca98` | `kernel_process_count_for_item_and_type` | Counts populated process-table entries matching the current item ID and requested process type; type `0x0c` is a wildcard and entries with flag bit 3 are excluded. Called by `item_action_process_dispatch`. | +| `0043cc44` | `kernel_process_get_by_id` | Returns a populated process pointer for a nonzero in-range ID, otherwise null. Used by process and item operations. | +| `0043cc6c` | `kernel_process_notify_item_processes` | Thin forwarding wrapper around `kernel_process_notify_matching`; callers include item removal, usecode dispatch, and process construction. | +| `0043cd20` | `kernel_process_notify_matching` | Guards against recursion, scans eligible processes matching an item ID and optional process type, and invokes virtual method `+0x0c`; then clears queued notification flags. | +| `0043ced4` | `kernel_process_notify_selected_types` | Filters eligible processes by item ID and a zero-terminated list of up to ten process types, invokes virtual method `+0x0c`, and clears queued notification flags. | +| `0043d39c` | `Kernel_Implies` | Usecode-facing helper with this existing symbol. On nonzero inputs it calls `00446bc8`, checks the selected process slot, and conditionally calls `004586a0` and `00458608`; higher-level script meaning remains unresolved. | +| `0043efdc` | `process_timer_setup_noop_callback` | Empty callback invoked by the timer/process setup routine after timing fields are initialized. | +| `00440340` | `memory_zero_fill` | Calls the byte-fill utility with a zero value; destination and size arrive through the caller's register convention. Used while resetting input/event state. | +| `00440510` | `empty_callback_stub` | Empty function body with no observed callers. | +| `004412c0` | `dispatcher_phase3_enqueue_record` | Appends a 12-byte record to a ten-entry phase-3 ring buffer, advances/wraps the write index, and refuses enqueue when full. | +| `00441314` | `dispatcher_phase3_dequeue_record` | Reads the next 12-byte phase-3 record, advances/wraps the read index, and decrements the queued count. | +| `004413b0` | `resource_container_cleanup` | Releases container/resource allocations according to flag bits or installs the default vtable on the reset path. Exact container type is unresolved. | +| `004413e0` | `intrusive_list_append` | Appends a non-null node to the tail, initializes the head when empty, and clears the node's next link. | +| `00441400` | `intrusive_list_move_node_to_tail` | Removes a non-null node from its current list, then appends it to the destination list. | +| `00441430` | `intrusive_list_remove_node` | Unlinks the supplied node, searching for its predecessor when needed and updating the head/tail endpoints. | +| `00441484` | `intrusive_list_destroy_nodes` | Calls each node's cleanup function while walking the list, then clears both endpoints. | +| `004414c0` | `game_runtime_transition_apply_mode` | Applies mode 0-6 branches coordinating event-loop waits, palette changes, static-overlay work, input reset, and process notifications. Called by `game_runtime_transition_dispatch`. | +| `00441e84` | `game_runtime_transition_process_state` | Dispatches transition behavior by mode and routes mode 3 through the dedicated setup helper. | +| `004423e4` | `game_runtime_transition_mode3_setup` | Mode-3 helper called by `game_runtime_transition_process_state`; it performs transition-related resource/process work whose individual state fields remain unidentified. | +| `00443f24` | `ui_get_preset_rect_by_id` | Returns four 16-bit preset coordinates for selectors 0-7 and a zero rectangle otherwise; the owning UI component is not established. | + +All 20 entries are listed at exact function-entry addresses; 19 generated names were replaced with operation-level names, and the existing `Kernel_Implies` name was retained. Names were read back, and representative process-notification, ring-buffer, and rectangle comments were confirmed in pseudocode. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Runtime UI, Palette, and Array Helpers + +This batch follows the mode-3 transition helper and preset rectangle lookup with runtime command handling, DirectDraw/UI support, and process-related array utilities. Names stay at the operation level where resource or state ownership is not established. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00444470` | `input_handle_runtime_key_command` | Switches on runtime command codes and updates associated audio or game state; exact command meanings remain unresolved. | +| `00444650` | `game_runtime_transition_create_overlay` | Called by the runtime transition state handler to create the overlay/state object used by that path. | +| `00444db4` | `ui_create_indexed_resource_control` | Constructs a type-2 control, stores its indexed-resource reference, initializes bounds, and conditionally invokes its update method. | +| `00445150` | `store_u16_output` | Writes the supplied 16-bit value through the implicit output pointer in `EAX`. | +| `00445418` | `directdraw_surface_lock` | Locks the configured DirectDraw surface and records its returned surface data and pitch for drawing. | +| `00445498` | `directdraw_surface_unlock` | Unlocks the configured DirectDraw surface after drawing. | +| `00445520` | `named_resource_release_if_present` | Looks up a named resource and, when present, invokes its release path; shared by process teardown and text-GDI cleanup. | +| `00445648` | `fatal_report_show_message_box` | Displays a fatal-error message box; callers include file/line and resource-error reporting paths. | +| `00445778` | `fatal_report_show_modal_error_and_pump` | Displays a modal error and pumps messages until the interaction completes. | +| `004458c4` | `directdraw_wait_for_vertical_blank` | Calls the DirectDraw surface vtable's `WaitForVerticalBlank` method with the wait flag and a null event. | +| `004458d8` | `directdraw_palette_set_entries` | Imports palette entries into DirectDraw using the game's RGB6 conversion path. | +| `00445948` | `directdraw_palette_get_entries` | Reads DirectDraw palette entries and converts them to the game's RGB6 representation. | +| `004459ac` | `video_transition_noop` | Empty callback with no body operations. | +| `00446030` | `win32_pump_messages_and_callbacks` | Services queued window messages and registered callbacks; routes fatal UI errors through the modal handler. | +| `00446400` | `ui_create_centered_text_panel` | Creates a centered text panel used by Japanese keyboard and option/cheat handling paths. | +| `004467e0` | `usecode_calculate_root_item_motion_steps` | Computes motion step counts and per-axis deltas for the Usecode root-item position query. | +| `00446a04` | `gravity_process_apply_root_item_delta` | Forwards the computed root-item position delta to the gravity-process helper. | +| `00446a40` | `kernel_process_id_filter_initialize` | Copies process IDs through the `0x408` terminator into owned storage and optionally resolves the associated process. | +| `00446b04` | `dynamic_array_release_required` | Requires an allocated array, frees it, then clears its count and pointer fields. | +| `00446b34` | `dynamic_array_release_if_present` | Conditionally frees an allocated array and clears its count and pointer fields. | + +All 20 entries are listed at exact function-entry addresses. Generated names were replaced with operation-level names, while existing descriptive names were retained. Live decompiler readback confirmed the renamed array helpers and representative DirectDraw and process-filter comments. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Process Lists and Shape Collision Queries + +This batch documents the process-ID list helpers and stream support, then follows item shape-state handling into the spatial collision-query routines. Collision result fields and several mode flags remain only partly understood. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00446b78` | `process_id_list_contains_or_append` | Searches the sentinel-terminated process-ID list and appends an ID only when absent; called by process activation/linking paths. | +| `00446bc8` | `process_id_list_append` | Grows the owned list and appends an ID before sentinel `0x408`; used by process-state and Usecode helpers. | +| `00446c88` | `process_state_list_remove_id` | Rebuilds the list without the requested ID and releases storage when no IDs remain. | +| `00446e0c` | `u16_array_get_at` | Bounds-checks an index against the array count and returns that 16-bit element; callers include process callback/listener dispatch. | +| `00446e38` | `u16_array_set_at` | Bounds-checks an index and stores a 16-bit element. | +| `00446e64` | `process_id_list_find_unflagged_match` | Finds the first word whose low 10 bits match the requested ID and whose `0x400` flag is clear; returns the index and full word. | +| `00446f4c` | `u16_array_read_from_stream` | When an array allocation is present, allocates storage from its recorded count and reads the serialized contents from the file stream. | +| `00446fd0` | `buffer_write_to_stream` | Writes the non-null buffer associated with the incoming object to the file stream. | +| `00447070` | `usecode_shape_query_set_mode_and_init` | Sets `DAT_00484bf0` and initializes a full-range spatial selector; the exact mode semantics remain unresolved. | +| `00447170` | `usecode_shape_query_clear_mode_and_init` | Clears `DAT_00484bf0` and initializes the alternate full-range spatial selector mode. | +| `00447270` | `usecode_shape_query_get_mode` | Returns the current `DAT_00484bf0` selector-mode flag. | +| `00447278` | `item_process_shape_and_spawn_associated` | Guards repeated item work, reads render/shape-profile state, and may initialize selectors or create shape-derived items. | +| `00447740` | `collision_query_state_initialize` | Initializes the query's result pointer and state/status fields. | +| `0044775c` | `collision_query_release_linked_results` | Walks and frees the linked collision-result records. | +| `00447784` | `collision_query_release_results_and_reset` | Frees linked collision-result records and clears two associated status bytes. | +| `004477d8` | `item_shape_query_region_flags` | Decodes oriented shape extents and compact flags, queries a region, and reports whether matching flags are absent. | +| `004478ec` | `item_collision_record_append` | Adds a candidate collision record and may update the query's stored candidate point/state. | +| `004479b0` | `item_position_test_candidate_collision` | Tests a neighboring item's shape extents, compact flags, and Z range against the moving item, then records qualifying collision candidates. | +| `00448174` | `item_position_query_shape_collisions` | Initializes a shape-position query, scans nearby spatial items, and tests candidates for collision; callers determine how result flags are interpreted. | +| `00448740` | `item_position_query_collisions_for_item` | Obtains a reference item's outermost position and queries the selected shape at the supplied target coordinates. | + +All 20 entries are listed at exact function-entry addresses, with operation-level names and decompiler comments applied. Live readback confirmed the process-list removal, stream-read, item shape-state, and candidate-collision paths. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Collision Resolution, Mouse Control, and Audio + +The collision-query helpers lead into result processing, followed by the `mousectl.c` controller and a per-voice audio control update. Some cursor-slot fields and the audio control modes remain only partly interpreted. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00448818` | `item_process_collision_contacts_and_events` | Updates item position/event state, evaluates linked contact records and related shapes, then clears and releases query state; used by movement, spatial-condition, and guarded-action paths. | +| `00448b78` | `item_query_shape_collision_from_position` | Obtains an item's outermost position and queries collisions for the requested shape and query flags. | +| `00448bdc` | `item_query_shape_collision_with_step_fallback` | Runs the shape collision query and, for selected flags, retries at nearby vertical offsets to find a step-compatible position. | +| `00448f24` | `item_shape_region_has_collision_flags` | Initializes collision-query state, checks a shape region for matching flags, optionally returns a result word, then releases linked results; called by existing position-query dispatchers. | +| `00448fd0` | `mouse_controller_create` | Constructs the mouse controller, loads pointer-resource data, initializes cursor bounds and buffers, and installs the global controller pointer; source path `mousectl.c` appears in its corruption check. | +| `00449418` | `mouse_controller_destroy` | Releases controller resources; one flag path decrements/frees the shared object, while the other releases owned arrays and optional backing state. | +| `0044946c` | `mouse_controller_set_global_instance` | Forwards the object through its setup helper and stores it as the global mouse-controller instance. | +| `00449a6c` | `mouse_controller_restore_pointer_background` | If the pointer is drawn, clears that state and restores the saved screen rectangle beneath it. | +| `00449ac0` | `mouse_controller_draw_pointer` | Selects the current pointer image from the loaded resource, updates its bounds, redraws the saved screen area, and marks the pointer as drawn. | +| `00449bf8` | `mouse_controller_set_cursor_slot_value` | Stores the supplied value in the current cursor slot, refreshes pointer bounds, and redraws the pointer when it was already visible. | +| `00449d78` | `mouse_controller_advance_cursor_slot` | Advances a cursor-cycle counter, stores the supplied value in the current slot, and refreshes the selected pointer state. | +| `00449eb0` | `mouse_controller_reset_cursor_cycle` | Resets the cursor-cycle counter, stores the supplied value in the current slot, and refreshes pointer bounds and visibility. | +| `00449fd4` | `mouse_controller_retreat_cursor_cycle` | Retreats the cursor-cycle counter, updates the selected slot and pointer state, and returns the value previously stored in the slot. | +| `0044a1dc` | `mouse_controller_dequeue_event_record` | Retrieves the next 16-byte event record, using a pending single record when present or dequeuing from the ring buffer otherwise. | +| `0044a24c` | `mouse_controller_redraw_pointer_at_position` | When the pointer is drawn, refreshes its selected resource image and redraws it at the current controller position. | +| `0044a34c` | `mouse_controller_redraw_pointer_and_restore_background` | Restores the old pointer rectangle, redraws the pointer at its current position, and clears the refresh-pending flag. | +| `0044a3f4` | `mouse_resource_get_header_word_at_offset_4` | Returns the 16-bit header value stored at offset 4 in the loaded mouse resource. | +| `0044a400` | `mouse_controller_set_cursor_position` | Calls `SetCursorPos`, updates controller position and bounds, queues a position-change record when needed, and redraws the pointer if visible. | +| `0044a53c` | `mouse_controller_clear_active_input_flag` | Clears bit `0x40` in the active mouse-controller flags when a global controller is installed. | +| `0044a798` | `audio_voice_process_control_step` | Called for active voices from the audio update loop; processes a packed control mode that adjusts timing/rate or position fields, after which the caller clamps a secondary counter. | + +All 20 entries are listed at exact function-entry addresses, with operation-level names and decompiler comments applied. Readback confirmed collision-result processing, mouse-controller initialization and drawing, event dequeue, and the audio control-step behavior. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: AMF Audio Engine + +This nine-entry pass documents the audio command, mixing, device-output, and music-resource paths. The observed resource signature is `ASYLUM`; detailed meanings of individual packed control modes remain incomplete. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0044ab2c` | `audio_voice_apply_amf_command` | Decodes an AMF control word, initializes or updates the selected voice from its instrument record, and applies mode-specific sample, rate, timing, and volume parameters. | +| `0044af58` | `audio_mix_active_voices` | Mixes active voices into stereo accumulation buffers using sample and lookup tables, advances sample positions, and disables voices that reach their end. | +| `0044b0a0` | `audio_submit_mixed_buffer` | Clamps accumulated samples to signed 16-bit values, submits the output buffer through the device interface, and advances the ring offset when the device is ready. | +| `0044b168` | `audio_engine_update_tick` | Consumes queued AMF control words, updates active voices, clears the accumulation buffer, mixes voices, and submits the result to the audio device. | +| `0044b348` | `audio_load_amf_music_resource` | Loads and validates an `ASYLUM`/AMF resource, reads instrument records and sample data, converts sample bytes to signed values, and fixes sample lengths. | +| `0044b574` | `audio_push_track_and_play` | Pushes the current track onto a bounded stack and loads the requested AMF track when audio is active; runtime-transition and overlay-startup paths call it. | +| `0044b6ec` | `audio_pop_track_and_play_previous` | Pops and reloads the prior AMF track when audio is active; called by overlay shutdown. | +| `0044b854` | `audio_reset_track_stack_and_load_zero` | Clears the track stack and reloads track zero as the default AMF resource when audio is active. | +| `0044b980` | `audio_request_driver_sync` | Sets the pending synchronization flag while audio is active and invokes the device callback when its driver-ready bit is set. | + +All nine entries are listed at exact function-entry addresses, with operation-level names and decompiler comments applied. Live readback confirmed the AMF command decoder, voice mixer, engine tick, resource loader, track push, and driver-sync paths. This reaches the 747-entry milestone; no executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Audio Lifecycle and Resource Lists + +This batch closes out the audio-engine setup, track switching, and teardown paths, then documents dispatcher record predicates and resource-backed intrusive-list objects. Several record fields are still described only by their observed values and operations. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0044ba18` | `audio_resume_engine_with_timing` | Clears the pending audio-control flag and, when active, signals the device or applies a scaled timing value before resuming playback; called from window-message paths. | +| `0044bab0` | `audio_stop_engine_and_wait` | Stops the active device callback, waits for the audio worker thread, releases temporary buffers, and clears current-track state; used by runtime transitions and overlay lifecycle. | +| `0044bb5c` | `audio_start_engine` | Initializes voice levels and device buffers, configures audio output, starts the worker thread, and enables playback. | +| `0044bd2c` | `audio_select_and_play_track` | Loads the requested AMF track and records it as current when audio is active; called by Usecode dispatch. | +| `0044be78` | `audio_reload_current_track` | Invokes the owning object's callback twice, then reloads the current AMF track when the audio engine is active; used by savegame-load reconstruction. | +| `0044c034` | `audio_set_engine_timing_value` | Stores the engine timing value and updates the active device; zero or a pending-control flag takes the device notification path. | +| `0044c0b8` | `audio_get_engine_timing_value` | Returns the current audio-engine timing value. | +| `0044c0c0` | `audio_engine_initialize` | Builds audio lookup tables, initializes the device interface and format, then sets the engine-active flag on success. | +| `0044c28c` | `audio_engine_shutdown` | Stops and joins the audio worker, releases the device interface, and clears engine-active and current-track state. | +| `0044c448` | `dispatcher_record_initialize_fields` | Copies supplied words and register values into fixed fields of a dispatcher record; called by pending-transition and playback-record initialization paths. | +| `0044c474` | `dispatcher_record_is_type_1` | Tests whether the record's 16-bit type field equals 1. | +| `0044c484` | `dispatcher_record_is_type_2` | Tests whether the record's 16-bit type field equals 2. | +| `0044c494` | `dispatcher_record_is_type_3` | Tests whether the record's 16-bit type field equals 3. | +| `0044c4a4` | `resource_object_initialize` | Initializes a resource object's base fields and installs its vtable; used by linked-record construction. | +| `0044c4c0` | `resource_object_destroy` | Clears and destroys both owned intrusive lists, restores the base vtable, and releases the object when requested. | +| `0044c50c` | `resource_list_append` | Forwards the supplied node to the intrusive-list tail-insertion helper. | +| `0044c51c` | `intrusive_list_find_and_move_to_tail` | Traverses the supplied intrusive list until the cursor wraps, then moves the selected node to the list tail. | +| `0044c588` | `intrusive_list_find_by_tag_byte` | Walks an intrusive list and returns the first node whose tag byte matches the requested value. | +| `0044c5bc` | `resource_linked_record_create` | Initializes a resource-linked record and flags, constructs its nested resource object, and appends it to the owner list when present. | +| `0044c654` | `resource_object_release` | Clears the global current pointer if needed, frees auxiliary storage and owned lists, releases the object, and updates the shared count. | + +All 20 entries are listed at exact function-entry addresses, with operation-level names and decompiler comments applied. Live readback confirmed audio startup, lookup-table/device initialization, list traversal, linked-record construction, and resource-object release. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Gump Rendering and Dispatcher State + +This pass covers counted resource allocation, nested gump rendering and hit-testing, coordinate conversion, dispatcher context and event-ring helpers, and process cleanup. Packed object-state fields and several process flag meanings remain provisional. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0044c6d4` | `tracked_resource_allocate` | Allocates a tracked resource block, reports allocation failure, and increments current and high-water allocation counters; called by runtime transitions and event-context creation. | +| `0044c730` | `tracked_resource_release` | Releases a tracked resource block and decrements the shared allocation count; used by object/resource cleanup paths. | +| `0044c75c` | `tracked_object_extend_state_flags` | Updates the packed word at offset `0x2d`: preserves low-bit states 1 or 3, initializes zero to 3, otherwise shifts left two and sets the low bits. | +| `0044c798` | `gump_render_tree_recursive` | Invokes the gump draw callback when enabled, registers its intersecting screen rectangle, and recursively processes linked children with adjusted coordinates. | +| `0044c978` | `gump_render_tree` | Accumulates parent offsets, invokes recursive rendering, and optionally calls the active display callback; used by pending-state transitions and the dispatcher loop. | +| `0044cb44` | `gump_hit_test_tree` | Tests a gump and linked ancestors/children against event data and flags, returning a matching gump through an output pointer; source diagnostics identify `newgump.c`. | +| `0044cd3c` | `object_update_display_state_from_word` | Passes the high 16 bits of the supplied word to the object's display-state update helper. | +| `0044cd54` | `object_merge_state_bits` | Initializes the packed state word at offset `0x2d` or shifts its existing value and merges supplied state bits. | +| `0044cd80` | `gump_get_absolute_x` | Recursively sums the gump's X offset with each parent offset. | +| `0044cda0` | `gump_get_absolute_y` | Recursively sums the gump's Y offset with each parent offset. | +| `0044cdc0` | `gump_coordinate_to_local_x` | Converts a supplied X coordinate to the object's local coordinate by subtracting its stored X offset. | +| `0044cdd0` | `gump_coordinate_to_local_y` | Converts a supplied Y coordinate to the object's local coordinate by subtracting its stored Y offset. | +| `0044cff8` | `gump_set_allowed_shape_ids` | Replaces a zero-terminated 16-bit shape-ID filter and toggles the corresponding filter-present flag; called by runtime, text-entry, and modal-dialog setup. | +| `0044d130` | `gump_draw_content_and_invalidate` | Builds a display rectangle from position and parent offsets, invokes the display callback, and adds the intersecting screen region. | +| `0044d3c8` | `dispatcher_set_active_context_pointer` | Stores a supplied context pointer, defaulting to the current object when the argument is zero, and returns the shared context value. | +| `0044d3d8` | `dispatcher_clear_active_context_pointer` | Clears the shared context pointer and returns the shared context value. | +| `0044d3e4` | `dispatcher_event_queue_enqueue_record` | Validates required record fields and copies six words into the next slot of a 25-entry dispatcher ring. | +| `0044d614` | `new_gump_validate_id_complement` | Checks the NewGump ID complement invariant and reports a `Bad NewGumpId` error on mismatch. | +| `0044d720` | `process_terminate_related_children` | Walks a process ID list, applies flag-selected operations to related processes, and updates owner/state fields; called by `Process_Terminate`. | +| `0044d910` | `runtime_initialize_default_item_shape_entries` | Allocates a shared initialization block and sets default entries in item-shape, flag, Z, and related lookup tables. | + +All 20 entries are listed at exact function-entry addresses, with operation-level names and decompiler comments applied. Live readback confirmed recursive gump rendering, hit-testing, shape-ID filtering, dispatcher event-ring insertion, and process termination handling. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Shape-State and Per-Item Records + +This pass documents the runtime shape-state buffer and per-item record accessors used by input, item-state, process, and Usecode paths. Predicate names retain the exact tested record fields and values where their higher-level semantics are not established. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0044d984` | `runtime_shape_table_buffer_release` | Frees the allocated runtime shape-table buffer and clears its global pointer; called during runtime transitions. | +| `0044d9c0` | `object_invoke_vtable_method_0c_with_zero` | Invokes the object's virtual method at vtable offset `0x0c` with argument zero; used during savegame-load reconstruction. | +| `0044d9e0` | `process_has_item_type_minus_16` | Forwards the process context to the item-type-presence query with selector `-0x10`; called by Surrender, Pace, Guard, and Loiter process handlers. | +| `0044d9f8` | `item_marker_is_left_parenthesis` | Looks up the byte associated with the supplied item ID and tests whether it equals `'('`; used by item-state and input paths. | +| `0044da18` | `shape_state_load_record_and_spawn_item` | Copies a `0x8e`-byte shape-state record, optionally creates an item from its shape metadata, updates a selected per-item slot, and stores three record words. | +| `0044f264` | `item_update_state_cache_on_mode_change` | When the item's state mode differs from the requested mode, conditionally dispatches matching process exclusions and stores the resulting state in its per-item record. | +| `0044f33c` | `item_record_get_field_59_flag_1` | Returns bit 1 of the per-item byte at offset `0x59`; called from Usecode dispatch. | +| `0044f364` | `item_record_get_field_59_flag_3` | Returns bit 3 of the per-item byte at offset `0x59`; used by runtime-mode and viewport/item paths. | +| `0044f38c` | `item_shape_code_0d_is_not_probe_excluded` | Returns true when the per-item word at offset `0x0d` is not 0, 1, `0x0b`, `0x10`, or `0x3a`; called during item probe-position processing. | +| `0044f3cc` | `item_shape_code_0d_is_1c_or_1d` | Returns true when the per-item word at offset `0x0d` equals `0x1c` or `0x1d`; called from gameplay input handling. | +| `0044f3fc` | `item_record_value_within_200_of_field_69` | Obtains a per-item value and tests it against the record's offset-`0x69` value plus 200; used by an attack-process fallback. | +| `0044f440` | `item_record_flag_1_or_invalid_id` | For a valid item ID, returns bit 0 of the per-item word at offset `0x13`; returns true for an invalid ID. | +| `0044f474` | `item_set_flag_8000_and_mark_record` | Sets the item's `0x8000` flag through its helper and sets bit 0 of the per-item byte at offset `0x13`; used by state and Usecode dispatch. | +| `0044f49c` | `item_clear_flag_8000_and_clear_record_mark` | Clears the item's `0x8000` flag through its helper and clears bit 0 of the per-item byte at offset `0x13`; used by the Japanese option-cheat handler. | +| `0044f4c4` | `item_record_clear_field_59_flag_0` | Clears bit 0 of the per-item byte at offset `0x59`; called during item removal. | +| `0044f4e4` | `item_record_get_field_13_high_bit` | Returns bit 15 of the per-item word at offset `0x13`; used by item-state and cheat paths. | +| `0044f50c` | `item_record_set_field_13_flag_1` | Sets bit 1 of the per-item byte at offset `0x13`; called by input-cheat and Usecode paths. | +| `0044f52c` | `item_record_clear_field_13_flag_1` | Clears bit 1 of the per-item byte at offset `0x13`; called by input-cheat and Usecode paths. | +| `0044f54c` | `item_shape_code_0d_is_03_30_31_or_38` | Returns true when the per-item word at offset `0x0d` equals 3, `0x30`, `0x31`, or `0x38`; called during gameplay input handling. | +| `0044f588` | `shape_record_code_0d_is_excluded` | Returns true when the per-item word at offset `0x0d` equals `0x22`, `0x23`, or `0x26`; called from gameplay input handling. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed shape-state record loading, state-cache updates, the `0x8000` item flag path, and the shape-code exclusion predicate. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Pool, Shape Slots, and Record Fields + +This pass documents item-slot allocation and recycling, shape spawning, the 30-entry per-item shape-state list, and record-field accessors. The meaning of several packed marker bits remains expressed by their exact field offsets. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0044f5c0` | `item_record_get_field_13_flag_2` | Returns bit 2 of the per-item word at offset `0x13`; used by position, cache, probe, and input paths. | +| `0044f6a0` | `item_record_get_field_59_flag_5` | Returns bit 5 of the per-item byte at offset `0x59`. | +| `0044f6c8` | `item_record_set_field_59_flag_5` | Sets bit 5 of the per-item byte at offset `0x59`. | +| `0044f6e8` | `item_record_clear_field_59_flag_5` | Clears bit 5 of the per-item byte at offset `0x59`; called during pre-termination updates. | +| `0044f72c` | `item_allocate_slot_with_eviction` | Allocates from the small free pool or scans for an eligible item to remove and recycle, then initializes the requested shape and per-item state. | +| `0044fa54` | `item_spawn_shape_with_metadata` | Creates or recycles an item, restores its render state and catalog metadata, and sets an additional record flag for shapes `0x597` and `0x3ac`; called by item and Usecode spawn paths. | +| `0044fb38` | `item_spawn_shape_with_saved_state` | Creates or recycles an item, restores render state and catalog metadata, then loads its saved shape-state record; called by Usecode dispatch. | +| `0044fc98` | `item_record_get_shape_slot` | Returns the 16-bit value at per-item record offset `0x1b` plus twice the slot index. | +| `0044fcc0` | `item_shape_state_assign_linked_item` | Assigns an item ID to a shape-state slot, applies shape-flag-dependent cleanup or related-item updates, then sets the slot, Z value, and item flag. | +| `0044fe24` | `item_record_clear_shape_slot` | Clears the selected 16-bit slot at offset `0x1b` plus twice the supplied index. | +| `0044fe50` | `item_record_remove_shape_slot_references` | Scans the first 30 slots and clears every entry equal to the supplied item ID; called when an item ID is queued for release. | +| `0044fe94` | `item_record_clear_all_shape_slots` | Clears all 30 16-bit shape slots beginning at offset `0x1b`; called during item-grid mode rebuild. | +| `0044fed4` | `item_update_position_and_marker` | Updates item X/Y/Z and marker state, performs item/map cache updates, and handles pool transitions when the marker matches a global value. | +| `0044ffe4` | `item_record_find_empty_slot_01_05` | Returns the first empty slot index from 1 through 5, or zero if all five are occupied. | +| `00450030` | `item_record_find_empty_slot_06_10` | Returns the first empty slot index from 6 through 10, or zero if all five are occupied. | +| `0045007c` | `item_record_find_empty_slot_11_25` | Returns the first empty slot index from 11 through 25, or zero if all 15 are occupied. | +| `004500c8` | `item_get_marker_byte` | Returns the marker byte stored in the global per-item byte array. | +| `004500dc` | `item_record_set_field_06` | Stores a 16-bit value at offset `0x06` in the item's `0x79`-byte record. | +| `00450100` | `item_record_set_field_08` | Stores a 16-bit value at offset `0x08` in the item's `0x79`-byte record. | +| `00450124` | `item_record_set_field_0a` | Stores a 16-bit value at offset `0x0a` in the item's `0x79`-byte record. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed item-slot recycling, metadata-bearing shape spawning, linked-item assignment, marker/position updates, and slot lookup. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Action Modes and Related Slots + +This pass covers per-item record fields, action-mode dispatch, process updates, and selected linked-item slots used by the action and position-query paths. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00450148` | `item_record_set_field_12` | Stores the supplied byte at offset `0x12` in the item's `0x79`-byte record; called during shape-profile spawning. | +| `00450168` | `item_record_get_field_06` | Returns the 16-bit value at offset `0x06` in the item record. | +| `00450188` | `item_record_get_field_08` | Returns the 16-bit value at offset `0x08` in the item record. | +| `004501a8` | `item_record_get_field_0a` | Returns the 16-bit value at offset `0x0a` in the item record. | +| `004501c8` | `item_record_replace_field_02_save_previous` | Copies the current field at offset `0x02` to offset `0x04`, then stores the supplied value at offset `0x02`; called by an attack-process fallback. | +| `0045023c` | `item_set_action_mode_and_dispatch_process` | Updates item action-mode fields, dispatches process notifications, and ensures the selected Stand, Loiter, Pace, Guard, Surrender, or Attack process when the mode changes. | +| `00450684` | `item_action_mode_matches_current` | Resolves selectors `0x70`–`0x72` through record fields `0x06`, `0x08`, and `0x0a`, then compares with field `0x02`. | +| `00450714` | `item_release_shape_slot_selector_resource` | Selects one of two item-record slot indices, resolves a linked item, reads its catalog field, and releases the associated selector resource when present. | +| `004507bc` | `item_record_set_field_59_flag_3` | Sets bit 3 of the per-item byte at offset `0x59`; called by probe-position processing. | +| `004507f0` | `item_clear_state_flag_and_update_process` | Clears bit 3 of the state byte, then conditionally updates or dispatches the associated item process based on runtime mode and item flags. | +| `004508a4` | `item_repeat_action_for_direction_delta` | Forwards a direction delta to the item-action repeat helper; called by Surrender and Usecode paths. | +| `004508d8` | `item_record_get_field_00` | Returns the 16-bit value at offset `0x00` in the item record. | +| `004508f8` | `item_record_get_field_02` | Returns the 16-bit value at offset `0x02` in the item record. | +| `00450918` | `item_record_get_field_15` | Returns the 16-bit selector at offset `0x15` in the item record. | +| `00450938` | `item_record_get_field_19` | Returns the 16-bit selector at offset `0x19` in the item record. | +| `00450958` | `item_get_shape_catalog_field_02` | Returns `0x96` for item ID 1; otherwise resolves the shape's catalog record and returns its field at offset `0x02`. | +| `004509a0` | `item_get_related_item_from_slot_15` | Uses the selector at offset `0x15` to return the corresponding linked item ID from the 30-entry slot array, or zero when unset. | +| `004509d8` | `item_get_related_item_from_slot_17` | Uses the selector at offset `0x17` to return the corresponding linked item ID from the 30-entry slot array, or zero when unset. | +| `00450a10` | `item_get_related_item_from_slot_19` | Uses the selector at offset `0x19` to return the corresponding linked item ID from the 30-entry slot array, or zero when unset. | +| `00450a48` | `item_record_get_field_57` | Returns the 16-bit value at offset `0x57` in the item record. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed action-mode process dispatch, mode matching, selector-resource release, state-flag updates, and linked-item lookup. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Option Values and Runtime Item State + +This pass covers an item-1 option-value mapping, additional per-item record fields and packed data, selector-triggered refreshes, and a global runtime action-state value. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00450a68` | `item_record_set_field_57` | Stores a 16-bit value at per-item offset `0x57`; used by the option-cheat value helper. | +| `00450a9c` | `item1_value_from_option_selector` | For item ID 1, maps global selector values 1, 2, and 3 to 2500, 5000, and 10000; process `0x254` setup and Usecode are callers. | +| `00450ae8` | `item_set_option_cheat_value_or_create_process` | The Japanese option-cheat input path updates field `0x57` for item 1 when the selector argument is zero; otherwise it creates process `0x254` variant B. | +| `00450b54` | `item_record_get_field_66` | Returns the 16-bit value at per-item offset `0x66`; used by position-state dispatch. | +| `00450b74` | `item_record_set_field_66_and_refresh` | Stores a 16-bit value at offset `0x66` and invokes the shared refresh routine. | +| `00450ba0` | `item_get_option_selector` | Returns the global selector used by the item-1 special-value mapping. | +| `00450bb8` | `item_set_option_selector_and_item1_value` | Stores the global selector and updates item 1's field `0x57` using the corresponding mapped value. | +| `00450c14` | `item_record_set_field_00` | Stores a 16-bit value at per-item offset `0x00`. | +| `00450c34` | `item_record_get_field_5c` | Returns the 16-bit value at per-item offset `0x5c`. | +| `00450c54` | `item_record_set_field_5c` | Stores a 16-bit value at per-item offset `0x5c`. | +| `00450c78` | `item_record_set_packed_field_5e` | Copies five bytes from the input buffer to per-item offset `0x5e`; called during shape-profile spawning. | +| `00450ca8` | `item_record_copy_packed_field_5e` | Copies five bytes from per-item offset `0x5e` into the caller's output buffer. | +| `00450cec` | `item_record_set_field_15_and_refresh` | Stores a selector at per-item offset `0x15` and invokes the shared refresh routine; called by shape spawning and option handling. | +| `00450d14` | `item_record_set_field_19` | Stores a 16-bit selector at per-item offset `0x19`. | +| `00450d38` | `item_get_runtime_action_state` | Returns the global runtime action-state value. | +| `00450d40` | `item_set_runtime_action_state_and_refresh` | Stores the supplied global state; if the selected item's state and eligibility checks pass, temporarily enables an update guard and refreshes process state. | +| `00450db4` | `item_set_runtime_action_state_one_and_refresh` | Sets the global state to 1 and conditionally refreshes the selected item's process state under the same eligibility checks. | +| `00450e28` | `item_clear_runtime_action_state` | Clears the global runtime action-state value. | +| `00450e34` | `item_record_set_field_0c` | Stores a byte at per-item offset `0x0c`; callers include shape spawning, probe-position processing, and direction-code handling. | +| `00450e54` | `item_record_get_field_0c` | Returns the byte at per-item offset `0x0c`; called by viewport and item-shape position updates. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed the option-cheat selector mapping, packed-field copy, runtime-state refresh guard, and field `0x0c` accessor. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Item Values and Linked-Item Interaction + +This pass follows the option-value helpers into shape-linked item lookup, keyboard interaction state, and a global per-slot bitset. Two routines search for the special shape ID `0x4ed`; the longer interaction transition remains only partly interpreted. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00450e74` | `shape_record_get_code_0d` | Returns the 16-bit per-item record field at offset `0x0d`. | +| `00450e94` | `item_adjust_count_toward_shape_limit` | Adjusts field `0x00` by a signed delta, clamping to the shape catalog's field `0x02` or to `0x96` for item ID 1; called from Usecode. | +| `00450f48` | `item_adjust_field_57_toward_option_limit` | Adjusts field `0x57` by a signed delta, clamped between zero and the selector-derived item-1 limit; refreshes shared state when changed. | +| `00451010` | `item_get_shape_04ed_class_10_state` | Searches the 30-entry item-slot array for shape `0x4ed` and returns that item's shape-class-10 state, or zero if absent. | +| `0045107c` | `item_reset_runtime_and_option_fields` | Resets several selected-item fields, sets field `0x00` to `0x96`, clears the global bitset and item flags, and resets render state; called by runtime-transition dispatch. | +| `0045111c` | `startup_get_u_override_constant_6a` | Returns constant `0x6a`; called by startup handling for a U-key override. | +| `00451124` | `item_get_global_option_value_d7` | Returns the global 16-bit value at `DAT_004955d7`; exact meaning is unresolved. | +| `0045112c` | `object_call_virtual_0c_then_refresh` | Invokes the object's virtual function at vtable offset `0x0c` with argument zero, then calls the shared refresh helper. | +| `00451180` | `item_find_slot_by_shape_id` | Searches the 30-entry item-slot array for a matching shape ID and returns its item ID, or zero. | +| `004511d0` | `item_find_related_catalog_shape_slot` | Resolves the selected item's slot-`0x15` linked item, obtains its catalog related-item shape, and searches the slot array for a matching item. | +| `00451288` | `item_get_related_state_or_option_ratio` | Returns linked-item state metadata when present; otherwise computes item-1 field `0x57` divided by the linked shape's catalog byte at offset `0x0a`, using one when that divisor is zero. | +| `0045135c` | `item_apply_related_state_or_decrease_option_value` | Applies linked-item state/event metadata or decreases item-1 field `0x57` by the linked shape's catalog byte `0x0a`, clamped at zero; refreshes shared state. | +| `004514b4` | `item_related_shape_position_flag_test` | Checks for a slot-`0x15` linked item and its shape catalog byte at offset `0x0c`; returns true when no linked item is set. Used by target-position and attack paths. | +| `00451510` | `item_process_interaction_with_linked_item` | Keyboard-interaction path that applies linked-item catalog state/event changes or item-1 option-value adjustments, and may clean up related items. Detailed transition semantics remain partly unresolved. | +| `00451800` | `item_test_global_slot_bit` | Tests the bit indexed by `AL` in the global bitset at `DAT_004955d9`; called from Usecode. | +| `0045181c` | `item_set_global_slot_bit` | Sets the bit indexed by `AL` in the global bitset at `DAT_004955d9`. | +| `00451860` | `item_clear_global_slot_bits` | Clears the global bitset at `DAT_004955d9`. | +| `00451888` | `item_get_shape_04ed_class_10_state_variant` | Second scan for shape `0x4ed` that returns its shape-class-10 state, or zero if absent. | +| `004518f4` | `item_update_shape_04ed_class_10_state` | Finds shape `0x4ed` in the 30-entry item-slot array and updates its shape-class-10 state. | +| `00451960` | `item_record_get_field_63_byte` | Returns the byte at per-item offset `0x63`; callers include attack and Usecode paths. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed item-value clamping, shape-`0x4ed` slot searches, the global bitset operations, and the linked-item interaction path. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Palette and AVI Playback + +This sparse report slice finishes a few item-record helpers, then documents direction-process construction, palette transforms, run-length frame rendering, and AVI container/audio/video playback. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00451980` | `item_record_set_field_63_byte` | Stores a byte at offset `0x63` in the per-item record; called by shape spawning and Usecode. | +| `004519a0` | `item_record_get_field_04` | Returns the 16-bit value at offset `0x04` in the per-item record. | +| `00453500` | `process_direction_toward_target_create_at_position` | Creates process type `0x204` with the direction-toward-target update vtable and supplied target position; called by Loiter and Attack process paths. | +| `004536ac` | `process_direction_toward_target_create_at_item_position` | Creates process type `0x204` using the selected item's outermost position; called by Attack process paths. | +| `004542d0` | `palette_color_array_initialize_from_rgb` | Replaces the color buffer with 256 three-byte entries initialized from one RGB triple; used by palette fade/grayscale operations. | +| `00454340` | `palette_color_array_resize_and_copy` | Resizes a color buffer and copies three-byte entries; used by palette-manager initialization and fades. | +| `00454440` | `palette_load_resource_by_id` | Loads and copies a Windows executable resource of type `PALETTE` by numeric ID. | +| `004544f0` | `palette_rgb_to_yiq_transform` | Transforms each RGB palette entry to YIQ using integer coefficient matrices; called by grayscale-palette routines. | +| `004546a4` | `avi_player_context_construct` | Initializes the AVI player context, including stream, frame, audio, timing, and input state. | +| `00454958` | `avi_rle_blit_u8_to_u16` | Decodes run-length spans and dispatches nontransparent source spans to a 16-bit destination. | +| `00454a90` | `avi_rle_blit_u8_to_dual_u32` | Decodes run-length spans and dispatches nontransparent source spans to paired 32-bit destinations. | +| `00454bc8` | `avi_rle_copy_spans_to_byte_buffer` | Decodes run-length spans and copies nontransparent source bytes to a byte-oriented destination buffer. | +| `00454d0c` | `avi_rle_blit_u8_to_dual_u16` | Decodes run-length spans and dispatches nontransparent source spans to paired 16-bit destinations. | +| `00454e34` | `avi_player_advance_chunk_with_wrap` | Advances by the current chunk size and header, handles ring-buffer wrap, and tests whether a target stream position was crossed. | +| `00454f08` | `avi_player_consume_video_chunk` | Accepts video chunks `00db`/`00dc`, validates and copies frame payloads, and reports an error for other chunk types. | +| `00455034` | `avi_player_render_video_frame` | Computes frame row spans and dispatches to the appropriate run-length decoder for the output format. | +| `00455190` | `avi_player_update_status_text_overlay` | Updates timed player text and its screen rectangle. | +| `00455280` | `avi_player_process_audio_chunk` | Processes `01wb` audio chunks, submits prepared data through the audio-device virtual interface, and advances the audio-frame counter. | +| `0045542c` | `avi_player_parse_riff_header_and_index_chunks` | Reads the RIFF/AVI container, locates nested stream lists, and initializes chunk-position/index state. | +| `00455ce8` | `avi_player_read_stream_and_pump_input` | Reads 4 KiB stream blocks while pumping Windows messages, stops on selected mouse/keyboard input, and advances stream/timing state. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Live readback confirmed process type `0x204`, RGB-to-YIQ conversion, `00db`/`00dc` video chunks, `01wb` audio chunks, and RIFF/AVI indexing. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: AVI Lifecycle and Process Filters + +This slice completes the AVI player lifecycle and follows the report into shape-resource usage tracking and process-table type filters. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00455fb4` | `avi_player_find_video_or_resource_file` | Builds a media path and tries `.AVI`, with `.DAT` and optional `.TXT` fallbacks. The DAT path uses the static display overlay instead of AVI playback. | +| `004562f8` | `avi_player_prepare_stream_buffers_and_audio` | Initializes AVI ring-buffer pointers and optional audio/resource state; reports a `player.h` halt on invalid setup. | +| `004563d8` | `avi_player_apply_palette_fade_overlay` | Builds and installs a temporary RGB palette used by the AVI player's fade/display overlay. | +| `0045661c` | `avi_player_draw_screen_overlay_indicator` | Draws indexed overlay resources based on player position/state, or updates the overlay rectangle when active. | +| `00456774` | `avi_player_find_movi_list_and_start_stream` | Walks the RIFF index to find `movi`, initializes the first stream chunk, and primes video/audio playback. | +| `0045690c` | `avi_player_begin_display_overlay` | Saves palette state, applies fade/indicator setup, and prepares the player display. | +| `00456a20` | `avi_player_restore_game_display_state` | Restores display, palette, mouse, and runtime-action state changed during AVI playback. | +| `00456b18` | `avi_player_release_stream_resources` | Closes the AVI stream, releases audio/buffer/resource state, resets stream pointers, and clears input-event state. | +| `00456c20` | `avi_player_run_standard_profile` | Standard AVI playback entrypoint; initializes the context, opens/indexes the stream, runs playback, and restores resources. | +| `00456d90` | `avi_player_run_large_buffer_profile` | AVI playback entrypoint that sets a `0x300000` stream-buffer limit before using the shared playback and cleanup path. | +| `00456f0c` | `avi_player_run_item_cutscene_profile` | Item-triggered AVI playback entrypoint with its own context flags and the shared stream/playback/cleanup path. | +| `0045737c` | `shape_resource_mark_character_usage` | Sets a usage bit for a character/resource index in the bitmap selected by shape index. | +| `0045740c` | `shape_resource_build_live_item_usage_map` | Allocates two shape-character maps, scans items across both map planes, and marks character/resource-cache usage. | +| `004575a0` | `shape_resource_process_live_item_usage` | Builds live item usage; unless disabled, applies each marked shape-character pair, then frees the temporary maps. Called during item-grid initialization/rebuild. | +| `004576e0` | `process_type_filter_is_active` | Tests whether a process-type filter byte encodes an active all-types or bounded/exact match mode. | +| `00457704` | `process_type_filter_matches_type` | Matches a process type against less-than, equal, or greater-than mode and the filter's low-five-bit threshold. | +| `00457870` | `process_allocate_id_and_stage_pending_insert` | Allocates a process ID, halts on allocation failure, and stages the ID for pending process-table insertion. | +| `004578a0` | `process_require_state_flag_4000` | Halts unless the process state word contains flag `0x4000`; called from process update/control paths. | +| `004578c8` | `Process_SetItemNo` | Sets the process item ID and updates kernel item-ID and, for types `0xf0`-`0xf7`, process-type presence tracking. | +| `00457930` | `Process_SetProcType` | Sets the process type and refreshes process-type presence tracking for types `0xf0`-`0xf7`. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Caller/readback checks confirmed the AVI playback variants converge on the same setup and teardown, shape usage maps are built from live map items, and the process filter helpers are used by kernel matching/dispatch. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Process Timers and Related State + +This slice documents process-local timer scheduling, dependency-expression handling during termination, and the related-process state lists used by process construction and teardown. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00457994` | `keyboard_process_set_category_and_update_counts` | Validates a category from 1 through 31, updates the keyboard-process field, and maintains global per-category counts. | +| `00457a04` | `process_schedule_timer_deadline` | Marks the process timer active and stores its current accumulated 10 ms tick count plus the requested interval. | +| `00457a40` | `process_update_timer_and_check_deadline` | Advances the accumulated timer, clears an expired deadline, and dispatches the timer callback when enabled. Called by the process manager update. | +| `00457d74` | `process_evaluate_termination_dependency_expression` | Evaluates `true`, `AND`, `OR`, and terminator opcodes, then updates related-process state lists when true. Called during related-child termination. | +| `00458198` | `process_remove_related_state_flag_0800` | Clears relation flag `0x0800` and removes the state-list entry when no other relation flags remain. | +| `00458268` | `process_remove_related_state_flag_1000` | Clears relation flag `0x1000` and removes the state-list entry when no other relation flags remain. | +| `00458408` | `process_remove_related_state_flag_4000` | Clears relation flag `0x4000` and removes the state-list entry when no other relation flags remain. | +| `00458608` | `process_set_related_state_flag_2000` | Adds or updates a related-process list entry with flag `0x2000`; used by process activation/linking and `Kernel_Implies`. | +| `004586a0` | `process_set_related_state_flag_4000` | Adds or updates a related-process list entry with flag `0x4000`. | +| `00458738` | `process_initialize_related_state_lists` | Initializes reciprocal relation entries, updates item/type-presence bookkeeping, and appends related IDs plus an optional `AND` opcode. | +| `00458bfc` | `process_assert_flag_0800_clear_and_set_option_02` | Requires process flag `0x0800` to be clear, then sets state-byte bit `0x02`; used by process constructors. | +| `00458c2c` | `process_assert_flag_0002_clear_and_set_option_10` | Requires process flag `0x0002` to be clear, then sets state-byte bit `0x10`. | +| `00458c64` | `process_set_state_flag_08_and_increment_count` | Sets state-byte bit `0x08` and increments the global process-removal count; called by process-table removal. | +| `00458c70` | `process_release_state_arrays` | Releases the two dynamic arrays holding process state/relation entries. | +| `00458ca4` | `process_read_state_arrays` | Reads the process's two 16-bit state/relation arrays from a stream. | +| `00458cc0` | `process_write_state_arrays` | Writes the process's two state/relation buffers to a stream. | +| `00458cdc` | `process_construct_noop_base` | Calls the base initializer, installs the no-op callback vtable, clears callback data, and sets a base state bit. | +| `00458cfc` | `process_link_related_process_by_id` | Adds reciprocal relation entries between this process and the requested process using flags `0x1000` and `0x0800`. | +| `00458e5c` | `process_register_flag_40_state_guarded` | Checks shared-state guards, then registers the process for flag-`0x40` changes. Called during mouse-controller creation. | +| `00458ecc` | `process_register_flag_80_state_guarded` | Checks shared-state guards, then registers the process for flag-`0x80` changes. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Caller and decompiler readbacks confirmed the timer-manager path, the termination expression opcodes, reciprocal process-relation lists, and state-list flag operations. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Timer Setup, Overlay Streams, and Item Process Lists + +This mixed slice follows the process-state helpers into timer callbacks, the static-overlay stream and palette path, rectangle clipping, and the process-pointer list used by item collision handling. Names stay at the observed operation level where field semantics are not established. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00458f3c` | `process_set_state_flag_01_guarded` | Checks shared-state guards before setting process state-byte bit `0x01`; called by shared-state and keyboard-process construction. | +| `00458f74` | `process_construct_timed_noop_variant` | Constructs a no-op process variant, sets its mode flag, and initializes timer state; reused by controller, cycle, animation, and other process constructors. | +| `00458fb0` | `process_read_state_arrays_and_reset_tick` | Restores the process state arrays and resets its millisecond tick baseline. | +| `00458fc8` | `process_timer_initialize_clock` | Converts the configured rate to a timer interval, stores the `timeGetTime` baseline, and installs the timer callback. | +| `00459038` | `process_timer_dispatch_interval_callback` | When the interval elapses, advances the baseline, sets the callback-in-progress bit, invokes the process callback, and clears the bit. | +| `00459094` | `process_register_state_flag_04_and_track_active` | Marks state-byte bit `0x04`, updates shared process-state bookkeeping, and records the process ID in a state list. | +| `004590b8` | `process_set_state_flag_2000_and_adjust_counts` | Sets state flag `0x2000` and conditionally transfers a count between global process-state counters. | +| `00459360` | `process_has_state_flag_0002` | Returns whether process state flag `0x0002` is set; called by `Process_Terminate`. | +| `00459410` | `static_overlay_clear_stream_handle` | Clears the static-overlay file-stream handle. | +| `00459418` | `static_overlay_close_stream` | Closes and releases the static-overlay stream object, then clears its handle. | +| `00459448` | `static_overlay_open_stream_and_read_header` | Opens the requested stream and reads its header and fixed-size metadata blocks; called by the AVI `.DAT` fallback and static-overlay initialization. | +| `004594c0` | `static_overlay_release_stream` | Closes and releases the static-overlay stream object through a second cleanup entrypoint. | +| `004594ec` | `static_overlay_consume_frame_payloads` | Seeks to the stored stream offset and consumes the configured number of frame payload blocks. | +| `00459568` | `static_overlay_palette_to_rgb24` | Converts 256 RGB6 palette entries into packed three-byte RGB values for the overlay. | +| `004595f0` | `rect_contains_point` | Tests a point against the rectangle's inclusive left, right, top, and bottom bounds. | +| `00459610` | `rect_intersect_in_place` | Tightens the rectangle bounds to their intersection with a second rectangle and clears the result if empty. | +| `004597a0` | `storage_data_process_construct` | Constructs process type `0x236`, associates its item ID, and initializes storage-data fields. | +| `004598cc` | `process_pointer_list_initialize` | Initializes an empty process-pointer list and allocates its backing array when capacity is nonzero. | +| `00459920` | `process_pointer_list_append` | Appends a process pointer, increments the list count, and stores the assigned index in the process. | +| `00459940` | `process_pointer_list_terminate_matching_items` | Scans process fields at offsets `+0x02` and `+0x34` for the requested item ID, unlinks matches, marks them for deletion, and invokes teardown callbacks. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Caller/readback checks confirmed the timer callback path, AVI/static-overlay stream use, RGB6 conversion, rectangle intersection, and item-process teardown. No executable bytes were changed and the Ghidra project was not saved. +## Address-Ordered Pass: Savegame UI and Shape Resource Cache + +This slice finishes the item-process pointer-list helpers, follows the runtime savegame restore and slot-selector UI, then documents shape metadata and the static-resource cache paths used by viewport and item geometry routines. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004599e0` | `process_pointer_list_update_and_cleanup` | Dispatches each live list entry and unlinks/marks entries that become eligible for teardown; called by item collision processing. | +| `00459a48` | `process_pointer_list_release_storage` | Releases the pointer-list backing allocation when present; called at the end of item collision processing. | +| `00459a80` | `savegame_scan_slot_metadata_files` | Iterates 13 savegame slots, prepares each slot path, and reads fixed metadata for existing files. | +| `00459d28` | `game_runtime_restore_savegame_state` | On the savegame transition path, reads saved records and reinitializes input, audio, item-grid, Usecode, process, and viewport state. | +| `00459f3c` | `savegame_slot_get_metadata_buffer` | Returns the metadata buffer selected by the current slot index. | +| `00459f48` | `savegame_slot_set_metadata_text` | Copies supplied text into the metadata buffer selected by the current slot index. | +| `00459fa4` | `savegame_slot_selector_gump_construct` | Creates the slot-selector gump and 11 positioned row objects, loads its palette resource, and renders the UI. | +| `0045a570` | `savegame_slot_row_construct` | Constructs a row object with indexed-resource bounds and row-specific state; called by the slot-selector constructor. | +| `0045a8bc` | `savegame_slot_row_handle_event` | Handles row events, refreshes the slot text, and queues a selection event for a nonempty label. | +| `0045ab80` | `indexed_resource_child_construct` | Constructs an indexed-resource child object and initializes its bounds from the selected resource. | +| `0045acd0` | `build_length_prefixed_argument_descriptor` | Encodes variadic fields into a length-prefixed descriptor with a `$` terminator and a 31-byte limit; used by search-selector and snapshot paths. | +| `0045c3f8` | `shape_get_bounds_metadata` | Retrieves four shape bound/origin words from the cache or default record; called by item and projected-shape geometry checks. | +| `0045c450` | `shape_get_frame_resource_metadata` | Looks up shape/frame metadata and loads the entry when absent; called during visible-item animation updates. | +| `0045c4c4` | `shape_get_bounds_at_position` | Translates cached shape bounds to a rectangle at the supplied X/Y position; used by viewport render-node bounds updates. | +| `0045c55c` | `shape_resource_cache_insert_frame` | Creates a cache node, copies resource data through the cache interface, and links it into the shape entry. | +| `0045c660` | `shape_resource_cache_get_frame` | Retrieves the requested shape/frame entry and initializes its cached resource group on first access. | +| `0045c8b0` | `static_resource_cache_construct` | Constructs the static-resource cache manager, enumerates the static resource path, and initializes its streams and cache state. | +| `0045cc80` | `shape_resource_cache_get_frame_with_disk_fallback` | Retrieves a shape/frame entry, loading missing group data through resource streams before creating cache nodes. | +| `0045cff8` | `static_resource_cache_build_index` | Initializes the active cache context and walks 0x800 entries to build its resource index. | +| `0045d0f4` | `resource_cache_variant_construct_type_04` | Constructs resource-cache variant type `4`, installs its dispatch table, and registers cache slot 4. | + +All 20 entries are listed at exact function-entry addresses, with descriptive names and decompiler comments applied. Caller and decompiler readbacks confirmed the savegame restore/UI path, selector descriptor use, shape-bound consumers, and static-resource cache construction. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Static Swap Files, Snap-Egg Bounds, and Sound-FLX Cache + +This continuation follows static-resource-cache construction into swap-file management, then documents the snap-egg process's tracked-item bounds and overlap selection, and the sound-FLX entry cache's LRU lifecycle. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0045d140` | `resource_cache_managers_initialize` | Allocates and constructs the global static-resource manager and type-4 cache variant; reports a fatal resource error if either allocation fails. | +| `0045d190` | `static_resource_cache_release` | Invokes the static-resource manager's virtual cleanup and clears its global pointer. | +| `0045d1b8` | `static_resource_cache_build_swap_file` | Opens or creates the static swap/index file, scans 0x800 resource records, writes selected indexed records, and updates progress output. Called by `static_resource_cache_construct`. | +| `0045d64c` | `static_resource_cache_finalize_or_rebuild` | Releases the active static-resource object and either rebuilds the index or removes/recreates the temporary file, according to cache-mode globals. | +| `0045da10` | `snap_egg_process_construct` | Constructs a process with its specialized vtable, stores it globally, and initializes its tracked-item list and active-bound fields. | +| `0045da80` | `snap_egg_process_reset` | Clears the process's tracked IDs, current bounds, and active-selection fields; called during runtime transition dispatch. | +| `0045db24` | `snap_egg_get_item_world_bounds` | Computes an item's four world-space rectangle coordinates from its X/Y position and auxiliary footprint fields; used by snap-egg overlap checks. | +| `0045dc10` | `snap_egg_process_add_item` | Adds an item ID once to the process list; a full 0x40-entry list reports `Too many snap eggs!`. Called when item flag `0x2000` is set. | +| `0045dcf8` | `snap_egg_process_remove_item` | Removes an item ID, clears associated active-selection state, and trims empty trailing list slots; called from item creation/finalization paths. | +| `0045ddb0` | `snap_egg_item_overlaps_active_bounds` | Tests the current item's rectangle against the active item's bounds and accepts a vertical difference within `0x30`. | +| `0045df10` | `snap_egg_process_update_active_bounds` | Searches tracked IDs for an item overlapping the current item, records the match and its bounds, then updates the projected viewport tile cache. | +| `0045e28c` | `snap_egg_process_draw_item_outlines` | Iterates nonzero tracked IDs and draws isometric outlines using the current item's auxiliary footprint and each tracked item's position. | +| `0045e488` | `audio_sound_flx_cache_initialize` | Allocates the sound-FLX data, index, and entry-list storage for the requested count; called by `audio_initialize_sound_flx`. | +| `0045e560` | `audio_sound_flx_cache_destroy` | Resets sound-FLX entries and frees the three backing allocations; called during audio resource cleanup. | +| `0045e584` | `audio_sound_flx_cache_set_stream_object` | Stores the stream/resource object used by sound-FLX cache reads; called during sound-FLX initialization. | +| `0045e58c` | `audio_sound_flx_cache_reset_entries` | Recreates per-entry cache nodes, frees old buffers, and resets entry indices. | +| `0045e6c0` | `audio_sound_flx_cache_get_entry` | Returns a cached sound-FLX entry or loads it on demand, evicting an LRU slot when needed and transforming bytes after its 20-byte header. | +| `0045ecf0` | `audio_sound_flx_cache_initialize_once` | When the audio cache feature is enabled, allocates its singleton object and initializes the 12 entry slots once. | +| `0045ed5c` | `audio_sound_flx_cache_shutdown` | Clears the initialization flag, releases cache entries, and frees the backing singleton; called during audio cleanup. | +| `0045ed80` | `audio_sound_flx_cache_clear_entries` | Invokes per-entry cleanup for the 12 cache slots and resets their object, index, and state fields. | + +All 20 entries are listed at exact function-entry addresses with descriptive names and decompiler comments. Caller checks confirmed the static-cache constructor path, item flag/list lifecycle, snap-egg runtime reset, and sound-FLX initialization/cleanup. Representative readbacks confirmed the names and comments. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Sound Channels and Spatial Event Records + +This continuation maps the sound-FLX channel lifecycle and the 11-byte event records used by spatial item sounds. Names describe observed channel, cache-entry, and item-reference operations; the full record schema remains open. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0045ee9c` | `audio_sound_flx_start_or_update_channel` | Walks the 12 sound-FLX channels, obtains the requested cached entry, and configures the selected channel's buffer, volume, and playback state. Called by audio channel updates and item sound requests. | +| `0045f140` | `audio_sound_flx_start_playback` | Reuses a channel for the requested entry or delegates to channel setup; refreshes the audio object when the requested parameters differ. | +| `0045f204` | `audio_sound_flx_stop_playback` | Marks a matching channel for cleanup, stops its audio object, and resets its entry/playback fields; used by sound-ID stop handling. | +| `0045f310` | `audio_sound_flx_allocate_channel_slot` | Selects a free channel from the 8 normal or 4 reserved slots, advancing a replacement cursor and releasing a slot when its range is full. | +| `0045f418` | `audio_sound_flx_update_channels` | Updates all 12 channels from the sound cache and clears channels marked for release; called by event maintenance and item sound helpers. | +| `0045f468` | `audio_sound_flx_invalidate_entry_users` | Marks channels using an evicted cache entry for cleanup, stops their audio objects, and clears their entry IDs; called by cache eviction. | +| `0045f514` | `audio_sound_flx_set_channel_volume` | Multiplies a channel's stored volume by the global scale and applies it through the audio object. | +| `0045f5cc` | `audio_sound_flx_get_channel_state` | Returns a stored channel value only while its audio object is valid and not marked for cleanup; otherwise returns `-1`. | +| `0045f654` | `audio_sound_flx_find_channel_for_entry` | Finds an active channel by cache-entry index and returns its associated sound ID; used by initialization and stop paths. | +| `0045f698` | `audio_sound_flx_set_global_volume_scale` | Stores a global sound-volume scale and reapplies scaled volumes to active channels; called during runtime restore and key-command handling. | +| `0045f730` | `audio_sound_flx_get_global_volume_scale` | Returns the global sound-volume scale used by the channel volume updates. | +| `0045f80c` | `audio_sound_event_table_initialize` | Allocates the requested number of 11-byte sound-event records and initializes each sound ID to the unused sentinel; called by sound-FLX initialization. | +| `0045f8d0` | `audio_sound_event_table_release` | Releases the sound-event record array and clears its initialized flag; called by audio cleanup. | +| `0045f900` | `audio_sound_event_table_reset` | Resets each initialized event record's sound ID to the unused sentinel; called during process/runtime setup. | +| `0045fa18` | `audio_sound_find_available_event_slot` | Updates channels, reclaims event records whose playback is no longer active, and returns an available record offset. | +| `0045fa74` | `audio_sound_play_spatial_effect` | Creates an item-associated sound event and chooses attenuation from shape overlap or distance to the current view item; called through an item sound helper. | +| `0045fc28` | `audio_sound_play_or_refresh_spatial_loop` | Creates or refreshes a persistent spatial event, reusing an event for the same sound when possible and applying distance-based attenuation. | +| `0045fee0` | `audio_sound_play_item_effect_if_new` | Avoids duplicating an active event for the same item and sound, otherwise routes the request through spatial sound setup. | +| `0045ffb4` | `audio_sound_stop_item_effect` | Finds matching item/sound event records, stops their playback channels, and clears their record fields. | +| `00460044` | `audio_sound_clear_item_event_references` | Clears the item reference in matching sound-event records without stopping playback; called from item removal side effects. | + +All 20 entries are listed at exact function-entry addresses with descriptive names and decompiler comments. Caller checks tied channel eviction to the sound cache, global volume updates to runtime restore/input, and event-table initialization/cleanup to the audio lifecycle; spatial event helpers are reached from item sound calls. Representative readbacks confirmed the channel and spatial-event behavior. No executable bytes were changed and the Ghidra project was not saved. + +## Address-Ordered Pass: Sound Events and Sprite Manager + +This pass completes the remaining sound-event maintenance helpers, then follows the 64-entry sprite table through lifecycle, frame/position updates, projected bounds, and dirty-region rendering. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0046009c` | `audio_sound_stop_all_events_for_item` | Scans event records for the supplied item ID, stops each associated playback, and marks the record unused; called from item finalization and the item-mode helper. | +| `004600f8` | `audio_sound_stop_persistent_events_for_item` | Stops matching item-associated events only when the record's persistent/loop flag is set; called from item removal side effects. | +| `00460164` | `audio_sound_is_item_effect_active` | Updates sound channels and checks for an active event matching both the supplied sound and item IDs; called through the item-mode helper. | +| `00460314` | `audio_sound_clear_event_by_channel_id` | Finds a sound-event record by its ID and clears its sound and item fields; called while allocating channel slots and invalidating users of an evicted cache entry. | +| `00460380` | `audio_sound_refresh_spatial_event_volumes` | Refreshes the final four spatial records, selecting volume from item-shape overlap or distance to the current view item; called during viewport tile-cache updates. | +| `00460520` | `sprite_manager_initialize` | Initializes a table of 64 19-byte sprite records and screen-region state; invoked from runtime setup. | +| `00460600` | `sprite_manager_shutdown` | Releases the sprite table, screen-region state, and optional dynamic list; invoked from runtime teardown. | +| `00460668` | `sprite_manager_add_shape_entry` | Adds a shape-backed record in the first free slot, initializes its frame and position, and marks it for redraw; callers include tracked-item marker repositioning and sprite-process paths. | +| `00460758` | `sprite_manager_remove_shape_entry` | Removes a record, invalidates its prior clipped bounds, clears its fields, and trims trailing unused slots; called by runtime mode changes and tracked-item marker updates/stops. | +| `00460878` | `sprite_manager_get_frame` | Returns the frame index stored in the selected sprite record; called by sprite-process helpers. | +| `00460898` | `sprite_manager_set_frame` | Stores a new frame, refreshes cached shape dimensions, and marks the affected screen region for redraw; called from sprite creation and processing paths. | +| `0046093c` | `sprite_manager_set_world_position` | Updates a record's world-position fields and marks its previous screen bounds dirty when they change; called by item-position and marker-update paths. | +| `004609e0` | `sprite_manager_get_world_position` | Copies a record's stored world-position components into caller outputs; called by sprite-process handling. | +| `00460a14` | `sprite_manager_get_screen_bounds` | Projects a record into screen space and returns its un-clipped rectangle; used by the render/update pass. | +| `00460ae8` | `sprite_manager_project_world_position` | Projects a record's world position to a screen point with its vertical offset applied; used by sprite-process rendering. | +| `00460b58` | `sprite_manager_get_clipped_screen_bounds` | Projects a record's bounds and clamps the rectangle to the 640-by-480 screen region; used when invalidating or changing a sprite. | +| `00460c7c` | `sprite_manager_render_and_update` | Rebuilds dirty screen regions, draws affected cached shape frames, and clears per-entry dirty flags; called by the viewport update path. | +| `00461180` | `screen_region_process_intersecting_rects` | Removes overlaps from a screen-region rectangle list and processes the remaining rectangles; called by screen-region update code. | +| `004611f4` | `sprite_manager_reset_entries` | Resets the live sprite count and clears active/position fields in all 64 records; called during runtime initialization. | + +Caller checks and representative decompiler readbacks confirmed the sound-event/item relationships, sprite-table lifecycle, cached-frame updates, and dirty-region renderer. All 19 entries are documented at exact function-entry addresses with descriptive names and comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Sprite Processes and Position Queries + +This continuation completes sprite-manager accessors and restore controls, documents sprite-process creation/animation, then follows the position-query process through motion setup, collision-checked steps, and related cursor-state helpers. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00461230` | `sprite_manager_get_position_component_a` | Returns the 16-bit sprite-record field at offset `+0x0a`; callers include keyboard-facing adjustment and a sprite-state helper. The component's exact axis remains unresolved. | +| `00461250` | `sprite_manager_get_packed_world_xy` | Returns the packed position word at `+0x0c`, which the sprite manager passes to isometric projection; callers include keyboard-facing adjustment and motion setup. | +| `00461270` | `sprite_manager_suppress_updates` | Sets the global flag that makes the sprite render/update pass skip its work; called by a runtime state helper. | +| `00461278` | `sprite_manager_resume_and_mark_all_dirty` | Clears the suppression flag and marks every live sprite record dirty; called during runtime transitions. | +| `004612d8` | `sprite_manager_restore_state_from_stream` | Clears temporary lists, reads a 16-bit array from the supplied stream, and marks live sprite records dirty; called from savegame restoration. | +| `0046159c` | `sprite_process_find_or_create_for_state` | Allocates a sprite process for the requested state; for selected states it checks existing sprite positions and reuses a nearby process before creating another. Callers include item-state, marker, audio-selector, position-state, and Usecode paths. | +| `00461880` | `sprite_process_construct` | Constructs process type `0x249`, installs its dispatch table, creates a sprite-manager entry, and initializes animation fields; called by the state-based creator. | +| `00461b50` | `sprite_process_run` | Advances animation counters at a tick-dependent rate, updates the displayed frame, schedules the next timer, and removes its sprite entry on completion. This is a virtual run method. | +| `00461c9c` | `sprite_manager_offset_world_position` | Reads the selected sprite's position fields, applies two supplied offsets, and writes the updated position; called by item-grid insertion. | +| `00461cfc` | `position_query_process_construct` | Constructs process type `0x250`, initializes collision-query state and position-search fields, and stores its query-state object; called by candidate construction. | +| `00461e30` | `position_query_process_set_position_snapshot` | Copies a five-byte position value into two process snapshots and stores the accompanying field; also initializes an additional snapshot word. | +| `00461e50` | `position_query_process_set_position_snapshot_variant` | Copies the same five-byte position value into both snapshots and stores the accompanying field, without the additional word initialized by the other variant. | +| `00461e68` | `position_query_process_configure_motion` | Derives target deltas and step rates from the requested mode/state, with bounded randomized offsets; called by the position-query candidate builder and thin wrappers. | +| `0046227c` | `position_query_process_configure_motion_from_args` | Adapts its arguments and forwards them to the shared motion configurator; called by the candidate builder. | +| `00462300` | `position_query_process_configure_motion_from_sprite` | Reads stored sprite-manager position fields and forwards them with supplied parameters to the motion configurator; called by the candidate builder. | +| `00462414` | `position_query_process_update` | Updates process state, handles item contacts, synchronizes its sprite entry, advances a mode-specific frame, and may request another sprite process. | +| `004624f0` | `position_query_process_step_toward_target` | Advances toward a target in collision-checked increments, dispatches resulting position state and sound, then terminates or removes the associated item; called by its process update path. | +| `004628c0` | `position_query_update_world_bounds_from_shape` | Decodes shape-related packed fields and tightens supplied world-bound components using the item's outermost X/Y coordinates; called by the collision-checked step. | +| `0046332c` | `cursor_state_disable_and_center` | Sets the cursor-mode state to zero and centers the cursor at horizontal coordinate `0x140`; reached from Usecode dispatch. | +| `00463350` | `cursor_state_enable_and_center` | Sets the cursor-mode state and six related flags, then centers the cursor at horizontal coordinate `0x140`; reached from Usecode dispatch. | + +Caller checks and decompiler readbacks confirmed the sprite-process lifecycle, savegame restore path, position-query call chain, and cursor helpers. All 20 entries are listed at exact function-entry addresses with descriptive names and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Bottom Toolbar, AVI Text, and Process Timing + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00463390` | `bottom_toolbar_initialize` | Initializes five sprite-backed slots from a resource-ID table, spaces their bounds across the lower screen, and stores draw state. The direct caller lookup timed out; the matching five-slot state is consumed by the neighboring event and redraw helpers. | +| `00463520` | `bottom_toolbar_process_events` | Large event dispatcher; tests pointer input against the five stored rectangles, handles active-slot state, and dispatches selected UI/item actions. The exact user-facing meaning of each slot remains unresolved. | +| `00463c40` | `bottom_toolbar_redraw_dirty_slots` | Processes the stored rectangle for each dirty slot and clears its dirty flag when toolbar mode is active. | +| `00463cb0` | `bottom_toolbar_set_enabled` | Sets the toolbar state from the incoming boolean, marks all five slots dirty when enabled, and centers the cursor; called from two runtime helpers and a third unresolved entry. | +| `00463d0c` | `bottom_toolbar_enable_all_slots` | Enables toolbar mode, marks all five slots dirty, and centers the cursor; called by `game_runtime_transition_dispatch`. | +| `00463d4c` | `bottom_toolbar_disable` | Clears toolbar mode and centers the cursor; called by `game_runtime_transition_dispatch`. | +| `00463d70` | `bottom_toolbar_mark_slot_dirty` | Bounds-checks a slot index in the range 0-4 and marks that slot dirty; called by `item_shape_state_assign_linked_item`. | +| `00463dc0` | `avi_stream_file_buffer_init` | Clears stream fields, runs base initialization, then loads a requested file; called by `avi_player_find_video_or_resource_file`. | +| `00463e00` | `avi_stream_file_buffer_release` | Frees and clears the allocated stream-data pointer; called by AVI stream preparation and release paths. | +| `00463e1c` | `avi_stream_file_buffer_load` | Determines file size, allocates a buffer, reads the file through the stream helpers, and stores size and pointer; called by the initializer above. | +| `00463ed4` | `avi_player_get_next_status_record` | Returns the next 12-byte record and advances its index while records remain; called by `avi_player_update_status_text_overlay`. | +| `00463f08` | `avi_player_parse_text_records` | Walks buffered text records, locates `@` markers with DBCS-aware scanning, and fills per-record fields; called during AVI stream preparation. The text format's full semantics are unresolved. | +| `00463ff4` | `avi_player_find_next_text_record` | Finds a record boundary in the buffered text, advances across CR/LF and separators, and terminates parsed text in place; called by the parser above. | +| `004640b8` | `avi_player_find_record_marker` | Scans for `@` while skipping DBCS multibyte characters and returns the marker address; called by the AVI text parser. | +| `004641a0` | `file_stream_insert_at_offset` | Uses stream virtual methods to inspect/copy existing content, extend the stream, write bytes at the requested offset, and flush; called by an AVI-related helper. | +| `00464298` | `callback_noop_00464298` | Empty callback that immediately returns; referenced by an unresolved call site. | +| `0046429c` | `win32_shutdown_once` | Global guard ensures a registered shutdown callback runs once, then conditionally exits the Win32 message loop; called by fatal-report helpers and the main window procedure. | +| `004642f0` | `timer_process_construct` | Constructs a specialized process with type 4 and initializes its timer fields; called by `kernel_process_manager_initialize`. | +| `00464360` | `win32_delay_with_message_pump` | Pumps messages and callbacks until the multimedia timer advances by the requested number of 10 ms units; used by static-overlay loops and scripts. | +| `00464390` | `timer_process_accumulate_elapsed_ticks` | Accumulates elapsed 10 ms units and advances the process's previous timestamp; called by the process-manager loop and timer update helper. | + +Caller checks and decompiler readbacks confirmed the AVI preparation/status-text paths, shutdown callback, process constructor, and timing helpers. Direct caller retrieval for the two larger toolbar routines timed out; their names are supported by the five-slot initialization, hit-testing, dirty-state, and cursor behavior in their decompilation/disassembly. All 20 entries are listed at exact function-entry addresses with descriptive names and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Mouse, Command Line, and Usecode Resources + +This slice resumes at the next report-listed entry after the timer helpers. It covers small mouse/configuration utilities, Japanese command-line parsing, and resource-cache/process setup for Usecode event dispatch and the optional `-u` override. + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00465b88` | `usecode_opcode_table_get_9bit_field` | Extracts a 9-bit value from an indexed 9-byte table record; called by `usecode_opcode_dispatch`. The table field's higher-level meaning remains unresolved. | +| `00465bc0` | `filesystem_get_available_disk_space_bytes` | Multiplies the free-cluster count, sectors per cluster, and bytes per sector returned by `GetDiskFreeSpaceA`. | +| `00465c00` | `mouse_controller_initialize_global` | Creates the global mouse-controller object from its resource path, installs its dispatch table, and initializes dimensions to 320 by 200. | +| `00465c64` | `mouse_controller_update_pointer_region_state` | Translates cached pointer-region rectangles with controller dimensions and stores whether the supplied point lies in either region. | +| `00466068` | `process_construct_timed_state_flag_variant` | Builds on the timed no-op process constructor, initializes the process clock, registers state flag `0x04`, and sets another process flag. | +| `004660ac` | `Game_ViolenceEnabled` | Tests whether the configured `VIOLENCE` value contains `'1'` at offset 9; used by item-interaction and Usecode paths. | +| `004660bc` | `Game_CompileIs1` | Tests whether the configured `GAME_COMPILE` value contains `'1'` at offset `0x0d`; queried by Usecode opcode dispatch. | +| `004666d0` | `command_line_next_token` | Advances through the command-line buffer, skips classified separators, and returns the next token after terminating it in place; called by the Japanese argument parser. | +| `00466a1c` | `win32_game_initialize_command_line` | Initializes the Windows game object, sets the Japanese game-title prefix, dispatches Japanese command-line arguments, and invokes virtual cleanup; called from `win32_game_main`. | +| `00466c10` | `usecode_override_stream_open` | Constructs and opens the resource stream used by the optional Japanese Usecode override path; reports a fatal resource error if backing allocation fails. | +| `00466cf8` | `usecode_resource_stream_seek` | Seeks the Usecode resource stream to the requested offset and reports a fatal file error when the stream position is invalid. | +| `00466d30` | `usecode_resource_stream_read` | Forwards a requested byte count to the Usecode resource stream's read operation. | +| `00466d60` | `usecode_resource_cache_entry_initialize` | Initializes a resource-cache entry, allocates its backing data, stores size/resource metadata, and installs its release callback. | +| `00466de0` | `usecode_resource_cache_entry_release` | Releases a cache entry and its resource object, with additional cleanup selected by callback flags. | +| `00466e68` | `usecode_runtime_reset_state` | Resets the active Usecode runtime object and associated state; called during savegame restoration and startup initialization. | +| `00466ebc` | `startup_apply_u_override_if_present` | Applies the Japanese `-u` Usecode override when configured, loads its resource data, and rebuilds associated resource-index state. | +| `00467004` | `usecode_override_shutdown` | Releases the active Japanese Usecode override object, clears its global state, and performs shared runtime cleanup. | +| `00467060` | `usecode_get_item_event_selector` | Derives an item's Usecode event selector from its item flags, shape flags, shape-class state, or shape ID; called by event-selection helpers. | +| `004670b0` | `usecode_start_event_process_if_enabled` | Checks the item's derived selector against the enabled-event mask and creates a Usecode process when that event is enabled; called from item lifecycle paths. | +| `004671b0` | `UsecodeProcess_Create` | Constructs a Usecode process, initializes its program context/function data, and copies supplied argument bytes onto its stack. | +| `00467304` | `UsecodeProcess_Run` | Runs the next Usecode opcode, updates saved execution state on completion, and dispatches the process completion callback. | +| `00467360` | `UsecodeProcess_Callback_67360` | Releases the process state arrays and conditionally performs final cleanup when the process is not in its completed state. | +| `00467380` | `UsecodeProcess_Callback_67380` | Serializes process state arrays, execution offsets, function metadata, and associated data buffers to the save stream. | +| `00467448` | `UsecodeProcess_Callback_67448` | Restores serialized process state and data buffers, then reconnects the process to its active function/resource context. | +| `004676a0` | `usecode_resource_table_release_entries` | Releases both allocated arrays for each of the 128 Usecode resource-table entries, then clears the associated intrusive list. | +| `00467738` | `usecode_resource_table_find_or_select_slot` | Finds a resource-table entry by ID or selects and cleans a reusable slot, returning the selected slot through an output pointer. | +| `004678d4` | `usecode_resource_table_load_metadata` | Reads a resource-table entry header, allocates its metadata arrays, and initializes per-resource reference states. | +| `004679f0` | `usecode_resource_cache_acquire_resource` | Acquires a resource by table and index, loading and caching missing data, updating reference counts, and promoting cache nodes. | +| `00467d50` | `usecode_resource_cache_get_data_pointer` | Returns the data pointer from the cache entry acquired for the supplied resource table and index. | +| `00467d64` | `usecode_reference_table_decrement_refcount` | Decrements the selected resource reference count and reports an underflow. | +| `00467de8` | `usecode_resource_cache_release_if_unused` | Releases a cache node when its resource reference count reaches zero, updates cache accounting, and unlinks the node. | +| `00467ebc` | `usecode_resource_cache_release_matching` | Releases cache entries matching the requested table/resource selector, or drains entries when passed the all-entry sentinel. | +| `004680f0` | `UsecodeProcess_Callback_680F0` | Releases process-owned resource and dynamic-array state, with a separate teardown path selected by callback flags. | +| `004681f0` | `file_path_exists` | Returns whether `GetFileAttributesA` succeeds for the supplied path. | +| `00468208` | `random_range_inclusive` | Advances the shared linear-congruential random state and reduces its 16-bit value modulo the inclusive endpoint span. | +| `00468344` | `random_seed_initialize` | Initializes the shared random state from the supplied seed while forcing the low bit to one. | +| `00468354` | `random_next_modulo` | Advances the shared linear-congruential random state and returns its 16-bit value modulo the supplied nonzero bound. | +| `004683e4` | `surface_bitmap_buffer_initialize` | Initializes bitmap-buffer dimensions and row offsets, allocating backing storage or obtaining the DirectDraw surface pointer according to flags. | +| `00468510` | `surface_bitmap_buffer_release_resources` | Releases owned backing storage and row-offset data; flags select pointer-only clearing or preservation of externally managed storage. | +| `0046857c` | `surface_bitmap_buffer_release` | Thin cleanup wrapper that delegates bitmap-buffer release to the shared resource-release routine. | +| `00468588` | `surface_bitmap_buffer_copy_descriptor` | Releases the destination buffer's current resources, copies the supplied bitmap-buffer descriptor, and marks the copied buffer as externally managed. | +| `004685b8` | `surface_bitmap_buffer_get_pixel_address` | Computes a pixel address as the buffer base plus row times stride plus column. | +| `004685d4` | `surface_draw_line_bresenham` | Draws a clipped line between two coordinates using an integer Bresenham-style raster walk. | +| `00468964` | `surface_draw_horizontal_line` | Draws a horizontal span clipped to the bitmap-buffer bounds; an unsupported buffer mode takes the not-implemented error path. | +| `00468a78` | `surface_draw_rectangle_outline` | Draws a rectangle outline by composing clipped horizontal and vertical spans, defaulting zero bounds to the full buffer. | +| `00468c7c` | `surface_bitmap_buffer_copy_rect` | Copies a clipped rectangular pixel region between bitmap buffers, temporarily locking and unlocking a DirectDraw surface when its backing pointer is unavailable. Confirmed from disassembly after decompilation failed. | +| `004692e0` | `surface_draw_vertical_line` | Draws a clipped vertical span by writing the requested pixel value at each row using the buffer stride. | +| `00469338` | `surface_set_pixel` | Writes one pixel when its coordinates fall within the bitmap-buffer bounds. | +| `00469390` | `surface_blit_indexed_shape` | Blits a clipped indexed shape into the destination buffer, selecting the pixel-copy routine from the source encoding flag. | +| `00469488` | `surface_blit_indexed_shape_flipped` | Blits a clipped indexed shape with its source rows reversed horizontally, selecting the copy routine from the source encoding flag. | +| `00469598` | `render_flip_skip_translucent_not_implemented` | Reports the unsupported flipped skip-translucent draw mode through the fatal message-box path. | +| `004695a8` | `surface_blit_indexed_shape_with_pixel_effect` | Blits a clipped indexed shape through one of two pixel-effect routines selected by the source encoding flag. | +| `004696ac` | `render_flip_skip_transform_not_implemented` | Reports the unsupported flipped skip-transform draw mode through the fatal message-box path. | +| `004696bc` | `packed_shape_find_pixel_data_at_position` | Walks packed shape row data to locate source pixel data at a translated coordinate. | +| `0046974c` | `surface_blit_indexed_shape_with_mapping` | Blits a clipped indexed shape through one of two mapping/effect routines selected by the source encoding flag. | +| `00469850` | `surface_blit_shape_effect_mode_dispatch` | Dispatches the indexed-shape effect blit; the skip-translucent mode reports an unsupported-operation error. | +| `0046988c` | `surface_apply_yiq_palette_effect` | Transforms each buffer pixel using palette RGB-to-YIQ values, then releases the temporary palette buffer. | +| `004699fc` | `usecode_runtime_mode_flag_set` | Sets a shared runtime mode byte to one; its higher-level meaning is not yet established. | +| `00469a04` | `usecode_runtime_mode_flag_clear` | Clears the shared runtime mode byte; its higher-level meaning is not yet established. | +| `00469a10` | `usecode_process_create_special_type` | Allocates and initializes a process base object, then installs the derived process vtable at `004804e4`. | + +## Address-Ordered Pass: Item Interactions and Selection + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00469a2c` | `usecode_runtime_flag_set_00495834` | Sets runtime byte `00495834`; called from Usecode opcode dispatch. | +| `00469a34` | `usecode_runtime_flag_clear_00495834` | Clears runtime byte `00495834`; called from Usecode opcode dispatch. | +| `00469a40` | `item_action_advance_shape_entry` | Resets the current item-action shape entry, updates its sprite state, and advances the active entry list. | +| `00469af8` | `input_state_clear_and_reset` | Clears pending input-state fields and invokes the shared input-event reset routine. | +| `00469b18` | `runtime_flag_00482698_is_clear` | Returns whether runtime byte `00482698` is zero; exposed through Usecode opcode dispatch. | +| `00469b28` | `gump_item_shape_is_eligible` | Checks shape/category-specific slot and state constraints before the caller adds an item through its gump flow. | +| `00469d50` | `item_shape_interaction_apply_state` | Dispatches shape-specific interaction logic, updating category-dependent item slots and counters; selected paths also remove an item or refresh its selection state. | +| `0046a5a8` | `item_record_cycle_field_15_slot` | Cycles item-record field 15 through slots 1-5, skipping empty slots, then refreshes the toolbar and related shape state. | +| `0046a714` | `item_record_cycle_field_19_slot` | Cycles item-record field 19 through slots `0x0b`-`0x18`, skipping empty slots, and marks the toolbar slot dirty. | +| `0046a780` | `usecode_runtime_flag_clear_00495837` | Clears runtime byte `00495837`; called from Usecode opcode dispatch. | +| `0046a78c` | `usecode_runtime_flag_get_00495837` | Returns runtime byte `00495837` to Usecode opcode dispatch. | +| `0046a794` | `usecode_runtime_flag_set_00495837` | Sets runtime byte `00495837`; called from Usecode opcode dispatch. | +| `0046a7f4` | `modal_ui_suspend_world_rendering` | Stops audio, disables toolbar updates, suppresses sprite updates, and redraws the pointer for modal UI. | +| `0046a864` | `modal_ui_resume_world_rendering` | Restores sprite and toolbar updates, redraws the pointer, and resets input state after modal UI. | +| `0046a8e4` | `runtime_transition_noop_stub` | Decompiles to an immediate return and is called during runtime transition dispatch; unreachable-block warnings leave its original intent unclear. | +| `0046a940` | `item_shape_filter_gump_create` | Creates linked resource record type `0x11e`, initializes its UI fields and surface-derived bounds, and configures its shape filter. | +| `0046dc44` | `viewport_select_spatial_item_node` | Picks a viewport spatial node at the supplied point; for node type 2, updates item-shape state and clicked coordinates. | +| `0046ddec` | `item_shape_selection_candidates_rebuild` | Scans item IDs below `0x2800`, filters candidates by flags, shape/category, height, and distance, sorts by distance, and updates the active sprite entry. | +| `0046e154` | `item_shape_selection_advance_candidate` | Advances through the current item-shape candidate list while updating the associated sprite-manager entry. | +| `0046e2a0` | `item_shape_selection_clear_candidate` | Clears the current candidate and advances the list, removing the sprite entry when the active list ends. | + +## Address-Ordered Pass: Static Overlay and Usecode Values + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0046e384` | `sprite_manager_remove_shape_entry_if_active` | Calls sprite-manager shape-entry removal only when the global shape-entry index is active. | +| `0046e870` | `static_overlay_process_update` | Advances a static-overlay frame, updates and imports its palette, notifies matching processes, releases the stream, and renders the gump tree; selected modes delegate to a virtual handler. | +| `0046ed00` | `item_shape_selection_get_current_head` | Returns the first pointer-sized field from the supplied selection-list object; used as the initial candidate by the item-action path. | +| `0046ed3c` | `weapon_cache_load_records_for_type` | Loads the selected weapon-cache type from the static indexed resource, allocating cache buffers and reading records marked for caching. | +| `0046efb4` | `weapon_cache_get_shape_render_metadata` | Looks up cached shape render metadata and fills the caller's dimensions/offset outputs; reloads the cache when the active type changes and returns zeroed outputs for unsupported or absent entries. | +| `0046f0b0` | `weapon_cache_has_shape_records` | Ensures the selected weapon-cache type is loaded, then reports whether the requested shape slot has cached records. | +| `0046f0d4` | `weapon_cache_get_type_shape_value` | Finds the selected type in the weapon-cache table and returns its associated 16-bit shape value. | +| `0046f160` | `usecode_value_heap_initialize` | Allocates the Usecode value heap backing storage and installs its initial free-block metadata. | +| `0046f200` | `usecode_value_heap_shutdown` | Releases the backing storage for the Usecode value heap and clears its global base pointer. | +| `0046f220` | `usecode_value_heap_copy_string` | Allocates space in the Usecode value heap for a NUL-terminated string, copies it, and returns its heap offset. | +| `0046f274` | `usecode_value_heap_allocate` | Allocates a block from the Usecode value heap, splitting a larger free block when enough space remains. | +| `0046f394` | `usecode_value_heap_free_owner_values` | Releases Usecode heap values associated with the supplied owner ID by passing each matching allocation to `Usecode_FreeVal`. | +| `0046f3e8` | `Usecode_FreeVal` | Releases an allocated Usecode heap value and coalesces adjacent free blocks. | +| `0046f4d4` | `usecode_value_heap_reset` | Resets the Usecode value heap by replacing its backing allocation and restoring the empty-list sentinel. | +| `0046f588` | `Usecode_FreeList` | Traverses a Usecode value list and frees each value, including nested payload values when the list flag is set. | +| `0046f608` | `usecode_value_list_copy` | Copies a Usecode value list and duplicates each element's inline or string payload into the destination list. | +| `0046f79c` | `usecode_value_list_get_element` | Returns a pointer to the requested element's payload in a Usecode value list, or zero when the index is out of range. | +| `0046f850` | `usecode_value_list_append` | Appends a value offset to the end of a Usecode value list. | +| `0046f8c4` | `usecode_value_list_insert_sorted` | Inserts a value into a Usecode list in sorted order, comparing strings or value data according to the list type. | +| `0046faf0` | `usecode_value_list_remove_value` | Removes matching values from a Usecode list and releases their payload and heap allocations. | + +Caller and decompiler readbacks confirmed the static indexed weapon-cache path, its viewport-bound metadata lookups, and Usecode heap/list operations used by opcode processing and runtime reset. All 20 entries have exact-address table rows and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. +Caller and decompiler readbacks confirmed Usecode list membership/replacement helpers, the modal item-shape selection gump and event handler, selection limits and costs, and the indexed-shape row decoder variants used by the surface blitters. All 20 entries have exact-address table rows and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Usecode Lists and Item-Shape Selection + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0046fc84` | `usecode_value_list_contains_value` | Searches a Usecode value list for a matching value; string lists compare referenced strings, while other entries compare the stored value bytes. | +| `0046fd58` | `usecode_value_list_replace_element` | Replaces the zero-based list element with the supplied value, freeing the old string payload when applicable; returns zero if the index is out of range. | +| `0046fe18` | `usecode_value_list_set_heap_metadata` | Writes the supplied 16-bit value to the allocator header immediately before each list element and, for string lists, each referenced string block; header semantics are unresolved. | +| `0046fed0` | `item_shape_selection_show_modal` | Creates the item-shape selection gump when resource allocation succeeds, runs the event loop until it exits, invokes a virtual completion callback, and toggles the transition flag. | +| `0046ff30` | `item_shape_selection_gump_create` | Builds the item-shape selection gump and indexed-resource child controls, positions them relative to the screen, loads the requested record, queues setup, sets allowed shape IDs, and suspends modal world rendering. | +| `00470400` | `item_shape_gump_initialize_tag_groups_a` | Finds child controls with tags 2 through 8 and extends their state flags, adjusts the scale fields for tags 1 and 0, then renders the gump tree. | +| `004704b0` | `item_shape_gump_initialize_tag_groups_b` | Finds child controls with tags 1 and 0 and extends their state flags, adjusts scale fields for tags 2 through 7, renders the gump tree, and clears a state byte. | +| `00470994` | `item_shape_selection_load_record_by_index` | Loads the indexed fixed-size 0x142-byte selection record, clears type-specific fields for lower record classes, and advances the current cursor past entries with zero shape IDs. | +| `00470b50` | `flic_play_random_transition` | When the transition guard is clear, chooses a random FLIC path, runs it with the selected AVI profile, restores the palette and display region, and redraws the pointer. | +| `00470ee4` | `item_shape_selection_handle_input_action` | Dispatches item-shape selection UI actions 0 through 8, updating the current record and selection, handling navigation, and queuing follow-up events. | +| `0047155c` | `item_shape_selection_check_add_limit` | Counts existing selections of the requested shape, includes its item-slot/state cost when present, and checks the resulting count against a shape-class-specific limit. | +| `00471640` | `item_shape_selection_try_add_current` | Attempts to add the current shape to the selection: checks the remaining budget and gump eligibility, applies the per-shape limit, updates selection state, and removes the temporary item. | +| `00471748` | `item_shape_selection_clear_selected` | Clears selected shape state by restoring each selected item, refreshes the special shape 0x4ed state when present, then resets the selected count. | +| `00471914` | `item_shape_get_selection_cost` | Maps a shape record's class to a small selection-cost/category value; observed results include 3, 4, and 5, with 0 for unhandled classes. | +| `00471a44` | `surface_blit_indexed_shape_decode_rows` | Decodes one indexed-shape row stream into the destination surface using the supplied source and destination strides. | +| `00471aa2` | `surface_blit_indexed_shape_decode_rle_rows` | Decodes an indexed-shape row stream with literal and repeated-run forms into the destination surface. | +| `00471b27` | `surface_blit_indexed_shape_decode_rows_flipped` | Decodes an indexed-shape row stream into a horizontally reversed destination, as used by the flipped indexed-shape blitter. | +| `00471b8d` | `surface_blit_indexed_shape_decode_rle_rows_flipped` | Decodes an indexed-shape row stream with literal and repeated-run forms into a horizontally reversed destination. | +| `00471c20` | `surface_blit_indexed_shape_decode_rows_mapped` | Decodes indexed-shape rows into the destination while applying the supplied two-stage palette mapping to each output pixel. | +| `00471c99` | `surface_blit_indexed_shape_decode_rle_rows_mapped` | Decodes indexed-shape rows with literal and repeated-run forms while applying the supplied two-stage palette mapping to each output pixel. | + +Caller and helper decompilations confirmed pixel-effect row decoding, resource-object cleanup, deferred tracked-resource callbacks, allocation retries, configuration parsing, and x87 range-reduction loops. All 20 entries have exact-address table rows and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Pixel Effects, Resource Memory, and Config Helpers + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00471d49` | `surface_blit_indexed_shape_decode_rows_pixel_effect` | Decodes indexed-shape rows and applies the supplied pixel-effect lookup to each destination pixel. | +| `00471db9` | `surface_blit_indexed_shape_decode_rle_rows_pixel_effect` | Decodes indexed-shape rows with literal and repeated-run forms, applying the supplied pixel-effect lookup to each destination pixel. | +| `00471ea4` | `resource_object_release_owned_allocation` | Releases the allocation associated with a non-null resource-object data pointer through the shared resource cleanup path. | +| `00471ec4` | `tracked_resource_release_thunk` | Thunk entry used by resource-object cleanup paths to reach `tracked_resource_release`. | +| `00471ec9` | `random_seed_get_pointer` | Returns the random-generator state pointer from a virtual method's state field. | +| `00471ed3` | `random_next_15bit` | Advances the generator state with the observed 0x41c64e6d/0x3039 recurrence and returns bits 16 through 30. | +| `00471f20` | `memory_fill_byte_value` | Fills the destination with the supplied byte value by replicating it across a word-sized fill operation. | +| `00471f38` | `tracked_resource_process_deferred_queue` | Drains the global deferred resource-callback queue, invokes each saved callback record, and unlinks the processed entry. | +| `00471fc0` | `tracked_resource_release` | Releases a tracked-resource allocation, updates the owning range metadata, and invokes the resource object's cleanup callbacks. | +| `00471fcc` | `tracked_resource_allocate_wait_thunk` | Thunk entry to the tracked-resource allocation retry routine. | +| `00471fd4` | `tracked_resource_allocate_with_retries` | Retries tracked-resource allocation, servicing configured frame-skip and callback hooks between attempts; a zero requested size is promoted to one. | +| `00472000` | `tracked_resource_allocate_retry_worker` | Allocation retry continuation that pumps the configured callbacks and frame-skip hook until allocation succeeds or no callback remains. | +| `00472033` | `string_format_into_buffer` | Formats the supplied text into the destination buffer through the shared output callback, then writes a terminating NUL. | +| `00472050` | `string_compare_lexicographic` | Compares two NUL-terminated strings lexicographically and returns zero on equality, otherwise a signed ordering result. | +| `0047211e` | `config_parse_value_using_pattern` | Parses the supplied configuration text with a fixed format pattern through the shared formatted-input parser. | +| `00472145` | `config_parse_value_string_method` | Configuration-value method wrapper that forwards its input string to `config_parse_value_using_pattern`. | +| `00472166` | `string_lowercase_ascii` | Converts ASCII uppercase letters in the NUL-terminated input string to lowercase in place. | +| `0047218c` | `float80_return_passthrough` | Returns the supplied extended-precision floating-point value unchanged through the hidden return-storage pointer. | +| `004721aa` | `x87_cosine_reduce_argument` | Executes x87 FCOS and repeats while the FPU range-reduction status bit remains set. | +| `004721b4` | `x87_sine_reduce_argument` | Executes x87 FSIN and repeats while the FPU range-reduction status bit remains set. | + +Caller and decompiler/disassembly readbacks confirmed Usecode flag dispatch, input reset, modal UI suspend/resume, gump item eligibility, shape-specific item updates, viewport node selection, and distance-ordered item-shape candidates. All 20 entries have descriptive names and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +Caller and decompiler readbacks confirmed opcode dispatch, Japanese command-line parsing, override-stream operations, savegame/runtime reset, item-event process creation, resource-cache lifecycle, bitmap-buffer cleanup, clipped drawing, and indexed-shape rendering. The latest 60 entries are documented at exact function-entry addresses with descriptive names and comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Address-Ordered Pass: Timed Processes, String Tables, and Item Selection +## Address-Ordered Pass: Path, Heap, and File Runtime Helpers + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004721be` | `x87_wait_until_not_busy` | Polls x87 status bit 10 until clear, then returns the status word with AX. | +| `00472224` | `ascii_uppercase_char` | Converts one ASCII lowercase letter to uppercase; leaves other byte values unchanged. | +| `00472234` | `array_construct_elements_with_callback` | Initializes array-allocation metadata and invokes the element constructor callback once per requested element. | +| `0047227c` | `string_copy_dbcs_bounded` | Copies a bounded string/path component with DBCS-aware length handling and a terminating NUL. | +| `004722b2` | `path_split_drive_and_components` | Extracts an optional drive prefix and scans path separators and extension dots while respecting DBCS pairs. | +| `0047238b` | `string_find_last_character` | Scans through the string terminator and returns the last matching byte, or null when absent. | +| `004723a5` | `string_copy_with_zero_padding` | Copies up to the destination capacity and zero-fills the unused remainder. | +| `004723ef` | `uint_to_string_radix` | Converts an unsigned value to digits in a radix through 36 and writes them in forward order. | +| `00472439` | `int_to_string_radix` | Formats a signed value in the requested radix, adding a minus sign for negative base-10 values. | +| `00472454` | `memory_move_bytes` | Moves a byte range and copies backward when the higher-address destination overlaps the source. | +| `004724a1` | `heap_free_block_and_coalesce` | Selects the containing heap under lock, frees/coalesces the block, and refreshes cached free-block sizes. | +| `00472542` | `string_vformat_into_buffer` | Runs the custom varargs formatter through a buffer-writing callback and null-terminates the produced text. | +| `00472572` | `runtime_noop_callback` | Empty callback reached by the process-exit dispatch sequence. | +| `00472573` | `win32_process_exit_with_cleanup` | Runs configured shutdown callbacks and transfers control to the termination routine. | +| `0047258b` | `win32_process_exit_terminate` | Runs termination hooks and runtime cleanup, then exits through `ExitProcess`. | +| `004725b0` | `file_parse_open_mode_flags` | Parses `r`, `w`, or `a` mode strings and optional `+`, `b`, or `t` modifiers into access flags. | +| `00472681` | `file_object_open_with_mode_flags` | Opens the backing file using parsed flags and initializes or cleans up file-object state. | +| `00472745` | `file_object_open_with_mode_string` | Parses the mode string, obtains or reuses a file object, and opens the requested path. | +| `0047277e` | `file_object_open_mode_thunk` | Forwarding wrapper to the file-object mode-string opener. | +| `0047286a` | `file_stream_vformat_thunk` | Thunk to the formatted file-stream writer at `004755d9`. | +| `0047286f` | `resource_list_find_and_release_by_key` | Searches the global resource list by key, releases a matching entry, and returns -1 when no key matches. | +| `004728ae` | `resource_list_release_and_relink_entry` | Releases the matched resource object's state, then unlinks and relinks its list entry through the shared list helper. | +| `004728c3` | `hex_digit_to_lowercase_ascii` | Maps a hexadecimal nibble to its lowercase ASCII digit. | +| `004728cf` | `temporary_filename_build` | Builds a process-specific temporary filename in the observed `t..._....tmp` form. | +| `00472934` | `resource_object_release_owned_state` | Releases resource-object buffers and handles according to state flags, clears freed storage, and unregisters its runtime handle. | +| `00472a60` | `x87_log2_positive_input` | Computes x87 log2 for positive input; nonpositive or NaN input goes through the runtime domain-error helper. | +| `00472aa1` | `x87_log2_positive_input_thunk` | Forwarding thunk to the checked x87 log2 routine. | +| `00472ac1` | `audio_timing_log2_wrapper` | Audio timing callers forward an extended-precision value through the checked log2 routine. | +| `00472acd` | `string_uppercase_ascii` | Converts ASCII lowercase letters to uppercase in the input string in place. | +| `00472af2` | `string_to_signed_decimal` | Skips classified whitespace, accepts an optional sign, and accumulates decimal digits into a signed integer. | +| `00472b5f` | `local_time_to_timestamp` | Reads local calendar time, converts the populated time record to a timestamp, and stores an auxiliary result when requested. | +| `00472b8e` | `string_compare_case_insensitive_ascii` | Compares two NUL-terminated strings lexicographically after folding ASCII uppercase letters to lowercase. | +| `00472bd8` | `win32_runtime_fatal_error` | Triggers a debugger break when configured; otherwise writes the message, runs cleanup hooks, and exits with the supplied code. | +| `00472bf8` | `runtime_event_execute_nested_frame` | Pushes a temporary event/runtime frame, invokes the event interpreter, then restores the prior frame. | +| `00472c31` | `win32_runtime_get_current_thread_context` | Returns the current thread's runtime-context pointer captured during Win32 process initialization. | +| `00472c36` | `win32_process_exit_noop_callback` | Empty callback used by the process-exit dispatch path. | +| `00472c37` | `win32_handle_table_register_thunk` | Registers a Win32 handle in the runtime handle table and returns its slot index. | +| `00472c3c` | `win32_handle_table_unregister_thunk` | Clears a runtime handle-table slot by index. | +| `00472c41` | `win32_runtime_capture_process_context` | Captures environment strings, module path, command line, and GetVersion fields, then initializes per-thread runtime context. | +| `00472d68` | `win32_runtime_startup_initialize` | Captures process context, establishes exception-chain metadata, runs a startup callback, and invokes final runtime initialization. | +| `00472dd0` | `memory_fill_bytes` | Fills a byte range with a repeated byte value, handling destination alignment, dword stores, and trailing bytes. | +| `00472e07` | `memory_fill_dwords` | Writes a repeated 32-bit value using alignment handling and unrolled dword stores. | +| `00472e74` | `runtime_event_resolve_next_record` | Resolves the next runtime event record, follows conditional records, and routes invalid record types through the error path. | +| `00472ebe` | `runtime_event_call_if_flag_clear` | Tests event-state flags against a mask and invokes the record callback only when those bits are clear. | +| `00472f08` | `runtime_event_interpreter_execute` | Interprets runtime event records, dispatching callbacks and control records, including conditional flow and nested frames. | +| `00473038` | `runtime_event_interpreter_thunk` | Thunk forwarding to the event interpreter with the current register-provided context. | +| `00473042` | `runtime_event_run_global_sequence` | Runs the event interpreter against the global runtime sequence at `00495c80`. | +| `00473067` | `runtime_heap_allocate_with_retry` | Scans runtime heap regions and retries allocation after requesting additional storage; returns null when no region can satisfy the request. | +| `00473156` | `string_vformat_emit` | Custom variadic formatter that emits literal characters and converted arguments through an output callback. | +| `004734f5` | `format_spec_parse_width_precision` | Parses field width, optional precision, and length modifiers; width and precision may be supplied as arguments. | +| `00473633` | `format_spec_parse_flags` | Parses the `-`, `#`, `+`, space, and `0` conversion flags. | +| `00473692` | `format_count_narrow_string_limited` | Counts narrow-string characters up to NUL or the active field-width limit. | +| `004736b6` | `format_count_wide_string_limited` | Counts 16-bit string characters up to NUL or the active field-width limit. | +| `004736d9` | `format_integer_zero_padded_width` | Formats an integer in decimal and fills leading positions with zeroes to meet the requested width. | +| `00473737` | `format_fixed_point_decimal` | Formats a signed fixed-point value with the requested decimal precision and rounds the final fractional digit. | +| `0047382c` | `format_emit_character_callback` | Emits one character through the configured formatter output callback. | +| `00473833` | `format_emit_argument_conversion` | Fetches conversion arguments, applies parsed width/precision and flags, and dispatches supported conversions. | +| `00473d1c` | `string_copy_uppercase_ascii` | Copies a NUL-terminated string while converting each ASCII character to uppercase. | +| `00473d34` | `input_callback_read_character` | Invokes the input-stream callback at offset zero to fetch the next character. | +| `00473d3b` | `input_callback_unread_character` | Invokes the input-stream callback at offset four to return or unread the current character. | +| `00473d43` | `input_vformat_scan` | Shared callback-backed scanf-style parser; matches literals and whitespace, parses conversion specifications, and dispatches input conversions. | +| `00473f8a` | `input_scan_spec_parse` | Parses assignment suppression, field width, allocation and length flags, and the conversion length modifier. | +| `0047407f` | `input_scan_skip_whitespace` | Consumes classified whitespace through the input callback, leaving the first non-whitespace character unread. | +| `004740be` | `input_scan_read_character_field` | Reads a bounded character field and stores byte or wide-character values when assignment is enabled. | +| `00474153` | `input_scan_read_string_field` | Reads a width-limited string field until whitespace or input exhaustion and terminates an assigned result. | +| `00474276` | `input_scan_store_consumed_count` | Stores the number of input characters consumed through the next variadic destination. | +| `004742d4` | `input_scan_build_character_class_bitmap` | Builds a character-membership bitmap from the conversion class up to its closing bracket. | +| `00474317` | `input_scan_read_character_class` | Reads a bounded character-class field, supports initial negation, and NUL-terminates an assigned result. | +| `00474411` | `input_scan_read_float_field` | Collects a bounded signed decimal/fraction/exponent token, converts it, and stores the result using the requested width. | +| `00474728` | `input_scan_read_integer_field` | Parses a signed integer field, recognizes radix prefixes where applicable, and stores the result at the requested width. | +| `00474918` | `ascii_digit_to_hex_value` | Converts an ASCII decimal or hexadecimal digit to its value; returns 16 for bytes outside those ranges. | +| `0047493f` | `input_callback_read_with_width` | Reads one callback character while decrementing field width; returns -1 when width is exhausted or input ends. | +| `00474af1` | `runtime_context_frame_push` | Initializes a temporary runtime frame from the current context and invokes the frame setup helper. | +| `00474b21` | `dbcs_adjust_offset_to_character_boundary` | Adjusts a byte offset to a DBCS character boundary by walking character starts up to the requested address. | +| `00474b5f` | `dbcs_byte_length_for_character_count` | Measures the byte span of up to the requested number of DBCS characters. | +| `00474dee` | `string_copy_dbcs_bounded_dispatch` | Adjusts a bounded source span to a DBCS character boundary, then copies it with zero padding. | +| `00474e0d` | `string_copy_dbcs_with_zero_padding` | Copies with zero padding; in DBCS mode it preserves character pairs and avoids ending on a lead byte. | +| `00474ec1` | `dbcs_read_character` | Reads one string character as a byte or a two-byte DBCS value when the first byte is a lead byte. | +| `00474f7e` | `heap_region_allocate_block` | Finds a suitably aligned free block, splits it when possible, and updates runtime heap metadata. | +| `00475026` | `heap_region_free_block_and_coalesce` | Returns a block to the runtime heap, coalesces adjacent free blocks, and updates free-list counters. | +| `00475131` | `ascii_lowercase_char` | Converts one ASCII uppercase letter to lowercase; disassembly confirms the operation where decompiler output is empty. | +| `0047513f` | `runtime_context_set_error_code_0d` | Stores fixed runtime error code `0x0d` in the current thread context; higher-level meaning is unresolved. | +| `00475144` | `runtime_context_set_error_code` | Stores the supplied runtime error code at offset `+4` in the current thread context. | +| `00475152` | `runtime_context_set_error_code_0e` | Stores fixed runtime error code `0x0e` through the shared context setter. | +| `00475169` | `runtime_context_set_aux_error_value` | Stores the supplied auxiliary error value at offset `+8` in the current thread context. | +| `0047519b` | `win32_file_open_with_mode_flags` | Opens through `CreateFileA`, registers the resulting handle, and returns its runtime handle-table index. | +| `00475352` | `file_object_allocate_and_link` | Allocates and initializes a runtime file/object record, then links it into the active list. | +| `0047540a` | `runtime_object_release_to_free_pool` | Removes a matching runtime object from the active list, marks it released, and links it into the free pool. | +| `00475461` | `file_stream_update_buffer_cursor` | Repositions the buffered cursor when the offset is in range; otherwise resets it and signals an OS seek. | +| `004754a3` | `file_stream_seek` | Reconciles buffered state or flushes output before `SetFilePointer`; returns a failure sentinel on error. | +| `00475597` | `file_stream_initialize_mode_state` | Initializes file-stream state from its runtime descriptor and applies the observed mode-flag updates. | +| `004755d9` | `file_stream_vformat_write` | Formats variadic output through the stream callback, flushes when required, and restores status bits. | +| `0047566a` | `win32_get_current_process_id` | Wrapper for `GetCurrentProcessId`. | +| `00475674` | `file_stream_flush_buffer` | Writes pending stream data to the backing file, updates buffer state, and marks errors. | +| `0047575e` | `file_stream_get_position` | Gets the backing file position and adjusts it for buffered read/write offsets. | +| `004757af` | `win32_file_set_pointer` | Calls `SetFilePointer` for a registered handle and records the runtime error on failure. | +| `004757e9` | `win32_file_close_handle` | Closes a registered Win32 handle through the configured path and clears its runtime handle entry. | +| `00475858` | `win32_delete_file_a_thunk` | Calls `DeleteFileA` and records the Win32 error when deletion fails. | +| `0047594e` | `runtime_math_domain_error_dispatch` | Argument-forwarding wrapper to the math-error path, called by the checked x87 log2 routine. | +| `0047598a` | `local_time_record_read_system_time` | Reads `GetLocalTime` into the runtime calendar record and returns milliseconds. | +| `004759ef` | `local_time_record_to_timestamp` | Normalizes calendar fields, accounts for leap days and runtime timezone adjustments, and returns a timestamp or -1. | +| `00475b43` | `runtime_debug_break_if_enabled` | Executes an INT 3 breakpoint when the runtime debug-break flag is enabled; otherwise returns zero. | +| `00475b69` | `runtime_fatal_write_message_and_exit` | Writes the fatal message to the error-output handle, performs exception cleanup, and terminates the process. | +| `00475ba0` | `runtime_fatal_error_dispatch` | Attempts the configured debug break and otherwise routes to fatal output and process termination. | +| `00475be1` | `runtime_exception_dispatch_result_check` | Returns false for signal-dispatch status values 2 or 3 and true for other results. | +| `00475c16` | `runtime_exception_slots_are_idle` | Tests two thread-context exception status fields for values other than 2 and 3. | +| `00475c81` | `runtime_console_ctrl_handler_unregister` | Unregisters the installed console control handler and reports whether it is inactive. | +| `00475cbd` | `runtime_control_signal_dispatch` | Dispatches a control signal through the current thread's handler table and updates runtime state. | +| `00475cf6` | `runtime_thread_signal_handler_invoke` | Invokes the current thread's signal handler unless its slot contains a default/special sentinel. | +| `00475e22` | `runtime_thread_signal_table_initialize` | Copies global default signal-handler entries into the current thread's runtime context table. | +| `00475e4f` | `runtime_default_signal_handler_noop` | Empty default callback used as a runtime signal-handler target. | +| `00476220` | `win32_exception_handler_install` | Links a stack-based structured-exception frame into FS:[0] and assigns the runtime handler. | +| `0047625e` | `win32_exception_handler_remove` | Restores the prior FS:[0] frame, clears the context pointer, and resets idle signal/control state. | +| `004762ad` | `win32_handle_table_is_full` | Checks the registered-handle table capacity and searches for an empty slot. | +| `004762f2` | `win32_handle_table_register` | Registers a Win32 handle, expands the table when needed, and returns its slot index. | +| `00476407` | `win32_handle_table_unregister` | Clears an in-range handle-table slot. | +| `00476433` | `win32_standard_handle_table_initialize` | Initializes the handle table and registers standard input, output, and error handles. | +| `0047646a` | `win32_custom_handle_next_id` | Increments and returns the identifier used by the custom Win32 handle path. | +| `0047647d` | `win32_file_state_close_handles` | Closes the stored Win32 handle when present and clears associated object fields. | +| `00476530` | `runtime_recursive_mutex_acquire` | Lazily creates and acquires the mutex, records its owner thread, and increments the recursive lock count. | +| `00476592` | `runtime_recursive_mutex_release` | Decrements the recursive mutex count and releases the Win32 mutex when it reaches zero. | +| `004765d7` | `win32_runtime_thread_context_create` | Creates or initializes the current thread runtime context and records the current thread ID. | +| `00476616` | `win32_tls_alloc_with_win9x_guard` | Allocates a TLS index and, on Win9x, retries indices below 3 to avoid reserved slots. | +| `00476662` | `win32_runtime_thread_context_create_and_set_tls` | Creates and validates the current thread context, then stores it in the allocated TLS slot. | +| `004766af` | `win32_runtime_thread_context_destroy_current` | Releases the current thread's TLS context and optionally closes its associated Win32 handle. | +| `00476726` | `win32_runtime_support_initialize` | Initializes runtime callback pointers, the mutex, initial thread context, and context accessor. | +| `004768aa` | `runtime_strdup_with_retry` | Allocates space through the runtime heap retry helper and copies a string including its terminator. | +| `004768f0` | `runtime_startup_callback_dispatch` | Invokes pending startup callbacks by priority and marks each table entry complete. | +| `0047693b` | `runtime_process_exit_callback_dispatch` | Invokes eligible process-exit callbacks in priority order and marks each entry complete. | +| `0047698c` | `runtime_event_record_resolve` | Resolves runtime event-record size/position through a dispatch entry selected by record type. | +| `004769ba` | `runtime_event_cursor_initialize` | Initializes an event cursor from the supplied record/source and calls its type-specific setup routine. | +| `004769db` | `runtime_event_cursor_retreat` | Moves the runtime event cursor backward by one record-unit step. | +| `004769e0` | `runtime_event_cursor_find_predecessor` | Walks backward through event records, follows conditional branches, and returns a matching predecessor. | +| `00476a65` | `runtime_event_cursor_find_next_record` | Advances through event records, follows conditional branches, and routes unsupported types to the fatal path. | +| `00476af8` | `runtime_event_mark_frame_complete` | Marks the current event frame complete, sets its flag, and invokes its cleanup callback. | +| `00476b0f` | `runtime_event_stack_corruption_fatal` | Sets the stack-corruption diagnostic and enters the runtime event fatal-error path. | +| `00476be3` | `runtime_function_exception_specification_violation` | Sets the exception-specification violation diagnostic, dispatches a handler if present, then enters the fatal path. | +| `00476c1f` | `runtime_event_record_get_payload` | Returns the current event payload, skipping its leading tag byte for the tagged form. | +| `00476cd0` | `runtime_exception_event_action_interpret` | Interprets encoded exception/event actions, updates the active frame, and uses `RtlUnwind` as needed. | +| `0047738c` | `runtime_virtual_region_register` | Inserts a virtual region into an address-sorted doubly linked list and initializes its metadata. | +| `00477400` | `runtime_virtual_region_allocate` | Allocates and registers a page-backed virtual region, then initializes its metadata. | +| `00477490` | `runtime_heap_virtual_region_fallback` | Computes a rounded region size and attempts VirtualAlloc as a fallback for runtime heap allocation. | +| `004774a1` | `runtime_virtual_region_round_size` | Rounds a requested region size for metadata overhead, configured minimums, and page allocation. | +| `004774eb` | `runtime_allocation_failure_return_zero` | Returns zero as the allocation-failure fallback callback. | +| `004774ee` | `runtime_fatal_error_callback` | Forwards the runtime error state to the fatal-error dispatcher. | +| `00477525` | `runtime_uint_to_base_string` | Formats an unsigned integer as a NUL-terminated string in the selected radix. | +| `0047756f` | `runtime_signed_int_to_base_string` | Adds a minus sign for negative decimal values, then formats the integer in the selected radix. | +| `0047758a` | `runtime_decimal_to_float32_bits` | Converts the parsed decimal mantissa/exponent representation to IEEE-754 single-precision bits. | +| `004777d0` | `runtime_event_record_get_length` | Returns the payload length for an encoded event-record tag, routing invalid tags to the fatal path. | +| `00477814` | `runtime_context_exception_frame_link` | Links a runtime exception/context frame into the global frame chain and returns runtime state. | +| `0047783a` | `dbcs_decode_next_character` | Decodes the next character through the active multibyte lead-byte table and advances one or two bytes. | +| `0047793f` | `dbcs_previous_character_boundary` | Finds the previous character boundary, accounting for multibyte lead/trail-byte pairs. | +| `00477a31` | `win32_open_mode_to_access_flags` | Maps runtime open modes to Win32 generic read/write access and the associated share-mode value. | +| `00477a5d` | `win32_open_mode_to_creation_disposition` | Maps runtime open/create mode bits to the CreateFile creation-disposition value. | +| `00477a97` | `win32_last_error_set_runtime_status` | Stores a Win32 error in runtime context and maps it to a runtime error code. | +| `00477ae8` | `win32_last_error_to_runtime_status` | Reads GetLastError and forwards it to the runtime error-code mapping helper. | +| `00477af7` | `win32_handle_is_character_device` | Tests whether a registered Win32 handle is FILE_TYPE_CHAR and releases temporary handle access. | +| `00477b38` | `win32_handle_table_get` | Retrieves a registered handle and lazily records character-device state for standard handles. | +| `00477b8d` | `win32_handle_table_set_flags` | Updates the registered handle entry's runtime mode/status flags. | +| `00477ba2` | `win32_file_get_current_position` | Queries the file position with SetFilePointer(FILE_CURRENT) and records errors on failure. | +| `00477cbf` | `file_stream_write_character` | Writes one character to a buffered stream, handles newline translation, and flushes when stream flags or buffer capacity require it. | +| `00477d82` | `file_stream_initialize_buffer` | Selects a buffer size from stream mode flags and allocates or configures the stream buffer. | +| `00477df9` | `win32_file_write_buffer` | Writes pending bytes to a Win32 file handle, handles append mode, and maps short writes or API failures to runtime status. | +| `00477e9f` | `file_stream_flush_buffered_data` | Flushes buffered output or synchronizes the file position, then resets stream pointers and records errors. | +| `00477eaf` | `win32_delete_file_a` | Calls DeleteFileA and translates a Win32 failure into runtime error status. | +| `00477edd` | `runtime_thread_stack_update_and_measure` | Reads current-thread stack bounds, updates the tracked boundary when needed, and returns a stack-distance value. | +| `00477f0c` | `runtime_heap_initialize_region_size` | Sets the runtime region-size global to `0x8000` during startup. | +| `00477f18` | `runtime_math_fpu_control_dispatch` | Forwards a math/FPU control request to the floating-point status dispatcher. | +| `00477f22` | `runtime_fpu_apply_control_flags` | Maps floating-point exception/control bits to runtime categories and dispatches the resulting math status. | +| `00477ffd` | `runtime_is_leap_year` | Applies the Gregorian 4/100/400-year rule and returns whether the supplied year is a leap year. | +| `00478038` | `runtime_timezone_rule_day_of_year` | Converts a timezone transition-rule record to a zero-based day-of-year position, accounting for leap years and rule format. | +| `0047811d` | `runtime_timezone_transition_rule_compare` | Orders transition rules by year and then by their computed day-of-year positions. | +| `00478151` | `runtime_timezone_daylight_rule_active` | Tests a calendar record against the configured daylight-transition interval and stores the active-state result. | +| `00478414` | `runtime_calendar_fields_compare` | Compares calendar fields lexicographically in year, month, then day order. | +| `00478444` | `timestamp_to_calendar_record` | Applies a seconds offset to a timestamp and fills the calendar record's time, date, weekday, and year fields. | +| `004786d8` | `runtime_timezone_initialize` | Initializes timezone names, offsets, and transition rules from the runtime setting or Windows timezone data. | +| `00478721` | `runtime_parse_decimal_component` | Consumes consecutive decimal digits from the input and stores the resulting integer. | +| `00478745` | `runtime_timezone_parse_name_and_offset` | Parses a timezone name and signed hour/minute/second offset, returning the first unconsumed character. | +| `0047886e` | `runtime_timezone_parse_transition_rule` | Parses a POSIX transition rule in Julian-day or month/week/weekday form, including an optional transition time. | +| `00478a46` | `runtime_control_signal_fatal_callback` | Routes the fatal control-signal callback to the runtime fatal-error dispatcher with status `0xff`. | +| `00478b56` | `runtime_heap_reallocate` | Handles null/free cases, attempts an in-place resize, and falls back to allocate-copy-free when the block must move. | +| `00478bd0` | `win32_runtime_thread_context_get_or_create` | Ensures the current thread has a runtime context in TLS, routing initialization failure to the fatal path. | +| `00478c07` | `win32_runtime_thread_context_register_cleanup` | Allocates and links cleanup metadata for a newly created thread context, retaining its pointer and cleanup flag. | +| `00478c68` | `win32_runtime_thread_context_unregister_cleanup` | Removes the current thread context's cleanup record and releases its optional owned allocation. | +| `00478cdb` | `runtime_heap_allocate_zeroed` | Allocates the requested runtime heap size and zero-fills it when allocation succeeds. | +| `00478cf8` | `runtime_event_cursor_test_record_flag` | Tests an indexed event-record flag using the runtime bit-mask table. | +| `00478d18` | `runtime_unhandled_exception_handler_thunk` | Thunk to the unhandled-exception path, which invokes a configured handler or performs fatal cleanup and exits. | +| `00478ff0` | `runtime_noop_callback` | Empty callback that returns without changing state. | +| `00479012` | `runtime_heap_reclaim_matching_virtual_regions` | Scans virtual-region metadata and releases matching region records before another virtual allocation. | +| `00479026` | `runtime_virtual_region_release_memory` | Calls VirtualFree and updates allocator globals and stale path metadata after successful release. | +| `00479084` | `runtime_virtual_region_release_record` | Releases a region's memory, then unlinks its record from the allocator's doubly linked list. | +| `00479681` | `file_stream_flush_matching` | Flushes pending output buffers for registered streams whose mode/status flags match the supplied mask. | +| `004796c7` | `runtime_math_error_format_output` | Formats and emits the runtime math-error diagnostic through configured output callbacks. | +| `0047970f` | `runtime_math_error_dispatch` | Invokes the configured math-error handler or emits the diagnostic and stores the corresponding runtime error code. | +| `0047973e` | `runtime_environment_find_value` | Searches the runtime environment-string table for a named variable and returns the value after `=`. | +| `0047979f` | `runtime_heap_block_get_usable_size` | Returns the usable allocation size recorded in the heap block header, excluding allocator metadata. | +| `004797a8` | `runtime_heap_resize_block_locked` | Acquires the runtime heap lock, resizes a block in place, and releases the lock. | +| `004797e2` | `runtime_heap_resize_block_in_place` | Coalesces following free blocks when growing or splits excess space when shrinking a heap block. | +| `00479980` | `runtime_zero_result_callback` | Returns zero as a no-op/default result callback. | +| `0047998a` | `runtime_configured_callback_dispatch` | Invokes the callback currently stored in the runtime callback slot. | +| `00479991` | `runtime_callback_dispatch_return_value` | Invokes the callback stored in `PTR_runtime_zero_result_callback_0047c648`, returning its value through the call result registers. | +| `004799d8` | `runtime_unhandled_exception_dispatch` | Invokes a configured unhandled-exception handler when present; otherwise removes exception state, runs fatal cleanup, and exits the process. | +| `00479a0d` | `runtime_unhandled_exception_fatal_fallback` | Forwards the no-handler unhandled-exception path to the runtime fatal-error handler. | +| `00479a41` | `runtime_exception_specification_fatal_handler` | Routes an exception-specification violation to the runtime fatal-error handler with status 1. | +| `00479f8e` | `runtime_math_error_default_handler_thunk` | Thunk to the default runtime math-error handler at `0047abab`. | +| `00479f93` | `runtime_math_error_message_by_index` | Returns a 26-byte runtime math-error message record for indices 0-3; larger indices produce null/zero. | +| `00479fb2` | `file_stream_write_c_string` | Writes a NUL-terminated string to a runtime stream, initializing its buffer as needed and flushing when requested. | +| `0047a040` | `string_compare_case_insensitive_ascii` | Compares two strings with ASCII case folding, stopping at a mismatch, NUL, or the supplied length. | +| `0047a213` | `runtime_thread_exit_dispatch` | Dispatches configured thread-exit cleanup, removes exception-handler state, conditionally destroys the runtime thread context, then calls `ExitThread(0)`. | +| `0047a420` | `runtime_extended_float_classify_helper` | Processes extended-precision floating-point fields with exponent/significand checks and runtime tables; exact status-bit meanings remain unresolved. | +| `0047abab` | `runtime_math_error_default_handler` | Default runtime math-error callback; returns zero without side effects. | +| `0047ae48` | `ExitThread` | Win32 import thunk for `ExitThread`. | +| `0047ae4e` | `CreateThread` | Win32 import thunk for `CreateThread`. | +| `0047ae54` | `CreateEventA` | Win32 import thunk for `CreateEventA`. | +| `0047ae5a` | `GetCurrentThread` | Win32 import thunk for `GetCurrentThread`. | +| `0047ae60` | `SetEvent` | Win32 import thunk for `SetEvent`. | +| `0047ae66` | `VirtualFree` | Win32 import thunk for `VirtualFree`. | +| `0047ae6c` | `RtlUnwind` | Win32 import thunk for `RtlUnwind`. | +| `0047ae72` | `GetTimeZoneInformation` | Win32 import thunk for `GetTimeZoneInformation`. | +| `0047ae78` | `DeleteFileA` | Win32 import thunk for `DeleteFileA`. | +| `0047ae7e` | `GetFileType` | Win32 import thunk for `GetFileType`. | +| `0047ae84` | `GetLastError` | Win32 import thunk for `GetLastError`. | +| `0047ae8a` | `VirtualAlloc` | Win32 import thunk for `VirtualAlloc`. | +| `0047ae90` | `TlsFree` | Win32 import thunk for `TlsFree`. | +| `0047ae96` | `TlsSetValue` | Win32 import thunk for `TlsSetValue`. | +| `0047ae9c` | `TlsAlloc` | Win32 import thunk for `TlsAlloc`. | +| `0047aea2` | `TlsGetValue` | Win32 import thunk for `TlsGetValue`. | +| `0047aea8` | `ReleaseMutex` | Win32 import thunk for `ReleaseMutex`. | +| `0047aeae` | `WaitForSingleObject` | Win32 import thunk for `WaitForSingleObject`. | +| `0047aeb4` | `CreateMutexA` | Win32 import thunk for `CreateMutexA`. | +| `0047aeba` | `GetCurrentThreadId` | Win32 import thunk for `GetCurrentThreadId`. | +| `0047aec0` | `GetStdHandle` | Win32 import thunk for `GetStdHandle`. | +| `0047aee4` | `SetConsoleCtrlHandler` | Win32 import thunk for `SetConsoleCtrlHandler`. | +| `0047aeea` | `WriteFile` | Win32 import thunk for `WriteFile`. | +| `0047aef0` | `GetLocalTime` | Win32 import thunk for `GetLocalTime`. | +| `0047aef6` | `CloseHandle` | Win32 import thunk for `CloseHandle`. | +| `0047aefc` | `SetFilePointer` | Win32 import thunk for `SetFilePointer`. | +| `0047af02` | `GetCurrentProcessId` | Win32 import thunk for `GetCurrentProcessId`. | +| `0047af08` | `CreateFileA` | Win32 import thunk for `CreateFileA`. | +| `0047af14` | `GetModuleHandleA` | Win32 import thunk for `GetModuleHandleA`. | +| `0047af1a` | `GetVersion` | Win32 import thunk for `GetVersion`. | +| `0047af20` | `GetCommandLineA` | Win32 import thunk for `GetCommandLineA`. | +| `0047af26` | `GetModuleFileNameA` | Win32 import thunk for `GetModuleFileNameA`. | +| `0047af2c` | `GetEnvironmentStrings` | Win32 import thunk for `GetEnvironmentStrings`. | +| `0047af32` | `ExitProcess` | Win32 import thunk for `ExitProcess`. | +| `0047af56` | `WINNLSEnableIME` | Win32 import thunk for `WINNLSEnableIME`. | +| `0047af5c` | `DirectSoundCreate` | DirectSound import thunk for `DirectSoundCreate`. | +| 2026-10-12 | 1,486 / 1,493 (99.5%) | 7 (0.5%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the next 20 report-listed Win32 import thunks from `0047ae7e` through `0047af14`. | + +Readbacks confirmed DBCS-aware path/file helpers and heap/exit paths in the first slice, resource and Win32 runtime helpers in the second, event interpretation, heap allocation, and custom formatting/input callbacks in the third, scanf-style conversions, DBCS string handling, runtime frames, and heap block management in the fourth, runtime error state, file streams, Win32 file operations, and local-time records in the fifth, timestamp conversion, runtime signal/exception handling, handle-table operations, and mutex acquisition in the sixth, TLS contexts, callback dispatch, event records, exception actions, and virtual-region tracking in the seventh, virtual-region allocation, numeric conversions, DBCS navigation, file-mode mapping, and Win32 handle operations in the eighth, buffered stream output, stack/FPU support, calendar conversion, and POSIX timezone parsing in the ninth, heap reallocation, thread-context cleanup, virtual-region management, environment parsing, and math-error reporting in the tenth, exception dispatch, case-insensitive comparison, floating-point helper logic, and Win32 import thunks in the eleventh, additional Win32 runtime API imports in the twelfth, and final Win32/DirectSound import thunks in the thirteenth. The float helper's exact status-bit meanings remain unresolved. All 247 entries in this section have descriptive names and decompiler comments. Ghidra edits remain pending; executable bytes were not changed and the project was not saved. +| 2026-10-12 | 1,493 / 1,493 (100.0%) | 0 (0.0%) | 336,693 / 499,712 (67.4%) | 399,698 / 499,712 (80.0%) | Added the final 7 report-listed imports from `0047af1a` through `0047af5c`; the exact-entry ledger now covers every executable function. | + +## Address-Ordered Pass: Timed Processes, String Tables, and Item Selection + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004643cc` | `timer_process_accumulate_global_elapsed_ticks` | Updates the global timer object's accumulated elapsed value in 10 ms units and advances its last-sample timestamp. | +| `0046440c` | `timed_item_process_construct` | Constructs process type 10, associates the supplied item number, seeds its elapsed-time fields from the global timer, and initializes process flags. | +| `004644a0` | `timed_item_process_update` | Updates the global timer state, stores the elapsed value on this process, then invokes a timer-state helper. | +| `004646b0` | `string_table_construct` | Initializes the string-table object's vtables, counters, capacity, and entry-index array. | +| `00464840` | `string_table_load_from_stream` | Reads and terminates stream contents, allocates per-entry storage and an index array, then parses string records. Identifiers and record semantics are not fully recovered. | +| `00464b9c` | `string_table_clear_entries` | Frees each allocated entry, then releases the entry array and auxiliary buffer. | +| `00464c14` | `string_table_initialize_entries` | Reinitializes entry and index arrays for the supplied mode/count, initializes index order, and seeds records with the string `INVALID`. | +| `00464d48` | `string_table_write_selected_entries` | Builds an output buffer from selected entries and writes it at offset zero through `file_stream_insert_at_offset`. | +| `00464e60` | `string_table_sort_entries_by_key` | Compares entry strings and sorts by swapping entry pointers and their associated index values. | +| `00465120` | `text_overlay_construct` | Constructs a text-overlay object and uses the DBCS-aware multiline text-width helper to store measured dimensions and flags. | +| `00465300` | `tracked_item_id_set_initialize` | Allocates and zeroes a 100-element 16-bit item-ID array, resetting the tracked count. | +| `0046537c` | `tracked_item_id_set_release` | Frees the tracked-ID array and resets its capacity and count globals. | +| `004653ac` | `tracked_item_id_set_add` | Inserts the incoming ID in the first empty slot when capacity is available and increments the active count. | +| `0046540c` | `tracked_item_id_set_remove` | Finds the incoming ID, clears its slot, and decrements the active count. | +| `00465468` | `tracked_item_find_nearest_in_direction` | Searches tracked items in 8-way or 16-way direction, applies item/shape and overlap filters, and returns the nearest qualifying ID within the observed bound. | +| `004656dc` | `position_state_dispatch_for_nearby_items` | Begins a rectangular item query around the supplied position, filters results, and dispatches the requested position state for qualifying items. | +| `004658b8` | `tracked_item_id_set_save` | Writes tracked-ID capacity, active count, and the 16-bit ID array through the supplied stream object's write method. | +| `004659a0` | `resource_buffer_load` | Allocates a 0x4800-byte working area and initializes/loads resource-backed data through file/resource helpers. The resource's higher-level role remains unresolved. | +| `00465a68` | `resource_buffer_release` | Releases the object's working buffer and resource handle, clearing both fields. | +| `00465b54` | `fixed_record_copy_by_index` | Copies one fixed 9-byte record selected by index from the object's record array to the output buffer. | + +Decompiler and disassembly readbacks confirmed the timer, string-table, tracked-ID, spatial-selection, and fixed-record operations. All 20 entries are listed at exact function-entry addresses with descriptive names and decompiler comments. Ghidra changes remain pending; no executable bytes were changed and the project was not saved. + +## Verified Batch: Process Startup + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00429d44` | `init_scheduler_and_animation_processes` | High confidence. Called at `0046647c` in the startup initialization sequence. Lazily allocates the global scheduler and animation process objects using constructors that set process types `0x245` and `0x230`, respectively. | + +## Verified Batch: Process Kernel + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00457740` | `Process_InitBase` | High confidence. Initializes common fields on a preallocated process object, installs the base vtable, assigns initial fields, inserts it into the kernel table, and runs a post-insert hook. Many specialized process constructors call it before replacing the vtable/type. | +| `0043cb64` | `kernel_process_table_insert` | High confidence. Finds an unused global process-table slot, expands/retries when needed, stores the process pointer and ID, and increments the live count. | +| `0043d450` | `kernel_process_find_first` | High confidence. Starts a stateful table iterator at slot 3 with process-type and item/selector filters, skips entries with flag bit 3 set, and returns the first match. | +| `0043d4e0` | `kernel_process_find_next` | High confidence. Continues the iterator with the stored filters and cursor, returning the next eligible process or null. | +| `0043c0a0` | `kernel_process_manager_initialize` | High confidence. One-time initialization allocates process-table arrays and creates core process instances, then clears the initialization guard. | +| `0043db84` | `kernel_process_table_allocate` | High confidence. Allocates the process-pointer table, per-slot state arrays, and process-filter bitmaps; asserts on required allocation failure. | +| `0043c110` | `kernel_process_manager_shutdown` | High confidence. Tears down eligible entries, performs a flagged-entry sweep, frees the table arrays and related buffers, and clears manager globals. | +| `0043d834` | `kernel_process_table_remove` | High confidence. Called by `Process_Terminate`; removes the specified slot, updates live/type counts, releases the object, and refreshes filter bits based on remaining processes. | +| `0043dd2c` | `kernel_process_shutdown_flagged_sweep` | High confidence for the observed filter only: during shutdown, processes with flag bit 1 set and bit 3 clear receive a virtual cleanup call and are released. The flag meanings are unknown. | +| `0043ddc0` | `kernel_process_prune_flagged_entries` | High confidence for the observed operation. Called during savegame-load reconstruction; if the pending-prune count is nonzero, frees entries from slot 3 onward with flag bit 3 set and decrements that count. | +| `0043e11c` | `kernel_process_manager_rebuild` | High confidence for the lifecycle role. Its only known caller is the savegame-load reconstruction path. It tears down eligible processes and manager buffers, allocates new tables, reconstructs process entries through virtual callbacks, then resets related event/input state. The saved-state format and individual callback contracts remain unresolved. | +| `0043c340` | `kernel_process_manager_update` | High confidence. Per-cycle process dispatch: visits eligible entries and calls their primary virtual callback, handles queued events, releases marked entries, updates the selected process-type state, and services timed records by enqueueing events and invoking callbacks. Individual flag semantics remain partly unresolved. | +| `0043efe0` | `kernel_process_manager_run_loop` | High confidence. The Win32 startup path calls this timed, non-returning loop. It samples the multimedia clock, invokes the process-manager update, optionally invokes a supplied callback, and updates elapsed-time state before repeating. | +| `0043fbb4` | `kernel_process_mark_item_id_presence` | High confidence. Sets the bit for a process-associated item ID in `DAT_0048432c`; called by `Process_SetItemNo`. | +| `0043fc10` | `kernel_process_refresh_item_id_presence` | High confidence. Scans for another live process using the item ID, excluding entries with flag bit 3 set, then sets or clears that item's presence bit. | +| `0043fd18` | `kernel_process_mark_item_type_presence` | High confidence. Sets the process-type bit in the per-item bitmap `DAT_00484330`; called for item-associated processes in the observed type range `0xf0`-`0xf7`. | +| `0043fd6c` | `kernel_process_refresh_item_type_presence` | High confidence. Scans for a live process matching both item ID and process type, excluding entries with flag bit 3 set, then updates the corresponding per-item type bit. | +| `0043fe50` | `kernel_process_item_type_present` | High confidence. Tests the per-item process-type bitmap `DAT_00484330` for a given item ID and process type; used by object-placement/selection checks. | + +The function-boundary analyzer had split the timed loop: `0043efe0` held only its prologue while `0043f007` was incorrectly marked as a function entry at an internal loop target. The false entry was removed and the contiguous body was recreated as `kernel_process_manager_run_loop` (`0043efe0`-`0043f035`); instruction bytes were not changed. + +These helpers establish a JP process table, first/next query API, per-cycle dispatcher, timed run loop, item-association presence indexes, and explicit manager initialization, shutdown, removal, pruning, and savegame-load rebuild paths. The process record layout and flag semantics are only partially recovered; names describe the observed operations, not higher-level process behavior. + +## Verified Batch: Process Direction and Termination + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004538c0` | `process_update_direction_toward_target` | High confidence for the observed movement role. Reads the associated item's current X/Y through global item tables, delegates direction selection to `process_choose_direction_to_coords`, updates direction state, and dispatches vtable slot `+0x08` on arrival or terminal movement conditions. | +| `00453c64` | `process_choose_direction_to_coords` | High confidence for direction selection and the visible special paths. Tests candidate 8-way directions and updates direction/turn state; returns `0x10` under a packed-state condition. Its `0xff` path checks a process of type `0x259`, a nonzero record word at `+0x64`, item-bounds overlap, and a location test before calling `item_action_process_dispatch` with selector `0` and threshold `10000`, setting process byte `+0x7d` to 1, and updating bytes `+0x4a`/`+0x49`. Its `DebugBreak` sites are gated by `DAT_004955e8`. | +| `00453b10` | `process_pre_termination_update` | High confidence for observed operations, not the flag meanings. Clears bit `0x20` in a record byte at `+0x59`, then gates follow-up on fields `+0x47`, `+0x12`, `+0x49`, `+0x4a`, global `DAT_00482b78`, and associated-item/status checks. May call `item_action_process_dispatch` with selectors `0` or `4`. Called by both wrappers below. | +| `00453c3c` | `process_check_state_then_terminate` | High confidence for call order: runs `process_pre_termination_update`, then calls the existing `Process_Terminate` entry. | +| `00453c50` | `process_check_state_then_terminate_and_remove` | High confidence for call order: runs `process_pre_termination_update`, then calls `process_terminate_set_flag_20`, whose body reaches cleanup callbacks and `kernel_process_table_remove`. | +| `00458980` | `Process_Terminate` | Existing symbol. The entry clears bit `0x20` in byte `+0x14` before entering the shared cleanup path. Boundary ownership needs review: Ghidra reports a body spanning `00457ce5`-`00458b8b`, overlapping the preceding function range. | +| `00458990` | `process_terminate_set_flag_20` | Medium confidence as a separate entry. Sets bit `0x20` in byte `+0x14`, initializes `+0x10` from the second argument when unset, then reaches shared termination processing. Ghidra records a separate 16-byte body here while `Process_Terminate`'s reported body overlaps it; confirm the function boundary before treating these as independent complete routines. | +| `0040dfa0` | `process_set_byte_7d_one` | High confidence for the exact write. The sole observed caller is `process_choose_direction_to_coords`, which passes its process-object register; the helper writes `1` to byte `+0x7d`. The field's meaning is unresolved. | +| `00435148` | `item_shape_bounds_overlap_rect` | High confidence. Builds an item's shape bounds from position/shape data and tests them against the rectangle at `DAT_00495820`. Corrected the prototype from `void` to `bool` after confirming callers consume the low byte as a boolean. | +| `00459690` | `rectangles_overlap` | High confidence. Tests two axis-aligned four-short rectangles for inclusive overlap. Its three direct callers test the low byte as a boolean; the prototype is now `bool`. | + +The `0xff` branch also compares the process field at `+0x02` with `DAT_0047b1d6`, calls `kernel_process_find_first` for type `0x259`, reads that record's `+0x64` word, and requires both `item_shape_bounds_overlap_rect` and `target_position_query_from_packed_records` to pass. Once these checks succeed it calls `item_action_process_dispatch` with selector `0` and threshold `10000`, sets byte `+0x7d` through `process_set_byte_7d_one`, then updates bytes `+0x4a` and `+0x49`. The exact role of `DAT_0047b1d6`, the type-`0x259` record, state bytes, and individual action selectors remains open. Function and prototype edits are pending in the live JP Ghidra project; executable bytes were not changed. + +## Verified Batch: Position Queries and Distance Helpers + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00468288` | `max_axis_delta_3d` | High confidence. Returns the maximum absolute difference across three coordinate components. `0041bb7c` rounds this result upward in 16-unit steps and accepts values through `0x30`; other callers include attack and position-checking paths. | +| `004682ec` | `max_axis_delta_2d` | High confidence. Returns the maximum absolute difference across two coordinate components. Used by target-position logic including `0041b798`; it is an axis-max measure, not Euclidean distance. | + +The two position-query routines now have operation-level Ghidra names and comments recording their caller sets and observed checks. `target_position_query_from_packed_records` walks nonempty packed records and tests candidate offsets; `target_position_query_within_axis_threshold` applies a mode-4 spatial query and 3D axis-distance threshold. Their packed-record fields, exact success criteria, and coordinate units remain unresolved. + +## Verified Batch: Windows Keyboard/Event Input + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043f060` | `input_event_state_reset` | High confidence. Drains the pending 32-entry event ring, clears two 256-entry event tables and the ring records, resets input counters, then synchronizes the Caps Lock toggle through `GetKeyState(VK_CAPITAL)`. | +| `0043f334` | `input_keyboard_event_update` | High confidence. Called from Windows message-dispatch paths. Updates per-key press/timing state and modifiers, maps selected keypad/navigation keys, translates characters with `GetKeyboardState`/`ToAscii`, queues an event record, and dispatches eligible listeners. | +| `0043f7fc` | `input_keyboard_key_state_get` | High confidence for the read operation: returns a tracked 16-bit field from a two-dimensional key table. Gameplay and cancellation paths use it as a nonzero key-state check; the full index protocol remains unresolved. | +| `0043f9f4` | `kernel_process_dispatch_queued_events` | High confidence. Drains queued event records and sends them to registered process listeners matching the type filter, listener flag bit `0x10`, and process flag bit `0x100` clear. The meaning of the flags remains unknown. | +| `004403e4` | `keyboard_process_create` | High confidence. Creates the singleton keyboard process, installs `g_keyboardProcessFnPtrs`, sets process type `7`, and runs initialization helpers. Its sole known caller is `kernel_process_manager_initialize`. | + +The paired sweep at `0043f190` also calls listener vtable method `+0x28`, but selects processes with flag bit `0x100` set. Its distinct listener group is not yet understood. + +## Verified Batch: Windows Startup and Window Lifecycle + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `004729e0` | `entry` | PE entry point, confirmed by Ghidra's external-entry-point metadata. Its first instructions store `win32_game_main` (`00446250`) at `DAT_00495ccc` and jump to `0047585d`, where the runtime startup path eventually invokes the stored callback indirectly at `0047593c`. Ghidra currently includes that runtime path in an oversized `entry` body (`004729e0`-`0047594d`); `0047585d` is an internal label, not a separate defined function. | +| `00446250` | `win32_game_main` | High confidence. Installed as the startup callback by the PE entry routine. Checks joystick status, may show dialog resource `0x71`, stores the module instance, creates the main window, initializes DirectDraw/DirectSound, and enters the process-manager run loop. Startup parameter meanings remain partly unresolved. | +| `00445f40` | `win32_create_main_window` | High confidence. Registers `win32_main_window_proc`, creates a fullscreen popup titled `Crusader: No Remorse`, disables IME, and registers `MSWHEEL_ROLLMSG`. | +| `004459b0` | `video_init_directdraw_and_directsound` | High confidence. Creates DirectDraw, sets cooperative level and 640x480 display mode, creates the palette and primary surface, then initializes DirectSound. | +| `00445ba8` | `win32_main_window_proc` | High confidence for callback registration and message families. Handles `WM_DESTROY` resource release and quit posting, activation/device-state handling, keyboard input, mouse-event dispatch, and the registered mouse-wheel message. Ghidra currently models two register placeholders before the four stack callback arguments; the WNDPROC registration and `RET 0x10` establish the actual four-argument callback shape. | +| `004453d0` | `win32_shutdown_message_loop` | High confidence. Destroys the main window, then runs `GetMessageA`/`TranslateMessage`/`DispatchMessageA` until `WM_QUIT`, where it invokes the runtime shutdown path. This is a shutdown/close-path loop, not the steady-state game loop. | + +The `WM_CLOSE` path reaches `0046429c`, whose callback/reentrancy contract is not yet clear. DirectX error helpers at `00445648` and `00445778` show recoverable versus fatal window/error handling, but remain unnamed until the error-string and restoration contracts are separated. These findings confirm native Windows lifecycle behavior; they do not establish a JP-versus-Western behavioral difference. + +The verified startup call chain is `entry` (`004729e0`) -> runtime startup at internal label `0047585d` -> indirect callback through slot `00495ccc` to `win32_game_main` (`00446250`) -> `kernel_process_manager_run_loop` (`0043efe0`). Direct xrefs confirm the callback call at `0047593c` and the loop call at `004462f4`. During startup, `win32_game_main` calls `win32_create_main_window` (`00445f40`) at `004462a1` and `video_init_directdraw_and_directsound` (`004459b0`) at `004462b6`. The non-returning process loop repeatedly invokes `kernel_process_manager_update` (`0043c340`) at `0043effb`. All six defined functions in this chain already have descriptive Ghidra names; no rename was needed. Ghidra currently includes the runtime path in an oversized `entry` body (`004729e0`-`0047594d`); `0047585d` is an internal label, not a separate defined function. + +## Verified Batch: Item State Lifecycle + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00438a30` | `item_property_arrays_allocate` | High confidence. Allocates the per-item arrays for x/y/z, shape, flags, linked-item ID, and other fields. Called by `FUN_00436dd0`, which initializes the item free list and ID ranges. | +| `00438c24` | `item_property_arrays_free` | High confidence. Releases and clears those arrays; called by `FUN_00436f80` during teardown. | +| `00438d58` | `item_record_from_property_arrays` | High confidence for direction and copied fields. Copies one item ID's x/y/z, shape, flags, linked-item ID, and related bytes/words into a 16-byte record. Some field meanings are still unknown. | +| `00438dec` | `item_property_arrays_from_record` | High confidence for direction and copied fields. Copies the record fields into the selected item's global property arrays and derives one extra byte from shape data when available. | +| `00431f2c` | `item_create_from_shape_id` | High confidence. For shape IDs below `0x800`, allocates a free item ID, writes the shape and shape-derived defaults, and reports success; invalid shape IDs clear the output ID and fail. Used by item wrappers, restore code, and the JP cheat handler. | +| `00438ec4` | `item_restore_core_record` | High confidence for observed behavior. Restores the reserved item ID `1` from the snapshot's core record while clearing flags and two extra fields. | +| `00438f44` | `item_restore_shape_record` | High confidence for observed behavior. Creates an item from the saved shape ID, then copies shape-derived fields into the item arrays. | +| `00429240` | `snapshot_item_state` | High confidence. Stores selected item records and linked-item search results in `DAT_00482678` before the item subsystem is torn down. | +| `00429428` | `restore_item_state` | High confidence. Rebuilds the selected items and global arrays from that buffer, then frees the snapshot. | + +The transaction call sequence at `00429617` is `snapshot_item_state`, item-array teardown, subsystem reinitialization, then `restore_item_state` at `00429630`. The surrounding operation is not yet identified, so this is documented as item-state preservation across reinitialization rather than assumed to be a level transition. The 16-byte record's full schema and the linked-item selection criteria remain open. + +## Verified Batch: Spatial Search + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `00439420` | `search_selector_collect_rect_candidates` | High confidence. Traverses grid buckets and each bucket's linked item chain, appending IDs whose x/y coordinates are inside the inclusive rectangle to `DAT_00482b40`, then writes a zero terminator. | +| `0043b150` | `search_selector_begin_rect_query` | High confidence. Clamps/stores rectangle bounds, derives grid-cell bounds by shifting coordinates right 9 bits, invokes the collector, and initializes the selector cursor to the first candidate. Callers include `FUN_004129a0`, `FUN_0042a65c`, `FUN_00448174`, and `FUN_004656dc`. | + +The adjacent selector scan routines apply exact-shape, shape-family, shape-set, two-shape, or bounds-only filtering while walking the same grid buckets and item linked lists. `search_selector_next_spatial_match` dispatches to those filters based on selector mode. This establishes a JP spatial-search implementation path, but not a difference from Western retail; the selector record layout and coordinate units still need cross-build comparison. + +## Verified Batch: Direction Quantization + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043b328` | `direction_8way_from_delta` | High confidence. Classifies signed X/Y deltas into eight direction sectors encoded as even values `0..14`; returns `16` for a zero vector. Called by NPC adjacency logic and other movement/process paths. | +| `0043b414` | `direction_16way_from_delta` | High confidence. Classifies signed X/Y deltas into sixteen sectors encoded as `0..15`; returns `16` for a zero vector. Used by the wrapped-direction selector and other process/input paths. | +| `0043b270` | `choose_nearest_wrapped_direction` | High confidence. Uses the eight-way quantizer for period `8`, otherwise the sixteen-way quantizer, then chooses the closer of two candidate directions under modular wraparound. Callers include `AttackProcess_Run` and `FUN_0040ce6c`. | + +`npc_process_check_target_adjacent` uses the eight-way result to compare the target's relative direction with adjacent direction values. The encoding and behavior are verified for JP; no Western direction mapping has yet been performed. + +## Verified Batch: Joystick Input + +| JP address | Ghidra name | Evidence and confidence | +|---|---|---| +| `0043b5f4` | `joystick_process_ensure_or_reset` | High confidence. When the joystick-enabled global is set, creates the process if absent or resets its timing/button state fields if present. Called during saved-state subsystem reconstruction. | +| `0043b644` | `JoystickProcess_0043b644` | Existing constructor symbol confirmed by decompilation. Installs `g_joystickProcessFnPtrs`, sets process type `0x262`, initializes its state, and stores the global process pointer. | +| `0043b6d8` | `joystick_get_direction_flags` | High confidence. Polls joystick 0, reads calibrated axis ranges, and returns four directional bits for positions in the outer thirds; returns `-1` on polling failure. Used by `JoystickProcess_Run` and startup input code. | +| `0043b7dc` | `JoystickProcess_Run` | High confidence for the input paths. Polls joystick 0 with `joyGetPosEx` and disables the joystick global on polling or direction-sampling failure. In the default mode, configured button masks in `0047b9b2` and `0047b9c0`-`0047b9cc` select action IDs; IDs 4-8 build callback records carrying `u/g/s/m/e`, while action 9 maps direction flags to `q/w/i/o`. Other gameplay paths dispatch direction/control records through vtable `+0x28`. When process byte `+0x62` bit 0 is set, directions map to `<`/`>` and buttons to Enter/Escape with timed repeat handling. The action names, config-table schema, and meaning of the mode bit remain unresolved. | + +The adjacent startup routine `win32_game_main` at `00446250` also polls joystick direction, may set the enabled global or show a dialog, then creates the window and initializes DirectDraw/DirectSound. Its exact role within the wider startup call chain remains open. + +## Verified Batch: Debug and Test Switches + +| JP address | Switch/helper | Evidence and confidence | +|---|---|---| +| `00466774` | `handle_commandline_args_jp` | High confidence. The parser has a table-driven option list. `-debug` at `004811d2` selects the handler at `004668b4`, which prints `Debugging mode ON.`, writes `0x000a` to `DAT_00482620`, and sets bytes `DAT_004957d9` and `DAT_004957eb` to 1. | +| `00455eac` | `debug_mode_update_timeline_buffer` | High confidence for the buffer operation. Its caller checks `DAT_004957eb` before calling it. The helper builds and copies two 500-byte rows into a buffer reached through the object at `+0xfc` (base offset `+0x4ab78`), with marker values derived from object fields at `+0xeb`, `+0xef`, `+0xf3`, and `+0xf7`, scaled in 6000-unit steps. This confirms debug-gated timeline instrumentation; the meaning of each timestamp and how the buffer is presented remain unresolved. | +| `00466774` | `-laurie` special case | High confidence. Outside the option table, this token sets `g_wasLaurieSet` and `g_cheatsActive`, then prints `Cheats are active.` This is a separate cheat-enabling path, not evidence that the cheat strings belong to debug mode. | +| `00418454` | `key_check_jassica16_toggle_jp` | High confidence. The byte-by-byte key matcher uses the literal sequence `JASSICA16` at `0047b1cc`. On a full match it toggles `g_wasLaurieSet`, copies that state to `g_cheatsActive`, marks `DAT_00495838`, and displays the active/inactive cheat message. This and `-laurie` are two separate ways to set the cheat state. | +| `00415eec` | `key_handle_option_cheats_jp` | High confidence that it contains cheat-gated keyboard actions: it tests `g_cheatsActive`, has a `0x79` (`y`) path additionally gated by `DAT_0047bed4`, and emits `Immortality enabled.` / `Immortality disabled.` on separate branches. The full action mapping and exact trigger for the immortality toggle remain unresolved. | +| `004811f3` | `-warp N` | High confidence. Prints `Warping to mission %d.` and stores the selected mission index. `FUN_00428e00` resolves it through the base-map table at `0047b72c`, adds the `-mapoff` value, and follows the alternate map-start path. | +| `00481200` | `-mapoff N` | High confidence. Stores the parsed offset in `DAT_004957e8`; `FUN_00428e00` adds it to the selected mission's base-map value before starting that map. | +| `004811f9` | `-skill N` | High confidence for the data flow. Stores the parsed value in `DAT_0047bed0`; `FUN_00428e00` copies a positive value to `DAT_004955d7`. The game's skill encoding/range is not yet established. | +| `00481208` | `-egg N` | High confidence for the data flow. Stores and prints the destination value in `DAT_0047bed2`; the map-start path passes it to `FUN_00424764`, which creates a process of type `0xf0`. If no value is supplied, that path uses `0x1e`. The process's exact destination semantics remain unresolved. | +| `0048120d` | `-demo` | High confidence that this selects a distinct startup path: prints `Demo mode.` and sets `DAT_004957ea`. With no explicit `-warp`, `FUN_00428e00` clears `DAT_004823c0`/`DAT_004823c2` and repeatedly calls `FUN_00456d90` until the high word of `DAT_004823c2` becomes nonzero, instead of calling it once. The higher-level demo behavior is unresolved. | +| `004811cc`-`004811eb` | `-?`, `-u`, `-setver`, `-vesatest`, `-asylum` | The `-?` and `-u` handlers have not been traced. The observed switch targets for `-setver`, `-vesatest`, and `-asylum` return to the parser loop without a distinct handler in this build. | + +The timeline caller at `00455bb6` lies in an unrecognized function region around `00455ae4`-`00455ce4`; boundary analysis did not establish a reliable function entry, so it remains unnamed. The `DebugBreak` string at `00496734` is in `.idata` and has no reported data uses; it does not establish an active breakpoint feature. No executable bytes were changed, and Ghidra changes remain unsaved. + +## Examined Functions With Unresolved Semantics + +The functions previously listed as unnamed now have operation-level Ghidra names and evidence-backed comments. The addresses remain here as tracking anchors; unresolved rows identify the higher-level contracts that still need investigation. + +| JP address | Current Ghidra name | Observed behavior | Remaining uncertainty | +|---|---|---|---| +| `004059f0` | `memory_fill_buffer_with_zero` | Calls the repeated-byte memory-fill path with fill value zero; the keyed-cache loader is its only observed caller. | The exact buffer role and size contract remain unresolved. | +| `00405a10` | `item_action_repeat_for_direction_delta` | Computes the shortest wrapped difference over low-nibble direction values and repeats `item_action_process_dispatch(10000, mode, 0)` according to the difference. | Mode selection and incoming direction-field meanings remain unresolved. | +| `00405c4c` | `audio_play_sound_for_selector` | Maps an incoming mode through fixed/table-driven values, calls `0046159c(3, ...)`, and conditionally updates audio state. | Selector, table, and shared-helper semantics remain unresolved. | +| `00405ea8` | `controller_send_event_20_if_query_false` | When the query returns zero, sets `DAT_004822bd` and calls controller vtable slot `+0x28` with event `0x20`. | Controller event and global-state meanings remain unresolved. | +| `004060e8` | `item_state_dispatch_mode_one` | Wrapper around `item_state_update_and_dispatch` with a fixed mode. | Owning object fields and resulting gameplay action remain unresolved. | +| `00406100` | `item_state_update_and_dispatch` | Changes state bits, selects table-derived values, and calls shared action/spatial-query helpers. | The owning object fields and action semantics remain unresolved. | +| `00406378` | `packed_state_update_from_query_results` | Updates packed fields at `DAT_004957ac+0x1beb` from helper values around a spatial query. | Packed-record schema and query purpose remain unresolved. | +| `004071a0` | `item_action_resolve_position_and_autofirer` | Checks object/type state, handles an AutoFirer-specific branch, then queries position through `0041b208`. | Selector and event meanings remain unresolved. | +| `004076b0` | `item_process_probe_positions_and_update` | Constructs type-selected temporary processes, probes directional candidates, records process state at `+0x34`, then updates keyed-cache/item state. | Candidate geometry, record contract, and higher-level action remain unresolved. | +| `00407500` | `keyed_entry_cache_key_is_available` | Checks whether a 16-bit key can be resolved through `004262f8`. | The resource represented by the key remains unresolved. | +| `00405f18` | `keyed_cache_find_record_with_packed_fields` | Searches ten-slot table entries for a packed record with nonzero fields and returns matching offsets. | Record schema and exact spatial/shape operation remain unresolved. | +| `00406018` | `keyed_cache_get_record_with_packed_fields` | Returns scratch/record data associated with the packed-field lookup. | Record schema and caller-facing contract remain unresolved. | +| `0041bf9c` | `item_state_map_context_and_selector` | Maps context/selectors through tables near `0047b20c`/`0047b260`, with item/state checks for selectors `8` and `0x2a`. | Returned values and selector meanings remain unresolved. | +| `00429d2c` | `animation_process_set_flag_52` | Sets byte `+0x52` on the incoming animation-process object. | The flag meaning and owning call-path contract remain unresolved. | +| `00429e70` | `static_resource_create_registered_object` | Resolves resource `"static"`, creates/registers an associated object, and installs a function table. | The concrete object role remains unresolved. | +| `00429ea8` | `static_resource_load_and_initialize` | Initializes static-resource object state, obtains/caches a handle, and conditionally creates the registered object. | Resource/object ownership remains unresolved. | +| `0043d2c4` | `process_table_dispatch_flagged_callbacks` | Sweeps the process table and conditionally invokes virtual methods `+0x0c` and `+0x28` based on flags. | Callback contracts and lifecycle purpose remain unresolved. | +| `0043d574` | `process_table_find_by_id_and_type` | Finds a process entry matching object ID/type under flag checks and updates the search cursor. | Selected process role remains unresolved. | +| `0043d640` | `process_table_find_related_by_id_and_type` | Searches for a same-ID/type process whose relation list contains the current slot. | Relation-list semantics remain unresolved. | +| `0043d754` | `process_manager_get_cursor_slot_if_eligible` | Returns the current cursor slot only when in range, non-null, and eligible. | Cursor ownership and caller intent remain unresolved. | +| `0043d7a4` | `process_activate_and_link_related_processes` | Registers a process relationship, searches related entries, and updates relation-list state. | Link and activation semantics remain unresolved. | +| `00458b8c` | `process_activation_register_and_link` | Marks the process active, copies its type, and links related processes unless flag `0x1000` is set. | Activation/link contract remains unresolved. | +| `0043db10` | `process_initialization_mark_flag_40` | During manager initialization, sets process flag bit 6 when its slot exceeds `DAT_0048433a`. | Initialization flag meaning remains unresolved. | +| `0043db58` | `process_table_stage_pending_insert_id` | Asserts `DAT_00484306` is clear and stores the incoming 16-bit value for later process-table insertion. | Staged value meaning remains unresolved. | +| `0043ed80` | `process_dispatch_registered_window_callbacks` | Traverses registered startup/window entries and invokes `00459038` after process/type checks. | Callback and event-entry semantics remain unresolved. | +| `0043eed0` | `process_terminate_update_tracking_state` | During termination, updates shared counters/state and removes the process slot ID from a short-ID list. | Counter and list meanings remain unresolved. | +| `0044dc9c` | `item_action_process_dispatch` | Dispatches item actions to action-specific process constructors and updates tracked-item/AutoFirer state. | Individual selector meanings remain unresolved. | +| `0041b798` | `target_position_query_from_packed_records` | Scans nonempty packed records, derives candidate offsets, then checks occupancy and shape queries; several callers consume its low return word as boolean. | Packed fields, exact success criteria, and the `+0x64` input record meaning remain unresolved. | +| `0041bb7c` | `target_position_query_within_axis_threshold` | Forms target-relative coordinates, issues a mode-4 spatial query, then tests rounded-up 3D axis distance against `0x31` steps. | Coordinate units and threshold semantics remain unresolved. | +| `0043f038` | `process_manager_restore_saved_global_84314` | Restores `DAT_00484314` from saved byte `DAT_00484337` when nonzero. | Higher-level state meaning remains unresolved. | +| `0043f04c` | `process_manager_save_and_clear_global_84314` | Copies `DAT_00484314` to `DAT_00484337` and clears the original global. | Higher-level state meaning remains unresolved. | +| `0043f190` | `process_dispatch_flag_10_listeners` | Invokes vtable method `+0x28` when listener bit `0x10` and process bit `0x100` are both set. | Listener-group distinction remains unresolved. | +| `00440354` | `input_record_test_low_bits_at_offset_2` | Tests whether either low-order bit is set in the byte at input-record offset `+2`. | Record ownership and mode meanings remain unresolved. | +| `0044035c` | `input_record_test_flag_bit_3` | Tests bit 3 of the high word in the incoming dword. | Field ownership and flag meaning remain unresolved. | +| `00440368` | `input_record_test_flag_bit_2` | Tests bit 2 of the high word in the incoming dword. | Field ownership and flag meaning remain unresolved. | +| `00440374` | `stack_list_contains_byte_value_until_fe` | Searches a stack-provided list for a byte value until sentinel `0xfe`. | List schema remains unresolved. | +| `004405c8` | `modal_dialog_run` | Sets up a modal context, constructs the dialog, runs the dispatcher until completion, and tears down the context. | Dialog purpose remains unresolved. | +| `00440600` | `modal_dialog_construct_controls` | Constructs a vtable-backed dialog/process, derives bounds from `DAT_00495824`, and creates positioned child controls. | Dialog purpose and control labels remain unresolved. | +| `0043fe80` | `process_broadcast_to_flag_40_listeners` | Under a reentrancy guard, broadcasts event/payload values to processes with listener bit `0x40`. | Observed event IDs `1`, `4`, `8`, and `0x10` remain uninterpreted. | +| `0043f8f4` | `process_register_flag_80_state` | Sets process bit `0x80`, increments `DAT_0048433c`, and adds its ID to a unique short-ID list. | Higher-level process state remains unresolved. | +| `0043f97c` | `process_unregister_flag_80_state` | Clears process bit `0x80`, decrements `DAT_0048433c`, and removes its ID during termination. | Higher-level process state remains unresolved. | +| `0043ff9c` | `process_register_flag_40_state` | Sets process bit `0x40`, increments `DAT_0048437a`, and adds its ID to a unique short-ID list. | Higher-level process state remains unresolved. | +| `00440024` | `process_unregister_flag_40_state` | Clears process bit `0x40`, decrements `DAT_0048437a`, and removes its ID during termination. | Higher-level process state remains unresolved. | +| `00431148` | `process_state_list_add_unique_id` | Returns an existing ID or appends it and increments the list object's associated count. | List purpose remains unresolved. | +| `004310e0` | `process_state_list_remove_id` | Removes a 16-bit process ID and updates associated list state/counts. | List purpose remains unresolved. | +| `00407550` | `process_0x0f0_construct_for_item` | Constructs a type-`0xf0` process and optionally derives fields from an associated item. | Process class purpose remains unresolved. | +| `0043d0c8` | `process_table_dispatch_matching_type_exclusions` | Finds eligible matching process entries while excluding up to ten stack-supplied IDs, then invokes vtable method `+0x0c`. | Event/type and callback contracts remain unresolved. | +| `0043b5c4` | `process_word_shift9_forwarder` | Passes the incoming object's 16-bit word shifted right by 9 to `004356d4`. | Source-field and helper semantics remain unresolved. | +| `00446250` | `win32_game_main` | Checks joystick state, may show dialog resource `0x71`, then creates the main window and initializes graphics/audio. | Exact startup/UI role remains unresolved. | +| `00407304` | `item_shape_dispatch_interaction_rules` | Filters object/type values, queries adjacency, and consults violence-gated tables at `0047b074`/`0047b084`. | Event/effect behavior and table contents remain unresolved. | +| `00455ae4`-`00455ce4` | `unresolved; no verified function entry` | The range polls tracked keys, advances a counter, and updates the debug timeline when `DAT_004957eb` is nonzero. | Function entry and timeline timestamp/display path remain unresolved. | + +The reviewed process helpers now have operation-level names; selector, table, and flag semantics remain open. The timeline range above remains unassigned because boundary analysis did not establish a reliable function entry. + +## Western Comparison Status + +Current coverage establishes JP-specific item-state, spatial-search, process-manager lifecycle, Windows keyboard/event behavior, and native Windows startup/window lifecycle, but not a Japanese-versus-Western behavior difference. The process IDs, item record layout, dispatch tables, and function addresses documented here are JP-specific until matched against a verified Western implementation. Existing Japanese executable and platform findings are summarized in [JP Windows 9x investigation](jp-remorse-windows9x-investigation.md); broader JP/Western format and modding boundaries are in [JP Windows modding feasibility](jp-remorse-windows-modding-feasibility.md). + +## Semantic-Gap Analysis Checkpoint (2026-10-12) + +This is a read-only static pass over the five requested areas. No Ghidra database changes or executable-byte writes were made; the live Ghidra project remains under the user's control. + +| Area | Verified findings | Remaining analysis | +|---|---|---| +| Action and process behavior | `item_action_process_dispatch` cases `0`, `4`, `0x21`, `0x39`, and `0x3b` all construct type `0xf0` through `process_0x0f0_construct_for_item`, then install distinct callback tables. Type `0x259` is constructed by `AttackProcess_0040af20`. The direction helper's `0xff` path requires the current item to differ from `DAT_0047b1d6`, a type-`0x259` process with nonzero `+0x64`, shape-bounds overlap, and a successful packed-position query before dispatching selector `0`; it then sets process byte `+0x7d` and updates `+0x4a/+0x49`. | Identify the callback-table methods behind each selector; establish the meanings of `DAT_0047b1d6`, AttackProcess `+0x64`, and process `+0x7d`; confirm the caller-level result contract. | +| Data schemas | The keyed cache has ten rotating key slots and 256 entry pointers per slot. Its 16-bit key is looked up at file offset `key * 4`; descriptor low byte `+4` sets entry count and bit `0x40` at `+7` selects `0x40` versus `0x80` bytes per entry. The pair reader copies two dwords. The main item record stride is `0x79`; its separate 16-byte snapshot record maps X/Y words at `+0/+2`, Z at `+4`, shape at `+5`, packed byte at `+7`, flags at `+8`, an auxiliary word at `+0x0a`, auxiliary bytes at `+0x0c/+0x0d`, and next-item ID at `+0x0e`. | Resolve the cache key/resource and two-dword entry contract, auxiliary item-field and shape-profile flag meanings, and Western-build field correspondences. | +| Animation and spatial queries | AnimationProcess construction sets type `0x230`, vtable `0047e7a8`, and byte `+0x52` to zero; `animation_process_set_flag_52` writes one, and its only xref is the direct call at `00411fcd`, which has no owning function in Ghidra. Sixteen vtable slots were inspected; seven currently target defined functions and nine remain non-function/LAB targets. The spatial grid is indexed as 64 two-byte cells per `0x80`-byte row; selector coordinates advance by `0x200` and are converted with `>> 9`. | Establish the `+0x52` contract and unowned caller boundary; map remaining vtable slots, selector-mode tokens, and 8-way direction-sector encodings. | +| Input and presentation | Joystick polling uses `joyGetPosEx`; configured action IDs `4`-`8` emit `u/g/s/m/e`, action `9` maps directions to `q/w/i/o`, and process byte `+0x62` selects distinct handling paths. Startup opens dialog resource `0x71` only when joystick polling returns a nonzero direction; a zero dialog result aborts startup. The DirectDraw surface helper calls vtable offset `+0x60`, then locks at `+0x64` only on a zero result; that helper has no restore branch. The debug timeline helper has one caller at unowned address `00455bb6`. | Trace joystick configuration and mode semantics, decode resource `0x71` text/button intent, find any surface-restore path, and identify the timeline consumer/fields `+0xeb/+0xef/+0xf3/+0xf7` plus the writer for `DAT_004955e8`. | +| Unclassified bytes and boundaries | The latest report tracks all `1,493 / 1,493` function entries with zero untracked or generated names; function bodies cover `67.4%` and defined instructions cover `80.0%` of the `499,712` executable bytes. The remaining `100,014` bytes outside defined instructions may be data, padding, or unanalyzed code. Both `00411fcd` and `00455bb6` are confirmed code call sites without an owning function; five unmatched table addresses are not function entries. | Classify executable gaps by references and control flow before creating functions; prioritize the two confirmed unowned call sites and keep data/padding distinct from missed code. | + +## Next Work + +1. Classify the report's remaining executable-byte gaps as code, data, or padding using references and control flow; do not infer functions from coverage percentages alone. +2. Resolve the action callback tables and the `process_choose_direction_to_coords` `0xff` contract, including `DAT_0047b1d6`, AttackProcess `+0x64`, and process byte `+0x7d`. +3. Finish the keyed-cache resource/entry schema and label unresolved item snapshot, auxiliary-field, and shape-profile semantics; compare the verified `0x79` and 16-byte layouts against the Western build. +4. Map AnimationProcess vtable slots and the caller/boundary around `00411fcd`; resolve `+0x52`, selector-mode tokens, and 8-way direction-sector encodings. +5. Trace joystick configuration and `+0x62` mode behavior; identify the text/response meaning of startup dialog resource `0x71`, any DirectDraw surface-restore path, the debug timeline consumer/fields, and the writer of `DAT_004955e8`. +6. Recover process flag meanings and the related-process list used by `0043d574`, `0043d640`, and `0043d7a4`; distinguish bit `0x20` at record bytes `+0x59` and `+0x14`, and verify the overlapping `Process_Terminate`/`process_terminate_set_flag_20` boundaries. +7. Continue `item_shape_dispatch_interaction_rules` through its callers and resolve the violence-gated tables at `0047b074` and `0047b084`, including their selected effects and relationship to target adjacency. +8. Compare JP and Western process, animation, joystick, item-record, spatial-query, `-debug`, `JASSICA16`, and developer-switch behavior only after opening the correct Western Ghidra target; document semantic differences, not address differences. +9. Map the remaining actions in `key_handle_option_cheats_jp`, identify the immortality-toggle trigger, and determine the destination semantics of the type-`0xf0` process created for `-egg`. +10. Establish what state completes the `-demo` polling loop, then trace `-?`, `-u`, `DAT_00482620`, and `DAT_004957d9`. +11. Keep future batches evidence-backed, add Ghidra comments for mapped names, preserve uncertain functions as `FUN_...`, and leave project saving to the user. \ No newline at end of file diff --git a/docs/jp-remorse-handoff-2026-10-12.md b/docs/jp-remorse-handoff-2026-10-12.md new file mode 100644 index 0000000..ef3fa98 --- /dev/null +++ b/docs/jp-remorse-handoff-2026-10-12.md @@ -0,0 +1,47 @@ +# JP Semantic-Gap Investigation Handoff + +Date: 2026-10-12 + +## Resume Context + +- Workspace: `Crusader_Decomp` +- Live Ghidra target: `/ja/CRUSADER.EXE`, image base `00400000` +- Main ledger and active backlog: [JP decompilation progress](jp-remorse-decompilation-progress.md), under `Semantic-Gap Analysis Checkpoint` and `Next Work` +- Coverage script: `tools/jp_executable_documentation_report.py` + +The user asked to investigate five semantic-gap areas and add follow-up tasks to the JP ledger. That static pass is recorded in the progress document. The current investigation made no Ghidra database edits, saved no Ghidra state, and changed no executable bytes. Any pre-existing pending Ghidra changes were left untouched. + +## Verified Baseline + +The latest read-only coverage report for the active JP program reports: + +- Function entries tracked: `1,493 / 1,493` (100%); untracked: `0`; generated names: `0` +- Function-body coverage: `336,693 / 499,712` bytes (67.4%) +- Defined-instruction coverage: `399,698 / 499,712` bytes (80.0%) +- Executable bytes outside defined instructions: `100,014`; these may be data, padding, or unanalyzed code +- Five ledger table addresses are not function entries: `004811f3`, `004811f9`, `00481200`, `00481208`, `0048120d` + +Do not treat the remaining byte percentage or those five table addresses as proof of missing functions. + +## Findings So Far + +- Action dispatch: selectors `0`, `4`, `0x21`, `0x39`, and `0x3b` all construct a type-`0xf0` process through `process_0x0f0_construct_for_item`, then install distinct callback tables. The selector callbacks still need semantic names. +- Attack process: type `0x259` is constructed by `AttackProcess_0040af20`. The `process_choose_direction_to_coords` `0xff` path checks a nonzero `+0x64` value, shape overlap, and a packed-position query before dispatching selector `0`; the meanings of `DAT_0047b1d6`, `+0x64`, and process byte `+0x7d` remain open. +- Cache and records: the keyed cache has ten rotating key slots and 256 entry pointers per slot. The 16-bit key is looked up at file offset `key * 4`; descriptor low byte `+4` controls count and bit `0x40` at `+7` selects `0x40`/`0x80` bytes per entry. The pair reader copies two dwords. The separate 16-byte item snapshot layout is mapped in the progress ledger; the main item table has stride `0x79`. +- Animation and spatial search: AnimationProcess uses type `0x230` and vtable `0047e7a8`; its constructor clears `+0x52`, and a helper sets it to one. Its sole caller, `00411fcd`, is code with no owning Ghidra function. The spatial grid uses 64 two-byte cells per `0x80`-byte row; selector coordinates step by `0x200` and use `>> 9` for grid indexing. +- Input and presentation: joystick actions `4`-`8` emit `u/g/s/m/e`; action `9` maps directions to `q/w/i/o`; process byte `+0x62` selects distinct handling. Startup dialog resource `0x71` opens only for positive direction flags; a zero dialog result aborts startup. The DirectDraw lock helper has no restore branch. The debug timeline helper's sole caller is unowned code at `00455bb6`. +- Boundaries/debug: `00411fcd` and `00455bb6` are confirmed call sites but have no containing function. The timeline consumer/fields and writer for `DAT_004955e8` remain unresolved. + +No runtime test of the joystick dialog or presentation paths was performed, and no JP/Western semantic comparison was made. + +## First Steps Tomorrow + +1. Open or confirm the live `/ja/CRUSADER.EXE` target before using Ghidra MCP. Use MCP-only analysis; do not use the offline PyGhidra CLI. +2. Read the `Semantic-Gap Analysis Checkpoint` and `Next Work` sections in the [JP decompilation progress ledger](jp-remorse-decompilation-progress.md). +3. Start with boundary triage around `00411fcd` and `00455bb6`: inspect surrounding disassembly, control flow, and references to determine whether each belongs to a larger routine. Do not create or name a function until bounds are supported. +4. Continue with the prioritized backlog in the ledger: action callback/type-`0x259` contracts, cache and field semantics, animation/spatial details, then joystick/dialog/DirectDraw/debug-timeline paths. +5. Re-run the read-only coverage script when useful to confirm the exact-entry baseline. Leave Ghidra project saving to the user and never patch bytes in the reference executable. + +## Worktree Note + +`docs/jp-remorse-decompilation-progress.md` was already locally modified before this investigation. Those existing edits were preserved; this work updated the bottom checkpoint/backlog and corrected its heading structure. The current changes have not been committed. \ No newline at end of file diff --git a/docs/jp-remorse-usecode-debugger-feasibility.md b/docs/jp-remorse-usecode-debugger-feasibility.md new file mode 100644 index 0000000..2f54ac1 --- /dev/null +++ b/docs/jp-remorse-usecode-debugger-feasibility.md @@ -0,0 +1,158 @@ +# Japanese No Remorse USECODE Debugger Feasibility + +**Status:** Static feasibility assessment; no executable bytes changed +**Target:** Japanese Win32 `/ja/CRUSADER.EXE` in the active Ghidra project +**Reviewed:** 2026-10-11 + +## Executive Assessment + +Adding a useful USECODE debugger to the Japanese build is technically feasible, but it is a JP-specific port or extension, not a hidden feature that can be switched on by copying the No Regret bootstrapper. The Japanese executable has ordinary USECODE execution and some useful metadata, but the recovered image does not contain the classic debugger's break-state object, interpreter record lifecycle, UI, or debugger event handlers. + +The practical ratings are: + +| Approach | Feasibility | Assessment | +|---|---|---| +| Copy DOS No Remorse/No Regret debugger machine code into the JP PE | Very low | The sources are 16-bit DOS NE programs; JP is a flat 32-bit Win32 PE. Segmented pointers, calling conventions, allocators, file access, and the UI framework do not match. This is not a binary transplant. | +| Use the existing Windows native debugger on the JP process | High for machine-code debugging | Ghidra/x32dbg can stop and inspect native instructions, including the USECODE interpreter. This does not provide USECODE line breakpoints, unit-aware frames, watches, or a game debugger UI. | +| Build a small JP trace/break prototype | Feasible, moderate | Add or externally orchestrate hooks at interpreter boundaries; begin with current unit/event, bytecode offset, opcode, and stop/continue. This is the recommended first implementation target. | +| Port the complete in-game debugger | Feasible in principle, high effort and risk | Requires a new JP runtime-state layer, validated source mapping, break/step integration, watch semantics, and a UI path. No plugin ABI or existing JP debugger frontend has been recovered. | + +**Recommendation:** time-box a runtime instrumentation spike before writing a full debugger. Prove that a real JP interpreter invocation can be identified, paused at a stable bytecode boundary, resumed without state corruption, and associated with its live unit/event/frame. Use an external controller first; add an in-game UI only after that contract is demonstrated. + +## What The JP Executable Has + +The active Ghidra project reports the open domain file as `/ja/CRUSADER.EXE`; the image is the flat Win32 build, not either DOS NE executable. The existing JP investigation records its PE image base as `0x00400000` and its SHA-256 as `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`. Keep any future patcher tied to that exact build fingerprint. + +USECODE runs through `UsecodeProcess_Create` (`004671b0`), `UsecodeProcess_Run` (`00467304`), and the large opcode dispatcher `UsecodeProcess_NextOpcode` (`0042ddc8`). The process factory installs the ordinary process callback table; the recovered table does not expose a debugger callback or break-state global. + +### Process Lifecycle And Spawn Paths (2026-10-11) + +The primary process callback entries at `004803d4` cover ordinary scheduling and lifecycle work. `UsecodeProcess_Run` (`00467304`) is the run slot; `00458980` and `00458990` are termination callbacks. `004680f0` performs cleanup, `00467360` releases a value for an incomplete process, `00467448` restores process state, `00467380` serializes it, and `004672fc` is a thunk that returns the process resource at `+0x34`. The `00467448` and `00467380` callbacks use shared Windows file helpers `004262f8` (`ReadFile`) and `0042637c` (`WriteFile`), rebuilding runtime pointers around the instruction cursor and stack/frame fields. `004059d0` and `004059e0` are one-byte `RET` stubs. + +The word at `004803fc` (`00466de0`) begins a resource-object vtable used by `FUN_00466d60`, which installs `004803fc` as that object's vptr; `00466de0` is its destructor/release path. The following pointer at `00480400` (`0046a940`) is not another confirmed process callback. It is referenced as adjacent type/registration data from `0046eb7b`, and `0046a940` itself is constructor-like: it allocates and initializes a separate `0x11e`-sized object. The exact descriptor format and object's role remain open. None of the confirmed process lifecycle paths tests a source line or breakpoint. + +The dispatcher retains both process-spawn opcodes. Token-name pointer slots map `T_SPAWN` to opcode `0x57` and `T_SPAWN_INLINE` to `0x58`; their dispatcher cases at `0042feaf` and `0042ffce` each call `UsecodeProcess_Create` (`004671b0`). A third creation path, now named `usecode_start_event_process_if_enabled` (`004670b0`), resolves a unit/event, checks its event mask, and creates a process for eligible events. `item_create_from_shape_id` calls it for shape-dependent initialization events. This confirms that ordinary event dispatch and nested/child process creation survive, not debugger stepping or a debugger-owned child-context stack. + +The JP dispatcher retains two USECODE metadata opcodes, but their recovered handlers do not implement debugger control: + +- Opcode `0x5b` (`T_LINE_NUMBER`, token pointer at `0047b900`, name at `00480e94`) is handled at `0042dfaa`. It advances the USECODE cursor by two operand bytes and returns to dispatch; it does not retain the line value, update a current-line field, or test a breakpoint. A new hook could capture the operand, but its mapping to display rows is not verified. +- Opcode `0x5c` (`T_SYMBOL_INFO`, token pointer at `0047b904`, name at `00480ea2`) is handled at `0042dfbd`. It skips a two-byte field and a nine-byte inline name record. When `DAT_00482ad0` is nonzero, it sends the name to the shared output helper (`00445520`) using `"<%s>\n"`; it does not push a debugger current-entry record or preserve a frame for inspection. +- The same `DAT_00482ad0` condition gates generic opcode-name output at `0042dea3`, using the token-name table. The current data-use scan found these reads but no writer. This is trace-style output, not an interactive debugger surface. + +These handlers are useful hook locations because they expose a line operand and symbol activity during normal interpretation. They do not establish a complete source map or retain the state needed for source-level stops, stepping, watches, or frame inspection. The separate `T_SUSPEND` runtime operation is not connected to the line-number handler in the recovered path. + +### Line-Related String Matches That Are Not USECODE Debugging + +The broad string search also found halt/error text, but its references lead to the media-player error path rather than the USECODE VM: + +- `"Halted file %s\\nline %d"` (`00425230`) and `"Halted file %s\\nline %d\\n%s"` (`00425247`) are used by `00425050` and `00425084`. These are one-shot fatal-report handlers that call the message formatter and then `win32_shutdown_message_loop`. +- `"player halted on line %d"` (`00457060`) is passed by `004562f8` with source label `player.h` and line `0x1e`. `"Error in %s, line %ld. %s\\n"` (`00457082`) is used by `00454f08`, whose surrounding code parses RIFF/AVI chunks. These are media-player diagnostics, not USECODE line stops. + +They are recorded here to prevent interpreting a text match for “halted” or “line” as evidence of a USECODE debugger. + +## What Is Missing + +The JP function and string searches found no classic debugger function family or characteristic prompt bundle. In particular, the following pieces recovered in the DOS builds have no JP equivalent in the analyzed path: + +- A break-state object with breakpoint slots, current line, step flags, and a current-entry stack. +- Interpreter-side line update, current-entry push/copy, and return/unwind operations. +- A debugger-owned UI/event subsystem for source display, breakpoints, watches, inspection, and global editing. +- A bootstrap that allocates and publishes debugger state, and a callback that opens the UI when a break condition fires. + +The absence is bounded evidence, not proof that no encoded or dynamically registered helper exists. The stronger finding is behavioral: the known JP process and opcode paths do not perform the classic break-state lifecycle. + +### UI Surface Search (2026-10-11) + +The active `/ja/CRUSADER.EXE` program was searched again for both debugger-specific UI and ordinary game UI markers. This separates two questions that should not be conflated: + +- **Classic USECODE debugger/editor UI:** no debugger menus, source/watch panes, or debugger command surface were recovered. +- **Ordinary game UI:** the JP executable still contains generic Gump and event-dispatch infrastructure. Its presence does not establish that a debugger UI survived. + +The targeted function-name searches for `usecode`, `gump`, `NewGump`, `dialog`, `menu`, `conversation`, `speech`, and `intrinsic` returned only the known general USECODE functions for the `usecode` query (`UsecodeProcess_Create`, `UsecodeProcess_NextOpcode`, `UsecodeProcess_Run`, `Usecode_FreeList`, `Usecode_FreeVal`, and `usecode_reference_table_decrement_refcount`). The other queries returned no named functions. This is bounded by current Ghidra function names; it does not classify every unnamed function. + +Targeted decoded-string searches returned no matches for the classic debugger vocabulary: `Watch what?`, `Inspect what?`, `Goto Line`, `Breakpoints`, `Global name`, `Search for`, `FILE NOT FOUND`, `step`, `break`, and `source`. The `debug` search returned only `Debugging mode ON.\n\r` at `00466af9`, `-debug` at `004811d2`, and the imported `DebugBreak` name at `00496734`. The `usecode` search returned `usecode` at `0047be40` and `eusecode.flx` at `0047be90`. + +There is positive evidence for generic game UI, not for the debugger frontend: + +- `GUMPS.FLX` occurs at `00466a9b`; `.\\gumpshap.c` and `.\\newgump.c` source markers and `Bad NewGumpId [%04X]` occur in the executable. +- The `Bad NewGumpId` diagnostic is referenced by `FUN_0044cb44` and `FUN_0044d614`, called from the broader `FUN_0041ccc8` dispatch path. The recovered code traverses and validates generic Gump objects; it is not a debugger-owned menu or pane. +- The only `dialog` string-filter hits were imported Windows APIs `DialogBoxParamA` and `EndDialog`, not debugger prompts. The presence of those imports alone does not identify a game debugger UI. + +**Conclusion:** it is not accurate to say that the JP executable has no UI or no Gump code. It is accurate, with the current search coverage, to say that no classic USECODE debugger/editor UI has been found. This pass did not prove which JP USECODE intrinsics can invoke ordinary Gump/dialog UI, and it does not rule out encoded/localized or unnamed debugger remnants. The opcode `0x5b`/`0x5c` behavior remains the stronger functional evidence that the classic debugger lifecycle is absent from the recovered JP interpreter path. + +### Source and support files + +The inspected Japanese `USECODE` directory contains `JUSECODE.FLX` and `UNKDS.DAT`; the scan found no loose per-unit `.unk` files. `UNKDS.DAT` is 66 bytes in this installation. Its internal role remains unresolved, and the recovered older debugger path opens it separately from the source viewer. It is not the per-unit text listing expected by the classic debugger. + +The classic source pane constructs `.unk`, loads it as line-oriented text, and indexes its lines. Even if a debugger frontend were ported, the JP build would need either authentic JP listings or generated JP-specific display files. Western Remorse/Regret generated listings cannot be assumed to match JP names, bytecode, or line semantics. A source file improves display and navigation; it does not create executable state or make `RUN` interpret that text. + +## Why The No Regret Bootstrap Does Not Solve This + +No Regret is a useful behavioral reference, not a plug-in component. Its recovered `usecode_debugger_bootstrap_init` (`1398:0000`) allocates support objects, creates a break-state object, stores it in `1480:712c/712e`, and replaces the base vtable with a frontend-aware vtable. Its interpreter hook also contains the line, current-entry, child-context, and unwind handlers. + +However, the bootstrap has no recovered normal caller. In the tested ordinary session, the debugger global remained null. A statically present writer is not proof that startup executes it. Separately, forcing the modal UI or loading a generated `.unk` does not synthesize a valid current interpreter entry: the debugger's `RUN` command resumes the live interpreter rather than executing the displayed text, and an invalid/missing current-entry record can still crash the path. + +That distinction is even more important for JP. The JP build is not just missing No Regret's bootstrap call; its recovered interpreter handlers do not implement the producer/consumer lifecycle that bootstrap expects. Porting only the constructor would create state that JP's VM never updates. + +## Implementation Choices + +### 1. Native process debugging + +Use Ghidra's native debugger or x32dbg to break in `UsecodeProcess_NextOpcode`, inspect the process/context objects, and follow the `0x5b`/`0x5c` paths. This is the lowest-risk way to discover live unit, event, cursor, and frame fields. It provides machine-level debugging and is a prerequisite for the options below, not USECODE source-level parity. + +### 2. JP trace and controlled break prototype + +Add the smallest possible interpreter instrumentation, or drive equivalent breakpoints from an external controller. Record at least process identity, unit/class, event, bytecode offset, opcode, and the `0x5b` operand where present. Add stop/continue at an instruction boundary only after confirming register, stack, and scheduler behavior at that point. + +Keep the first controller outside the game's UI. This avoids having to recreate the DOS Gump interface before the VM state contract is known. A later UI can present the trace and break controls over a local IPC or debugger-agent connection. + +### 3. Full JP in-game debugger + +A full port would need JP-native implementations for: + +1. A debugger session object and safe lifecycle attached to each active USECODE process/context. +2. Unit/event identity and a balanced frame stack across calls, child processes, returns, suspension, and resumption. +3. Line/bytecode mapping, breakpoints, break-next, single-step, step-over, and resume semantics. +4. A source/listing loader and JP-specific generated or authentic per-unit listings. +5. Watch/inspect expression evaluation over JP values, frames, globals, and intrinsic results. +6. A frontend built on the JP UI framework or an external debugger window, plus a safe bridge to the emulation/game thread. + +Do not begin with watch/inspect or a full UI. Those features depend on runtime value ownership and descriptor semantics, which the current JP evidence does not close. + +## Binary Modification Constraints + +JP's flat PE layout is easier to reason about than the DOS NE segment/fixup model, but that does not make arbitrary injection safe. No general plugin ABI or JP-specific patcher is established. Existing DOS NE patch definitions and offsets are inapplicable. + +Any actual code experiment should use a separate writable copy of the fingerprinted JP executable, preserve the original file, and be reversible. A detour must preserve the original instruction boundaries, registers, flags, stack state, and execution timing. Prefer an external debugger breakpoint for the initial runtime investigation. Do not patch or save changes into the currently loaded reference executable or Ghidra program. + +## Recommended Spike And Gates + +Start with a bounded 1-2 week investigation, not a full feature commitment: + +1. Attach to an unmodified JP game and capture one real USECODE event through `UsecodeProcess_NextOpcode`; identify the active unit/event, process object, source cursor, and frame/value context. +2. Trace the `0x5b` and `0x5c` cases on real data. Establish what their operands mean in JP and whether unit names and offsets can be associated with a class/event listing. +3. Set an external native breakpoint at a chosen opcode boundary, resume the game, and verify that the same process continues correctly. Check nested calls and at least one return/yield transition before claiming reliable stepping. +4. Generate a JP-specific listing only after source identity and line-offset rules are established. Label synthetic rows as synthetic; do not imply original source-line fidelity. +5. Decide whether the first usable debugger is an external trace/break UI or a game-integrated frontend. Estimate the full port only after the runtime snapshot and mapping gates pass. + +### Go/no-go criteria + +Proceed toward a source-aware debugger if the spike can reliably recover a live unit/event/bytecode position, stop and resume without corrupting scheduler state, and maintain a coherent frame across nested execution. If the line operand or symbol metadata is not sufficient for source mapping, a bytecode-offset debugger is still viable, but should be scoped and named accordingly. + +Treat watches, global editing, and source-line breakpoints as later milestones. They require validated JP frame/value semantics and should not be advertised based only on the DOS debugger's menu behavior. + +## Evidence And Limits + +This assessment combines the active Ghidra target check, a live disassembly of `0042df90..0042e020`, the 2026-10-11 targeted function-name/string/UI-resource search, and the existing JP debugger, dispatch, USECODE-resource, No Regret, and `.unk` investigations listed below. Program bytes were not changed. No live JP game session was captured for this assessment, so pause/resume behavior, runtime frame fields, loader behavior for generated JP listings, and the meaning of `UNKDS.DAT` remain open. + +The negative function/string searches do not prove absolute absence. They do show that the currently recovered JP interpreter/runtime does not contain the classic debugger lifecycle. The feasibility conclusion is therefore: **a JP-specific debugger extension is possible; direct reuse of the DOS debugger is not; first prove the live VM state contract before committing to a complete UI or watch system.** + +## Related Investigations + +- [Japanese hidden debugger investigation](jp-remorse-hidden-debugger-investigation.md) +- [Japanese USECODE dispatch analysis](usecode-jp-dispatch-analysis.md) +- [Japanese Windows debugging](jp-remorse-windows-debugging.md) +- [Japanese Windows modding feasibility](jp-remorse-windows-modding-feasibility.md) +- [No Regret hidden debugger investigation](regret-hidden-debugger-investigation.md) +- [USECODE `.unk` format](usecode-unk-format.md) +- [Standalone USECODE debugger proposal](standalone-usecode-debugger.md) \ No newline at end of file diff --git a/docs/jp-remorse-windows-debugging.md b/docs/jp-remorse-windows-debugging.md new file mode 100644 index 0000000..caf43ee --- /dev/null +++ b/docs/jp-remorse-windows-debugging.md @@ -0,0 +1,64 @@ +# Japanese No Remorse Windows Debugging + +## Executive Summary + +The JP executable can be debugged as a normal 32-bit Win32 process with an external debugger. Its own debug facilities are narrower: `-debug` enables a timeline-like diagnostic buffer, and the executable imports `DebugBreak` for selected invariant/error paths. No JP equivalent of the DOS `CRUDEBUG` environment switch, classic hidden USECODE debugger, or app-specific debugger-attach protocol was found. + +Ghidra 12.1.4 includes live debugger agents for Microsoft `dbgeng` and x64dbg, including local attach launchers. Its Decompiler can be used as an address-oriented view while the native executable runs. The reconstructed C is not executable source: breakpoints and stepping operate on machine instructions, with pseudocode synchronized to those addresses where possible. + +## JP Game-Side Facilities + +### The `-debug` option + +`handle_commandline_args_jp` at `00466774` maps `-debug` to the handler at `004668b4`. The handler prints `Debugging mode ON` and sets bytes at `004957d9` and `004957eb`. The latter gates `debug_mode_update_timeline_buffer` at `00455eac`; that helper builds and copies a 512-byte timeline-like marker buffer from object counters. Its exact visible consumer is unresolved. This is engine instrumentation, not a debugger connection, breakpoint UI, or recovered USECODE break-state system. The flag at `004957d9` has no recovered reader. + +The separate [hidden debugger investigation](jp-remorse-hidden-debugger-investigation.md) found no classic JP USECODE debugger UI/bootstrap or break-state lifecycle. JP's metadata opcodes do not reproduce the DOS debugger's source-line and current-entry recording behavior. + +### Environment variables + +The DOS build's `Kernel_Init` reads `CRUDEBUG` through its environment lookup helper and sets a debug-enabled global. In the JP PE, an exact ASCII byte search for `CRUDEBUG` found no hit. `GetEnvironmentStrings` is in the import table, but Ghidra found no code call site to it beyond the import entry. No JP environment-variable equivalent was recovered. + +The JP `-debug` command-line option is the nearest identified counterpart, but it is not behaviorally equivalent to DOS `CRUDEBUG`: it enables the timeline-buffer instrumentation described above. Absence of the literal and direct environment lookup is strong negative evidence, not proof that no encoded or dynamically constructed environment check exists. + +### Breaks, assertions, and crashes + +The PE imports `DebugBreak`. One confirmed use is in `usecode_reference_table_decrement_refcount` at the call site `00467da6`: if the reference lookup fails, the code shows the game window/cursor, calls `DebugBreak`, retries the lookup, and then continues using the result. An attached debugger can stop at this breakpoint exception. If the lookup still fails after continuing, an invalid access can follow; this is an invariant trap, not a crash-recovery handler. + +Other `DebugBreak` references occur in `process_choose_direction_to_coords` at `00453c64`. The call at `00453985` belongs to the recovered `process_update_direction_toward_target` at `004538c0`: it reads its associated item's current X/Y from the global item tables and delegates 8-way direction selection to the helper. The helper tests direction candidates and updates direction/turn state; it can return `0x10` when a packed process-state flag is set or `0xff` through a separate special-action path. These breakpoints are gated by global `004955e8`. Static xrefs still show reads of this global but no in-image writes, so how it becomes nonzero and whether ordinary gameplay reaches the breaks remain unresolved. They are diagnostic traps, not evidence of a user-facing stepping or inspection facility. + +The imports include CRT unwind support (`RtlUnwind`) and the image contains C++ exception-runtime messages. The inspected import table has no explicit `SetUnhandledExceptionFilter` or `UnhandledExceptionFilter` import, and no custom JP crash-reporting path was established. This does not mean crashes cannot be debugged: a native debugger can stop on an access violation or breakpoint exception, provided it is attached before the fault or launches the process under debugging. Exact first-chance/second-chance behavior depends on the debugger backend and its exception policy. + +No imports or strings were found for common app-side attach/detection APIs such as `IsDebuggerPresent`, `CheckRemoteDebuggerPresent`, `DebugActiveProcess`, or `OutputDebugString`. Such APIs are not required for an external debugger to attach; process attachment is provided by Windows and the debugger backend. + +## Debugging With Ghidra + +### Live native debugging + +The installed Ghidra 12.1.4 distribution contains: + +- `Debugger-agent-dbgeng`, with local launch and attach launchers using `dbgeng.dll`. +- `Debugger-agent-x64dbg`, with local launch and attach launchers using `x64dbg.dll` and x64dbg's automation interface. The agent has 32-bit register/context support; for this x86 game, use the x32 debugger variant where appropriate. + +Ghidra's setup notes specify Python 3.9-3.14 for debugger agents; WinDbg/DbgEng support uses Pybag and protobuf. The bundled launcher F1 help describes the local setup and dependencies. The attach launchers accept a process ID, so the JP game can be started normally and attached, or launched from Ghidra under the selected backend. + +With a live target, Ghidra can provide dynamic disassembly, registers, memory, stack/call-stack state, breakpoints, and trace snapshots, subject to what the backend reports. The bundled Debugger course documents setting an address breakpoint from a static or dynamic listing, including the Decompiler window. A breakpoint selected on pseudocode resolves to a machine address; it does not create a source-line breakpoint in original game source. + +### What “debug the decompiled code” means + +- **Supported:** stop the native process at an address represented in the Decompiler, inspect the synchronized instruction/pseudocode, and use value hovers to evaluate recovered locals, parameters, globals, or fields against live state when Ghidra can map them. +- **Not source-level execution:** Ghidra cannot execute a decompiler C statement as C or step it independently of the binary. A pseudocode statement can correspond to several instructions, and recovered types, names, and variable lifetimes are hypotheses unless confirmed by runtime state. Without matching source/debug symbols, use the disassembly, registers, stack, and memory as the ground truth. +- **Emulation is different:** Ghidra's emulator steps the instruction semantics represented as p-code, which is also used by the decompiler. It does not run the decompiled C and does not automatically reproduce the full Windows/DirectDraw/DirectSound environment. It is useful for bounded functions or paths, but unsupported p-code userops and external API behavior may require modeling or stubbing. + +### Practical workflow + +1. Open the JP `/ja/CRUSADER.EXE` program in the Ghidra Debugger tool and choose the local `dbgeng attach` or x64dbg attach launcher, or launch the game under that backend. Confirm the target module is mapped to the analyzed image before trusting static-address breakpoints. +2. Set a breakpoint from the Decompiler/disassembly at the code of interest. For the known invariant trap, `00467da6` is a candidate; use a narrow breakpoint rather than breaking on every `DebugBreak` invocation. +3. To investigate a crash, attach before reproducing it and configure the backend to stop on the relevant access violation/breakpoint exception. Capture the exception address, registers, stack, and nearby memory before resuming or terminating the process. +4. To test `-debug`, launch with that argument and observe the `00455bac` gate and `00455eac` helper. Do not infer classic USECODE debugger behavior from the “Debugging mode ON” message. +5. Keep the game executable and data unchanged during initial debugging. Static analysis and live debugging are read-only unless an explicit dynamic edit/patch action is chosen. + +## Evidence Boundary + +The JP findings above come from live Ghidra analysis of `/ja/CRUSADER.EXE`, including its import table, `-debug` handler, timeline-buffer consumer, and `DebugBreak` xrefs. The no-`CRUDEBUG` result is based on the absence of the ASCII byte pattern and the lack of a direct `GetEnvironmentStrings` code reference. The exception/crash discussion is static; no JP crash was reproduced in a live debugger during this investigation. + +Ghidra capability claims were checked against the installed 12.1.4 distribution: `docs/GhidraClass/Debugger/A3-Breakpoints.md`, `A4-MachineState.md`, and `B2-Emulation.md`; the `Debugger-agent-dbgeng` and `Debugger-agent-x64dbg` launchers; and the Debugger notes in `docs/GettingStarted.md`. The attach integration is available in this installation, but an actual JP live-debugger session has not yet been tested. \ No newline at end of file diff --git a/docs/jp-remorse-windows-modding-feasibility.md b/docs/jp-remorse-windows-modding-feasibility.md new file mode 100644 index 0000000..959b3b2 --- /dev/null +++ b/docs/jp-remorse-windows-modding-feasibility.md @@ -0,0 +1,222 @@ +# Japanese No Remorse Windows Modding Feasibility + +## Executive Assessment + +The Japanese No Remorse release is a credible base for a **separate Windows-native mod target**, especially for data and script experiments. It is not a drop-in replacement for Western DOS retail, and executable patches or data should not be shared across those builds without validation. + +| Question | Assessment | Main boundary | +|---|---|---| +| Use JP as a modding base | **Feasible with a version-specific toolchain** | JP has a native Win32 executable and a substantial data set, but maps and scripts are not interchangeable with Western retail by default. Rebuilt assets have not yet been proven in-game. | +| Launch natively on Windows 10/11 | **DxWrapper reaches Direct3D device setup; full game stability remains unverified** | The game is a Win32 PE and does not require DOSBox by architecture. A DDraw-to-D3D9 test creates a 1920x1440 device, but the earlier device-loss/lock failure and a later write access violation mean menu-to-game stability still needs testing. | +| Reuse Western retail decompilation or patches | **Low without translation and validation** | JP is a flat Win32 implementation; Western retail is a Phar Lap protected-mode MZ/NE executable. Addresses, ABI, loader, and some runtime behavior differ. | +| Rebuild the original or a very similar executable | **Not currently practical from available materials** | No source or build project was found on the extracted JP CD. Decompiled output is not compiler-ready, and there is no recovered JP build system or complete source-port implementation. | +| Use JP as a cross-reference | **Useful selectively** | Shared data and behavior can corroborate hypotheses, but JP-specific interpreter/debugger behavior must be checked per build. | + +Track JP as its own target profile: separate executable fingerprint, asset manifest, USECODE assumptions, patch format, and Windows launch tests. Keep Western DOS/NE retail as a separate target for existing patches and DOSBox workflows. + +## Established Evidence + +The prior [Win9x investigation](jp-remorse-windows9x-investigation.md) found that JP is a PE-style Win32 application loaded at `0x00400000`, with Windows startup/window creation, registry-backed configuration, DirectDraw/DirectSound initialization, and a `GetVersion`/TLS branch for Win9x behavior. This strongly supports an intended native Windows 9x path. It does not certify runtime behavior on Windows 95, nor Windows 10/11 compatibility. + +The active `/ja/CRUSADER.EXE` Ghidra program was also queried for `004459b0` (`video_init_directdraw_and_directsound`). It calls `DirectDrawCreate`, sets the display mode to `0x280 x 0x1e0` (640x480), creates a palette and primary surface, and initializes DirectSound. Its decompilation is still imperfect: the flat Win32 function has a `ulonglong __fastcall` signature, `undefined4` parameters, synthetic `extraout_ECX` values, and calls through interface-vtable offsets. This is a useful concrete example of both the clearer Windows API boundary and the remaining decompiler cleanup. + +An independent REA pass with Ghidra 12.1.4 analyzed the byte-identical JP PE (SHA-256 `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`) and resolved `FUN_004459b0` to `0x004459B0–0x00445B6A` (443 bytes). It corroborates the DirectDraw/DirectSound setup and also shows `ShowCursor(0)`; this remains static evidence, not a Windows 10/11 runtime test. REA Evidence ID: `ev_14075934dbe400153ac7280118a67be1a31059251467a81b81a237b5a2c9f99b`. + +The local JP assets and renderer evidence establish substantial shared format support, not drop-in data identity: + +- Retail, 1.01, and JP expose the same 63 detected maps, and the map viewer exports JP scenes. +- Every shared JP/Western-retail map differs in the normalized exported scene payload. Similar top-line counts in sampled maps do not make the payloads identical. +- `COMBAT.DAT` is byte-identical across JP and the listed Western builds, showing that some gameplay data is exactly shared. + +See [family export differences](versions/family-export-differences.md) and [COMBAT.DAT evidence](combat-dat.md). A successful map export proves the reader can inspect the format; it does not prove that a rebuilt archive loads in the original JP game. + +## Feasibility As A Modding Base + +### Good fits + +- **JP-targeted map and asset work:** `STATIC_JP` contains a substantial game data set, including `FIXED.DAT` and major graphics/resource archives, and the viewer supports JP map exports. Keep JP inputs and outputs together and test edits in the JP executable. +- **Shared data:** files confirmed byte-identical, such as `COMBAT.DAT`, are candidates for shared tooling and cross-build tests. Matching filenames alone are not evidence of compatibility. +- **Windows-native experiments:** JP is a better host than DOS retail when the goal is to investigate the Windows API path or build a mod that avoids DOSBox. +- **Behavioral cross-reference:** JP can help explain shared game concepts, data structures, and services, but each conclusion should be checked against its intended target. + +### Boundaries and risks + +- **Not a Western-retail replacement:** JP map payloads differ, the local JP archive is named `JUSECODE.FLX`, and executable behavior is version-specific. Do not mix JP and Western fixed data or scripts without format and in-game validation. +- **USECODE compatibility is not established:** the JP interpreter dispatches opcodes `0x00..0x79`; `0x71` and `0x72` take an invalid-token path. Its `0x5b`/`0x5c` handlers also differ from the classic DOS hidden-debugger line/current-entry behavior. This is concrete reason not to assume Western compiled USECODE is a safe JP replacement. See [JP USECODE dispatch analysis](usecode-jp-dispatch-analysis.md) and [JP debugger investigation](jp-remorse-hidden-debugger-investigation.md). +- **Archive naming needs closure:** the JP executable contains an `eusecode.flx` string associated with its `-u` startup override, while the local static folder contains `JUSECODE.FLX`. The override helper does not establish the default JP archive lookup. Trace or runtime-test the default loader before renaming files or designing an override package. See [JP launch parameters](jp-remorse-cheats-and-launch-params.md). +- **Palette caveat:** the viewer currently falls back to Western `GAMEPAL.PAL` when the JP copy is absent. That is a renderer workaround, not proof the JP game expects or accepts that palette. See [version differences](versions/version-differences.md). +- **No known general plugin ABI:** native code changes need build-specific PE patching or a separately validated shim/injection mechanism. Existing NE patch definitions and relocation logic target the DOS executable and cannot be reused as-is. +- **Japanese integration matters:** the executable imports DBCS/code-page and IME APIs. Preserve the intended text/input environment during tests and distinguish localization failures from game logic failures. + +**Modding verdict:** JP is reasonable for JP-targeted data mods and controlled binary experiments, provided executable and assets are fingerprinted as one profile. It is not yet a turnkey mod platform: the archive rebuild/load loop, JP USECODE round-trip/compiler path, and runtime acceptance of edited resources remain unproven. For Western retail mod support, retain the DOS/NE target and its existing [patch/data feasibility path](remorse-patching-mod-system-feasibility.md). + +## Windows 10/11 Native Launch Feasibility + +### Why direct launch is plausible + +JP is already a Win32 executable, not a DOS program dependent on `RUN286`, Phar Lap, NE segment loading, or DOS interrupts. A 32-bit Win32 application can generally run on x64 Windows through WoW64, which is Windows' x86 compatibility layer, not DOSBox. The recovered imports include windowing, registry, file, timing, joystick, DirectDraw, and DirectSound APIs. The Win9x TLS branch handles a Win9x-specific allocation constraint; no blanket Windows NT rejection has been established. + +This makes unmodified direct launch the right first experiment. It does not prove all legacy API behavior works on current Windows, or that the original installer runs on x64 Windows. The prior analysis did not identify the required DirectX/runtime prerequisites or test Windows 95 in a VM. + +### Compatibility work, ordered by risk + +1. **Test the unmodified executable first** on clean Windows 10 and 11 x64 systems with a complete JP data set, expected working directory, and writable game directory. Test the game separately from its installer. Record startup, menu/game entry, display mode, input, audio, config/save paths, and shutdown. +2. **Add a launch wrapper only for environment setup** if needed: establish the working directory, pass supported arguments, and capture diagnostics. Do not silently rewrite data paths or mix asset versions. +3. **Use compatibility settings or shims only for a reproduced failure.** Investigate legacy DirectDraw fullscreen/palette behavior, DirectSound initialization, display changes/Alt-Tab, registry assumptions, and writes beneath protected install directories. These are risks inferred from the API surface, not observed Windows 10/11 failures. +4. **Patch the PE only for a localized, repeatable failure.** Identify the exact version check or failing call first. The Win9x `GetVersion` branch alone is not a reason to patch version detection. Tie changes to an exact executable fingerprint and retest ordinary startup. + +Current claim: **the PE architecture supports running without DOSBox, but the observed DirectX startup failure means an unmodified Windows 10/11 launch is not currently demonstrated.** If "native" means no DOSBox, the architecture is favorable. If it means no WoW64 or compatibility behavior on x64 Windows, that is not a realistic requirement for a 32-bit game. + +### Observed DirectX startup failure and likely boundary + +The user reports that startup fails with a DirectX error on a modern Windows system. The exact dialog text and the stage label shown by the game have not been captured, so this does not yet identify a root cause. Static analysis provides a concrete first boundary to test: `video_init_directdraw_and_directsound` at `004459b0` initializes DirectDraw before DirectSound. It calls `DirectDrawCreate`, sets cooperative level, requests 640x480, creates a palette and primary surface, applies the palette, and then calls DirectSound. The failure handler includes labels for each DirectDraw stage. In this initializer, the DirectSound result appears not to be fatal; that is a static inference, not a runtime finding. + +Therefore, if the displayed error comes from this initializer, DirectDraw mode/surface setup is the leading hypothesis. The exact dialog stage label (or a wrapper log showing the last successful API operation) is the cheap check that could disconfirm it. Other startup failures remain possible until that evidence is recorded. + +### Local dxwrapper test on Windows 11 + +The writable test copy at `K:\ghidra\Crusader_Decomp\JP\CRUSADER_JP_ISO` uses the local dxwrapper 1.8.8600.25 payload and its `Stub\ddraw.dll`; the C:\ analysis copy was not modified. The log identifies Windows 11 x64 build 26100 and confirms that `DirectDrawCreate` is redirected to D3D9. + +- With Dd7to9 and a 1920x1440 override but D3D9Ex disabled, device creation failed with `D3DERR_DEVICELOST`; the next logged operation was `m_IDirectDrawSurfaceX::Lock2: d3d9 device not setup`. The Windows error dialog then reported a write access violation at `00468e13`, targeting `0b4e8000`. The lock failure is the best-supported cause chain; the dialog alone does not prove which game data structure supplied that pointer. +- Enabling `D3d9to9Ex` allowed the D3D9Ex device to initialize, but a later write access violation still occurred. Enabling `DdrawEmulateLock` did not prevent the same game instruction (`00468e13`) from faulting; the dxwrapper log recorded exception `0xC0000005` with bad address `0B1B6F4C`. +- An earlier native-resolution comparison restored the game's 640x480 output while retaining `D3d9to9Ex=1`, `DdrawEmulateLock=1`, and a 60 FPS test cap. Its log confirmed a 640x480 D3D device and the process was responsive at the last check; the previously failing gameplay transition still needs to be exercised. The user reports that a 30 FPS cap made the fan animation extremely slow and prevented the initial teleport sequence from initializing, so 30 FPS is not a viable setting for this build. +- The separate 1920x1440 test profile created a 1920x1440 D3D target and measured a top-level window of about 1101x849 at `(549,194)` with caption and thick-frame style bits. The draggable border was observed, but the visible output was not confirmed as a true 3x on-screen scale. +- Decoding `README.TXT` as CP932 confirms a Pentium 90 MHz minimum and a requirement for DirectX 2-compatible graphics/audio; it gives no original FPS target. The 30 FPS cap proved too restrictive. In a later 60-versus-120 FPS comparison, the user reported that 120 FPS made gameplay feel normal; this is not a measured simulation rate or a historically verified target. The text symptom and wrapper tests are documented below. + +### Frame pacing: why the wrapper cap appears half-rate + +The reported result is approximately `gameplay rate = LimitPerFrameFPS / 2`: a 60 cap feels like 30, while a 120 cap feels like the expected 60. These are user-observed settings and gameplay impressions, not measured render or simulation rates. + +The live JP Ghidra trace identifies why an uncapped run can go too fast: + +- `00446250` initializes the window and DirectDraw. Immediately before entering `kernel_process_manager_run_loop` at `0043efe0`, it clears both EAX and EDX at `004462f0`: the loop receives interval `0` and a null optional callback. +- The loop calls `kernel_process_manager_update` every iteration. Its wait target is `start_tick + interval`; with interval `0`, the target is already reached, so the busy-wait exits immediately. The null callback is skipped. The loop records elapsed scheduler units in `DAT_00484368`, but does not globally pace iterations. +- `FUN_00464390` calls `timeGetTime`, converts elapsed milliseconds into 10 ms units, and accumulates those units. This clock quantum feeds some timed/catch-up behavior; it is not a global frame limiter or evidence of a 100 FPS render rate. +- `kernel_process_manager_update` uses separate 16 ms and 66 ms deadlines for timed process events. `SpriteProcess_Run` always performs at least one base pass per invocation; `DAT_00484368` selects up to four additional catch-up passes. Thus animation can advance once on every fast loop iteration even when the elapsed-tick value is zero. +- The inspected primary-surface path at `00445418`/`00445498` checks surface loss, then locks and unlocks the DirectDraw surface. The core scheduler loop itself contains no DirectDraw flip or vertical-blank wait. The two `Sleep` references found elsewhere are a `Sleep(0)` yield and a DirectSound buffer-position polling delay, not a global frame limiter. + +The uncapped-speed cause is therefore in the game loop: its actual startup path supplies no interval, so process updates run as fast as the update body and host allow. The 10 ms clock does not prevent per-invocation behavior from accelerating, and the sprite runner's base pass is per invocation. This explains why removing the wrapper cap can produce speeds well above the intended rate; the exact uncapped multiplier depends on loop throughput and is not fixed at 2x. + +The separate `60 cap -> 30` and `120 cap -> 60` observation still indicates a 2:1 mismatch between the wrapper's counted pacing events and perceived game updates. The inspected primary-surface Lock/Unlock path is relevant to Dd7to9, but static Ghidra analysis cannot establish how many D3D9 presents dxwrapper counts per update. Treat two wrapper-counted events per game update as a hypothesis, not a proven call count. + +The discriminating runtime check is to count `kernel_process_manager_update`/`SpriteProcess_Run` iterations and primary-surface Unlock/D3D9 Present events with no cap, then at caps of 60 and 120. This will measure the uncapped loop throughput and determine whether a 2:1 wrapper-event-to-update ratio explains the capped results. Keep 120 as an empirical compatibility setting, not a verified original target. + +#### Practical pacing and patch options + +- **Keep the 120 FPS wrapper cap as the low-risk workaround.** It is the only setting currently reported to make gameplay feel normal; it is not a measured 60 Hz simulation rate or a historically established target. Keep it in a JP-specific wrapper profile. +- **Test wrapper VSync or frame limiting at a completed-frame boundary.** DDrawCompat or dgVoodoo2 could provide a useful comparison if their wait applies once per completed game frame. The inspected JP path uses primary-surface Lock/Unlock and the core loop has no explicit Flip/vblank wait, so a limiter attached to a lower-level operation could preserve or worsen the observed 2:1 mismatch. These wrapper options are untested for frame pacing. +- **Consider a local pacing shim if wrapper settings cannot identify one frame per update.** A shim that throttles a mapped update boundary is a better conceptual fit than limiting every surface/presentation event, but the correct hook point has not yet been established. Instrument first; do not assume each Unlock or D3D9 Present equals one simulation update. +- **Prototype a version-specific PE interval patch.** Startup clears `EAX` at `004462f2` immediately before calling the main loop, making its interval zero. The existing clock advances in 10 ms units, so interval `1` is approximately a 10 ms/100 Hz wait and interval `2` approximately 20 ms/50 Hz. These are coarse probes, not exact 60 FPS fixes; a stable 60 Hz target would need fractional/accumulator pacing or finer timing and careful interaction with existing elapsed-time catch-up. + +No PE patch or custom shim has been applied. For an executable experiment, use a separate copy, record the exact JP PE hash, resolve the call-site RVA/file offset for that build, and preserve the untouched executable. Compare fan animation, the initial teleport sequence, gameplay timers, input response, and transitions with no cap, interval probes, and the 120-cap baseline before treating any result as a fix. + +#### Original DOS comparison + +The original DOS NE build has the same important pacing property: its main process loop is also entered with a zero tick interval. `Runtime_InitializeCommandLineAndRunLoop_1040_0079` calls `Kernel_RunTimedSchedulerLoop_11d0_31cf` with interval zero and a far callback at `1040:0073`. That callback stub calls `Spanker_CollectProfileAddresses_1218_0953`; the target only records profiler data when profiling flags are enabled, and does not wait for retrace or pace frames. + +`Kernel_RunTimedSchedulerLoop` snapshots the `SystemTimerProcess` counter, calls `Kernel_RunProcessSchedulerIteration_11d0_0255`, invokes the optional callback, then waits until `current_tick >= start_tick + interval`. With the startup interval at zero, that condition is already satisfied on every pass. It records the elapsed timer delta in `1478:3a00/3a02`, but the delta is not a global loop throttle. `Kernel_Init_11d0_000c` sets up the timer-interrupt path and creates/registers the BIOS and system timer processes; `SystemTimerProcess_Increment_11c0_00f8` increments the system timer's 32-bit counter. + +The DOS `SpriteProcess_Run_1138_04e2` also performs one base animation pass on every process-manager iteration and uses elapsed timer ticks to select additional catch-up passes. This closely parallels the JP runner at `00461b50`. The key difference is the clock plumbing: DOS reads an interrupt-maintained `SystemTimerProcess` counter and dispatches DOS timer events, while JP polls WinMM `timeGetTime()` and quantizes elapsed time into 10 ms units. Neither startup path provides a nonzero global frame interval, so both can be host-throughput-sensitive; the DOS timer supports elapsed-time events/catch-up but does not, by itself, pace the main loop. This is static analysis, not a new DOS runtime test. + +### JP text corruption and PE patch feasibility + +The user-provided screenshot shows the game scene and message box rendered normally while the subtitle/menu glyphs appear as fragmented, multicolored pixels. This localizes the visible symptom to text, but does not by itself distinguish bad byte decoding from glyph rasterization or palette conversion. + +On the test machine, `Get-WinSystemLocale` returned `it-IT`, the active ANSI code page (ACP) is 1252, and the OEM code page is 850. The Japanese executable is a 32-bit x86 PE with SHA-256 `037b7d2be829048a1b305eae15e7f78be72329af80425cc32e2f5fcee0ba5231`. These are separate facts: the locale values describe the Windows host, while the following API behavior comes from static analysis of the executable. + +REA/Ghidra 12.1.4 found imports for `CreateFontA`, `GetTextMetricsA`, `TextOutA`, `IsDBCSLeadByte`, and `GetCPInfo`. The font initializer at `0x004100b4` creates a compatible DC and a 32x32 8-bit bitmap, selects a 256-entry palette whose red component is an intensity ramp, and creates a font with charset `0x80` (`SHIFTJIS_CHARSET`) before calling `GetTextMetricsA`. The character-width helper at `0x0040fae8` calls `GetCharWidthA` when it has an HDC. `TextOutA` and `GetCPInfo` are present in the import table, but REA found no resolved direct code callers for them; focused import/procedure searches also found no `GetACP`, `MultiByteToWideChar`, `WideCharToMultiByte`, or explicit locale setter. Dynamic or unresolved indirect calls are not ruled out. Evidence: `ev_de7bd0221ca25ca3a5a8aa606d4b4570686e040fcdccfdad1a063d5f8bcb0b1d`, `ev_9e0169945fe29f6e1a23f0c5d3621722adeb7c881d867dcfe4913dd91088f47f`, and `ev_f9e245025ef4d9c8dd3077053e91028c173b653feb3c5f17fbc73abb8bce8686`. + +`IsDBCSLeadByte` is called at seven resolved sites across six functions: `0x00412d10` copies DBCS text, `0x00413188` walks and wraps text while measuring glyph widths, `0x00428ac8` measures strings, `0x00428be4` and `0x00428d40` combine byte pairs before dispatching them to a glyph/layout helper, and `0x004640b8` scans a tokenized string. For example, `0x00428ac8` combines a lead byte and its following byte before asking a font-like object for a width; `0x00413188` uses the same lead-byte test before calling the `GetCharWidthA` helper. Microsoft documents that `IsDBCSLeadByte` tests the system default ANSI code page (`CP_ACP`), while its `Ex` variant is needed for a specified code page. With ACP 1252, the Japanese CP932 lead-byte ranges are not recognized as DBCS leads. The executable therefore has a concrete dependency on running under a Japanese-compatible ACP, despite selecting a Shift-JIS font charset. Evidence: `ev_b12b18650a53d90c9efb8583e65b7e9939594730dbdb290130f4bbccc080c0f6`, `ev_8cc6c851948c5b1f081ef83f939319c7a5af0f1d06be7ce0bcfc6eb7007f2bf0`, `ev_d8c64f4077ccdbca248a7166bb4dbf5b3612fa979f9e58933996e236db1a06f8`, `ev_dcc900b2086b1da3c5de5eaf7431133f3b1c8a40f739b8d3cf0e24cf480544a6`, `ev_54e5a97e481666d25e6829f052231996050c77fc07566dfba7990ae7222147d9`, and `ev_d0e9fabd41de9d73a68c42250286f5e1d652928e035ffd63b7bbf963c7776ec5`. + +The locale mismatch is a strong explanation for DBCS parsing and measurement errors, but it does not alone explain the rainbow pixel colors. The font path's 8-bit bitmap and custom palette leave a separate GDI/DirectDraw conversion hypothesis open. In the current writable test profile, `DdrawEmulateSurface=1` produced no reported visual improvement and was restored to `0`. Enabling both `DdrawReadFromGDI=1` and `DdrawWriteToGDI=1` produced a completely black game screen; the wrapper log recorded repeated invalid rectangles `{1283,643,640,480}`, then exception `0xC0000005` at address `0x00000000`. Both options were restored to `0`. The current profile keeps `LimitPerFrameFPS=120`; no game bytes or system locale settings have been changed. + +**Executable-hack assessment:** a PE patch is technically possible, but a reliable fix is not yet established. A first, bounded patch could replace the seven `IsDBCSLeadByte` call sites with a fixed CP932 lead-byte predicate (`0x81-0x9f` or `0xe0-0xfc`). That would repair DBCS byte-boundary handling in copying, wrapping, measuring, glyph dispatch, and token scanning, but it would not change the ACP behavior of ANSI GDI calls such as `GetCharWidthA`, nor prove that the 8-bit palette is converted correctly. A complete executable fix may need a CP932-aware shim or conversion to Unicode GDI calls, plus a separate correction to the glyph-bitmap/palette path if the rainbow artifacts remain. This requires tracing the indirect glyph renderer and carefully modifying a version-fingerprinted writable PE; it is substantially more invasive than a one-byte patch. No executable patch has been applied. + +The lowest-risk next discriminator is still a process-local Japanese ACP run, which the user deferred for now; no system-wide locale change is recommended. If CP932 fixes the text, prototype the narrow DBCS patch on a separate writable copy and verify subtitles, confirmation menus, ASCII text, and input. If the rainbow pixels persist under CP932, investigate the custom 8-bit glyph palette and indirect drawing helper before attempting a PE rendering patch. Do not reuse the Western DOS/NE patcher for this PE. + +### English-language content from original game files + +A read-only comparison of Western `STATIC` resources with the writable JP test installation found three likely presentation/data candidates are already byte-identical: + +- `FONTS.FLX` (198,862 bytes) +- `GUMPS.FLX` (501,404 bytes) +- `FIXED.DAT` (3,735,392 bytes) + +Their SHA-256 hashes match between the two compared installs. Replacing these copies with the Western versions would not introduce English text or change the font data. The Western workspace also has a 25,897-byte `FONTS.DAT` that is absent from the JP `STATIC` directory, but its role and JP loader path are not established; its presence alone is not evidence that copying it would help. The identical `FONTS.FLX` also means the observed glyph corruption is not explained by a different Japanese font archive in these installs; it does not rule out the ACP or bitmap/palette issues described above. + +Movie subtitles are a more direct candidate. The JP `FLICS` directory contains `.TXT` sidecars paired with many `.AVI` files. In the sampled `01A.TXT`, each `@frame` marker is followed by an English line and then a Japanese line. The local ScummVM reference documents `.txt` and `.iff` subtitle sidecars for Crusader movies. This supports a low-risk, one-movie experiment: on a separate writable copy, preserve the frame markers and English lines while removing the Japanese lines, then check whether the JP game's movie player displays the English-only sidecar. This is a candidate, not a verified JP runtime behavior; it affects movie subtitles only, not menus or in-game dialogue. + +The script route is possible but substantially less certain. Western `STATIC\\EUSECODE.FLX` is 556,613 bytes; JP `USECODE\\JUSECODE.FLX` is 554,522 bytes. A preliminary header/directory check found 3,074 entries in each and all directory rows pointed within their respective files. That is only coarse structural evidence: the local format extractor is validated against Western `EUSECODE.FLX`, not the JP archive, and matching entry counts do not establish compatible class records, event bodies, or opcodes. The JP interpreter has documented differences, and its `-u`/default archive naming path remains unresolved. Do not replace `JUSECODE.FLX` directly with `EUSECODE.FLX`; first establish the JP loader path and validate compatibility through an isolated override on a disposable copy. See [JP USECODE dispatch analysis](usecode-jp-dispatch-analysis.md) and [JP launch parameters](jp-remorse-cheats-and-launch-params.md). + +The source of specific menu or confirmation strings, including the observed exit text, was not established by this resource comparison. Trace that string to its executable, script, or data source before choosing an English replacement; do not infer it from the movie subtitle mechanism. + +### Established wrapper options + +The options below are local compatibility layers, not proof that this particular game works with them. Test with a writable copy of the JP installation, one wrapper at a time, and preserve the original executable and data. The game requests 640x480 and uses a palette; the current Dd7to9 scaling experiment is a separate profile from the original-mode startup test. + +| Wrapper | Role | Fit for this failure | Caveat | +|---|---|---|---| +| [DDrawCompat](https://github.com/narzoul/DDrawCompat) | Local `ddraw.dll` compatibility implementation for legacy DirectDraw | **First test.** It is the least transformative first probe: it can mediate DirectDraw mode, surface, and fullscreen behavior while keeping the game's DirectDraw API path. Its per-directory configuration and logs are useful for recording the failing stage. | It is a DirectDraw layer, not an automatic API rewrite. If the failure requires a different rendering backend rather than compatibility fixes, this may not be enough. | +| [dxwrapper](https://github.com/elishacloud/dxwrapper), feature [Dd7to9](https://github.com/elishacloud/dxwrapper/wiki/DirectDraw-to-Direct3D9-Conversion) | Local proxy wrapper; Dd7to9 translates DirectDraw 1-7 calls to Direct3D 9 | **Tested locally; D3D9Ex creates the device and the bordered-window style is observed, but lock emulation did not prevent a later game access violation.** | The project notes that most DirectDraw APIs are implemented, not all. DirectSound handling is separate from Dd7to9; do not assume the graphics conversion fixes audio. Mixed GDI/DirectDraw, surface locks, and palette behavior may need per-game configuration. | +| [dgVoodoo2](https://dege.freeweb.hu/dgVoodoo2/ReadmeDirectX/) | Local DirectDraw/Direct3D emulation with configurable virtual devices and output | **Third comparison.** It supports classic resolutions including 640x480 and can emulate old DirectDraw behavior through a different implementation. | Its documentation warns that some old GDI/DirectDraw interactions are incomplete and that forced-resolution upscaling is a poor first setting for 8-bit palettized DirectDraw content. Use its local game-folder setup; do not copy wrapper DLLs into Windows system directories. | + +Suggested test sequence: + +1. Record the exact DirectX dialog text, Windows version, executable hash, and whether the error names a DirectDraw stage. Start with no wrapper on an untouched test copy. +2. Add only DDrawCompat beside the copied executable, enable its normal logging, and retry without changing the requested 640x480 mode. Save the log and note whether the dialog changes or startup advances. +3. Remove/disable that wrapper before trying dxwrapper with only `Dd7to9` enabled; preserve its logs. If DirectDraw initializes but sound fails later, investigate the separate DirectSound path rather than changing the DDraw configuration blindly. +4. Repeat as an independent dgVoodoo2 test. Do not combine wrappers, install the bundled DirectX 2/3 setup payloads on modern Windows, or change system DLLs/registry settings as part of this comparison. + +DDrawCompat remains an untested comparison because it preserves the DirectDraw API path. Dd7to9 is the only wrapper tested so far; its current test reaches device creation and requests a bordered window, but the game transition and text rendering remain open. dgVoodoo2 is also untested. Do not treat any wrapper as a completed compatibility solution until gameplay, text, input, audio, and shutdown have been checked. + +## Modding And Rebuild Practicality + +### Modding relative to Western DOS retail + +JP is a better target for understanding and patching Windows-facing behavior: it has a flat 32-bit PE image, Windows imports, and linear addresses, avoiding much of the DOS build's segmented pointer, far-call, and NE-fixup friction. A tightly scoped PE patch or local proxy is consequently more approachable than creating a new DOS NE segment. This does not give JP a supported plugin ABI, and data/archive rebuild-and-load remains unproven. + +Western DOS retail has the opposite advantage: the repository already documents concrete `STATIC\\FIXED.DAT` and `-u` replacement paths plus a cautious NE patch workflow. Those mechanisms and patch definitions are build-specific and must not be carried over to JP. JP has its own `JUSECODE.FLX`/override uncertainty, differing map payloads and USECODE behavior, so treat its data and executable as a separate versioned mod target. For narrow data/script changes, the DOS path currently has better-established evidence; for Windows API experiments and a future native PE patch, JP has the simpler executable model. + +### Can the JP executable be rebuilt? + +The extracted CD tree at `C:\\RE\\CRUSADER_JP_ISO` contains the compiled executable, setup files, and game resources. A targeted search for common C/C++/assembly sources and native project/make files found none there. This only establishes that the supplied CD tree does not expose those build inputs; it cannot rule out separate archival source elsewhere. + +Decompilation is not a substitute for that missing source. Even the much-studied Western executable's exports contain unresolved calling conventions, undefined-width values, synthetic temporaries, segmented-pointer reconstruction, and provisional data layouts. The JP PE removes the NE/far-call burden but still needs type and ABI recovery, correct resource and startup behavior, and a complete replacement for the original build and runtime environment. No complete JP function-equivalence map, recovered JP source tree, compiler/toolchain, or link/resource recipe is established here. + +The realistic options are distinct: + +- **Reproduce the original bytes:** not supported by current evidence and unlikely without original source, exact toolchain, build scripts, and assets in their original build form. Decompiled C cannot establish byte identity. +- **Build a behaviorally similar native game:** possible in principle, but it is a large source-port/reimplementation effort. The existing [Windows rebuild roadmap](remorse-windows-rebuild-roadmap.md) describes an incomplete host implementation based primarily on Western DOS exports; it is not a JP rebuild pipeline or a near-term way to regenerate `CRUSADER.EXE`. +- **Modify the existing JP game:** the pragmatic route for bounded changes. Prefer version-fingerprinted PE edits, established local wrappers, or validated JP-specific data replacement. Test each against a separate copy and preserve a clean baseline. + +**Rebuild verdict:** a very similar executable is a research project, not a build step available from the CD or current decompilation. A localized mod/compatibility shim has a much better cost-to-result ratio; pursue a source port only if the goal justifies implementing and validating the whole runtime over time. + +## Decompilation And Reverse-Engineering Differences + +| Surface | Japanese Windows build | Western retail build | +|---|---|---| +| Executable model | Flat Win32 PE image, reported at `0x00400000` | DOS MZ containing an NE image, with Phar Lap protected-mode loading | +| Addressing | Linear 32-bit addresses and PE imports/relocations | Segment:offset addresses, far calls, NE fixups, extender/runtime services | +| Platform boundary | Windows windowing, registry, DirectDraw/DirectSound, WinMM | DOS/extender, segmented memory, hardware/service calls, DOS-oriented paths | +| Decompiler friction | Win32 API behavior, flat pointers, Windows structures; still has ABI/type recovery work | 16-bit widths, near/far pointer provenance, segmented calls, loader fixups, uncertain conventions | +| Reuse value | Native Windows implementation and semantic parallels | Canonical target for current Western exports, ABI work, and NE patches | + +These are distinct implementations, not two load formats for an interchangeable binary. JP addresses do not map to NE addresses by a constant offset. PE and NE relocations, pointer widths, calling conventions, and data layouts require independent recovery. JP decompilation is not a source drop-in for `exports/src_remorse`, and the Western NE patcher cannot patch the JP PE. + +There is meaningful overlap at the behavior and data level: JP retains USECODE execution, familiar launch/cheat concepts, and shared assets such as `COMBAT.DAT`. But the JP debugger and opcode analyses show implementation differences. Use function comparisons to test specific hypotheses; do not infer source identity from matching names, strings, or file formats. + +No complete function-by-function JP-versus-Western diff is claimed. Existing evidence is strongest for executable format, Windows integration, selected USECODE behavior, and resource/export differences. A broader code-equivalence map needs a dedicated comparison pass. + +## Recommended Next Work + +1. **Runtime gate:** launch the unmodified JP game on Windows 10 and 11 x64 from a writable copy; establish startup, menu/game entry, resolution, input, audio, config/save paths, and shutdown. +2. **Loader gate:** trace/test JP lookup for `FIXED.DAT`, `JUSECODE.FLX`, palette, and core assets. Resolve the `JUSECODE.FLX` versus `eusecode.flx` discrepancy before recommending overrides. +3. **Data-mod gate:** make one reversible JP map or asset edit, rebuild it, and prove the original executable loads it. Renderer export success is not this gate. +4. **USECODE gate:** establish a JP-compatible round-trip/compiler corpus and compare supported opcodes, intrinsics, class/event tables, and archive conventions before porting Western scripts. +5. **Patch gate:** fingerprint the JP PE and prototype one low-risk reversible patch only after launch behavior is known. Define PE-specific RVA/file-offset and relocation handling; do not reuse NE patch records. +6. **Cross-build gate:** maintain separate JP and Western retail test profiles, promoting only verified shared formats or behavior into common tooling. +7. **English subtitle probe:** on a separate writable copy, create an English-only version of one paired JP movie subtitle file while preserving `@frame` markers, then verify that the JP movie player displays it. Keep the original sidecar unchanged and record the tested movie and result. + +## Evidence Boundary + +This assessment combines the existing live-Ghidra JP Win9x, launch-parameter, debugger, and USECODE investigations with local version/resource comparisons, a targeted scan of the supplied CD tree, direct inspection of JP `video_init_directdraw_and_directsound` at `004459b0`, the frame-pacing trace at `0043efe0`/`00464390`/`00461b50`, and the bounded Windows 11 dxwrapper tests above. The English-resource comparison used Western `STATIC` files and the writable K: JP test copy; it confirmed matching hashes for `FONTS.FLX`, `GUMPS.FLX`, and `FIXED.DAT`, sampled the bilingual JP `FLICS/01A.TXT`, and performed only a coarse USECODE directory-bounds check. No game resources were edited and no English-only subtitle or USECODE override was runtime-tested. The 1920x1440 run still faulted at `00468e13` with lock emulation enabled; the native-resolution comparison is awaiting the same gameplay transition. No runtime counter comparison of scheduler updates against D3D9 presents has been performed, so the wrapper-side 2:1 explanation remains an evidence-backed hypothesis. This note does not claim a complete Windows 10/11 runtime pass, successful JP asset rebuild-and-load, or complete function-level equivalence. Those remain explicit validation gates. \ No newline at end of file diff --git a/docs/observer-npc-analysis.md b/docs/observer-npc-analysis.md new file mode 100644 index 0000000..2849a3e --- /dev/null +++ b/docs/observer-npc-analysis.md @@ -0,0 +1,120 @@ +# No Remorse Observer NPC Investigation + +## Executive Read + +No Remorse has a real NPC definition named `Observer`: DTABLE row `6` selects actor shape `0x033c` (`828`). The strongest evidence does not support a unique Observer-specific AI script. Instead, row 6 configures the normal native NPC activity system with a pacing activity and two `Attack5` defaults. The resulting behavior is a mobile actor that can transition into the shared attack process when its visibility/alert path fires. + +The unusual part is the mismatch between that ordinary combat-capable runtime profile and the sparse presentation/content evidence: the Observer class has only one short event body, its current renderer preview deliberately avoids lower frames because they are blank or broken, and map records that resolve to Observer are often paired controller records rather than unambiguous actor spawns. "Unused" is therefore a plausible description of its encounter role, not a proven description of its executable/data status. + +## Identity And Data + +No Remorse `STATIC/DTABLE.FLX` contains row `6`: + +| Field | Value | Meaning / evidence | +|---|---:|---| +| Name | `Observer` | DTABLE name object 2, row 6 | +| NPC row | `6` | Index used by the DTABLE-backed NPC creation path | +| Shape | `0x033c` (`828`) | Actor shape stored at NPCDat offset `0x3e` | +| HP range | `35-45` | Minimum/maximum HP at row offsets `0x00/0x02` | +| Weapon selectors | `1 / 2` | Words at offsets `0x18/0x1a`; these are data selectors, not proof of two simultaneously equipped weapons | +| Default activities | `3 / 5 / 5` | Words at offsets `0x1e`, `0x40`, and `0x42` | + +The 142-byte NPCDat row and parallel 32-byte name row are loaded from FLEX objects 0 and 2. The layout is corroborated by the `NPCDat` reader and the local [NPC spawner investigation](map_renderer/npc-spawners.md). Native `NPC_SetDataFromDTable` (`10e8:0152`) reads a `0x8e`-byte row into a local buffer, equips a weapon using the row's `+0x18` selector when nonzero, and writes the three activity fields into the actor's `0x06/0x08/0x0a` activity slots. + +Shape `0x033c` is an NPC because it is the shape in DTABLE row 6 and is referenced as Observer's actor shape by the spawn data. The map renderer's catalog currently labels it `Helper Geometry` and notes that its display name was derived from NPC self-shape comparison in USECODE; that catalog label is not evidence that the actor is scenery. + +## Native AI + +### Configured Activities + +The activity values are named in the live No Remorse `CRUSADER.EXE` Ghidra database: + +| DTABLE field | Value | Native activity | Effect when selected | +|---|---:|---|---| +| `0x06` / default activity 0 | `3` | `Pace` | Creates `PaceProcess` (`1100:0693`, run at `1100:0708`) | +| `0x08` / default activity 1 | `5` | `Attack5` | Creates the shared `AttackProcess` | +| `0x0a` / default activity 2 | `5` | `Attack5` | Same activity family; used by other callers that select activity field `0x0a` | + +`NPC_StartNextNPCActivityBehaviorProcess` (`10e8:2cfa`) resolves special activity selectors for fields `0x06`, `0x08`, and `0x0a`, then applies common gates: the NPC must be alive, not the controlled actor, not suppressed by the relevant actor flag, and inside a fast area before an activity process is created. It records current/previous activity and avoids restarting an activity that is already current. `NPC_ResetForEgg` (`10d8:04b1`) is a confirmed creation path that loads/sets the three activity fields and starts the field-`0x06` activity. Exact authored `0x04d0` spawner pairs can also supply activity values through their paired records, so the DTABLE row is the baseline profile, not a guarantee that every map instance uses all three unmodified. + +### Observer's Likely Runtime Loop + +For an Observer whose initial field-`0x06` activity remains DTABLE value `3`, the expected loop is: + +1. Start `PaceProcess`, rather than `GuardProcess` or `LoiterProcess`. +2. Before pacing, `PaceProcess::Run` calls `NPC_StartBehaviorInField0x8IfCanSeeControlledNPC` (`1100:026e`). That helper checks that the actor is entirely on screen, field `0x08` is nonzero, the current activity is not already the field-`0x08` activity, and the controlled NPC is visible. +3. If those checks pass, field `0x08` is selected. For Observer, that is `Attack5`, which creates the common attack process. +4. Otherwise, when not busy, `PaceProcess::Run` tries a walk animation in the actor's current direction. A successful walk clears its local failed-step count and waits for the animation. After a failed walk, it performs a stand/turn-around response and waits 60 ticks; after more than one failed step it requests another activity. +5. That blocked-movement fallback requests `Attack5` for ordinary shapes. The explicit surrender exceptions in the native branch are shapes `0x2f5`, `0x2f7`, `0x2f6`, `0x344`, and `0x597`; Observer shape `0x033c` is not in that list. + +This makes Observer a pacing/roaming combat actor, not an inert lookout. However, this code does not prove that every Observer placement immediately sees or attacks the player: visibility, fast-area activation, busy state, and map-specific activity overrides all gate the transition. + +`Attack5` is an activity/process selector, not a literal weapon or a complete behavior description. The resulting `AttackProcess` uses the actor's combat-tactic state and `COMBAT.DAT` machinery. The confirmed egg reset path initializes tactic number `0`; [the COMBAT.DAT analysis](combat-dat.md) records the shipped tactic 0 name `Dumb` and an unresolved compatibility detail around how tactic 0 is interpreted. Do not infer a precise firing pattern for every Observer spawn from the activity value alone. At difficulty level `4`, the native selector can randomly remap an `Attack5` request to `AttackA` (`10e8:2cfa`); this is shared NPC behavior, not an Observer-specific rule. + +### No Bespoke Observer AI Script + +The extracted `OBSERVER` class (`0x033c`) has no bodies for `setActivity`, `hit`, `gotHit`, `schedule`, `enterFastArea`, or the other common events. Its only non-empty common event is slot `0x0e`, `calledFromAnim`: + +```text +set_info(0x021A, *(arg_06)); +process_exclude(); +return; +``` + +That is a short state/process callback, not a custom movement or combat routine. Compare the neighboring `GUARD` and `SCIENTIS` slot-`0x0e` bodies: both perform the same setup and additionally spawn `NPCDEATH.slot_20`. Observer's body does not. This is a real script difference, but it only proves that Observer omits that scripted callback; it does not prove that the engine has no native death handling. + +The distinction between actor identity and controller identity matters here. Shape `0x04d0` uses the `MONSTER` class as a spawner/controller. Its `enterFastArea` body checks frame 0 and `mapNum & 8`, then launches `MONSTER.equip`; paired `ITEM.slot_2D` logic handles actor creation. Those `MONSTER` event bodies are not Observer's AI. See [the paired-spawner investigation](map_1_spawners_targeted_investigation.md) for the unresolved question of which member of some frame-0/frame-1 pairs supplies the final spawned NPC row. + +## Comparison With Similar NPCs + +All values below are from the No Remorse DTABLE rows; activity names are the native enum values. + +| NPC row | Shape | HP | Weapon selectors `+0x18/+0x1a` | Activities `0x06/0x08/0x0a` | Main contrast | +|---|---:|---:|---:|---|---| +| Observer `6` | `0x033c` | `35-45` | `1 / 2` | `Pace / Attack5 / Attack5` | Baseline under investigation | +| GUARD `4` | `0x02fd` | `20-35` | `1 / 2` | `Pace / Attack5 / Attack5` | Same activity profile and weapon selectors, lower HP; its animation callback adds `NPCDEATH` | +| Thermatron `10` | `0x0338` | `250-250` | `7 / 5` | `Pace / Attack5 / Attack5` | Same activity profile, much higher HP and different weapon selectors | +| RoamingSusan `11` | `0x02cb` | `35-45` | `1 / 2` | `Loiter / Attack5 / Attack5` | Same HP and weapon selectors; starts in `Loiter`, not `Pace` | +| Scientist `7` | `0x0344` | `5-12` | `0 / 0` | `Loiter / Attack5 / Attack5` | Unarmed selectors and low HP; `PaceProcess` specifically treats this shape as a surrender exception after repeated blocked steps | +| Vetron `19` | `0x04e6` | `425-625` | `9 / 10` | `Pace / Attack5 / AttackA` | Same initial activity family, much higher HP and a distinct third default | + +The most useful comparison is not simply Observer versus the NPC named GUARD. Observer shares GUARD's and Thermatron's default activity tuple, but the activity value `3` starts `PaceProcess`; the named `GuardProcess` is selected by the separate activity value `8`. Observer therefore does not inherit the named Guard's stationary guard/idle loop just because the DTABLE contains an armed humanoid row or the character is called Observer. + +At the process level, `GuardProcess::Run` (`1100:0a0e`) attacks when the player is visible and otherwise sleeps or chooses random idle animations. `LoiterProcess::Run` (`1100:0bfa`) plays idle animations or pathfinds to randomized points near its anchor. Observer's activity `3` chooses the distinct `PaceProcess`, which attempts a directional walk and can transition to field `0x08`'s attack behavior. These process differences are stronger evidence than visual resemblance or class names. + +## Maps And Spawn Evidence + +The current No Remorse map-export audit reports DTABLE row 6 on maps `6, 7, 9, 16, 23, 42, 47, 55, 56, 62, 69, 116, 170, 248`. The No Remorse demo audit reports no Observer map occurrence. This establishes map-data presence in retail exports, not that every listed map is an intended encounter or that every preview resolves to a live Observer. The audit is maintained in the [map-viewer NPC spawn audit](../../crusader_map_viewer/map_renderer/docs/npc-spawn-audit.md). + +Examples that show why the distinction matters: + +- Remorse map 69 has a frame-0 family-7 `0x024f` monster egg with `npcNum = 6`, which resolves directly to Observer in the current preview pipeline. +- On map 1, a frame-0 `0x04d0` record with `npcNum = 6` is paired with a frame-1 record resolving to RoamingSusan, ChemSuitGuy, or GUARD. The `MONSTER` controller can be dormant or paired; those records are not equivalent proof of an Observer actor. +- On map 248, some frame-1 `0x04d0` records resolve to Observer while their paired frame-0 controller records contain `npcNum` values such as `100` or `134`, which do not resolve in the current Remorse DTABLE preview. These are stronger Observer-spawn candidates, but the paired creation arguments still need a call-site-level close. + +These examples and the broader pair scan are detailed in [the map-1 spawner investigation](map_1_spawners_targeted_investigation.md). The evidence supports calling Observer a shipped, spawnable NPC definition with map placements. It does not establish that maps 6, 7, or 248 are all "unused," nor does the label `Observer` by itself establish a surveillance-specific combat role. + +## Sprite And Presentation State + +The No Remorse reference data identifies shape `0x033c` as an NPC-derived shape, but the current map renderer has only indexed Observer sprite entries at frames `7` (`121 x 98`) and `15` (`48 x 35`). Its preview code explicitly chooses frame `0x0f` for Observer because lower-numbered preview frames are blank or broken. That is concrete evidence of incomplete usable preview art in the current pipeline and is consistent with the reported missing orientations. + +The atlas is a curated set of scene/preview sprites, not a complete inventory of every frame in `SHAPES.FLX`. The code's `frames.length > 15` test establishes that frame 15 exists in the loaded shape, but the two indexed atlas entries do not establish that the full shape contains only two frames. Exact missing facings and animation sets remain unverified; do not treat frame numbers 7 and 15 as a complete orientation table. + +## Open Questions And Next Checks + +1. Enumerate shape `0x033c` directly from the full No Remorse `SHAPES.FLX`; classify blank frames, animation groups, and facing coverage instead of relying on the preview atlas. +2. Trace every map-69 `0x024f` Observer egg through its trigger, difficulty gate, and field-`0x06` activity startup in the retail executable. +3. Close the `0x04d0` paired-spawner call argument ownership so frame-0/frame-1 pairs can be classified as actual Observer spawns or controller-only records. +4. Recover the initial activity and combat-tactic values for actors created through the `0x04d0` path, including whether map/partner fields override DTABLE row 6. +5. Test the Observer `calledFromAnim` path in a live No Remorse session and determine whether native death handling replaces the absent `NPCDEATH.slot_20` callback. +6. Compare retail `CRUSADER.EXE` handling of tactic 0 against shipped `COMBAT.DAT` entry `Dumb` to establish Observer's concrete weapon/fire loop on the egg-spawn path. +7. Audit the listed map IDs against mission routing and editor-only/unreachable status before labeling any placement definitively unused. + +## Evidence Pointers + +- No Remorse DTABLE and NPC row layout: [NPC spawner data](map_renderer/npc-spawners.md), `STATIC/DTABLE.FLX`, and ScummVM's [NPCDat loader](https://raw.githubusercontent.com/scummvm/scummvm/master/engines/ultima/ultima8/world/actors/npc_dat.cpp). +- Observer event body and class slots: `USECODE/EUSECODE_extracted/pseudocode/OBSERVER/slot_0E_calledFromAnim.txt` and `USECODE/EUSECODE_extracted/class_event_index.tsv`. +- Native activity selection: `NPC_SetDataFromDTable` (`10e8:0152`), `NPC_StartNextNPCActivityBehaviorProcess` (`10e8:2cfa`), `NPC_StartBehaviorInField0x8IfCanSeeControlledNPC` (`1100:026e`), `PaceProcess::Run` (`1100:0708`), `GuardProcess::Run` (`1100:0a0e`), and `LoiterProcess::Run` (`1100:0bfa`) in live No Remorse `CRUSADER.EXE`. +- Process family ownership: [NPC action process layout](npc-action-process-class-layout.md). +- `0x04d0` controller and map pair evidence: [NPC spawners](map_renderer/npc-spawners.md) and [targeted map investigation](map_1_spawners_targeted_investigation.md). +- Combat tactic data and tactic-0 caveat: [COMBAT.DAT](combat-dat.md). \ No newline at end of file diff --git a/docs/spice86/README.md b/docs/spice86/README.md new file mode 100644 index 0000000..93f8b33 --- /dev/null +++ b/docs/spice86/README.md @@ -0,0 +1,598 @@ +# Spice86 - A PC emulator for real mode reverse engineering + +![Linux](https://img.shields.io/badge/-Linux-grey?logo=linux) +![macOS](https://img.shields.io/badge/-OSX-black?logo=apple) +![Windows](https://img.shields.io/badge/-Windows-red?logo=windows) +[![.NET Build](https://github.com/OpenRakis/Spice86/actions/workflows/prerelease.yml/badge.svg)](https://github.com/OpenRakis/Spice86/actions/workflows/prerelease.yml) +[![NuGet](https://img.shields.io/nuget/v/Spice86.svg)](https://www.nuget.org/packages/Spice86) +![Licence](https://img.shields.io/badge/License-Apache_2.0-44cc11.svg) +[![downloads](https://img.shields.io/nuget/dt/Spice86)](https://www.nuget.org/packages/Spice86) + +Spice86 is a tool to execute, reverse engineer and rewrite real mode DOS programs for which source code is not available. + +Releases are available [on Nuget](https://www.nuget.org/packages/Spice86/). + +Pre-releases are also available [on the Release page](https://github.com/OpenRakis/Spice86/releases/tag/latest) + +NOTE: This is a port, and a continuation from the [original Java Spice86](https://github.com/kevinferrare/spice86). + +It requires [.NET 10](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) and runs on Windows, macOS, and Linux. + +## Approach + +Rewriting a program from only the binary is a hard task. + +Spice86 is a tool that helps you do so with a methodic divide and conquer approach. + +General process: + +- You start by emulating the program in the Spice86 emulator. +- As the program runs, Spice86 builds a Control Flow Graph (CFG) of the executed code. +- At the end of each run, the emulator dumps some runtime data (memory dump, execution flow and the CFG). +- From that CFG, Spice86 **directly generates a self-contained, runnable C# project** that overrides the original assembly with equivalent C# code. +- You then gradually rewrite the generated C# functions, replacing the mechanical translation with readable, intentful code (a task an LLM can help with). +- This is helpful because: + - Small sequences of assembly can be statically analyzed and are generally easy to translate to a higher level language. + - You work all the time with a fully working version of the program so it is relatively easy to catch mistakes early. + - Rewriting code function by function allows you to discover the intent of the author. + +Spice86 also dumps Ghidra-compatible symbols, so you can **optionally** load the memory dump into [Ghidra](https://github.com/NationalSecurityAgency/ghidra) via the [spice86-ghidra-plugin](https://github.com/OpenRakis/spice86-ghidra-plugin) for deeper static analysis. This is no longer required to produce C# overrides; it is just an extra analysis aid. + +## Running your exe + +| Command | Description | +|---------|-------------| +| `Spice86 -e file.exe` | Run the specified executable | +| `Spice86 -e file.com` | Run a COM file | +| `Spice86 -e file.bat` | Run a DOS batch file | +| `Spice86 -e file.bin` | Run a BIOS file | + +## Dumping data + +| Setting | Description | +|---------|-------------| +| Environment Variable | `SPICE86_DUMPS_FOLDER` - Set this to control the base directory where data is dumped | +| Command Line | Use `--RecordedDataDirectory` to specify the base dump location | +| Default Location | Current directory if neither of the above is specified | + +**Note:** Regardless of the base directory setting, dumps are always placed in a subdirectory named with the program's SHA-256 hash. This ensures that multiple executables from the same game (e.g., SETUP.EXE, GAME.EXE) have isolated dump folders. + +The emulator dumps the following files: + +- **spice86dumpMemoryDump.bin**: Snapshot of the real mode address space +- **spice86dumpExecutionFlow.json**: Contains function addresses, labels, and executed instructions +- **spice86dumpGhidraSymbols.txt**: Ghidra-compatible symbols (function and label addresses), for optional import into Ghidra +- **spice86dumpCfgBlocks.json**: The explored CFG as basic blocks with execution-context metadata +- **spice86dumpCfgPartitions.json**: The recovered function/helper partitions and inter-partition transfers, derived from the block graph +- **spice86dumpCfgGeneratedOverrides.cs**: C# overrides generated from the explored CFG +- **GeneratedProject/**: A self-contained, runnable C# override project (see [Generated C# override project](#generated-c-override-project)) + +When there is already data in the specified location, the emulator will load it first and complement it. + +**CFG graph reload:** The CFG instruction graph is also dumped (**spice86dumpCfgReload.json**) and, by default, reloaded from the recorded data directory at startup so previously explored program structure is preserved across runs. Disable with `--ReloadCfgGraph false`. It is a no-op if the file is absent. + +**Code overrides:** When code overrides are active (`--UseCodeOverride true` with an `--OverrideSupplierClassName`), the CFG and execution flow dumps (**spice86dumpExecutionFlow.json**, **spice86dumpCfgBlocks.json**, **spice86dumpCfgPartitions.json**, **spice86dumpCfgReload.json**) are not written. Overrides replace the emulated asm, so the recorded graph would jump between overrides and no longer reflect the program. + +### CPU Heavy Logging + +For detailed debugging, you can enable CPU heavy logging which records every executed instruction to a file. + +**⚠️ Warning:** This feature has a significant performance impact and should only be used for debugging purposes. + +| Setting | Description | +|---------|-------------| +| `--CpuHeavyLog` | Enables CPU heavy logging (default: false) | +| `--CpuHeavyLogDumpFile` | Custom path for the log file (optional). If set, will enable CpuHeavyLog as well. Default Location: `{DumpDirectory}/cpu_heavy.log` | +| `--CpuHeavyLogExpressions` | Named expressions appended to every CPU heavy log line. Repeat the option for each expression to append (for example: `--CpuHeavyLogExpressions "life=AX+1" --CpuHeavyLogExpressions "myvalue=word ptr DS:[0x456]"`). Only active when `--CpuHeavyLog` is true. | + +**Log Format:** Each line contains: `SegmentedAddress InstructionString` + +**Example:** + +``` +017D:0000 mov AX,0xDD1D +017D:0003 call near 0xE4AD +017D:E4AD mov SI,0x0080 +``` + +**Usage:** + +```bash +# Enable with default location +Spice86 -e program.exe --CpuHeavyLog + +# Use custom log file path +Spice86 -e program.exe --CpuHeavyLog --CpuHeavyLogDumpFile "C:\logs\cpu.log" + +# Append named expressions to each log line (example) +Spice86 -e program.exe --CpuHeavyLog \ + --CpuHeavyLogExpressions "life=AX+1" \ + --CpuHeavyLogExpressions "myvalue=word ptr DS:[0x456]" +``` + + +## Command line options + +``` + --Debug (Default: false) Starts the program paused and pauses once again when stopping. + --Cycles (Default: null) Target CPU cycles per ms, for the rare speed sensitive game. 3000 by default. Overrides Instructions per second option below if used. + --Xms (Default: true) Enables 15 MB of XMS memory. + --Ems (Default: true) Enables EMS memory. EMS adds 8 MB of memory accessible to DOS programs through the EMM Page Frame. + --A20Gate (Default: false) Disables the 20th address line to support programs relying on the rollover of memory addresses above the HMA (slightly above 1 MB). + -m, --Mt32RomsPath Zip file or directory containing the MT-32 ROM files + -c, --CDrive Path to C drive, default is exe parent + -r, --RecordedDataDirectory Directory to dump data to when not specified otherwise. If blank dumps to SPICE86_DUMPS_FOLDER, and if not defined dumps to a sub directory named with the program SHA 256 signature + -e, --Exe Required. Path to executable + -a, --ExeArgs List of parameters to give to the emulated program + -x, --ExpectedChecksum Hexadecimal string representing the expected SHA256 checksum of the emulated program + -f, --FailOnUnhandledPort (Default: false) If true, will fail when encountering an unhandled IO port. Useful to check for unimplemented hardware. false by default. + -g, --GdbPort GDB port. If 0, GDB server will be disabled. Default is 10000. + -o, --OverrideSupplierClassName Name of a class that will generate the initial function information. See documentation for more information. + -p, --ProgramEntryPointSegment (Default: 4096) Segment where to load the program. DOS PSP and MCB will be created before it. + -u, --UseCodeOverride (Default: true) if false it will use the names provided by overrideSupplierClassName but not the code + -i, --InstructionTimeScale if blank will use time based timer. + --ClockJitterSeed Optional integer seed enabling small deterministic clock jitter (±0.01 ms). Omit to disable. + --ClockStartTime Optional UTC start date/time for the emulated clock (parseable by DateTime.Parse, e.g. 1993-06-01T00:00:00Z). When omitted defaults to the current UTC time. + -t, --TimeMultiplier (Default: 1)