-
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 2 (UxROM) (#13)
- Loading branch information
1 parent
ec43dfd
commit 8b7fcdb
Showing
3 changed files
with
42 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
39 changes: 39 additions & 0 deletions
39
GhidraNes/src/main/java/ghidranes/mappers/UxROMMapper.java
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,39 @@ | ||
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 UxROMMapper extends NesMapper { | ||
@Override | ||
public void updateMemoryMapForRom(NesRom rom, Program program, TaskMonitor monitor) throws LockException, MemoryConflictException, AddressOverflowException, CancelledException, DuplicateNameException { | ||
|
||
/* UxROM has switchable 16k PRG ROM banks mapped at 8000-FFFF. | ||
The lower bank (fixed at 8000-BFFF) is typically the first bank, and | ||
the upper bank (C000-FFFF) is switchable. */ | ||
int bankCount = rom.prgRom.length / 0x4000; | ||
|
||
// Load the fixed lower bank (first 16KB) | ||
int lowerBankPermissions = MemoryBlockDescription.READ | MemoryBlockDescription.EXECUTE; | ||
byte[] lowerBankBytes = Arrays.copyOfRange(rom.prgRom, 0, 0x4000); | ||
MemoryBlockDescription.initialized(0x8000, 0x4000, "PRG Lower", lowerBankPermissions, lowerBankBytes, false, monitor) | ||
.create(program); | ||
|
||
// Load switchable upper banks | ||
for (int bank = 1; bank < bankCount; bank++) { | ||
int upperBankPermissions = MemoryBlockDescription.READ | MemoryBlockDescription.EXECUTE; | ||
|
||
byte[] upperBankBytes = Arrays.copyOfRange(rom.prgRom, bank*0x4000, (bank+1)*0x4000); | ||
MemoryBlockDescription.initialized(0xC000, 0x4000, "PRG Upper " + bank, upperBankPermissions, upperBankBytes, bank < (bankCount - 1), 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