@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.
@@ -124,33 +124,33 @@ impl Mapper for MMC1Mapper {
124
124
  } else {
125
125
  0
126
126
  };
127
- let mut bank_num = (prg_high << 4) | prg_low;
128
- if self.program_bank_num > 0 {
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 => 0,
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 => self.program_bank_num as u32 - 1,
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmustier/pi-nes",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "NES emulator extension for pi",
5
5
  "keywords": [
6
6
  "pi-package",