1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! NES Cartridge interface and components
//!
//! This crate provides the core abstractions for implementing NES cartridges.
//! A cartridge in the NES contains the game program (PRG ROM) and character data (CHR ROM/RAM),
//! along with optional hardware for memory mapping and other special features.
//!
//! # Key Components
//!
//! - `Cartridge` trait: The main interface that all cartridge implementations must provide
//! - `ChrRomContentStatus`: Tracks whether CHR ROM/RAM content has been modified
//!
//! # Example Usage
//!
//! ```no_run
//! use cge_nes::{Cartridge, ChrRomContentStatus};
//!
//! struct MyCartridge { /* ... */ }
//!
//! impl Cartridge for MyCartridge {
//! fn read_cpu_mapped(&self, addr: u16) -> u8 { /* ... */ 0 }
//! fn write_cpu_mapped(&mut self, data: u8, addr: u16) -> ChrRomContentStatus {
//! ChrRomContentStatus::Unchanged
//! }
//! fn read_ppu_mapped(&mut self, addr: u16) -> u8 { /* ... */ 0 }
//! fn write_ppu_mapped(&mut self, data: u8, addr: u16) -> ChrRomContentStatus {
//! ChrRomContentStatus::Changed
//! }
//! }
//! ```
/// Represents whether CHR ROM/RAM content has been modified during a write operation
///
/// This is used to track when character data is modified, which helps emulators know
/// when to update PPU-related caches or trigger redraws.
/// Core interface for NES cartridge implementations
///
/// This trait defines the required methods for implementing a NES cartridge,
/// providing memory mapping for both CPU and PPU address spaces.
///
/// # Memory Mapping
///
/// - CPU address space: 0x4020-0xFFFF
/// - PPU pattern tables: 0x0000-0x1FFF
///
/// # Returns
///
/// Write operations return a [`ChrRomContentStatus`] to indicate if character data was modified