The ROM loading API has been simplified to focus on binary file loading only, removing the array-based loading method that was never actually used in production code.
Removed:
loadROM(array $romData): void- Array-based loading (unused)loadBinaryROM(string $binaryFile): void- Old method name
Added:
loadFromFile(string $path, ?int $loadAddress = null): void- Simplified, clearer name with optional load address
Rationale:
- ROM represents physical hardware that loads from binary files
- Tests don't need ROM - they use
SimpleBuswhich is all RAM - Array loading was only in documentation examples, never used in actual code
- Simpler API with single, clear loading method
Changed:
- Now implements
ROMInterfaceexplicitly - Renamed
loadBinaryROM()→loadFromFile() - Removed
loadROM(array)method entirely - Added
loadAddressparameter toloadFromFile()for custom load addresses
Added Interface Methods:
getStartAddress(): int- Returns 0x8000getEndAddress(): int- Returns 0xFFFFgetSize(): int- Returns 0x8000 (32KB)handlesAddress(int $address): bool- Checks if address is in ROM range
docs/INSTRUCTIONS.md:
- Changed
$rom->loadBinaryROM('file.bin')→$rom->loadFromFile('file.bin') - Removed array loading example
- Added custom load address example:
$rom->loadFromFile('program.bin', 0xC000)
CLAUDE.md:
- Updated ROM documentation to mention
ROMInterfaceimplementation - Documented
loadFromFile()andloadFromDirectory()methods
// Loading from binary file
$rom->loadBinaryROM('roms/wozmon.bin');
// Loading from array (for tests - NOT RECOMMENDED)
$rom->loadROM([
0x8000 => 0xA9,
0x8001 => 0x42
]);// Loading from binary file
$rom->loadFromFile('roms/wozmon.bin');
// Loading with custom address
$rom->loadFromFile('roms/program.bin', 0xC000);
// For tests - use SimpleBus instead
$bus = new SimpleBus();
$bus->loadProgram(0x8000, [0xA9, 0x42]);- Clarity - ROM models physical hardware, which loads from files
- Simplicity - Single method instead of two
- Removes Dead Code - Array loading was never used
- Better Testing Pattern - Tests should use SimpleBus, not ROM
- Flexibility - Optional load address parameter for advanced use cases
All tests pass (same failures as before, unrelated to ROM):
./vendor/bin/phpunit
# Tests: 56, Assertions: 156, Failures: 6 (pre-existing interrupt tests)Static analysis passes:
./vendor/bin/phpstan analyse src/ROMInterface.php src/Systems/Eater/ROM.php --level=5
# [OK] No errorssrc/ROMInterface.php- Simplified interfacesrc/Systems/Eater/ROM.php- Updated implementationdocs/INSTRUCTIONS.md- Updated examplesCLAUDE.md- Updated architecture notes