@tmustier/pi-nes 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
@@ -124,33 +124,33 @@ impl Mapper for MMC1Mapper {
|
|
|
124
124
|
} else {
|
|
125
125
|
0
|
|
126
126
|
};
|
|
127
|
-
let
|
|
128
|
-
|
|
129
|
-
bank_num %= self.program_bank_num as u32;
|
|
130
|
-
}
|
|
127
|
+
let outer_offset = prg_high * 0x10;
|
|
128
|
+
let bank_num = prg_low;
|
|
131
129
|
|
|
132
130
|
match self.control_register.load_bits(2, 2) {
|
|
133
131
|
0 | 1 => {
|
|
134
132
|
// switch 32KB at 0x8000, ignoring low bit of bank number
|
|
135
133
|
// TODO: Fix me
|
|
136
134
|
offset = offset | (address & 0x4000);
|
|
137
|
-
bank = bank_num & 0x1E;
|
|
135
|
+
bank = outer_offset + (bank_num & 0x1E);
|
|
138
136
|
},
|
|
139
137
|
2 => {
|
|
140
138
|
// fix first bank at 0x8000 and switch 16KB bank at 0xC000
|
|
141
139
|
bank = match address < 0xC000 {
|
|
142
|
-
true =>
|
|
143
|
-
false => bank_num
|
|
140
|
+
true => outer_offset,
|
|
141
|
+
false => outer_offset + bank_num
|
|
144
142
|
};
|
|
145
143
|
},
|
|
146
144
|
_ /*3*/ => {
|
|
147
145
|
// fix last bank at 0xC000 and switch 16KB bank at 0x8000
|
|
148
146
|
bank = match address >= 0xC000 {
|
|
149
|
-
true =>
|
|
150
|
-
false => bank_num
|
|
147
|
+
true => outer_offset + 0x0F,
|
|
148
|
+
false => outer_offset + bank_num
|
|
151
149
|
};
|
|
152
150
|
}
|
|
153
151
|
};
|
|
152
|
+
let max_bank = self.program_bank_num as u32;
|
|
153
|
+
let bank = if max_bank > 0 { bank % max_bank } else { bank };
|
|
154
154
|
bank * 0x4000 + offset
|
|
155
155
|
}
|
|
156
156
|
|