215. Ines rom dataclass
add
Lesson 215 of 356 · tests/chapter_02_rom_loading/test_215_ines_rom_dataclass.py
add emulator/cartridge/ines.py::INesRom.
Why this step exists
This immutable parser result keeps the interpreted header and extracted program and graphics sections together so parse_ines_rom need not return loose values. It builds on the header model and parser from lessons 213-214.
Suggested implementation after parse_ines_header:
@dataclass(frozen=True)
class INesRom:
header: INesHeader
prg_rom: bytes
chr_rom: bytesInvariants: the field order is header, prg_rom, chr_rom; both payloads are bytes; and the dataclass is frozen because it describes file contents. Do not confuse this format-level result with the emulator-facing Cartridge.
Out of scope for this step
1. Lesson 216 calculates offsets, skips trainers, and validates payload size.
2. Lesson 217 introduces the emulator-facing `Cartridge`.
3. Lessons 218-219 implement mapper address translation.Run this lesson
uv run pytest tests/chapter_02_rom_loading/test_215_ines_rom_dataclass.py -v