Skip to content

Commit

Permalink
Merge pull request #236 from lukexor/fxrom
Browse files Browse the repository at this point in the history
feat: added Mapper 010 - FxROM
  • Loading branch information
lukexor authored May 20, 2024
2 parents 57d323d + 4c60206 commit 7c97195
Show file tree
Hide file tree
Showing 13 changed files with 998 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ args = ["-p", "dist"]
description = "Build TetaNES Web"
category = "Build"
command = "trunk"
args = ["build", "--config", "tetanes/Cargo.toml", "--release", "--dist", "dist/web"]
args = ["build", "--config", "tetanes/Cargo.toml", "--release", "--dist", "dist/web", "--public-url", "./"]
dependencies = ["create-dist", "add-wasm-target"]

[tasks.build-all]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,14 @@ Support for the following mappers is currently implemented or in development:
| 005 | ExROM/MMC5 | Castlevania 3, Laser Invasion | ~24 | <0.01% |
| 007 | AxROM | Battletoads, Marble Madness | ~75 | ~3% |
| 009 | PxROM/MMC2 | Punch Out!! | 1 | <0.01% |
| 010 | FxROM/MMC4 | Fire Emblem Gaiden | 3 | <0.01% |
| 024 | VRC6a | Akumajou Densetsu | 1 | <0.01% |
| 026 | VRC6b | Madara, Esper Dream 2 | 2 | <0.01% |
| 034 | BNROM/NINA-001 | Deadly Towers, Impossible Mission II | 3 | <0.01% |
| 066 | GxROM/MxROM | Super Mario Bros. + Duck Hunt | ~17 | <0.01% |
| 071 | Camerica/Codemasters | Firehawk, Bee 52, MiG 29 - Soviet Fighter | ~15 | <0.01% |
| 155 | SxROM/MMC1A | Tatakae!! Ramen Man: Sakuretsu Choujin | 2 | <0.01% |
| | | | ~2091 / 2447 | ~85.5% |
| | | | ~2094 / 2447 | ~85.6% |

<!-- markdownlint-enable line-length -->

Expand Down
486 changes: 463 additions & 23 deletions tetanes-core/game_database.txt

Large diffs are not rendered by default.

Binary file modified tetanes-core/game_regions.dat
Binary file not shown.
270 changes: 258 additions & 12 deletions tetanes-core/src/cart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
fs,
mapper::{
m024_m026_vrc6::Revision as Vrc6Revision, m034_nina001::Nina001, Axrom, Bf909x, Bnrom,
Cnrom, Exrom, Gxrom, Mapper, Mmc1Revision, Nrom, Pxrom, Sxrom, Txrom, Uxrom, Vrc6,
Cnrom, Exrom, Fxrom, Gxrom, Mapper, Mmc1Revision, Nrom, Pxrom, Sxrom, Txrom, Uxrom, Vrc6,
},
mem::RamState,
ppu::Mirroring,
Expand Down Expand Up @@ -33,8 +33,6 @@ pub enum Error {
value: u8,
message: String,
},
#[error("unimplemented mapper `{0}`")]
UnimplementedMapper(u16),
#[error("{context}: {source:?}")]
Io {
context: String,
Expand Down Expand Up @@ -198,6 +196,7 @@ impl Cart {
5 => Exrom::load(&mut cart),
7 => Axrom::load(&mut cart),
9 => Pxrom::load(&mut cart),
10 => Fxrom::load(&mut cart),
24 => Vrc6::load(&mut cart, Vrc6Revision::A),
26 => Vrc6::load(&mut cart, Vrc6Revision::B),
34 => {
Expand All @@ -211,7 +210,7 @@ impl Cart {
66 => Gxrom::load(&mut cart),
71 => Bf909x::load(&mut cart),
155 => Sxrom::load(&mut cart, Mmc1Revision::A),
_ => return Err(Error::UnimplementedMapper(cart.header.mapper_num)),
_ => Mapper::none(),
};

info!("loaded ROM `{cart}`");
Expand Down Expand Up @@ -481,13 +480,15 @@ impl NesHeader {
value: header[0],
message: "nes header signature not found".to_string(),
});
} else if (header[7] & 0x0C) == 0x04 {
}
if (header[7] & 0x0C) == 0x04 {
return Err(Error::InvalidHeader {
byte: 7,
value: header[7],
message: "header is corrupted by `DiskDude!`. repair and try again".to_string(),
});
} else if (header[7] & 0x0C) == 0x0C {
}
if (header[7] & 0x0C) == 0x0C {
return Err(Error::InvalidHeader {
byte: 7,
value: header[7],
Expand Down Expand Up @@ -529,19 +530,22 @@ impl NesHeader {
value: prg_ram_shift,
message: "invalid prg-ram size in header".to_string(),
});
} else if chr_ram_shift & 0x0F == 0x0F || chr_ram_shift & 0xF0 == 0xF0 {
}
if chr_ram_shift & 0x0F == 0x0F || chr_ram_shift & 0xF0 == 0xF0 {
return Err(Error::InvalidHeader {
byte: 11,
value: chr_ram_shift,
message: "invalid chr-ram size in header".to_string(),
});
} else if chr_ram_shift & 0xF0 == 0xF0 {
}
if chr_ram_shift & 0xF0 == 0xF0 {
return Err(Error::InvalidHeader {
byte: 11,
value: chr_ram_shift,
message: "battery-backed chr-ram is currently not supported".to_string(),
});
} else if header[14] > 0 || header[15] > 0 {
}
if header[14] > 0 || header[15] > 0 {
return Err(Error::InvalidHeader {
byte: 14,
value: header[14],
Expand Down Expand Up @@ -603,15 +607,257 @@ impl NesHeader {
3 => "Mapper 003 - CNROM",
4 => "Mapper 004 - TxROM/MMC3/MMC6",
5 => "Mapper 005 - ExROM/MMC5",
6 => "Mapper 006 - FFE 1M/2M",
7 => "Mapper 007 - AxROM",
9 => "Mapper 009 - PxROM",
8 => "Mapper 008 - FFE 1M/2M", // Also Mapper 006 Submapper 4
9 => "Mapper 009 - PxROM/MMC2",
10 => "Mapper 010 - FxROM/MMC4",
11 => "Mapper 011 - Color Dreams",
12 => "Mapper 012 - Gouder/FFE 4M/MMC3",
13 => "Mapper 013 - CPROM",
14 => "Mapper 014 - UNL SL1632",
15 => "Mapper 015 - K1029/30",
16 => "Mapper 016 - Bandai FCG",
17 => "Mapper 017 - FFE",
18 => "Mapper 018 - Jaleco SS 88006",
19 => "Mapper 019 - Namco 129/163",
20 => "Mapper 020 - FDS",
21 => "Mapper 021 - Vrc4a/Vrc4c",
22 => "Mapper 022 - Vrc2a",
23 => "Mapper 023 - Vrc4e",
24 => "Mapper 024 - Vrc6a",
25 => "Mapper 025 - Vrc4b",
26 => "Mapper 026 - Vrc6b",
27 => "Mapper 027 - Vrc4x",
28 => "Mapper 028 - Action 53",
29 => "Mapper 029 - Sealie Computing",
30 => "Mapper 030 - UNROM 512",
31 => "Mapper 031 - NSF",
32 => "Mapper 032 - Irem G101",
33 => "Mapper 033 - Taito TC0190",
34 => "Mapper 034 - BNROM/NINA-001",
35 => "Mapper 035 - JY Company",
36 => "Mapper 036 - TXC 22000",
37 => "Mapper 037 - MMC3 Multicart",
38 => "Mapper 038 - UNL PCI556",
39 => "Mapper 039 - Subor",
40 => "Mapper 040 - NTDEC 2722",
41 => "Mapper 041 - Caltron 6-in-1",
42 => "Mapper 042",
43 => "Mapper 043 - TONY-I/YS-612",
44 => "Mapper 044 - MMC3 Multicart",
45 => "Mapper 045 - MMC3 Multicart",
46 => "Mapper 046 - Color Dreams",
47 => "Mapper 047 - MMC3 Multicart",
48 => "Mapper 048 - Taito TC0690",
49 => "Mapper 049 - MMC Multicart",
50 => "Mapper 050",
51 => "Mapper 051",
52 => "Mapper 052 - Realtec 8213/MMC Multicaart",
53 => "Mapper 053 - Supervision",
54 => "Mapper 054 - Novel Diamond",
55 => "Mapper 055 - UNIF BTL-MARIO1-MALEE2",
56 => "Mapper 056",
57 => "Mapper 057",
58 => "Mapper 058",
59 => "Mapper 059 - BMC T3H53/D1038",
60 => "Mapper 060",
61 => "Mapper 061",
62 => "Mapper 062",
63 => "Mapper 063",
64 => "Mapper 064 - RAMBO-1",
65 => "Mapper 065 - Irem H3001",
66 => "Mapper 066 - GxROM/MxROM",
71 => "Mapper 071 - Camerica/Codemasters/BF909x",
67 => "Mapper 067 - Sunsoft-3",
68 => "Mapper 068 - Sunsoft-4",
69 => "Mapper 069 - Sunsoft FME-7",
70 => "Mapper 070 - Bandai",
71 => "Mapper 071 - BF909x",
72 => "Mapper 072 - Jaleco JF-17",
73 => "Mapper 073 - Vrc3",
74 => "Mapper 074",
75 => "Mapper 075 - Vrc1",
76 => "Mapper 076 - NAMCOT-108",
77 => "Mapper 077",
78 => "Mapper 078",
79 => "Mapper 079 - NINA-03/06",
80 => "Mapper 080 - Taito X1005",
81 => "Mapper 081 - NTDEC 715021",
82 => "Mapper 082 - Taito X1017",
83 => "Mapper 083",
84 => "Mapper 084",
85 => "Mapper 085 - Vrc7",
86 => "Mapper 086 - Jaleco JF-13",
87 => "Mapper 087 - Jaleco JF-xx",
88 => "Mapper 088",
89 => "Mapper 089 - Sunsoft",
90 => "Mapper 090 - JY Company",
91 => "Mapper 091",
92 => "Mapper 092",
93 => "Mapper 093 - Sunsoft",
94 => "Mapper 094 - UxROM",
95 => "Mapper 095 - NAMCOT-3425",
96 => "Mapper 096 - Oeka Kids",
97 => "Mapper 097 - Irem TAM-S1",
98 => "Mapper 098",
99 => "Mapper 099 - Vs. System",
100 => "Mapper 100",
101 => "Mapper 101 - Jaleco JF-10",
102 => "Mapper 102",
103 => "Mapper 103",
104 => "Mapper 104 - Golden Five",
105 => "Mapper 105 - MMC1",
106 => "Mapper 106",
107 => "Mapper 107",
108 => "Mapper 108",
109 => "Mapper 109",
110 => "Mapper 110",
111 => "Mapper 111 - GTROM",
112 => "Mapper 112",
113 => "Mapper 113 - NINA-03/06",
114 => "Mapper 114 - MMC3",
115 => "Mapper 115 - MMC3",
116 => "Mapper 116 - SOMARI-P",
117 => "Mapper 117",
118 => "Mapper 118 - TxSROM",
119 => "Mapper 119 - TQROM",
120 => "Mapper 120",
121 => "Mapper 121 - MMC3",
122 => "Mapper 122",
123 => "Mapper 123 - MMC3",
124 => "Mapper 124",
125 => "Mapper 125 - UNL-LH32",
126 => "Mapper 126 - MMC36",
127 => "Mapper 127",
128 => "Mapper 128",
129 => "Mapper 129",
130 => "Mapper 130",
131 => "Mapper 131",
132 => "Mapper 132 - TXC",
133 => "Mapper 133 - Sachen 3009",
134 => "Mapper 134 - MMC3",
135 => "Mapper 135 - Sachen 8259A",
136 => "Mapper 136 - Sachen 3011",
137 => "Mapper 137 - Sachen 8259D",
138 => "Mapper 138 - Sachen 8259B",
139 => "Mapper 139 - Sachen 8259C",
140 => "Mapper 140 - Jaleco JF-11/14",
141 => "Mapper 141 - Sachen 8259A",
142 => "Mapper 142 - Kaiser KS-7032",
143 => "Mapper 143 - NROM",
144 => "Mapper 144 - Color Dreams",
145 => "Mapper 145 - Sachen SA-72007",
146 => "Mapper 146 - NINA-03/06",
147 => "Mapper 147 - Sachen 3018",
148 => "Mapper 148 - Sachen SA-008-A/Tengen 800008",
149 => "Mapper 149 - Sachen SA-0036",
150 => "Mapper 150 - Sach SA-015/630",
151 => "Mapper 151 - Vrc1",
152 => "Mapper 152",
153 => "Mapper 153 - Bandai FCG",
154 => "Mapper 154 - NAMCOT-3453",
155 => "Mapper 155 - SxROM/MMC1A",
_ => "Unimplemented Mapper",
156 => "Mapper 156 - Daou",
157 => "Mapper 157 - Bandai FCG",
158 => "Mapper 158 - Tengen 800037",
159 => "Mapper 159 - Bandai FCG",
160 => "Mapper 160",
161 => "Mapper 161",
162 => "Mapper 162 - Wàixīng",
163 => "Mapper 163 - Nánjīng",
164 => "Mapper 164 - Dōngdá/Yànchéng",
165 => "Mapper 165 - MMC3",
166 => "Mapper 166 - Subor",
167 => "Mapper 167 - Subor",
168 => "Mapper 168 - Racermate",
169 => "Mapper 169 - Yuxing",
170 => "Mapper 170",
171 => "Mapper 171 - Kaiser KS-7058",
172 => "Mapper 172",
173 => "Mapper 173",
174 => "Mapper 174",
175 => "Mapper 175 - Kaiser KS-7022",
176 => "Mapper 176 - MMC3",
177 => "Mapper 177 - Hénggé Diànzǐ",
178 => "Mapper 178",
179 => "Mapper 179",
180 => "Mapper 180 - UNROM",
181 => "Mapper 181",
182 => "Mapper 182 - MMC3",
183 => "Mapper 183",
184 => "Mapper 184 - Sunsoft",
185 => "Mapper 185 - CNROM",
186 => "Mapper 186",
187 => "Mapper 187 - Kǎshèng/MMC3",
188 => "Mapper 188 - Bandai Karaoke",
189 => "Mapper 189 - MMC3",
190 => "Mapper 190 -",
191 => "Mapper 191 - MMC3",
192 => "Mapper 192 - Wàixīng",
193 => "Mapper 193 - NTDEC TC-112",
194 => "Mapper 194 - MMC3",
195 => "Mapper 195 - Wàixīng/MMC3",
196 => "Mapper 196 - MMC3",
197 => "Mapper 197 - MMC3",
198 => "Mapper 198 - MMC3",
199 => "Mapper 199 - Wàixīng/MMC3",
200 => "Mapper 200",
201 => "Mapper 201 - NROM",
202 => "Mapper 202",
203 => "Mapper 203",
204 => "Mapper 204",
205 => "Mapper 205 - MMC3",
206 => "Mapper 206 - DxROM",
207 => "Mapper 207 - Taito X1-005",
208 => "Mapper 208 - MMC3",
209 => "Mapper 209 - JY Company",
210 => "Mapper 210 - Namco",
211 => "Mapper 211 - JyCompany",
212 => "Mapper 212",
213 => "Mapper 213",
214 => "Mapper 214",
215 => "Mapper 215 - MMC3",
216 => "Mapper 216",
217 => "Mapper 217 - MMC3",
218 => "Mapper 218",
219 => "Mapper 219 - Kǎshèng/MMC3",
220 => "Mapper 220",
221 => "Mapper 221 - NTDEC N625092",
222 => "Mapper 222",
223 => "Mapper 223",
224 => "Mapper 224 - Jncota/MMC3",
225 => "Mapper 225",
226 => "Mapper 226",
227 => "Mapper 227",
228 => "Mapper 228- Active Enterprises",
229 => "Mapper 229",
230 => "Mapper 230",
231 => "Mapper 231",
232 => "Mapper 232 - BF909x",
233 => "Mapper 233",
234 => "Mapper 234 - Maxi 15 Multicart",
235 => "Mapper 235",
236 => "Mapper 236 - Realtec",
237 => "Mapper 237",
238 => "Mapper 238 - MMC3",
239 => "Mapper 239",
240 => "Mapper 240",
241 => "Mapper 241 - BxROM",
242 => "Mapper 242",
243 => "Mapper 243 - Sachen SA-020A",
244 => "Mapper 244",
245 => "Mapper 245 - Wàixīng/MMC3",
246 => "Mapper 246",
247 => "Mapper 247",
248 => "Mapper 248",
249 => "Mapper 249 - MMC3",
250 => "Mapper 250 - Nitra/MMC3",
251 => "Mapper 251",
252 => "Mapper 252 - Wàixīng",
253 => "Mapper 253 - Wàixīng",
254 => "Mapper 254 - MMC3",
255 => "Mapper 255",
_ => "Invalid Mapper",
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions tetanes-core/src/control_deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub enum Error {
/// Invalid file path.
#[error("invalid file path {0:?}")]
InvalidFilePath(PathBuf),
#[error("unimplemented mapper `{0}`")]
UnimplementedMapper(u16),
/// Filesystem error.
#[error(transparent)]
Fs(#[from] fs::Error),
Expand Down Expand Up @@ -283,6 +285,9 @@ impl ControlDeck {
let name = name.to_string();
self.unload_rom()?;
let cart = Cart::from_rom(&name, rom, self.cpu.bus.ram_state)?;
if cart.mapper.is_none() {
return Err(Error::UnimplementedMapper(cart.mapper_num()));
}
let loaded_rom = LoadedRom {
name: name.clone(),
battery_backed: cart.battery_backed(),
Expand Down
Loading

0 comments on commit 7c97195

Please sign in to comment.