How ergoadams/arbne works
Main components
• Emulator (driver): The central hub that likely initializes and connects all hardware emulation modules.
• CPU (cpu.py): Emulates the processor responsible for executing the game/program instructions.
• PPU (ppu.py): Handles graphics, including background rendering and sprite management.
• Bus (bus.py): Interconnects the CPU, PPU, and other memory modules, managing read/write operations.
• Cartridge (cartridge.py): Simulates the game cartridge from which ROM data is loaded. It might also contain additional ROM/RAM regions.
• Mapper (mapper.py): Handles memory mapping, allowing support for different cartridge mapping hardware.
• (Optional) Additional components may include aspects such as debugging support or a test harness (referenced in the README TODOs).
Their interactions
• The Emulator module coordinates the initialization and running of emulation cycles, triggering updates in the CPU and PPU.
• The CPU communicates with both the Cartridge (via the Bus) to fetch instructions and data, and with the Mapper to translate addresses.
• The PPU reads from the Cartridge and through the Mapper for graphics data, and processes background and sprite rendering.
• The Bus sits in the middle, facilitating bidirectional data transfer between the CPU, PPU, and Cartridge.
• The Mapper acts as a translation layer for memory addresses, affecting both CPU and PPU reads for correct ROM/RAM mapping.
Architectural patterns and design principles
• Modularity: Each major hardware component is encapsulated in its own module/file, allowing isolation and independent testing.
• Emulation Loop: The Emulator likely maintains an emulation loop that simulates clock cycles, coordinating updates across CPU, PPU, and bus activities.
• Data Flow Abstraction: Communication flows via the bus and address mapping (handled by the mapper) reflect clear separation of concerns.