diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index b1d83e2..c80624e 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Revert unintended change in memory block order + ## 20221115 - 2022-11-15 ### Added diff --git a/src/main/java/fi/gekkio/ghidraboy/GameBoyLoader.java b/src/main/java/fi/gekkio/ghidraboy/GameBoyLoader.java index 3859702..9565a8c 100644 --- a/src/main/java/fi/gekkio/ghidraboy/GameBoyLoader.java +++ b/src/main/java/fi/gekkio/ghidraboy/GameBoyLoader.java @@ -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); @@ -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());