Skip to content

Commit

Permalink
Revert unintended change in memory block order
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekkio committed Nov 16, 2022
1 parent c135665 commit bfacaa3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Revert unintended change in memory block order

## 20221115 - 2022-11-15

### Added
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/fi/gekkio/ghidraboy/GameBoyLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,18 @@ protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec, List
var banked = provider.length() > 0x8000;
try {
createInitializedBlock(program, false, banked ? "rom0" : "rom", as.getAddress(0x0000), rom, 0, banked ? 0x4000 : 0x8000, "Cartridge ROM (offset 0)", getName(), true, false, true, log);
if (banked) {
var romX = as.getAddress(0x4000);
var offset = 0x4000;
var bank = 1;
while (offset < rom.getSize()) {
createInitializedBlock(program, true, "rom" + bank, romX, rom, offset, 0x4000, "Cartridge ROM (offset %d)".formatted(offset), getName(), true, false, true, log);
offset += 0x4000;
bank += 1;
}
}
createUninitializedBlock(program, false, "xram", as.getAddress(0xa000), 0x2000, "Cartridge RAM", getName(), true, true, true, log);

var st = program.getSymbolTable();
st.createLabel(as.getAddress(0x0000), "rst00", SourceType.IMPORTED);
st.createLabel(as.getAddress(0x0008), "rst08", SourceType.IMPORTED);
Expand All @@ -196,17 +207,6 @@ protected boolean loadProgramInto(ByteProvider provider, LoadSpec loadSpec, List
} catch (OverlappingFunctionException e) {
log.appendException(e);
}

if (banked) {
var romX = as.getAddress(0x4000);
var offset = 0x4000;
var bank = 1;
while (offset < rom.getSize()) {
createInitializedBlock(program, true, "rom" + bank, romX, rom, offset, 0x4000, "Cartridge ROM (offset %d)".formatted(offset), getName(), true, false, true, log);
offset += 0x4000;
bank += 1;
}
}
} catch (AddressOverflowException | InvalidInputException e) {
log.appendException(e);
throw new CancelledException("Loading failed: " + e.getMessage());
Expand Down

0 comments on commit bfacaa3

Please sign in to comment.