Skip to content

Commit

Permalink
ws: Properly load trimmed cartridge ROMs - starting from the end of t…
Browse files Browse the repository at this point in the history
…he address space.
  • Loading branch information
asiekierka authored and LukeUsher committed Sep 14, 2023
1 parent 546aed6 commit 8ba3bd6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ares/ws/cartridge/cartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ auto Cartridge::connect() -> void {
if(pak->attribute("orientation") == "horizontal") information.orientation = "Horizontal";
if(pak->attribute("orientation") == "vertical" ) information.orientation = "Vertical";

// WS cartridges are allocated from the top (end of ROM) down
if(auto fp = pak->read("program.flash")) {
rom.allocate(fp->size());
rom.load(fp);
rom.allocate(bit::round(fp->size()));
fp->read({rom.data() + bit::round(fp->size()) - fp->size(), fp->size()});
has.flash = true;
} else if(auto fp = pak->read("program.rom")) {
rom.allocate(fp->size());
rom.load(fp);
rom.allocate(bit::round(fp->size()));
fp->read({rom.data() + bit::round(fp->size()) - fp->size(), fp->size()});
}

if(auto fp = pak->read("save.ram")) {
Expand Down

0 comments on commit 8ba3bd6

Please sign in to comment.