mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
7c40d33db3
Phase 1a (boot slice): 30 instructions at 0xBFC00000, compiles clean. Phase 1b (instruction coverage): 54 opcodes implemented in strict_translator, 44,629 walker-reachable instructions covered, 0 missing. Phase 1c (function discovery): 76 functions from 2 seeds, 2,988 instructions, 199 call edges, 27 indirect jumps. All validated through StrictTranslator. Phase 1d (indirect control flow): 27 sites classified — 21 A0/B0/C0 dispatch stubs, 4 computed calls, 2 computed tail calls. Ghidra cross-referenced with 0 disagreements. Phase 1e (relocation): ROM-to-RAM copy at FUN_bfc00420 proven with both Ghidra (static) and DuckStation (runtime). 69 address aliases, 68/69 function entries match byte-for-byte in RAM. Normalization rule documented. Includes PRINCIPLES.md and DEBUG.md adapted from recomp-template. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#pragma once
|
|
/*
|
|
* annotations.hpp — PS1 address annotation table
|
|
*
|
|
* Generic mechanism: loads a CSV file of (address, note) tuples and makes them
|
|
* available to the code generator for inline comment emission.
|
|
*
|
|
* The CSV is game-specific data; this module is game-agnostic.
|
|
* The code generator calls annotation_lookup(addr) at each function emit point
|
|
* and prepends the result as a C block comment if present.
|
|
*
|
|
* CSV format (one entry per line):
|
|
* # comment lines and blank lines are ignored
|
|
* 0x8001dfd4, entity tick dispatcher — iterates 200 entity slots
|
|
*
|
|
* address: hex with 0x prefix (e.g. 0x8001dfd4) or decimal
|
|
* note: free text; may contain commas; appears as [NOTE] in generated C
|
|
*
|
|
* Convention: place annotation files at annotations/<exe_stem>_annotations.csv
|
|
* in the project root. The recompiler looks for this path relative to CWD.
|
|
*/
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace PSXRecomp {
|
|
|
|
class AnnotationTable {
|
|
public:
|
|
// Load CSV from path. Silently succeeds with empty table if file not found.
|
|
// Returns true if any entries were loaded.
|
|
bool load(const char* csv_path);
|
|
|
|
// Returns the note string for addr, or empty string if no entry exists.
|
|
const std::string& lookup(uint32_t addr) const;
|
|
|
|
int count() const { return static_cast<int>(table_.size()); }
|
|
|
|
private:
|
|
std::unordered_map<uint32_t, std::string> table_;
|
|
static const std::string empty_;
|
|
};
|
|
|
|
} // namespace PSXRecomp
|