-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for mapper 10 (MMC4) (#15)
- Loading branch information
1 parent
52b20db
commit ec43dfd
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ghidranes.mappers; | ||
|
||
import java.util.Arrays; | ||
|
||
import ghidra.framework.store.LockException; | ||
import ghidra.program.model.address.AddressOverflowException; | ||
import ghidra.program.model.listing.Program; | ||
import ghidra.program.model.mem.MemoryConflictException; | ||
import ghidra.util.exception.CancelledException; | ||
import ghidra.util.exception.DuplicateNameException; | ||
import ghidra.util.task.TaskMonitor; | ||
import ghidranes.NesRom; | ||
import ghidranes.util.MemoryBlockDescription; | ||
|
||
|
||
public class MMC4Mapper extends NesMapper { | ||
@Override | ||
public void updateMemoryMapForRom(NesRom rom, Program program, TaskMonitor monitor) throws LockException, MemoryConflictException, AddressOverflowException, CancelledException, DuplicateNameException { | ||
int sramPermissions = MemoryBlockDescription.READ | MemoryBlockDescription.WRITE | MemoryBlockDescription.EXECUTE; | ||
MemoryBlockDescription.uninitialized(0x6000, 0x2000, "SRAM", sramPermissions, false).create(program); | ||
|
||
int romPermissions = MemoryBlockDescription.READ | MemoryBlockDescription.EXECUTE; | ||
for (int bank = 0; bank * 0x4000 < rom.prgRom.length; bank++) { | ||
byte[] rombankBytes = Arrays.copyOfRange(rom.prgRom, bank * 0x4000, (bank + 1) * 0x4000); | ||
MemoryBlockDescription.initialized(0x8000, 0x4000, "PRG" + bank, romPermissions, rombankBytes, bank != 0, monitor).create(program); | ||
} | ||
|
||
int lastBank = rom.prgRom.length / 0x4000 - 1; | ||
byte[] lastBankBytes = Arrays.copyOfRange(rom.prgRom, lastBank * 0x4000, (lastBank + 1) * 0x4000); | ||
MemoryBlockDescription.initialized(0xC000, 0x4000, "PRG" + lastBank + "_MIRROR", romPermissions, lastBankBytes, false, monitor).create(program); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters